/**ใช้รวมไฟล์ย่อยๆ ของ api แต่ละไฟล์ */

/** API Metadata */
import manageOrganization from "./api/manage/api.organization";
import managePerson from "./api/manage/api.person";
import managePosition from "./api/manage/api.position";
import managePositionEmployee from "./api/manage/api.positionEmployee";
import manageInsignia from "./api/manage/api.insignia";
import manageHoliday from "./api/manage/api.holiday";

/** API Tree List */
import organizationTreeList from "./api/02_organizational/api.treelist";

/** API Structure & Org Chart */
import organizationChart from "./api/02_organizational/api.chart";

/** API periodexam List */
import periodexam from "./api/recruiting/api.period-exam";
import disableexam from "./api/recruiting/api.disable";

/** API Recruit List */
import recruit from "./api/recruiting/api.recruit";

/** API Profile List */
import profile from "./api/registry/api.profile";
import registry from "./api/registry/api.registry";

/** API Report2 List */
import report2 from "./api/recruiting/api.report2";

/** API ระบบการบรรจุ แต่งตั้ง ย้าย โอน List */
import placement from "./api/05_placement/api.placement";
import probation from "./api/05_placement/api.probation";

/** API ระบบการพ้นจากราชการ List */
import retirement from "./api/06_retirement/api.retirement";

/** API ระบบงานเครื่องราชอิสริยาภรณ์ List */
import insignia from "./api/07_insignia/api.insignia";

/** API dashboard  */
import message from "./api/00_dashboard/api.message";

/** API reports  */
import reports from "./api/reports/api.report";

/** API ระบบลงเวลา */
import leave from "./api/09_leave/api.leave";

/** API วินัย */
import discipline from "./api/11_discipline/api.discipline";

/**API ประเมิน */
import evaluate from "./api/12_evaluatePersonal/api.evaluate";

/** API โครงสร้างอัตรากำลัง*/
import organization from "./api/02_organizational/api.organization";

import support from "./api/00_support/api.support";

/** API เงินเดือน/ค่าจ้าง*/
import salary from "./api/13_salary/api.salary";

/** API ระเมินผลการปฏิบัติราชการระดับบุคคล*/
import KPI from "./api/14_KPI/api.KPI";

/** API เงินเดือน/ค่าจ้าง*/
import development from "./api/15_development/api.development";

/** ออกคำสั่งใหม่ */
import command from "./api/18_command/api.command";

import file from "./api/file/api.file";

// environment variables
export const compettitivePanel = import.meta.env.VITE_COMPETITIVE_EXAM_PANEL;
export const qualifyDisableExamPanel = import.meta.env
  .VITE_QUALIFY_DISABLE_EMAM_PANEL;
export const qualifyExamPanel = import.meta.env.VITE_QUALIFY_EXAM_PANEL;
export const s3ClusterUrl = import.meta.env.VITE_S3CLUSTER_PUBLIC_URL;

const API = {
  //Metadata
  ...manageOrganization,
  ...managePerson,
  ...managePosition,
  ...managePositionEmployee,
  ...manageInsignia,
  ...manageHoliday,

  // โครงสร้างอัตรากำลัง
  ...organization,

  //Tree List
  ...organizationTreeList,
  ...organizationChart,

  //periodexam
  ...periodexam,
  ...disableexam,

  // recruit
  ...recruit,

  //profile
  ...profile,
  ...registry,

  //report2
  ...report2,

  ...placement,
  ...probation,
  ...retirement,
  ...insignia,

  //dashboard
  ...message,

  //reports
  ...reports,

  /**leave */
  ...leave,

  /**discipline */
  ...discipline,

  /**evaluate*/
  ...evaluate,

  /** support */
  ...support,

  ...salary,
  ...KPI,
  ...development,

  /** ออกคำสั่งใหม่ */
  ...command,

  /*file*/
  ...file,
};

const path =
  import.meta.env.VITE_MANUAL_URL ??
  "https://bma-ehr-manual.frappet.synology.me";

