/**ใช้รวมไฟล์ย่อยๆ ของ 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";

/** socket */
import socket from "./api/socket";

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;

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,

  /*socket*/
  ...socket,
};

const path = import.meta.env.VITE_MANUAL_URL ?? "";

const generatePopupPath = (routeName: any) => {
  if (routeName.includes("metadata")) {
    return `${path}/chapter-2-admin-metadata`;
  } else if (
    routeName == "registryNew" ||
    routeName == "registryNewByid" ||
    routeName == "registryNewRequestEdit"
  ) {
    return `${path}/chapter-2-1-admin-registry`;
  } else if (
    routeName == "registryEmployeeList" ||
    routeName == "registryNewEmployeeByid" ||
    routeName == "registryNewRequestEditEMP"
  ) {
    return `${path}/chapter-2-2-admin-registry`;
  } else if (
    routeName == "registry-employee" ||
    routeName == "registry-employeeId"
  ) {
    return `${path}/chapter-2-3-admin-registry`;
  } else if (routeName == "registryRetireOfficer") {
    return `${path}/chapter-3-admin-registry-retire-officer`;
  } else if (routeName == "registryRetireEmployee") {
    return `${path}/chapter-3-2-admin-registry-retire-employee`;
  } else if (routeName.includes("acting")) {
    return `${path}/chapter-7-admin-acting`;
  } else if (routeName.includes("positionEmployee")) {
    return `${path}/chapter-5-admin-position-employee`;
  } else if (
    routeName == "retirement" ||
    routeName == "retirementidDetail" ||
    routeName == "retirementid"
  ) {
    return `${path}/chapter-14-admin-retirement`;
  } else if (
    routeName == "resign" ||
    routeName == "resignbyid" ||
    routeName == "resignDetailreject" ||
    routeName == "resignDetailbyid" ||
    routeName == "resignReject"
  ) {
    return `${path}/chapter-14-2-admin-retirement`;
  } else if (
    routeName == "resignEmployee" ||
    routeName == "resignDetailbyidEMP" ||
    routeName == "resignbyidEMP" ||
    routeName == "resignDetailrejectEMP" ||
    routeName == "resignRejectEMP"
  ) {
    return `${path}/chapter-14-3-admin-retirement`;
  } else if (
    routeName == "exit-Interview" ||
    routeName == "exit-Interview-details" ||
    routeName == "exit-Interview-detailsOnly" ||
    routeName == "ExitInterviewEditQuestion"
  ) {
    return `${path}/chapter-14-4-admin-retirement`;
  } else if (
    routeName == "deceased" ||
    routeName == "deceased-detail" ||
    routeName == "deceased-detailByid"
  ) {
    return `${path}/chapter-14-5-admin-retirement`;
  } else if (
    routeName == "dismiss-order" ||
    routeName == "outDetail" ||
    routeName == "outDetailOnly"
  ) {
    return `${path}/chapter-14-6-admin-retirement`;
  } else if (
    routeName == "dismiss-order-emp" ||
    routeName == "outDetailEmp" ||
    routeName == "outDetailOnlyEmp"
  ) {
    return `${path}/chapter-14-7-admin-retirement`;
  } else if (routeName == "retireReport") {
    return `${path}/chapter-14-8-admin-retirement`;
  } else if (routeName.includes("disciplineComplaints")) {
    return `${path}/chapter-17-admin-discipline-complaints`;
  } else if (routeName.includes("disciplineInvestigatefacts")) {
    return `${path}/chapter-17-2-admin-discipline-investigatefacts`;
  } else if (routeName.includes("disciplineDisciplinary")) {
    return `${path}/chapter-17-3-admin-discipline-disciplinary`;
  } else if (
    routeName == "disciplineResult" ||
    routeName == "disciplineEditResult" ||
    routeName == "disciplineResultDetail"
  ) {
    return `${path}/chapter-17-4-admin-discipline-result`;
  } else if (
    routeName == "disciplineListSuspend" ||
    routeName == "disciplineEditSuspend" ||
    routeName == "disciplineDetailSuspend"
  ) {
    return `${path}/chapter-17-5-admin-discipline-suspend`;
  } else if (routeName.includes("appealComplain")) {
    return `${path}/chapter-17-6-admin-discipline-appealcomplain`;
  } else if (routeName.includes("disciplineDirector")) {
    return `${path}/chapter-17-7-admin-discipline-director`;
  } else if (routeName.includes("disciplineChannel")) {
    return `${path}/chapter-17-7-2-admin-discipline-channel`;
  } else if (routeName.includes("disciplineReport")) {
    return `${path}/chapter-17-8-admin-discipline-report`;
  } else if (routeName.includes("KPIIndicatorByPlan")) {
    return `${path}/chapter-9-admin-indicator-plan`;
  } else if (routeName.includes("KPIIndicatorByRole")) {
    return `${path}/chapter-9-1-2-admin-indicator-role`;
  } else if (routeName.includes("KPIAssignment")) {
    return `${path}/chapter-9-1-3-admin-indicator-assignment`;
  } else if (routeName.includes("KPICompetency")) {
    return `${path}/chapter-9-2-admin-competency`;
  } else if (routeName.includes("strategic")) {
    return `${path}/chapter-9-3-admin-strategic`;
  } else if (
    routeName == "commandListPage" ||
    routeName == "commandEditDetailPage" ||
    routeName == "commandViewDetailPage"
  ) {
    return `${path}/chapter-10-admin-order`;
  } else if (
    routeName == "competePeriod" ||
    routeName == "competePeriodAdd" ||
    routeName == "recruitingDetail" ||
    routeName == "recruitingDetailEx" ||
    routeName == "competePeriodEdit"
  ) {
    return `${path}/chapter-11-3-admin-compete-period`;
  } else if (
    routeName == "qualifyPeriod" ||
    routeName == "qualifyPeriodAdd" ||
    routeName == "qualifyPeriodEditDetail" ||
    routeName == "qualifyPeriodEdit"
  ) {
    return `${path}/chapter-11-4-1-admin-qualify-period`;
  } else if (
    routeName == "disablePeriod" ||
    routeName == "disablePeriodAdd" ||
    routeName == "disablePeriodDetail" ||
    routeName == "disablePeriodEdit"
  ) {
    return `${path}/chapter-11-4-2-admin-disable-period`;
  } else if (
    routeName == "manage" ||
    routeName == "manageDetaill" ||
    routeName == "ExamForm"
  ) {
    return `${path}/chapter-11-4-3-admin-qualify-manage`;
  } else if (routeName == "qualifyPeriodStat") {
    return `${path}/chapter-11-4-4-admin-qualify-period-stat`;
  } else if (routeName == "qualifyPeriodStatDisable") {
    return `${path}/chapter-11-4-5-admin-qualify-disable-stat`;
  } else if (routeName.includes("competePeriodStat")) {
    return `${path}/chapter-11-3-2-admin-compete-period-stat`;
  } else if (routeName.includes("probation")) {
    return `${path}/chapter-13-admin-probation`;
  } else if (routeName.includes("insigniaProposals")) {
    return `${path}/chapter-15-admin-insignia`;
  } else if (routeName == "insigniaManage") {
    return `${path}/chapter-15-2-admin-insignia`;
  } else if (routeName == "insigniaManageEmp") {
    return `${path}/chapter-15-3-admin-insignia`;
  } else if (routeName == "insigniaRecord") {
    return `${path}/chapter-15-4-admin-insignia`;
  } else if (routeName == "insigniaRecordEmp") {
    return `${path}/chapter-15-5-admin-insignia`;
  } else if (routeName.includes("insigniaAllocate")) {
    return `${path}/chapter-15-6-admin-insignia`;
  } else if (routeName.includes("insigniaBorrow")) {
    return `${path}/chapter-15-7-admin-insignia`;
  } else if (routeName == "insigniaReclaim") {
    return `${path}/chapter-15-8-admin-insignia`;
  } else if (routeName.includes("insigniaReport")) {
    return `${path}/chapter-15-9-admin-insignia`;
  } else if (routeName.includes("roundTime")) {
    return `${path}/chapter-16-admin-leave`;
  } else if (routeName.includes("workList")) {
    return `${path}/chapter-16-2-admin-leave`;
  } else if (routeName.includes("changeRound")) {
    return `${path}/chapter-16-3-admin-leave`;
  } else if (routeName.includes("timestampSpecial")) {
    return `${path}/chapter-16-4-admin-leave`;
  } else if (routeName == "checkinReport") {
    return `${path}/chapter-16-5-admin-leave`;
  } else if (
    routeName == "leave" ||
    routeName == "leaveDetail" ||
    routeName == "leaveRejectDetail"
  ) {
    return `${path}/chapter-16-6-admin-leave`;
  } else if (routeName == "leaveHistory") {
    return `${path}/chapter-16-7-admin-leave`;
  } else if (routeName == "leaveReport") {
    return `${path}/chapter-16-8-admin-leave`;
  } else if (routeName == "positionTemp") {
    return `${path}/chapter-6-admin-position-temp`;
  } else if (routeName == "competeReport") {
    return `${path}/chapter-11-3-3-admin-compete-report`;
  } else if (
    routeName == "developmentMain" ||
    routeName == "developmentDetailPage" ||
    routeName == "developmentDetail"
  ) {
    return `${path}/chapter-21-admin-development`;
  } else if (routeName.includes("developmentHistory")) {
    return `${path}/chapter-21-2-admin-development-history`;
  } else if (routeName.includes("developmentEmployeeHistory")) {
    return `${path}/chapter-21-3-admin-development-employee-history`;
  } else if (routeName.includes("developmentScholarship")) {
    return `${path}/chapter-21-4-admin-development-scholarship`;
  } else if (routeName == "evaluate" || routeName == "evaluateDetail") {
    return `${path}/chapter-18-admin-evaluate`;
  } else if (
    routeName == "evaluateDirector" ||
    routeName == "evaluateDirectorAdd"
  ) {
    return `${path}/chapter-18-2-admin-evaluate-director`;
  } else if (
    routeName == "evaluateMeeting" ||
    routeName == "evaluateMeetingEdit" ||
    routeName == "evaluateMeetingAdd"
  ) {
    return `${path}/chapter-18-2-2-admin-evaluate-meeting`;
  } else if (routeName == "salaryChart" || routeName == "salaryRate") {
    return `${path}/chapter-19-admin-salary`;
  } else if (
    routeName == "salaryEmployeeChart" ||
    routeName == "salaryEmployeeRate"
  ) {
    return `${path}/chapter-19-2-admin-salary-employee`;
  } else if (routeName == "salaryRound") {
    return `${path}/chapter-19-3-admin-salary-round`;
  } else if (routeName == "salaryLists") {
    return `${path}/chapter-19-4-admin-salary-lists`;
  } else if (routeName == "salaryEmployeeLists") {
    return `${path}/chapter-19-5-admin-salary-employee-lists`;
  } else if (routeName == "KPIRound") {
    return `${path}/chapter-20-admin-KPI-round`;
  } else if (
    routeName == "KPI​List" ||
    routeName == "KPIDetailPage" ||
    routeName == "KPIDetail"
  ) {
    return `${path}/chapter-20-2-admin-KPI-list`;
  } else if (routeName == "KPIResults") {
    return `${path}/chapter-20-3-admin-KPI-results`;
  } else if (routeName == "KPIReport") {
    return `${path}/chapter-20-4-admin-KPI-report`;
  } else if (routeName == "positionCondition") {
    return `${path}/chapter-8-admin-position-condition`;
  } else if (routeName == "transfer" || routeName == "transfer-id") {
    return `${path}/chapter-12-2-admin-transfer`;
  } else {
    return manualConfig[routeName as keyof typeof manualConfig];
  }
};

