@zeniai/web-app-ui 5.1.86-dev → 5.1.87-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (132) hide show
  1. package/dist/assets/AddressRoutes-DxEoxIUb.js +1 -0
  2. package/dist/assets/AddressScreen-Chily4bM.js +9 -0
  3. package/dist/assets/{AiCfoScreen-DK7jWO5l.js → AiCfoScreen-BBEO3Suh.js} +1 -1
  4. package/dist/assets/{BillPayApprovalRoutes-Bufqh5bf.js → BillPayApprovalRoutes-DaiEsNWA.js} +1 -1
  5. package/dist/assets/{BillPayRoutes-DQrVntHX.js → BillPayRoutes-PIaeEBdZ.js} +11 -11
  6. package/dist/assets/{BusinessVerificationPageScreen-BVO4LcOB.js → BusinessVerificationPageScreen-D5dvQNJp.js} +2 -2
  7. package/dist/assets/{CardsAiCfoScreen-BPq182YL.js → CardsAiCfoScreen-BXBY9Hni.js} +1 -1
  8. package/dist/assets/{ChargeCardRoutes--1Cz6d6F.js → ChargeCardRoutes-BK0OrIBV.js} +11 -11
  9. package/dist/assets/CompanyPassportScreen-Cm4gk9yY.js +1 -0
  10. package/dist/assets/ConnectionAuthScreen-CffoYAGH.js +11 -0
  11. package/dist/assets/CustomerOnboardingAuthScreen-C8YQtDAl.js +1 -0
  12. package/dist/assets/{CustomerOnboardingRoutes-DBUibBfl.js → CustomerOnboardingRoutes-Cy5fh7Ph.js} +3 -3
  13. package/dist/assets/{DashboardRoutes-CWiRUKmL.js → DashboardRoutes-BEwjeJIS.js} +4 -4
  14. package/dist/assets/{DefaultTenantHome-Q8Gr6wzz.js → DefaultTenantHome-Dek2VXLS.js} +1 -1
  15. package/dist/assets/{DomesticWireDetailScreen-Bg4bD2vf.js → DomesticWireDetailScreen-B1_XQRWz.js} +4 -4
  16. package/dist/assets/{DrawerScreen-ESB0V3An.js → DrawerScreen-DvcQwYJL.js} +1 -1
  17. package/dist/assets/EntityDetailRoutes-DmlCVpq5.js +1 -0
  18. package/dist/assets/{ExpenseAutomationRoutes-DRdJk7UH.js → ExpenseAutomationRoutes-B51dpCOX.js} +1 -1
  19. package/dist/assets/FeaturePreviewScreen-rsKGOKMt.js +1 -0
  20. package/dist/assets/HubSpotOAuthCallbackScreen-B8HTRdsG.js +1 -0
  21. package/dist/assets/MagicLinkRoutes-w7z-lC8R.js +72 -0
  22. package/dist/assets/MagicLinkSignInScreen-DRVCTLxJ.js +12 -0
  23. package/dist/assets/{MobileAppDrawer-CNkPd-0r.js → MobileAppDrawer-C4Qb7oTx.js} +1 -1
  24. package/dist/assets/NotFoundScreen-DF585FcE.js +1 -0
  25. package/dist/assets/{NotificationRoutes-CDTyM5yC.js → NotificationRoutes-B1yY0K-v.js} +1 -1
  26. package/dist/assets/OAuthConsentScreen-DjqkjsZh.js +1 -0
  27. package/dist/assets/{PandLWithForecastRoutes-CgJVRO_P.js → PandLWithForecastRoutes-DVRTwbY5.js} +1 -1
  28. package/dist/assets/PeopleRoutes-DNIjECiJ.js +22 -0
  29. package/dist/assets/PerformanceRoutes-CBA6LdQM.js +1 -0
  30. package/dist/assets/{Preview-ng4_PqRv.js → Preview-Dva_bJum.js} +1 -1
  31. package/dist/assets/{QBOConnectionScreen-B3-UhwG_.js → QBOConnectionScreen-CGkERoNs.js} +1 -1
  32. package/dist/assets/ReferralListScreen-CjqD8MEj.js +5 -0
  33. package/dist/assets/{ReimbursementApprovalRoutes-DJ6r8--7.js → ReimbursementApprovalRoutes-C6wjjcY2.js} +1 -1
  34. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-CGou3dCd.js → ReimbursementApprovalRuleDetailScreen-lqMGwwjC.js} +1 -1
  35. package/dist/assets/{ReimbursementRoutes-C1KqmlyM.js → ReimbursementRoutes-DwMQE72_.js} +9 -9
  36. package/dist/assets/{ReportsRoutes-BTVnfyaM.js → ReportsRoutes-AH6kORjA.js} +1 -1
  37. package/dist/assets/RewardsRoutes-CV4ZZqiN.js +1 -0
  38. package/dist/assets/ScreenRoutes-CWOU9Zyz.js +2 -0
  39. package/dist/assets/{SettingsRoutes-ZI-PRowa.js → SettingsRoutes-B4qGOdQZ.js} +7 -7
  40. package/dist/assets/{SetupPagesScreen-CnFtaoyZ.js → SetupPagesScreen-CZVsa4S1.js} +5 -5
  41. package/dist/assets/SignInScreen-BMK86dbR.js +1 -0
  42. package/dist/assets/SignOutScreen-DS_DDs6h.js +9 -0
  43. package/dist/assets/TaskListScreen-C5s1cVme.js +9 -0
  44. package/dist/assets/TaskRoutes-C2QoRTON.js +9 -0
  45. package/dist/assets/{TransactionDetailRoutes-75MHva3P.js → TransactionDetailRoutes-DvTD9yn_.js} +1 -1
  46. package/dist/assets/{TransactionDetailScreen-BdRaLDX3.js → TransactionDetailScreen-D3MDrNqC.js} +2 -2
  47. package/dist/assets/{TransactionListRoutes-BK2uV7qm.js → TransactionListRoutes-DqVFZNDK.js} +1 -1
  48. package/dist/assets/{TreasuryRoutes-JT_IY3Gx.js → TreasuryRoutes-_BFzpxv8.js} +6 -6
  49. package/dist/assets/VendorsRoutes-Dc2IVyP5.js +112 -0
  50. package/dist/assets/WiseConfirmationScreen-6okfuCMP.js +12 -0
  51. package/dist/assets/{ZeniAccountRoutes-BPiHmqg-.js → ZeniAccountRoutes--kyyJ82L.js} +11 -11
  52. package/dist/assets/ZeniAccountStatementScreen-D99BQFQI.js +9 -0
  53. package/dist/assets/{accountMappingHelper-COLWfB1U.js → accountMappingHelper-Du8kIzw4.js} +1 -1
  54. package/dist/assets/{analytics-dJ9Vu0DH.js → analytics-BY30ztud.js} +1 -1
  55. package/dist/assets/{analyticsHelper-B2nQzr20.js → analyticsHelper-CxPzmrE2.js} +1 -1
  56. package/dist/assets/{core-Ca6G0voE.js → core-FEzHdTwu.js} +1 -1
  57. package/dist/assets/{decodeURIComponentSafe-BMcEUj25.js → decodeURIComponentSafe-_VO6ySKg.js} +1 -1
  58. package/dist/assets/{dnd-Be5WoH8E.js → dnd-Cb_vPZwC.js} +1 -1
  59. package/dist/assets/{empty-uy3M1msm.js → empty-C5RcOwbi.js} +1 -1
  60. package/dist/assets/{empty-DHGdIlcJ.js → empty-C8ieKMB7.js} +1 -1
  61. package/dist/assets/{emptyVideoElement-IUbgWLFZ.js → emptyVideoElement-BmUcQvfG.js} +1 -1
  62. package/dist/assets/epic-BNsbOFuA.js +2 -0
  63. package/dist/assets/getLocaleForTenant-C7oVCXTV.js +1 -0
  64. package/dist/assets/{index-sd36C9hC.js → index-B4FjCn1f.js} +1 -1
  65. package/dist/assets/{index-D3FowIif.js → index-C7vi0ZZK.js} +1 -1
  66. package/dist/assets/{index-Dpm9OcRr.js → index-CBsCykBf.js} +1 -1
  67. package/dist/assets/{index-Dcmv7y8l.js → index-CVniyevN.js} +1 -1
  68. package/dist/assets/{index-Vw1oLCxE.js → index-CkBh8V_t.js} +2 -2
  69. package/dist/assets/{index-BMVCuDFR.js → index-DgG7sdLK.js} +1 -1
  70. package/dist/assets/{index-Ck8HU4ZH.js → index-jQssSn-J.js} +1 -1
  71. package/dist/assets/{index-DD9OmSLj.js → index-pXx5w7oJ.js} +14263 -14305
  72. package/dist/assets/{lexical-DTpvAJin.js → lexical-fJeYHrZP.js} +1 -1
  73. package/dist/assets/{liveblocks-4PIBJMyE.js → liveblocks-B2D23g1h.js} +1 -1
  74. package/dist/assets/{lottie-B7am_Gp2.js → lottie-BKshFrBj.js} +1 -1
  75. package/dist/assets/{mui-BI3ZId9r.js → mui-C754KMjM.js} +1 -1
  76. package/dist/assets/{pathToGoBack-CrG50xVP.js → pathToGoBack-UuLm5E-W.js} +1 -1
  77. package/dist/assets/{pdf-DUHWpwzW.js → pdf-BSvba1pn.js} +3 -3
  78. package/dist/assets/{pdf-lib-DyNMbFeB.js → pdf-lib-DwZXgIAK.js} +1 -1
  79. package/dist/assets/{plaid-BFzM5Kog.js → plaid--k8gbxl0.js} +1 -1
  80. package/dist/assets/{pusher-BmnXBdoc.js → pusher-DZSPU4Iz.js} +1 -1
  81. package/dist/assets/{react-CffrEBOp.js → react-Bv0wImI-.js} +1 -1
  82. package/dist/assets/{react-BOWfROr3.js → react-Bwb7DPQL.js} +1 -1
  83. package/dist/assets/{react-DM-Vx6Nk.js → react-CNLrYL7C.js} +1 -1
  84. package/dist/assets/{react-CZFZzs7c.js → react-DTEOm1rk.js} +1 -1
  85. package/dist/assets/{react-Wm4oo8rw.js → react-KlSSTbpt.js} +1 -1
  86. package/dist/assets/{react-DMQWnTjk.js → react-_GRuT6vD.js} +1 -1
  87. package/dist/assets/{recharts-D6NnjcYi.js → recharts-CIXkvtnT.js} +1 -1
  88. package/dist/assets/{routePaths-BumbtdKN.js → routePaths-x0riE4xM.js} +1 -1
  89. package/dist/assets/{sentry-CXcgkCeA.js → sentry-BQ1KU1t3.js} +1 -1
  90. package/dist/assets/{url-DVO5HPAn.js → url-BWcieJIW.js} +1 -1
  91. package/dist/assets/{url-DsqsNUWn.js → url-DLepITYL.js} +1 -1
  92. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-DQzT3CdB.js → useAiCfoDashboardSuggestedQuestionsChips-CVRUasWi.js} +1 -1
  93. package/dist/assets/useAskAiCfoHostNavButtonProps-Be2oPcqW.js +1 -0
  94. package/dist/assets/useCashManagementBanner-GC5G0bCW.js +1 -0
  95. package/dist/assets/{useChargeCardPusherEvents-CtFgCR2P.js → useChargeCardPusherEvents-B89u0v4H.js} +1 -1
  96. package/dist/assets/{useDeviceId-BbYF3u-l.js → useDeviceId-C0O1xmgi.js} +1 -1
  97. package/dist/assets/useEmailConnectResultRefresh-BS2g621b.js +1 -0
  98. package/dist/assets/{useInitialThreadRequest-B6-oXb8Z.js → useInitialThreadRequest-qt3qTzlR.js} +1 -1
  99. package/dist/assets/{utils-DFP_hVXq.js → utils-C8oTXAPM.js} +1 -1
  100. package/dist/assets/{withTransactionSidePanel-iSi7Lgwj.js → withTransactionSidePanel-CYkngv7G.js} +1 -1
  101. package/dist/assets/{zeni-epic-state-BIxjj87B.js → zeni-epic-state-Bxb-N0Vf.js} +5 -5
  102. package/dist/index.html +1 -1
  103. package/package.json +3 -3
  104. package/dist/assets/AddressRoutes-CYnGGpGr.js +0 -1
  105. package/dist/assets/AddressScreen-Cgf_DSfy.js +0 -9
  106. package/dist/assets/CompanyPassportScreen-Cr6_STQF.js +0 -1
  107. package/dist/assets/ConnectionAuthScreen-DPDyawJA.js +0 -11
  108. package/dist/assets/CustomerOnboardingAuthScreen-CwgXB2Ot.js +0 -1
  109. package/dist/assets/EntityDetailRoutes-BgIcnD30.js +0 -1
  110. package/dist/assets/FeaturePreviewScreen-CPre8DhJ.js +0 -1
  111. package/dist/assets/HubSpotOAuthCallbackScreen-D1vja8MF.js +0 -1
  112. package/dist/assets/MagicLinkRoutes-50BdhE1X.js +0 -72
  113. package/dist/assets/MagicLinkSignInScreen-oln-_jh3.js +0 -12
  114. package/dist/assets/NotFoundScreen-C4hj38o6.js +0 -1
  115. package/dist/assets/OAuthConsentScreen-Bfra_k87.js +0 -1
  116. package/dist/assets/PeopleRoutes-DsSKCjjc.js +0 -22
  117. package/dist/assets/PerformanceRoutes-5mjMtnxs.js +0 -1
  118. package/dist/assets/ReferralListScreen-Dt6a-ZaL.js +0 -5
  119. package/dist/assets/RewardsRoutes-DdOKhqcE.js +0 -1
  120. package/dist/assets/ScreenRoutes-CR7u1SOQ.js +0 -2
  121. package/dist/assets/SignInScreen-BoQaZMzp.js +0 -1
  122. package/dist/assets/SignOutScreen-BWN6fg9F.js +0 -9
  123. package/dist/assets/TaskListScreen-wwlTbcpO.js +0 -9
  124. package/dist/assets/TaskRoutes-BZfNRRg-.js +0 -9
  125. package/dist/assets/VendorsRoutes-BS6JrHkM.js +0 -112
  126. package/dist/assets/WiseConfirmationScreen-CrmCNnnU.js +0 -12
  127. package/dist/assets/ZeniAccountStatementScreen-DxgFXxRD.js +0 -9
  128. package/dist/assets/epic-DoVGgmyH.js +0 -2
  129. package/dist/assets/getLocaleForTenant-DVEihZ-H.js +0 -1
  130. package/dist/assets/useAskAiCfoHostNavButtonProps-CSLK93Wz.js +0 -1
  131. package/dist/assets/useCashManagementBanner-BNEI8i2V.js +0 -1
  132. package/dist/assets/useEmailConnectResultRefresh-CMs316dl.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as c}from"./liveblocks-4PIBJMyE.js";import{u as me,j as i,h as le,g as he,i as Ve,N as oa,s as _t,n as Pe,t as Dn,o as ss,p as ce}from"./core-Ca6G0voE.js";import{f8 as Pt,RT as cs,fk as wt,bt as Fe,RU as os,RV as is,eZ as hn,RW as _n,f6 as Pn,RX as wn,RY as vn,RZ as Tn,R_ as Fn,f7 as xn,fj as Bn,R$ as Rn,S0 as ds,fd as ls,fc as us,S1 as ms,C2 as Ln,fm as ia,S2 as Cs,S3 as ps,e$ as hs,e_ as fs,fz as Ke,ff as On,fe as Un,S4 as gs,fg as Ss,Bz as bs,By as ys,BC as Is,BE as ks,fs as Es,eW as jn,S5 as As,S6 as Ds,fx as Mn,S7 as _s,fy as yt,BK as Ps,BH as ws,eX as ge,S8 as qa,fC as xe,fD as Be,fE as Re,gw as da,cv as la,S9 as ua,Sa as vt,uQ as $a,kF as za,Sb as Ka,Ci as ka,fn as Qe,Ck as Tt,kv as Nn,Sc as ma,C6 as _a,Sd as vs,Se as Ts,C9 as Qa,Sf as Fs,Qf as Xa,fi as Vn,Cf as Sa,hV as xs,Sg as Hn,f9 as Ca,bo as Bs,Sh as Rs,gh as Ja,gg as et,CO as Ls,gf as at,PX as Os,Si as Gn,co as $n,cQ as Us,Qe as wa,Dn as zn,Sj as fn,CZ as Pa,Sk as Kn,Do as js,QD as Ms,Dp as Ns,Eu as Vs,ub as Hs,Eo as Gs,Sl as $s,Cj as sa,Sm as zs,Sn as Ks,So as Zs,Sp as Ws,Sq as Ys,Sr as Ft,Ss as qs,Cz as Zn,Cs as Qs,St as Xs,gy as Js,CI as Wn,CM as Yn,gx as ec,Su as ac,D9 as qn,Sv as tc,Sw as nc,Sx as rc,CK as Qn,Cv as Xn,Cc as Jn,CE as er,CC as ar,CG as sc,Sy as tr,Sz as cc,fu as oc,fv as ic,fw as dc,SA as tt,fo as nr,cS as xt,SB as lc,SC as uc,SD as mc,SE as Cc,CU as It,Dg as pc,Dc as hc,CQ as fc,De as gc,D4 as Sc,D6 as bc,SF as rr,Dm as Ga,Kd as yc,SG as Ic,SH as kc,SI as Ec,SJ as sr,SK as Ac,DJ as Dc,CY as cr,CT as Ne,CX as _c,SL as Pc,SM as wc,C3 as vc,SN as or,fh as ir,SO as Tc,C5 as Fc,C4 as gn,SP as xc,SQ as Bc,SR as Rc,MK as Lc,SS as Bt,ST as Oc,xR as dr,ld as Uc,hL as jc,DO as Mc,SU as lr,f3 as Nc,f4 as Vc,SV as Hc,dj as Gc,fl as $c,DE as zc,Dy as qe,bs as Kc,bJ as Zc,cA as Wc,bK as Yc,LX as qc}from"./zeni-epic-state-BIxjj87B.js";import{j as Le,cr as ur,q as we,cs as mr,ct as Cr,cu as Qc,a as Je,a0 as Rt,cv as Xc,cw as Jc,Z as pr,c as hr,$ as fr,s as ye,C as ue,U as Z,ar as ya,cx as gr,cy as eo,cz as ao,z as te,B as va,cg as nt,cA as to,cB as no,cC as ro,K as Ta,aS as Ze,bt as Lt,cD as so,E as Fa,k as rt,y as Ot,e as J,a9 as st,cE as co,bG as ba,cF as kt,cG as oo,x as Ut,cH as io,au as Sr,a4 as Et,cI as lo,_ as br,M as uo,g as yr,cJ as mo,cK as Co,cL as po,cM as ho,cN as fo,cO as go,cP as So,o as Za,cQ as bo,cR as yo,cS as ht,F as Io,cT as ko,cU as Eo,cV as Ao,cW as Do,cX as _o,i as Po}from"./index-DD9OmSLj.js";import{n as He,D as Ir,S as wo}from"./mui-BI3ZId9r.js";import{a as r}from"./sentry-CXcgkCeA.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-CSLK93Wz.js";import{M as Ie}from"./MobileAppDrawer-CNkPd-0r.js";import{d as jt}from"./recharts-D6NnjcYi.js";import{g as _e,a as Ba,b as kr,c as Oe,d as Ue,e as Xe,f as ea,h as aa,A as vo,i as Mt,P as To,j as Nt,s as Ia,k as Er,l as ca,m as Ar,n as Fo,o as Dr,p as xo,S as Sn}from"./SetupPagesScreen-CnFtaoyZ.js";import{u as _r}from"./useInitialThreadRequest-B6-oXb8Z.js";import ct from"./NotFoundScreen-C4hj38o6.js";import{u as Vt}from"./useChargeCardPusherEvents-CtFgCR2P.js";import{n as bn}from"./utils-DFP_hVXq.js";import{t as Bo}from"./AddressScreen-Cgf_DSfy.js";import"./analytics-dJ9Vu0DH.js";import"./plaid-BFzM5Kog.js";import"./dnd-Be5WoH8E.js";import"./stripe-DMRn4zHo.js";import"./lottie-B7am_Gp2.js";import"./lexical-DTpvAJin.js";import"./pdf-DUHWpwzW.js";import"./analyticsHelper-B2nQzr20.js";import"./routePaths-BumbtdKN.js";import"./BusinessVerificationPageScreen-BVO4LcOB.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1abeecb2-a076-49b3-9008-d39aa72d8c3d",e._sentryDebugIdIdentifier="sentry-dbid-1abeecb2-a076-49b3-9008-d39aa72d8c3d")}catch{}})();const Ro=e=>{const n=e.cardHolderUser,t=`${n.firstName??""} ${n.lastName??""}`.trim()||n.email||n.userId;return{userId:n.userId,displayName:t,roleLabel:e.cardHolderRoles?.titleAtCompany}},Pr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:Ro(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)});function wr(){const e=me(),n=i(a=>Pt(a.cardPolicyState)),t=i(a=>cs(a.cardPolicyState));r.useEffect(()=>{t!==""||n==="Completed"&&t===""||n==="In-Progress"||e(wt())},[e,n,t])}const{spendManagement:{chargeCard:{cardPolicyPage:yn}}}=Je.getLocalizedStrings(),Lo=e=>On(e,!1),Oo=e=>Un(e.name,!1);function Uo(){const e=le(),n=he(),{tenantEmailDomain:t}=Ve(),a=me(),s=Le(),b=Fe(s?.loggedInUserRoleMap),[g,S]=r.useState(!1),P=r.useCallback(A=>{S(A)},[]),m=r.useCallback(()=>{P(!0)},[P]),{isAiCfoAccessEnabled:C,onAskAiCfoClick:F}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect(()=>()=>{a(os()),a(is()),a(hn())},[a]);const v=i(A=>_n(A.cardPolicyState)),l=i(A=>Pn(A.cardPolicyState)),M=i(A=>wn(A.cardPolicyState)),B=i(A=>vn(A.cardPolicyState)),R=i(A=>Tn(A.cardPolicyState)),p=i(A=>Fn(A.cardPolicyState)),h=i(A=>xn(A.cardPolicyState)),T=i(A=>Pt(A.cardPolicyState)),u=i(A=>A.chargeCardConfigState.receiptRequiredAboveAmount.amount),w=i(A=>A.chargeCardConfigState.fetchState);r.useEffect(()=>{v!=="Completed"&&v!=="In-Progress"&&a(Bn())},[a,v]),wr();const E=i(A=>Rn(A.createCardPolicyState)),U=i(A=>ds(A.createCardPolicyState)),y=i(A=>ls(A.cardPolicyState)),k=i(A=>us(A.cardPolicyState)),x=i(A=>ms(A.createCardPolicyState)),d=i(A=>Ln(A));r.useEffect(()=>{d.fetchState==="Not-Started"&&a(ia(!1,!1,!1))},[d.fetchState,a]);const f=r.useMemo(()=>l.map(Lo),[l]),j=r.useMemo(()=>h.map(Oo),[h]),H=r.useMemo(()=>d.cards.filter(A=>!ur(A.status.code)).map(Pr),[d.cards]),O=v==="Completed"&&d.fetchState==="Completed"&&w==="Completed";r.useEffect(()=>{O&&x==null&&a(Cs({cardsMasterList:H,defaultRequireReceiptAmount:u,suggestedAllowMerchants:M,suggestedBlockMerchants:B,suggestedAllowCategories:R,suggestedBlockCategories:p}))},[w,a,O,x,H,u,M,B,R,p]);const L=r.useMemo(()=>jt(A=>{a(wt(A))},250),[a]);r.useEffect(()=>()=>{L.cancel()},[L]);const z=r.useCallback(A=>{L(A)},[L]),$=E.fetchState,_=t!=null?`/${t}/cards/policy`:"..",D=r.useCallback(()=>{const A=we(n.state?.pathnameStackToGoBack),Y=A.poppedPathname??_;e(Y,{state:{pathnameStackToGoBack:A.newStack}})},[n.state,e,_]),G=r.useCallback(()=>{e(_)},[e,_]),Q=r.useCallback(A=>{a(ps(A))},[a]),I=r.useCallback(A=>{const Y=mr(A);a(hs({templates:[Y]}))},[a]),N=r.useCallback(A=>{A.length!==0&&a(fs(A))},[a]),W=r.useCallback(()=>{a(hn())},[a]),X=r.useRef($);r.useEffect(()=>{const A=X.current;X.current=$,$==="Completed"&&A!=="Completed"&&U!=null&&(a(Ke({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(_))},[a,$,U,e,_]);const o=$==="Error"?E.error?.message??yn.createPolicyGenericErrorMessage:void 0;return b&&t!=null?x==null?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(Cr,{showUploadDocumentSection:!0,navBarTitle:yn.createPageTitle,onBackClick:D,onClickMenuIcon:m,isAiCfoAccessEnabled:C,onAskAiCfoClick:F})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(Qc,{formDraft:x,vendorSearchOptions:j,categorySearchOptions:f,isVendorSearchLoading:T==="In-Progress",onVendorSearchTextChange:z,submitState:$,submitErrorMessage:o,documentUploadState:y,uploadedFileName:k,isAiCfoAccessEnabled:C,onAskAiCfoClick:F,onBackClick:D,onCancelClick:G,onClickMenuIcon:m,onFormChange:Q,onSubmit:I,onUploadDocument:N,onRemoveDocument:W})]}):c.jsx(oa,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:jo}}}=Je.getLocalizedStrings(),Mo=e=>On(e,!1),No=e=>Un(e.name,!1);function Vo(){const e=le(),n=he(),{tenantEmailDomain:t,templateId:a}=Ve(),s=me(),b=Le(),g=Fe(b?.loggedInUserRoleMap),[S,P]=r.useState(!1),m=r.useCallback(o=>{P(o)},[]),C=r.useCallback(()=>{m(!0)},[m]),{isAiCfoAccessEnabled:F,onAskAiCfoClick:v}=xa({mobileExploreReferrer:"Card Policy"}),l=i(o=>gs(o)),M=i(o=>_n(o.cardPolicyState)),B=i(o=>Pn(o.cardPolicyState)),R=i(o=>wn(o.cardPolicyState)),p=i(o=>vn(o.cardPolicyState)),h=i(o=>Tn(o.cardPolicyState)),T=i(o=>Fn(o.cardPolicyState)),u=i(o=>xn(o.cardPolicyState)),w=i(o=>Pt(o.cardPolicyState)),E=i(o=>Ln(o)),U=i(o=>a!=null?Ss(o.cardPolicyState,a):void 0),y=r.useMemo(()=>l.templateId===a&&l.formDraft!=null?l.formDraft:U!=null?bs(U):void 0,[l.templateId,l.formDraft,U,a]);r.useEffect(()=>{if(a==null)return;const o=l.detailFetchState.fetchState;l.templateId===a&&(o==="Completed"||o==="In-Progress")||U!=null||s(ys(a))},[s,a,l.templateId,l.detailFetchState.fetchState,U]),r.useEffect(()=>{M!=="Completed"&&M!=="In-Progress"&&s(Bn())},[s,M]),wr();const k=i(o=>o.chargeCardConfigState.receiptRequiredAboveAmount.amount);r.useEffect(()=>{E.fetchState==="Not-Started"&&s(ia(!1,!1,!1))},[E.fetchState,s]);const x=r.useMemo(()=>B.map(Mo),[B]),d=r.useMemo(()=>u.map(No),[u]),f=r.useMemo(()=>E.cards.filter(o=>!ur(o.status.code)).map(Pr),[E.cards]);Rt({isDataReady:y!=null});const j=r.useMemo(()=>{if(y!=null)return Xc({draft:y,cardRows:f,categorySearchOptions:x,vendorSearchOptions:d,defaultRequireReceiptAmount:k,suggestedAllowMerchants:R,suggestedBlockMerchants:p,suggestedAllowCategories:h,suggestedBlockCategories:T})},[y,f,x,d,k,R,p,h,T]),[H,O]=r.useState(void 0),L=r.useRef(!1);r.useEffect(()=>{L.current||H!=null||j==null||(L.current=!0,O(j))},[H,j]);const z=r.useCallback(o=>{O(o)},[]),$=r.useMemo(()=>jt(o=>{s(wt(o))},250),[s]);r.useEffect(()=>()=>{$.cancel()},[$]);const _=r.useCallback(o=>{$(o)},[$]),D=l.updateFetchState.fetchState,G=t!=null?`/${t}/cards/policy`:"..",Q=r.useCallback(()=>{const o=we(n.state?.pathnameStackToGoBack),A=o.poppedPathname??G;e(A,{state:{pathnameStackToGoBack:o.newStack}})},[n.state,e,G]),I=r.useCallback(()=>{e(G)},[e,G]),N=r.useCallback(o=>{if(a==null)return;const A=mr(o);s(Is(A)),s(ks(a))},[s,a]),W=r.useRef(D);r.useEffect(()=>{const o=W.current;W.current=D,D==="Completed"&&o!=="Completed"&&(s(Ke({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(G))},[s,D,e,G]);const X=D==="Error"?l.updateFetchState.error?.message??jo.updatePolicyGenericErrorMessage:void 0;return!g||t==null||a==null?c.jsx(oa,{to:"..",replace:!0}):H!=null&&M==="Completed"&&E.fetchState==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:m}),c.jsx(Jc,{templateName:l.template?.name??"",formDraft:H,vendorSearchOptions:d,categorySearchOptions:x,isVendorSearchLoading:w==="In-Progress",onVendorSearchTextChange:_,submitState:D,submitErrorMessage:X,isAiCfoAccessEnabled:F,onAskAiCfoClick:v,onBackClick:Q,onCancelClick:I,onClickMenuIcon:C,onFormChange:z,onSubmit:N})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:m}),c.jsx(Cr,{showUploadDocumentSection:!1,navBarTitle:l.template?.name,onBackClick:Q,onClickMenuIcon:C,isAiCfoAccessEnabled:F,onAskAiCfoClick:v})]})}function vr(e,n,t){return n?e.filter(a=>a!=null&&a.trim().length>0).slice(0,t):[]}function Tr(e){return i(n=>e==null||e===""?{chips:ft,isResolved:!1}:function(t){const a=t?.fetchState,s=a==="Completed"||a==="Error";return{chips:a==="Completed"?t?.suggestedQuestions??ft:ft,isResolved:s}}(Es(n,e)),_t)}const ft=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Ho,subheadline:Go,pageTitle:$o}}}}=Je.getLocalizedStrings(),zo=e=>{const n=e.cardsCount>0?e.cardsCount:e.appliedCards.length,t=e.allowedEntity.merchantNames.length+e.blockedEntity.merchantNames.length,a=e.allowedEntity.categoryCodes.length+e.blockedEntity.categoryCodes.length;return{templateId:e.templateId,name:e.name,description:e.description,mode:e.mode==="flexible"?"flexible":"strict",createdAtFormatted:e.createdAt.format("ll"),cardsCount:n,vendorRestrictionsCount:t,categoryRestrictionsCount:a}};function Ko(){const e=le(),n=he(),{tenantEmailDomain:t}=Ve(),a=me(),s=Le(),b=Fe(s?.loggedInUserRoleMap),[g,S]=r.useState(!1),P=r.useCallback(_=>{S(_)},[]),m=r.useCallback(()=>{P(!0)},[P]),{useFeatureGate:C}=ue(),{isFeatureEnabled:F}=C(Z.isAiCfoFileUploadEnabled),{isFeatureEnabled:v}=C(Z.isCardPolicyEnabled),{isAiCfoAccessEnabled:l,onAskAiCfoClick:M}=xa({mobileExploreReferrer:"Card Policy"}),B=i(_=>As(_)),R=i(_=>Rn(_.createCardPolicyState)),p=i(_=>Ds(_.createCardPolicyState)),h=i(_=>p==null?[]:Mn(_.aiCfoState,p).filter(D=>D.kind==="creating_policy"),_t),T=R.fetchState==="In-Progress"?Math.max(h.length,1):0,u=i(_=>_s(_.createCardPolicyState)),w=ya(R.fetchState);r.useEffect(()=>{if(w==="In-Progress"&&R.fetchState==="Completed"&&p!=null)h.forEach(_=>{a(yt({chatSessionId:p,id:_.id,entityIds:u,kind:"created_policy"}))});else if(w==="In-Progress"&&R.fetchState==="Error"&&p!=null){h.forEach(D=>{a(yt({chatSessionId:p,id:D.id,kind:"errored_policy"}))});const _=R.error?.message!=null&&R.error.message.length>0?R.error.message:Je.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;a(Ke({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:_}]}))}},[R.error?.message,R.fetchState,a,p,u,h,w]);const E=B.fetchState.fetchState;r.useEffect(()=>{E!=="Not-Started"&&E!=="Error"||a(Ps())},[a,E]);const U=B.archiveFetchState.fetchState,y=ya(U);r.useEffect(()=>{y==="In-Progress"&&U==="Completed"&&a(Ke({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))},[U,a,y]);const k=r.useMemo(()=>B.templates.map(zo),[B.templates]);Rt({isDataReady:B.fetchState.fetchState==="Completed"});const x=k.length>0||T>0,d=function(_){const{hasAnyPolicies:D,isChargeCardAdmin:G,isFileUploadEnabled:Q}=_,I=le(),N=he(),{tenantEmailDomain:W}=Ve(),{isAiCfoOpen:X,setIsAiCfoOpen:o}=pr(),A=hr(),Y=fr(),ne=i(oe=>jn(oe)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:q,isResolved:ke}=Tr("card_policy"),ve=r.useMemo(()=>vr(q,ke,3),[q,ke]),[fe,se]=r.useState(""),Ee=Y&&A&&W!=null&&!X,re=r.useCallback(oe=>{if(W==null)return;const fa=ye(N.state?.pathnameStackToGoBack,N.pathname);I(`/${W}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:fa,referrer:"card_policy_hero",aiCfoInitialQuestion:oe,aiCfoShouldSubmit:oe!=null&&oe.trim().length>0}})},[N.pathname,N.state,I,W]),Ce=r.useCallback(oe=>{oe.trim().length!==0&&(se(""),re(oe))},[re]),Ae=r.useCallback(()=>{const oe=fe.trim();oe.length!==0&&(se(""),re(oe))},[fe,re]),ee=r.useCallback(()=>{},[]),Te=r.useCallback(oe=>{se(oe)},[]),De=r.useCallback(()=>{o(!0)},[o]),ae=r.useCallback(()=>{re(void 0)},[re]);return r.useMemo(()=>{if(Ee&&!D&&G)return{aiAgentName:$o,headline:Ho,subheadline:Go,promptChips:ve,composer:{currentInput:fe,isSubmitting:ne,isFileUploadEnabled:Q,onInputChange:Te,onSubmit:Ae,onStopSubmit:ee},onPromptClick:Ce,onOpenSidePanel:De,onOpenFullView:ae,dataTestIdPrefix:"card-policy-ai-cfo-hero"}},[fe,D,Ee,G,Q,ne,Te,ae,De,Ce,ee,Ae,ve])}({hasAnyPolicies:x,isChargeCardAdmin:b,isFileUploadEnabled:F}),f=v&&d!=null?c.jsx(gr,{...d}):null,j=l&&f==null,H=r.useCallback(()=>{const _=we(n.state?.pathnameStackToGoBack),D=_.poppedPathname??"..";e(D,{state:{pathnameStackToGoBack:_.newStack}})},[n.state,e]),O=r.useCallback(()=>{t!=null&&e(`/${t}/cards/policy/new`)},[e,t]),L=r.useCallback(_=>{t!=null&&e(`/${t}/cards/policy/${_}/edit`)},[e,t]),z=r.useCallback(_=>{a(ws(_))},[a]),$=B.fetchState.fetchState;return!x&&$!=="Completed"&&$!=="Error"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(eo,{onBackClick:H,onNewPolicyClick:O,onClickMenuIcon:m,isAiCfoAccessEnabled:l,onAskAiCfoClick:M})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(ao,{policies:k,archivingTemplateId:B.archiveTargetTemplateId,pendingCreationCount:T,onBackClick:H,onNewPolicyClick:O,onEditPolicyClick:L,onArchivePolicyClick:z,onClickMenuIcon:m,policyAiCfoHero:f,isAiCfoAccessEnabled:j,onAskAiCfoClick:M})]})}function Zo(){const e=le(),{cardId:n}=Ve(),t=me(),a=te.getSignedInUser(),s=i(q=>ge(q)),b=Le(),g=Fe(b?.loggedInUserRoleMap),{useFeatureGate:S}=ue();if(a==null)throw Error("Can't access Add To Wallet Page without signing in...");const[P,m]=r.useState(!1),C=i(q=>qa(q).firstViewAfterActivation);if(n==null)throw Error("Empty card id is not valid...");const F=s.userRole.includes("charge_card_user"),{isFeatureEnabled:v}=S(Z.isChargeCardFeatureEnabled),l=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:M}=S(Z.isDebitCardFeatureEnabled),B=xe(s),R=Be(s),p=Re(M,s),h=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,T=Oe({isDebitCardFeatureEnabled:M,isBankingOnlyTenant:p}),u=Ue({isCardsOnlyTenant:B,isChargeCardFeatureEnabled:v,isBookKeepingTenant:R,isDebitCardProductVisible:T,chargeCardsCreditAccountLimit:h}),w=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,E=i(q=>da(q,s.companyId)),U=la(E.controllers),{creditAccount:y,creditAccountRepayment:k}=i(q=>ua(q)),x=i(q=>q.classListState.fetchState),d=!F&&u&&l,f=i(q=>vt(q,n,d,u)),[j,H]=r.useState(!1),O=f.chargeCard,L=O?.cardCreatedByUser?.userId,z=i(q=>L!=null?$a(q.userRoleState,L):void 0),$=z?.accountingClassIDs[0],_=i(q=>$!=null?za(q.classState,{classId:$,reportId:"class_list"}):void 0),D=O?.cardHolderUser?.userId,G=i(q=>D!=null?$a(q.userRoleState,D):void 0),Q=G?.accountingClassIDs[0],I=i(q=>Q!=null?za(q.classState,{classId:Q,reportId:"class_list"}):void 0),N=O?.type.code==="business_physical_credit_card"||O?.type.code==="business_physical_debit_card",W=O?.type.code==="business_physical_debit_card";r.useEffect(()=>{C&&P===!1&&N&&(m(!0),setTimeout(()=>{t(Ka()),W&&t(Ke({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[C,P,N,W]),r.useEffect(()=>{j||f.fetchState==="Completed"||f.fetchState==="In-Progress"||n==null||(H(!0),t(ka(n,d,!1)))},[j,f,n,t]),r.useEffect(()=>{if(f.fetchState==="Completed"&&(N===!1||N&&O?.status?.code!=="active"||O?.cardHolderUserId!==a.userId||C===!1&&P===!1||O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card")){const q=_e(s.tenantEmailDomain,n,a,O,C);e(q)}},[f.fetchState,C,N]),r.useEffect(()=>{y.fetchState!=="Completed"&&y.fetchState!=="In-Progress"&&u&&l&&g&&t(Qe()),k.fetchState!=="Completed"&&k.fetchState!=="In-Progress"&&u&&l&&g&&t(Tt()),x!=="Completed"&&x!=="In-Progress"&&t(Nn())},[y.fetchState,k.fetchState,t,u,l,g,x]);const X=()=>{if(a!=null&&n!=null){t(Ka());const q=_e(s.tenantEmailDomain,n,a);e(q)}},o=O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card",A=Xe(u,T,w,l),Y=Ba(u,l,g,y,k),ne=kr(o,f);return f.fetchState!=="Completed"?c.jsx(va,{fetchState:"In-Progress"}):c.jsxs(c.Fragment,{children:[c.jsx(nt,{showConfetti:C}),c.jsx(to,{onGotItClick:X,isDebitCard:O?.type.code==="business_physical_debit_card",controllerEmails:U,isChargeCardFeatureEnabled:u,isDebitCardFeatureEnabled:T,isDebitCardSetupEnabled:w,isChargeCardSetupEnabled:l,productInformation:A,creditAccountInformation:Y,debitAccountInformation:ne,chargeCardDetailView:f,creditAccount:y,classListFetchState:x,creditAccountRepayment:k,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:_?.className,cardHolderRoles:G?.userRoles,cardHolderDepartmentName:I?.className})]})}const Fr="charge-card-transaction-update",xr="charge-card-transaction-created",Br="charge-card-transaction-declined",Rr="charge-card-transaction-updated",Lr="charge-card-transaction-receipt-uploaded",pa="charge-card-status-update",Ht="charge-card-spending-updated",ot="credit-account-balance-updated",it="charge-card-created",Gt="charge-card-limit-updated",$t="charge-card-limit-reset",zt="charge-card-renamed",Wo="charge-card-department-updated",Or="charge-card-repayment-completed",Ur="charge-card-payment-date-updated",Ra="charge-card-cashback-redeemed",La="charge-card-cashback-earned",ha=(e,n)=>e==null||e===""?[]:n.map(t=>`private-encrypted-${e}.${t}`),Yo=[La,Ra],qo=Pe(function(e){const n=ma(e);return{insightsData:n.insight,cashbackByPeriod:n.cashbackByPeriod,uiState:n.uiState,cashbackSummary:n.cashbackSummary}},function(e){return{onColumnSortConfigChanged:(n,t)=>{e(vs({uiState:{sortKey:n,sortOrder:t}}))}}})(ro);function Qo(){const e=le(),n=me(),t=he(),a=te.getSignedInUser(),s=i(M=>ge(M)),{useFeatureGate:b}=ue(),{isFeatureEnabled:g}=b(Z.isCardsCommentingEnabled),[S,P]=r.useState(!1),m=i(M=>ma(M)),C=_r(s.companyId,{clearParams:m.fetchState==="Completed"}),F=r.useCallback(()=>{const M=we(t.state?.pathnameStackToGoBack),B=M.poppedPathname??Xo(s.tenantEmailDomain);e(B,{state:{pathnameStackToGoBack:M.newStack}})},[e,t,s.tenantEmailDomain]),v=ea(s);if(Vt({events:ha(v,Yo),onEvent:M=>{switch(M){case La:case Ra:return void n(_a(!0))}},onSubscribed:()=>{n(_a(!0))}}),r.useEffect(()=>{S||m.fetchState==="Completed"||m.fetchState==="In-Progress"||(P(!0),n(_a()))},[S,m,n]),a==null)throw Error("Can't access cashback detail page without signing in...");const l=m.cashbackSummary?.cashbackEarned?.amount!=null&&m.fetchState!=="Not-Started";return m.fetchState!=="In-Progress"||l?(m.cashbackSummary?.cashbackEarned?.amount??0)===0&&m.fetchState==="Completed"?c.jsx(ct,{}):c.jsx(qo,{onBackClick:F,isCardsCommentingEnabled:g,initialOpenThreadRequest:C}):c.jsx(no,{onBackClick:F})}const Xo=e=>`/${e}/cards`,Jo={containerWidth:new Fa(100,58)},ei=({appContent:e})=>{const n=Ta(),t=me(),a=le(),{cardId:s}=Ve(),b=he(),{useDynamicConfig:g}=ue(),[S,P]=r.useState(!1),[m,C]=r.useState(!1),[F,v]=r.useState(!1),[l,M]=r.useState(!1),B=te.getSignedInUser();if(B==null)throw Error("Can't access onboarding card page without signing in...");const R=i(I=>ge(I));if(s==null)throw Error("Empty card id is not valid...");const{configValue:p}=g(Ze.zeniCardsConfig),h=p.max_charge_card_activation_attempts_by_card_id,T=i(I=>Ts(I,s)),u=T.chargeCard,w=i(I=>I.chargeCardConfigState.fetchState),{useFeatureGate:E}=ue(),{isFeatureEnabled:U}=E(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:y}=E(Z.isDebitCardFeatureEnabled),k=Re(y,R),x=Oe({isDebitCardFeatureEnabled:y,isBankingOnlyTenant:k}),d=!!R.companyChargeCardInfo?.info?.isChargeCardEnabled,f=R.userRole.includes("charge_card_user"),j=xe(R),H=Be(R),O=R.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,L=Ue({isCardsOnlyTenant:j,isChargeCardFeatureEnabled:U,isBookKeepingTenant:H,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:O}),z=!f&&L&&d;r.useEffect(()=>{S===!1&&w!=="In-Progress"&&w!=="Completed"&&(t(Qa()),P(!0)),m===!1&&T.fetchState==="Not-Started"&&(C(!0),t(ka(s,z,L)))},[m,T.fetchState,S,w]);const $=u?.type.code==="business_physical_credit_card"||u?.type.code==="business_physical_debit_card";r.useEffect(()=>{if(T.fetchState==="Completed"){if(F===!1&&($===!1||$&&u?.status?.code!=="inactive"||u?.cardHolderUserId!==B.userId)){const I=_e(R.tenantEmailDomain,s,B,u,!0),N=ye(b.state?.pathnameStackToGoBack,b.pathname);a(I,{state:{pathnameStackToGoBack:N}})}else if(F&&T.isRefreshingViewInBackground===!1&&u?.status?.code==="active"){t(Fs({chargeCardId:s}));const I=_e(R.tenantEmailDomain,s,B,u,!0),N=ye(b.state?.pathnameStackToGoBack,b.pathname);t(Xa()),a(I,{state:{pathnameStackToGoBack:N}})}}},[T.fetchState,u?.type.code,F,T.isRefreshingViewInBackground]);const _=te.getZeniOtpTokenForCardHolder(s),D=i(I=>Vn(I.userState,B.userId)),G=()=>{u?.status?.code!=="active"&&t(Sa(s,!0))};r.useEffect(()=>{T.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&u?.cardActivationAttemptHistory.some(I=>I.statusCode==="success")===!0&&F===!1&&(setTimeout(G,3e3),v(!0))},[T.updatePhysicalChargeCardAttemptFetchState.fetchState,u?.cardActivationAttemptHistory]);const Q=I=>{M(I)};if(w!=="Completed"||u==null)return c.jsx(va,{fetchState:"In-Progress"});if(u.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(D?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(ni,{children:[c.jsx(Ie,{isAppContentDrawerOpen:l,handleDrawerToggle:Q}),c.jsx(ai,{cardId:s,card:u,shippingAddressId:u.shippingAddressId,phone:D.phone,signedInUser:B,isSandboxEnv:Lt(),chargeCardDetailState:T,signedInUserToken:_,navigate:a,currentTenant:R,location:b,maxChargeCardActivationAttempts:h[s]!=null?h[s]:p.default_max_charge_card_activation_attempts!=null?p.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:p.charge_card_cashback_rate_per_transaction!=null?p.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{Q(!0)}}),e!=null?c.jsx(ti,{windowSize:n,children:e}):null]})},ai=Pe(function(e,{chargeCardDetailState:n,shippingAddressId:t,location:a,cardId:s}){const b=xs(e.addressState,t);if(b==null)throw Error("Can't access shippingAddress.");const g=Hn(e,s),S=n.updateStatus,P=Ca(e,!1,!1,!1);let m=!1;P.fetchState==="Completed"&&P.cards.length<=1&&(m=!0);const C=a.state?.message==="comingFromV2UrlPath";return{showActivatePage:n.chargeCard?.providerCardCreateTime!=null&&n.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Bs())||C,showMenuIcon:m,shippingAddress:b,vgsVaultId:rt.cardVaultId,twoFAView:g,activationWaitStatus:S,isRefreshingViewInBackground:n.isRefreshingViewInBackground}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:b,chargeCardDetailState:g}=n,S=g.chargeCard?.cardProviderID,{tenantEmailDomain:P}=b;return{onGetOtp:m=>{S!=null&&e(at(m,"ChargeCardHolder",a))},onUpdatePhysicalChargeCardAttempt:m=>{e(Ls(a,m))},onResendOtp:m=>{S!=null&&e(et(m,"ChargeCardHolder",a))},onVerifyOtp:(m,C)=>{S!=null&&e(Ja(m,C,"ChargeCardHolder",a))},onVerifyOtpSuccess:m=>{m!=null&&te.saveZeniOtpTokenForCardHolder(m,a)},onCVVActivateSuccess:()=>{e(Rs({chargeCardId:a}))},onBackClick:()=>{const m=we(s.state?.pathnameStackToGoBack),C=m.poppedPathname==null||m.poppedPathname.includes("onboard")===!0?aa(P):m.poppedPathname;t(C,{state:{pathnameStackToGoBack:m.newStack}})}}})(so),ti=He.div`
1
+ import{j as c}from"./liveblocks-B2D23g1h.js";import{u as me,j as i,h as le,g as he,i as Ve,N as oa,s as _t,n as Pe,t as Dn,o as ss,p as ce}from"./core-FEzHdTwu.js";import{f8 as Pt,RW as cs,fk as wt,bt as Fe,RX as os,RY as is,eZ as hn,RZ as _n,f6 as Pn,R_ as wn,R$ as vn,S0 as Tn,S1 as Fn,f7 as xn,fj as Bn,S2 as Ln,S3 as ds,fd as ls,fc as us,S4 as ms,C5 as Rn,fm as ia,S5 as Cs,S6 as ps,e$ as hs,e_ as fs,fz as Ye,ff as On,fe as Un,S7 as gs,fg as Ss,BC as bs,BB as ys,BF as Is,BH as ks,fs as Es,eW as jn,S8 as As,S9 as Ds,fx as Mn,Sa as _s,fy as yt,BN as Ps,BK as ws,eX as ge,Sb as qa,fC as xe,fD as Be,fE as Le,gw as da,cv as la,Sc as ua,Sd as vt,uT as $a,kF as za,Se as Ya,Cl as ka,fn as Qe,Cn as Tt,kv as Nn,Sf as ma,C9 as _a,Sg as vs,Sh as Ts,Cc as Qa,Si as Fs,Qi as Xa,fi as Vn,Ci as Sa,hV as xs,Sj as Hn,f9 as Ca,bo as Bs,Sk as Ls,gh as Ja,gg as et,CR as Rs,gf as at,P_ as Os,Sl as Gn,co as $n,cQ as Us,Qh as wa,Dq as zn,Sm as fn,D0 as Pa,Sn as Yn,Dr as js,QG as Ms,Ds as Ns,Ex as Vs,ub as Hs,Er as Gs,So as $s,Cm as sa,Sp as zs,Sq as Ys,Sr as Ws,Ss as Ks,St as Zs,Su as Ft,Sv as qs,CC as Wn,Cv as Qs,Sw as Xs,gy as Js,CL as Kn,CP as Zn,gx as ec,Sx as ac,Dc as qn,Sy as tc,Sz as nc,SA as rc,CN as Qn,Cy as Xn,Cf as Jn,CH as er,CF as ar,CJ as sc,SB as tr,SC as cc,fu as oc,fv as ic,fw as dc,SD as tt,fo as nr,cS as xt,SE as lc,SF as uc,SG as mc,SH as Cc,CX as It,Dj as pc,Df as hc,CT as fc,Dh as gc,D7 as Sc,D9 as bc,SI as rr,Dp as Ga,Kg as yc,SJ as Ic,SK as kc,SL as Ec,SM as sr,SN as Ac,DM as Dc,C$ as cr,CW as Ne,C_ as _c,SO as Pc,SP as wc,C6 as vc,SQ as or,fh as ir,SR as Tc,C8 as Fc,C7 as gn,SS as xc,ST as Bc,SU as Lc,MN as Rc,SV as Bt,SW as Oc,xU as dr,ld as Uc,hL as jc,DR as Mc,SX as lr,f3 as Nc,f4 as Vc,SY as Hc,dj as Gc,fl as $c,DH as zc,DB as qe,bs as Yc,bJ as Wc,cA as Kc,bK as Zc,L_ as qc}from"./zeni-epic-state-Bxb-N0Vf.js";import{j as Re,cr as ur,p as we,cs as mr,ct as Cr,cu as Qc,a as Je,a0 as Lt,cv as Xc,cw as Jc,Y as pr,c as hr,$ as fr,q as ye,C as ue,U as W,ar as ya,cx as gr,cy as eo,cz as ao,z as te,B as va,cg as nt,cA as to,cB as no,cC as ro,K as Ta,aS as We,bt as Rt,cD as so,E as Fa,h as rt,y as Ot,d as J,a9 as st,cE as co,bG as ba,cF as kt,cG as oo,x as Ut,cH as io,au as Sr,a4 as Et,cI as lo,Z as br,R as uo,f as yr,cJ as mo,cK as Co,cL as po,cM as ho,cN as fo,cO as go,cP as So,o as Wa,cQ as bo,cR as yo,cS as ht,v as Io,cT as ko,cU as Eo,cV as Ao,cW as Do,cX as _o,i as Po}from"./index-pXx5w7oJ.js";import{n as He,D as Ir,S as wo}from"./mui-C754KMjM.js";import{a as r}from"./sentry-BQ1KU1t3.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-Be2oPcqW.js";import{M as Ie}from"./MobileAppDrawer-C4Qb7oTx.js";import{d as jt}from"./recharts-CIXkvtnT.js";import{g as _e,a as Ba,b as kr,c as Oe,d as Ue,e as Xe,f as ea,h as aa,A as vo,i as Mt,P as To,j as Nt,s as Ia,k as Er,l as ca,m as Ar,n as Fo,o as Dr,p as xo,S as Sn}from"./SetupPagesScreen-CZVsa4S1.js";import{u as _r}from"./useInitialThreadRequest-qt3qTzlR.js";import ct from"./NotFoundScreen-DF585FcE.js";import{u as Vt}from"./useChargeCardPusherEvents-B89u0v4H.js";import{n as bn}from"./utils-C8oTXAPM.js";import{t as Bo}from"./AddressScreen-Chily4bM.js";import"./analytics-BY30ztud.js";import"./plaid--k8gbxl0.js";import"./dnd-Cb_vPZwC.js";import"./stripe-DMRn4zHo.js";import"./lottie-BKshFrBj.js";import"./lexical-fJeYHrZP.js";import"./pdf-BSvba1pn.js";import"./analyticsHelper-CxPzmrE2.js";import"./routePaths-x0riE4xM.js";import"./BusinessVerificationPageScreen-D5dvQNJp.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ab8c60e7-5dc0-4c3f-8847-ef548174d076",e._sentryDebugIdIdentifier="sentry-dbid-ab8c60e7-5dc0-4c3f-8847-ef548174d076")}catch{}})();const Lo=e=>{const n=e.cardHolderUser,t=`${n.firstName??""} ${n.lastName??""}`.trim()||n.email||n.userId;return{userId:n.userId,displayName:t,roleLabel:e.cardHolderRoles?.titleAtCompany}},Pr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:Lo(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)});function wr(){const e=me(),n=i(a=>Pt(a.cardPolicyState)),t=i(a=>cs(a.cardPolicyState));r.useEffect(()=>{t!==""||n==="Completed"&&t===""||n==="In-Progress"||e(wt())},[e,n,t])}const{spendManagement:{chargeCard:{cardPolicyPage:yn}}}=Je.getLocalizedStrings(),Ro=e=>On(e,!1),Oo=e=>Un(e.name,!1);function Uo(){const e=le(),n=he(),{tenantEmailDomain:t}=Ve(),a=me(),s=Re(),b=Fe(s?.loggedInUserRoleMap),[g,S]=r.useState(!1),P=r.useCallback(A=>{S(A)},[]),m=r.useCallback(()=>{P(!0)},[P]),{isAiCfoAccessEnabled:C,onAskAiCfoClick:F}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect(()=>()=>{a(os()),a(is()),a(hn())},[a]);const v=i(A=>_n(A.cardPolicyState)),l=i(A=>Pn(A.cardPolicyState)),M=i(A=>wn(A.cardPolicyState)),B=i(A=>vn(A.cardPolicyState)),L=i(A=>Tn(A.cardPolicyState)),p=i(A=>Fn(A.cardPolicyState)),h=i(A=>xn(A.cardPolicyState)),T=i(A=>Pt(A.cardPolicyState)),u=i(A=>A.chargeCardConfigState.receiptRequiredAboveAmount.amount),w=i(A=>A.chargeCardConfigState.fetchState);r.useEffect(()=>{v!=="Completed"&&v!=="In-Progress"&&a(Bn())},[a,v]),wr();const E=i(A=>Ln(A.createCardPolicyState)),U=i(A=>ds(A.createCardPolicyState)),y=i(A=>ls(A.cardPolicyState)),k=i(A=>us(A.cardPolicyState)),x=i(A=>ms(A.createCardPolicyState)),d=i(A=>Rn(A));r.useEffect(()=>{d.fetchState==="Not-Started"&&a(ia(!1,!1,!1))},[d.fetchState,a]);const f=r.useMemo(()=>l.map(Ro),[l]),j=r.useMemo(()=>h.map(Oo),[h]),H=r.useMemo(()=>d.cards.filter(A=>!ur(A.status.code)).map(Pr),[d.cards]),O=v==="Completed"&&d.fetchState==="Completed"&&w==="Completed";r.useEffect(()=>{O&&x==null&&a(Cs({cardsMasterList:H,defaultRequireReceiptAmount:u,suggestedAllowMerchants:M,suggestedBlockMerchants:B,suggestedAllowCategories:L,suggestedBlockCategories:p}))},[w,a,O,x,H,u,M,B,L,p]);const R=r.useMemo(()=>jt(A=>{a(wt(A))},250),[a]);r.useEffect(()=>()=>{R.cancel()},[R]);const z=r.useCallback(A=>{R(A)},[R]),$=E.fetchState,_=t!=null?`/${t}/cards/policy`:"..",D=r.useCallback(()=>{const A=we(n.state?.pathnameStackToGoBack),Z=A.poppedPathname??_;e(Z,{state:{pathnameStackToGoBack:A.newStack}})},[n.state,e,_]),G=r.useCallback(()=>{e(_)},[e,_]),Q=r.useCallback(A=>{a(ps(A))},[a]),I=r.useCallback(A=>{const Z=mr(A);a(hs({templates:[Z]}))},[a]),N=r.useCallback(A=>{A.length!==0&&a(fs(A))},[a]),K=r.useCallback(()=>{a(hn())},[a]),X=r.useRef($);r.useEffect(()=>{const A=X.current;X.current=$,$==="Completed"&&A!=="Completed"&&U!=null&&(a(Ye({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(_))},[a,$,U,e,_]);const o=$==="Error"?E.error?.message??yn.createPolicyGenericErrorMessage:void 0;return b&&t!=null?x==null?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(Cr,{showUploadDocumentSection:!0,navBarTitle:yn.createPageTitle,onBackClick:D,onClickMenuIcon:m,isAiCfoAccessEnabled:C,onAskAiCfoClick:F})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(Qc,{formDraft:x,vendorSearchOptions:j,categorySearchOptions:f,isVendorSearchLoading:T==="In-Progress",onVendorSearchTextChange:z,submitState:$,submitErrorMessage:o,documentUploadState:y,uploadedFileName:k,isAiCfoAccessEnabled:C,onAskAiCfoClick:F,onBackClick:D,onCancelClick:G,onClickMenuIcon:m,onFormChange:Q,onSubmit:I,onUploadDocument:N,onRemoveDocument:K})]}):c.jsx(oa,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:jo}}}=Je.getLocalizedStrings(),Mo=e=>On(e,!1),No=e=>Un(e.name,!1);function Vo(){const e=le(),n=he(),{tenantEmailDomain:t,templateId:a}=Ve(),s=me(),b=Re(),g=Fe(b?.loggedInUserRoleMap),[S,P]=r.useState(!1),m=r.useCallback(o=>{P(o)},[]),C=r.useCallback(()=>{m(!0)},[m]),{isAiCfoAccessEnabled:F,onAskAiCfoClick:v}=xa({mobileExploreReferrer:"Card Policy"}),l=i(o=>gs(o)),M=i(o=>_n(o.cardPolicyState)),B=i(o=>Pn(o.cardPolicyState)),L=i(o=>wn(o.cardPolicyState)),p=i(o=>vn(o.cardPolicyState)),h=i(o=>Tn(o.cardPolicyState)),T=i(o=>Fn(o.cardPolicyState)),u=i(o=>xn(o.cardPolicyState)),w=i(o=>Pt(o.cardPolicyState)),E=i(o=>Rn(o)),U=i(o=>a!=null?Ss(o.cardPolicyState,a):void 0),y=r.useMemo(()=>l.templateId===a&&l.formDraft!=null?l.formDraft:U!=null?bs(U):void 0,[l.templateId,l.formDraft,U,a]);r.useEffect(()=>{if(a==null)return;const o=l.detailFetchState.fetchState;l.templateId===a&&(o==="Completed"||o==="In-Progress")||U!=null||s(ys(a))},[s,a,l.templateId,l.detailFetchState.fetchState,U]),r.useEffect(()=>{M!=="Completed"&&M!=="In-Progress"&&s(Bn())},[s,M]),wr();const k=i(o=>o.chargeCardConfigState.receiptRequiredAboveAmount.amount);r.useEffect(()=>{E.fetchState==="Not-Started"&&s(ia(!1,!1,!1))},[E.fetchState,s]);const x=r.useMemo(()=>B.map(Mo),[B]),d=r.useMemo(()=>u.map(No),[u]),f=r.useMemo(()=>E.cards.filter(o=>!ur(o.status.code)).map(Pr),[E.cards]);Lt({isDataReady:y!=null});const j=r.useMemo(()=>{if(y!=null)return Xc({draft:y,cardRows:f,categorySearchOptions:x,vendorSearchOptions:d,defaultRequireReceiptAmount:k,suggestedAllowMerchants:L,suggestedBlockMerchants:p,suggestedAllowCategories:h,suggestedBlockCategories:T})},[y,f,x,d,k,L,p,h,T]),[H,O]=r.useState(void 0),R=r.useRef(!1);r.useEffect(()=>{R.current||H!=null||j==null||(R.current=!0,O(j))},[H,j]);const z=r.useCallback(o=>{O(o)},[]),$=r.useMemo(()=>jt(o=>{s(wt(o))},250),[s]);r.useEffect(()=>()=>{$.cancel()},[$]);const _=r.useCallback(o=>{$(o)},[$]),D=l.updateFetchState.fetchState,G=t!=null?`/${t}/cards/policy`:"..",Q=r.useCallback(()=>{const o=we(n.state?.pathnameStackToGoBack),A=o.poppedPathname??G;e(A,{state:{pathnameStackToGoBack:o.newStack}})},[n.state,e,G]),I=r.useCallback(()=>{e(G)},[e,G]),N=r.useCallback(o=>{if(a==null)return;const A=mr(o);s(Is(A)),s(ks(a))},[s,a]),K=r.useRef(D);r.useEffect(()=>{const o=K.current;K.current=D,D==="Completed"&&o!=="Completed"&&(s(Ye({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(G))},[s,D,e,G]);const X=D==="Error"?l.updateFetchState.error?.message??jo.updatePolicyGenericErrorMessage:void 0;return!g||t==null||a==null?c.jsx(oa,{to:"..",replace:!0}):H!=null&&M==="Completed"&&E.fetchState==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:m}),c.jsx(Jc,{templateName:l.template?.name??"",formDraft:H,vendorSearchOptions:d,categorySearchOptions:x,isVendorSearchLoading:w==="In-Progress",onVendorSearchTextChange:_,submitState:D,submitErrorMessage:X,isAiCfoAccessEnabled:F,onAskAiCfoClick:v,onBackClick:Q,onCancelClick:I,onClickMenuIcon:C,onFormChange:z,onSubmit:N})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:m}),c.jsx(Cr,{showUploadDocumentSection:!1,navBarTitle:l.template?.name,onBackClick:Q,onClickMenuIcon:C,isAiCfoAccessEnabled:F,onAskAiCfoClick:v})]})}function vr(e,n,t){return n?e.filter(a=>a!=null&&a.trim().length>0).slice(0,t):[]}function Tr(e){return i(n=>e==null||e===""?{chips:ft,isResolved:!1}:function(t){const a=t?.fetchState,s=a==="Completed"||a==="Error";return{chips:a==="Completed"?t?.suggestedQuestions??ft:ft,isResolved:s}}(Es(n,e)),_t)}const ft=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Ho,subheadline:Go,pageTitle:$o}}}}=Je.getLocalizedStrings(),zo=e=>{const n=e.cardsCount>0?e.cardsCount:e.appliedCards.length,t=e.allowedEntity.merchantNames.length+e.blockedEntity.merchantNames.length,a=e.allowedEntity.categoryCodes.length+e.blockedEntity.categoryCodes.length;return{templateId:e.templateId,name:e.name,description:e.description,mode:e.mode==="flexible"?"flexible":"strict",createdAtFormatted:e.createdAt.format("ll"),cardsCount:n,vendorRestrictionsCount:t,categoryRestrictionsCount:a}};function Yo(){const e=le(),n=he(),{tenantEmailDomain:t}=Ve(),a=me(),s=Re(),b=Fe(s?.loggedInUserRoleMap),[g,S]=r.useState(!1),P=r.useCallback(_=>{S(_)},[]),m=r.useCallback(()=>{P(!0)},[P]),{useFeatureGate:C}=ue(),{isFeatureEnabled:F}=C(W.isAiCfoFileUploadEnabled),{isFeatureEnabled:v}=C(W.isCardPolicyEnabled),{isAiCfoAccessEnabled:l,onAskAiCfoClick:M}=xa({mobileExploreReferrer:"Card Policy"}),B=i(_=>As(_)),L=i(_=>Ln(_.createCardPolicyState)),p=i(_=>Ds(_.createCardPolicyState)),h=i(_=>p==null?[]:Mn(_.aiCfoState,p).filter(D=>D.kind==="creating_policy"),_t),T=L.fetchState==="In-Progress"?Math.max(h.length,1):0,u=i(_=>_s(_.createCardPolicyState)),w=ya(L.fetchState);r.useEffect(()=>{if(w==="In-Progress"&&L.fetchState==="Completed"&&p!=null)h.forEach(_=>{a(yt({chatSessionId:p,id:_.id,entityIds:u,kind:"created_policy"}))});else if(w==="In-Progress"&&L.fetchState==="Error"&&p!=null){h.forEach(D=>{a(yt({chatSessionId:p,id:D.id,kind:"errored_policy"}))});const _=L.error?.message!=null&&L.error.message.length>0?L.error.message:Je.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;a(Ye({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:_}]}))}},[L.error?.message,L.fetchState,a,p,u,h,w]);const E=B.fetchState.fetchState;r.useEffect(()=>{E!=="Not-Started"&&E!=="Error"||a(Ps())},[a,E]);const U=B.archiveFetchState.fetchState,y=ya(U);r.useEffect(()=>{y==="In-Progress"&&U==="Completed"&&a(Ye({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))},[U,a,y]);const k=r.useMemo(()=>B.templates.map(zo),[B.templates]);Lt({isDataReady:B.fetchState.fetchState==="Completed"});const x=k.length>0||T>0,d=function(_){const{hasAnyPolicies:D,isChargeCardAdmin:G,isFileUploadEnabled:Q}=_,I=le(),N=he(),{tenantEmailDomain:K}=Ve(),{isAiCfoOpen:X,setIsAiCfoOpen:o}=pr(),A=hr(),Z=fr(),ne=i(oe=>jn(oe)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:q,isResolved:ke}=Tr("card_policy"),ve=r.useMemo(()=>vr(q,ke,3),[q,ke]),[fe,se]=r.useState(""),Ee=Z&&A&&K!=null&&!X,re=r.useCallback(oe=>{if(K==null)return;const fa=ye(N.state?.pathnameStackToGoBack,N.pathname);I(`/${K}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:fa,referrer:"card_policy_hero",aiCfoInitialQuestion:oe,aiCfoShouldSubmit:oe!=null&&oe.trim().length>0}})},[N.pathname,N.state,I,K]),Ce=r.useCallback(oe=>{oe.trim().length!==0&&(se(""),re(oe))},[re]),Ae=r.useCallback(()=>{const oe=fe.trim();oe.length!==0&&(se(""),re(oe))},[fe,re]),ee=r.useCallback(()=>{},[]),Te=r.useCallback(oe=>{se(oe)},[]),De=r.useCallback(()=>{o(!0)},[o]),ae=r.useCallback(()=>{re(void 0)},[re]);return r.useMemo(()=>{if(Ee&&!D&&G)return{aiAgentName:$o,headline:Ho,subheadline:Go,promptChips:ve,composer:{currentInput:fe,isSubmitting:ne,isFileUploadEnabled:Q,onInputChange:Te,onSubmit:Ae,onStopSubmit:ee},onPromptClick:Ce,onOpenSidePanel:De,onOpenFullView:ae,dataTestIdPrefix:"card-policy-ai-cfo-hero"}},[fe,D,Ee,G,Q,ne,Te,ae,De,Ce,ee,Ae,ve])}({hasAnyPolicies:x,isChargeCardAdmin:b,isFileUploadEnabled:F}),f=v&&d!=null?c.jsx(gr,{...d}):null,j=l&&f==null,H=r.useCallback(()=>{const _=we(n.state?.pathnameStackToGoBack),D=_.poppedPathname??"..";e(D,{state:{pathnameStackToGoBack:_.newStack}})},[n.state,e]),O=r.useCallback(()=>{t!=null&&e(`/${t}/cards/policy/new`)},[e,t]),R=r.useCallback(_=>{t!=null&&e(`/${t}/cards/policy/${_}/edit`)},[e,t]),z=r.useCallback(_=>{a(ws(_))},[a]),$=B.fetchState.fetchState;return!x&&$!=="Completed"&&$!=="Error"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(eo,{onBackClick:H,onNewPolicyClick:O,onClickMenuIcon:m,isAiCfoAccessEnabled:l,onAskAiCfoClick:M})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(ao,{policies:k,archivingTemplateId:B.archiveTargetTemplateId,pendingCreationCount:T,onBackClick:H,onNewPolicyClick:O,onEditPolicyClick:R,onArchivePolicyClick:z,onClickMenuIcon:m,policyAiCfoHero:f,isAiCfoAccessEnabled:j,onAskAiCfoClick:M})]})}function Wo(){const e=le(),{cardId:n}=Ve(),t=me(),a=te.getSignedInUser(),s=i(q=>ge(q)),b=Re(),g=Fe(b?.loggedInUserRoleMap),{useFeatureGate:S}=ue();if(a==null)throw Error("Can't access Add To Wallet Page without signing in...");const[P,m]=r.useState(!1),C=i(q=>qa(q).firstViewAfterActivation);if(n==null)throw Error("Empty card id is not valid...");const F=s.userRole.includes("charge_card_user"),{isFeatureEnabled:v}=S(W.isChargeCardFeatureEnabled),l=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:M}=S(W.isDebitCardFeatureEnabled),B=xe(s),L=Be(s),p=Le(M,s),h=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,T=Oe({isDebitCardFeatureEnabled:M,isBankingOnlyTenant:p}),u=Ue({isCardsOnlyTenant:B,isChargeCardFeatureEnabled:v,isBookKeepingTenant:L,isDebitCardProductVisible:T,chargeCardsCreditAccountLimit:h}),w=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,E=i(q=>da(q,s.companyId)),U=la(E.controllers),{creditAccount:y,creditAccountRepayment:k}=i(q=>ua(q)),x=i(q=>q.classListState.fetchState),d=!F&&u&&l,f=i(q=>vt(q,n,d,u)),[j,H]=r.useState(!1),O=f.chargeCard,R=O?.cardCreatedByUser?.userId,z=i(q=>R!=null?$a(q.userRoleState,R):void 0),$=z?.accountingClassIDs[0],_=i(q=>$!=null?za(q.classState,{classId:$,reportId:"class_list"}):void 0),D=O?.cardHolderUser?.userId,G=i(q=>D!=null?$a(q.userRoleState,D):void 0),Q=G?.accountingClassIDs[0],I=i(q=>Q!=null?za(q.classState,{classId:Q,reportId:"class_list"}):void 0),N=O?.type.code==="business_physical_credit_card"||O?.type.code==="business_physical_debit_card",K=O?.type.code==="business_physical_debit_card";r.useEffect(()=>{C&&P===!1&&N&&(m(!0),setTimeout(()=>{t(Ya()),K&&t(Ye({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[C,P,N,K]),r.useEffect(()=>{j||f.fetchState==="Completed"||f.fetchState==="In-Progress"||n==null||(H(!0),t(ka(n,d,!1)))},[j,f,n,t]),r.useEffect(()=>{if(f.fetchState==="Completed"&&(N===!1||N&&O?.status?.code!=="active"||O?.cardHolderUserId!==a.userId||C===!1&&P===!1||O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card")){const q=_e(s.tenantEmailDomain,n,a,O,C);e(q)}},[f.fetchState,C,N]),r.useEffect(()=>{y.fetchState!=="Completed"&&y.fetchState!=="In-Progress"&&u&&l&&g&&t(Qe()),k.fetchState!=="Completed"&&k.fetchState!=="In-Progress"&&u&&l&&g&&t(Tt()),x!=="Completed"&&x!=="In-Progress"&&t(Nn())},[y.fetchState,k.fetchState,t,u,l,g,x]);const X=()=>{if(a!=null&&n!=null){t(Ya());const q=_e(s.tenantEmailDomain,n,a);e(q)}},o=O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card",A=Xe(u,T,w,l),Z=Ba(u,l,g,y,k),ne=kr(o,f);return f.fetchState!=="Completed"?c.jsx(va,{fetchState:"In-Progress"}):c.jsxs(c.Fragment,{children:[c.jsx(nt,{showConfetti:C}),c.jsx(to,{onGotItClick:X,isDebitCard:O?.type.code==="business_physical_debit_card",controllerEmails:U,isChargeCardFeatureEnabled:u,isDebitCardFeatureEnabled:T,isDebitCardSetupEnabled:w,isChargeCardSetupEnabled:l,productInformation:A,creditAccountInformation:Z,debitAccountInformation:ne,chargeCardDetailView:f,creditAccount:y,classListFetchState:x,creditAccountRepayment:k,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:_?.className,cardHolderRoles:G?.userRoles,cardHolderDepartmentName:I?.className})]})}const Fr="charge-card-transaction-update",xr="charge-card-transaction-created",Br="charge-card-transaction-declined",Lr="charge-card-transaction-updated",Rr="charge-card-transaction-receipt-uploaded",pa="charge-card-status-update",Ht="charge-card-spending-updated",ot="credit-account-balance-updated",it="charge-card-created",Gt="charge-card-limit-updated",$t="charge-card-limit-reset",zt="charge-card-renamed",Ko="charge-card-department-updated",Or="charge-card-repayment-completed",Ur="charge-card-payment-date-updated",La="charge-card-cashback-redeemed",Ra="charge-card-cashback-earned",ha=(e,n)=>e==null||e===""?[]:n.map(t=>`private-encrypted-${e}.${t}`),Zo=[Ra,La],qo=Pe(function(e){const n=ma(e);return{insightsData:n.insight,cashbackByPeriod:n.cashbackByPeriod,uiState:n.uiState,cashbackSummary:n.cashbackSummary}},function(e){return{onColumnSortConfigChanged:(n,t)=>{e(vs({uiState:{sortKey:n,sortOrder:t}}))}}})(ro);function Qo(){const e=le(),n=me(),t=he(),a=te.getSignedInUser(),s=i(M=>ge(M)),{useFeatureGate:b}=ue(),{isFeatureEnabled:g}=b(W.isCardsCommentingEnabled),[S,P]=r.useState(!1),m=i(M=>ma(M)),C=_r(s.companyId,{clearParams:m.fetchState==="Completed"}),F=r.useCallback(()=>{const M=we(t.state?.pathnameStackToGoBack),B=M.poppedPathname??Xo(s.tenantEmailDomain);e(B,{state:{pathnameStackToGoBack:M.newStack}})},[e,t,s.tenantEmailDomain]),v=ea(s);if(Vt({events:ha(v,Zo),onEvent:M=>{switch(M){case Ra:case La:return void n(_a(!0))}},onSubscribed:()=>{n(_a(!0))}}),r.useEffect(()=>{S||m.fetchState==="Completed"||m.fetchState==="In-Progress"||(P(!0),n(_a()))},[S,m,n]),a==null)throw Error("Can't access cashback detail page without signing in...");const l=m.cashbackSummary?.cashbackEarned?.amount!=null&&m.fetchState!=="Not-Started";return m.fetchState!=="In-Progress"||l?(m.cashbackSummary?.cashbackEarned?.amount??0)===0&&m.fetchState==="Completed"?c.jsx(ct,{}):c.jsx(qo,{onBackClick:F,isCardsCommentingEnabled:g,initialOpenThreadRequest:C}):c.jsx(no,{onBackClick:F})}const Xo=e=>`/${e}/cards`,Jo={containerWidth:new Fa(100,58)},ei=({appContent:e})=>{const n=Ta(),t=me(),a=le(),{cardId:s}=Ve(),b=he(),{useDynamicConfig:g}=ue(),[S,P]=r.useState(!1),[m,C]=r.useState(!1),[F,v]=r.useState(!1),[l,M]=r.useState(!1),B=te.getSignedInUser();if(B==null)throw Error("Can't access onboarding card page without signing in...");const L=i(I=>ge(I));if(s==null)throw Error("Empty card id is not valid...");const{configValue:p}=g(We.zeniCardsConfig),h=p.max_charge_card_activation_attempts_by_card_id,T=i(I=>Ts(I,s)),u=T.chargeCard,w=i(I=>I.chargeCardConfigState.fetchState),{useFeatureGate:E}=ue(),{isFeatureEnabled:U}=E(W.isChargeCardFeatureEnabled),{isFeatureEnabled:y}=E(W.isDebitCardFeatureEnabled),k=Le(y,L),x=Oe({isDebitCardFeatureEnabled:y,isBankingOnlyTenant:k}),d=!!L.companyChargeCardInfo?.info?.isChargeCardEnabled,f=L.userRole.includes("charge_card_user"),j=xe(L),H=Be(L),O=L.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,R=Ue({isCardsOnlyTenant:j,isChargeCardFeatureEnabled:U,isBookKeepingTenant:H,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:O}),z=!f&&R&&d;r.useEffect(()=>{S===!1&&w!=="In-Progress"&&w!=="Completed"&&(t(Qa()),P(!0)),m===!1&&T.fetchState==="Not-Started"&&(C(!0),t(ka(s,z,R)))},[m,T.fetchState,S,w]);const $=u?.type.code==="business_physical_credit_card"||u?.type.code==="business_physical_debit_card";r.useEffect(()=>{if(T.fetchState==="Completed"){if(F===!1&&($===!1||$&&u?.status?.code!=="inactive"||u?.cardHolderUserId!==B.userId)){const I=_e(L.tenantEmailDomain,s,B,u,!0),N=ye(b.state?.pathnameStackToGoBack,b.pathname);a(I,{state:{pathnameStackToGoBack:N}})}else if(F&&T.isRefreshingViewInBackground===!1&&u?.status?.code==="active"){t(Fs({chargeCardId:s}));const I=_e(L.tenantEmailDomain,s,B,u,!0),N=ye(b.state?.pathnameStackToGoBack,b.pathname);t(Xa()),a(I,{state:{pathnameStackToGoBack:N}})}}},[T.fetchState,u?.type.code,F,T.isRefreshingViewInBackground]);const _=te.getZeniOtpTokenForCardHolder(s),D=i(I=>Vn(I.userState,B.userId)),G=()=>{u?.status?.code!=="active"&&t(Sa(s,!0))};r.useEffect(()=>{T.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&u?.cardActivationAttemptHistory.some(I=>I.statusCode==="success")===!0&&F===!1&&(setTimeout(G,3e3),v(!0))},[T.updatePhysicalChargeCardAttemptFetchState.fetchState,u?.cardActivationAttemptHistory]);const Q=I=>{M(I)};if(w!=="Completed"||u==null)return c.jsx(va,{fetchState:"In-Progress"});if(u.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(D?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(ni,{children:[c.jsx(Ie,{isAppContentDrawerOpen:l,handleDrawerToggle:Q}),c.jsx(ai,{cardId:s,card:u,shippingAddressId:u.shippingAddressId,phone:D.phone,signedInUser:B,isSandboxEnv:Rt(),chargeCardDetailState:T,signedInUserToken:_,navigate:a,currentTenant:L,location:b,maxChargeCardActivationAttempts:h[s]!=null?h[s]:p.default_max_charge_card_activation_attempts!=null?p.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:p.charge_card_cashback_rate_per_transaction!=null?p.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{Q(!0)}}),e!=null?c.jsx(ti,{windowSize:n,children:e}):null]})},ai=Pe(function(e,{chargeCardDetailState:n,shippingAddressId:t,location:a,cardId:s}){const b=xs(e.addressState,t);if(b==null)throw Error("Can't access shippingAddress.");const g=Hn(e,s),S=n.updateStatus,P=Ca(e,!1,!1,!1);let m=!1;P.fetchState==="Completed"&&P.cards.length<=1&&(m=!0);const C=a.state?.message==="comingFromV2UrlPath";return{showActivatePage:n.chargeCard?.providerCardCreateTime!=null&&n.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Bs())||C,showMenuIcon:m,shippingAddress:b,vgsVaultId:rt.cardVaultId,twoFAView:g,activationWaitStatus:S,isRefreshingViewInBackground:n.isRefreshingViewInBackground}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:b,chargeCardDetailState:g}=n,S=g.chargeCard?.cardProviderID,{tenantEmailDomain:P}=b;return{onGetOtp:m=>{S!=null&&e(at(m,"ChargeCardHolder",a))},onUpdatePhysicalChargeCardAttempt:m=>{e(Rs(a,m))},onResendOtp:m=>{S!=null&&e(et(m,"ChargeCardHolder",a))},onVerifyOtp:(m,C)=>{S!=null&&e(Ja(m,C,"ChargeCardHolder",a))},onVerifyOtpSuccess:m=>{m!=null&&te.saveZeniOtpTokenForCardHolder(m,a)},onCVVActivateSuccess:()=>{e(Ls({chargeCardId:a}))},onBackClick:()=>{const m=we(s.state?.pathnameStackToGoBack),C=m.poppedPathname==null||m.poppedPathname.includes("onboard")===!0?aa(P):m.poppedPathname;t(C,{state:{pathnameStackToGoBack:m.newStack}})}}})(so),ti=He.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: ${e=>`${Jo.containerWidth.value(e.windowSize)}%`};
@@ -11,18 +11,18 @@ import{j as c}from"./liveblocks-4PIBJMyE.js";import{u as me,j as i,h as le,g as
11
11
  flex-direction: column;
12
12
  align-items: center;
13
13
  background-color: ${e=>e.theme.colors.grey4};
14
- `,Wa=Je.getLocalizedStrings().dateFormat,ri={overlayWidth:new Fa(100,100,58)},jr=[Or,ot],si=new Set(jr),ci=Pe(function(e,n){const t=n.currentTenant?.companyId;return{plaidConnectionDetails:Ms(e,t,"zeni_accounts","external_account").plaidConnectionDetails,depositAccountListView:Ns(e.depositAccountState,e.depositAccountListState)}},function(e,n){const{navigate:t,currentTenant:a,hasZeniAccountsAdminAccess:s,isZeniAccountsUser:b,isCashbackInfoFetchStateCompleted:g,isCreditCardInfoFetchStateCompleted:S,isDebitCardInfoFetchStateCompleted:P,controllerEmails:m,paymentDetails:C,productInformation:F,cashbackInformation:v,paymentSourceInformation:l,creditAccountInformation:M,debitAccountInformation:B,paymentInitiatedDate:R,sourcePage:p}=n,{tenantEmailDomain:h}=a,T=()=>{e(zn(!0));const u=ea(a);u!=null&&u!==""&&e(Pa(u,!0,!0)),e(Qe(!0))};return{onBackNavigation:()=>{if(g&&S&&P&&v!=null&&J.trackCardsPayEarlyFormClick(m,F,v,"Back",C.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:C.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:C.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:C.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:C.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:R?.add(3,"day").format(Wa.visual.MMMDCommaYYYYformat),paymentInitiatedDate:R?.format(Wa.visual.MMMDCommaYYYYformat)},l,M,B),p==="cardPaymentHistory")n.closeDrawerHandler(!0),e(Kn());else{const u=aa(h);t(u)}},onUpdatePaymentAccountStatus:(u,w,E)=>{e(Gs(u,w,"bill_pay","bill_pay_detail",E))},onEstablishConnectionSuccess:()=>{e(Pa(a.companyId,!0))},onFetchLinkTokenClick:u=>{e(Hs("external_account",u))},onEstablishConnectionClick:u=>{e(Vs(u,a.companyId,"charge_card_payment","charge_cards"))},onSignUpAccountClick:()=>{s?window.open(`/${h}/checking/promo`,"_blank"):window.open("https://www.zeni.ai/product/business-checking-accounts","_blank")},onMoveMoneyClick:()=>{b?window.open(`/${h}/checking/transfer`):window.open("https://www.zeni.ai/product/business-checking-accounts","_blank")},onEventReceived:u=>{si.has(u)&&T()},onPusherSubscribed:T}})(st(co)),Kt=({isPaymentDrawerOpen:e,closeDrawerHandler:n,pageName:t,creditAccountSpentAmount:a,productInformation:s,sourcePage:b,creditAccountInformation:g,debitAccountInformation:S,cashbackInformation:P,isDebitCardInfoFetchStateCompleted:m,isCreditCardInfoFetchStateCompleted:C,isCashbackInfoFetchStateCompleted:F,paymentInitiatedDate:v,retryRepayment:l})=>{const M=le(),{useDynamicConfig:B}=ue(),{configValue:R}=B(Ze.zeniAccountsConfig),p=Os(R),h=i(A=>Gn(A)),{creditAccount:T}=i(A=>ua(A)),u=i(A=>ge(A)),w=Ot(),E=Ta(),U=me(),y=te.getSignedInUser(),k=Le(),[x,d]=r.useState(!1),[f,j]=r.useState(!1),{configValue:H}=B(Ze.zeniCardsConfig),O=H.credit_card_auto_pay_threshold_by_company_id?.[u.companyId]??H.default_credit_card_auto_pay_threshold??vo,L=$n(k?.loggedInUserRoleMap),z=Us(k?.loggedInUserRoleMap),$=!!u.companyZeniAccountInfo?.info?.isZeniAccountEnabled,_=i(A=>wa(A,u.companyId)),D=_.companyChargeCardInfo?.primaryFundingAccount,G=_.allFundingAccounts.find(A=>A.id===D?.accountId),Q=i(A=>da(A,u.companyId)),I=la(Q.controllers);r.useEffect(()=>{if(h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"&&U(zn()),h.fetchState==="Completed"&&!f){const A=u.companyChargeCardInfo?.info?.primaryFundingAccount?.accountId,Y=h.transferFromAccounts.find(q=>q.id===A);let ne;if(b==="cardPaymentHistory"&&l){const q=l.paymentAccountId!=null?h.transferFromAccounts.find(ke=>ke.id===l.paymentAccountId):void 0;ne={amount:l.amount,isAutoRepayment:u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,idempotencyKey:bn(),transferFrom:q??Y}}else ne={amount:{amount:T.balance.amount+T.hold.amount,currencyCode:T.balance.currencyCode,currencySymbol:T.balance.currencySymbol},isAutoRepayment:u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,idempotencyKey:bn(),transferFrom:Y};U(fn(ne)),j(!0)}},[h.fetchState,f,b,l,h.transferFromAccounts,u.companyChargeCardInfo?.info?.primaryFundingAccount?.accountId,u.companyChargeCardInfo?.info?.isAutoPayEnabled,T.balance.amount,T.balance.currencyCode,T.balance.currencySymbol,T.hold.amount,U]);const N={isZeniCheckingEnabled:u.companyZeniAccountInfo?.info?.isZeniAccountEnabled??!1,isZeniCheckingPaymentSource:G?.accType==="depositAccount",creditCardPaymentSourceAccountName:G?.label,creditCardPaymentSourceAccountType:G?.accType,creditCardPaymentSourceLastFourDigits:G?.accountLast4,creditCardPaymentSourceBalance:G?.accountBalance?.available?.amount??0};if(r.useEffect(()=>{_.fetchState!=="Completed"&&_.fetchState!=="In-Progress"&&U(Pa(u.companyId,!0))},[_.fetchState]),r.useEffect(()=>{h.updateStatus==="Completed"&&P!=null&&F&&C&&m&&J.trackCardsPayEarlyPayNowClick(I,s,P,h.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:h.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:h.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:h.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:h.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:v?.add(3,"day").format(Wa.visual.MMMDCommaYYYYformat),paymentInitiatedDate:v?.format(Wa.visual.MMMDCommaYYYYformat)},N,g,S)},[h.updateStatus,P,F,C,m,v]),r.useEffect(()=>{h.fetchState==="Completed"&&P!=null&&F&&C&&m&&!x&&e&&f&&P!=null&&(J.trackCardsPayEarlyFormView(I,s,P,t,u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,T.balance.amount,N,g,S),d(!0))},[h,F,C,m,x,e,f]),y==null)throw Error("Can't access invite people page without signing in...");const W=()=>{n(!0),U(Kn())},X=ea(u),o={events:e?ha(X,jr):[],eventCallback:(A,Y,ne)=>{ne.onEventReceived(A)},onSubscribed:A=>{A.onPusherSubscribed()}};return c.jsx(c.Fragment,{children:c.jsx(Ir,{onClose:()=>{W()},anchor:"right",transitionDuration:250,open:e,PaperProps:{style:{width:ri.overlayWidth.valuePercentage(E),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:w.colors.black,opacity:.75,cursor:"pointer"}}},children:c.jsx(oi,{onClick:A=>A.stopPropagation(),children:c.jsx(ci,{...o,closeDrawerHandler:n,navigate:M,paymentDetails:h,creditAccountSpentAmount:a,onTransferClick:()=>{F&&C&&m&&P!=null&&J.trackCardsPayEarlyFormClick(I,s,P,"Pay Now",h.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:h.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:h.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:h.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:h.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:void 0,paymentInitiatedDate:void 0},N,g,S),U(js({companyId:u.companyId}))},onDismissClick:W,onSaveChangesToLocalStore:A=>{U(fn(A))},currentTenant:u,hasZeniAccountsAdminAccess:L,isZeniAccountsUser:z,isZeniAccountSetupEnabled:$,productInformation:s,sourcePage:b,controllerEmails:I,autoPayThreshold:O,paymentSourceInformation:N,creditAccountInformation:g,debitAccountInformation:S,cashbackInformation:P,isCashbackInfoFetchStateCompleted:F,isCreditCardInfoFetchStateCompleted:C,isDebitCardInfoFetchStateCompleted:m,paymentInitiatedDate:v,maxInsuredAmount:p.maxInsuredAmount})})})})},oi=He(wo)`
14
+ `,Ka=Je.getLocalizedStrings().dateFormat,ri={overlayWidth:new Fa(100,100,58)},jr=[Or,ot],si=new Set(jr),ci=Pe(function(e,n){const t=n.currentTenant?.companyId;return{plaidConnectionDetails:Ms(e,t,"zeni_accounts","external_account").plaidConnectionDetails,depositAccountListView:Ns(e.depositAccountState,e.depositAccountListState)}},function(e,n){const{navigate:t,currentTenant:a,hasZeniAccountsAdminAccess:s,isZeniAccountsUser:b,isCashbackInfoFetchStateCompleted:g,isCreditCardInfoFetchStateCompleted:S,isDebitCardInfoFetchStateCompleted:P,controllerEmails:m,paymentDetails:C,productInformation:F,cashbackInformation:v,paymentSourceInformation:l,creditAccountInformation:M,debitAccountInformation:B,paymentInitiatedDate:L,sourcePage:p}=n,{tenantEmailDomain:h}=a,T=()=>{e(zn(!0));const u=ea(a);u!=null&&u!==""&&e(Pa(u,!0,!0)),e(Qe(!0))};return{onBackNavigation:()=>{if(g&&S&&P&&v!=null&&J.trackCardsPayEarlyFormClick(m,F,v,"Back",C.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:C.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:C.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:C.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:C.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:L?.add(3,"day").format(Ka.visual.MMMDCommaYYYYformat),paymentInitiatedDate:L?.format(Ka.visual.MMMDCommaYYYYformat)},l,M,B),p==="cardPaymentHistory")n.closeDrawerHandler(!0),e(Yn());else{const u=aa(h);t(u)}},onUpdatePaymentAccountStatus:(u,w,E)=>{e(Gs(u,w,"bill_pay","bill_pay_detail",E))},onEstablishConnectionSuccess:()=>{e(Pa(a.companyId,!0))},onFetchLinkTokenClick:u=>{e(Hs("external_account",u))},onEstablishConnectionClick:u=>{e(Vs(u,a.companyId,"charge_card_payment","charge_cards"))},onSignUpAccountClick:()=>{s?window.open(`/${h}/checking/promo`,"_blank"):window.open("https://www.zeni.ai/product/business-checking-accounts","_blank")},onMoveMoneyClick:()=>{b?window.open(`/${h}/checking/transfer`):window.open("https://www.zeni.ai/product/business-checking-accounts","_blank")},onEventReceived:u=>{si.has(u)&&T()},onPusherSubscribed:T}})(st(co)),Yt=({isPaymentDrawerOpen:e,closeDrawerHandler:n,pageName:t,creditAccountSpentAmount:a,productInformation:s,sourcePage:b,creditAccountInformation:g,debitAccountInformation:S,cashbackInformation:P,isDebitCardInfoFetchStateCompleted:m,isCreditCardInfoFetchStateCompleted:C,isCashbackInfoFetchStateCompleted:F,paymentInitiatedDate:v,retryRepayment:l})=>{const M=le(),{useDynamicConfig:B}=ue(),{configValue:L}=B(We.zeniAccountsConfig),p=Os(L),h=i(A=>Gn(A)),{creditAccount:T}=i(A=>ua(A)),u=i(A=>ge(A)),w=Ot(),E=Ta(),U=me(),y=te.getSignedInUser(),k=Re(),[x,d]=r.useState(!1),[f,j]=r.useState(!1),{configValue:H}=B(We.zeniCardsConfig),O=H.credit_card_auto_pay_threshold_by_company_id?.[u.companyId]??H.default_credit_card_auto_pay_threshold??vo,R=$n(k?.loggedInUserRoleMap),z=Us(k?.loggedInUserRoleMap),$=!!u.companyZeniAccountInfo?.info?.isZeniAccountEnabled,_=i(A=>wa(A,u.companyId)),D=_.companyChargeCardInfo?.primaryFundingAccount,G=_.allFundingAccounts.find(A=>A.id===D?.accountId),Q=i(A=>da(A,u.companyId)),I=la(Q.controllers);r.useEffect(()=>{if(h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"&&U(zn()),h.fetchState==="Completed"&&!f){const A=u.companyChargeCardInfo?.info?.primaryFundingAccount?.accountId,Z=h.transferFromAccounts.find(q=>q.id===A);let ne;if(b==="cardPaymentHistory"&&l){const q=l.paymentAccountId!=null?h.transferFromAccounts.find(ke=>ke.id===l.paymentAccountId):void 0;ne={amount:l.amount,isAutoRepayment:u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,idempotencyKey:bn(),transferFrom:q??Z}}else ne={amount:{amount:T.balance.amount+T.hold.amount,currencyCode:T.balance.currencyCode,currencySymbol:T.balance.currencySymbol},isAutoRepayment:u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,idempotencyKey:bn(),transferFrom:Z};U(fn(ne)),j(!0)}},[h.fetchState,f,b,l,h.transferFromAccounts,u.companyChargeCardInfo?.info?.primaryFundingAccount?.accountId,u.companyChargeCardInfo?.info?.isAutoPayEnabled,T.balance.amount,T.balance.currencyCode,T.balance.currencySymbol,T.hold.amount,U]);const N={isZeniCheckingEnabled:u.companyZeniAccountInfo?.info?.isZeniAccountEnabled??!1,isZeniCheckingPaymentSource:G?.accType==="depositAccount",creditCardPaymentSourceAccountName:G?.label,creditCardPaymentSourceAccountType:G?.accType,creditCardPaymentSourceLastFourDigits:G?.accountLast4,creditCardPaymentSourceBalance:G?.accountBalance?.available?.amount??0};if(r.useEffect(()=>{_.fetchState!=="Completed"&&_.fetchState!=="In-Progress"&&U(Pa(u.companyId,!0))},[_.fetchState]),r.useEffect(()=>{h.updateStatus==="Completed"&&P!=null&&F&&C&&m&&J.trackCardsPayEarlyPayNowClick(I,s,P,h.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:h.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:h.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:h.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:h.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:v?.add(3,"day").format(Ka.visual.MMMDCommaYYYYformat),paymentInitiatedDate:v?.format(Ka.visual.MMMDCommaYYYYformat)},N,g,S)},[h.updateStatus,P,F,C,m,v]),r.useEffect(()=>{h.fetchState==="Completed"&&P!=null&&F&&C&&m&&!x&&e&&f&&P!=null&&(J.trackCardsPayEarlyFormView(I,s,P,t,u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,T.balance.amount,N,g,S),d(!0))},[h,F,C,m,x,e,f]),y==null)throw Error("Can't access invite people page without signing in...");const K=()=>{n(!0),U(Yn())},X=ea(u),o={events:e?ha(X,jr):[],eventCallback:(A,Z,ne)=>{ne.onEventReceived(A)},onSubscribed:A=>{A.onPusherSubscribed()}};return c.jsx(c.Fragment,{children:c.jsx(Ir,{onClose:()=>{K()},anchor:"right",transitionDuration:250,open:e,PaperProps:{style:{width:ri.overlayWidth.valuePercentage(E),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:w.colors.black,opacity:.75,cursor:"pointer"}}},children:c.jsx(oi,{onClick:A=>A.stopPropagation(),children:c.jsx(ci,{...o,closeDrawerHandler:n,navigate:M,paymentDetails:h,creditAccountSpentAmount:a,onTransferClick:()=>{F&&C&&m&&P!=null&&J.trackCardsPayEarlyFormClick(I,s,P,"Pay Now",h.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:h.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:h.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:h.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:h.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:void 0,paymentInitiatedDate:void 0},N,g,S),U(js({companyId:u.companyId}))},onDismissClick:K,onSaveChangesToLocalStore:A=>{U(fn(A))},currentTenant:u,hasZeniAccountsAdminAccess:R,isZeniAccountsUser:z,isZeniAccountSetupEnabled:$,productInformation:s,sourcePage:b,controllerEmails:I,autoPayThreshold:O,paymentSourceInformation:N,creditAccountInformation:g,debitAccountInformation:S,cashbackInformation:P,isCashbackInfoFetchStateCompleted:F,isCreditCardInfoFetchStateCompleted:C,isDebitCardInfoFetchStateCompleted:m,paymentInitiatedDate:v,maxInsuredAmount:p.maxInsuredAmount})})})})},oi=He(wo)`
15
15
  display: flex;
16
16
  min-height: 100%;
17
17
  flex-direction: column;
18
- `,Zt=e=>e!=null&&typeof e=="object"?e:null,de=e=>typeof e=="string"?e:void 0,Me=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Ya=e=>e!=null&&typeof e=="object"&&typeof e.code=="string"&&typeof e.name=="string",gt=e=>{if(e==null||typeof e!="object")return!1;const n=e;return typeof n.transaction_id=="string"&&typeof n.amount=="number"&&typeof n.currency_code=="string"&&typeof n.currency_symbol=="string"&&typeof n.direction=="string"&&!!Ya(n.transaction_status)&&!!Ya(n.transaction_type)},Wt=(e,n)=>{const t=e?.card_status;if(!Ya(t))return null;const a=e?.is_locked_by_admin;return{cardId:n,cardStatus:t,isLockedByAdmin:typeof a=="boolean"?a:void 0}},At=[Fr,xr,Br,Rr,Lr,pa,Ht,ot,Gt,$t,zt],Mr=[La,Ra],ii=new Set([...At,...Mr]),St=Je.getLocalizedStrings().dateFormat,di=Pe(function(e,n){const{includeCreditAccountInfo:t,cardId:a,signedInUserToken:s,isChargeCardFeatureEnabled:b}=n,g=te.getSignedInUser(),S=e.tenantState.currentTenantId,P={userId:g?.userId??"",sessionId:g?.zeniSessionId??"",tenantId:S??""},m=vt(e,a,t,b),C=Xs(e,a),F=Js(e);return{chargeCardDetailView:m,chargeCardsRecurringExpensesState:C,vgsVaultId:rt.cardVaultId,transactionAttachmentsEndpointToFetch:`${Et}/card_transaction_attachments`,transactionAttachmentEndpointToDownload:`${Et}/card_transaction_attachment`,authParams:P,isSnackbarOpen:F.isSnackbarOpen,cardsEndPoint:`${Sr.cardMicroServiceBaseUrl}`,signedInUserToken:m.twoFAView.token??s}},function(e,n){const{cardId:t,currentTenant:a,navigate:s,location:b,cardProviderId:g,includeCreditAccountInfo:S,setIsPaymentOpen:P,controllerEmails:m,productInformation:C,cashbackInformation:F,primaryFundingAccountDetails:v,creditAccountInformation:l,debitAccountInformation:M,isChargeCardFeatureEnabled:B}=n,{tenantEmailDomain:R}=a;return{onEventReceived:(p,h)=>{(({event:T,data:u,cardId:w,dispatch:E,subscribedEvents:U})=>{const y=Zt(u);switch(T){case La:case Ra:return void E(_a(!0));case Fr:{const k=de(y?.card_id);if(k==null||k!==w)return;const x=de(y?.transaction_id),d=y?.transaction_status;return x!=null&&Ya(d)?void E(qs({transactionId:x,transactionStatus:d})):void E(sa(w,null,null,!0))}case pa:{const k=de(y?.card_id)??w;if(k!==w)return;const x=Wt(y,k);return x!=null?void E(Ft(x)):void E(Sa(w,!0))}case Ht:{const k=de(y?.card_id)??w;if(k!==w)return;const x=de(y?.currency_code),d=de(y?.currency_symbol),f=Me(y?.balance);return x!=null&&d!=null&&f!=null?(E(Ys({cardId:k,currencyCode:x,currencySymbol:d,balance:f,hold:Me(y?.hold),dailyPurchaseSpends:Me(y?.daily_purchase_spends),monthlyPurchaseSpends:Me(y?.monthly_purchase_spends),dailyWithdrawals:Me(y?.daily_withdrawals),monthlyWithdrawals:Me(y?.monthly_withdrawals)})),void E(Qe(!0))):(E(Sa(w,!0)),void E(Qe(!0)))}case ot:{const k=de(y?.currency_code),x=de(y?.currency_symbol),d=Me(y?.available_amount),f=Me(y?.balance_amount);return k!=null&&x!=null&&d!=null&&f!=null?void E(Ws({currencyCode:k,currencySymbol:x,available:d,balance:f,hold:Me(y?.hold_amount),cashback:Me(y?.cashback_amount)})):void E(Qe(!0))}case xr:{const k=de(y?.card_id)??w;if(k!==w)return;const x=y?.transaction;return gt(x)?void E(Zs({cardId:k,transaction:x})):void E(sa(w,null,null,!0))}case Br:{const k=de(y?.card_id)??w;if(k!==w)return;const x=y?.transaction;return gt(x)?void E(Ks({cardId:k,declineReason:de(y?.decline_reason),transaction:x})):void E(sa(w,null,null,!0))}case Rr:{const k=de(y?.card_id)??w;if(k!==w)return;const x=y?.transaction;return gt(x)?void E(zs({cardId:k,transaction:x})):void E(sa(w,null,null,!0))}case Lr:{const k=de(y?.card_id)??w;if(k!==w)return;const x=de(y?.transaction_id),d=y?.attachment_file_paths;return x!=null&&Array.isArray(d)&&d.every(f=>typeof f=="string")?void E($s({cardId:k,transactionId:x,attachmentFilePaths:d})):void E(sa(w,null,null,!0))}case Gt:case $t:case zt:{const k=de(y?.card_id);if(k==null||k!==w)return;E(Sa(w,!0))}}})({event:p,data:h,cardId:t,dispatch:e,subscribedEvents:ii})},onPusherSubscribed:()=>{e(Sa(t,!0)),e(sa(t,null,null,!0)),e(Qe(!0))},onReloadTransactions:()=>{e(ka(t,S,B))},onFetchChargeCardTransactionList:(p,h)=>{e(sa(t,p,h))},onUpdateScrollYOffset:p=>{},onGetOtp:p=>{g!=null&&e(at(p,"ChargeCardHolder",t))},onResendOtp:p=>{g!=null&&e(et(p,"ChargeCardHolder",t))},onVerifyOtp:(p,h)=>{g!=null&&e(Ja(p,h,"ChargeCardHolder",t))},onVerifyOtpSuccess:p=>{p!=null&&te.saveZeniOtpTokenForCardHolder(p,t)},onColorCodeChange:p=>{e(sc(t,p))},onLockChargeCard:(p,h)=>{e(ar(p,t,h))},onUnlockChargeCard:p=>{e(er(p,t))},onCloseChargeCard:p=>{e(Jn(t,p))},onFetchChargeCardsRecurringExpenses:()=>{e(Xn([t]))},updateChargeCardName:(p,h)=>{e(Qn(p,t,h))},updateChargeCardTransactionAttachments:(p,h)=>{h!=null&&e(rc({transactionId:p,data:h}))},updateChargeCardTransactionUploadReceiptsFetchStatus:(p,h,T,u)=>{e(nc({chargeCardId:h,transactionId:p,fetchState:T,error:u}))},updateChargeCardTransactionReceiptsShowTick:(p,h,T)=>{e(tc({chargeCardId:h,transactionId:p,shouldShowTick:T}))},onChargeCardRevokeInviteClick:()=>{e(qn(t))},updateChargeCardTransactionIsViewReceiptClicked:(p,h,T)=>{e(ac({chargeCardId:h,transactionId:p,isViewReceiptClicked:T}))},onChargeCardTransactionRowClick:(p,h)=>{const T=ye(b.state?.pathnameStackToGoBack,b.pathname);s(`../../transaction/${p}/${h}`,{state:{pathnameStackToGoBack:T}})},onBackClick:()=>{const p=we(b.state?.pathnameStackToGoBack),h=aa(R);s(h,{state:{pathnameStackToGoBack:p.newStack,message:"comingFromCardDetail"}})},removeSnackbar:()=>{e(ec())},onUpdateDebitCardPinAttempt:p=>{e(Yn(t,p)),p==="success"&&e(Ke({messageSection:"update_debit_card_pin_attempt",messageText:"success",type:"success",showStatusIcon:!0}))},onUploadReceiptComplete:(p,h)=>{p?e(Ke({messageSection:"charge_card_receipt_upload",messageText:"success",type:"success",showStatusIcon:!0})):h!=null&&e(Ke({messageSection:"charge_card_receipt_upload",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:h.message}]}))},updateSpendLimit(p,h,T,u){e(Wn(p,h,T.code,u))},shouldOpenCreditCardPaymentDrawer(p){p&&F!=null&&J.trackCardsPayEarlyClick(m,C,F,"Card Detail","Text Button","Pay Now",{isZeniCheckingEnabled:a.company?.companyZeniAccountInfo.isZeniAccountEnabled??!1,isZeniCheckingPaymentSource:v?.accType==="depositAccount",creditCardPaymentSourceAccountName:v?.label,creditCardPaymentSourceAccountType:v?.accType,creditCardPaymentSourceLastFourDigits:v?.accountLast4,creditCardPaymentSourceBalance:v?.accountBalance?.available?.amount??0},l,M),P(p)}}})(st(io));function li(){const e=le(),n=me(),t=he(),{cardId:a}=Ve(),[s,b]=r.useState(!1),[g,S]=r.useState(!1),{useDynamicConfig:P}=ue(),m=te.getSignedInUser(),C=i(K=>ge(K)),F=i(K=>qa(K).firstViewAfterActivation),v=i(K=>K.classListState.fetchState),{configValue:l}=P(Ze.documentAiReceiptMaxSizeLimitBytesConfig),{configValue:M}=P(Ze.zeniCardsConfig),B=M.enable_card_controls_for_company_ids,R=M.is_card_controls_enabled_for_all_tenants===!0||Array.isArray(B)&&B.includes(C.companyId),[p,h]=r.useState(!1),[T,u]=r.useState(!1),{useFeatureGate:w}=ue(),{isFeatureEnabled:E}=w(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:U}=w(Z.isDebitCardFeatureEnabled),y=Re(U,C),k=Oe({isDebitCardFeatureEnabled:U,isBankingOnlyTenant:y}),{isFeatureEnabled:x}=w(Z.isEarlyPayFeatureEnabled),{isFeatureEnabled:d}=w(Z.isCardsCommentingEnabled),f=Be(C),j=xe(C),H=C.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,O=Ue({isCardsOnlyTenant:j,isChargeCardFeatureEnabled:E,isBookKeepingTenant:f,isDebitCardProductVisible:k,chargeCardsCreditAccountLimit:H}),L=!!C.companyDebitCardInfo?.info?.isDebitCardEnabled,z=!!C.companyChargeCardInfo?.info?.isChargeCardEnabled,$=!C.userRole.includes("charge_card_user")&&O&&z;if(a==null)throw Error("Empty card id is not valid...");const _=i(K=>wa(K,C.companyId)),{creditAccount:D,creditAccountRepayment:G}=i(K=>ua(K)),Q=te.getZeniOtpTokenForCardHolder(a),I=i(K=>vt(K,a,$,O)),{isAiCfoAccessEnabled:N,onAskAiCfoClick:W}=xa({mobileExploreReferrer:"Card Detail"});Rt({isDataReady:I.fetchState==="Completed"});const X=i(K=>ma(K)),o=I.chargeCard,A=Le(),Y=Fe(A?.loggedInUserRoleMap),ne=o?.type.code==="business_physical_debit_card"||o?.type.code==="business_virtual_debit_card",q=o?.type.code==="business_physical_debit_card"||o?.type.code==="business_physical_credit_card",ke=o?.type.code==="business_virtual_debit_card"||o?.type.code==="business_virtual_credit_card",ve=o?.type.code==="business_virtual_debit_card",fe=Ba(O,z,Y,D,G),se=kr(ne,I),Ee=Mt(Y,X),re=Xe(O,k,L,z),Ce=I.depositAccountLimitFetchState.fetchState!=="Completed"&&I.depositAccountLimitFetchState.fetchState!=="In-Progress",Ae=i(K=>da(K,C.companyId)),ee=la(Ae.controllers),Te=i(K=>o?.cardCreatedByUser?.userId!=null?$a(K.userRoleState,o?.cardCreatedByUser?.userId):void 0),De=i(K=>Te?.accountingClassIDs[0]!=null?za(K.classState,{classId:Te?.accountingClassIDs[0],reportId:"class_list"}):void 0),ae=i(K=>o?.cardHolderUser?.userId!=null?$a(K.userRoleState,o?.cardHolderUser?.userId):void 0),oe=i(K=>ae?.accountingClassIDs[0]!=null?za(K.classState,{classId:ae?.accountingClassIDs[0],reportId:"class_list"}):void 0),fa=C?.userRole,ta=i(K=>Ca(K,!1,k,E).revokeCardInvite),Oa=ya(ta.saveStatus.fetchState);if(r.useEffect(()=>{if(Oa==="In-Progress"&&ta.saveStatus.fetchState==="Completed"){const K=aa(C.tenantEmailDomain);e(K)}},[Oa,ta.saveStatus.fetchState,e,C.tenantEmailDomain]),r.useEffect(()=>{F&&s===!1&&ke&&(b(!0),setTimeout(()=>{n(Ka()),ve&&n(Ke({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[F,s,ke,ve]),r.useEffect(()=>{p||I.fetchState==="Completed"||I.fetchState==="In-Progress"||a==null||(h(!0),n(ka(a,$,O,!1)))},[p,I,a,n]),r.useEffect(()=>{!T&&I.fetchState==="Completed"&&I.chargeCard?.connectedAccountId!=null&&ne&&Ce&&Y&&(u(!0),n(Zn({depositAccountId:I.chargeCard?.connectedAccountId})))},[T,I,n,Ce,Y]),r.useEffect(()=>{X.fetchState!=="Completed"&&X.fetchState!=="In-Progress"&&Y&&n(_a()),v!=="Completed"&&v!=="In-Progress"&&n(Nn()),I.transactionStatistics.fetchState!=="Completed"&&I.transactionStatistics.fetchState!=="In-Progress"&&n(Qs({chargeCardId:a})),_.fetchState!=="Completed"&&_.fetchState!=="In-Progress"&&n(Pa(C.companyId,!0))},[X.fetchState,n,Y,v,I.transactionStatistics.fetchState,_.fetchState]),r.useEffect(()=>{if(!(I.fetchState!=="Completed"||O&&D.fetchState!=="Completed"||o==null||I.transactionStatistics.fetchState!=="Completed"||ne&&Y&&I.depositAccountLimitFetchState.fetchState!=="Completed")){const K=o.type.code.includes("physical"),Se=K?o.cardActivationAttemptHistory[0]?.timestamp:o.createTime;J.trackCardsCardDetailView(ee,re,{cardId:a,cardName:o.cardName,cardType:o.type.code.includes("credit")?"credit":"debit",cardCategory:K?"physical":"virtual",cardLimit:ba(o.limit.amount),cardLastFourDigits:o.accountLast4,cardStatus:o.status.code,cardAssignedDate:o.createTime?.format(St.analytics.MMMDashDDDashYYYYFormat),cardIssuedDate:o.providerCardCreateTime?.format(St.analytics.MMMDashDDDashYYYYFormat),cardActivatedDate:Se?.format(St.analytics.MMMDashDDDashYYYYFormat),cardLimitFrequency:o.creditLimitFrequency.name,cardSpentAmount:ba(o.balance.amount),cardAvailableLimit:ba(o.available.amount),cardUtilizationPercent:o.limit.amount>0?Math.round((o.limit.amount-o.available.amount)/o.limit.amount*100):0,cardUtilizationAmount:ba(o.limit.amount-o.available.amount),totalNumberOfDeclinedTransactions:I.transactionStatistics.statistics.totalNumberOfDeclinedTransactions,numberOfDeclinedTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfDeclinedTransactionsCurrentMonth,totalNumberOfPaidTransactions:I.transactionStatistics.statistics.totalNumberOfPaidTransactions,numberOfPaidTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfPaidTransactionsCurrentMonth,totalNumberOfCanceledTransactions:I.transactionStatistics.statistics.totalNumberOfCanceledTransactions,numberOfCanceledTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfCanceledTransactionsCurrentMonth,totalNumberOfAuthorizedTransactions:I.transactionStatistics.statistics.totalNumberOfAuthorizedTransactions,numberOfAuthorizedTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfAuthorizedTransactionsCurrentMonth,totalNumberOfTransactionsWithReceipts:I.transactionStatistics.statistics.totalNumberOfTransactionsWithReceipts,numberOfTransactionsWithReceiptsCurrentMonth:I.transactionStatistics.statistics.numberOfTransactionsWithReceiptsCurrentMonth},{cardIssuedByName:kt(o.cardCreatedByUser,!1),cardIssuedByEmail:o.cardCreatedByUser?.email,cardIssuedByUserId:o.cardCreatedByUser?.userId,cardIssuedByRole:Te?.userRoles,cardIssuedByDepartment:De?.className},{cardholderName:kt(o.cardHolderUser,!1),cardholderEmail:o.cardHolderUser?.email,cardholderRole:ae?.userRoles,cardholderUserId:o.cardHolderUser?.userId,cardholderDepartment:oe?.className},fe,se)}},[I.fetchState,I.depositAccountLimitFetchState.fetchState,I.transactionStatistics.fetchState,D.fetchState,Y]),m==null)throw Error("Can't access card detail page without signing in...");const dt=ea(C),Ea=Y?[...At,...Mr]:At,na={events:ha(dt,Ea),eventCallback:(K,Se,ie)=>{ie.onEventReceived(K,Se)},onSubscribed:K=>{K.onPusherSubscribed()}},Aa=()=>{if(a!=null&&o!=null){const{ownerName:K,cardName:Se,utilisation:ie,limit:Ge,frequency:We,cardColor:$e}=bt(o),ze=o.cardHolderUserId===m.userId;J.trackCardsDetailPageViewed(a,K,Se,ie,Ge,We,$e,ze)}};r.useEffect(()=>{if(I.fetchState==="Completed"){const K=I.chargeCard;if(K?.status.code==="inactive"||ne&&K?.isPinSet===!1||q&&F){const Se=_e(C.tenantEmailDomain,a,m,o,F);e(Se)}}},[I.fetchState]);const lt=(K,Se)=>{if(a!=null&&o!=null){const{ownerName:ie,cardName:Ge,utilisation:We,limit:$e,frequency:ze}=bt(o),ra=o.cardHolderUserId===m.userId;J.trackCardsDetailPageClicked(a,ie,Ge,We,$e,ze,K,ra,Se)}},ut=(K,Se)=>{if(a!=null&&o!=null){const{ownerName:ie,cardName:Ge,utilisation:We,limit:$e,frequency:ze}=bt(o),ra=o.cardHolderUserId===m.userId;J.trackCardsVerifyPopUpClick(a,ie,Ge,We,$e,ze,K,ra,Se)}},pe=D.balance.amount+D.hold.amount,Ua=C.companyChargeCardInfo?.info?.primaryFundingAccount,Da=_.allFundingAccounts.find(K=>K.id===Ua?.accountId),ja=I.chargeCard!=null,Ma=I.depositAccountLimit!=null;return I.fetchState!=="Error"||ja?!ja&&(I.fetchState==="In-Progress"||I.fetchState==="Not-Started")||ta.saveStatus.fetchState==="In-Progress"||!Ma&&ne&&Y&&I.depositAccountLimitFetchState.fetchState!=="Completed"?c.jsx(oo,{}):c.jsxs(c.Fragment,{children:[c.jsx(nt,{showConfetti:F}),I.fetchState==="Completed"?c.jsx(Ut,{analytics:J,onLoad:Aa}):null,g===!0?c.jsx(Kt,{closeDrawerHandler:()=>S(!1),isPaymentDrawerOpen:g,pageName:"Card Detail",sourcePage:"cardDetailPage",productInformation:re,creditAccountInformation:fe,debitAccountInformation:se,cashbackInformation:Ee,creditAccountSpentAmount:pe,isDebitCardInfoFetchStateCompleted:!ne||!Y||I.depositAccountLimitFetchState.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!O||D.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!Y||X.fetchState==="Completed",paymentInitiatedDate:G.initiatedRepaymentDate}):null,c.jsx(di,{...na,hideSorting:!0,onColumnSortConfigChanged:()=>{},onFireVerifyPopOnClickAnalytics:ut,onFireOnClickAnalytics:lt,isSandboxEnv:Lt(),signedInUser:m,location:t,navigate:e,setIsPaymentOpen:S,cardIssuedByRoles:Te?.userRoles,cardIssuedByDepartmentName:De?.className,cardHolderRoles:ae?.userRoles,cardHolderDepartmentName:oe?.className,loggedInUserRole:fa,isChargeCardFeatureEnabled:O,isDebitCardFeatureEnabled:k,isDebitCardSetupEnabled:L,isChargeCardSetupEnabled:z,isCardControlsEnabled:R,isEarlyPayEnabled:x,controllerEmails:ee,chargeCardCashbackDetailState:X,productInformation:re,creditAccountInformation:fe,debitAccountInformation:se,cashbackInformation:Ee,classListFetchState:v,primaryFundingAccountDetails:Da,currentTenant:C,cardProviderId:I.chargeCard?.cardProviderID,cardId:a,creditAccount:D,creditAccountRepayment:G,includeCreditAccountInfo:$,signedInUserToken:Q,appleWalletLink:"shoebox://",googleWalletLink:"https://www.android.com/payapp/",documentAiReceiptMaxSizeLimit:l.documentAiReceiptMaxSizeLimitBytes!=null?l.documentAiReceiptMaxSizeLimitBytes:9437184,isAiCfoAccessEnabled:N,onAskAiCfoClick:W,isCardsCommentingEnabled:d})]}):c.jsx(ct,{})}const bt=e=>{const n=`${e.cardHolderUser?.firstName.toLowerCase()} ${e.cardHolderUser?.lastName.toLowerCase()}`,t=e.cardName,a=(e.limit.amount??0)-(e.available.amount??0),s=e.limit.amount,b=e.creditLimitFrequency.name;return{ownerName:n,cardName:t,utilisation:a,cardColor:e.cardColorCode??"",frequency:b,limit:s}},{spendManagement:{chargeCard:{cardsAiCfoHero:{headline:ui,subheadline:mi,pageTitle:Ci}}}}=Je.getLocalizedStrings(),Nr=[pa,ot,Ur,Ra,La,it,zt,Wo,Gt,$t,Ht],pi=new Set(Nr),Dt=jt((e,n,t,a)=>{e(ia(n,t,a,!0))},400),hi=He.div`
18
+ `,Wt=e=>e!=null&&typeof e=="object"?e:null,de=e=>typeof e=="string"?e:void 0,Me=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Za=e=>e!=null&&typeof e=="object"&&typeof e.code=="string"&&typeof e.name=="string",gt=e=>{if(e==null||typeof e!="object")return!1;const n=e;return typeof n.transaction_id=="string"&&typeof n.amount=="number"&&typeof n.currency_code=="string"&&typeof n.currency_symbol=="string"&&typeof n.direction=="string"&&!!Za(n.transaction_status)&&!!Za(n.transaction_type)},Kt=(e,n)=>{const t=e?.card_status;if(!Za(t))return null;const a=e?.is_locked_by_admin;return{cardId:n,cardStatus:t,isLockedByAdmin:typeof a=="boolean"?a:void 0}},At=[Fr,xr,Br,Lr,Rr,pa,Ht,ot,Gt,$t,zt],Mr=[Ra,La],ii=new Set([...At,...Mr]),St=Je.getLocalizedStrings().dateFormat,di=Pe(function(e,n){const{includeCreditAccountInfo:t,cardId:a,signedInUserToken:s,isChargeCardFeatureEnabled:b}=n,g=te.getSignedInUser(),S=e.tenantState.currentTenantId,P={userId:g?.userId??"",sessionId:g?.zeniSessionId??"",tenantId:S??""},m=vt(e,a,t,b),C=Xs(e,a),F=Js(e);return{chargeCardDetailView:m,chargeCardsRecurringExpensesState:C,vgsVaultId:rt.cardVaultId,transactionAttachmentsEndpointToFetch:`${Et}/card_transaction_attachments`,transactionAttachmentEndpointToDownload:`${Et}/card_transaction_attachment`,authParams:P,isSnackbarOpen:F.isSnackbarOpen,cardsEndPoint:`${Sr.cardMicroServiceBaseUrl}`,signedInUserToken:m.twoFAView.token??s}},function(e,n){const{cardId:t,currentTenant:a,navigate:s,location:b,cardProviderId:g,includeCreditAccountInfo:S,setIsPaymentOpen:P,controllerEmails:m,productInformation:C,cashbackInformation:F,primaryFundingAccountDetails:v,creditAccountInformation:l,debitAccountInformation:M,isChargeCardFeatureEnabled:B}=n,{tenantEmailDomain:L}=a;return{onEventReceived:(p,h)=>{(({event:T,data:u,cardId:w,dispatch:E,subscribedEvents:U})=>{const y=Wt(u);switch(T){case Ra:case La:return void E(_a(!0));case Fr:{const k=de(y?.card_id);if(k==null||k!==w)return;const x=de(y?.transaction_id),d=y?.transaction_status;return x!=null&&Za(d)?void E(qs({transactionId:x,transactionStatus:d})):void E(sa(w,null,null,!0))}case pa:{const k=de(y?.card_id)??w;if(k!==w)return;const x=Kt(y,k);return x!=null?void E(Ft(x)):void E(Sa(w,!0))}case Ht:{const k=de(y?.card_id)??w;if(k!==w)return;const x=de(y?.currency_code),d=de(y?.currency_symbol),f=Me(y?.balance);return x!=null&&d!=null&&f!=null?(E(Zs({cardId:k,currencyCode:x,currencySymbol:d,balance:f,hold:Me(y?.hold),dailyPurchaseSpends:Me(y?.daily_purchase_spends),monthlyPurchaseSpends:Me(y?.monthly_purchase_spends),dailyWithdrawals:Me(y?.daily_withdrawals),monthlyWithdrawals:Me(y?.monthly_withdrawals)})),void E(Qe(!0))):(E(Sa(w,!0)),void E(Qe(!0)))}case ot:{const k=de(y?.currency_code),x=de(y?.currency_symbol),d=Me(y?.available_amount),f=Me(y?.balance_amount);return k!=null&&x!=null&&d!=null&&f!=null?void E(Ks({currencyCode:k,currencySymbol:x,available:d,balance:f,hold:Me(y?.hold_amount),cashback:Me(y?.cashback_amount)})):void E(Qe(!0))}case xr:{const k=de(y?.card_id)??w;if(k!==w)return;const x=y?.transaction;return gt(x)?void E(Ws({cardId:k,transaction:x})):void E(sa(w,null,null,!0))}case Br:{const k=de(y?.card_id)??w;if(k!==w)return;const x=y?.transaction;return gt(x)?void E(Ys({cardId:k,declineReason:de(y?.decline_reason),transaction:x})):void E(sa(w,null,null,!0))}case Lr:{const k=de(y?.card_id)??w;if(k!==w)return;const x=y?.transaction;return gt(x)?void E(zs({cardId:k,transaction:x})):void E(sa(w,null,null,!0))}case Rr:{const k=de(y?.card_id)??w;if(k!==w)return;const x=de(y?.transaction_id),d=y?.attachment_file_paths;return x!=null&&Array.isArray(d)&&d.every(f=>typeof f=="string")?void E($s({cardId:k,transactionId:x,attachmentFilePaths:d})):void E(sa(w,null,null,!0))}case Gt:case $t:case zt:{const k=de(y?.card_id);if(k==null||k!==w)return;E(Sa(w,!0))}}})({event:p,data:h,cardId:t,dispatch:e,subscribedEvents:ii})},onPusherSubscribed:()=>{e(Sa(t,!0)),e(sa(t,null,null,!0)),e(Qe(!0))},onReloadTransactions:()=>{e(ka(t,S,B))},onFetchChargeCardTransactionList:(p,h)=>{e(sa(t,p,h))},onUpdateScrollYOffset:p=>{},onGetOtp:p=>{g!=null&&e(at(p,"ChargeCardHolder",t))},onResendOtp:p=>{g!=null&&e(et(p,"ChargeCardHolder",t))},onVerifyOtp:(p,h)=>{g!=null&&e(Ja(p,h,"ChargeCardHolder",t))},onVerifyOtpSuccess:p=>{p!=null&&te.saveZeniOtpTokenForCardHolder(p,t)},onColorCodeChange:p=>{e(sc(t,p))},onLockChargeCard:(p,h)=>{e(ar(p,t,h))},onUnlockChargeCard:p=>{e(er(p,t))},onCloseChargeCard:p=>{e(Jn(t,p))},onFetchChargeCardsRecurringExpenses:()=>{e(Xn([t]))},updateChargeCardName:(p,h)=>{e(Qn(p,t,h))},updateChargeCardTransactionAttachments:(p,h)=>{h!=null&&e(rc({transactionId:p,data:h}))},updateChargeCardTransactionUploadReceiptsFetchStatus:(p,h,T,u)=>{e(nc({chargeCardId:h,transactionId:p,fetchState:T,error:u}))},updateChargeCardTransactionReceiptsShowTick:(p,h,T)=>{e(tc({chargeCardId:h,transactionId:p,shouldShowTick:T}))},onChargeCardRevokeInviteClick:()=>{e(qn(t))},updateChargeCardTransactionIsViewReceiptClicked:(p,h,T)=>{e(ac({chargeCardId:h,transactionId:p,isViewReceiptClicked:T}))},onChargeCardTransactionRowClick:(p,h)=>{const T=ye(b.state?.pathnameStackToGoBack,b.pathname);s(`../../transaction/${p}/${h}`,{state:{pathnameStackToGoBack:T}})},onBackClick:()=>{const p=we(b.state?.pathnameStackToGoBack),h=aa(L);s(h,{state:{pathnameStackToGoBack:p.newStack,message:"comingFromCardDetail"}})},removeSnackbar:()=>{e(ec())},onUpdateDebitCardPinAttempt:p=>{e(Zn(t,p)),p==="success"&&e(Ye({messageSection:"update_debit_card_pin_attempt",messageText:"success",type:"success",showStatusIcon:!0}))},onUploadReceiptComplete:(p,h)=>{p?e(Ye({messageSection:"charge_card_receipt_upload",messageText:"success",type:"success",showStatusIcon:!0})):h!=null&&e(Ye({messageSection:"charge_card_receipt_upload",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:h.message}]}))},updateSpendLimit(p,h,T,u){e(Kn(p,h,T.code,u))},shouldOpenCreditCardPaymentDrawer(p){p&&F!=null&&J.trackCardsPayEarlyClick(m,C,F,"Card Detail","Text Button","Pay Now",{isZeniCheckingEnabled:a.company?.companyZeniAccountInfo.isZeniAccountEnabled??!1,isZeniCheckingPaymentSource:v?.accType==="depositAccount",creditCardPaymentSourceAccountName:v?.label,creditCardPaymentSourceAccountType:v?.accType,creditCardPaymentSourceLastFourDigits:v?.accountLast4,creditCardPaymentSourceBalance:v?.accountBalance?.available?.amount??0},l,M),P(p)}}})(st(io));function li(){const e=le(),n=me(),t=he(),{cardId:a}=Ve(),[s,b]=r.useState(!1),[g,S]=r.useState(!1),{useDynamicConfig:P}=ue(),m=te.getSignedInUser(),C=i(Y=>ge(Y)),F=i(Y=>qa(Y).firstViewAfterActivation),v=i(Y=>Y.classListState.fetchState),{configValue:l}=P(We.documentAiReceiptMaxSizeLimitBytesConfig),{configValue:M}=P(We.zeniCardsConfig),B=M.enable_card_controls_for_company_ids,L=M.is_card_controls_enabled_for_all_tenants===!0||Array.isArray(B)&&B.includes(C.companyId),[p,h]=r.useState(!1),[T,u]=r.useState(!1),{useFeatureGate:w}=ue(),{isFeatureEnabled:E}=w(W.isChargeCardFeatureEnabled),{isFeatureEnabled:U}=w(W.isDebitCardFeatureEnabled),y=Le(U,C),k=Oe({isDebitCardFeatureEnabled:U,isBankingOnlyTenant:y}),{isFeatureEnabled:x}=w(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:d}=w(W.isCardsCommentingEnabled),f=Be(C),j=xe(C),H=C.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,O=Ue({isCardsOnlyTenant:j,isChargeCardFeatureEnabled:E,isBookKeepingTenant:f,isDebitCardProductVisible:k,chargeCardsCreditAccountLimit:H}),R=!!C.companyDebitCardInfo?.info?.isDebitCardEnabled,z=!!C.companyChargeCardInfo?.info?.isChargeCardEnabled,$=!C.userRole.includes("charge_card_user")&&O&&z;if(a==null)throw Error("Empty card id is not valid...");const _=i(Y=>wa(Y,C.companyId)),{creditAccount:D,creditAccountRepayment:G}=i(Y=>ua(Y)),Q=te.getZeniOtpTokenForCardHolder(a),I=i(Y=>vt(Y,a,$,O)),{isAiCfoAccessEnabled:N,onAskAiCfoClick:K}=xa({mobileExploreReferrer:"Card Detail"});Lt({isDataReady:I.fetchState==="Completed"});const X=i(Y=>ma(Y)),o=I.chargeCard,A=Re(),Z=Fe(A?.loggedInUserRoleMap),ne=o?.type.code==="business_physical_debit_card"||o?.type.code==="business_virtual_debit_card",q=o?.type.code==="business_physical_debit_card"||o?.type.code==="business_physical_credit_card",ke=o?.type.code==="business_virtual_debit_card"||o?.type.code==="business_virtual_credit_card",ve=o?.type.code==="business_virtual_debit_card",fe=Ba(O,z,Z,D,G),se=kr(ne,I),Ee=Mt(Z,X),re=Xe(O,k,R,z),Ce=I.depositAccountLimitFetchState.fetchState!=="Completed"&&I.depositAccountLimitFetchState.fetchState!=="In-Progress",Ae=i(Y=>da(Y,C.companyId)),ee=la(Ae.controllers),Te=i(Y=>o?.cardCreatedByUser?.userId!=null?$a(Y.userRoleState,o?.cardCreatedByUser?.userId):void 0),De=i(Y=>Te?.accountingClassIDs[0]!=null?za(Y.classState,{classId:Te?.accountingClassIDs[0],reportId:"class_list"}):void 0),ae=i(Y=>o?.cardHolderUser?.userId!=null?$a(Y.userRoleState,o?.cardHolderUser?.userId):void 0),oe=i(Y=>ae?.accountingClassIDs[0]!=null?za(Y.classState,{classId:ae?.accountingClassIDs[0],reportId:"class_list"}):void 0),fa=C?.userRole,ta=i(Y=>Ca(Y,!1,k,E).revokeCardInvite),Oa=ya(ta.saveStatus.fetchState);if(r.useEffect(()=>{if(Oa==="In-Progress"&&ta.saveStatus.fetchState==="Completed"){const Y=aa(C.tenantEmailDomain);e(Y)}},[Oa,ta.saveStatus.fetchState,e,C.tenantEmailDomain]),r.useEffect(()=>{F&&s===!1&&ke&&(b(!0),setTimeout(()=>{n(Ya()),ve&&n(Ye({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[F,s,ke,ve]),r.useEffect(()=>{p||I.fetchState==="Completed"||I.fetchState==="In-Progress"||a==null||(h(!0),n(ka(a,$,O,!1)))},[p,I,a,n]),r.useEffect(()=>{!T&&I.fetchState==="Completed"&&I.chargeCard?.connectedAccountId!=null&&ne&&Ce&&Z&&(u(!0),n(Wn({depositAccountId:I.chargeCard?.connectedAccountId})))},[T,I,n,Ce,Z]),r.useEffect(()=>{X.fetchState!=="Completed"&&X.fetchState!=="In-Progress"&&Z&&n(_a()),v!=="Completed"&&v!=="In-Progress"&&n(Nn()),I.transactionStatistics.fetchState!=="Completed"&&I.transactionStatistics.fetchState!=="In-Progress"&&n(Qs({chargeCardId:a})),_.fetchState!=="Completed"&&_.fetchState!=="In-Progress"&&n(Pa(C.companyId,!0))},[X.fetchState,n,Z,v,I.transactionStatistics.fetchState,_.fetchState]),r.useEffect(()=>{if(!(I.fetchState!=="Completed"||O&&D.fetchState!=="Completed"||o==null||I.transactionStatistics.fetchState!=="Completed"||ne&&Z&&I.depositAccountLimitFetchState.fetchState!=="Completed")){const Y=o.type.code.includes("physical"),Se=Y?o.cardActivationAttemptHistory[0]?.timestamp:o.createTime;J.trackCardsCardDetailView(ee,re,{cardId:a,cardName:o.cardName,cardType:o.type.code.includes("credit")?"credit":"debit",cardCategory:Y?"physical":"virtual",cardLimit:ba(o.limit.amount),cardLastFourDigits:o.accountLast4,cardStatus:o.status.code,cardAssignedDate:o.createTime?.format(St.analytics.MMMDashDDDashYYYYFormat),cardIssuedDate:o.providerCardCreateTime?.format(St.analytics.MMMDashDDDashYYYYFormat),cardActivatedDate:Se?.format(St.analytics.MMMDashDDDashYYYYFormat),cardLimitFrequency:o.creditLimitFrequency.name,cardSpentAmount:ba(o.balance.amount),cardAvailableLimit:ba(o.available.amount),cardUtilizationPercent:o.limit.amount>0?Math.round((o.limit.amount-o.available.amount)/o.limit.amount*100):0,cardUtilizationAmount:ba(o.limit.amount-o.available.amount),totalNumberOfDeclinedTransactions:I.transactionStatistics.statistics.totalNumberOfDeclinedTransactions,numberOfDeclinedTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfDeclinedTransactionsCurrentMonth,totalNumberOfPaidTransactions:I.transactionStatistics.statistics.totalNumberOfPaidTransactions,numberOfPaidTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfPaidTransactionsCurrentMonth,totalNumberOfCanceledTransactions:I.transactionStatistics.statistics.totalNumberOfCanceledTransactions,numberOfCanceledTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfCanceledTransactionsCurrentMonth,totalNumberOfAuthorizedTransactions:I.transactionStatistics.statistics.totalNumberOfAuthorizedTransactions,numberOfAuthorizedTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfAuthorizedTransactionsCurrentMonth,totalNumberOfTransactionsWithReceipts:I.transactionStatistics.statistics.totalNumberOfTransactionsWithReceipts,numberOfTransactionsWithReceiptsCurrentMonth:I.transactionStatistics.statistics.numberOfTransactionsWithReceiptsCurrentMonth},{cardIssuedByName:kt(o.cardCreatedByUser,!1),cardIssuedByEmail:o.cardCreatedByUser?.email,cardIssuedByUserId:o.cardCreatedByUser?.userId,cardIssuedByRole:Te?.userRoles,cardIssuedByDepartment:De?.className},{cardholderName:kt(o.cardHolderUser,!1),cardholderEmail:o.cardHolderUser?.email,cardholderRole:ae?.userRoles,cardholderUserId:o.cardHolderUser?.userId,cardholderDepartment:oe?.className},fe,se)}},[I.fetchState,I.depositAccountLimitFetchState.fetchState,I.transactionStatistics.fetchState,D.fetchState,Z]),m==null)throw Error("Can't access card detail page without signing in...");const dt=ea(C),Ea=Z?[...At,...Mr]:At,na={events:ha(dt,Ea),eventCallback:(Y,Se,ie)=>{ie.onEventReceived(Y,Se)},onSubscribed:Y=>{Y.onPusherSubscribed()}},Aa=()=>{if(a!=null&&o!=null){const{ownerName:Y,cardName:Se,utilisation:ie,limit:Ge,frequency:Ke,cardColor:$e}=bt(o),ze=o.cardHolderUserId===m.userId;J.trackCardsDetailPageViewed(a,Y,Se,ie,Ge,Ke,$e,ze)}};r.useEffect(()=>{if(I.fetchState==="Completed"){const Y=I.chargeCard;if(Y?.status.code==="inactive"||ne&&Y?.isPinSet===!1||q&&F){const Se=_e(C.tenantEmailDomain,a,m,o,F);e(Se)}}},[I.fetchState]);const lt=(Y,Se)=>{if(a!=null&&o!=null){const{ownerName:ie,cardName:Ge,utilisation:Ke,limit:$e,frequency:ze}=bt(o),ra=o.cardHolderUserId===m.userId;J.trackCardsDetailPageClicked(a,ie,Ge,Ke,$e,ze,Y,ra,Se)}},ut=(Y,Se)=>{if(a!=null&&o!=null){const{ownerName:ie,cardName:Ge,utilisation:Ke,limit:$e,frequency:ze}=bt(o),ra=o.cardHolderUserId===m.userId;J.trackCardsVerifyPopUpClick(a,ie,Ge,Ke,$e,ze,Y,ra,Se)}},pe=D.balance.amount+D.hold.amount,Ua=C.companyChargeCardInfo?.info?.primaryFundingAccount,Da=_.allFundingAccounts.find(Y=>Y.id===Ua?.accountId),ja=I.chargeCard!=null,Ma=I.depositAccountLimit!=null;return I.fetchState!=="Error"||ja?!ja&&(I.fetchState==="In-Progress"||I.fetchState==="Not-Started")||ta.saveStatus.fetchState==="In-Progress"||!Ma&&ne&&Z&&I.depositAccountLimitFetchState.fetchState!=="Completed"?c.jsx(oo,{}):c.jsxs(c.Fragment,{children:[c.jsx(nt,{showConfetti:F}),I.fetchState==="Completed"?c.jsx(Ut,{analytics:J,onLoad:Aa}):null,g===!0?c.jsx(Yt,{closeDrawerHandler:()=>S(!1),isPaymentDrawerOpen:g,pageName:"Card Detail",sourcePage:"cardDetailPage",productInformation:re,creditAccountInformation:fe,debitAccountInformation:se,cashbackInformation:Ee,creditAccountSpentAmount:pe,isDebitCardInfoFetchStateCompleted:!ne||!Z||I.depositAccountLimitFetchState.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!O||D.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!Z||X.fetchState==="Completed",paymentInitiatedDate:G.initiatedRepaymentDate}):null,c.jsx(di,{...na,hideSorting:!0,onColumnSortConfigChanged:()=>{},onFireVerifyPopOnClickAnalytics:ut,onFireOnClickAnalytics:lt,isSandboxEnv:Rt(),signedInUser:m,location:t,navigate:e,setIsPaymentOpen:S,cardIssuedByRoles:Te?.userRoles,cardIssuedByDepartmentName:De?.className,cardHolderRoles:ae?.userRoles,cardHolderDepartmentName:oe?.className,loggedInUserRole:fa,isChargeCardFeatureEnabled:O,isDebitCardFeatureEnabled:k,isDebitCardSetupEnabled:R,isChargeCardSetupEnabled:z,isCardControlsEnabled:L,isEarlyPayEnabled:x,controllerEmails:ee,chargeCardCashbackDetailState:X,productInformation:re,creditAccountInformation:fe,debitAccountInformation:se,cashbackInformation:Ee,classListFetchState:v,primaryFundingAccountDetails:Da,currentTenant:C,cardProviderId:I.chargeCard?.cardProviderID,cardId:a,creditAccount:D,creditAccountRepayment:G,includeCreditAccountInfo:$,signedInUserToken:Q,appleWalletLink:"shoebox://",googleWalletLink:"https://www.android.com/payapp/",documentAiReceiptMaxSizeLimit:l.documentAiReceiptMaxSizeLimitBytes!=null?l.documentAiReceiptMaxSizeLimitBytes:9437184,isAiCfoAccessEnabled:N,onAskAiCfoClick:K,isCardsCommentingEnabled:d})]}):c.jsx(ct,{})}const bt=e=>{const n=`${e.cardHolderUser?.firstName.toLowerCase()} ${e.cardHolderUser?.lastName.toLowerCase()}`,t=e.cardName,a=(e.limit.amount??0)-(e.available.amount??0),s=e.limit.amount,b=e.creditLimitFrequency.name;return{ownerName:n,cardName:t,utilisation:a,cardColor:e.cardColorCode??"",frequency:b,limit:s}},{spendManagement:{chargeCard:{cardsAiCfoHero:{headline:ui,subheadline:mi,pageTitle:Ci}}}}=Je.getLocalizedStrings(),Nr=[pa,ot,Ur,La,Ra,it,zt,Ko,Gt,$t,Ht],pi=new Set(Nr),Dt=jt((e,n,t,a)=>{e(ia(n,t,a,!0))},400),hi=He.div`
19
19
  display: flex;
20
20
  width: 100%;
21
21
  flex: 1 1 auto;
22
22
  flex-direction: column;
23
23
  align-items: center;
24
24
  background-color: ${e=>e.theme.colors.grey4};
25
- `,fi=Pe(function(e,n){const t=Ca(e,n.includeCreditAccountDebitSummaryAndCashbackInfo,n.isDebitCardFeatureEnabled&&n.isDebitCardSetupEnabled,n.isChargeCardFeatureEnabled&&n.isChargeCardSetupEnabled);return{chargeCardListView:t,rowActionView:lc(e),bulkActionView:uc(e),companyLegalName:n.currentTenant.companyName,admins:n.admins,searchText:t.searchText,uiState:t.uiState,signedInUser:n.signedInUser}},function(e,n){const{navigateAndClearBulkSelection:t,currentTenant:a,location:s,signedInUser:b,chargeCardListState:g,includeCreditAccountDebitSummaryAndCashbackInfo:S,isChargeCardFeatureEnabled:P,isCreditCardProductVisibleForExpressInterest:m,isChargeCardSetupEnabled:C,isDebitCardFeatureEnabled:F,isDebitCardSetupEnabled:v,isDebitCardTOSAccepted:l,isChargeCardTOSAccepted:M,controllerEmails:B,depositAccountListWithDebitCardIssued:R,primaryFundingAccountDetails:p,chargeCardSetUpViewFetchState:h,productInformation:T,cashbackInformation:u,creditAccountInformation:w,debitAccountInformation:E,updatePayNowInfoTooltip:U,isUserHasCardsAdminLevelAccess:y}=n,{tenantEmailDomain:k}=a,{cards:x}=g;return{onChargeCardRowClick:(d,f)=>{const j=Ar(x,d);let H;j!=null&&((L=>{const z=L.limit.amount-L.available.amount,$=`${L.cardHolderUser?.firstName.toLowerCase()} ${L.cardHolderUser?.lastName.toLowerCase()}`,_=L.cardName,D=L.department?.className??"",G=L.limit.amount,Q=L.creditLimitFrequency.name;J.trackCardsListRowClicked($,_,D,z,G,Q,b.userId===L.cardHolderUserId)})(j),ca(F,v,R)&&J.trackCardsCardListRowClick(B,T,"Card Row Item","row_clicked",f+1,{cardOwner:kt(j.cardHolderUser,!1),cardName:j.cardName,cardType:j.type.code.includes("credit")?"credit":"debit",cardStatus:j.status.code,cardUtilizationAmount:ba(j.limit.amount-j.available.amount),cardUtilizationPercent:j.limit.amount>0?Math.round((j.limit.amount-j.available.amount)/j.limit.amount*100):0,cardLimit:ba(j.limit.amount)},u,w,E)),H=j?.status.code==="request_on_hold"&&b.userId===j.cardHolderUserId?Dr(k):_e(k,d,b,j);const O=ye(s.state?.pathnameStackToGoBack,s.pathname);t(H,{state:{pathnameStackToGoBack:O}})},onFetchChargeCardsRecurringExpenses:d=>{e(Xn(d))},onFetchDepositAccountLimit:d=>{e(Zn({depositAccountId:d}))},onChargeCardResendInviteClick:d=>{e(bc(d))},onChargeCardRevokeInviteClick:d=>{e(qn(d))},onLockChargeCardList:(d,f)=>{e(Sc(d,f))},onUnlockChargeCardList:d=>{e(gc(d))},onCloseChargeCardList:(d,f)=>{e(fc(d,f))},onRevokeChargeCardList:d=>{e(hc(d))},updateChargeCardListSpendLimit(d,f,j){e(pc(d,f,j.code))},onLockChargeCard:(d,f)=>{e(ar(y,d,f))},onUnlockChargeCard:d=>{e(er(y,d))},onCloseChargeCard:(d,f)=>{e(Jn(d,f))},onUpdateSpendLimit(d,f,j,H){e(Wn(d,f,j.code,H))},updateChargeCardName:(d,f)=>{e(Qn(y,d,f))},onClickSetupIcon:()=>{J.trackCardsListPageClicked("settings"),ca(F,v,R)&&u!=null&&J.trackCardsSettingsClick(B,T,u,w,E);const d=Fo(k),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},onIssueCardClick:()=>{J.trackCardsListPageClicked("new card"),ca(F,v,R)&&u!=null&&J.trackCardsNewCardClick(B,T,u,"New Button","card_creation_initiated","Card List",w,E);const d=gi(k),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},onColumnSortConfigChanged:(d,f)=>{ca(F,v,R)&&u!=null&&J.trackCardsCardListSortClick(B,T,u,"Sort Icon","sort",d,f==="ascending"?"ASC":"DESC","Cards List",w,E),e(It({uiState:{sortKey:d,sortOrder:f}}))},onSearchTextChanged:d=>{e(Cc(d))},onReloadCards:()=>{e(ia(S,F&&v,P&&C,!0))},onLetsGoClick:()=>{t("./onboard")},onBackClick:()=>{t("../../")},onTotalCashbackClick:()=>{ca(F,v,R)&&u!=null&&J.trackCardsCashbackOverviewClick(B,T,u,"Cashback Overview","cashback_details_viewed",w,E),t("./cashback")},onClickStatementsIcon:()=>{ca(F,v,R)&&u!=null&&J.trackCardsStatementsClick(B,T,u,w,E),t("./statements")},onCreateNowClick:d=>{ca(F,v,R)&&u!=null&&J.trackCardsNewCardClick(B,T,u,"Promo Banner","card_creation_initiated","Card List",w,E),t(`./new?cardType=${d}`)},onPromoCardClick:d=>{t(d==="debit"&&F&&!l||d==="credit"&&m&&!M?`../promo?cardPromoType=${d}`:"./setup")},navigateToCreditCardPaymentPage:(d,f)=>{h==="Completed"&&a.company!=null&&u!=null&&J.trackCardsPayEarlyClick(B,T,u,"Card List",d,f,{isZeniCheckingEnabled:a.company.companyZeniAccountInfo.isZeniAccountEnabled,isZeniCheckingPaymentSource:p?.accType==="depositAccount",creditCardPaymentSourceAccountName:p?.label,creditCardPaymentSourceAccountType:p?.accType,creditCardPaymentSourceLastFourDigits:p?.accountLast4,creditCardPaymentSourceBalance:p?.accountBalance?.available?.amount??0},w,E);const j=Si(k);t(j)},navigateToCreditCardPaymentHistoryPage:()=>{const d=bi(k),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},shouldShowPayNowInfoTooltip:U,onSetRowActionCardId:d=>{e(mc(d))},onSetBulkActionCardIds:d=>{e(tr(d))},onEventReceived:d=>{pi.has(d)&&Dt(e,S,F&&v,P&&C)},onPusherSubscribed:()=>{Dt(e,S,F&&v,P&&C)}}})(st(Co));function In({isPaymentDrawerOpen:e}){const n=le(),t=me(),a=he(),s=r.useCallback((V,je)=>{t(tr([])),n(V,je)},[t,n]),[b,g]=r.useState(!1),[S,P]=r.useState(te.getPayNowInfoTooltip()??!1),m=V=>{te.savePayNowInfoTooltip(V),P(V)},[C,F]=r.useState(!1),v=te.getSignedInUser(),l=i(V=>ge(V)),[M,B]=r.useState(!1),[R,p]=r.useState(!1),{isAiCfoAccessEnabled:h,onAskAiCfoClick:T}=xa({mobileExploreReferrer:"Cards"}),u=l.userRole.includes("charge_card_user"),w=!u,E=!!l.companyDebitCardInfo?.info?.isDebitCardEnabled,{useFeatureGate:U,useDynamicConfig:y}=ue(),{isFeatureEnabled:k}=U(Z.isCashbackFeatureEnabled),{isFeatureEnabled:x}=U(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:d}=U(Z.isDebitCardFeatureEnabled),{isFeatureEnabled:f}=U(Z.isEarlyPayFeatureEnabled),{isFeatureEnabled:j}=U(Z.isChargeCardPaymentHistoryFeatureEnabled),{isFeatureEnabled:H}=U(Z.isCardsCommentingEnabled),{isFeatureEnabled:O}=U(Z.isAiCfoFileUploadEnabled),{isFeatureEnabled:L}=U(Z.isCardPolicyEnabled),{isFeatureEnabled:z}=U(Z.isAiCardCreationEnabled),$=Re(d,l),_=Oe({isDebitCardFeatureEnabled:d,isBankingOnlyTenant:$}),D=xe(l),G=Be(l),Q=l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,I=Ue({isCardsOnlyTenant:D,isChargeCardFeatureEnabled:x,isBookKeepingTenant:G,isDebitCardProductVisible:_,chargeCardsCreditAccountLimit:Q}),N=Er({isCardsOnlyTenant:D,isChargeCardFeatureEnabled:x,isBookKeepingTenant:G}),{configValue:W}=y(Ze.zeniCardsConfig),X=Le(),o=Fe(X?.loggedInUserRoleMap),A=i(V=>da(V,l.companyId)),Y=la(A.controllers),ne=W.charge_card_cashback_rate_per_transaction!=null?W.charge_card_cashback_rate_per_transaction:.0175,q=W.credit_card_pay_now_threshold_by_company_id?.[l.companyId]??W.default_credit_card_pay_now_threshold??To,ke=W.is_card_controls_enabled_for_all_tenants===!0||Array.isArray(W.enable_card_controls_for_company_ids)&&W.enable_card_controls_for_company_ids.includes(l.companyId),ve=!!l.companyChargeCardInfo?.info?.isChargeCardTOSAccepted,fe=!!l.companyDebitCardInfo?.info?.isDebitCardTOSAccepted,se=!!l.companyChargeCardInfo?.info?.isChargeCardEnabled,Ee=!!l.company?.companyChargeCardInfo?.isChargeCardEnabled,re=!!l.company?.companyDebitCardInfo?.isDebitCardEnabled,Ce=i(V=>Gn(V)),Ae=ya(Ce.updateStatus),ee=i(V=>Ca(V,w,_&&E,I&&se)),Te=i(V=>cc(V)),De=i(V=>oc(V)),ae=i(V=>ic(V)),oe=i(V=>dc(V)),fa=i(V=>ae==null?[]:Mn(V.aiCfoState,ae).filter(je=>je.kind==="creating_cards"),_t),ta=ya(De.fetchState);r.useEffect(()=>{ta==="In-Progress"&&De.fetchState==="Completed"&&ae!=null&&fa.forEach(V=>{t(yt({chatSessionId:ae,id:V.id,entityIds:oe,kind:"created_cards"}))})},[t,De.fetchState,ae,oe,fa,ta]);const Oa=ee.cards.filter(V=>V.type.code.includes("debit")).map(V=>V.connectedAccountId),dt=[...new Set(Oa)],Ea=i(V=>ma(V)),na=i(V=>tt(V,dt)),Aa=i(V=>wa(V,l.companyId)),lt=Aa.companyChargeCardInfo?.primaryFundingAccount,ut=Aa.allFundingAccounts.find(V=>V.id===lt?.accountId),pe=ee.fetchState,Ua=ee.creditAccount,Da=r.useCallback(()=>o===!0&&L===!0&&pe==="Completed"&&te.getCardPolicyPopupSeen(l.tenantEmailDomain??"")!==!0,[o,L,pe,l.tenantEmailDomain]),[ja,Ma]=r.useState(Da);r.useEffect(()=>{Ma(Da())},[Da]);const K=()=>{te.saveCardPolicyPopupSeen(l.tenantEmailDomain??"",!0),Ma(!1)},Se=pe==="Completed"&&!ee.hasCreditCard&&!ee.hasDebitCard;lo({isDataReady:pe==="Completed",pageContext:Se?"cards_creation":"cards"});const{creditAccountRepayment:ie}=i(V=>ua(V)),Ge=i(V=>qa(V).firstViewAfterActivation),{areTenantIdsInSync:We}=br(),$e=Mt(o,Ea),ze=Ba(I,se,o,Ua,ie),ra=Nt(_,E,o,na,ee.debitCardSummary),mt=Xe(I,_,E,se),Ct=ee.creditAccount.balance.amount+ee.creditAccount.hold.amount;if(r.useEffect(()=>{pe==="Completed"&&(te.getPayNowInfoTooltip()==null||Ct<q*ee.creditAccount.limit.amount/100)&&m(!0)},[pe,q,Ct,ee.creditAccount.limit.amount]),r.useEffect(()=>{if(e!=null&&e===!0&&ie.initiatedRepayments.amount===0&&ie.fetchState==="Completed"||Ae==="In-Progress"&&Ce.updateStatus==="Completed")m(!1),g(!0);else if(ie.initiatedRepayments.amount>0&&ie.fetchState==="Completed"){g(!1),document.body.style.overflow="auto";const V=aa(l.tenantEmailDomain);s(V)}},[e,ie.initiatedRepayments.amount,ie.fetchState,Ae,Ce.updateStatus,s,l.tenantEmailDomain]),r.useEffect(()=>{!M&&(se||E)&&(Ee||re)&&We&&(B(!0),t(ia(w,_&&E,I&&se,!1)))},[M,w,t,We,Ee,re]),r.useEffect(()=>{Ge&&C===!1&&(F(!0),setTimeout(()=>{t(Ka())},5e3))},[Ge,C]),r.useEffect(()=>()=>{Dt.flush()},[]),r.useEffect(()=>{pe==="Completed"&&u&&ee.cards.length===1&&(ee.cards[0].status.code==="inactive"&&ee.cards[0].type.code==="business_physical_credit_card"?s(`./${ee.cards[0].id}/activate`):ee.cards[0].status.code!=="request_on_hold"&&(a.state?.message==="comingFromCardDetail"?s("../../"):s(`./${ee.cards[0].id}`)))},[pe,u,a.state,s,ee.cards]),r.useEffect(()=>{if(pe==="Completed"&&u){const V=ee.cards.length,je=ee.cards.filter(Ye=>Ye.cardHolderUserId===v?.userId).filter(Ye=>Ye.status.code==="request_on_hold");je.length>0&&V===je.length&&s("./onboard")}},[pe,ee.cards,u,s,v?.userId]),r.useEffect(()=>{pe!=="Completed"||I&&ie.fetchState!=="Completed"||_&&E&&o&&na.fetchState!=="Completed"||J.trackCardsCardListView(Y,mt,$e,ze,ra)},[pe,Ua,ie.fetchState,na.fetchState,o]),v==null)throw Error("Can't access charge card list page without signing in...");const $r=i(V=>nr(V.userState,V.userRoleState,V.userListViewState,"cardAdmin")),Yt=xt(X?.loggedInUserRoleMap),qt=V=>{p(V)},zr=ee.creditAccount.limit,Kr=()=>{g(!1),s("..")},Zr=l.companyChargeCardInfo?.info!=null&&Ia({cardInfo:l.companyChargeCardInfo.info,isProductVisible:I&&Ee,isTOSAccepted:ve,isSetupEnabled:se,isUserHasCardsAdminLevelAccess:o,isUserHasCardsAccess:Yt}),Wr=l.companyDebitCardInfo?.info!=null&&Ia({cardInfo:l.companyDebitCardInfo.info,isProductVisible:_&&re,isTOSAccepted:fe,isSetupEnabled:E,isUserHasCardsAdminLevelAccess:o,isUserHasCardsAccess:Yt}),Yr=Zr||Wr,Qt=function(V){const{isEmptyCardsState:je,isChargeCardAdmin:Ye,isFileUploadEnabled:en}=V,an=le(),Na=he(),{tenantEmailDomain:Va}=Ve(),{isAiCfoOpen:as,setIsAiCfoOpen:tn}=pr(),ts=hr(),ns=fr(),nn=i(be=>jn(be)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:rn,isResolved:sn}=Tr("cards_creation"),cn=r.useMemo(()=>vr(rn,sn,3),[rn,sn]),[Ha,pt]=r.useState(""),on=ns&&ts&&Va!=null&&!as,ga=r.useCallback(be=>{if(Va==null)return;const rs=ye(Na.state?.pathnameStackToGoBack,Na.pathname);an(`/${Va}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:rs,referrer:"cards_hero",aiCfoInitialQuestion:be,aiCfoShouldSubmit:be!=null&&be.trim().length>0}})},[Na.pathname,Na.state,an,Va]),dn=r.useCallback(be=>{be.trim().length!==0&&(pt(""),ga(be))},[ga]),ln=r.useCallback(()=>{const be=Ha.trim();be.length!==0&&(pt(""),ga(be))},[Ha,ga]),un=r.useCallback(()=>{},[]),mn=r.useCallback(be=>{pt(be)},[]),Cn=r.useCallback(()=>{tn(!0)},[tn]),pn=r.useCallback(()=>{ga(void 0)},[ga]);return r.useMemo(()=>{if(on&&je&&Ye)return{aiAgentName:Ci,headline:ui,subheadline:mi,promptChips:cn,composer:{currentInput:Ha,isSubmitting:nn,isFileUploadEnabled:en,onInputChange:mn,onSubmit:ln,onStopSubmit:un},onPromptClick:dn,onOpenSidePanel:Cn,onOpenFullView:pn,dataTestIdPrefix:"cards-ai-cfo-hero"}},[Ha,on,Ye,je,en,nn,mn,pn,Cn,dn,un,ln,cn])}({isEmptyCardsState:Se,isChargeCardAdmin:o,isFileUploadEnabled:O}),Xt=z&&Qt!=null?c.jsx(gr,{...Qt}):null,{isCardsShuttingDown:qr,shutdownContent:Jt}=uo(l.tenantId,l.company?.managementInfo?.receiverEmails),Qr=qr===!0&&Jt!=null?c.jsx(mo,{shutdownContent:Jt}):null,Xr=h&&Xt==null,Jr=ea(l),es={events:ha(Jr,Nr),eventCallback:(V,je,Ye)=>{Ye.onEventReceived(V)},onSubscribed:V=>{V.onPusherSubscribed()}};return se||E?c.jsxs(c.Fragment,{children:[pe==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ut,{analytics:J,onLoad:()=>{J.trackPageLoaded(yr.Event.cardsListPage),(I&&!se||_&&!E)&&J.trackCardsPromoView(Y,{isCreditCardOffered:I,isDebitCardOffered:_,isDebitCardEnabled:E,isCreditCardEnabled:se},"Banner",_&&!E?"Debit Card":I&&!se?"Credit Card":"","Card List")}}),c.jsx(nt,{showConfetti:Ge})]}):null,b===!0?c.jsx(Kt,{closeDrawerHandler:Kr,isPaymentDrawerOpen:b,pageName:"Card List",sourcePage:"cardListPage",creditAccountSpentAmount:Ct,productInformation:mt,creditAccountInformation:ze,debitAccountInformation:ra,cashbackInformation:$e,isDebitCardInfoFetchStateCompleted:!(_&&E&&o)||na.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!I||ie.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!o||Ea.fetchState==="Completed",paymentInitiatedDate:ie.initiatedRepaymentDate}):null,c.jsxs(hi,{children:[c.jsx(Ie,{isAppContentDrawerOpen:R,handleDrawerToggle:qt}),c.jsx(fi,{...es,isCashbackFeatureEnabled:k,isChargeCardFeatureEnabled:I,isDebitCardFeatureEnabled:_,isCreditCardProductVisibleForExpressInterest:N,updatePayNowInfoTooltip:m,showPayNowInfoTooltip:S,creditCardPayNowThreshold:q,signedInUser:v,chargeCardListState:ee,location:a,admins:$r.users,navigateAndClearBulkSelection:s,currentTenant:l,isCardControlsEnabled:ke,companyChargeCardInfoCreditAccountLimit:l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,isCompanyInterestedInChargeCard:l.companyChargeCardInfo?.info?.isCompanyInterestedInChargeCard??!1,isUserHasCardsAdminLevelAccess:o,includeCreditAccountDebitSummaryAndCashbackInfo:w,onClickMenuIcon:()=>{qt(!0)},creditLimit:zr,isChargeCardSetupEnabled:se,isChargeCardEnabledOnCompany:Ee,isDebitCardSetupEnabled:E,isDebitCardEnabledOnCompany:re,isEarlyPayEnabled:f,isChargeCardPaymentHistoryFeatureEnabled:j,cashbackRate:ne,controllerEmails:Y,chargeCardCashbackDetailState:Ea,depositAccountListWithDebitCardIssued:na,isChargeCardTOSAccepted:ve,isDebitCardTOSAccepted:fe,primaryFundingAccountDetails:ut,chargeCardSetUpViewFetchState:Aa.fetchState,productInformation:mt,creditAccountInformation:ze,debitAccountInformation:ra,cashbackInformation:$e,isAiCfoAccessEnabled:Xr,onAskAiCfoClick:T,isCardsCommentingEnabled:H,cardsAiCfoHero:Xt,cardsShutdownBanner:Qr,onClickPolicyIcon:o&&L?()=>n(yi(l.tenantEmailDomain)):void 0,isPolicyIntroTooltipVisible:ja,onPolicyIntroTooltipClose:K,pendingCreationCount:Te})]})]}):(ve||fe)&&o===!0?c.jsx(oa,{to:"../setup"}):Yr?c.jsx(oa,{to:"../promo"}):c.jsx(va,{fetchState:pe})}const gi=e=>`/${e}/cards/new`,Si=e=>`/${e}/cards/payment`,bi=e=>`/${e}/cards/payment-history`,yi=e=>`/${e}/cards/policy`,Vr=[Or,Ur],Ii=new Set(Vr),ki=Pe(function(e){const n=te.getSignedInUser(),t=ge(e),a=e.tenantState.currentTenantId,s=rr(e),b={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:a??""},g=t?.companyName??"",S=e.chargeCardPaymentHistoryState.downloadUIState.downloadState;return{fetchState:s.fetchState,filters:s.filters,isZeniTenant:yc(t),repaymentList:s.repaymentHistory,searchText:s.searchText,repaymentHistoryUsers:s.repaymentHistoryUsers,sortConfig:{sortKey:s.uiState.sortKey,sortOrder:s.uiState.sortOrder},downloadParams:{authParams:b,companyName:g,spendManagementEndPoint:`${Et}/spendManagement`,isShowDeletedBillsEnabled:!1,isShowDeletedReimbursementEnabled:!1},downloadState:S}},function(e,n){const{location:t,navigate:a}=n;return{onBackClick:()=>{const s=we(t.state?.pathnameStackToGoBack),b=s.poppedPathname??"..";a(b,{state:{pathnameStackToGoBack:s.newStack}})},onColumnSortConfigChanged:(s,b)=>{e({type:"chargeCardPaymentHistory/updatePaymentHistoryUIState",payload:{uiState:{sortKey:s,sortOrder:b}}})},onFiltersChange:s=>{e(kc({filters:s}))},onReloadPayments:()=>{e(Ga(!0))},onEventReceived:s=>{Ii.has(s)&&e(Ga(!0))},onPusherSubscribed:()=>{e(Ga(!0))},onSearchTextChanged:s=>{e({type:"chargeCardPaymentHistory/updatePaymentHistorySearchText",payload:s})},updateDownloadStateHandler:s=>{e(Ic({uiState:{downloadState:s}}))}}})(st(po));function Ei(){const e=le(),n=he(),t=me(),{areTenantIdsInSync:a}=br(),{useFeatureGate:s}=ue();if(te.getSignedInUser()==null)throw Error("Can't access payment history page without signing in...");const b=i(o=>ge(o)),g=i(o=>rr(o)),[S,P]=r.useState(!1),[m,C]=r.useState(!1),[F,v]=r.useState(!1),[l,M]=r.useState(null),B=!b.userRole.includes("charge_card_user"),R=!!b.companyDebitCardInfo?.info?.isDebitCardEnabled,{isFeatureEnabled:p}=s(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:h}=s(Z.isDebitCardFeatureEnabled),T=Re(h,b),u=Oe({isDebitCardFeatureEnabled:h,isBankingOnlyTenant:T}),w=xe(b),E=Be(b),U=b.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,y=Ue({isCardsOnlyTenant:w,isChargeCardFeatureEnabled:p,isBookKeepingTenant:E,isDebitCardProductVisible:u,chargeCardsCreditAccountLimit:U}),k=!!b.companyChargeCardInfo?.info?.isChargeCardEnabled,x=Le(),d=Fe(x?.loggedInUserRoleMap),f=i(o=>Ca(o,B,u&&R,y&&k)),j=r.useMemo(()=>{const o=f.cards.filter(A=>A.type.code.includes("debit"));return[...new Set(o.map(A=>A.connectedAccountId))]},[f.cards]),H=i(o=>ma(o)),O=i(o=>tt(o,j)),{creditAccountRepayment:L}=i(o=>ua(o)),z=r.useMemo(()=>Mt(d,H),[d,H]),$=r.useMemo(()=>Ba(y,k,d,f.creditAccount,L),[y,k,d,f.creditAccount,L]),_=r.useMemo(()=>Nt(u,R,d,O,f.debitCardSummary),[u,R,d,O,f.debitCardSummary]),D=r.useMemo(()=>Xe(y,u,R,k),[y,u,R,k]),G=f.creditAccount.balance.amount+f.creditAccount.hold.amount,Q=r.useMemo(()=>l!=null?g.repaymentHistory.find(o=>o.cardRepaymentId===l):void 0,[l,g.repaymentHistory]),I=r.useCallback(o=>{M(o),t(ia(B,u&&R,y&&k,!1)),v(!0)},[t,B,u,R,y,k]),N=r.useCallback(()=>{v(!1),M(null),document.body.style.overflow="auto"},[]);r.useEffect(()=>{S||g.fetchState==="Completed"||g.fetchState==="In-Progress"||(P(!0),t(Ga()))},[S,t,g.fetchState]),r.useEffect(()=>{!m&&(k||R)&&a&&(C(!0),t(ia(B,!1,y&&k,!1)))},[m,k,R,a,t,B,y]);const W=ea(b),X={events:ha(W,Vr),eventCallback:(o,A,Y)=>{Y.onEventReceived(o)},onSubscribed:o=>{o.onPusherSubscribed()}};return c.jsxs(c.Fragment,{children:[F?c.jsx(Kt,{closeDrawerHandler:N,isPaymentDrawerOpen:F,pageName:"Payment History",sourcePage:"cardPaymentHistory",creditAccountSpentAmount:G,productInformation:D,creditAccountInformation:$,debitAccountInformation:_,cashbackInformation:z,isDebitCardInfoFetchStateCompleted:!(u&&R&&d)||O.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!y||L.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!d||H.fetchState==="Completed",paymentInitiatedDate:L.initiatedRepaymentDate,retryRepayment:Q}):null,c.jsx(ki,{...X,location:n,navigate:e,accountInfoByAccountId:g.accountInfoByAccountId,onRetryPaymentClick:I})]})}const kn=He.div`
25
+ `,fi=Pe(function(e,n){const t=Ca(e,n.includeCreditAccountDebitSummaryAndCashbackInfo,n.isDebitCardFeatureEnabled&&n.isDebitCardSetupEnabled,n.isChargeCardFeatureEnabled&&n.isChargeCardSetupEnabled);return{chargeCardListView:t,rowActionView:lc(e),bulkActionView:uc(e),companyLegalName:n.currentTenant.companyName,admins:n.admins,searchText:t.searchText,uiState:t.uiState,signedInUser:n.signedInUser}},function(e,n){const{navigateAndClearBulkSelection:t,currentTenant:a,location:s,signedInUser:b,chargeCardListState:g,includeCreditAccountDebitSummaryAndCashbackInfo:S,isChargeCardFeatureEnabled:P,isCreditCardProductVisibleForExpressInterest:m,isChargeCardSetupEnabled:C,isDebitCardFeatureEnabled:F,isDebitCardSetupEnabled:v,isDebitCardTOSAccepted:l,isChargeCardTOSAccepted:M,controllerEmails:B,depositAccountListWithDebitCardIssued:L,primaryFundingAccountDetails:p,chargeCardSetUpViewFetchState:h,productInformation:T,cashbackInformation:u,creditAccountInformation:w,debitAccountInformation:E,updatePayNowInfoTooltip:U,isUserHasCardsAdminLevelAccess:y}=n,{tenantEmailDomain:k}=a,{cards:x}=g;return{onChargeCardRowClick:(d,f)=>{const j=Ar(x,d);let H;j!=null&&((R=>{const z=R.limit.amount-R.available.amount,$=`${R.cardHolderUser?.firstName.toLowerCase()} ${R.cardHolderUser?.lastName.toLowerCase()}`,_=R.cardName,D=R.department?.className??"",G=R.limit.amount,Q=R.creditLimitFrequency.name;J.trackCardsListRowClicked($,_,D,z,G,Q,b.userId===R.cardHolderUserId)})(j),ca(F,v,L)&&J.trackCardsCardListRowClick(B,T,"Card Row Item","row_clicked",f+1,{cardOwner:kt(j.cardHolderUser,!1),cardName:j.cardName,cardType:j.type.code.includes("credit")?"credit":"debit",cardStatus:j.status.code,cardUtilizationAmount:ba(j.limit.amount-j.available.amount),cardUtilizationPercent:j.limit.amount>0?Math.round((j.limit.amount-j.available.amount)/j.limit.amount*100):0,cardLimit:ba(j.limit.amount)},u,w,E)),H=j?.status.code==="request_on_hold"&&b.userId===j.cardHolderUserId?Dr(k):_e(k,d,b,j);const O=ye(s.state?.pathnameStackToGoBack,s.pathname);t(H,{state:{pathnameStackToGoBack:O}})},onFetchChargeCardsRecurringExpenses:d=>{e(Xn(d))},onFetchDepositAccountLimit:d=>{e(Wn({depositAccountId:d}))},onChargeCardResendInviteClick:d=>{e(bc(d))},onChargeCardRevokeInviteClick:d=>{e(qn(d))},onLockChargeCardList:(d,f)=>{e(Sc(d,f))},onUnlockChargeCardList:d=>{e(gc(d))},onCloseChargeCardList:(d,f)=>{e(fc(d,f))},onRevokeChargeCardList:d=>{e(hc(d))},updateChargeCardListSpendLimit(d,f,j){e(pc(d,f,j.code))},onLockChargeCard:(d,f)=>{e(ar(y,d,f))},onUnlockChargeCard:d=>{e(er(y,d))},onCloseChargeCard:(d,f)=>{e(Jn(d,f))},onUpdateSpendLimit(d,f,j,H){e(Kn(d,f,j.code,H))},updateChargeCardName:(d,f)=>{e(Qn(y,d,f))},onClickSetupIcon:()=>{J.trackCardsListPageClicked("settings"),ca(F,v,L)&&u!=null&&J.trackCardsSettingsClick(B,T,u,w,E);const d=Fo(k),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},onIssueCardClick:()=>{J.trackCardsListPageClicked("new card"),ca(F,v,L)&&u!=null&&J.trackCardsNewCardClick(B,T,u,"New Button","card_creation_initiated","Card List",w,E);const d=gi(k),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},onColumnSortConfigChanged:(d,f)=>{ca(F,v,L)&&u!=null&&J.trackCardsCardListSortClick(B,T,u,"Sort Icon","sort",d,f==="ascending"?"ASC":"DESC","Cards List",w,E),e(It({uiState:{sortKey:d,sortOrder:f}}))},onSearchTextChanged:d=>{e(Cc(d))},onReloadCards:()=>{e(ia(S,F&&v,P&&C,!0))},onLetsGoClick:()=>{t("./onboard")},onBackClick:()=>{t("../../")},onTotalCashbackClick:()=>{ca(F,v,L)&&u!=null&&J.trackCardsCashbackOverviewClick(B,T,u,"Cashback Overview","cashback_details_viewed",w,E),t("./cashback")},onClickStatementsIcon:()=>{ca(F,v,L)&&u!=null&&J.trackCardsStatementsClick(B,T,u,w,E),t("./statements")},onCreateNowClick:d=>{ca(F,v,L)&&u!=null&&J.trackCardsNewCardClick(B,T,u,"Promo Banner","card_creation_initiated","Card List",w,E),t(`./new?cardType=${d}`)},onPromoCardClick:d=>{t(d==="debit"&&F&&!l||d==="credit"&&m&&!M?`../promo?cardPromoType=${d}`:"./setup")},navigateToCreditCardPaymentPage:(d,f)=>{h==="Completed"&&a.company!=null&&u!=null&&J.trackCardsPayEarlyClick(B,T,u,"Card List",d,f,{isZeniCheckingEnabled:a.company.companyZeniAccountInfo.isZeniAccountEnabled,isZeniCheckingPaymentSource:p?.accType==="depositAccount",creditCardPaymentSourceAccountName:p?.label,creditCardPaymentSourceAccountType:p?.accType,creditCardPaymentSourceLastFourDigits:p?.accountLast4,creditCardPaymentSourceBalance:p?.accountBalance?.available?.amount??0},w,E);const j=Si(k);t(j)},navigateToCreditCardPaymentHistoryPage:()=>{const d=bi(k),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},shouldShowPayNowInfoTooltip:U,onSetRowActionCardId:d=>{e(mc(d))},onSetBulkActionCardIds:d=>{e(tr(d))},onEventReceived:d=>{pi.has(d)&&Dt(e,S,F&&v,P&&C)},onPusherSubscribed:()=>{Dt(e,S,F&&v,P&&C)}}})(st(Co));function In({isPaymentDrawerOpen:e}){const n=le(),t=me(),a=he(),s=r.useCallback((V,je)=>{t(tr([])),n(V,je)},[t,n]),[b,g]=r.useState(!1),[S,P]=r.useState(te.getPayNowInfoTooltip()??!1),m=V=>{te.savePayNowInfoTooltip(V),P(V)},[C,F]=r.useState(!1),v=te.getSignedInUser(),l=i(V=>ge(V)),[M,B]=r.useState(!1),[L,p]=r.useState(!1),{isAiCfoAccessEnabled:h,onAskAiCfoClick:T}=xa({mobileExploreReferrer:"Cards"}),u=l.userRole.includes("charge_card_user"),w=!u,E=!!l.companyDebitCardInfo?.info?.isDebitCardEnabled,{useFeatureGate:U,useDynamicConfig:y}=ue(),{isFeatureEnabled:k}=U(W.isCashbackFeatureEnabled),{isFeatureEnabled:x}=U(W.isChargeCardFeatureEnabled),{isFeatureEnabled:d}=U(W.isDebitCardFeatureEnabled),{isFeatureEnabled:f}=U(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:j}=U(W.isChargeCardPaymentHistoryFeatureEnabled),{isFeatureEnabled:H}=U(W.isCardsCommentingEnabled),{isFeatureEnabled:O}=U(W.isAiCfoFileUploadEnabled),{isFeatureEnabled:R}=U(W.isCardPolicyEnabled),{isFeatureEnabled:z}=U(W.isAiCardCreationEnabled),$=Le(d,l),_=Oe({isDebitCardFeatureEnabled:d,isBankingOnlyTenant:$}),D=xe(l),G=Be(l),Q=l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,I=Ue({isCardsOnlyTenant:D,isChargeCardFeatureEnabled:x,isBookKeepingTenant:G,isDebitCardProductVisible:_,chargeCardsCreditAccountLimit:Q}),N=Er({isCardsOnlyTenant:D,isChargeCardFeatureEnabled:x,isBookKeepingTenant:G}),{configValue:K}=y(We.zeniCardsConfig),X=Re(),o=Fe(X?.loggedInUserRoleMap),A=i(V=>da(V,l.companyId)),Z=la(A.controllers),ne=K.charge_card_cashback_rate_per_transaction!=null?K.charge_card_cashback_rate_per_transaction:.0175,q=K.credit_card_pay_now_threshold_by_company_id?.[l.companyId]??K.default_credit_card_pay_now_threshold??To,ke=K.is_card_controls_enabled_for_all_tenants===!0||Array.isArray(K.enable_card_controls_for_company_ids)&&K.enable_card_controls_for_company_ids.includes(l.companyId),ve=!!l.companyChargeCardInfo?.info?.isChargeCardTOSAccepted,fe=!!l.companyDebitCardInfo?.info?.isDebitCardTOSAccepted,se=!!l.companyChargeCardInfo?.info?.isChargeCardEnabled,Ee=!!l.company?.companyChargeCardInfo?.isChargeCardEnabled,re=!!l.company?.companyDebitCardInfo?.isDebitCardEnabled,Ce=i(V=>Gn(V)),Ae=ya(Ce.updateStatus),ee=i(V=>Ca(V,w,_&&E,I&&se)),Te=i(V=>cc(V)),De=i(V=>oc(V)),ae=i(V=>ic(V)),oe=i(V=>dc(V)),fa=i(V=>ae==null?[]:Mn(V.aiCfoState,ae).filter(je=>je.kind==="creating_cards"),_t),ta=ya(De.fetchState);r.useEffect(()=>{ta==="In-Progress"&&De.fetchState==="Completed"&&ae!=null&&fa.forEach(V=>{t(yt({chatSessionId:ae,id:V.id,entityIds:oe,kind:"created_cards"}))})},[t,De.fetchState,ae,oe,fa,ta]);const Oa=ee.cards.filter(V=>V.type.code.includes("debit")).map(V=>V.connectedAccountId),dt=[...new Set(Oa)],Ea=i(V=>ma(V)),na=i(V=>tt(V,dt)),Aa=i(V=>wa(V,l.companyId)),lt=Aa.companyChargeCardInfo?.primaryFundingAccount,ut=Aa.allFundingAccounts.find(V=>V.id===lt?.accountId),pe=ee.fetchState,Ua=ee.creditAccount,Da=r.useCallback(()=>o===!0&&R===!0&&pe==="Completed"&&te.getCardPolicyPopupSeen(l.tenantEmailDomain??"")!==!0,[o,R,pe,l.tenantEmailDomain]),[ja,Ma]=r.useState(Da);r.useEffect(()=>{Ma(Da())},[Da]);const Y=()=>{te.saveCardPolicyPopupSeen(l.tenantEmailDomain??"",!0),Ma(!1)},Se=pe==="Completed"&&!ee.hasCreditCard&&!ee.hasDebitCard;lo({isDataReady:pe==="Completed",pageContext:Se?"cards_creation":"cards"});const{creditAccountRepayment:ie}=i(V=>ua(V)),Ge=i(V=>qa(V).firstViewAfterActivation),{areTenantIdsInSync:Ke}=br(),$e=Mt(o,Ea),ze=Ba(I,se,o,Ua,ie),ra=Nt(_,E,o,na,ee.debitCardSummary),mt=Xe(I,_,E,se),Ct=ee.creditAccount.balance.amount+ee.creditAccount.hold.amount;if(r.useEffect(()=>{pe==="Completed"&&(te.getPayNowInfoTooltip()==null||Ct<q*ee.creditAccount.limit.amount/100)&&m(!0)},[pe,q,Ct,ee.creditAccount.limit.amount]),r.useEffect(()=>{if(e!=null&&e===!0&&ie.initiatedRepayments.amount===0&&ie.fetchState==="Completed"||Ae==="In-Progress"&&Ce.updateStatus==="Completed")m(!1),g(!0);else if(ie.initiatedRepayments.amount>0&&ie.fetchState==="Completed"){g(!1),document.body.style.overflow="auto";const V=aa(l.tenantEmailDomain);s(V)}},[e,ie.initiatedRepayments.amount,ie.fetchState,Ae,Ce.updateStatus,s,l.tenantEmailDomain]),r.useEffect(()=>{!M&&(se||E)&&(Ee||re)&&Ke&&(B(!0),t(ia(w,_&&E,I&&se,!1)))},[M,w,t,Ke,Ee,re]),r.useEffect(()=>{Ge&&C===!1&&(F(!0),setTimeout(()=>{t(Ya())},5e3))},[Ge,C]),r.useEffect(()=>()=>{Dt.flush()},[]),r.useEffect(()=>{pe==="Completed"&&u&&ee.cards.length===1&&(ee.cards[0].status.code==="inactive"&&ee.cards[0].type.code==="business_physical_credit_card"?s(`./${ee.cards[0].id}/activate`):ee.cards[0].status.code!=="request_on_hold"&&(a.state?.message==="comingFromCardDetail"?s("../../"):s(`./${ee.cards[0].id}`)))},[pe,u,a.state,s,ee.cards]),r.useEffect(()=>{if(pe==="Completed"&&u){const V=ee.cards.length,je=ee.cards.filter(Ze=>Ze.cardHolderUserId===v?.userId).filter(Ze=>Ze.status.code==="request_on_hold");je.length>0&&V===je.length&&s("./onboard")}},[pe,ee.cards,u,s,v?.userId]),r.useEffect(()=>{pe!=="Completed"||I&&ie.fetchState!=="Completed"||_&&E&&o&&na.fetchState!=="Completed"||J.trackCardsCardListView(Z,mt,$e,ze,ra)},[pe,Ua,ie.fetchState,na.fetchState,o]),v==null)throw Error("Can't access charge card list page without signing in...");const $r=i(V=>nr(V.userState,V.userRoleState,V.userListViewState,"cardAdmin")),Zt=xt(X?.loggedInUserRoleMap),qt=V=>{p(V)},zr=ee.creditAccount.limit,Yr=()=>{g(!1),s("..")},Wr=l.companyChargeCardInfo?.info!=null&&Ia({cardInfo:l.companyChargeCardInfo.info,isProductVisible:I&&Ee,isTOSAccepted:ve,isSetupEnabled:se,isUserHasCardsAdminLevelAccess:o,isUserHasCardsAccess:Zt}),Kr=l.companyDebitCardInfo?.info!=null&&Ia({cardInfo:l.companyDebitCardInfo.info,isProductVisible:_&&re,isTOSAccepted:fe,isSetupEnabled:E,isUserHasCardsAdminLevelAccess:o,isUserHasCardsAccess:Zt}),Zr=Wr||Kr,Qt=function(V){const{isEmptyCardsState:je,isChargeCardAdmin:Ze,isFileUploadEnabled:en}=V,an=le(),Na=he(),{tenantEmailDomain:Va}=Ve(),{isAiCfoOpen:as,setIsAiCfoOpen:tn}=pr(),ts=hr(),ns=fr(),nn=i(be=>jn(be)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:rn,isResolved:sn}=Tr("cards_creation"),cn=r.useMemo(()=>vr(rn,sn,3),[rn,sn]),[Ha,pt]=r.useState(""),on=ns&&ts&&Va!=null&&!as,ga=r.useCallback(be=>{if(Va==null)return;const rs=ye(Na.state?.pathnameStackToGoBack,Na.pathname);an(`/${Va}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:rs,referrer:"cards_hero",aiCfoInitialQuestion:be,aiCfoShouldSubmit:be!=null&&be.trim().length>0}})},[Na.pathname,Na.state,an,Va]),dn=r.useCallback(be=>{be.trim().length!==0&&(pt(""),ga(be))},[ga]),ln=r.useCallback(()=>{const be=Ha.trim();be.length!==0&&(pt(""),ga(be))},[Ha,ga]),un=r.useCallback(()=>{},[]),mn=r.useCallback(be=>{pt(be)},[]),Cn=r.useCallback(()=>{tn(!0)},[tn]),pn=r.useCallback(()=>{ga(void 0)},[ga]);return r.useMemo(()=>{if(on&&je&&Ze)return{aiAgentName:Ci,headline:ui,subheadline:mi,promptChips:cn,composer:{currentInput:Ha,isSubmitting:nn,isFileUploadEnabled:en,onInputChange:mn,onSubmit:ln,onStopSubmit:un},onPromptClick:dn,onOpenSidePanel:Cn,onOpenFullView:pn,dataTestIdPrefix:"cards-ai-cfo-hero"}},[Ha,on,Ze,je,en,nn,mn,pn,Cn,dn,un,ln,cn])}({isEmptyCardsState:Se,isChargeCardAdmin:o,isFileUploadEnabled:O}),Xt=z&&Qt!=null?c.jsx(gr,{...Qt}):null,{isCardsShuttingDown:qr,shutdownContent:Jt}=uo(l.tenantId,l.company?.managementInfo?.receiverEmails),Qr=qr===!0&&Jt!=null?c.jsx(mo,{shutdownContent:Jt}):null,Xr=h&&Xt==null,Jr=ea(l),es={events:ha(Jr,Nr),eventCallback:(V,je,Ze)=>{Ze.onEventReceived(V)},onSubscribed:V=>{V.onPusherSubscribed()}};return se||E?c.jsxs(c.Fragment,{children:[pe==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ut,{analytics:J,onLoad:()=>{J.trackPageLoaded(yr.Event.cardsListPage),(I&&!se||_&&!E)&&J.trackCardsPromoView(Z,{isCreditCardOffered:I,isDebitCardOffered:_,isDebitCardEnabled:E,isCreditCardEnabled:se},"Banner",_&&!E?"Debit Card":I&&!se?"Credit Card":"","Card List")}}),c.jsx(nt,{showConfetti:Ge})]}):null,b===!0?c.jsx(Yt,{closeDrawerHandler:Yr,isPaymentDrawerOpen:b,pageName:"Card List",sourcePage:"cardListPage",creditAccountSpentAmount:Ct,productInformation:mt,creditAccountInformation:ze,debitAccountInformation:ra,cashbackInformation:$e,isDebitCardInfoFetchStateCompleted:!(_&&E&&o)||na.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!I||ie.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!o||Ea.fetchState==="Completed",paymentInitiatedDate:ie.initiatedRepaymentDate}):null,c.jsxs(hi,{children:[c.jsx(Ie,{isAppContentDrawerOpen:L,handleDrawerToggle:qt}),c.jsx(fi,{...es,isCashbackFeatureEnabled:k,isChargeCardFeatureEnabled:I,isDebitCardFeatureEnabled:_,isCreditCardProductVisibleForExpressInterest:N,updatePayNowInfoTooltip:m,showPayNowInfoTooltip:S,creditCardPayNowThreshold:q,signedInUser:v,chargeCardListState:ee,location:a,admins:$r.users,navigateAndClearBulkSelection:s,currentTenant:l,isCardControlsEnabled:ke,companyChargeCardInfoCreditAccountLimit:l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,isCompanyInterestedInChargeCard:l.companyChargeCardInfo?.info?.isCompanyInterestedInChargeCard??!1,isUserHasCardsAdminLevelAccess:o,includeCreditAccountDebitSummaryAndCashbackInfo:w,onClickMenuIcon:()=>{qt(!0)},creditLimit:zr,isChargeCardSetupEnabled:se,isChargeCardEnabledOnCompany:Ee,isDebitCardSetupEnabled:E,isDebitCardEnabledOnCompany:re,isEarlyPayEnabled:f,isChargeCardPaymentHistoryFeatureEnabled:j,cashbackRate:ne,controllerEmails:Z,chargeCardCashbackDetailState:Ea,depositAccountListWithDebitCardIssued:na,isChargeCardTOSAccepted:ve,isDebitCardTOSAccepted:fe,primaryFundingAccountDetails:ut,chargeCardSetUpViewFetchState:Aa.fetchState,productInformation:mt,creditAccountInformation:ze,debitAccountInformation:ra,cashbackInformation:$e,isAiCfoAccessEnabled:Xr,onAskAiCfoClick:T,isCardsCommentingEnabled:H,cardsAiCfoHero:Xt,cardsShutdownBanner:Qr,onClickPolicyIcon:o&&R?()=>n(yi(l.tenantEmailDomain)):void 0,isPolicyIntroTooltipVisible:ja,onPolicyIntroTooltipClose:Y,pendingCreationCount:Te})]})]}):(ve||fe)&&o===!0?c.jsx(oa,{to:"../setup"}):Zr?c.jsx(oa,{to:"../promo"}):c.jsx(va,{fetchState:pe})}const gi=e=>`/${e}/cards/new`,Si=e=>`/${e}/cards/payment`,bi=e=>`/${e}/cards/payment-history`,yi=e=>`/${e}/cards/policy`,Vr=[Or,Ur],Ii=new Set(Vr),ki=Pe(function(e){const n=te.getSignedInUser(),t=ge(e),a=e.tenantState.currentTenantId,s=rr(e),b={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:a??""},g=t?.companyName??"",S=e.chargeCardPaymentHistoryState.downloadUIState.downloadState;return{fetchState:s.fetchState,filters:s.filters,isZeniTenant:yc(t),repaymentList:s.repaymentHistory,searchText:s.searchText,repaymentHistoryUsers:s.repaymentHistoryUsers,sortConfig:{sortKey:s.uiState.sortKey,sortOrder:s.uiState.sortOrder},downloadParams:{authParams:b,companyName:g,spendManagementEndPoint:`${Et}/spendManagement`,isShowDeletedBillsEnabled:!1,isShowDeletedReimbursementEnabled:!1},downloadState:S}},function(e,n){const{location:t,navigate:a}=n;return{onBackClick:()=>{const s=we(t.state?.pathnameStackToGoBack),b=s.poppedPathname??"..";a(b,{state:{pathnameStackToGoBack:s.newStack}})},onColumnSortConfigChanged:(s,b)=>{e({type:"chargeCardPaymentHistory/updatePaymentHistoryUIState",payload:{uiState:{sortKey:s,sortOrder:b}}})},onFiltersChange:s=>{e(kc({filters:s}))},onReloadPayments:()=>{e(Ga(!0))},onEventReceived:s=>{Ii.has(s)&&e(Ga(!0))},onPusherSubscribed:()=>{e(Ga(!0))},onSearchTextChanged:s=>{e({type:"chargeCardPaymentHistory/updatePaymentHistorySearchText",payload:s})},updateDownloadStateHandler:s=>{e(Ic({uiState:{downloadState:s}}))}}})(st(po));function Ei(){const e=le(),n=he(),t=me(),{areTenantIdsInSync:a}=br(),{useFeatureGate:s}=ue();if(te.getSignedInUser()==null)throw Error("Can't access payment history page without signing in...");const b=i(o=>ge(o)),g=i(o=>rr(o)),[S,P]=r.useState(!1),[m,C]=r.useState(!1),[F,v]=r.useState(!1),[l,M]=r.useState(null),B=!b.userRole.includes("charge_card_user"),L=!!b.companyDebitCardInfo?.info?.isDebitCardEnabled,{isFeatureEnabled:p}=s(W.isChargeCardFeatureEnabled),{isFeatureEnabled:h}=s(W.isDebitCardFeatureEnabled),T=Le(h,b),u=Oe({isDebitCardFeatureEnabled:h,isBankingOnlyTenant:T}),w=xe(b),E=Be(b),U=b.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,y=Ue({isCardsOnlyTenant:w,isChargeCardFeatureEnabled:p,isBookKeepingTenant:E,isDebitCardProductVisible:u,chargeCardsCreditAccountLimit:U}),k=!!b.companyChargeCardInfo?.info?.isChargeCardEnabled,x=Re(),d=Fe(x?.loggedInUserRoleMap),f=i(o=>Ca(o,B,u&&L,y&&k)),j=r.useMemo(()=>{const o=f.cards.filter(A=>A.type.code.includes("debit"));return[...new Set(o.map(A=>A.connectedAccountId))]},[f.cards]),H=i(o=>ma(o)),O=i(o=>tt(o,j)),{creditAccountRepayment:R}=i(o=>ua(o)),z=r.useMemo(()=>Mt(d,H),[d,H]),$=r.useMemo(()=>Ba(y,k,d,f.creditAccount,R),[y,k,d,f.creditAccount,R]),_=r.useMemo(()=>Nt(u,L,d,O,f.debitCardSummary),[u,L,d,O,f.debitCardSummary]),D=r.useMemo(()=>Xe(y,u,L,k),[y,u,L,k]),G=f.creditAccount.balance.amount+f.creditAccount.hold.amount,Q=r.useMemo(()=>l!=null?g.repaymentHistory.find(o=>o.cardRepaymentId===l):void 0,[l,g.repaymentHistory]),I=r.useCallback(o=>{M(o),t(ia(B,u&&L,y&&k,!1)),v(!0)},[t,B,u,L,y,k]),N=r.useCallback(()=>{v(!1),M(null),document.body.style.overflow="auto"},[]);r.useEffect(()=>{S||g.fetchState==="Completed"||g.fetchState==="In-Progress"||(P(!0),t(Ga()))},[S,t,g.fetchState]),r.useEffect(()=>{!m&&(k||L)&&a&&(C(!0),t(ia(B,!1,y&&k,!1)))},[m,k,L,a,t,B,y]);const K=ea(b),X={events:ha(K,Vr),eventCallback:(o,A,Z)=>{Z.onEventReceived(o)},onSubscribed:o=>{o.onPusherSubscribed()}};return c.jsxs(c.Fragment,{children:[F?c.jsx(Yt,{closeDrawerHandler:N,isPaymentDrawerOpen:F,pageName:"Payment History",sourcePage:"cardPaymentHistory",creditAccountSpentAmount:G,productInformation:D,creditAccountInformation:$,debitAccountInformation:_,cashbackInformation:z,isDebitCardInfoFetchStateCompleted:!(u&&L&&d)||O.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!y||R.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!d||H.fetchState==="Completed",paymentInitiatedDate:R.initiatedRepaymentDate,retryRepayment:Q}):null,c.jsx(ki,{...X,location:n,navigate:e,accountInfoByAccountId:g.accountInfoByAccountId,onRetryPaymentClick:I})]})}const kn=He.div`
26
26
  display: flex;
27
27
  height: 100vh;
28
28
  width: 100%;
@@ -31,7 +31,7 @@ import{j as c}from"./liveblocks-4PIBJMyE.js";import{u as me,j as i,h as le,g as
31
31
  overflow: auto;
32
32
  align-items: center;
33
33
  background-color: ${e=>e.theme.colors.grey4};
34
- `,En=Je.getLocalizedStrings().months;function Ai(){const e=le(),n=me(),t=he(),{creditAccount:a,creditAccountRepayment:s}=i(D=>ua(D)),b=`${Sr.cardMicroServiceBaseUrl}/1.0/credit-accounts/${a.id}`,[g,S]=r.useState(!1),[P,m]=r.useState(!1),C=i(D=>Ec(D)),{useFeatureGate:F}=ue(),v=i(D=>ge(D)),{isFeatureEnabled:l}=F(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:M}=F(Z.isDebitCardFeatureEnabled),{isFeatureEnabled:B}=F(Z.isCardsCommentingEnabled),R=_r(B?v.companyId:void 0,{clearParams:B&&C.fetchState==="Completed"}),p=Re(M,v),h=Oe({isDebitCardFeatureEnabled:M,isBankingOnlyTenant:p}),T=xe(v),u=Be(v),w=v.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,E=Ue({isCardsOnlyTenant:T,isChargeCardFeatureEnabled:l,isBookKeepingTenant:u,isDebitCardProductVisible:h,chargeCardsCreditAccountLimit:w}),U=!!v.companyDebitCardInfo?.info?.isDebitCardEnabled,y=!!v.companyChargeCardInfo?.info?.isChargeCardEnabled,k=i(D=>da(D,v.companyId)),x=la(k.controllers),d=i(D=>sr(D)),f=d.cards.filter(D=>D.type.code.includes("debit")).map(D=>D.connectedAccountId),j=[...new Set(f)],H=i(D=>tt(D,j)),O=i(D=>Ac(D));r.useEffect(()=>{P||a.fetchState==="Completed"||a.fetchState==="In-Progress"||(S(!0),n(Qe()))},[g,n,a.fetchState]),r.useEffect(()=>{P||a.fetchState!=="Completed"||a.id==null||C.fetchState==="Completed"||C.fetchState==="In-Progress"||(m(!0),n(Dc(a.id)))},[P,n,a.fetchState,a.id,C.fetchState]),r.useEffect(()=>{H.fetchState!=="Completed"&&H.fetchState!=="In-Progress"&&h&&U&&n(cr()),d.fetchState!=="Completed"&&d.fetchState!=="In-Progress"&&n(Ne()),O.fetchState!=="Completed"&&O.fetchState!=="In-Progress"&&h&&U&&n(_c()),s.fetchState!=="Completed"&&s.fetchState!=="In-Progress"&&E&&y&&n(Tt())},[H.fetchState,h,U,d.fetchState,O.fetchState,s.fetchState,E,y]),r.useEffect(()=>{if(C.fetchState==="Completed"&&a.fetchState==="Completed"&&s.fetchState==="Completed"&&d.fetchState==="Completed"&&(!h||!U||H.fetchState==="Completed"&&O.fetchState==="Completed")){let D="",G="";if(C.statements.length>0){const W=C.statements[C.statements.length-1].period,[X,o]=W.split("-"),A=C.statements[0].period,[Y,ne]=A.split("-");D=`${En[parseInt(o)-1]} ${X}`,G=`${En[parseInt(ne)-1]} ${Y}`}const Q=Xe(E,h,U,y),I=Ba(E,y,!0,a,s),N=Nt(h,U,!0,H,O);J.trackCardsCreditCardStatementsView(x,Q,{numberOfStatements:C.statements.length,oldestStatementMonthYear:D,latestStatementMonthYear:G},I,N)}},[C.fetchState,a.fetchState,s.fetchState,H.fetchState,d.fetchState,O.fetchState]);const L=()=>{const D=we(t.state?.pathnameStackToGoBack),G=D.poppedPathname??"..";e(G,{state:{pathnameStackToGoBack:D.newStack}})},z=i(D=>ma(D)),$=te.getSignedInUser(),_={userId:$?.userId??"",sessionId:$?.zeniSessionId??"",tenantId:v.tenantId??""};if($==null)throw Error("Can't access address page without signing in...");if(C.fetchState!=="Completed")return c.jsx(kn,{children:c.jsx(ho,{onBackClick:L})});{const D=Xe(E,h,U,y);return c.jsx(kn,{children:c.jsx(fo,{currentTenantCompanyName:v.companyName,statementListView:C,productInformation:D,onBackClick:L,authParams:_,controllerEmails:x,isChargeCardFeatureEnabled:E,isDebitCardFeatureEnabled:h,isDebitCardSetupEnabled:U,isChargeCardSetupEnabled:y,isCardsCommentingEnabled:B,initialOpenThreadRequest:R,chargeCardCashbackDetailState:z,creditAccount:a,creditAccountRepayment:s,depositAccountListWithDebitCardIssued:H,debitCardSummary:O,downloadEndPoint:b})})}}const Hr=[pa,it],Di=new Set(Hr),_i={containerWidth:new Fa(100,58)},Pi=({appContent:e})=>{const n=Ta(),t=me(),a=le(),s=he(),{useDynamicConfig:b}=ue(),[g,S]=r.useState(!1),[P,m]=r.useState(!1),[C,F]=r.useState(!1),[v,l]=r.useState(!1),M=r.useRef(!1),B=r.useRef(null);r.useEffect(()=>()=>{B.current!=null&&(clearTimeout(B.current),B.current=null)},[]);const[R,p]=r.useState(!1),[h,T]=r.useState(!1),u=te.getSignedInUser();if(u==null)throw Error("Can't access onboarding card page without signing in...");const w=i(N=>ge(N)),{configValue:E}=b(Ze.zeniCardsConfig),U=i(N=>Pc(N)),{tenantEmailDomain:y}=w,k=i(N=>N.settingsViewState.profile.fetchState),x=i(N=>N.chargeCardListState.fetchState),d=i(N=>N.settingsViewState.profile.userId),f=i(N=>N.chargeCardConfigState.fetchState);r.useEffect(()=>{g===!1&&k!=="In-Progress"&&k!=="Completed"&&(t(wc()),S(!0)),P===!1&&f!=="In-Progress"&&f!=="Completed"&&(t(Qa()),m(!0)),C===!1&&x==="Not-Started"&&(F(!0),t(Ne()))},[g,C,x,P,f]),r.useEffect(()=>{k==="Completed"&&R===!1&&d!=null&&x==="Completed"&&U.cards.length>0&&(t(vc({userId:d})),t(or({cardId:U.cards[U.cards.length-1].id})),p(!0))},[k,R,d,x]),r.useEffect(()=>{if(!v&&U.fetchState==="Completed"&&U.cards.length===0){const N=we(s.state?.pathnameStackToGoBack),W=N.poppedPathname??aa(y);a(W,{state:{pathnameStackToGoBack:N.newStack}})}},[U.fetchState,U.cards,v]);const j=i(N=>qa(N)),H=ya(j.updateStatus.fetchState),O=j.currentDisplayedCardId,{useFeatureGate:L}=ue(),{isFeatureEnabled:z}=L(Z.isChargeCardFeatureEnabled),$=!!w.companyChargeCardInfo?.info?.isChargeCardEnabled,_=!w.userRole.includes("charge_card_user")&&z&&$,D=i(N=>O!=null?ir(N.chargeCardState,O):null),G=()=>{O!=null&&(M.current=!0,B.current!=null&&clearTimeout(B.current),B.current=setTimeout(()=>{M.current=!1,B.current=null},5e3),t(ka(O,_,!0)),t(Ne(!0)),l(!0))},Q=ea(w);Vt({events:ha(Q,Hr),onSubscribed:()=>{t(Ne(!0))},onEvent:(N,W)=>{if(!Di.has(N))return;const X=Zt(W),o=M.current;if(N===pa){const Y=de(X?.card_id)??O;if(Y!=null){const ne=Wt(X,Y);if(ne!=null)return t(Ft(ne)),void(Y!==O||o||G())}}if(N===it)return void t(Ne(!0));const A=de(X?.card_id)??O;(O==null||A===O)&&O!=null?o||G():t(Ne(!0))}}),r.useEffect(()=>{if(v&&O!=null&&D!=null&&D.status.code!=="request_on_hold"){const N=_e(w.tenantEmailDomain,O,u,D),W=ye(s.state?.pathnameStackToGoBack,s.pathname);t(Tc()),D?.type.code==="business_virtual_credit_card"&&t(Xa()),a(N,{state:{pathnameStackToGoBack:W},replace:!0}),M.current=!1,B.current!=null&&(clearTimeout(B.current),B.current=null)}},[v,D?.status.code]),r.useEffect(()=>{H==="In-Progress"&&j.updateStatus.fetchState==="Completed"&&setTimeout(G,3e3)},[H,j.updateStatus.fetchState]);const I=N=>{T(N)};if(k!=="Completed"||U.cards.length===0)return c.jsxs(An,{children:[c.jsx(Ie,{isAppContentDrawerOpen:h,handleDrawerToggle:I}),c.jsx(go,{})]});if(d==null)throw Error("Can't access my userId.");return c.jsxs(An,{children:[c.jsx(Ie,{isAppContentDrawerOpen:h,handleDrawerToggle:I}),c.jsx(wi,{chargeCardListView:U,cardUserOnboardingView:j,navigate:a,currentTenant:w,myUserId:d,location:s,chargeCardCashbackRatePerTransaction:E.charge_card_cashback_rate_per_transaction!=null?E.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{I(!0)}}),e!=null?c.jsx(vi,{windowSize:n,children:e}):null]})},wi=Pe(function(e,{currentTenant:n,cardUserOnboardingView:t,chargeCardListView:a,myUserId:s}){const b=Ca(e,!1,!1,!1);let g=!1;return b.fetchState==="Completed"&&b.cards.length<=1&&(g=!0),{cards:a.cards,showMenuIcon:g,companyLegalName:n.companyName,twoFAView:t.twoFAView,cardUserOnboardingLocalData:t.cardUserOnboardingLocalData??{userId:s},isDOBDisabled:t.isDOBPresent,onboardingProgressStatus:t.onboardingProgressStatus}},function(e,n){const{navigate:t,cardUserOnboardingView:a,location:s,currentTenant:b}=n,{tenantEmailDomain:g}=b;return{updateCardUserOnboardingLocalData:S=>{e(gn({localData:S}))},onGetOtp:S=>{if(a.cardUserOnboardingLocalData!=null){const P={...a.cardUserOnboardingLocalData,phone:S};e(gn({localData:P}))}e(at(S,"CardUserOnboarding"))},onResendOtp:S=>{e(et(S,"CardUserOnboarding"))},onVerifyOtp:(S,P)=>{e(Ja(S,P,"CardUserOnboarding"))},onVerifyOtpSuccess:S=>{e(Fc()),S!=null&&te.saveZeniOtpToken(S)},setCurrentDisplayedCardId:S=>{e(or({cardId:S}))},onBackClick:()=>{const S=we(s.state?.pathnameStackToGoBack),P=S.poppedPathname??aa(g);t(P,{state:{pathnameStackToGoBack:S.newStack}})}}})(So),vi=He.div`
34
+ `,En=Je.getLocalizedStrings().months;function Ai(){const e=le(),n=me(),t=he(),{creditAccount:a,creditAccountRepayment:s}=i(D=>ua(D)),b=`${Sr.cardMicroServiceBaseUrl}/1.0/credit-accounts/${a.id}`,[g,S]=r.useState(!1),[P,m]=r.useState(!1),C=i(D=>Ec(D)),{useFeatureGate:F}=ue(),v=i(D=>ge(D)),{isFeatureEnabled:l}=F(W.isChargeCardFeatureEnabled),{isFeatureEnabled:M}=F(W.isDebitCardFeatureEnabled),{isFeatureEnabled:B}=F(W.isCardsCommentingEnabled),L=_r(B?v.companyId:void 0,{clearParams:B&&C.fetchState==="Completed"}),p=Le(M,v),h=Oe({isDebitCardFeatureEnabled:M,isBankingOnlyTenant:p}),T=xe(v),u=Be(v),w=v.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,E=Ue({isCardsOnlyTenant:T,isChargeCardFeatureEnabled:l,isBookKeepingTenant:u,isDebitCardProductVisible:h,chargeCardsCreditAccountLimit:w}),U=!!v.companyDebitCardInfo?.info?.isDebitCardEnabled,y=!!v.companyChargeCardInfo?.info?.isChargeCardEnabled,k=i(D=>da(D,v.companyId)),x=la(k.controllers),d=i(D=>sr(D)),f=d.cards.filter(D=>D.type.code.includes("debit")).map(D=>D.connectedAccountId),j=[...new Set(f)],H=i(D=>tt(D,j)),O=i(D=>Ac(D));r.useEffect(()=>{P||a.fetchState==="Completed"||a.fetchState==="In-Progress"||(S(!0),n(Qe()))},[g,n,a.fetchState]),r.useEffect(()=>{P||a.fetchState!=="Completed"||a.id==null||C.fetchState==="Completed"||C.fetchState==="In-Progress"||(m(!0),n(Dc(a.id)))},[P,n,a.fetchState,a.id,C.fetchState]),r.useEffect(()=>{H.fetchState!=="Completed"&&H.fetchState!=="In-Progress"&&h&&U&&n(cr()),d.fetchState!=="Completed"&&d.fetchState!=="In-Progress"&&n(Ne()),O.fetchState!=="Completed"&&O.fetchState!=="In-Progress"&&h&&U&&n(_c()),s.fetchState!=="Completed"&&s.fetchState!=="In-Progress"&&E&&y&&n(Tt())},[H.fetchState,h,U,d.fetchState,O.fetchState,s.fetchState,E,y]),r.useEffect(()=>{if(C.fetchState==="Completed"&&a.fetchState==="Completed"&&s.fetchState==="Completed"&&d.fetchState==="Completed"&&(!h||!U||H.fetchState==="Completed"&&O.fetchState==="Completed")){let D="",G="";if(C.statements.length>0){const K=C.statements[C.statements.length-1].period,[X,o]=K.split("-"),A=C.statements[0].period,[Z,ne]=A.split("-");D=`${En[parseInt(o)-1]} ${X}`,G=`${En[parseInt(ne)-1]} ${Z}`}const Q=Xe(E,h,U,y),I=Ba(E,y,!0,a,s),N=Nt(h,U,!0,H,O);J.trackCardsCreditCardStatementsView(x,Q,{numberOfStatements:C.statements.length,oldestStatementMonthYear:D,latestStatementMonthYear:G},I,N)}},[C.fetchState,a.fetchState,s.fetchState,H.fetchState,d.fetchState,O.fetchState]);const R=()=>{const D=we(t.state?.pathnameStackToGoBack),G=D.poppedPathname??"..";e(G,{state:{pathnameStackToGoBack:D.newStack}})},z=i(D=>ma(D)),$=te.getSignedInUser(),_={userId:$?.userId??"",sessionId:$?.zeniSessionId??"",tenantId:v.tenantId??""};if($==null)throw Error("Can't access address page without signing in...");if(C.fetchState!=="Completed")return c.jsx(kn,{children:c.jsx(ho,{onBackClick:R})});{const D=Xe(E,h,U,y);return c.jsx(kn,{children:c.jsx(fo,{currentTenantCompanyName:v.companyName,statementListView:C,productInformation:D,onBackClick:R,authParams:_,controllerEmails:x,isChargeCardFeatureEnabled:E,isDebitCardFeatureEnabled:h,isDebitCardSetupEnabled:U,isChargeCardSetupEnabled:y,isCardsCommentingEnabled:B,initialOpenThreadRequest:L,chargeCardCashbackDetailState:z,creditAccount:a,creditAccountRepayment:s,depositAccountListWithDebitCardIssued:H,debitCardSummary:O,downloadEndPoint:b})})}}const Hr=[pa,it],Di=new Set(Hr),_i={containerWidth:new Fa(100,58)},Pi=({appContent:e})=>{const n=Ta(),t=me(),a=le(),s=he(),{useDynamicConfig:b}=ue(),[g,S]=r.useState(!1),[P,m]=r.useState(!1),[C,F]=r.useState(!1),[v,l]=r.useState(!1),M=r.useRef(!1),B=r.useRef(null);r.useEffect(()=>()=>{B.current!=null&&(clearTimeout(B.current),B.current=null)},[]);const[L,p]=r.useState(!1),[h,T]=r.useState(!1),u=te.getSignedInUser();if(u==null)throw Error("Can't access onboarding card page without signing in...");const w=i(N=>ge(N)),{configValue:E}=b(We.zeniCardsConfig),U=i(N=>Pc(N)),{tenantEmailDomain:y}=w,k=i(N=>N.settingsViewState.profile.fetchState),x=i(N=>N.chargeCardListState.fetchState),d=i(N=>N.settingsViewState.profile.userId),f=i(N=>N.chargeCardConfigState.fetchState);r.useEffect(()=>{g===!1&&k!=="In-Progress"&&k!=="Completed"&&(t(wc()),S(!0)),P===!1&&f!=="In-Progress"&&f!=="Completed"&&(t(Qa()),m(!0)),C===!1&&x==="Not-Started"&&(F(!0),t(Ne()))},[g,C,x,P,f]),r.useEffect(()=>{k==="Completed"&&L===!1&&d!=null&&x==="Completed"&&U.cards.length>0&&(t(vc({userId:d})),t(or({cardId:U.cards[U.cards.length-1].id})),p(!0))},[k,L,d,x]),r.useEffect(()=>{if(!v&&U.fetchState==="Completed"&&U.cards.length===0){const N=we(s.state?.pathnameStackToGoBack),K=N.poppedPathname??aa(y);a(K,{state:{pathnameStackToGoBack:N.newStack}})}},[U.fetchState,U.cards,v]);const j=i(N=>qa(N)),H=ya(j.updateStatus.fetchState),O=j.currentDisplayedCardId,{useFeatureGate:R}=ue(),{isFeatureEnabled:z}=R(W.isChargeCardFeatureEnabled),$=!!w.companyChargeCardInfo?.info?.isChargeCardEnabled,_=!w.userRole.includes("charge_card_user")&&z&&$,D=i(N=>O!=null?ir(N.chargeCardState,O):null),G=()=>{O!=null&&(M.current=!0,B.current!=null&&clearTimeout(B.current),B.current=setTimeout(()=>{M.current=!1,B.current=null},5e3),t(ka(O,_,!0)),t(Ne(!0)),l(!0))},Q=ea(w);Vt({events:ha(Q,Hr),onSubscribed:()=>{t(Ne(!0))},onEvent:(N,K)=>{if(!Di.has(N))return;const X=Wt(K),o=M.current;if(N===pa){const Z=de(X?.card_id)??O;if(Z!=null){const ne=Kt(X,Z);if(ne!=null)return t(Ft(ne)),void(Z!==O||o||G())}}if(N===it)return void t(Ne(!0));const A=de(X?.card_id)??O;(O==null||A===O)&&O!=null?o||G():t(Ne(!0))}}),r.useEffect(()=>{if(v&&O!=null&&D!=null&&D.status.code!=="request_on_hold"){const N=_e(w.tenantEmailDomain,O,u,D),K=ye(s.state?.pathnameStackToGoBack,s.pathname);t(Tc()),D?.type.code==="business_virtual_credit_card"&&t(Xa()),a(N,{state:{pathnameStackToGoBack:K},replace:!0}),M.current=!1,B.current!=null&&(clearTimeout(B.current),B.current=null)}},[v,D?.status.code]),r.useEffect(()=>{H==="In-Progress"&&j.updateStatus.fetchState==="Completed"&&setTimeout(G,3e3)},[H,j.updateStatus.fetchState]);const I=N=>{T(N)};if(k!=="Completed"||U.cards.length===0)return c.jsxs(An,{children:[c.jsx(Ie,{isAppContentDrawerOpen:h,handleDrawerToggle:I}),c.jsx(go,{})]});if(d==null)throw Error("Can't access my userId.");return c.jsxs(An,{children:[c.jsx(Ie,{isAppContentDrawerOpen:h,handleDrawerToggle:I}),c.jsx(wi,{chargeCardListView:U,cardUserOnboardingView:j,navigate:a,currentTenant:w,myUserId:d,location:s,chargeCardCashbackRatePerTransaction:E.charge_card_cashback_rate_per_transaction!=null?E.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{I(!0)}}),e!=null?c.jsx(vi,{windowSize:n,children:e}):null]})},wi=Pe(function(e,{currentTenant:n,cardUserOnboardingView:t,chargeCardListView:a,myUserId:s}){const b=Ca(e,!1,!1,!1);let g=!1;return b.fetchState==="Completed"&&b.cards.length<=1&&(g=!0),{cards:a.cards,showMenuIcon:g,companyLegalName:n.companyName,twoFAView:t.twoFAView,cardUserOnboardingLocalData:t.cardUserOnboardingLocalData??{userId:s},isDOBDisabled:t.isDOBPresent,onboardingProgressStatus:t.onboardingProgressStatus}},function(e,n){const{navigate:t,cardUserOnboardingView:a,location:s,currentTenant:b}=n,{tenantEmailDomain:g}=b;return{updateCardUserOnboardingLocalData:S=>{e(gn({localData:S}))},onGetOtp:S=>{if(a.cardUserOnboardingLocalData!=null){const P={...a.cardUserOnboardingLocalData,phone:S};e(gn({localData:P}))}e(at(S,"CardUserOnboarding"))},onResendOtp:S=>{e(et(S,"CardUserOnboarding"))},onVerifyOtp:(S,P)=>{e(Ja(S,P,"CardUserOnboarding"))},onVerifyOtpSuccess:S=>{e(Fc()),S!=null&&te.saveZeniOtpToken(S)},setCurrentDisplayedCardId:S=>{e(or({cardId:S}))},onBackClick:()=>{const S=we(s.state?.pathnameStackToGoBack),P=S.poppedPathname??aa(g);t(P,{state:{pathnameStackToGoBack:S.newStack}})}}})(So),vi=He.div`
35
35
  display: flex;
36
36
  flex-direction: column;
37
37
  width: ${e=>`${_i.containerWidth.value(e.windowSize)}%`};
@@ -44,13 +44,13 @@ import{j as c}from"./liveblocks-4PIBJMyE.js";import{u as me,j as i,h as le,g as
44
44
  flex-direction: column;
45
45
  align-items: center;
46
46
  background-color: ${e=>e.theme.colors.grey4};
47
- `,Ti={containerWidth:new Fa(100,58)},Fi=({appContent:e})=>{const n=Ta(),t=me(),a=le(),{cardId:s}=Ve(),b=he(),{useDynamicConfig:g,useFeatureGate:S}=ue(),[P,m]=r.useState(!1),[C,F]=r.useState(!1),[v,l]=r.useState(!1),[M,B]=r.useState(!1),R=te.getSignedInUser();if(R==null)throw Error("Can't access onboarding card page without signing in...");const p=i(_=>ge(_));if(s==null)throw Error("Empty card id is not valid...");const{configValue:h}=g(Ze.zeniCardsConfig),T=i(_=>xc(_,s)),{isFeatureEnabled:u}=S(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:w}=S(Z.isDebitCardFeatureEnabled),E=Re(w,p),U=Oe({isDebitCardFeatureEnabled:w,isBankingOnlyTenant:E}),y=xe(p),k=Be(p),x=p.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,d=Ue({isCardsOnlyTenant:y,isChargeCardFeatureEnabled:u,isBookKeepingTenant:k,isDebitCardProductVisible:U,chargeCardsCreditAccountLimit:x}),f=T.chargeCard,j=i(_=>_.chargeCardConfigState.fetchState);r.useEffect(()=>{P===!1&&j!=="In-Progress"&&j!=="Completed"&&(t(Qa()),m(!0)),C===!1&&T.fetchState==="Not-Started"&&(F(!0),t(ka(s,!1,d)))},[C,T.fetchState,P,j]);const H=f?.type.code==="business_physical_debit_card"||f?.type.code==="business_virtual_debit_card";r.useEffect(()=>{if(T.fetchState==="Completed"){if(v===!1&&(H===!1||H&&f.status?.code!=="active"||H&&f.status.code==="active"&&f.isPinSet||f.cardHolderUserId!==R.userId)){const _=_e(p.tenantEmailDomain,s,R,f,!0),D=ye(b.state?.pathnameStackToGoBack,b.pathname);a(_,{state:{pathnameStackToGoBack:D}})}else if(v&&T.isRefreshingViewInBackground===!1&&f?.isPinSet===!0){t(Bc({chargeCardId:s}));const _=_e(p.tenantEmailDomain,s,R,f,!0),D=ye(b.state?.pathnameStackToGoBack,b.pathname);t(Xa()),a(_,{state:{pathnameStackToGoBack:D}})}}},[T.fetchState,f?.type.code,v,T.isRefreshingViewInBackground]);const O=te.getZeniOtpTokenForCardHolder(s),L=i(_=>Vn(_.userState,R.userId)),z=()=>{f?.isPinSet!==!0&&t(Sa(s,!0))};r.useEffect(()=>{T.updateDebitCardPinAttemptFetchState.fetchState==="Completed"&&(setTimeout(z,3e3),l(!0))},[T.updateDebitCardPinAttemptFetchState.fetchState]);const $=_=>{B(_)};if(j!=="Completed"||f==null)return c.jsx(va,{fetchState:"In-Progress"});if(L?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(Ri,{children:[c.jsx(Ie,{isAppContentDrawerOpen:M,handleDrawerToggle:$}),c.jsx(xi,{cardId:s,card:f,phone:L.phone,signedInUser:R,isSandboxEnv:Lt(),debitCardDetailState:T,signedInUserToken:O,navigate:a,currentTenant:p,location:b,chargeCardCashbackRatePerTransaction:h.charge_card_cashback_rate_per_transaction!=null?h.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{$(!0)}}),e!=null?c.jsx(Bi,{windowSize:n,children:e}):null]})},xi=Pe(function(e,{debitCardDetailState:n,cardId:t}){const a=Hn(e,t),s=n.updateStatus,b=Ca(e,!1,!1,!1);let g=!1;return b.fetchState==="Completed"&&b.cards.length<=1&&(g=!0),{showMenuIcon:g,vgsVaultId:rt.cardVaultId,twoFAView:a,setPinWaitStatus:s}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:b,debitCardDetailState:g}=n,S=g.chargeCard?.cardProviderID,{tenantEmailDomain:P}=b;return{onGetOtp:m=>{S!=null&&e(at(m,"ChargeCardHolder",a))},onUpdateDebitCardPinAttempt:m=>{e(Yn(a,m))},onResendOtp:m=>{S!=null&&e(et(m,"ChargeCardHolder",a))},onVerifyOtp:(m,C)=>{S!=null&&e(Ja(m,C,"ChargeCardHolder",a))},onVerifyOtpSuccess:m=>{m!=null&&te.saveZeniOtpTokenForCardHolder(m,a)},onSetPinSuccess:()=>{e(Rc({chargeCardId:a}))},onBackClick:()=>{const m=we(s.state?.pathnameStackToGoBack),C=m.poppedPathname==null||m.poppedPathname.includes("activate")===!0?aa(P):m.poppedPathname;t(C,{state:{pathnameStackToGoBack:m.newStack}})}}})(bo),Bi=He.div`
47
+ `,Ti={containerWidth:new Fa(100,58)},Fi=({appContent:e})=>{const n=Ta(),t=me(),a=le(),{cardId:s}=Ve(),b=he(),{useDynamicConfig:g,useFeatureGate:S}=ue(),[P,m]=r.useState(!1),[C,F]=r.useState(!1),[v,l]=r.useState(!1),[M,B]=r.useState(!1),L=te.getSignedInUser();if(L==null)throw Error("Can't access onboarding card page without signing in...");const p=i(_=>ge(_));if(s==null)throw Error("Empty card id is not valid...");const{configValue:h}=g(We.zeniCardsConfig),T=i(_=>xc(_,s)),{isFeatureEnabled:u}=S(W.isChargeCardFeatureEnabled),{isFeatureEnabled:w}=S(W.isDebitCardFeatureEnabled),E=Le(w,p),U=Oe({isDebitCardFeatureEnabled:w,isBankingOnlyTenant:E}),y=xe(p),k=Be(p),x=p.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,d=Ue({isCardsOnlyTenant:y,isChargeCardFeatureEnabled:u,isBookKeepingTenant:k,isDebitCardProductVisible:U,chargeCardsCreditAccountLimit:x}),f=T.chargeCard,j=i(_=>_.chargeCardConfigState.fetchState);r.useEffect(()=>{P===!1&&j!=="In-Progress"&&j!=="Completed"&&(t(Qa()),m(!0)),C===!1&&T.fetchState==="Not-Started"&&(F(!0),t(ka(s,!1,d)))},[C,T.fetchState,P,j]);const H=f?.type.code==="business_physical_debit_card"||f?.type.code==="business_virtual_debit_card";r.useEffect(()=>{if(T.fetchState==="Completed"){if(v===!1&&(H===!1||H&&f.status?.code!=="active"||H&&f.status.code==="active"&&f.isPinSet||f.cardHolderUserId!==L.userId)){const _=_e(p.tenantEmailDomain,s,L,f,!0),D=ye(b.state?.pathnameStackToGoBack,b.pathname);a(_,{state:{pathnameStackToGoBack:D}})}else if(v&&T.isRefreshingViewInBackground===!1&&f?.isPinSet===!0){t(Bc({chargeCardId:s}));const _=_e(p.tenantEmailDomain,s,L,f,!0),D=ye(b.state?.pathnameStackToGoBack,b.pathname);t(Xa()),a(_,{state:{pathnameStackToGoBack:D}})}}},[T.fetchState,f?.type.code,v,T.isRefreshingViewInBackground]);const O=te.getZeniOtpTokenForCardHolder(s),R=i(_=>Vn(_.userState,L.userId)),z=()=>{f?.isPinSet!==!0&&t(Sa(s,!0))};r.useEffect(()=>{T.updateDebitCardPinAttemptFetchState.fetchState==="Completed"&&(setTimeout(z,3e3),l(!0))},[T.updateDebitCardPinAttemptFetchState.fetchState]);const $=_=>{B(_)};if(j!=="Completed"||f==null)return c.jsx(va,{fetchState:"In-Progress"});if(R?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(Li,{children:[c.jsx(Ie,{isAppContentDrawerOpen:M,handleDrawerToggle:$}),c.jsx(xi,{cardId:s,card:f,phone:R.phone,signedInUser:L,isSandboxEnv:Rt(),debitCardDetailState:T,signedInUserToken:O,navigate:a,currentTenant:p,location:b,chargeCardCashbackRatePerTransaction:h.charge_card_cashback_rate_per_transaction!=null?h.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{$(!0)}}),e!=null?c.jsx(Bi,{windowSize:n,children:e}):null]})},xi=Pe(function(e,{debitCardDetailState:n,cardId:t}){const a=Hn(e,t),s=n.updateStatus,b=Ca(e,!1,!1,!1);let g=!1;return b.fetchState==="Completed"&&b.cards.length<=1&&(g=!0),{showMenuIcon:g,vgsVaultId:rt.cardVaultId,twoFAView:a,setPinWaitStatus:s}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:b,debitCardDetailState:g}=n,S=g.chargeCard?.cardProviderID,{tenantEmailDomain:P}=b;return{onGetOtp:m=>{S!=null&&e(at(m,"ChargeCardHolder",a))},onUpdateDebitCardPinAttempt:m=>{e(Zn(a,m))},onResendOtp:m=>{S!=null&&e(et(m,"ChargeCardHolder",a))},onVerifyOtp:(m,C)=>{S!=null&&e(Ja(m,C,"ChargeCardHolder",a))},onVerifyOtpSuccess:m=>{m!=null&&te.saveZeniOtpTokenForCardHolder(m,a)},onSetPinSuccess:()=>{e(Lc({chargeCardId:a}))},onBackClick:()=>{const m=we(s.state?.pathnameStackToGoBack),C=m.poppedPathname==null||m.poppedPathname.includes("activate")===!0?aa(P):m.poppedPathname;t(C,{state:{pathnameStackToGoBack:m.newStack}})}}})(bo),Bi=He.div`
48
48
  display: flex;
49
49
  flex-direction: column;
50
50
  width: ${e=>`${Ti.containerWidth.value(e.windowSize)}%`};
51
51
  ${e=>e.windowSize!=="small"?"overflow: auto;":""}
52
- box-shadow: ${e=>`${Za.sp0} 2px ${Za.sp1} ${e.theme.colors.dropShadowNormal}`};
53
- `,Ri=He.div`
52
+ box-shadow: ${e=>`${Wa.sp0} 2px ${Wa.sp1} ${e.theme.colors.dropShadowNormal}`};
53
+ `,Li=He.div`
54
54
  display: flex;
55
55
  min-height: 100%;
56
56
  width: 100%;
@@ -58,8 +58,8 @@ import{j as c}from"./liveblocks-4PIBJMyE.js";import{u as me,j as i,h as le,g as
58
58
  flex-direction: column;
59
59
  align-items: center;
60
60
  background-color: ${e=>e.theme.colors.grey4};
61
- box-shadow: ${e=>`${Za.sp0} 2px ${Za.sp1} ${e.theme.colors.dropShadowNormal}`};
62
- `,Li={overlayWidth:new Fa(ht[12],ht[12],ht[9])},Oi=Pe(function(e,n){const t=Bt(e,!1,!1),a=n.lineId,s=t.customAddress[a],b=t.customAddressStatus[a]??{fetchState:"Not-Started",error:void 0};return{googleAPIKey:n.googleAPIKey,customAddress:s,customAddressStatus:b,lineId:a}},function(e,n){const{newCustomAddressId:t,lineId:a,chargeCardTypeOption:s}=n;return{onSubmitHandler:b=>{t!=null&&e(dr(`${s==="creditCard"?"credit":"debit"}_custom_shipping_${a}_address`));const g=Bo(b);e(Uc({addressType:`${s==="creditCard"?"credit":"debit"}_custom_shipping_${a}_address`,addressToCreate:g})),e(jc(`${s==="creditCard"?"credit":"debit"}_custom_shipping_${a}_address`))},onDismissClick:()=>{n.onDismissClick(),t!=null&&e(Oc({addressId:t,cardLineId:a,cardType:s==="creditCard"?"business_physical_credit_card":"business_physical_debit_card"}))}}})(yo),Ui=({lineId:e,closeDrawerHandler:n,chargeCardTypeOption:t})=>{const a=Ot(),s=Ta(),b=()=>{n()},g=i(S=>Lc(`${t==="creditCard"?"credit":"debit"}_custom_shipping_${e}_address`,S))?.newAddressId;return c.jsx(Ir,{anchor:"right",open:e.length>0,PaperProps:{style:{minWidth:Li.overlayWidth.valuePercentage(s),boxShadow:"none",zIndex:8}},slotProps:{backdrop:{style:{opacity:.75,backgroundColor:a.colors.black,cursor:"pointer"}}},onClose:(S,P)=>(P==="backdropClick"||P==="escapeKeyDown")&&b(),children:c.jsx(Oi,{googleAPIKey:rt.googleMapsAPIKey,onDismissClick:b,lineId:e,chargeCardTypeOption:t,newCustomAddressId:g})})},ji=Pe(function(e,n){const{isChargeCardFeatureEnabled:t,isDebitCardFeatureEnabled:a,isIssuePhysicalCardEnabled:s,isIssuePhysicalDebitCardEnabled:b,isChargeCardSetupEnabled:g,isDebitCardSetupEnabled:S}=n,P=Bt(e,t&&g,a&&S);return{issueChargeCards:P,isIssuePhysicalCardEnabled:s,isIssuePhysicalDebitCardEnabled:b,isDebitCardFeatureEnabled:a,isChargeCardFeatureEnabled:t,isChargeCardSetupEnabled:g,isDebitCardSetupEnabled:S,cardHolderCandidates:P.userList.map(m=>m.user).filter(Boolean),allRoles:P.userList.map(m=>m.userRole),allAccountingClasses:P.allAccountingClasses,userList:P.userList}},function(e,n){return{onIssueCardClick:()=>{e(Vc())},onSaveChangesToLocalStore:t=>{e(Nc(t))},onDismissClick:()=>{e(lr()),n.navigate("../")},resetCustomAddressByLineID:(t,a)=>{e(dr(`${a==="creditCard"?"credit":"debit"}_custom_shipping_${t}_address`))},openAddAddressDrawerHandler:n.openAddAddressDrawerHandler}})(Eo);function Mi(){const e=te.getSignedInUser(),n=le(),t=me(),a=Io(),[s]=Dn(),b=s.get("cardType"),{useFeatureGate:g}=ue(),{isFeatureEnabled:S}=g(Z.isIssuePhysicalCardEnabled),{isFeatureEnabled:P}=g(Z.isIssuePhysicalDebitCardEnabled),{isFeatureEnabled:m}=g(Z.isDebitCardFeatureEnabled),{isFeatureEnabled:C}=g(Z.isChargeCardFeatureEnabled),F=i(z=>ge(z)),v=Re(m,F),l=Oe({isDebitCardFeatureEnabled:m,isBankingOnlyTenant:v}),M=xe(F),B=Be(F),R=F.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,p=Ue({isCardsOnlyTenant:M,isChargeCardFeatureEnabled:C,isBookKeepingTenant:B,isDebitCardProductVisible:l,chargeCardsCreditAccountLimit:R}),[h,T]=r.useState(!1);if(e==null)throw Error("Can't access issue card page without signing in...");r.useEffect(()=>{h||(T(!0),t(Mc(l&&w,p&&u,!1)))},[h,T,t]);const u=!!F.companyChargeCardInfo?.info?.isChargeCardEnabled,w=!!F.companyDebitCardInfo?.info?.isDebitCardEnabled,E=i(z=>Bt(z,p&&u,l&&w)),U=E.fetchState,y=E.issueCardStatus.fetchState,k=E.lastSelfIssuedDebitCardId,x=i(z=>k!=null?ir(z.chargeCardState,k):void 0),[d,f]=r.useState(null),[j,H]=r.useState(null),O=()=>{f(null)},L=(z,$)=>{f(z),H($)};return r.useEffect(()=>{if(y==="Completed"){if(k!=null&&x?.type.code==="business_virtual_debit_card"){let z;z=x?.status.code==="request_on_hold"&&e.userId===x.cardHolderUserId?Dr(F.tenantEmailDomain):_e(F.tenantEmailDomain,k,e,x),n(z)}else n("../");t(lr())}},[y,k]),U==="Completed"?c.jsxs(c.Fragment,{children:[d!==null&&j!==null?c.jsx(Ui,{closeDrawerHandler:O,lineId:d,chargeCardTypeOption:j}):null,c.jsx(ji,{themeState:a,isIssuePhysicalCardEnabled:S,isIssuePhysicalDebitCardEnabled:P,isDebitCardFeatureEnabled:l,isChargeCardFeatureEnabled:p,isChargeCardSetupEnabled:u,isDebitCardSetupEnabled:w,navigate:n,fetchState:E.fetchState,openAddAddressDrawerHandler:L,defaultCardType:b==="creditCard"||b==="debitCard"?b:void 0})]}):U==="Error"?c.jsx(ct,{}):c.jsx(ko,{})}const Gr=[pa,it],Ni=new Set(Gr),Vi=He.div`
61
+ box-shadow: ${e=>`${Wa.sp0} 2px ${Wa.sp1} ${e.theme.colors.dropShadowNormal}`};
62
+ `,Ri={overlayWidth:new Fa(ht[12],ht[12],ht[9])},Oi=Pe(function(e,n){const t=Bt(e,!1,!1),a=n.lineId,s=t.customAddress[a],b=t.customAddressStatus[a]??{fetchState:"Not-Started",error:void 0};return{googleAPIKey:n.googleAPIKey,customAddress:s,customAddressStatus:b,lineId:a}},function(e,n){const{newCustomAddressId:t,lineId:a,chargeCardTypeOption:s}=n;return{onSubmitHandler:b=>{t!=null&&e(dr(`${s==="creditCard"?"credit":"debit"}_custom_shipping_${a}_address`));const g=Bo(b);e(Uc({addressType:`${s==="creditCard"?"credit":"debit"}_custom_shipping_${a}_address`,addressToCreate:g})),e(jc(`${s==="creditCard"?"credit":"debit"}_custom_shipping_${a}_address`))},onDismissClick:()=>{n.onDismissClick(),t!=null&&e(Oc({addressId:t,cardLineId:a,cardType:s==="creditCard"?"business_physical_credit_card":"business_physical_debit_card"}))}}})(yo),Ui=({lineId:e,closeDrawerHandler:n,chargeCardTypeOption:t})=>{const a=Ot(),s=Ta(),b=()=>{n()},g=i(S=>Rc(`${t==="creditCard"?"credit":"debit"}_custom_shipping_${e}_address`,S))?.newAddressId;return c.jsx(Ir,{anchor:"right",open:e.length>0,PaperProps:{style:{minWidth:Ri.overlayWidth.valuePercentage(s),boxShadow:"none",zIndex:8}},slotProps:{backdrop:{style:{opacity:.75,backgroundColor:a.colors.black,cursor:"pointer"}}},onClose:(S,P)=>(P==="backdropClick"||P==="escapeKeyDown")&&b(),children:c.jsx(Oi,{googleAPIKey:rt.googleMapsAPIKey,onDismissClick:b,lineId:e,chargeCardTypeOption:t,newCustomAddressId:g})})},ji=Pe(function(e,n){const{isChargeCardFeatureEnabled:t,isDebitCardFeatureEnabled:a,isIssuePhysicalCardEnabled:s,isIssuePhysicalDebitCardEnabled:b,isChargeCardSetupEnabled:g,isDebitCardSetupEnabled:S}=n,P=Bt(e,t&&g,a&&S);return{issueChargeCards:P,isIssuePhysicalCardEnabled:s,isIssuePhysicalDebitCardEnabled:b,isDebitCardFeatureEnabled:a,isChargeCardFeatureEnabled:t,isChargeCardSetupEnabled:g,isDebitCardSetupEnabled:S,cardHolderCandidates:P.userList.map(m=>m.user).filter(Boolean),allRoles:P.userList.map(m=>m.userRole),allAccountingClasses:P.allAccountingClasses,userList:P.userList}},function(e,n){return{onIssueCardClick:()=>{e(Vc())},onSaveChangesToLocalStore:t=>{e(Nc(t))},onDismissClick:()=>{e(lr()),n.navigate("../")},resetCustomAddressByLineID:(t,a)=>{e(dr(`${a==="creditCard"?"credit":"debit"}_custom_shipping_${t}_address`))},openAddAddressDrawerHandler:n.openAddAddressDrawerHandler}})(Eo);function Mi(){const e=te.getSignedInUser(),n=le(),t=me(),a=Io(),[s]=Dn(),b=s.get("cardType"),{useFeatureGate:g}=ue(),{isFeatureEnabled:S}=g(W.isIssuePhysicalCardEnabled),{isFeatureEnabled:P}=g(W.isIssuePhysicalDebitCardEnabled),{isFeatureEnabled:m}=g(W.isDebitCardFeatureEnabled),{isFeatureEnabled:C}=g(W.isChargeCardFeatureEnabled),F=i(z=>ge(z)),v=Le(m,F),l=Oe({isDebitCardFeatureEnabled:m,isBankingOnlyTenant:v}),M=xe(F),B=Be(F),L=F.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,p=Ue({isCardsOnlyTenant:M,isChargeCardFeatureEnabled:C,isBookKeepingTenant:B,isDebitCardProductVisible:l,chargeCardsCreditAccountLimit:L}),[h,T]=r.useState(!1);if(e==null)throw Error("Can't access issue card page without signing in...");r.useEffect(()=>{h||(T(!0),t(Mc(l&&w,p&&u,!1)))},[h,T,t]);const u=!!F.companyChargeCardInfo?.info?.isChargeCardEnabled,w=!!F.companyDebitCardInfo?.info?.isDebitCardEnabled,E=i(z=>Bt(z,p&&u,l&&w)),U=E.fetchState,y=E.issueCardStatus.fetchState,k=E.lastSelfIssuedDebitCardId,x=i(z=>k!=null?ir(z.chargeCardState,k):void 0),[d,f]=r.useState(null),[j,H]=r.useState(null),O=()=>{f(null)},R=(z,$)=>{f(z),H($)};return r.useEffect(()=>{if(y==="Completed"){if(k!=null&&x?.type.code==="business_virtual_debit_card"){let z;z=x?.status.code==="request_on_hold"&&e.userId===x.cardHolderUserId?Dr(F.tenantEmailDomain):_e(F.tenantEmailDomain,k,e,x),n(z)}else n("../");t(lr())}},[y,k]),U==="Completed"?c.jsxs(c.Fragment,{children:[d!==null&&j!==null?c.jsx(Ui,{closeDrawerHandler:O,lineId:d,chargeCardTypeOption:j}):null,c.jsx(ji,{themeState:a,isIssuePhysicalCardEnabled:S,isIssuePhysicalDebitCardEnabled:P,isDebitCardFeatureEnabled:l,isChargeCardFeatureEnabled:p,isChargeCardSetupEnabled:u,isDebitCardSetupEnabled:w,navigate:n,fetchState:E.fetchState,openAddAddressDrawerHandler:R,defaultCardType:b==="creditCard"||b==="debitCard"?b:void 0})]}):U==="Error"?c.jsx(ct,{}):c.jsx(ko,{})}const Gr=[pa,it],Ni=new Set(Gr),Vi=He.div`
63
63
  display: flex;
64
64
  height: 100vh;
65
65
  width: 100%;
@@ -68,4 +68,4 @@ import{j as c}from"./liveblocks-4PIBJMyE.js";import{u as me,j as i,h as le,g as
68
68
  overflow: auto;
69
69
  align-items: center;
70
70
  background-color: ${e=>e.theme.colors.grey4};
71
- `,Hi=Pe(function(e,n){const{myPendingActivationChargeCardListState:t}=n;return{myPendingActivationChargeCardListView:t,uiState:t.uiState,signedInUser:n.signedInUser}},function(e,n){const{navigate:t,currentTenant:a,location:s,signedInUser:b,myPendingActivationChargeCardListState:g}=n,{tenantEmailDomain:S}=a,{cards:P}=g;return{onChargeCardRowClick:m=>{const C=Ar(P,m),F=_e(S,m,b,C),v=ye(s.state?.pathnameStackToGoBack,s.pathname);t(F,{state:{pathnameStackToGoBack:v}})},onColumnSortConfigChanged:(m,C)=>{e(It({uiState:{sortKey:m,sortOrder:C}}))},onReloadCards:()=>{e(Ne())},onBackClick:()=>{const m=a.userRole.includes("charge_card_user");e(It({uiState:{sortKey:m?"cardName":"owner",sortOrder:"ascending"}})),t("../")}}})(Ao);function Gi(){const e=le(),n=me(),t=he(),a=Ot(),[s,b]=r.useState(!1),g=i(L=>Hc(L)),S=i(L=>ge(L)),P=i(L=>da(L,S.companyId)),m=la(P.controllers),{useFeatureGate:C}=ue(),{isFeatureEnabled:F}=C(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:v}=C(Z.isDebitCardFeatureEnabled),l=Re(v,S),M=Oe({isDebitCardFeatureEnabled:v,isBankingOnlyTenant:l}),B=!!S.companyDebitCardInfo?.info?.isDebitCardEnabled,R=!!S.companyChargeCardInfo?.info?.isChargeCardEnabled,p=Le(),h=xe(S),T=Be(S),u=S.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,w=Ue({isCardsOnlyTenant:h,isChargeCardFeatureEnabled:F,isBookKeepingTenant:T,isDebitCardProductVisible:M,chargeCardsCreditAccountLimit:u}),E=Fe(p?.loggedInUserRoleMap),U=i(L=>ma(L)),{creditAccount:y,creditAccountRepayment:k}=i(L=>ua(L)),x=i(L=>sr(L)).cards.filter(L=>L.type.code.includes("debit")).map(L=>L.connectedAccountId),d=[...new Set(x)],f=i(L=>tt(L,d));r.useEffect(()=>{s||g.fetchState==="Completed"||g.fetchState==="In-Progress"||(b(!0),n(Ne()),n(Qa()))},[s,n,g.fetchState]),r.useEffect(()=>{if(g.fetchState==="Completed"&&g.cards.length===1&&j!=null){const L=_e(S.tenantEmailDomain,g.cards[0].id,j,g.cards[0]);e(L,{state:{message:t.state?.message}})}},[g.fetchState,g.cards]);const j=te.getSignedInUser();r.useEffect(()=>{y.fetchState!=="Completed"&&y.fetchState!=="In-Progress"&&w&&R&&E&&n(Qe()),k.fetchState!=="Completed"&&k.fetchState!=="In-Progress"&&E&&n(Tt()),f.fetchState!=="Completed"&&f.fetchState!=="In-Progress"&&M&&B&&E&&n(cr())},[y.fetchState,k.fetchState,n,f.fetchState,M,B,E,w,R]);const H=ea(S);if(Vt({events:ha(H,Gr),onEvent:(L,z)=>{if(!Ni.has(L))return;const $=Zt(z);if(L===pa){const _=de($?.card_id);if(_!=null){const D=Wt($,_);if(D!=null)return void n(Ft(D))}}n(Ne(!0))},onSubscribed:()=>{n(Ne(!0))}}),j==null)throw Error("Can't access address page without signing in...");const O=g.cards!=null&&g.cards.length>0;if(g.fetchState==="Completed"||O){const L=Xe(w,M,B,R);return c.jsx(Vi,{children:c.jsx(Hi,{navigate:e,currentTenant:S,signedInUser:j,productInformation:L,myPendingActivationChargeCardListState:g,isChargeCardFeatureEnabled:w,isDebitCardFeatureEnabled:M,isDebitCardSetupEnabled:B,isChargeCardSetupEnabled:R,chargeCardCashbackDetailState:U,creditAccount:y,creditAccountRepayment:k,depositAccountListWithDebitCardIssued:f,controllerEmails:m,location:t})})}return c.jsx(va,{fetchState:"In-Progress",style:{backgroundColor:a.colors.grey5}})}const $i=Pe(function(e,n){const{companyId:t,companyLegalName:a}=n;return{chargeCardSetupView:wa(e,t),admins:n.adminList,companyLegalName:a,meetingUrl:"https://meetings.hubspot.com/niharn/demo-zeni-charge-cards?embed=true"}},function(e,n){const{navigate:t,companyId:a,isCompanyBusinessVerificationAndPaymentSetUpDone:s,isDebitCardSetupEnabled:b,isChargeCardSetupEnabled:g,signedInUser:S,location:P,productInformation:m,isEarlyPayEnabled:C,controllerEmails:F,chargeCardsCreditAccountLimit:v}=n;return{onSetupButtonClick:l=>{if(S!=null&&J.trackCardsPromoPageClicked("enable cards"),s)switch(J.trackCardsEnableCardsClick(F,m,"Cards Promo"),l){case"credit":e(qe(a,!0,"charge_cards",C,!1));break;case"debit":e(qe(a,!0,"debit_cards",C,!1));break;case"debit_and_credit":e(v===0?qe(a,!0,"debit_cards",C,!0):qe(a,!0,"charge_cards__debit_cards",C,!1))}else switch(J.trackCardsSetupCardsClick(F,m,"Cards Promo"),l){case"credit":e(qe(a,!1,"charge_cards",C,!1));break;case"debit":e(qe(a,!1,"debit_cards",C,!1));break;case"debit_and_credit":e(v===0?qe(a,!1,"debit_cards",C,!0):qe(a,!1,"charge_cards__debit_cards",C,!1))}},onBackClick:()=>{const l=we(P.state?.pathnameStackToGoBack);let M=l.poppedPathname;M==null&&(M=b||g?"..":"../.."),t(M,{state:{pathnameStackToGoBack:l.newStack}})},onLetsGoClick:()=>{t("./onboard")},onSetupChargeCardSuccess:()=>{s?(e(Xa()),t("../",{relative:"path"})):t("../setup",{relative:"path"})},onExpressInterestClick:()=>{e(zc(a))}}})(_o),zi=()=>{const e=le(),{tenantEmailDomain:n}=Ve(),[t]=Dn(),a=t.get("cardPromoType"),s=me(),{useDynamicConfig:b,useFeatureGate:g}=ue(),[S,P]=r.useState(!1),{isFeatureEnabled:m}=g(Z.isDebitCardFeatureEnabled),{isFeatureEnabled:C}=g(Z.isEarlyPayFeatureEnabled),{isFeatureEnabled:F}=g(Z.isChargeCardFeatureEnabled),{configValue:v}=b(Ze.zeniCardsConfig),l=i(ae=>ge(ae)),M=i(ae=>da(ae,l.companyId)),B=la(M.controllers),R=v.charge_card_cashback_rate_per_transaction!=null?v.charge_card_cashback_rate_per_transaction:.0175,p=he(),h=te.getSignedInUserTenant(n)?.companyId??l.companyId,T=i(ae=>wa(ae,h)),u=T.primaryFundingAccount,w=l.companyBillPayInfo?.info,E=xe(l),U=Be(l),y=Re(m,l),k=l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,x=Oe({isDebitCardFeatureEnabled:m,isBankingOnlyTenant:y}),d=Ue({isCardsOnlyTenant:E,isChargeCardFeatureEnabled:F,isBookKeepingTenant:U,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:k}),f=Er({isCardsOnlyTenant:E,isChargeCardFeatureEnabled:F,isBookKeepingTenant:U}),j=x&&d===!1,H=w?.businessVerificationStatus?.code==="verified"&&(j||u?.accType==="depositAccount"||Gc(u?.providerVerificationStatus?.code??"")),O=te.getSignedInUser(),L=!!l.companyZeniAccountInfo?.info?.isZeniAccountEnabled,z=!!l.companyChargeCardInfo?.info?.isChargeCardTOSAccepted,$=!!l.company?.companyChargeCardInfo?.isChargeCardEnabled,_=!!l.company?.companyDebitCardInfo?.isDebitCardEnabled,D=!!l.companyChargeCardInfo?.info?.isChargeCardEnabled,G=!!l.companyDebitCardInfo?.info?.isDebitCardEnabled,Q=!!l.companyDebitCardInfo?.info?.isDebitCardTOSAccepted,I=ae=>{P(ae)},N=i(ae=>ae.chargeCardSetupViewState.fetchState);if(O==null)throw Error("Can't access Charge Card promo page without signing in...");const W=Le(),X=Fe(W?.loggedInUserRoleMap),o=xt(W?.loggedInUserRoleMap),[A,Y]=r.useState(!1),[ne,q]=r.useState(!1),[ke,ve]=r.useState(!1);r.useEffect(()=>{A===!1&&p.state?.message==="activation"&&Y(!0)},[p.state]),r.useEffect(()=>{ne||N!=="Not-Started"||h==null||(q(!0),s(Pa(h,!0)))},[ne,N,h,s]);const fe=l.companyChargeCardInfo?.info!=null&&Ia({cardInfo:l.companyChargeCardInfo.info,isProductVisible:f&&$,isTOSAccepted:z,isSetupEnabled:D,isUserHasCardsAdminLevelAccess:X,isUserHasCardsAccess:o}),se=l.companyDebitCardInfo?.info!=null&&Ia({cardInfo:l.companyDebitCardInfo.info,isProductVisible:x&&_,isTOSAccepted:Q,isSetupEnabled:G,isUserHasCardsAdminLevelAccess:X,isUserHasCardsAccess:o}),Ee=x&&se&&f&&k>=0&&fe?"debit_and_credit":x&&se?"debit":"credit",re=xo(a,Ee),Ce=T?.chargeCardTermsDetails?.fetchStatus?.fetchState,Ae=r.useRef(null);r.useEffect(()=>{Ce==="In-Progress"?Ae.current=re:Ce!=="Error"&&Ce!=="Not-Started"||(Ae.current=null)},[Ce,re]);const ee=Ce!=="In-Progress"&&Ce!=="Completed"||Ae.current==null?re:Ae.current;r.useEffect(()=>{re==="credit"&&(D||f===!1&&G)||re==="debit"&&G||re==="debit_and_credit"&&G&&D?e("../"):(re==="debit_and_credit"&&z===!0&&Q===!0||re==="credit"&&(z===!0||f===!1&&Q===!0)||re==="debit"&&Q===!0)&&X===!0&&e("../setup")},[H,D,G,re,z,Q]),r.useEffect(()=>{ke||(s($c("cardAdmin")),ve(!0))},[ke]);const Te=i(ae=>nr(ae.userState,ae.userRoleState,ae.userListViewState,"cardAdmin")),De=Xe(f,x,G,D);return(ae=>{switch(ae){case"credit":return $;case"debit":return _;case"debit_and_credit":return $&&_;default:return!1}})(ee)?(fe||se)&&N==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ut,{analytics:J,onLoad:()=>{if(J.trackPageLoaded(yr.Event.cardsPromoPage),!!f&&!D||!!x&&!G||!!f&&!!x&&!G&&!D){const ae=Ki({isDebitCardSetupEnabled:G,isChargeCardSetupEnabled:D,isCreditCardProductVisibleForExpressInterest:f,isDebitCardProductVisible:x});J.trackCardsPromoView(B,De,"Page",ae,"Promo Page")}}}),c.jsx(nt,{showConfetti:A}),c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:I}),c.jsx($i,{signedInUser:O,location:p,showEnableCardButton:H,isCompanyBusinessVerificationAndPaymentSetUpDone:H,isChargeCardSetupEnabled:D,isDebitCardSetupEnabled:G,companyLegalName:l.companyName,adminList:Te.users,isCheckingEnabled:L,navigate:e,companyId:h,cardPromoType:ee,controllerEmails:B,productInformation:De,isCreditCardProductVisible:d,isDebitCardFeatureEnabled:m,isEarlyPayEnabled:C,cashbackRate:R,chargeCardsCreditAccountLimit:k,onClickMenuIcon:()=>{I(!0)}})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:I}),c.jsx(Do,{})]}):c.jsx(oa,{to:"../",replace:!0})},Ki=({isDebitCardSetupEnabled:e,isChargeCardSetupEnabled:n,isCreditCardProductVisibleForExpressInterest:t,isDebitCardProductVisible:a})=>t&&a&&!e&&!n?"Credit & Debit Card":t&&!n?"Credit Card":a&&!e?"Debit Card":"";function Sd(){const e=he(),n=i(W=>ge(W)),{useFeatureGate:t}=ue(),{isFeatureEnabled:a}=t(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:s}=t(Z.isDebitCardFeatureEnabled),{isFeatureEnabled:b}=t(Z.isEarlyPayFeatureEnabled),{isFeatureEnabled:g}=t(Z.isChargeCardPaymentHistoryFeatureEnabled),{isFeatureEnabled:S}=t(Z.isCardPolicyEnabled),P=Re(s,n),m=Oe({isDebitCardFeatureEnabled:s,isBankingOnlyTenant:P}),C=Po(n,a,s),F=!!n.company?.companyChargeCardInfo.isChargeCardTOSAccepted,v=!!n.company?.companyDebitCardInfo.isDebitCardTOSAccepted,l=!!n.company?.companyChargeCardInfo?.isChargeCardEnabled,M=!!n.company?.companyDebitCardInfo?.isDebitCardEnabled,B=!!n.companyChargeCardInfo?.info?.isChargeCardEnabled,R=!!n.companyDebitCardInfo?.info?.isDebitCardEnabled,p=Le(),h=Fe(p?.loggedInUserRoleMap),T=xt(p?.loggedInUserRoleMap),{isFeatureEnabled:u}=t(Z.isCashbackFeatureEnabled),w=n.userRole.includes("charge_card_user"),E=!w,U=!w&&B,y=n?.userRole!=null&&Kc(n?.userRole),k=(n?.company==null||n.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!y)&&Zc(p?.loggedInUserRoleMap),x=Wc(p?.loggedInUserRoleMap),d=(n?.company==null||n.company.featuresActivationInfo?.isReimbursementFeatureEnabled&&!y)&&Yc(p?.loggedInUserRoleMap),{isFeatureEnabled:f}=t(Z.isDepositAccountsFeatureEnabled),j=f&&!y&&$n(p?.loggedInUserRoleMap),H=B&&l&&!y,O=R&&M&&!y,L=C&&!y&&Fe(p?.loggedInUserRoleMap),z=qc(p?.loggedInUserRoleMap),$=xe(n),_=Be(n),D=n.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,G=Ue({isCardsOnlyTenant:$,isChargeCardFeatureEnabled:a,isBookKeepingTenant:_,isDebitCardProductVisible:m,chargeCardsCreditAccountLimit:D}),Q=n.companyChargeCardInfo?.info!=null&&Ia({cardInfo:n.companyChargeCardInfo.info,isProductVisible:G&&l,isTOSAccepted:F,isSetupEnabled:B,isUserHasCardsAdminLevelAccess:h,isUserHasCardsAccess:T}),I=n.companyDebitCardInfo?.info!=null&&Ia({cardInfo:n.companyDebitCardInfo.info,isProductVisible:m&&M,isTOSAccepted:v,isSetupEnabled:R,isUserHasCardsAdminLevelAccess:h,isUserHasCardsAccess:T}),N=Q||I;return c.jsxs(ss,{children:[h?c.jsx(ce,{path:"setup",element:c.jsx(Sn,{isBillPayAdminLevelAccess:k,isReimbursementAdminLevelAccess:d,isZeniAccountAdminLevelAccess:j,isChargeCardAdminLevelAccess:L,isUserHasOnlyCardAccess:z,isUserHasOnlyBillPayAccess:x,productType:"charge_cards",type:"setup"})}):null,h?c.jsx(ce,{path:"verification",element:c.jsx(Sn,{isBillPayAdminLevelAccess:k,isUserHasOnlyBillPayAccess:x,isReimbursementAdminLevelAccess:d,isZeniAccountAdminLevelAccess:j,isChargeCardAdminLevelAccess:L,isUserHasOnlyCardAccess:z,productType:"charge_cards",type:"verification"})}):null,h&&S?c.jsxs(c.Fragment,{children:[c.jsx(ce,{path:"policy",element:c.jsx(Ko,{})}),c.jsx(ce,{path:"policy/new",element:c.jsx(Uo,{})}),c.jsx(ce,{path:"policy/:templateId/edit",element:c.jsx(Vo,{})})]}):null,c.jsx(ce,{path:"promo",element:c.jsx(zi,{})}),H||O?c.jsxs(c.Fragment,{children:[c.jsx(ce,{path:"/",element:c.jsx(In,{isPaymentDrawerOpen:!1})}),L&&b?c.jsx(ce,{path:"payment",element:c.jsx(In,{isPaymentDrawerOpen:!0})}):null,c.jsx(ce,{path:"activate",element:c.jsx(Gi,{})}),c.jsx(ce,{path:"onboard",element:c.jsx(Pi,{})}),h?c.jsx(ce,{path:"new",element:c.jsx(Mi,{})}):null,u&&E?c.jsx(ce,{path:"cashback",element:c.jsx(Qo,{})}):null,U?c.jsx(ce,{path:"statements",element:c.jsx(Ai,{})}):null,L&&g&&B?c.jsx(ce,{path:"payment-history",element:c.jsx(Ei,{})}):null,c.jsx(ce,{path:":cardId/activate",element:c.jsx(ei,{})}),c.jsx(ce,{path:":cardId/setPin",element:c.jsx(Fi,{})}),c.jsx(ce,{path:":cardId/addToWallet",element:c.jsx(Zo,{})}),c.jsx(ce,{path:":cardId/*",element:c.jsx(li,{})}),c.jsx(ce,{path:"*",element:c.jsx(ct,{})})]}):(F||v)&&h?c.jsx(ce,{path:"*",element:c.jsx(oa,{to:"../setup"})}):N?c.jsx(ce,{path:"*",element:c.jsx(oa,{to:"../promo",state:e.state})}):c.jsx(ce,{path:"*",element:null})]})}export{Sd as default};
71
+ `,Hi=Pe(function(e,n){const{myPendingActivationChargeCardListState:t}=n;return{myPendingActivationChargeCardListView:t,uiState:t.uiState,signedInUser:n.signedInUser}},function(e,n){const{navigate:t,currentTenant:a,location:s,signedInUser:b,myPendingActivationChargeCardListState:g}=n,{tenantEmailDomain:S}=a,{cards:P}=g;return{onChargeCardRowClick:m=>{const C=Ar(P,m),F=_e(S,m,b,C),v=ye(s.state?.pathnameStackToGoBack,s.pathname);t(F,{state:{pathnameStackToGoBack:v}})},onColumnSortConfigChanged:(m,C)=>{e(It({uiState:{sortKey:m,sortOrder:C}}))},onReloadCards:()=>{e(Ne())},onBackClick:()=>{const m=a.userRole.includes("charge_card_user");e(It({uiState:{sortKey:m?"cardName":"owner",sortOrder:"ascending"}})),t("../")}}})(Ao);function Gi(){const e=le(),n=me(),t=he(),a=Ot(),[s,b]=r.useState(!1),g=i(R=>Hc(R)),S=i(R=>ge(R)),P=i(R=>da(R,S.companyId)),m=la(P.controllers),{useFeatureGate:C}=ue(),{isFeatureEnabled:F}=C(W.isChargeCardFeatureEnabled),{isFeatureEnabled:v}=C(W.isDebitCardFeatureEnabled),l=Le(v,S),M=Oe({isDebitCardFeatureEnabled:v,isBankingOnlyTenant:l}),B=!!S.companyDebitCardInfo?.info?.isDebitCardEnabled,L=!!S.companyChargeCardInfo?.info?.isChargeCardEnabled,p=Re(),h=xe(S),T=Be(S),u=S.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,w=Ue({isCardsOnlyTenant:h,isChargeCardFeatureEnabled:F,isBookKeepingTenant:T,isDebitCardProductVisible:M,chargeCardsCreditAccountLimit:u}),E=Fe(p?.loggedInUserRoleMap),U=i(R=>ma(R)),{creditAccount:y,creditAccountRepayment:k}=i(R=>ua(R)),x=i(R=>sr(R)).cards.filter(R=>R.type.code.includes("debit")).map(R=>R.connectedAccountId),d=[...new Set(x)],f=i(R=>tt(R,d));r.useEffect(()=>{s||g.fetchState==="Completed"||g.fetchState==="In-Progress"||(b(!0),n(Ne()),n(Qa()))},[s,n,g.fetchState]),r.useEffect(()=>{if(g.fetchState==="Completed"&&g.cards.length===1&&j!=null){const R=_e(S.tenantEmailDomain,g.cards[0].id,j,g.cards[0]);e(R,{state:{message:t.state?.message}})}},[g.fetchState,g.cards]);const j=te.getSignedInUser();r.useEffect(()=>{y.fetchState!=="Completed"&&y.fetchState!=="In-Progress"&&w&&L&&E&&n(Qe()),k.fetchState!=="Completed"&&k.fetchState!=="In-Progress"&&E&&n(Tt()),f.fetchState!=="Completed"&&f.fetchState!=="In-Progress"&&M&&B&&E&&n(cr())},[y.fetchState,k.fetchState,n,f.fetchState,M,B,E,w,L]);const H=ea(S);if(Vt({events:ha(H,Gr),onEvent:(R,z)=>{if(!Ni.has(R))return;const $=Wt(z);if(R===pa){const _=de($?.card_id);if(_!=null){const D=Kt($,_);if(D!=null)return void n(Ft(D))}}n(Ne(!0))},onSubscribed:()=>{n(Ne(!0))}}),j==null)throw Error("Can't access address page without signing in...");const O=g.cards!=null&&g.cards.length>0;if(g.fetchState==="Completed"||O){const R=Xe(w,M,B,L);return c.jsx(Vi,{children:c.jsx(Hi,{navigate:e,currentTenant:S,signedInUser:j,productInformation:R,myPendingActivationChargeCardListState:g,isChargeCardFeatureEnabled:w,isDebitCardFeatureEnabled:M,isDebitCardSetupEnabled:B,isChargeCardSetupEnabled:L,chargeCardCashbackDetailState:U,creditAccount:y,creditAccountRepayment:k,depositAccountListWithDebitCardIssued:f,controllerEmails:m,location:t})})}return c.jsx(va,{fetchState:"In-Progress",style:{backgroundColor:a.colors.grey5}})}const $i=Pe(function(e,n){const{companyId:t,companyLegalName:a}=n;return{chargeCardSetupView:wa(e,t),admins:n.adminList,companyLegalName:a,meetingUrl:"https://meetings.hubspot.com/niharn/demo-zeni-charge-cards?embed=true"}},function(e,n){const{navigate:t,companyId:a,isCompanyBusinessVerificationAndPaymentSetUpDone:s,isDebitCardSetupEnabled:b,isChargeCardSetupEnabled:g,signedInUser:S,location:P,productInformation:m,isEarlyPayEnabled:C,controllerEmails:F,chargeCardsCreditAccountLimit:v}=n;return{onSetupButtonClick:l=>{if(S!=null&&J.trackCardsPromoPageClicked("enable cards"),s)switch(J.trackCardsEnableCardsClick(F,m,"Cards Promo"),l){case"credit":e(qe(a,!0,"charge_cards",C,!1));break;case"debit":e(qe(a,!0,"debit_cards",C,!1));break;case"debit_and_credit":e(v===0?qe(a,!0,"debit_cards",C,!0):qe(a,!0,"charge_cards__debit_cards",C,!1))}else switch(J.trackCardsSetupCardsClick(F,m,"Cards Promo"),l){case"credit":e(qe(a,!1,"charge_cards",C,!1));break;case"debit":e(qe(a,!1,"debit_cards",C,!1));break;case"debit_and_credit":e(v===0?qe(a,!1,"debit_cards",C,!0):qe(a,!1,"charge_cards__debit_cards",C,!1))}},onBackClick:()=>{const l=we(P.state?.pathnameStackToGoBack);let M=l.poppedPathname;M==null&&(M=b||g?"..":"../.."),t(M,{state:{pathnameStackToGoBack:l.newStack}})},onLetsGoClick:()=>{t("./onboard")},onSetupChargeCardSuccess:()=>{s?(e(Xa()),t("../",{relative:"path"})):t("../setup",{relative:"path"})},onExpressInterestClick:()=>{e(zc(a))}}})(_o),zi=()=>{const e=le(),{tenantEmailDomain:n}=Ve(),[t]=Dn(),a=t.get("cardPromoType"),s=me(),{useDynamicConfig:b,useFeatureGate:g}=ue(),[S,P]=r.useState(!1),{isFeatureEnabled:m}=g(W.isDebitCardFeatureEnabled),{isFeatureEnabled:C}=g(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:F}=g(W.isChargeCardFeatureEnabled),{configValue:v}=b(We.zeniCardsConfig),l=i(ae=>ge(ae)),M=i(ae=>da(ae,l.companyId)),B=la(M.controllers),L=v.charge_card_cashback_rate_per_transaction!=null?v.charge_card_cashback_rate_per_transaction:.0175,p=he(),h=te.getSignedInUserTenant(n)?.companyId??l.companyId,T=i(ae=>wa(ae,h)),u=T.primaryFundingAccount,w=l.companyBillPayInfo?.info,E=xe(l),U=Be(l),y=Le(m,l),k=l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,x=Oe({isDebitCardFeatureEnabled:m,isBankingOnlyTenant:y}),d=Ue({isCardsOnlyTenant:E,isChargeCardFeatureEnabled:F,isBookKeepingTenant:U,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:k}),f=Er({isCardsOnlyTenant:E,isChargeCardFeatureEnabled:F,isBookKeepingTenant:U}),j=x&&d===!1,H=w?.businessVerificationStatus?.code==="verified"&&(j||u?.accType==="depositAccount"||Gc(u?.providerVerificationStatus?.code??"")),O=te.getSignedInUser(),R=!!l.companyZeniAccountInfo?.info?.isZeniAccountEnabled,z=!!l.companyChargeCardInfo?.info?.isChargeCardTOSAccepted,$=!!l.company?.companyChargeCardInfo?.isChargeCardEnabled,_=!!l.company?.companyDebitCardInfo?.isDebitCardEnabled,D=!!l.companyChargeCardInfo?.info?.isChargeCardEnabled,G=!!l.companyDebitCardInfo?.info?.isDebitCardEnabled,Q=!!l.companyDebitCardInfo?.info?.isDebitCardTOSAccepted,I=ae=>{P(ae)},N=i(ae=>ae.chargeCardSetupViewState.fetchState);if(O==null)throw Error("Can't access Charge Card promo page without signing in...");const K=Re(),X=Fe(K?.loggedInUserRoleMap),o=xt(K?.loggedInUserRoleMap),[A,Z]=r.useState(!1),[ne,q]=r.useState(!1),[ke,ve]=r.useState(!1);r.useEffect(()=>{A===!1&&p.state?.message==="activation"&&Z(!0)},[p.state]),r.useEffect(()=>{ne||N!=="Not-Started"||h==null||(q(!0),s(Pa(h,!0)))},[ne,N,h,s]);const fe=l.companyChargeCardInfo?.info!=null&&Ia({cardInfo:l.companyChargeCardInfo.info,isProductVisible:f&&$,isTOSAccepted:z,isSetupEnabled:D,isUserHasCardsAdminLevelAccess:X,isUserHasCardsAccess:o}),se=l.companyDebitCardInfo?.info!=null&&Ia({cardInfo:l.companyDebitCardInfo.info,isProductVisible:x&&_,isTOSAccepted:Q,isSetupEnabled:G,isUserHasCardsAdminLevelAccess:X,isUserHasCardsAccess:o}),Ee=x&&se&&f&&k>=0&&fe?"debit_and_credit":x&&se?"debit":"credit",re=xo(a,Ee),Ce=T?.chargeCardTermsDetails?.fetchStatus?.fetchState,Ae=r.useRef(null);r.useEffect(()=>{Ce==="In-Progress"?Ae.current=re:Ce!=="Error"&&Ce!=="Not-Started"||(Ae.current=null)},[Ce,re]);const ee=Ce!=="In-Progress"&&Ce!=="Completed"||Ae.current==null?re:Ae.current;r.useEffect(()=>{re==="credit"&&(D||f===!1&&G)||re==="debit"&&G||re==="debit_and_credit"&&G&&D?e("../"):(re==="debit_and_credit"&&z===!0&&Q===!0||re==="credit"&&(z===!0||f===!1&&Q===!0)||re==="debit"&&Q===!0)&&X===!0&&e("../setup")},[H,D,G,re,z,Q]),r.useEffect(()=>{ke||(s($c("cardAdmin")),ve(!0))},[ke]);const Te=i(ae=>nr(ae.userState,ae.userRoleState,ae.userListViewState,"cardAdmin")),De=Xe(f,x,G,D);return(ae=>{switch(ae){case"credit":return $;case"debit":return _;case"debit_and_credit":return $&&_;default:return!1}})(ee)?(fe||se)&&N==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ut,{analytics:J,onLoad:()=>{if(J.trackPageLoaded(yr.Event.cardsPromoPage),!!f&&!D||!!x&&!G||!!f&&!!x&&!G&&!D){const ae=Yi({isDebitCardSetupEnabled:G,isChargeCardSetupEnabled:D,isCreditCardProductVisibleForExpressInterest:f,isDebitCardProductVisible:x});J.trackCardsPromoView(B,De,"Page",ae,"Promo Page")}}}),c.jsx(nt,{showConfetti:A}),c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:I}),c.jsx($i,{signedInUser:O,location:p,showEnableCardButton:H,isCompanyBusinessVerificationAndPaymentSetUpDone:H,isChargeCardSetupEnabled:D,isDebitCardSetupEnabled:G,companyLegalName:l.companyName,adminList:Te.users,isCheckingEnabled:R,navigate:e,companyId:h,cardPromoType:ee,controllerEmails:B,productInformation:De,isCreditCardProductVisible:d,isDebitCardFeatureEnabled:m,isEarlyPayEnabled:C,cashbackRate:L,chargeCardsCreditAccountLimit:k,onClickMenuIcon:()=>{I(!0)}})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:I}),c.jsx(Do,{})]}):c.jsx(oa,{to:"../",replace:!0})},Yi=({isDebitCardSetupEnabled:e,isChargeCardSetupEnabled:n,isCreditCardProductVisibleForExpressInterest:t,isDebitCardProductVisible:a})=>t&&a&&!e&&!n?"Credit & Debit Card":t&&!n?"Credit Card":a&&!e?"Debit Card":"";function Sd(){const e=he(),n=i(K=>ge(K)),{useFeatureGate:t}=ue(),{isFeatureEnabled:a}=t(W.isChargeCardFeatureEnabled),{isFeatureEnabled:s}=t(W.isDebitCardFeatureEnabled),{isFeatureEnabled:b}=t(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:g}=t(W.isChargeCardPaymentHistoryFeatureEnabled),{isFeatureEnabled:S}=t(W.isCardPolicyEnabled),P=Le(s,n),m=Oe({isDebitCardFeatureEnabled:s,isBankingOnlyTenant:P}),C=Po(n,a,s),F=!!n.company?.companyChargeCardInfo.isChargeCardTOSAccepted,v=!!n.company?.companyDebitCardInfo.isDebitCardTOSAccepted,l=!!n.company?.companyChargeCardInfo?.isChargeCardEnabled,M=!!n.company?.companyDebitCardInfo?.isDebitCardEnabled,B=!!n.companyChargeCardInfo?.info?.isChargeCardEnabled,L=!!n.companyDebitCardInfo?.info?.isDebitCardEnabled,p=Re(),h=Fe(p?.loggedInUserRoleMap),T=xt(p?.loggedInUserRoleMap),{isFeatureEnabled:u}=t(W.isCashbackFeatureEnabled),w=n.userRole.includes("charge_card_user"),E=!w,U=!w&&B,y=n?.userRole!=null&&Yc(n?.userRole),k=(n?.company==null||n.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!y)&&Wc(p?.loggedInUserRoleMap),x=Kc(p?.loggedInUserRoleMap),d=(n?.company==null||n.company.featuresActivationInfo?.isReimbursementFeatureEnabled&&!y)&&Zc(p?.loggedInUserRoleMap),{isFeatureEnabled:f}=t(W.isDepositAccountsFeatureEnabled),j=f&&!y&&$n(p?.loggedInUserRoleMap),H=B&&l&&!y,O=L&&M&&!y,R=C&&!y&&Fe(p?.loggedInUserRoleMap),z=qc(p?.loggedInUserRoleMap),$=xe(n),_=Be(n),D=n.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,G=Ue({isCardsOnlyTenant:$,isChargeCardFeatureEnabled:a,isBookKeepingTenant:_,isDebitCardProductVisible:m,chargeCardsCreditAccountLimit:D}),Q=n.companyChargeCardInfo?.info!=null&&Ia({cardInfo:n.companyChargeCardInfo.info,isProductVisible:G&&l,isTOSAccepted:F,isSetupEnabled:B,isUserHasCardsAdminLevelAccess:h,isUserHasCardsAccess:T}),I=n.companyDebitCardInfo?.info!=null&&Ia({cardInfo:n.companyDebitCardInfo.info,isProductVisible:m&&M,isTOSAccepted:v,isSetupEnabled:L,isUserHasCardsAdminLevelAccess:h,isUserHasCardsAccess:T}),N=Q||I;return c.jsxs(ss,{children:[h?c.jsx(ce,{path:"setup",element:c.jsx(Sn,{isBillPayAdminLevelAccess:k,isReimbursementAdminLevelAccess:d,isZeniAccountAdminLevelAccess:j,isChargeCardAdminLevelAccess:R,isUserHasOnlyCardAccess:z,isUserHasOnlyBillPayAccess:x,productType:"charge_cards",type:"setup"})}):null,h?c.jsx(ce,{path:"verification",element:c.jsx(Sn,{isBillPayAdminLevelAccess:k,isUserHasOnlyBillPayAccess:x,isReimbursementAdminLevelAccess:d,isZeniAccountAdminLevelAccess:j,isChargeCardAdminLevelAccess:R,isUserHasOnlyCardAccess:z,productType:"charge_cards",type:"verification"})}):null,h&&S?c.jsxs(c.Fragment,{children:[c.jsx(ce,{path:"policy",element:c.jsx(Yo,{})}),c.jsx(ce,{path:"policy/new",element:c.jsx(Uo,{})}),c.jsx(ce,{path:"policy/:templateId/edit",element:c.jsx(Vo,{})})]}):null,c.jsx(ce,{path:"promo",element:c.jsx(zi,{})}),H||O?c.jsxs(c.Fragment,{children:[c.jsx(ce,{path:"/",element:c.jsx(In,{isPaymentDrawerOpen:!1})}),R&&b?c.jsx(ce,{path:"payment",element:c.jsx(In,{isPaymentDrawerOpen:!0})}):null,c.jsx(ce,{path:"activate",element:c.jsx(Gi,{})}),c.jsx(ce,{path:"onboard",element:c.jsx(Pi,{})}),h?c.jsx(ce,{path:"new",element:c.jsx(Mi,{})}):null,u&&E?c.jsx(ce,{path:"cashback",element:c.jsx(Qo,{})}):null,U?c.jsx(ce,{path:"statements",element:c.jsx(Ai,{})}):null,R&&g&&B?c.jsx(ce,{path:"payment-history",element:c.jsx(Ei,{})}):null,c.jsx(ce,{path:":cardId/activate",element:c.jsx(ei,{})}),c.jsx(ce,{path:":cardId/setPin",element:c.jsx(Fi,{})}),c.jsx(ce,{path:":cardId/addToWallet",element:c.jsx(Wo,{})}),c.jsx(ce,{path:":cardId/*",element:c.jsx(li,{})}),c.jsx(ce,{path:"*",element:c.jsx(ct,{})})]}):(F||v)&&h?c.jsx(ce,{path:"*",element:c.jsx(oa,{to:"../setup"})}):N?c.jsx(ce,{path:"*",element:c.jsx(oa,{to:"../promo",state:e.state})}):c.jsx(ce,{path:"*",element:null})]})}export{Sd as default};
@@ -0,0 +1 @@
1
+ import{j as m}from"./liveblocks-B2D23g1h.js";import{a as g}from"./sentry-BQ1KU1t3.js";import{h as w,u as T,g as x,i as k,j as b,n as E}from"./core-FEzHdTwu.js";import{z as C,be as P,x as F,d as V,f as j,ag as O,bf as A,au as L,av as U,q as B}from"./index-pXx5w7oJ.js";import{eX as D,gj as M,tC as _,ge as G,c6 as R,Pn as z,bn as q,rC as Y,rq as H,l5 as Q,mG as S,Po as X,bE as Z,cy as N,mQ as $,mT as J}from"./zeni-epic-state-Bxb-N0Vf.js";import"./mui-C754KMjM.js";import{d as K}from"./routePaths-x0riE4xM.js";import{M as W}from"./MobileAppDrawer-C4Qb7oTx.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="7c514e2b-678d-4a7b-8696-9baef1eaebb6",a._sentryDebugIdIdentifier="sentry-dbid-7c514e2b-678d-4a7b-8696-9baef1eaebb6")}catch{}})();const ee=E(function(a){const t=G(a),i=C.getSignedInUser(),l=D(a),c=l.tenantId,p={userId:i?.userId??"",sessionId:i?.zeniSessionId??"",tenantId:c??""},f=R(l?.userRole??[])&&t.localData.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",e=z(a.companyConfigState),n=a.countryListState?.byCountryListCode?.nationalityCountryList?.countries??[];return{isCompanyVerified:t.companyView?.company?.company?.companyBillPayInfo?.companyVerificationStatus?.code==="verified",companyPassportView:t,allIndustries:e.companyIndustries??[],allNationalityCountries:n,isDisabled:f,authParams:p,filesEndPoint:`${L.fileMicroServiceBaseUrl}`,isZeniUser:q(i)}},function(a,t){const{companyId:i,currentTenant:l,navigate:c,location:p}=t,{tenantEmailDomain:f}=l;return{onScheduleClick:e=>{let n=e.href;n.includes("http")||(n="https://".concat(n)),window.open(n,"_blank")},onSaveAll:()=>{a(J())},onAddressClick:e=>{const n=K(f,e),o=B(p.state?.pathnameStackToGoBack,p.pathname);c(n,{state:{pathnameStackToGoBack:o}})},onResetClick:()=>{a($({companyId:i}))},onBackClick:()=>{c("../")},onCompanyDetailsChanged:e=>{const{companyInfo:n,incInfo:o,taxDetails:r,zeniFinanceTeam:d}=e,{website:u}=n,{meetingLink:y}=d,{incDate:s}=o,{taxesFiledYears:h}=r,v={companyInfo:{...n,website:u!=""&&u!=null?N(u):void 0,meetingLink:y!=""&&y!=null?N(y):void 0,industry:n.industry.selectedOption,companyIndustryType:n.companyIndustryType?.selectedOption??void 0,companySubIndustry:n.companySubIndustry?.selectedOption??void 0,businessModel:n.businessModel.selectedOption??"",companySourceOfFunds:n.companySourceOfFunds?.selectedOption,companySourceOfFundsDescription:n.companySourceOfFundsDescription??void 0,countriesOfOperations:n.countriesOfOperations?.selectedOptions?.map(I=>I.length===2?I:U(I))??[],transactionVolume:n.transactionVolume?.selectedOption??void 0,transactionVolumeDescription:n.transactionVolumeDescription??void 0,regulatedStatus:n.regulatedStatus??void 0,regulatedStatusDescription:n.regulatedStatusDescription??void 0,usNexus:n.usNexus??void 0,usNexusTypes:n.usNexusTypes?.selectedOptions??[],purposeOfAccount:n.purposeOfAccount?.selectedOption??void 0,purposeOfAccountDescription:n.purposeOfAccountDescription??void 0},incInfo:{typeOfInc:o.typeOfInc.selectedOption??"",stateOfInc:o.stateOfInc.selectedOption??"",incDate:s!=null?Z(s?.toString()):s,fileId:o.fileIds[0]},taxDetails:{taxIdOrEIN:r.taxIdOrEIN,sicCode:r.sicCode,naicsCode:r.naicsCode,dunsNumber:r.dunsNumber,taxesFiledYears:h.selectedOptions.map(I=>parseInt(I)),fileId:r.fileIds[0]}};a(S({companyDetails:v}))},onPrimaryContactDetailsUpdated:e=>{a(S({primaryContact:{userId:e.userId,email:e.email.trim(),firstName:e.name.firstName,lastName:e.name.lastName}}))},onNewCompanyOfficerAdded:e=>{a(S({officers:[{officerType:e.officerType,email:e.email.trim(),phone:e.phone,firstName:e.name.firstName,lastName:e.name.lastName,userId:void 0}]}))},onNewCompanyOfficerRemoved:e=>{a(X(e))},onCompanyOfficerUpdated:e=>{a(S({officers:[{officerType:e.officerType,email:e.email.trim(),phone:e.phone,firstName:e.name.firstName,lastName:e.name.lastName,userId:e.userId}]}))},updateFilesEntity:e=>{a(Q({files:e}))},onDeleteFile:e=>{a(H(e))},onEditFileName:(e,n)=>{a(Y(e,n.split(".")[0]))}}})(A);function de(){const a=w(),t=T(),i=x(),{tenantEmailDomain:l}=k(),[c,p]=g.useState(!1),[f,e]=g.useState(!1),n=b(s=>s.companyViewState.passportView.fetchState),o=b(s=>s.companyConfigState.fetchState),r=b(s=>D(s)),d=r.companyId??C.getSignedInUserTenant(l)?.companyId;if(C.getSignedInUser()==null)throw Error("Can't access company details page without signing in...");g.useEffect(()=>{c||n!=="Not-Started"||d==null||(p(!0),t(M(d)))},[c,n,d,t]),g.useEffect(()=>{o==="Not-Started"&&t(_())},[o,t]);const u=s=>{e(s)},y=n==="Not-Started"||n==="In-Progress"||o==="Not-Started"||o==="In-Progress";return d!=null&&n==="Error"?m.jsx(P,{onGoHome:()=>a("../",{replace:!0}),onReload:()=>window.location.reload()}):m.jsxs(m.Fragment,{children:[m.jsx(F,{analytics:V,onLoad:s=>s.trackPageLoaded(j.Event.companyPassport,O(i)?"Settings":"Company Passport")}),O(i)?m.jsx(W,{isAppContentDrawerOpen:f,handleDrawerToggle:u}):null,m.jsx(ee,{companyId:d,navigate:a,location:i,isLoading:y,currentTenant:r,isSettings:O(i),onClickMenuIcon:()=>{u(!0)}})]})}export{de as C};