const generatePopupPath = (routeName: any) => {
  console.log("🚀 ~ generatePopupPath ~ routeName:", routeName);
  if (routeName.includes("metadata")) {
    return `${path}/manual/chapter-2-admin-metadata`;
  } else if (routeName.includes("registryNew")) {
    return `${path}/manual/chapter-6-1-admin-registry`;
  } else if (routeName.includes("registryEmployeeList")) {
    return `${path}/manual/chapter-6-2-admin-registry`;
  } else if (routeName.includes("registry-employee")) {
    return `${path}/manual/chapter-6-3-admin-registry`;
  } else if (routeName.includes("insignia")) {
    return `${path}/manual/chapter-13-admin-insignia`;
  } else if (routeName.includes("acting")) {
    return `${path}/manual/chapter-4-admin-acting`;
  } else if (routeName.includes("positionEmployee")) {
    return `${path}/manual/chapter-5-admin-position-employee`;
  } else if (routeName.includes("resign")) {
    return `${path}/manual/chapter-12-admin-retirement`;
  } else if (routeName.includes("retirement")) {
    return `${path}/manual/chapter-12-admin-retirement`;
  } else if (routeName.includes("deceased")) {
    return `${path}/manual/chapter-12-admin-retirement`;
  } else if (routeName.includes("exit-Interview")) {
    return `${path}/manual/chapter-12-admin-retirement`;
  } else if (routeName.includes("expulsion")) {
    return `${path}/manual/chapter-12-admin-retirement`;
  } else if (routeName.includes("discharged")) {
    return `${path}/manual/chapter-12-admin-retirement`;
  } else if (routeName.includes("disciplineComplaints")) {
    return `${path}/manual/chapter-14-admin-discipline-complaints`;
  } else if (routeName.includes("disciplineInvestigatefacts")) {
    return `${path}/manual/chapter-14-2-admin-discipline-investigatefacts`;
  } else if (routeName.includes("disciplineDisciplinary")) {
    return `${path}/manual/chapter-14-3-admin-discipline-disciplinary`;
  } else if (routeName.includes("disciplineResult")) {
    return `${path}/manual/chapter-14-4-admin-discipline-result`;
  } else if (routeName.includes("disciplineListSuspend")) {
    return `${path}/manual/chapter-14-5-admin-discipline-suspend`;
  } else if (routeName.includes("appealComplain")) {
    return `${path}/manual/chapter-14-6-admin-discipline-appealcomplain`;
  } else if (routeName.includes("disciplineDirector")) {
    return `${path}/manual/chapter-14-7-admin-discipline-director`;
  } else if (routeName.includes("disciplineChannel")) {
    return `${path}/manual/chapter-14-7-2-admin-discipline-channel`;
  } else if (routeName.includes("KPIIndicatorByPlan")) {
    return `${path}/manual/chapter-2-admin-evaluate`;
  } else if (routeName.includes("KPIIndicatorByRole")) {
    return `${path}/manual/chapter-2-1-2-admin-evaluate`;
  } else if (routeName.includes("KPIAssignment")) {
    return `${path}/manual/chapter-2-1-3-admin-evaluate`;
  } else if (routeName.includes("KPICompetency")) {
    return `${path}/manual/chapter-2-2-admin-evaluate`;
  } else if (routeName.includes("strategic")) {
    return `${path}/manual/chapter-2-3-admin-evaluate`;
  } else if (routeName == "commandListPage") {
    return `${path}/manual/chapter-7-admin-order`;
  } else if (routeName == "competePeriod") {
    return `${path}/manual/chapter-8-3-admin-compete-period`;
  } else if (routeName == "qualifyPeriod") {
    return `${path}/manual/chapter-8-4-1-admin-qualify-period`;
  } else if (routeName == "disablePeriod") {
    return `${path}/manual/chapter-8-4-2-admin-disable-period`;
  } else if (routeName == "manage") {
    return `${path}/manual/chapter-8-4-3-admin-qualify-manage`;
  } else if (routeName == "qualifyPeriodStat") {
    return `${path}/manual/chapter-8-4-4-admin-qualify-period-stat`;
  } else if (routeName == "qualifyPeriodStatDisable") {
    return `${path}/manual/chapter-8-4-5-admin-qualify-disable-stat`;
  } else if (routeName.includes("competePeriodStat")) {
    return `${path}/manual/chapter-8-3-2-admin-compete-period-stat`;
  } else if (routeName.includes("probation")) {
    return `${path}/manual/chapter-10-admin-probation`;
  } else if (routeName.includes("insigniaProposals")) {
    return `${path}/manual/chapter-12-admin-insignia`;
  } else if (routeName.includes("insigniaManage")) {
    return `${path}/manual/chapter-12-2-admin-insignia`;
  } else if (routeName.includes("insigniaRecord")) {
    return `${path}/manual/chapter-12-3-admin-insignia`;
  } else if (routeName.includes("insigniaAllocate")) {
    return `${path}/manual/chapter-12-4-admin-insignia`;
  } else if (routeName.includes("insigniaBorrow")) {
    return `${path}/manual/chapter-12-5-admin-insignia`;
  } else if (routeName.includes("insigniaReport")) {
    return `${path}/manual/chapter-12-6-admin-insignia`;
  } else if (routeName.includes("roundTime")) {
    return `${path}/manual/chapter-13-admin-leave`;
  } else if (routeName.includes("workList")) {
    return `${path}/manual/chapter-13-2-admin-leave`;
  } else if (routeName.includes("changeRound")) {
    return `${path}/manual/chapter-13-3-admin-leave`;
  } else if (routeName.includes("timestampSpecial")) {
    return `${path}/manual/chapter-13-4-admin-leave`;
  } else if (routeName == "leave") {
    return `${path}/manual/chapter-13-5-admin-leave`;
  } else if (routeName == "leaveReport") {
    return `${path}/manual/chapter-13-6-admin-leave`;
  } else if (
    routeName.includes("qualify") ||
    routeName.includes("recruiting") ||
    routeName.includes("compete") ||
    routeName.includes("disable") ||
    routeName.includes("manage")
  ) {
    return `${path}/manual/chapter-9-admin-recruit`;
  } else if (routeName.includes("developmentMain")) {
    return `${path}/manual/chapter-18-admin-development`;
  } else if (routeName.includes("developmentHistory")) {
    return `${path}/manual/chapter-18-2-admin-development-history`;
  } else if (routeName.includes("developmentEmployeeHistory")) {
    return `${path}/manual/chapter-18-3-admin-development-employee-history`;
  } else if (routeName.includes("developmentScholarship")) {
    return `${path}/manual/chapter-18-4-admin-development-scholarship`;
  } else if (routeName == "evaluate") {
    return `${path}/manual/chapter-15-admin-KPI`;
  } else if (routeName == "evaluateDirector") {
    return `${path}/manual/chapter-15-2-admin-KPI`;
  } else if (routeName == "evaluateMeeting") {
    return `${path}/manual/chapter-15-2-2-admin-KPI`;
  } else if (routeName == "salaryChart") {
    return `${path}/manual/chapter-16-admin-salary`;
  } else if (routeName == "salaryEmployeeChart") {
    return `${path}/manual/chapter-16-2-admin-salary`;
  } else if (routeName == "salaryRound") {
    return `${path}/manual/chapter-16-3-admin-salary`;
  } else if (routeName == "salaryLists") {
    return `${path}/manual/chapter-16-4-admin-salary`;
  } else if (routeName == "salaryEmployeeLists") {
    return `${path}/manual/chapter-16-5-admin-salary`;
  } else if (routeName == "KPIRound") {
    return `${path}/manual/chapter-17-admin-development`;
  } else if (routeName == "KPI​List") {
    return `${path}/manual/chapter-17-2-admin-development-history`;
  } else if (routeName == "KPIResults") {
    return `${path}/manual/chapter-17-3-admin-development-employee-history`;
  } else if (routeName == "KPIReport") {
    return `${path}/manual/chapter-17-4-admin-development-scholarship`;
  } else {
    return manualConfig[routeName as keyof typeof manualConfig];
  }
};