const manualConfig = {
  dashboard: `${path}/`,
  strategic: `${path}/chapter-9-admin-indicator-plan`,
  KPIIndicatorByRoleAdd: `${path}/chapter-9-1-2-admin-indicator-role`,
  KPIIndicatorByPlan: `${path}/chapter-9-admin-indicator-plan`,
  "KPIIndicatorByPlan/Add": `${path}/chapter-9-admin-indicator-plan`,
  KPIIndicatorByPlanByid: `${path}/chapter-9-admin-indicator-plan`,
  KPIIndicatorByRoleByid: `${path}/chapter-9-admin-indicator-plan`,
  KPICompetency: `${path}/chapter-9-2-admin-competency`,
  KPIAssignment: `${path}/chapter-9-admin-indicator-plan`,
  KPIAssignmentById: `${path}/chapter-9-admin-indicator-plan`,
  KPIIndicatorByRole: `${path}/chapter-9-admin-indicator-plan`,
  KPICompetencyAdd: `${path}/chapter-9-2-admin-competency`,
  KPICompetencyByid: `${path}/chapter-9-2-admin-competency`,
  organizationalNew: `${path}/chapter-4-admin-organization`,
  organization: `${path}/chapter-6-admin-registry`,
  registry: `${path}/chapter-6-admin-registry`,
  registryDetail: `${path}/chapter-6-admin-registry`,
  verified: `${path}/chapter-6-admin-registry`,
  order: `${path}/chapter-8-admin-order`,
  OrderDetail: `${path}/chapter-8-admin-order`,
  OrderAdd: `${path}/chapter-8-admin-order`,
  editorweb: `${path}/chapter-11-admin-recruit`,

  placement: `${path}/chapter-12-admin-placement`,
  placementDetail: `${path}/chapter-12-admin-placement`,
  PlacementPersonalDetail: `${path}/chapter-12-admin-placement`,

  receive: `${path}/chapter-12-3-admin-receive`,
  receiveAdd: `${path}/chapter-12-3-admin-receive`,
  receiveDetail: `${path}/chapter-12-3-admin-receive`,
  "help-government": `${path}/chapter-12-4-admin-help-government`,
  governmentbyId: `${path}/chapter-12-4-admin-help-government`,
  repatriate: `${path}/chapter-12-5-admin-repatriate`,
  repatriatebyId: `${path}/chapter-12-5-admin-repatriate`,
  "appoint-promote": `${path}/chapter-12-6-admin-appoint-promote`,
  "appoint-promote-detail": `${path}/chapter-12-6-admin-appoint-promote`,
  "appoint-employee": `${path}/chapter-12-7-admin-appoint-employee`,
  "appoint-employee-detail": `${path}/chapter-12-7-admin-appoint-employee`,
  other: `${path}/chapter-12-8-admin-other`,
  "other-detail": `${path}/chapter-12-8-admin-other`,
  placementReport: `${path}/chapter-12-9-admin-placement-repoet`,

  probation: `${path}/chapter-11-admin-probation`,
  probationDetail: `${path}/chapter-11-admin-probation`,
  probationForm: `${path}/chapter-11-admin-probation`,
  "report-report": `${path}/chapter-13-admin-insignia`,
  "report-report-01": `${path}/chapter-13-admin-insignia`,
  appealComplain: `${path}/chapter-15-admin-discipline`,
  // KPIRound: `${path}/chapter-18-admin-perf-evaluation`,
  // "KPI​List": `${path}/chapter-18-admin-perf-evaluation`,
  // KPIDetail: `${path}/chapter-18-admin-perf-evaluation`,
  // KPIReport: `${path}/chapter-18-admin-perf-evaluation`,
  // KPIDetailnew: `${path}/chapter-18-admin-perf-evaluation`,
};

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