import { ROUTE_NAMES, RouteNamesType } from '@/shared/constants/route-names';

export type PathType = RouteNamesType[keyof RouteNamesType];
const generatePath = (base: string, path?: PathType): string => {
  base = base.replace(/\/\*/g, '');
  if (typeof path === 'string') {
    path = path?.replace(/:.*/, '');
  }
  let rs = path ? `${base}/${path as string}` : base;
  return rs;
};

export const PATHS: RouteNamesType = {
  home: generatePath(ROUTE_NAMES.home),
  transaction: {
    base: generatePath(ROUTE_NAMES.transaction.base),
    allTransaction: {
      base: generatePath(`${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.allTransaction.base}`),
      list: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.allTransaction.base}`,
        ROUTE_NAMES.transaction.allTransaction.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.allTransaction.base}`,
        ROUTE_NAMES.transaction.allTransaction.detail,
      ),
      cancel: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.allTransaction.base}`,
        ROUTE_NAMES.transaction.allTransaction.cancel,
      ),
    },
    cashReceipt: {
      base: generatePath(`${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.cashReceipt.base}`),
      list: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.cashReceipt.base}`,
        ROUTE_NAMES.transaction.cashReceipt.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.cashReceipt.base}`,
        ROUTE_NAMES.transaction.cashReceipt.detail,
      ),
      handWrittenIssuance: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.cashReceipt.base}`,
        ROUTE_NAMES.transaction.cashReceipt.handWrittenIssuance,
      ),
    },
    escrow: {
      base: generatePath(`${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.escrow.base}`),
      list: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.escrow.base}`,
        ROUTE_NAMES.transaction.escrow.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.escrow.base}`,
        ROUTE_NAMES.transaction.escrow.detail,
      ),
    },
    billing: {
      base: generatePath(`${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.billing.base}`),
      list: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.billing.base}`,
        ROUTE_NAMES.transaction.billing.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.billing.base}`,
        ROUTE_NAMES.transaction.billing.detail,
      ),
      charge: generatePath(
        `${ROUTE_NAMES.transaction.base}${ROUTE_NAMES.transaction.billing.base}`,
        ROUTE_NAMES.transaction.billing.charge,
      ),
    }
  },
  settlement: {
    base: generatePath(ROUTE_NAMES.settlement.base),
    calendar: generatePath(ROUTE_NAMES.settlement.base, ROUTE_NAMES.settlement.calendar),
    list: generatePath(ROUTE_NAMES.settlement.base, ROUTE_NAMES.settlement.list),
    detail: generatePath(ROUTE_NAMES.settlement.base, ROUTE_NAMES.settlement.detail),
  },
  businessMember: {
    base: generatePath(ROUTE_NAMES.businessMember.base),
    info: generatePath(ROUTE_NAMES.businessMember.base, ROUTE_NAMES.businessMember.info),
    registrationStatus: generatePath(ROUTE_NAMES.businessMember.base, ROUTE_NAMES.businessMember.registrationStatus),
  },
  payment: {
    base: generatePath(ROUTE_NAMES.payment.base),
    info: generatePath(ROUTE_NAMES.payment.base, ROUTE_NAMES.payment.info),
    dataNotification: generatePath(ROUTE_NAMES.payment.base, ROUTE_NAMES.payment.dataNotification),
  },
  account: {
    base: generatePath(ROUTE_NAMES.account.base),
    user: {
      base: generatePath(`${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`),
      manage: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.manage,
      ),
      loginAuthInfo: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.loginAuthInfo,
      ),
      accountAuth: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.accountAuth,
      ),
      menuAuth: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.menuAuth,
      ),
      addAccount: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.user.base}`,
        ROUTE_NAMES.account.user.addAccount,
      ),
    },
    password: {
      base: generatePath(`${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.password.base}`),
      manage: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.password.base}`,
        ROUTE_NAMES.account.password.manage,
      ),
      modifyLoginPassword: generatePath(
        `${ROUTE_NAMES.account.base}${ROUTE_NAMES.account.password.base}`,
        ROUTE_NAMES.account.password.modifyLoginPassword,
      ),
    }
  },
  tax: {
    base: generatePath(ROUTE_NAMES.tax.base),
    invoice: {
      base: generatePath(`${ROUTE_NAMES.tax.base}${ROUTE_NAMES.tax.invoice.base}`),
      list: generatePath(
        `${ROUTE_NAMES.tax.base}${ROUTE_NAMES.tax.invoice.base}`,
        ROUTE_NAMES.tax.invoice.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.tax.base}${ROUTE_NAMES.tax.invoice.base}`,
        ROUTE_NAMES.tax.invoice.detail,
      ),
    },
    vatReference: generatePath(ROUTE_NAMES.tax.base, ROUTE_NAMES.tax.vatReference),
  },
  additionalService: {
    base: generatePath(ROUTE_NAMES.additionalService.base),
    intro: generatePath(ROUTE_NAMES.additionalService.base, ROUTE_NAMES.additionalService.intro),
    arsCardPayment: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.arsCardPayment.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.arsCardPayment.base}`,
        ROUTE_NAMES.additionalService.arsCardPayment.list,
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.arsCardPayment.base}`,
        ROUTE_NAMES.additionalService.arsCardPayment.request,
      ),
      requestSuccess: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.arsCardPayment.base}`,
        ROUTE_NAMES.additionalService.arsCardPayment.requestSuccess,
      ),
    },
    keyInPayment: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.keyInPayment.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.keyInPayment.base}`,
        ROUTE_NAMES.additionalService.keyInPayment.list
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.keyInPayment.base}`,
        ROUTE_NAMES.additionalService.keyInPayment.request,
      ),
      requestSuccess: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.keyInPayment.base}`,
        ROUTE_NAMES.additionalService.keyInPayment.requestSuccess,
      ),
    },
    smsPaymentNotification: generatePath(ROUTE_NAMES.additionalService.base, ROUTE_NAMES.additionalService.smsPaymentNotification),
    accountHolderSearch: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderSearch.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderSearch.base}`,
        ROUTE_NAMES.additionalService.accountHolderSearch.list
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderSearch.base}`,
        ROUTE_NAMES.additionalService.accountHolderSearch.detail
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.accountHolderSearch.base}`,
        ROUTE_NAMES.additionalService.accountHolderSearch.request,
      )
    },
    accountHolderAuth: generatePath(ROUTE_NAMES.additionalService.base, ROUTE_NAMES.additionalService.accountHolderAuth),
    linkPayment: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`),
      shippingHistory: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.shippingHistory,
      ),
      pendingSend: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.pendingSend,
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.request,
      ),
      requestConfirm: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.requestConfirm,
      ),
      confirmSuccess: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.confirmSuccess,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.detail,
      ),
      pendingDetail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.linkPayment.base}`,
        ROUTE_NAMES.additionalService.linkPayment.pendingDetail,
      )
    },
    kakaoPaymentNotification: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.kakaoPaymentNotification.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.kakaoPaymentNotification.base}`,
        ROUTE_NAMES.additionalService.kakaoPaymentNotification.list,
      ),
      setting: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.kakaoPaymentNotification.base}`,
        ROUTE_NAMES.additionalService.kakaoPaymentNotification.setting,
      ),
    },
    fundTransfer: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundTransfer.base}`),
      requestList: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundTransfer.base}`,
        ROUTE_NAMES.additionalService.fundTransfer.requestList,
      ),
      requestRegister: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundTransfer.base}`,
        ROUTE_NAMES.additionalService.fundTransfer.requestRegister,
      ),
      resultInquiry: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.fundTransfer.base}`,
        ROUTE_NAMES.additionalService.fundTransfer.resultInquiry,
      ),
    },
    settlementAgency: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.paymentAgency.base}`),
      manage: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.manage,
      ),
      deposit: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.deposit,
      ),
      member: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.member,
      ),
      register: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.register,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.settlementAgency.base}`,
        ROUTE_NAMES.additionalService.settlementAgency.detail,
      ),
    },
    paymentAgency: {
      base: generatePath(`${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.paymentAgency.base}`),
      list: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.paymentAgency.base}`,
        ROUTE_NAMES.additionalService.paymentAgency.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.paymentAgency.base}`,
        ROUTE_NAMES.additionalService.paymentAgency.detail,
      ),
      request: generatePath(
        `${ROUTE_NAMES.additionalService.base}${ROUTE_NAMES.additionalService.paymentAgency.base}`,
        ROUTE_NAMES.additionalService.paymentAgency.request,
      ),
    },
  },
  support: {
    base: generatePath(ROUTE_NAMES.support.base),
    notice: {
      base: generatePath(`${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.notice.base}`),
      list: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.notice.base}`,
        ROUTE_NAMES.support.notice.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.notice.base}`,
        ROUTE_NAMES.support.notice.detail,
      ),
    },
    faq: {
      base: generatePath(`${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.faq.base}`),
      list: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.faq.base}`,
        ROUTE_NAMES.support.notice.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.faq.base}`,
        ROUTE_NAMES.support.faq.detail,
      ),
    },
    qna: {
      base: generatePath(`${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.qna.base}`),
      list: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.qna.base}`,
        ROUTE_NAMES.support.qna.list,
      ),
      detail: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.qna.base}`,
        ROUTE_NAMES.support.qna.detail,
      ),
      register: generatePath(
        `${ROUTE_NAMES.support.base}${ROUTE_NAMES.support.qna.base}`,
        ROUTE_NAMES.support.qna.register,
      ),
    },
  },
  setting: generatePath(ROUTE_NAMES.setting),
  alarm: {
    base: generatePath(ROUTE_NAMES.alarm.base),
    list: generatePath(ROUTE_NAMES.alarm.base, ROUTE_NAMES.alarm.list),
  },
};

export const BACK_BLOCKED_PATHS = {
  /*
  [PATHS.home]: [
    PATHS.intro,
    PATHS.start,
    PATHS.appAuth,
    PATHS.mobileVerification,
    PATHS.signUp.bioPinNumber,
    PATHS.signUp.inputPinNumber,
    PATHS.signUp.setPinNumber,
    PATHS.signUp.reSetBiometricAuth,
    PATHS.signUp.setBiometricAuth,
    
  ],
  */
  //[PATHS.appAuth]: [PATHS.intro],
};