const manualConfig = {
  dashboard: `${path}/`,
  strategic: `${path}/manual/chapter-2-admin-evaluate`,
  KPIIndicatorByRoleAdd: `${path}/manual/chapter-2-admin-evaluate`,
  KPIIndicatorByPlan: `${path}/manual/chapter-2-admin-evaluate`,
  "KPIIndicatorByPlan/Add": `${path}/manual/chapter-2-admin-evaluate`,
  KPIIndicatorByPlanByid: `${path}/manual/chapter-2-admin-evaluate`,
  KPIIndicatorByRoleByid: `${path}/manual/chapter-2-admin-evaluate`,
  KPICompetency: `${path}/manual/chapter-2-admin-evaluate`,
  KPIAssignment: `${path}/manual/chapter-2-admin-evaluate`,
  KPIAssignmentById: `${path}/manual/chapter-2-admin-evaluate`,
  KPIIndicatorByRole: `${path}/manual/chapter-2-admin-evaluate`,
  KPICompetencyAdd: `${path}/manual/chapter-2-admin-evaluate`,
  KPICompetencyByid: `${path}/manual/chapter-2-admin-evaluate`,
  organizationalNew: `${path}/manual/chapter-3-admin-organization`,
  organization: `${path}/manual/chapter-6-admin-registry`,
  registry: `${path}/manual/chapter-6-admin-registry`,
  registryDetail: `${path}/manual/chapter-6-admin-registry`,
  verified: `${path}/manual/chapter-6-admin-registry`,
  order: `${path}/manual/chapter-8-admin-order`,
  OrderDetail: `${path}/manual/chapter-8-admin-order`,
  OrderAdd: `${path}/manual/chapter-8-admin-order`,
  editorweb: `${path}/manual/chapter-8-admin-recruit`,

  placement: `${path}/manual/chapter-9-admin-placement`,
  transfer: `${path}/manual/chapter-9-2-admin-transfer`,
  receive: `${path}/manual/chapter-9-3-admin-receive`,
  "help-government": `${path}/manual/chapter-9-4-admin-help-government`,
  repatriate: `${path}/manual/chapter-9-5-admin-repatriate`,
  "appoint-promote": `${path}/manual/chapter-9-6-admin-appoint-promote`,
  "appoint-employee": `${path}/manual/chapter-9-7-admin-appoint-employee`,
  other: `${path}/manual/chapter-9-8-admin-other`,

  probation: `${path}/manual/chapter-11-admin-probation`,
  probationDetail: `${path}/manual/chapter-11-admin-probation`,
  probationForm: `${path}/manual/chapter-11-admin-probation`,
  retirement: `${path}/manual/chapter-12-admin-retirement`,
  resign: `${path}/manual/chapter-12-admin-retirement`,
  ExitInterviewEditQuestion: `${path}/manual/chapter-12-admin-retirement`,
  "dismiss-order": `${path}/manual/chapter-12-admin-retirement`,
  "report-report": `${path}/manual/chapter-13-admin-insignia`,
  "report-report-01": `${path}/manual/chapter-13-admin-insignia`,
  roundTime: `${path}/manual/chapter-14-admin-leave`,
  changeRound: `${path}/manual/chapter-14-admin-leave`,
  workList: `${path}/manual/chapter-14-admin-leave`,
  timestampSpecial: `${path}/manual/chapter-14-admin-leave`,
  leave: `${path}/manual/chapter-14-admin-leave`,
  leaveDetail: `${path}/manual/chapter-14-admin-leave`,
  leaveRejectDetail: `${path}/manual/chapter-14-admin-leave`,
  leaveReport: `${path}/manual/chapter-14-admin-leave`,
  appealComplain: `${path}/manual/chapter-15-admin-discipline`,
  // KPIRound: `${path}/manual/chapter-18-admin-perf-evaluation`,
  // "KPI​List": `${path}/manual/chapter-18-admin-perf-evaluation`,
  // KPIDetail: `${path}/manual/chapter-18-admin-perf-evaluation`,
  // KPIReport: `${path}/manual/chapter-18-admin-perf-evaluation`,
  // KPIDetailnew: `${path}/manual/chapter-18-admin-perf-evaluation`,
};

export default {
  API: API,
  compettitivePanel,
  qualifyDisableExamPanel,
  qualifyExamPanel,
  s3ClusterUrl,
  manualConfig,
  generatePopupPath,
};
