@zeniai/web-app-ui 5.1.60-qa → 5.1.61-qa

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 (107) hide show
  1. package/dist/assets/AddressRoutes-DYu6X0mE.js +1 -0
  2. package/dist/assets/{AddressScreen-FgxQZ6Pn.js → AddressScreen-DmitYkw7.js} +1 -1
  3. package/dist/assets/{AiCfoScreen-CZfRGF0l.js → AiCfoScreen-It5Iqwvu.js} +1 -1
  4. package/dist/assets/{BillPayApprovalRoutes-DxR0TAud.js → BillPayApprovalRoutes-BzW0b3Z-.js} +1 -1
  5. package/dist/assets/{BillPayRoutes-CxBU4_Qt.js → BillPayRoutes-BM10Ap-2.js} +1 -1
  6. package/dist/assets/{BusinessVerificationPageScreen-CsuP5vKP.js → BusinessVerificationPageScreen-tq2Pq8-k.js} +1 -1
  7. package/dist/assets/{CardsAiCfoScreen-BJGdQu7N.js → CardsAiCfoScreen-DWCPoMx2.js} +1 -1
  8. package/dist/assets/{ChargeCardRoutes-DV0rSLTc.js → ChargeCardRoutes-BKpbGgWX.js} +1 -1
  9. package/dist/assets/{CompanyPassportScreen-MkVkCyf-.js → CompanyPassportScreen-CdbgEPbH.js} +1 -1
  10. package/dist/assets/{ConnectionAuthScreen-BZSmdXjw.js → ConnectionAuthScreen-B6ApFE5A.js} +1 -1
  11. package/dist/assets/CustomerOnboardingAuthScreen-BC6kPGo0.js +1 -0
  12. package/dist/assets/CustomerOnboardingRoutes-DC4e3Ogu.js +30 -0
  13. package/dist/assets/{DashboardRoutes-CF_VnugU.js → DashboardRoutes-BpHU2Qkf.js} +1 -1
  14. package/dist/assets/{DefaultTenantHome-DDp58t5d.js → DefaultTenantHome-TmE6YsRf.js} +1 -1
  15. package/dist/assets/{DomesticWireDetailScreen-DJG5dj2b.js → DomesticWireDetailScreen-Bg4mE0II.js} +1 -1
  16. package/dist/assets/{DrawerScreen-Q_os61z4.js → DrawerScreen-Q_Fkogtz.js} +1 -1
  17. package/dist/assets/{EntityDetailRoutes-DWaZ2x0h.js → EntityDetailRoutes-FVCOQ4xF.js} +1 -1
  18. package/dist/assets/{ExpenseAutomationRoutes-BAGScNm2.js → ExpenseAutomationRoutes-CGrxhlUE.js} +1 -1
  19. package/dist/assets/{FeaturePreviewScreen-BsLL5iCn.js → FeaturePreviewScreen-D35UAPet.js} +1 -1
  20. package/dist/assets/{HubSpotOAuthCallbackScreen-OGK79MYJ.js → HubSpotOAuthCallbackScreen-CqLWzeL5.js} +1 -1
  21. package/dist/assets/{MagicLinkRoutes-DPOV0bqy.js → MagicLinkRoutes-Cy9sY1KO.js} +1 -1
  22. package/dist/assets/{MagicLinkSignInScreen-DIaQ6IJE.js → MagicLinkSignInScreen-CTQVJ1D1.js} +1 -1
  23. package/dist/assets/{MobileAppDrawer-DQwHFEP8.js → MobileAppDrawer-DChLZMjE.js} +1 -1
  24. package/dist/assets/NotFoundScreen-DRRoMVDk.js +1 -0
  25. package/dist/assets/{NotificationRoutes-BLkbRobx.js → NotificationRoutes-DC-UVqrq.js} +1 -1
  26. package/dist/assets/{OAuthConsentScreen-B21EksvD.js → OAuthConsentScreen-DXJTz5MU.js} +1 -1
  27. package/dist/assets/{PandLWithForecastRoutes-ClN_7czZ.js → PandLWithForecastRoutes-DtN54cOv.js} +1 -1
  28. package/dist/assets/{PeopleRoutes-BBk6x3GN.js → PeopleRoutes-DM0B31yg.js} +1 -1
  29. package/dist/assets/{PerformanceRoutes-BpOIoQ_l.js → PerformanceRoutes-yT4nKfMt.js} +1 -1
  30. package/dist/assets/{Preview-dDFLUSBQ.js → Preview-DgYvT3D-.js} +1 -1
  31. package/dist/assets/{QBOConnectionScreen-BmcSCHav.js → QBOConnectionScreen-Dxk5EKMF.js} +1 -1
  32. package/dist/assets/{ReferralListScreen-CXbObkR0.js → ReferralListScreen-DoZyTHjO.js} +1 -1
  33. package/dist/assets/{ReimbursementApprovalRoutes-C7YE-LAA.js → ReimbursementApprovalRoutes-AEJXMIeN.js} +1 -1
  34. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-Q0l5mvWj.js → ReimbursementApprovalRuleDetailScreen-Btjx5v4l.js} +1 -1
  35. package/dist/assets/{ReimbursementRoutes-DcDcmnq5.js → ReimbursementRoutes-CLjD-rz3.js} +1 -1
  36. package/dist/assets/{ReportsRoutes-BMAOx8yk.js → ReportsRoutes-DIvKwgKT.js} +1 -1
  37. package/dist/assets/{RewardsRoutes-Cz7znVbs.js → RewardsRoutes-B_SjWYxl.js} +1 -1
  38. package/dist/assets/{ScreenRoutes-Uy0Kxm7R.js → ScreenRoutes-DrzMUCeq.js} +2 -2
  39. package/dist/assets/{SettingsRoutes-DVfn4HMx.js → SettingsRoutes-CwZJeFhH.js} +1 -1
  40. package/dist/assets/{SetupPagesScreen-CVepw64Y.js → SetupPagesScreen-DHP6inkV.js} +1 -1
  41. package/dist/assets/{SignInScreen-CA6G7f6o.js → SignInScreen-B5h77NMY.js} +1 -1
  42. package/dist/assets/{SignOutScreen-B7LAzkpH.js → SignOutScreen-MsTaSP0q.js} +1 -1
  43. package/dist/assets/{TaskListScreen-BYXHdSHM.js → TaskListScreen-BDTDGrzi.js} +1 -1
  44. package/dist/assets/{TaskRoutes-0COd9gMj.js → TaskRoutes-CNamnrYQ.js} +1 -1
  45. package/dist/assets/{TransactionDetailRoutes-B7hwRUTE.js → TransactionDetailRoutes-DWs1Egcj.js} +1 -1
  46. package/dist/assets/{TransactionDetailScreen-BLBk60iy.js → TransactionDetailScreen-BbsGsqi_.js} +1 -1
  47. package/dist/assets/{TransactionListRoutes-CU2IvbfK.js → TransactionListRoutes-Co9duxwX.js} +1 -1
  48. package/dist/assets/{TreasuryRoutes-nOHCoa6D.js → TreasuryRoutes-B_Dv4GZ7.js} +1 -1
  49. package/dist/assets/{VendorsRoutes-Bms7VhV2.js → VendorsRoutes-puD2Dgk7.js} +1 -1
  50. package/dist/assets/{WiseConfirmationScreen-DgOnupdP.js → WiseConfirmationScreen-DAi_rrl_.js} +1 -1
  51. package/dist/assets/{ZeniAccountRoutes-rCwoYBVh.js → ZeniAccountRoutes-CbulRVVe.js} +1 -1
  52. package/dist/assets/{ZeniAccountStatementScreen-DnZ2Bj4h.js → ZeniAccountStatementScreen-DbJvbotJ.js} +1 -1
  53. package/dist/assets/{accountMappingHelper-BBILjeHz.js → accountMappingHelper-BPz1owqi.js} +1 -1
  54. package/dist/assets/{analytics-BlxwN6GD.js → analytics-C-A3qVJh.js} +1 -1
  55. package/dist/assets/{analyticsHelper-CrGhWq9e.js → analyticsHelper-CewoJ3Hu.js} +1 -1
  56. package/dist/assets/{core-Ctjv24YM.js → core-SRRzy8qJ.js} +1 -1
  57. package/dist/assets/{decodeURIComponentSafe-Z8As9uQN.js → decodeURIComponentSafe-Bz-26BXW.js} +1 -1
  58. package/dist/assets/{dnd-DdE4ICzz.js → dnd-CR8sMRK3.js} +1 -1
  59. package/dist/assets/{empty-Cgmg-ODN.js → empty-BjaZv87n.js} +1 -1
  60. package/dist/assets/{empty-BgBFHjf_.js → empty-Btqk4ZK3.js} +1 -1
  61. package/dist/assets/{emptyVideoElement-BxJPDgaA.js → emptyVideoElement-CcSCePHi.js} +1 -1
  62. package/dist/assets/{epic-D1NCPIYf.js → epic-DDYIjE2A.js} +1 -1
  63. package/dist/assets/{getLocaleForTenant-DnliJT-u.js → getLocaleForTenant-DHWNDQcY.js} +1 -1
  64. package/dist/assets/{index-B6LHkFfA.js → index-6PBzTIZ2.js} +1 -1
  65. package/dist/assets/{index-BJyv5Z6x.js → index-BnX1nS7p.js} +85 -85
  66. package/dist/assets/{index-DN_Tvj5e.js → index-CEFX9nem.js} +1 -1
  67. package/dist/assets/{index-DZAo63F3.js → index-CejiZfG4.js} +1 -1
  68. package/dist/assets/{index-Brx9Hk6c.js → index-CxtVVz4g.js} +1 -1
  69. package/dist/assets/{index-DrylXWCT.js → index-DiKyQs4W.js} +1 -1
  70. package/dist/assets/{index-D5yqrruP.js → index-JPErnqsm.js} +2 -2
  71. package/dist/assets/{index-hzMyClsK.js → index-rTYnRLvf.js} +1 -1
  72. package/dist/assets/{lexical-z-P2V9ug.js → lexical-qJrDnJMV.js} +1 -1
  73. package/dist/assets/{liveblocks-UQZFqaDN.js → liveblocks-DS8sOLD1.js} +1 -1
  74. package/dist/assets/{lottie-h9wdJ9gi.js → lottie-Coq2aDEW.js} +1 -1
  75. package/dist/assets/{mui-DU4JyJ-_.js → mui-DQ-jfgFM.js} +1 -1
  76. package/dist/assets/{pathToGoBack-dHZq4iEC.js → pathToGoBack-BmSmVqnZ.js} +1 -1
  77. package/dist/assets/{pdf-BK4Cbxeo.js → pdf-D2Xq7623.js} +4 -4
  78. package/dist/assets/{pdf-lib-BWuwD2_b.js → pdf-lib-fB9Fkl6A.js} +1 -1
  79. package/dist/assets/{plaid-Dtkg2fMC.js → plaid-DWZgMqW3.js} +1 -1
  80. package/dist/assets/{pusher-BRkEMaTd.js → pusher-Xj81uOBz.js} +1 -1
  81. package/dist/assets/{react-DDqHZ_bg.js → react-BlqDZveQ.js} +1 -1
  82. package/dist/assets/{react-BEV1hQDm.js → react-CgdBA-iC.js} +1 -1
  83. package/dist/assets/{react-lX-1Fc9t.js → react-DRyTZBkZ.js} +1 -1
  84. package/dist/assets/{react-BTEnGEot.js → react-DrjKWElm.js} +1 -1
  85. package/dist/assets/{react-Tzoiwmeg.js → react-DyXk5i5q.js} +1 -1
  86. package/dist/assets/{react-B6jUeEM2.js → react-eGjCUI9Z.js} +1 -1
  87. package/dist/assets/{recharts-RL5R0Iqz.js → recharts-CHATJmXy.js} +1 -1
  88. package/dist/assets/{routePaths-C7N5VwuK.js → routePaths-DyfF54Mg.js} +1 -1
  89. package/dist/assets/{sentry-C0E1AQIe.js → sentry-B2Aew07S.js} +1 -1
  90. package/dist/assets/{url-DASTrDxO.js → url-BOKPP8B2.js} +1 -1
  91. package/dist/assets/{url-B8pn9E20.js → url-BfvldWlU.js} +1 -1
  92. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-BguLij7r.js → useAiCfoDashboardSuggestedQuestionsChips-DiiAXpvy.js} +1 -1
  93. package/dist/assets/{useAskAiCfoHostNavButtonProps-DZ2VqCuW.js → useAskAiCfoHostNavButtonProps-RYFll1PC.js} +1 -1
  94. package/dist/assets/{useCashManagementBanner-Cg-NIFnV.js → useCashManagementBanner-DeSZsTvv.js} +1 -1
  95. package/dist/assets/{useChargeCardPusherEvents-CaVuS_Mc.js → useChargeCardPusherEvents-iVaYEDl9.js} +1 -1
  96. package/dist/assets/{useDeviceId-_WmC04ST.js → useDeviceId-obtSvxuy.js} +1 -1
  97. package/dist/assets/{useEmailConnectResultRefresh-BJvktFhn.js → useEmailConnectResultRefresh-DEaO6bJX.js} +1 -1
  98. package/dist/assets/{useInitialThreadRequest-B13VgkiL.js → useInitialThreadRequest-8loDIspA.js} +1 -1
  99. package/dist/assets/{utils-hcCBORos.js → utils-D8kKiFqT.js} +1 -1
  100. package/dist/assets/{withTransactionSidePanel-Dj5HWFje.js → withTransactionSidePanel-CpddR0Hs.js} +1 -1
  101. package/dist/assets/{zeni-epic-state-ym9j-rvL.js → zeni-epic-state-DcKqCCCg.js} +3 -3
  102. package/dist/index.html +1 -1
  103. package/package.json +1 -1
  104. package/dist/assets/AddressRoutes-RF8G7l2e.js +0 -1
  105. package/dist/assets/CustomerOnboardingAuthScreen-xBcb8Thx.js +0 -1
  106. package/dist/assets/CustomerOnboardingRoutes-B7Fnla-Z.js +0 -30
  107. package/dist/assets/NotFoundScreen-DtHa7L00.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as e}from"./liveblocks-DS8sOLD1.js";import{A as d}from"./AddressScreen-DmitYkw7.js";import i from"./NotFoundScreen-DRRoMVDk.js";import"./sentry-B2Aew07S.js";import{o as s,p as r}from"./core-SRRzy8qJ.js";import"./zeni-epic-state-DcKqCCCg.js";import"./recharts-CHATJmXy.js";import"./index-BnX1nS7p.js";import"./mui-DQ-jfgFM.js";import"./analytics-C-A3qVJh.js";import"./plaid-DWZgMqW3.js";import"./dnd-CR8sMRK3.js";import"./stripe-DMRn4zHo.js";import"./lottie-Coq2aDEW.js";import"./lexical-qJrDnJMV.js";import"./pdf-D2Xq7623.js";import"./utils-D8kKiFqT.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new t.Error().stack;o&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[o]="cd0ff2b4-1e27-4329-addf-f475e5a9db34",t._sentryDebugIdIdentifier="sentry-dbid-cd0ff2b4-1e27-4329-addf-f475e5a9db34")}catch{}})();function _(){return e.jsxs(s,{children:[e.jsx(r,{path:"/edit/:addressType/:addressId",element:e.jsx(d,{})}),e.jsx(r,{path:"/new/:addressType",element:e.jsx(d,{})}),e.jsx(r,{path:"*",element:e.jsx(i,{})})]})}export{_ as default};
@@ -1,4 +1,4 @@
1
- import{j as d}from"./liveblocks-UQZFqaDN.js";import{a as h}from"./sentry-C0E1AQIe.js";import{h as T,u as _,g as j,i as M,j as E,n as B}from"./core-Ctjv24YM.js";import{q as $,m as D,z as L,I as K,w as R,x as F,d as C,f as S,j as G,i as b,k as z}from"./index-BJyv5Z6x.js";import{MF as w,hR as U,eV as V,MG as q,c6 as H,MH as N,la as O}from"./zeni-epic-state-ym9j-rvL.js";import{n as J}from"./mui-DU4JyJ-_.js";import Q from"./NotFoundScreen-DtHa7L00.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="58c90981-6ae5-48a9-90f1-67381e34de06",e._sentryDebugIdIdentifier="sentry-dbid-58c90981-6ae5-48a9-90f1-67381e34de06")}catch{}})();const W=J.div`
1
+ import{j as d}from"./liveblocks-DS8sOLD1.js";import{a as h}from"./sentry-B2Aew07S.js";import{h as T,u as _,g as j,i as M,j as E,n as B}from"./core-SRRzy8qJ.js";import{q as $,m as D,z as L,I as K,w as R,x as F,d as C,f as S,j as G,i as b,k as z}from"./index-BnX1nS7p.js";import{MF as w,hR as U,eV as V,MG as q,c6 as H,MH as N,la as O}from"./zeni-epic-state-DcKqCCCg.js";import{n as J}from"./mui-DQ-jfgFM.js";import Q from"./NotFoundScreen-DRRoMVDk.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="58c90981-6ae5-48a9-90f1-67381e34de06",e._sentryDebugIdIdentifier="sentry-dbid-58c90981-6ae5-48a9-90f1-67381e34de06")}catch{}})();const W=J.div`
2
2
  display: flex;
3
3
  height: 100vh;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as c}from"./liveblocks-UQZFqaDN.js";import{a as r}from"./sentry-C0E1AQIe.js";import{u as xe,h as Pe,g as we,j as X,i as ye,n as Ee}from"./core-Ctjv24YM.js";import{Q as Te,da as ve,z as Qe,q as Ae,db as _e,dc as Ue,b9 as Z,dd as se,de as Oe,b8 as ae,k as M,x as B,d as I,df as R,dg as je,dh as Le,a1 as De,f as Fe,a7 as Be,di as Re,dj as Ve,a2 as Me,dk as $e,dl as Ge,dm as qe,s as Ne,b4 as He,dn as We}from"./index-BJyv5Z6x.js";import{gi as ze,eU as oe,eV as Ye,ix as Je,TS as Ke,fm as Xe,iH as Ze,iD as et,eW as V,ft as tt,g3 as st,fY as at,g0 as ee,g4 as ot,g5 as nt,g6 as it,g7 as rt,g8 as lt}from"./zeni-epic-state-ym9j-rvL.js";import{D as dt,n as k,S as ct,P as ut}from"./mui-DU4JyJ-_.js";import{u as mt}from"./useAiCfoDashboardSuggestedQuestionsChips-BguLij7r.js";import{p as pt}from"./pathToGoBack-dHZq4iEC.js";import"./recharts-RL5R0Iqz.js";import"./analytics-BlxwN6GD.js";import"./plaid-Dtkg2fMC.js";import"./dnd-DdE4ICzz.js";import"./stripe-DMRn4zHo.js";import"./lottie-h9wdJ9gi.js";import"./lexical-z-P2V9ug.js";import"./pdf-BK4Cbxeo.js";import"./utils-hcCBORos.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="94027e9a-e05f-4bf1-8ae3-cc48796ddb70",e._sentryDebugIdIdentifier="sentry-dbid-94027e9a-e05f-4bf1-8ae3-cc48796ddb70")}catch{}})();const ne="chat-response-generated",ht=Ee(function(e,o){const t=oe(e),u=o.isSubmitting,s=t.uiState?.currentChatSessionId,h=s!=null?tt(e.aiCfoState,s):[],S=Ve(e,{allUsers:o.allUsers,onCardPolicyVendorSearchTextChange:o.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:o.sessionFromUrl==="explore"&&t.uiState.currentChatSessionId==null,aiCfoView:t,isSubmitting:u,isNewChatSession:o.sessionFromUrl==="new_chat"||o.sessionFromUrl==="explore",isFullView:!0,tableDownloadEndPoint:`${Me}/tableDownload`,emailLinkQuestion:o.emailLinkQuestion,autoSubmitEmailLinkQuestion:o.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:o.onEmailLinkQuestionProcessed,routedInitialQuestionSource:o.routedInitialQuestionSource,routedInitialQuestionSuggestionIndex:o.routedInitialQuestionSuggestionIndex,exploreSuggestedPromptQuestions:o.exploreSuggestedPromptQuestions,exploreSuggestedPromptQuestionsLoading:o.exploreSuggestedPromptQuestionsLoading,isFileUploadEnabled:o.isFileUploadEnabled,isUploadPromoVisible:o.isUploadPromoVisible,onUploadPromoClose:o.onUploadPromoClose,syntheticAnswers:h,resolveSyntheticAnswerCardTile:Ge(e),resolveSyntheticAnswerPolicyTile:$e(e),...S}},function(e,o){const{location:t,currentTenant:u,userId:s,navigate:h,currentChatSessionId:S,allSessionsWithOrderedQuestionAnswers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,setIsAiCfoOpen:b}=o,m=u.tenantEmailDomain;return{onEventReceived:(a,l)=>{if(a===ne&&typeof l.text=="string"&&typeof l.metadata=="object"){const d=l,g=nt(d.type),p=d.metadata.chat_session_id??null,{currentChatSession:n,currentQuestionAnswer:P,currentQuestionAnswerSummary:Q}=ae(x,p);g!=="answer"?I.trackAICFOChatResponseGenerated(g,P?.question.questionText??"",d.text,p,We(Q,n),d.metadata.message_id??null):I.trackAICFOChatAnswerGenerated(d.text,P?.question.questionText??"",(d.follow_up_questions?.length??0)>0,!!d.assumptions,!!d.insights,d.visualization!=null,it(d.visualization?.type??"")??null,p,d.summarized_title,d.metadata.message_id??null),e(rt({chatSessionId:d.metadata.chat_session_id,responseType:g,fetchState:{fetchState:"Completed",error:void 0}})),e(lt({chatSessionId:d.metadata.chat_session_id,answerPayload:d,userId:s}))}},onSubmit:(a,l,d,g)=>{a&&He(e,a,l,S,x,s,g,d)},updateCurrentInput:a=>{e(ee(a))},onStopSubmit:()=>{},onUpdateScrollYOffset:a=>{e(ot(a))},onSelectSampleQuestion:()=>{},onBackClick:()=>{h(-1)},onCloseClick:()=>{const a=M(t.state?.pathnameStackToGoBack),l=a.poppedPathname??pt(1);h(l,{state:{...t.state,pathnameStackToGoBack:a.newStack}}),e(ee(""))},togglePageView:()=>{const a=M(t.state?.pathnameStackToGoBack),l=a.poppedPathname??`/${u.tenantEmailDomain}/dashboard`;h(l,{state:{...se(t.state),pathnameStackToGoBack:a.newStack,message:"open_ai_cfo_drawer"}}),b(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{h(-1)},onNewChatClick:()=>{S!=null&&e(at());const a=Ne(t.state?.pathnameStackToGoBack,t.pathname);h(`/${u.tenantEmailDomain}/ai-cfo/new_chat`,{state:{pathnameStackToGoBack:a.slice(0,-1),referrer:"Sidebar"}})},onToggleCotCollapsed:(a,l)=>{e(st({questionAnswerId:a,isCollapsed:l}))},onMenuClick:o.onMenuClick,...qe(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:v,currentChatSessionId:S,onAfterCardsCreationSubmit:()=>{b(!0),h(`/${m}/cards`,{state:{...t.state}})},onAfterCardPolicySubmit:()=>{b(!0),h(`/${m}/cards/policy`,{state:{...t.state}})}})}})(Be(Re)),Dt=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:o}=Te(),t=xe(),u=Pe(),s=we(),[h,S]=r.useState(!1),{allUsers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,onCardPolicyVendorSearchTextChange:b}=ve();r.useEffect(()=>{t(ze())},[t]);const m=X(i=>oe(i)),a=Qe.getSignedInUser(),{session_id:l}=ye(),d=Ae(),g=De(d),p=X(i=>Ye(i)),n=m.uiState.currentChatSessionId,P=p.tenantEmailDomain,{handleUploadPromoClose:Q,isUploadPromoVisible:ie}=_e({isFileUploadEnabled:e,tenantEmailDomain:P}),A=Ue({currentTenant:p,currentChatSessionId:n,aiCfoView:m}),{isSuggestedQuestionsLoading:re,suggestedPromptQuestions:le}=mt(),w=s.state,y=w?.aiCfoInitialQuestion,$=!!w?.aiCfoShouldSubmit;r.useEffect(()=>{const i=s.state;if(i?.[Z]!==!0)return;S(!0);const f={...i};delete f[Z],u(s,{replace:!0,state:f})},[s.pathname,s.search,s.state,u]);const[de,_]=r.useState(null),[ce,U]=r.useState(!1),[ue,O]=r.useState(void 0),[me,j]=r.useState(void 0),G=r.useRef(!1);r.useEffect(()=>{if(!G.current&&y!=null&&y!==""){const i=s.state;_(y),U($),O(i?.aiCfoInitialSubmissionSource!=null?i.aiCfoInitialSubmissionSource:void 0);const f=i?.aiCfoSuggestionIndex;j(typeof f=="number"?f:void 0),G.current=!0}},[y,$,s.state]);const pe=r.useCallback(()=>{_(null),U(!1),O(void 0),j(void 0),u(s.pathname,{replace:!0,state:se(s.state)})},[s.pathname,s.state,u]),q=r.useMemo(()=>new URLSearchParams(s.search),[s.search]),N=q.get("ref")??w?.aiCfoRef,L=q.get("emailRefId")??w?.aiCfoEmailRefId,H=r.useRef(!1);r.useEffect(()=>{H.current||N!=="month-end-email"||L==null||n!=null||a==null||(t(Je("controller",a.userId,L,"MONTH_END_EMAIL")),H.current=!0)},[N,L,n,t,a]);const E=m.uiState.lastContextMessage;r.useEffect(()=>{E!=null&&E!==""&&n!=null&&(_(E),U(!0),O(void 0),j(void 0),t(Ke()))},[E,n,t]);const he=p.masterTOSInfo,C=he?.isMasterTOSAccepted??!1,{visitedSessions:W}=Oe(n),D=m.fetchState,F=m.uiState.chatSessionsNextPageToken.hasMore||!m.uiState.chatSessionsFirstPageFetched,z=n!=null?m.fetchChatSessionHistoryByChatSessionId?.[n]?.fetchState??"Not-Started":"Not-Started",Y=n==null||(m.uiState.chatHistoryNextPageToken[n]?.hasMore??!0),J=m.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:Se}=ae(J,n),ge=Se.length===0;r.useEffect(()=>{C||g||u("../dashboard",{state:{...s.state,message:"open_ai_cfo_drawer"}})},[C,g,u,s.state]);const fe=r.useCallback(()=>{const i=M(s.state?.pathnameStackToGoBack),f=p.tenantEmailDomain;u(i.poppedPathname??(f!=null?`/${f}/dashboard`:".."),{state:{...s.state,pathnameStackToGoBack:i.newStack}})},[p.tenantEmailDomain,s.state,u]);r.useEffect(()=>{n!=null&&l!==n&&u(`../ai-cfo/${n}`,{state:{...s.state}})},[n,l]),r.useEffect(()=>{l!=null&&n==null&&l!=="new_chat"&&l!=="explore"&&t(Xe({sessionId:l,agentId:"controller"}))},[]);const Ce=r.useMemo(()=>({events:W.map(i=>`private-encrypted-chat-${i}.${ne}`),eventCallback:(i,f,ke)=>ke.onEventReceived(i,f)}),[W]);r.useEffect(()=>{D!=="In-Progress"&&F&&t(Ze())},[D,F,t]),r.useEffect(()=>{n!=null&&z!=="In-Progress"&&Y&&a!=null&&D==="Completed"&&!F&&t(et(n,a.userId))},[z,Y,n,a,t]);const K=i=>i.trackAICFOOnboardingScreenStateChanged("open","first_visit");if(a==null||l==null)throw Error("Can't access AI Controller page without signing in...");const be=n!=null&&m.responseStateByChatSessionId?.[n]?.answer?.fetchState==="In-Progress";if(!C&&g)return c.jsxs(gt,{children:[c.jsx(B,{analytics:I,onLoad:K}),A.drawerElement,c.jsx(ft,{children:c.jsx(te,{children:c.jsx(R,{isTOSAccepted:!1,acceptMasterTOSState:m.masterTOSAcceptanceState,onCloseClick:fe,onCompleteClick:()=>{p.userRoleId!=null&&t(V(p.userRoleId))}})})})]});const Ie=c.jsxs(c.Fragment,{children:[h&&!C?c.jsx(B,{analytics:I,onLoad:K}):null,c.jsx(R,{isTOSAccepted:C,acceptMasterTOSState:m.masterTOSAcceptanceState,showHeader:!1,togglePageView:C?()=>S(!1):void 0,onCloseClick:()=>S(!1),onCompleteClick:()=>{C||p.userRoleId==null||t(V(p.userRoleId)),S(!1)}})]});return c.jsxs(c.Fragment,{children:[c.jsxs(St,{children:[c.jsx(B,{analytics:I,onLoad:i=>i.trackPageLoaded(Fe.Event.aiCFOPage)}),g&&A.drawerElement,c.jsx(ht,{...Ce,currentChatSessionId:n,allSessionsWithOrderedQuestionAnswers:J,allUsers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,openOnboardingPage:()=>S(!0),userId:a.userId,setIsAiCfoOpen:o,navigate:u,sessionFromUrl:l,location:s,isSubmitting:be,isEmptyChatWithSession:ge,currentTenant:p,emailLinkQuestion:de??void 0,autoSubmitEmailLinkQuestion:ce,onEmailLinkQuestionProcessed:pe,routedInitialQuestionSource:ue,routedInitialQuestionSuggestionIndex:me,onCardPolicyVendorSearchTextChange:b,onMenuClick:g?A.open:void 0,isFileUploadEnabled:e,isUploadPromoVisible:ie,onUploadPromoClose:Q,exploreSuggestedPromptQuestions:le,exploreSuggestedPromptQuestionsLoading:re}),h&&g?c.jsx(dt,{anchor:"right",open:h,transitionDuration:250,PaperProps:{component:Ct,style:{width:"100%"}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>S(!1),children:c.jsx(te,{onClick:i=>i.stopPropagation(),children:c.jsx(R,{isTOSAccepted:C,acceptMasterTOSState:m.masterTOSAcceptanceState,onCloseClick:()=>S(!1),onCompleteClick:()=>{C||p.userRoleId==null||t(V(p.userRoleId)),S(!1)}})})}):null]}),h&&!g?c.jsx(je,{open:h,onClose:()=>S(!1),children:c.jsx(Le,{children:Ie})}):null]})},te=k(ct)`
1
+ import{j as c}from"./liveblocks-DS8sOLD1.js";import{a as r}from"./sentry-B2Aew07S.js";import{u as xe,h as Pe,g as we,j as X,i as ye,n as Ee}from"./core-SRRzy8qJ.js";import{Q as Te,da as ve,z as Qe,q as Ae,db as _e,dc as Ue,b9 as Z,dd as se,de as Oe,b8 as ae,k as M,x as B,d as I,df as R,dg as je,dh as Le,a1 as De,f as Fe,a7 as Be,di as Re,dj as Ve,a2 as Me,dk as $e,dl as Ge,dm as qe,s as Ne,b4 as He,dn as We}from"./index-BnX1nS7p.js";import{gi as ze,eU as oe,eV as Ye,ix as Je,TS as Ke,fm as Xe,iH as Ze,iD as et,eW as V,ft as tt,g3 as st,fY as at,g0 as ee,g4 as ot,g5 as nt,g6 as it,g7 as rt,g8 as lt}from"./zeni-epic-state-DcKqCCCg.js";import{D as dt,n as k,S as ct,P as ut}from"./mui-DQ-jfgFM.js";import{u as mt}from"./useAiCfoDashboardSuggestedQuestionsChips-DiiAXpvy.js";import{p as pt}from"./pathToGoBack-BmSmVqnZ.js";import"./recharts-CHATJmXy.js";import"./analytics-C-A3qVJh.js";import"./plaid-DWZgMqW3.js";import"./dnd-CR8sMRK3.js";import"./stripe-DMRn4zHo.js";import"./lottie-Coq2aDEW.js";import"./lexical-qJrDnJMV.js";import"./pdf-D2Xq7623.js";import"./utils-D8kKiFqT.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="94027e9a-e05f-4bf1-8ae3-cc48796ddb70",e._sentryDebugIdIdentifier="sentry-dbid-94027e9a-e05f-4bf1-8ae3-cc48796ddb70")}catch{}})();const ne="chat-response-generated",ht=Ee(function(e,o){const t=oe(e),u=o.isSubmitting,s=t.uiState?.currentChatSessionId,h=s!=null?tt(e.aiCfoState,s):[],S=Ve(e,{allUsers:o.allUsers,onCardPolicyVendorSearchTextChange:o.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:o.sessionFromUrl==="explore"&&t.uiState.currentChatSessionId==null,aiCfoView:t,isSubmitting:u,isNewChatSession:o.sessionFromUrl==="new_chat"||o.sessionFromUrl==="explore",isFullView:!0,tableDownloadEndPoint:`${Me}/tableDownload`,emailLinkQuestion:o.emailLinkQuestion,autoSubmitEmailLinkQuestion:o.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:o.onEmailLinkQuestionProcessed,routedInitialQuestionSource:o.routedInitialQuestionSource,routedInitialQuestionSuggestionIndex:o.routedInitialQuestionSuggestionIndex,exploreSuggestedPromptQuestions:o.exploreSuggestedPromptQuestions,exploreSuggestedPromptQuestionsLoading:o.exploreSuggestedPromptQuestionsLoading,isFileUploadEnabled:o.isFileUploadEnabled,isUploadPromoVisible:o.isUploadPromoVisible,onUploadPromoClose:o.onUploadPromoClose,syntheticAnswers:h,resolveSyntheticAnswerCardTile:Ge(e),resolveSyntheticAnswerPolicyTile:$e(e),...S}},function(e,o){const{location:t,currentTenant:u,userId:s,navigate:h,currentChatSessionId:S,allSessionsWithOrderedQuestionAnswers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,setIsAiCfoOpen:b}=o,m=u.tenantEmailDomain;return{onEventReceived:(a,l)=>{if(a===ne&&typeof l.text=="string"&&typeof l.metadata=="object"){const d=l,g=nt(d.type),p=d.metadata.chat_session_id??null,{currentChatSession:n,currentQuestionAnswer:P,currentQuestionAnswerSummary:Q}=ae(x,p);g!=="answer"?I.trackAICFOChatResponseGenerated(g,P?.question.questionText??"",d.text,p,We(Q,n),d.metadata.message_id??null):I.trackAICFOChatAnswerGenerated(d.text,P?.question.questionText??"",(d.follow_up_questions?.length??0)>0,!!d.assumptions,!!d.insights,d.visualization!=null,it(d.visualization?.type??"")??null,p,d.summarized_title,d.metadata.message_id??null),e(rt({chatSessionId:d.metadata.chat_session_id,responseType:g,fetchState:{fetchState:"Completed",error:void 0}})),e(lt({chatSessionId:d.metadata.chat_session_id,answerPayload:d,userId:s}))}},onSubmit:(a,l,d,g)=>{a&&He(e,a,l,S,x,s,g,d)},updateCurrentInput:a=>{e(ee(a))},onStopSubmit:()=>{},onUpdateScrollYOffset:a=>{e(ot(a))},onSelectSampleQuestion:()=>{},onBackClick:()=>{h(-1)},onCloseClick:()=>{const a=M(t.state?.pathnameStackToGoBack),l=a.poppedPathname??pt(1);h(l,{state:{...t.state,pathnameStackToGoBack:a.newStack}}),e(ee(""))},togglePageView:()=>{const a=M(t.state?.pathnameStackToGoBack),l=a.poppedPathname??`/${u.tenantEmailDomain}/dashboard`;h(l,{state:{...se(t.state),pathnameStackToGoBack:a.newStack,message:"open_ai_cfo_drawer"}}),b(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{h(-1)},onNewChatClick:()=>{S!=null&&e(at());const a=Ne(t.state?.pathnameStackToGoBack,t.pathname);h(`/${u.tenantEmailDomain}/ai-cfo/new_chat`,{state:{pathnameStackToGoBack:a.slice(0,-1),referrer:"Sidebar"}})},onToggleCotCollapsed:(a,l)=>{e(st({questionAnswerId:a,isCollapsed:l}))},onMenuClick:o.onMenuClick,...qe(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:v,currentChatSessionId:S,onAfterCardsCreationSubmit:()=>{b(!0),h(`/${m}/cards`,{state:{...t.state}})},onAfterCardPolicySubmit:()=>{b(!0),h(`/${m}/cards/policy`,{state:{...t.state}})}})}})(Be(Re)),Dt=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:o}=Te(),t=xe(),u=Pe(),s=we(),[h,S]=r.useState(!1),{allUsers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,onCardPolicyVendorSearchTextChange:b}=ve();r.useEffect(()=>{t(ze())},[t]);const m=X(i=>oe(i)),a=Qe.getSignedInUser(),{session_id:l}=ye(),d=Ae(),g=De(d),p=X(i=>Ye(i)),n=m.uiState.currentChatSessionId,P=p.tenantEmailDomain,{handleUploadPromoClose:Q,isUploadPromoVisible:ie}=_e({isFileUploadEnabled:e,tenantEmailDomain:P}),A=Ue({currentTenant:p,currentChatSessionId:n,aiCfoView:m}),{isSuggestedQuestionsLoading:re,suggestedPromptQuestions:le}=mt(),w=s.state,y=w?.aiCfoInitialQuestion,$=!!w?.aiCfoShouldSubmit;r.useEffect(()=>{const i=s.state;if(i?.[Z]!==!0)return;S(!0);const f={...i};delete f[Z],u(s,{replace:!0,state:f})},[s.pathname,s.search,s.state,u]);const[de,_]=r.useState(null),[ce,U]=r.useState(!1),[ue,O]=r.useState(void 0),[me,j]=r.useState(void 0),G=r.useRef(!1);r.useEffect(()=>{if(!G.current&&y!=null&&y!==""){const i=s.state;_(y),U($),O(i?.aiCfoInitialSubmissionSource!=null?i.aiCfoInitialSubmissionSource:void 0);const f=i?.aiCfoSuggestionIndex;j(typeof f=="number"?f:void 0),G.current=!0}},[y,$,s.state]);const pe=r.useCallback(()=>{_(null),U(!1),O(void 0),j(void 0),u(s.pathname,{replace:!0,state:se(s.state)})},[s.pathname,s.state,u]),q=r.useMemo(()=>new URLSearchParams(s.search),[s.search]),N=q.get("ref")??w?.aiCfoRef,L=q.get("emailRefId")??w?.aiCfoEmailRefId,H=r.useRef(!1);r.useEffect(()=>{H.current||N!=="month-end-email"||L==null||n!=null||a==null||(t(Je("controller",a.userId,L,"MONTH_END_EMAIL")),H.current=!0)},[N,L,n,t,a]);const E=m.uiState.lastContextMessage;r.useEffect(()=>{E!=null&&E!==""&&n!=null&&(_(E),U(!0),O(void 0),j(void 0),t(Ke()))},[E,n,t]);const he=p.masterTOSInfo,C=he?.isMasterTOSAccepted??!1,{visitedSessions:W}=Oe(n),D=m.fetchState,F=m.uiState.chatSessionsNextPageToken.hasMore||!m.uiState.chatSessionsFirstPageFetched,z=n!=null?m.fetchChatSessionHistoryByChatSessionId?.[n]?.fetchState??"Not-Started":"Not-Started",Y=n==null||(m.uiState.chatHistoryNextPageToken[n]?.hasMore??!0),J=m.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:Se}=ae(J,n),ge=Se.length===0;r.useEffect(()=>{C||g||u("../dashboard",{state:{...s.state,message:"open_ai_cfo_drawer"}})},[C,g,u,s.state]);const fe=r.useCallback(()=>{const i=M(s.state?.pathnameStackToGoBack),f=p.tenantEmailDomain;u(i.poppedPathname??(f!=null?`/${f}/dashboard`:".."),{state:{...s.state,pathnameStackToGoBack:i.newStack}})},[p.tenantEmailDomain,s.state,u]);r.useEffect(()=>{n!=null&&l!==n&&u(`../ai-cfo/${n}`,{state:{...s.state}})},[n,l]),r.useEffect(()=>{l!=null&&n==null&&l!=="new_chat"&&l!=="explore"&&t(Xe({sessionId:l,agentId:"controller"}))},[]);const Ce=r.useMemo(()=>({events:W.map(i=>`private-encrypted-chat-${i}.${ne}`),eventCallback:(i,f,ke)=>ke.onEventReceived(i,f)}),[W]);r.useEffect(()=>{D!=="In-Progress"&&F&&t(Ze())},[D,F,t]),r.useEffect(()=>{n!=null&&z!=="In-Progress"&&Y&&a!=null&&D==="Completed"&&!F&&t(et(n,a.userId))},[z,Y,n,a,t]);const K=i=>i.trackAICFOOnboardingScreenStateChanged("open","first_visit");if(a==null||l==null)throw Error("Can't access AI Controller page without signing in...");const be=n!=null&&m.responseStateByChatSessionId?.[n]?.answer?.fetchState==="In-Progress";if(!C&&g)return c.jsxs(gt,{children:[c.jsx(B,{analytics:I,onLoad:K}),A.drawerElement,c.jsx(ft,{children:c.jsx(te,{children:c.jsx(R,{isTOSAccepted:!1,acceptMasterTOSState:m.masterTOSAcceptanceState,onCloseClick:fe,onCompleteClick:()=>{p.userRoleId!=null&&t(V(p.userRoleId))}})})})]});const Ie=c.jsxs(c.Fragment,{children:[h&&!C?c.jsx(B,{analytics:I,onLoad:K}):null,c.jsx(R,{isTOSAccepted:C,acceptMasterTOSState:m.masterTOSAcceptanceState,showHeader:!1,togglePageView:C?()=>S(!1):void 0,onCloseClick:()=>S(!1),onCompleteClick:()=>{C||p.userRoleId==null||t(V(p.userRoleId)),S(!1)}})]});return c.jsxs(c.Fragment,{children:[c.jsxs(St,{children:[c.jsx(B,{analytics:I,onLoad:i=>i.trackPageLoaded(Fe.Event.aiCFOPage)}),g&&A.drawerElement,c.jsx(ht,{...Ce,currentChatSessionId:n,allSessionsWithOrderedQuestionAnswers:J,allUsers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,openOnboardingPage:()=>S(!0),userId:a.userId,setIsAiCfoOpen:o,navigate:u,sessionFromUrl:l,location:s,isSubmitting:be,isEmptyChatWithSession:ge,currentTenant:p,emailLinkQuestion:de??void 0,autoSubmitEmailLinkQuestion:ce,onEmailLinkQuestionProcessed:pe,routedInitialQuestionSource:ue,routedInitialQuestionSuggestionIndex:me,onCardPolicyVendorSearchTextChange:b,onMenuClick:g?A.open:void 0,isFileUploadEnabled:e,isUploadPromoVisible:ie,onUploadPromoClose:Q,exploreSuggestedPromptQuestions:le,exploreSuggestedPromptQuestionsLoading:re}),h&&g?c.jsx(dt,{anchor:"right",open:h,transitionDuration:250,PaperProps:{component:Ct,style:{width:"100%"}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>S(!1),children:c.jsx(te,{onClick:i=>i.stopPropagation(),children:c.jsx(R,{isTOSAccepted:C,acceptMasterTOSState:m.masterTOSAcceptanceState,onCloseClick:()=>S(!1),onCompleteClick:()=>{C||p.userRoleId==null||t(V(p.userRoleId)),S(!1)}})})}):null]}),h&&!g?c.jsx(je,{open:h,onClose:()=>S(!1),children:c.jsx(Le,{children:Ie})}):null]})},te=k(ct)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;
@@ -1 +1 @@
1
- import{j as c}from"./liveblocks-UQZFqaDN.js";import{a as v}from"./sentry-C0E1AQIe.js";import{h as U,g as B,u as j,j as y,N as z,n as V,i as W,o as te,p as D}from"./core-Ctjv24YM.js";import{eV as k,Q3 as A,PL as h,zm as E,ze as q,zi as R,z7 as K,PN as M,zo as ae,za as Q,zr as G,zn as C}from"./zeni-epic-state-ym9j-rvL.js";import{z as O,a7 as H,bL as oe,af as P,bC as J,bM as le,m as X,w as Y,bN as pe,bO as se}from"./index-BJyv5Z6x.js";import"./mui-DU4JyJ-_.js";import{u as Z,i as ne}from"./ReimbursementApprovalRuleDetailScreen-Q0l5mvWj.js";import re from"./NotFoundScreen-DtHa7L00.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},p=new e.Error().stack;p&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[p]="7addaf2c-9c06-4c46-9fe7-db2b6dd87e16",e._sentryDebugIdIdentifier="sentry-dbid-7addaf2c-9c06-4c46-9fe7-db2b6dd87e16")}catch{}})();const T="bill-approval-rule-update",ie=V(function(e){return{approvalView:A(e),billPaySetupApproverViewUpdateData:h(e).billPaySetupApproverViewUpdateData}},function(e,p){const{navigate:t,location:o}=p;return{onApprovalRulesEventReceived:a=>{a.endsWith(T)&&e(M(!1))},onBackClick:()=>{P(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(K(a,!1))},onEditRuleClick:a=>{a!=null?(e(R(a)),t(`./${a}/edit`)):(e(R()),t("./new"))}}})(H(oe)),ce=({isLoading:e})=>{const p=U(),t=B(),o=j(),[a,r]=v.useState(!1),[n,u]=v.useState(!1),l=y(s=>s.billPaySetupApproverViewState.fetchState),d=y(s=>k(s)),i=y(s=>A(s)),f=y(s=>h(s).billPaySetupApproverViewUpdateData);if(v.useEffect(()=>{f?.updateStatus.fetchState==="Completed"&&o(E())},[f]),v.useEffect(()=>{a||l!=="Not-Started"||e||(r(!0),o(q(!0,!0,!1)))},[a,l,e,o]),O.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");v.useEffect(()=>{i.allApprovalRules.length===0&&i.fetchState==="Completed"&&(n||(u(!0),o(R())),p("./new"))},[n,i,o]);const g={events:d.companyId!=null?[`private-encrypted-${d.companyId}.${T}`]:[],eventCallback:(s,w,S)=>{s.endsWith(T)&&S.onApprovalRulesEventReceived(s)}};return d?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?c.jsx(z,{to:"../../promo"}):c.jsx(ie,{currentTenant:d,location:t,navigate:p,...g})},_="bill-approval-rule-update",de=V(function(e){const p=A(e),t=h(e).billPaySetupApproverViewUpdateData,o={};for(const r of Object.values(e.vendorState.vendorByID))r?.id!=null&&(o[r.id]=r.name);const a={};for(const r of Object.values(e.classState.classesByKey))r?.classId!=null&&(a[r.classId]=r.className);return{approvalView:p,billPaySetupApproverViewUpdateData:t,vendorNamesById:o,departmentNamesById:a}},function(e,p){const{navigate:t,location:o}=p;return{onApprovalRulesEventReceived:a=>{a.endsWith(_)&&e(M(!1))},onBackClick:()=>{P(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(K(a,!0))},onEditRuleClick:a=>{a!=null?(e(R(a)),t(`./${a}/edit`)):(e(R()),t("./new"))},onReorderRules:a=>{e(ae(a,!0))}}})(H(le)),ue=()=>{const e=y(o=>k(o)),{isApprovalRulesV3Enabled:p,isLoading:t}=J(e?.tenantId);return p?c.jsx(ve,{isLoading:t}):c.jsx(ce,{isLoading:t})},ve=({isLoading:e})=>{const p=U(),t=B(),o=j(),[a,r]=v.useState(!1),[n,u]=v.useState(!1),l=y(s=>s.billPaySetupApproverViewState.fetchState),d=y(s=>k(s));Z();const i=y(s=>A(s)),f=y(s=>h(s).billPaySetupApproverViewUpdateData);if(v.useEffect(()=>{f?.updateStatus.fetchState==="Completed"&&o(E())},[f]),v.useEffect(()=>{a||l!=="Not-Started"||e||(r(!0),o(q(!0,!0,!0)))},[a,l,e,o]),O.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");v.useEffect(()=>{i.allApprovalRules.length===0&&i.fetchState==="Completed"&&(n||(u(!0),o(R())),p("./new"))},[n,i,o]);const g={events:d.companyId!=null?[`private-encrypted-${d.companyId}.${_}`]:[],eventCallback:(s,w,S)=>{s.endsWith(_)&&S.onApprovalRulesEventReceived(s)}};return d?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?c.jsx(z,{to:"../../promo"}):c.jsx(de,{currentTenant:d,location:t,navigate:p,isLoading:e,...g})},fe=V(function(e,p){const t=h(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=o==="approval_create"&&t.allApprovalRules.length!==0;let r=t.allApprovalRules.length===0;return p.approvalRuleId&&(r=t.allApprovalRules.findIndex(n=>n.approvalRuleId===p.approvalRuleId)===0),{localData:t,hideUpperBoundField:a,isLowerBoundDisabled:r,approvalUpdateActionType:o}},function(e,p){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:r}=p,n=o.billPaySetupApproverViewUpdateData?.type,u=P(p.location);return{onApprovalRuleDataUpdated:l=>{const d=f=>{const g=[];return f.forEach(s=>{const w=s.actors.selectedUsers.map(b=>({type:"user",userId:b.userId,isImplicitActor:!1})),S=s.actors.selectedNonUsers.map(b=>{const I=!!ne(b.value);return{type:I?"attribute":"role",subType:b.value,userId:void 0,idType:void 0,isImplicitActor:!I}}),m=w.concat(S);g.push({action:s.stepType.selectedOption,actors:m,operator:m.length>1?s.stepType.selectedOption==="require_approval"?"or":"and":"is"})}),g},i={amount:{type:"amount",comparator:"range",min:{amount:l.lowerBound,currencyCode:"USD",currencySymbol:"$"},max:{amount:l.upperBound,currencyCode:"USD",currencySymbol:"$"}}};if(n==="approval_create"){const f={criteria:i,steps:d(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(f))}else{const f={approvalRuleId:r,criteria:i,steps:d(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(f))}},onResetClick:()=>{e(E()),n==="approval_update"||u?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),n==="approval_update"||u?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!1))},onSaveRuleSuccess:()=>{t("../")}}})(pe);function ye(){const e=U(),p=j(),t=B(),{approvalRuleId:o}=W(),a=O.getSignedInUser(),r=X(),n=y(i=>h(i)),u=y(i=>A(i)),[l,d]=v.useState(!1);if(v.useEffect(()=>{l||(d(!0),p(Q(!0)))}),v.useEffect(()=>{u.fetchState==="Not-Started"&&e(o!=null?"../../":"../")},[u,o]),a==null)throw Error("Can't access address page without signing in...");return n.approverListFetchStatus.fetchState=="Not-Started"||n.approverListFetchStatus.fetchState==="In-Progress"?c.jsx(Y,{fetchState:n.approverListFetchStatus.fetchState,style:{backgroundColor:r.colors.grey5}}):c.jsx(fe,{navigate:e,approvalUpdateDataView:n,approvalRuleId:o,approverViewData:u,location:t})}const me=V(function(e,p){const t=h(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=[],r={};for(const n of Object.values(e.vendorState.vendorByID))n?.id!=null&&(a.push(n.id),r[n.id]=n.name);return{localData:t,approvalUpdateActionType:o,allVendorIds:a,vendorNamesById:r,editingRuleId:o==="approval_update"?p.approvalRuleId:void 0,allApprovalRulesWithUser:A(e).allApprovalRules}},function(e,p){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:r}=p,n=o.billPaySetupApproverViewUpdateData?.type,u=P(p.location);return{onApprovalRuleDataUpdated:l=>{const d=m=>{const b=[];return m.forEach(I=>{const L=I.actorKind?.selectedOption,N=I.selectedRole?.selectedOption;let x=[];L==="role"&&N!=null?x=[{type:"attribute",subType:N,userId:void 0,idType:void 0,isImplicitActor:!1}]:L==="specific_person"&&(x=(I.persons?.selectedUsers??[]).map(ee=>({type:"user",userId:ee.userId,isImplicitActor:!1})));const F=I.action??"require_approval";b.push({action:F,actors:x,operator:x.length>1?F==="require_approval"?"or":"and":"is"})}),b},i=l.amountCriteria,f=l.vendorCriteria,g=l.departmentCriteria,s={};if(i!=null&&i.comparator.selectedOption!=null){const m=i.comparator.selectedOption;s.amount={type:"amount",comparator:m,min:m==="less_than"?void 0:i.min,max:m==="greater_than"?void 0:i.max}}const w=f?.selection.selectedOptions??[];w.length>0&&(s.vendor={type:"vendor",operator:f?.operator.selectedOption??"is",vendorIds:w});const S=g?.selection.selectedOptions??[];if(S.length>0&&(s.department={type:"department",operator:g?.operator.selectedOption??"is",departmentIds:S}),n==="approval_create"){const m={name:l.name,description:l.description,separationOfDuties:l.separationOfDuties,isFallback:l.isFallback,criteria:s,steps:d(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(m))}else{const m={approvalRuleId:r,name:l.name,description:l.description,separationOfDuties:l.separationOfDuties,isFallback:l.isFallback,criteria:s,steps:d(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(m))}},onResetClick:()=>{e(E()),n==="approval_update"||u?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),n==="approval_update"||u?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!0))},onSaveRuleSuccess:()=>{t("../")},onEditExistingRule:l=>{e(R(l)),t(n==="approval_update"?`../../${l}/edit`:`../${l}/edit`)}}})(se);function $(){const e=y(t=>k(t)),{isApprovalRulesV3Enabled:p}=J(e?.tenantId);return p?c.jsx(ge,{}):c.jsx(ye,{})}function ge(){const e=U(),p=j(),t=B(),{approvalRuleId:o}=W(),a=O.getSignedInUser(),r=X(),n=y(i=>h(i)),u=y(i=>A(i)),[l,d]=v.useState(!1);if(Z(),v.useEffect(()=>{l||(d(!0),p(Q(!0)))}),v.useEffect(()=>{u.fetchState==="Not-Started"&&e(o!=null?"../../":"../")},[u,o]),a==null)throw Error("Can't access address page without signing in...");return n.approverListFetchStatus.fetchState=="Not-Started"||n.approverListFetchStatus.fetchState==="In-Progress"?c.jsx(Y,{fetchState:n.approverListFetchStatus.fetchState,style:{backgroundColor:r.colors.grey5}}):c.jsx(me,{navigate:e,approvalUpdateDataView:n,approvalRuleId:o,approverViewData:u,location:t},o??"new")}function xe(){return c.jsxs(te,{children:[c.jsx(D,{path:"/",element:c.jsx(ue,{})}),c.jsx(D,{path:"/new",element:c.jsx($,{})}),c.jsx(D,{path:"/:approvalRuleId/edit",element:c.jsx($,{})}),c.jsx(D,{path:"*",element:c.jsx(re,{})})]})}export{xe as B};
1
+ import{j as c}from"./liveblocks-DS8sOLD1.js";import{a as v}from"./sentry-B2Aew07S.js";import{h as U,g as B,u as j,j as y,N as z,n as V,i as W,o as te,p as D}from"./core-SRRzy8qJ.js";import{eV as k,Q3 as A,PL as h,zm as E,ze as q,zi as R,z7 as K,PN as M,zo as ae,za as Q,zr as G,zn as C}from"./zeni-epic-state-DcKqCCCg.js";import{z as O,a7 as H,bL as oe,af as P,bC as J,bM as le,m as X,w as Y,bN as pe,bO as se}from"./index-BnX1nS7p.js";import"./mui-DQ-jfgFM.js";import{u as Z,i as ne}from"./ReimbursementApprovalRuleDetailScreen-Btjx5v4l.js";import re from"./NotFoundScreen-DRRoMVDk.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},p=new e.Error().stack;p&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[p]="7addaf2c-9c06-4c46-9fe7-db2b6dd87e16",e._sentryDebugIdIdentifier="sentry-dbid-7addaf2c-9c06-4c46-9fe7-db2b6dd87e16")}catch{}})();const T="bill-approval-rule-update",ie=V(function(e){return{approvalView:A(e),billPaySetupApproverViewUpdateData:h(e).billPaySetupApproverViewUpdateData}},function(e,p){const{navigate:t,location:o}=p;return{onApprovalRulesEventReceived:a=>{a.endsWith(T)&&e(M(!1))},onBackClick:()=>{P(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(K(a,!1))},onEditRuleClick:a=>{a!=null?(e(R(a)),t(`./${a}/edit`)):(e(R()),t("./new"))}}})(H(oe)),ce=({isLoading:e})=>{const p=U(),t=B(),o=j(),[a,r]=v.useState(!1),[n,u]=v.useState(!1),l=y(s=>s.billPaySetupApproverViewState.fetchState),d=y(s=>k(s)),i=y(s=>A(s)),f=y(s=>h(s).billPaySetupApproverViewUpdateData);if(v.useEffect(()=>{f?.updateStatus.fetchState==="Completed"&&o(E())},[f]),v.useEffect(()=>{a||l!=="Not-Started"||e||(r(!0),o(q(!0,!0,!1)))},[a,l,e,o]),O.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");v.useEffect(()=>{i.allApprovalRules.length===0&&i.fetchState==="Completed"&&(n||(u(!0),o(R())),p("./new"))},[n,i,o]);const g={events:d.companyId!=null?[`private-encrypted-${d.companyId}.${T}`]:[],eventCallback:(s,w,S)=>{s.endsWith(T)&&S.onApprovalRulesEventReceived(s)}};return d?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?c.jsx(z,{to:"../../promo"}):c.jsx(ie,{currentTenant:d,location:t,navigate:p,...g})},_="bill-approval-rule-update",de=V(function(e){const p=A(e),t=h(e).billPaySetupApproverViewUpdateData,o={};for(const r of Object.values(e.vendorState.vendorByID))r?.id!=null&&(o[r.id]=r.name);const a={};for(const r of Object.values(e.classState.classesByKey))r?.classId!=null&&(a[r.classId]=r.className);return{approvalView:p,billPaySetupApproverViewUpdateData:t,vendorNamesById:o,departmentNamesById:a}},function(e,p){const{navigate:t,location:o}=p;return{onApprovalRulesEventReceived:a=>{a.endsWith(_)&&e(M(!1))},onBackClick:()=>{P(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(K(a,!0))},onEditRuleClick:a=>{a!=null?(e(R(a)),t(`./${a}/edit`)):(e(R()),t("./new"))},onReorderRules:a=>{e(ae(a,!0))}}})(H(le)),ue=()=>{const e=y(o=>k(o)),{isApprovalRulesV3Enabled:p,isLoading:t}=J(e?.tenantId);return p?c.jsx(ve,{isLoading:t}):c.jsx(ce,{isLoading:t})},ve=({isLoading:e})=>{const p=U(),t=B(),o=j(),[a,r]=v.useState(!1),[n,u]=v.useState(!1),l=y(s=>s.billPaySetupApproverViewState.fetchState),d=y(s=>k(s));Z();const i=y(s=>A(s)),f=y(s=>h(s).billPaySetupApproverViewUpdateData);if(v.useEffect(()=>{f?.updateStatus.fetchState==="Completed"&&o(E())},[f]),v.useEffect(()=>{a||l!=="Not-Started"||e||(r(!0),o(q(!0,!0,!0)))},[a,l,e,o]),O.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");v.useEffect(()=>{i.allApprovalRules.length===0&&i.fetchState==="Completed"&&(n||(u(!0),o(R())),p("./new"))},[n,i,o]);const g={events:d.companyId!=null?[`private-encrypted-${d.companyId}.${_}`]:[],eventCallback:(s,w,S)=>{s.endsWith(_)&&S.onApprovalRulesEventReceived(s)}};return d?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?c.jsx(z,{to:"../../promo"}):c.jsx(de,{currentTenant:d,location:t,navigate:p,isLoading:e,...g})},fe=V(function(e,p){const t=h(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=o==="approval_create"&&t.allApprovalRules.length!==0;let r=t.allApprovalRules.length===0;return p.approvalRuleId&&(r=t.allApprovalRules.findIndex(n=>n.approvalRuleId===p.approvalRuleId)===0),{localData:t,hideUpperBoundField:a,isLowerBoundDisabled:r,approvalUpdateActionType:o}},function(e,p){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:r}=p,n=o.billPaySetupApproverViewUpdateData?.type,u=P(p.location);return{onApprovalRuleDataUpdated:l=>{const d=f=>{const g=[];return f.forEach(s=>{const w=s.actors.selectedUsers.map(b=>({type:"user",userId:b.userId,isImplicitActor:!1})),S=s.actors.selectedNonUsers.map(b=>{const I=!!ne(b.value);return{type:I?"attribute":"role",subType:b.value,userId:void 0,idType:void 0,isImplicitActor:!I}}),m=w.concat(S);g.push({action:s.stepType.selectedOption,actors:m,operator:m.length>1?s.stepType.selectedOption==="require_approval"?"or":"and":"is"})}),g},i={amount:{type:"amount",comparator:"range",min:{amount:l.lowerBound,currencyCode:"USD",currencySymbol:"$"},max:{amount:l.upperBound,currencyCode:"USD",currencySymbol:"$"}}};if(n==="approval_create"){const f={criteria:i,steps:d(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(f))}else{const f={approvalRuleId:r,criteria:i,steps:d(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(f))}},onResetClick:()=>{e(E()),n==="approval_update"||u?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),n==="approval_update"||u?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!1))},onSaveRuleSuccess:()=>{t("../")}}})(pe);function ye(){const e=U(),p=j(),t=B(),{approvalRuleId:o}=W(),a=O.getSignedInUser(),r=X(),n=y(i=>h(i)),u=y(i=>A(i)),[l,d]=v.useState(!1);if(v.useEffect(()=>{l||(d(!0),p(Q(!0)))}),v.useEffect(()=>{u.fetchState==="Not-Started"&&e(o!=null?"../../":"../")},[u,o]),a==null)throw Error("Can't access address page without signing in...");return n.approverListFetchStatus.fetchState=="Not-Started"||n.approverListFetchStatus.fetchState==="In-Progress"?c.jsx(Y,{fetchState:n.approverListFetchStatus.fetchState,style:{backgroundColor:r.colors.grey5}}):c.jsx(fe,{navigate:e,approvalUpdateDataView:n,approvalRuleId:o,approverViewData:u,location:t})}const me=V(function(e,p){const t=h(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=[],r={};for(const n of Object.values(e.vendorState.vendorByID))n?.id!=null&&(a.push(n.id),r[n.id]=n.name);return{localData:t,approvalUpdateActionType:o,allVendorIds:a,vendorNamesById:r,editingRuleId:o==="approval_update"?p.approvalRuleId:void 0,allApprovalRulesWithUser:A(e).allApprovalRules}},function(e,p){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:r}=p,n=o.billPaySetupApproverViewUpdateData?.type,u=P(p.location);return{onApprovalRuleDataUpdated:l=>{const d=m=>{const b=[];return m.forEach(I=>{const L=I.actorKind?.selectedOption,N=I.selectedRole?.selectedOption;let x=[];L==="role"&&N!=null?x=[{type:"attribute",subType:N,userId:void 0,idType:void 0,isImplicitActor:!1}]:L==="specific_person"&&(x=(I.persons?.selectedUsers??[]).map(ee=>({type:"user",userId:ee.userId,isImplicitActor:!1})));const F=I.action??"require_approval";b.push({action:F,actors:x,operator:x.length>1?F==="require_approval"?"or":"and":"is"})}),b},i=l.amountCriteria,f=l.vendorCriteria,g=l.departmentCriteria,s={};if(i!=null&&i.comparator.selectedOption!=null){const m=i.comparator.selectedOption;s.amount={type:"amount",comparator:m,min:m==="less_than"?void 0:i.min,max:m==="greater_than"?void 0:i.max}}const w=f?.selection.selectedOptions??[];w.length>0&&(s.vendor={type:"vendor",operator:f?.operator.selectedOption??"is",vendorIds:w});const S=g?.selection.selectedOptions??[];if(S.length>0&&(s.department={type:"department",operator:g?.operator.selectedOption??"is",departmentIds:S}),n==="approval_create"){const m={name:l.name,description:l.description,separationOfDuties:l.separationOfDuties,isFallback:l.isFallback,criteria:s,steps:d(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(m))}else{const m={approvalRuleId:r,name:l.name,description:l.description,separationOfDuties:l.separationOfDuties,isFallback:l.isFallback,criteria:s,steps:d(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(m))}},onResetClick:()=>{e(E()),n==="approval_update"||u?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),n==="approval_update"||u?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!0))},onSaveRuleSuccess:()=>{t("../")},onEditExistingRule:l=>{e(R(l)),t(n==="approval_update"?`../../${l}/edit`:`../${l}/edit`)}}})(se);function $(){const e=y(t=>k(t)),{isApprovalRulesV3Enabled:p}=J(e?.tenantId);return p?c.jsx(ge,{}):c.jsx(ye,{})}function ge(){const e=U(),p=j(),t=B(),{approvalRuleId:o}=W(),a=O.getSignedInUser(),r=X(),n=y(i=>h(i)),u=y(i=>A(i)),[l,d]=v.useState(!1);if(Z(),v.useEffect(()=>{l||(d(!0),p(Q(!0)))}),v.useEffect(()=>{u.fetchState==="Not-Started"&&e(o!=null?"../../":"../")},[u,o]),a==null)throw Error("Can't access address page without signing in...");return n.approverListFetchStatus.fetchState=="Not-Started"||n.approverListFetchStatus.fetchState==="In-Progress"?c.jsx(Y,{fetchState:n.approverListFetchStatus.fetchState,style:{backgroundColor:r.colors.grey5}}):c.jsx(me,{navigate:e,approvalUpdateDataView:n,approvalRuleId:o,approverViewData:u,location:t},o??"new")}function xe(){return c.jsxs(te,{children:[c.jsx(D,{path:"/",element:c.jsx(ue,{})}),c.jsx(D,{path:"/new",element:c.jsx($,{})}),c.jsx(D,{path:"/:approvalRuleId/edit",element:c.jsx($,{})}),c.jsx(D,{path:"*",element:c.jsx(re,{})})]})}export{xe as B};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-UQZFqaDN.js";import{h as K,u as se,g as J,i as ae,j as v,N as te,n as X,l as na,o as ia,p as S}from"./core-Ctjv24YM.js";import{eV as Z,Pl as _e,bs as It,Ka as oa,bq as wt,bJ as pe,Pm as At,yE as Ct,zT as $e,zb as la,bn as De,Pn as sa,Po as ra,c6 as ca,Pp as da,ku as Bt,Pq as xt,Pr as Et,As as Ge,yT as Be,Ps as ua,ys as tt,Pt as pa,Ey as ma,yw as ba,yC as Dt,Pu as ke,Pv as Me,zU as Ne,Pw as ha,Px as ga,zX as Oe,Py as ya,A8 as Sa,Pz as Pt,zE as at,zJ as fa,PA as ka,PB as ue,PC as jt,PD as Tt,PE as Ft,gm as va,yY as Ue,cA as Rt,PF as Ia,fv as wa,PG as Aa,PH as Ca,fA as Vt,fy as $t,PI as ze,PJ as Ba,PK as xa,N4 as Ze,PL as Ea,N5 as oe,N6 as He,PM as Da,PN as Pa,PO as ja,zL as nt,zI as Ta,PP as Fa,PQ as Ra,PR as Va,zu as $a,PS as Ua,PT as La,PU as _a,co as Ut,cQ as Lt,kF as Ga,bP as Ma,bo as _t,bQ as Gt,xK as Na,PV as Oa,El as za,Er as Za,u8 as Ha,zV as Wa,Az as qa,kS as fe,PW as Qa,PX as Mt,lk as Ka,kM as Nt,l5 as Ot,l4 as it,bE as be,bO as Ja,PY as Xa,PZ as ve,jp as Ya,P_ as ot,P$ as en,jt as tn,jO as an,AN as nn,Q0 as on,ld as ln,AD as sn,Q1 as lt,AH as rn,AM as cn,AJ as dn,AB as un,Q2 as zt,yN as pn,Q3 as mn,Q4 as bn,ge as hn,gd as gn,gc as yn,kV as Sn,lb as st,lm as fn,rz as kn,l2 as vn,AF as In,jz as wn,lr as An,Q5 as Cn,jr as Bn,rq as xn,Q6 as En,zA as Dn,bK as Pn,bt as jn,LU as Tn,cS as Fn,cR as Rn,cz as Vn,cG as $n}from"./zeni-epic-state-ym9j-rvL.js";import{m as me,z as V,I as Ie,Z as We,W as le,U as y,aQ as xe,w as re,o as x,x as Pe,d as D,bh as Un,k as z,a2 as qe,s as E,q as we,bi as rt,bj as ct,bk as Ln,ak as _n,A as Gn,aK as Mn,y as Zt,a as Qe,C as Ke,bl as Nn,au as Ht,bm as On,V as zn,f as Wt,a7 as Zn,bn as Hn,bo as Wn,bp as qn,bq as Qn,br as Kn,bs as Jn,bt as Xn,bu as Yn,bv as ei,$ as ti,bw as ai,bc as ni,bx as ii,by as oi,a9 as li}from"./index-BJyv5Z6x.js";import{n as L,S as si}from"./mui-DU4JyJ-_.js";import{A as dt}from"./AddressScreen-FgxQZ6Pn.js";import{g as ie,a as je,i as qt,V as Je,b as Xe,c as ri,v as ci,d as di,A as he,D as ge}from"./DomesticWireDetailScreen-DJG5dj2b.js";import{a as f}from"./sentry-C0E1AQIe.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-DZ2VqCuW.js";import{u as Qt}from"./useInitialThreadRequest-B13VgkiL.js";import Ee from"./NotFoundScreen-DtHa7L00.js";import{D as ui}from"./DrawerScreen-Q_os61z4.js";import{M as Kt}from"./MobileAppDrawer-DQwHFEP8.js";import{F as Jt}from"./FeaturePreviewScreen-BsLL5iCn.js";import{S as Te}from"./SetupPagesScreen-CVepw64Y.js";import{B as pi}from"./BillPayApprovalRoutes-DxR0TAud.js";import{FallBackRoute as mi}from"./ScreenRoutes-Uy0Kxm7R.js";import"./recharts-RL5R0Iqz.js";import"./analytics-BlxwN6GD.js";import"./plaid-Dtkg2fMC.js";import"./dnd-DdE4ICzz.js";import"./stripe-DMRn4zHo.js";import"./lottie-h9wdJ9gi.js";import"./lexical-z-P2V9ug.js";import"./pdf-BK4Cbxeo.js";import"./utils-hcCBORos.js";import"./analyticsHelper-CrGhWq9e.js";import"./routePaths-C7N5VwuK.js";import"./BusinessVerificationPageScreen-CsuP5vKP.js";import"./ReimbursementApprovalRuleDetailScreen-Q0l5mvWj.js";import"./getLocaleForTenant-DnliJT-u.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a8ea9f1b-2bcd-495d-a0fe-51bf66fd3361",e._sentryDebugIdIdentifier="sentry-dbid-a8ea9f1b-2bcd-495d-a0fe-51bf66fd3361")}catch{}})();const bi=X(function(e,t){const l=_e(e,t.billId),n=V.getSignedInUser(),c=e.tenantState.currentTenantId,r={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:c??""},u=z(t.location.state?.pathnameStackToGoBack);let o=!0;u.poppedPathname?.includes("bills")===!0&&(o=!1);let s=`${l.createdBy?.firstName??"Zeni"} ${l.createdBy?.lastName??""}`;const i=De(n);i||!l.createdBy?.email?.includes("zeni.ai")||(s="Zeni");let d=!1,p=!1;if(l?.billActivities.length>0){const{isApprovalorRejectBtnVisible:g,isMarkAsPaidBtnVisible:b}=sa(l.billActivities,ra(t.currentTenant),n);d=g,p=b}const m=ca(t.currentTenant?.userRole??[]),h=l.transactionDetails!=null&&da(l.transactionDetails,m,n);return{billDetails:l,isAccountingClassesEnabled:Bt(e),createdBy:s,authParams:r,transactionAttachmentEndpoint:`${qe}/transaction_attachment`,signedInUser:n,showBackButton:o,isAdmin:m,isRealTimeApprovalEnabled:t.isRealTimeApprovalEnabled,showApproveRejectBtns:d,showMarkAsPaidButtonToApprover:p,hasZeniAssistAccess:t.hasZeniAssistAccess,analytics:D,showMarkAsPaidButtonToCreator:h,isZeniUser:i}},function(e,t){const{billId:l,currentTenant:n,location:c,navigate:r}=t,{tenantEmailDomain:u}=n;return{redirectToBillsScreen:()=>{const o=ie(u),s=E(c.state?.pathnameStackToGoBack,c.pathname);r(o,{state:{pathnameStackToGoBack:s}})},redirectToEditableBillScreen:()=>{const o=E(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}})},discardBillDetailsFromLocalStore:()=>{e(ke({}))},deleteBill:o=>{D.trackBillPayDeleteBill(l,o),e(Dt(l))},cancelAndDeleteBill:(o,s)=>{s===!0?D.trackBillPayCancelAndDeleteBill(l,o):D.trackBillPayCancelBill(l),e(ba(l,s))},onSaveRealTimeApprovals:o=>{e(ma(l,"bill_pay",o))},updateEditRealTimeApproverClicked:o=>{e(pa({isEdit:o,entityId:l,entityType:"bill_pay"}))},approveOrRejectBill:o=>{o.type==="approved"?e(tt(l,o.type,"")):e(tt(l,o.type,o.description??""))},retryOrRefundBill:o=>{o.type==="retry"?e(Be(l,"retry")):e(Be(l,"refund"))},onAddNewRule:()=>{r("../../bills/approval-rules")},onAttachmentClick:(o,s)=>{const i=je(u,o,s),d=E(c.state?.pathnameStackToGoBack,c.pathname);r(i,{state:{pathnameStackToGoBack:d}})},onBackClick:()=>{const o=z(t.location.state?.pathnameStackToGoBack),s=o.poppedPathname??ie(u);r(s,{state:{pathnameStackToGoBack:o.newStack}})},onRetryPaymentClick:()=>{const o=E(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}}),e(ua({billId:t.billId}))},onRefundPaymentClick:()=>{e(Be(t.billId,"refund"))},saveBillDetails:(o,s,i)=>{o&&e(Et({data:i,billId:l})),e(Ge(o?"paid":"pending_approval",o,s,l))},discardOutsideZeniPaymentData:()=>{e(xt({billId:l}))}}})(Un);function hi(){const e=K(),t=se(),l=J(),{billId:n}=ae(),c=me(),r=V.getSignedInUser(),u=Ie(),o=v(N=>Z(N)),s=v(N=>_e(N,n??"")),i=s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1,d=Qt(o?.companyId,{clearParams:s.fetchState==="Completed"&&!i}),{isAiCfoAccessEnabled:p,onAskAiCfoClick:m}=Ye({mobileExploreReferrer:"Bill Details"});We({isDataReady:s.fetchState==="Completed"});const h=o?.userRole!=null&&It(o?.userRole),g=o?.company==null||o.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!h,[b,k]=f.useState(!1),[P,A]=f.useState(!1),[C,G]=f.useState(!1),{useFeatureGate:j,useDynamicConfig:_}=le(),{isFeatureEnabled:$}=j(y.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:I}=j(y.isBillPayCommentingEnabled),{isFeatureEnabled:H}=j(y.isBillPayDetectInsufficientFundsEnabled),{configValue:M}=_(xe.zeniAssistConfig),B=oa(o),q=wt(o.userRole),W=g&&pe(u?.loggedInUserRoleMap),U=M.user_ids!=null&&r?.userId!=null&&M.user_ids.includes(r?.userId),{isFeatureEnabled:Q}=j(y.isInternationalPaymentShaVsOurFeatureEnabled),{isFeatureEnabled:Y}=j(y.billPaySetupShowInternationalPaymentByWise);if(f.useEffect(()=>{$&&s.transactionDetails?.isDeleted===!0||o.isZeni===!0&&r?.userEmailDomain==="zeni.ai"&&B===!1?G(!1):G(s.billActivities[0]?.isRealTimeApprovalEnabled&&(q||W||s.allApprovers.find(N=>N.user.userId===r?.userId)!=null||s.transactionDetails?.lastUpdatedByUserId===r?.userId))},[s.billActivities[0]?.isRealTimeApprovalEnabled,s.allApprovers,s.transactionDetails?.lastUpdatedByUserId,q,W,o.isZeni,B,r]),f.useEffect(()=>{n!=null&&t(At(n))},[n]),f.useEffect(()=>{b||s.fetchState=="Completed"||s.fetchState=="In-Progress"||(k(!0),t(Ct(n??"",$,U,!1)))},[b,s,n,t]),f.useEffect(()=>{P||s.fetchState!="Completed"||s.transactionDetails?.billPayInfo.stage.code=="paid"||(A(!0),t($e(!1,$,U,Y,n)),s.billActivities[0]?.isRealTimeApprovalEnabled===!0&&t(la()))},[P,s,n,t]),r==null)throw Error("Can't access address page without signing in...");return s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1?a.jsx(te,{to:`./edit${l.search}`}):s.deleteStatus.fetchState==="In-Progress"||s.cancelAndDeleteStatus.fetchState==="In-Progress"||s.cancelStatus.fetchState==="In-Progress"?a.jsx(re,{fetchState:s.deleteStatus.fetchState,style:{boxShadow:`0px 2px ${x.sp1} ${c.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[a.jsx(Pe,{analytics:D,onLoad:N=>(ee=>{n!=null&&ee.trackBillPayBillDetails(n,s.isRecurring)})(N)}),a.jsx(bi,{initialOpenThreadRequest:d??void 0,isShowDeletedBillsEnabled:$,location:l,navigate:e,isBillPayCommentingEnabled:I,isRealTimeApprovalEnabled:C,currentTenant:o,billId:n??"",isInternationalPaymentShaVsOurEnabled:Q,hasZeniAssistAccess:U,isDetectInsufficientFundsEnabled:H,isAiCfoAccessEnabled:p,onAskAiCfoClick:m})]})}const ye=Qe.getLocalizedStrings().spendManagement.billPay.billDetails,gi={containerWidth:new Zt(100,58)},ut=X(function(e,t){const l=V.getSignedInUser(),n=e.tenantState.currentTenantId,c={userId:l?.userId??"",sessionId:l?.zeniSessionId??"",tenantId:n??""},r=t.showActionButtons,u=r&&t.file==null;return{uploadInvoiceEndPoint:`${Ht.communicationAgentMicroServiceBaseUrl}`,authParams:c,billId:t.billId,file:t.file,showAutofill:t.showAutofill,analytics:D,entityId:t.billId,showTitlebarIcon:r,showTitlebar:r&&t?.file!=null,uploadStatus:t.uploadStatus,shouldNotShowAttachment:u,style:{paddingTop:x.sp10,paddingRight:x.sp3,paddingBottom:"15px",paddingLeft:x.sp5,...t.showAutofill?{}:{backgroundColor:t.backgroundColor,paddingBottom:"128px"}}}},function(e,t){const l=V.getSignedInUser();return{onInvoiceUpload:n=>{n!=null&&(t.file!=null||t.billId!=null||t.isInitialEdit?(t.setPayload(n),t.setShowConfirmationPopup(!0)):e(Oe(n,t.isVendorRecommendationEnabled,t.billId)))},updateInvoiceUploadFetchState:n=>{e(Sa({fetchState:{fetchState:n,error:void 0},billId:t.billId}))},onSkipAutofill:n=>{D?.trackBillPaySkipAutofill(),e(Ne(n))},onDeleteClick:()=>{e(ya({billId:t.billId})),D?.trackInvoiceActionClick(t.billStage??"","delete",l?.userEmail??"",null)}}})(Mn);function w({appContent:e}){const t=se(),l=K(),{billId:n}=ae(),c=J(),r=c.pathname,u=r.includes("bill/new")||r.includes("/edit"),o=we(),s=me(),i=V.getSignedInUser(),{useFeatureGate:d,useDynamicConfig:p}=le(),{isFeatureEnabled:m}=d(y.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:h}=d(y.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:g}=d(y.isDepositAccountsFeatureEnabled),{isFeatureEnabled:b}=d(y.billPaySetupShowInternationalPaymentByWise),{configValue:k}=p(xe.zeniAssistConfig),P=k.user_ids!=null&&i?.userId!=null&&k.user_ids.includes(i?.userId),A=v(F=>Z(F)),[C,G]=f.useState(!1),[j,_]=f.useState(!1),[$,I]=f.useState(!1),[H,M]=f.useState(),B=v(F=>Me(F,m,g,n));let q=B.fetchState,W=B.file,U=B.showAutofill;const Q=v(F=>_e(F,n??""));u===!1&&(q=Q.fetchState,W=Q.transactionDetails?.attachments?.[0],U=!1);const Y=B.billPayInfo!=null&&B.billPayInfo.stage.code==="pending_approval"?B.billPayInfo.billStatus.code:B.billStage;f.useEffect(()=>{n==null&&t(Ne(!0))},[n,t]),f.useEffect(()=>{q==="Not-Started"&&(u&&j?_(!1):!u&&C&&G(!1))},[n]),f.useEffect(()=>{C||n==null||u||(G(!0),t(Ct(n,h,P,!1)),j||(_(!0),t($e(!1,h,P,b,n)))),u&&!j&&(_(!0),t($e(!1,h,P,b,n)))},[C,j,u,n,t]);const N={onOkClick:()=>{if(I(!1),!H)return;const F=W!=null?"replace":"upload";D?.trackInvoiceActionClick(Y??"",F,i?.userEmail??"","yes"),t(ga({replaceBillData:!0,billId:n})),t(Oe(H,m,n))},onCancelClick:()=>{if(I(!1),!H)return;const F=W!=null?"replace":"upload";D?.trackInvoiceActionClick(Y??"",F,i?.userEmail??"","no"),t(ha({file:H,billId:n}))}},ee=f.useCallback(()=>{const F=z(c.state?.pathnameStackToGoBack),ce=F.poppedPathname??ie(A.tenantEmailDomain);t(ke({billId:n})),l(ce,{state:{pathnameStackToGoBack:F.newStack}})},[c.state,A.tenantEmailDomain,n,t,l]);if(i==null)throw Error("Can't access address page without signing in...");if(q==="Error"||Q.fetchState==="Error")return a.jsx(Ee,{});if(q!="Completed")return n==null&&o!=="small"?a.jsx(rt,{fallback:ee,children:a.jsxs(Fe,{windowSize:o,children:[a.jsx(mt,{}),a.jsx(Re,{}),a.jsx(ut,{backgroundColor:s.colors.grey4,billId:n,file:W,showAutofill:!0,uploadStatus:B.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:void 0,setShowConfirmationPopup:I,setPayload:M,showActionButtons:!1,isInitialEdit:!!B.isInitialEdit,billStage:Y}),a.jsx(Ve,{windowSize:o,children:a.jsx(ct,{isNewBill:!0})})]})}):a.jsxs(Fe,{windowSize:o,children:[o==="small"||U?null:a.jsx(pt,{children:a.jsx(Xt,{onClick:ee,"data-testid":"nav-bar-back-click"})}),o!=="small"?a.jsx(Re,{}):null,a.jsx(Ln,{}),a.jsx(Ve,{windowSize:o,children:a.jsx(ct,{isNewBill:n==null})})]});{const F=B.billPayInfo!=null&&B.billPayInfo.stage.code==="pending_approval"?B.billPayInfo.billStatus.code:B.billStage;return a.jsx(rt,{fallback:ee,children:a.jsxs(Fe,{windowSize:o,children:[U&&o!=="small"?a.jsx(mt,{}):null,$?a.jsx(_n,{titleComponent:a.jsx(wi,{children:ye.overwriteTitle}),descriptionComponent:a.jsx(Ai,{children:ye.overwriteDescription}),primaryButtonText:ye.buttons.yes,secondaryButtonText:ye.buttons.no,action:N,isEditPopup:!0}):null,o==="small"||U?null:a.jsx(pt,{children:a.jsx(yi,{})}),o!=="small"?a.jsx(Re,{}):null,a.jsx(ut,{backgroundColor:s.colors.grey4,billId:n,file:W,showAutofill:U,uploadStatus:B.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:Si(u,Q,B),setShowConfirmationPopup:I,setPayload:M,showActionButtons:fi(u,B),isInitialEdit:!!B.isInitialEdit,billStage:F}),a.jsx(Ve,{windowSize:o,children:e})]})})}}function yi(){const{triggerBack:e}=Nn();return a.jsx(Xt,{onClick:e,"data-testid":"nav-bar-back-click"})}function Si(e,t,l){let n,c;return e?(n=l.recurringConfig?.currentInstance,c=l.recurringConfig?.totalPaymentCycles):(n=t.transactionDetails?.recurringBillInstance,c=t.recurringBillConfigDetail?.totalPaymentCycles),t?.isRecurring===!0?a.jsxs(ki,{children:[a.jsx(vi,{children:`${ye.recurringBill.recurringCycle}
1
+ import{j as a}from"./liveblocks-DS8sOLD1.js";import{h as K,u as se,g as J,i as ae,j as v,N as te,n as X,l as na,o as ia,p as S}from"./core-SRRzy8qJ.js";import{eV as Z,Pl as _e,bs as It,Ka as oa,bq as wt,bJ as pe,Pm as At,yE as Ct,zT as $e,zb as la,bn as De,Pn as sa,Po as ra,c6 as ca,Pp as da,ku as Bt,Pq as xt,Pr as Et,As as Ge,yT as Be,Ps as ua,ys as tt,Pt as pa,Ey as ma,yw as ba,yC as Dt,Pu as ke,Pv as Me,zU as Ne,Pw as ha,Px as ga,zX as Oe,Py as ya,A8 as Sa,Pz as Pt,zE as at,zJ as fa,PA as ka,PB as ue,PC as jt,PD as Tt,PE as Ft,gm as va,yY as Ue,cA as Rt,PF as Ia,fv as wa,PG as Aa,PH as Ca,fA as Vt,fy as $t,PI as ze,PJ as Ba,PK as xa,N4 as Ze,PL as Ea,N5 as oe,N6 as He,PM as Da,PN as Pa,PO as ja,zL as nt,zI as Ta,PP as Fa,PQ as Ra,PR as Va,zu as $a,PS as Ua,PT as La,PU as _a,co as Ut,cQ as Lt,kF as Ga,bP as Ma,bo as _t,bQ as Gt,xK as Na,PV as Oa,El as za,Er as Za,u8 as Ha,zV as Wa,Az as qa,kS as fe,PW as Qa,PX as Mt,lk as Ka,kM as Nt,l5 as Ot,l4 as it,bE as be,bO as Ja,PY as Xa,PZ as ve,jp as Ya,P_ as ot,P$ as en,jt as tn,jO as an,AN as nn,Q0 as on,ld as ln,AD as sn,Q1 as lt,AH as rn,AM as cn,AJ as dn,AB as un,Q2 as zt,yN as pn,Q3 as mn,Q4 as bn,ge as hn,gd as gn,gc as yn,kV as Sn,lb as st,lm as fn,rz as kn,l2 as vn,AF as In,jz as wn,lr as An,Q5 as Cn,jr as Bn,rq as xn,Q6 as En,zA as Dn,bK as Pn,bt as jn,LU as Tn,cS as Fn,cR as Rn,cz as Vn,cG as $n}from"./zeni-epic-state-DcKqCCCg.js";import{m as me,z as V,I as Ie,Z as We,W as le,U as y,aQ as xe,w as re,o as x,x as Pe,d as D,bh as Un,k as z,a2 as qe,s as E,q as we,bi as rt,bj as ct,bk as Ln,ak as _n,A as Gn,aK as Mn,y as Zt,a as Qe,C as Ke,bl as Nn,au as Ht,bm as On,V as zn,f as Wt,a7 as Zn,bn as Hn,bo as Wn,bp as qn,bq as Qn,br as Kn,bs as Jn,bt as Xn,bu as Yn,bv as ei,$ as ti,bw as ai,bc as ni,bx as ii,by as oi,a9 as li}from"./index-BnX1nS7p.js";import{n as L,S as si}from"./mui-DQ-jfgFM.js";import{A as dt}from"./AddressScreen-DmitYkw7.js";import{g as ie,a as je,i as qt,V as Je,b as Xe,c as ri,v as ci,d as di,A as he,D as ge}from"./DomesticWireDetailScreen-Bg4mE0II.js";import{a as f}from"./sentry-B2Aew07S.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-RYFll1PC.js";import{u as Qt}from"./useInitialThreadRequest-8loDIspA.js";import Ee from"./NotFoundScreen-DRRoMVDk.js";import{D as ui}from"./DrawerScreen-Q_Fkogtz.js";import{M as Kt}from"./MobileAppDrawer-DChLZMjE.js";import{F as Jt}from"./FeaturePreviewScreen-D35UAPet.js";import{S as Te}from"./SetupPagesScreen-DHP6inkV.js";import{B as pi}from"./BillPayApprovalRoutes-BzW0b3Z-.js";import{FallBackRoute as mi}from"./ScreenRoutes-DrzMUCeq.js";import"./recharts-CHATJmXy.js";import"./analytics-C-A3qVJh.js";import"./plaid-DWZgMqW3.js";import"./dnd-CR8sMRK3.js";import"./stripe-DMRn4zHo.js";import"./lottie-Coq2aDEW.js";import"./lexical-qJrDnJMV.js";import"./pdf-D2Xq7623.js";import"./utils-D8kKiFqT.js";import"./analyticsHelper-CewoJ3Hu.js";import"./routePaths-DyfF54Mg.js";import"./BusinessVerificationPageScreen-tq2Pq8-k.js";import"./ReimbursementApprovalRuleDetailScreen-Btjx5v4l.js";import"./getLocaleForTenant-DHWNDQcY.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a8ea9f1b-2bcd-495d-a0fe-51bf66fd3361",e._sentryDebugIdIdentifier="sentry-dbid-a8ea9f1b-2bcd-495d-a0fe-51bf66fd3361")}catch{}})();const bi=X(function(e,t){const l=_e(e,t.billId),n=V.getSignedInUser(),c=e.tenantState.currentTenantId,r={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:c??""},u=z(t.location.state?.pathnameStackToGoBack);let o=!0;u.poppedPathname?.includes("bills")===!0&&(o=!1);let s=`${l.createdBy?.firstName??"Zeni"} ${l.createdBy?.lastName??""}`;const i=De(n);i||!l.createdBy?.email?.includes("zeni.ai")||(s="Zeni");let d=!1,p=!1;if(l?.billActivities.length>0){const{isApprovalorRejectBtnVisible:g,isMarkAsPaidBtnVisible:b}=sa(l.billActivities,ra(t.currentTenant),n);d=g,p=b}const m=ca(t.currentTenant?.userRole??[]),h=l.transactionDetails!=null&&da(l.transactionDetails,m,n);return{billDetails:l,isAccountingClassesEnabled:Bt(e),createdBy:s,authParams:r,transactionAttachmentEndpoint:`${qe}/transaction_attachment`,signedInUser:n,showBackButton:o,isAdmin:m,isRealTimeApprovalEnabled:t.isRealTimeApprovalEnabled,showApproveRejectBtns:d,showMarkAsPaidButtonToApprover:p,hasZeniAssistAccess:t.hasZeniAssistAccess,analytics:D,showMarkAsPaidButtonToCreator:h,isZeniUser:i}},function(e,t){const{billId:l,currentTenant:n,location:c,navigate:r}=t,{tenantEmailDomain:u}=n;return{redirectToBillsScreen:()=>{const o=ie(u),s=E(c.state?.pathnameStackToGoBack,c.pathname);r(o,{state:{pathnameStackToGoBack:s}})},redirectToEditableBillScreen:()=>{const o=E(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}})},discardBillDetailsFromLocalStore:()=>{e(ke({}))},deleteBill:o=>{D.trackBillPayDeleteBill(l,o),e(Dt(l))},cancelAndDeleteBill:(o,s)=>{s===!0?D.trackBillPayCancelAndDeleteBill(l,o):D.trackBillPayCancelBill(l),e(ba(l,s))},onSaveRealTimeApprovals:o=>{e(ma(l,"bill_pay",o))},updateEditRealTimeApproverClicked:o=>{e(pa({isEdit:o,entityId:l,entityType:"bill_pay"}))},approveOrRejectBill:o=>{o.type==="approved"?e(tt(l,o.type,"")):e(tt(l,o.type,o.description??""))},retryOrRefundBill:o=>{o.type==="retry"?e(Be(l,"retry")):e(Be(l,"refund"))},onAddNewRule:()=>{r("../../bills/approval-rules")},onAttachmentClick:(o,s)=>{const i=je(u,o,s),d=E(c.state?.pathnameStackToGoBack,c.pathname);r(i,{state:{pathnameStackToGoBack:d}})},onBackClick:()=>{const o=z(t.location.state?.pathnameStackToGoBack),s=o.poppedPathname??ie(u);r(s,{state:{pathnameStackToGoBack:o.newStack}})},onRetryPaymentClick:()=>{const o=E(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}}),e(ua({billId:t.billId}))},onRefundPaymentClick:()=>{e(Be(t.billId,"refund"))},saveBillDetails:(o,s,i)=>{o&&e(Et({data:i,billId:l})),e(Ge(o?"paid":"pending_approval",o,s,l))},discardOutsideZeniPaymentData:()=>{e(xt({billId:l}))}}})(Un);function hi(){const e=K(),t=se(),l=J(),{billId:n}=ae(),c=me(),r=V.getSignedInUser(),u=Ie(),o=v(N=>Z(N)),s=v(N=>_e(N,n??"")),i=s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1,d=Qt(o?.companyId,{clearParams:s.fetchState==="Completed"&&!i}),{isAiCfoAccessEnabled:p,onAskAiCfoClick:m}=Ye({mobileExploreReferrer:"Bill Details"});We({isDataReady:s.fetchState==="Completed"});const h=o?.userRole!=null&&It(o?.userRole),g=o?.company==null||o.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!h,[b,k]=f.useState(!1),[P,A]=f.useState(!1),[C,G]=f.useState(!1),{useFeatureGate:j,useDynamicConfig:_}=le(),{isFeatureEnabled:$}=j(y.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:I}=j(y.isBillPayCommentingEnabled),{isFeatureEnabled:H}=j(y.isBillPayDetectInsufficientFundsEnabled),{configValue:M}=_(xe.zeniAssistConfig),B=oa(o),q=wt(o.userRole),W=g&&pe(u?.loggedInUserRoleMap),U=M.user_ids!=null&&r?.userId!=null&&M.user_ids.includes(r?.userId),{isFeatureEnabled:Q}=j(y.isInternationalPaymentShaVsOurFeatureEnabled),{isFeatureEnabled:Y}=j(y.billPaySetupShowInternationalPaymentByWise);if(f.useEffect(()=>{$&&s.transactionDetails?.isDeleted===!0||o.isZeni===!0&&r?.userEmailDomain==="zeni.ai"&&B===!1?G(!1):G(s.billActivities[0]?.isRealTimeApprovalEnabled&&(q||W||s.allApprovers.find(N=>N.user.userId===r?.userId)!=null||s.transactionDetails?.lastUpdatedByUserId===r?.userId))},[s.billActivities[0]?.isRealTimeApprovalEnabled,s.allApprovers,s.transactionDetails?.lastUpdatedByUserId,q,W,o.isZeni,B,r]),f.useEffect(()=>{n!=null&&t(At(n))},[n]),f.useEffect(()=>{b||s.fetchState=="Completed"||s.fetchState=="In-Progress"||(k(!0),t(Ct(n??"",$,U,!1)))},[b,s,n,t]),f.useEffect(()=>{P||s.fetchState!="Completed"||s.transactionDetails?.billPayInfo.stage.code=="paid"||(A(!0),t($e(!1,$,U,Y,n)),s.billActivities[0]?.isRealTimeApprovalEnabled===!0&&t(la()))},[P,s,n,t]),r==null)throw Error("Can't access address page without signing in...");return s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1?a.jsx(te,{to:`./edit${l.search}`}):s.deleteStatus.fetchState==="In-Progress"||s.cancelAndDeleteStatus.fetchState==="In-Progress"||s.cancelStatus.fetchState==="In-Progress"?a.jsx(re,{fetchState:s.deleteStatus.fetchState,style:{boxShadow:`0px 2px ${x.sp1} ${c.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[a.jsx(Pe,{analytics:D,onLoad:N=>(ee=>{n!=null&&ee.trackBillPayBillDetails(n,s.isRecurring)})(N)}),a.jsx(bi,{initialOpenThreadRequest:d??void 0,isShowDeletedBillsEnabled:$,location:l,navigate:e,isBillPayCommentingEnabled:I,isRealTimeApprovalEnabled:C,currentTenant:o,billId:n??"",isInternationalPaymentShaVsOurEnabled:Q,hasZeniAssistAccess:U,isDetectInsufficientFundsEnabled:H,isAiCfoAccessEnabled:p,onAskAiCfoClick:m})]})}const ye=Qe.getLocalizedStrings().spendManagement.billPay.billDetails,gi={containerWidth:new Zt(100,58)},ut=X(function(e,t){const l=V.getSignedInUser(),n=e.tenantState.currentTenantId,c={userId:l?.userId??"",sessionId:l?.zeniSessionId??"",tenantId:n??""},r=t.showActionButtons,u=r&&t.file==null;return{uploadInvoiceEndPoint:`${Ht.communicationAgentMicroServiceBaseUrl}`,authParams:c,billId:t.billId,file:t.file,showAutofill:t.showAutofill,analytics:D,entityId:t.billId,showTitlebarIcon:r,showTitlebar:r&&t?.file!=null,uploadStatus:t.uploadStatus,shouldNotShowAttachment:u,style:{paddingTop:x.sp10,paddingRight:x.sp3,paddingBottom:"15px",paddingLeft:x.sp5,...t.showAutofill?{}:{backgroundColor:t.backgroundColor,paddingBottom:"128px"}}}},function(e,t){const l=V.getSignedInUser();return{onInvoiceUpload:n=>{n!=null&&(t.file!=null||t.billId!=null||t.isInitialEdit?(t.setPayload(n),t.setShowConfirmationPopup(!0)):e(Oe(n,t.isVendorRecommendationEnabled,t.billId)))},updateInvoiceUploadFetchState:n=>{e(Sa({fetchState:{fetchState:n,error:void 0},billId:t.billId}))},onSkipAutofill:n=>{D?.trackBillPaySkipAutofill(),e(Ne(n))},onDeleteClick:()=>{e(ya({billId:t.billId})),D?.trackInvoiceActionClick(t.billStage??"","delete",l?.userEmail??"",null)}}})(Mn);function w({appContent:e}){const t=se(),l=K(),{billId:n}=ae(),c=J(),r=c.pathname,u=r.includes("bill/new")||r.includes("/edit"),o=we(),s=me(),i=V.getSignedInUser(),{useFeatureGate:d,useDynamicConfig:p}=le(),{isFeatureEnabled:m}=d(y.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:h}=d(y.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:g}=d(y.isDepositAccountsFeatureEnabled),{isFeatureEnabled:b}=d(y.billPaySetupShowInternationalPaymentByWise),{configValue:k}=p(xe.zeniAssistConfig),P=k.user_ids!=null&&i?.userId!=null&&k.user_ids.includes(i?.userId),A=v(F=>Z(F)),[C,G]=f.useState(!1),[j,_]=f.useState(!1),[$,I]=f.useState(!1),[H,M]=f.useState(),B=v(F=>Me(F,m,g,n));let q=B.fetchState,W=B.file,U=B.showAutofill;const Q=v(F=>_e(F,n??""));u===!1&&(q=Q.fetchState,W=Q.transactionDetails?.attachments?.[0],U=!1);const Y=B.billPayInfo!=null&&B.billPayInfo.stage.code==="pending_approval"?B.billPayInfo.billStatus.code:B.billStage;f.useEffect(()=>{n==null&&t(Ne(!0))},[n,t]),f.useEffect(()=>{q==="Not-Started"&&(u&&j?_(!1):!u&&C&&G(!1))},[n]),f.useEffect(()=>{C||n==null||u||(G(!0),t(Ct(n,h,P,!1)),j||(_(!0),t($e(!1,h,P,b,n)))),u&&!j&&(_(!0),t($e(!1,h,P,b,n)))},[C,j,u,n,t]);const N={onOkClick:()=>{if(I(!1),!H)return;const F=W!=null?"replace":"upload";D?.trackInvoiceActionClick(Y??"",F,i?.userEmail??"","yes"),t(ga({replaceBillData:!0,billId:n})),t(Oe(H,m,n))},onCancelClick:()=>{if(I(!1),!H)return;const F=W!=null?"replace":"upload";D?.trackInvoiceActionClick(Y??"",F,i?.userEmail??"","no"),t(ha({file:H,billId:n}))}},ee=f.useCallback(()=>{const F=z(c.state?.pathnameStackToGoBack),ce=F.poppedPathname??ie(A.tenantEmailDomain);t(ke({billId:n})),l(ce,{state:{pathnameStackToGoBack:F.newStack}})},[c.state,A.tenantEmailDomain,n,t,l]);if(i==null)throw Error("Can't access address page without signing in...");if(q==="Error"||Q.fetchState==="Error")return a.jsx(Ee,{});if(q!="Completed")return n==null&&o!=="small"?a.jsx(rt,{fallback:ee,children:a.jsxs(Fe,{windowSize:o,children:[a.jsx(mt,{}),a.jsx(Re,{}),a.jsx(ut,{backgroundColor:s.colors.grey4,billId:n,file:W,showAutofill:!0,uploadStatus:B.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:void 0,setShowConfirmationPopup:I,setPayload:M,showActionButtons:!1,isInitialEdit:!!B.isInitialEdit,billStage:Y}),a.jsx(Ve,{windowSize:o,children:a.jsx(ct,{isNewBill:!0})})]})}):a.jsxs(Fe,{windowSize:o,children:[o==="small"||U?null:a.jsx(pt,{children:a.jsx(Xt,{onClick:ee,"data-testid":"nav-bar-back-click"})}),o!=="small"?a.jsx(Re,{}):null,a.jsx(Ln,{}),a.jsx(Ve,{windowSize:o,children:a.jsx(ct,{isNewBill:n==null})})]});{const F=B.billPayInfo!=null&&B.billPayInfo.stage.code==="pending_approval"?B.billPayInfo.billStatus.code:B.billStage;return a.jsx(rt,{fallback:ee,children:a.jsxs(Fe,{windowSize:o,children:[U&&o!=="small"?a.jsx(mt,{}):null,$?a.jsx(_n,{titleComponent:a.jsx(wi,{children:ye.overwriteTitle}),descriptionComponent:a.jsx(Ai,{children:ye.overwriteDescription}),primaryButtonText:ye.buttons.yes,secondaryButtonText:ye.buttons.no,action:N,isEditPopup:!0}):null,o==="small"||U?null:a.jsx(pt,{children:a.jsx(yi,{})}),o!=="small"?a.jsx(Re,{}):null,a.jsx(ut,{backgroundColor:s.colors.grey4,billId:n,file:W,showAutofill:U,uploadStatus:B.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:Si(u,Q,B),setShowConfirmationPopup:I,setPayload:M,showActionButtons:fi(u,B),isInitialEdit:!!B.isInitialEdit,billStage:F}),a.jsx(Ve,{windowSize:o,children:e})]})})}}function yi(){const{triggerBack:e}=Nn();return a.jsx(Xt,{onClick:e,"data-testid":"nav-bar-back-click"})}function Si(e,t,l){let n,c;return e?(n=l.recurringConfig?.currentInstance,c=l.recurringConfig?.totalPaymentCycles):(n=t.transactionDetails?.recurringBillInstance,c=t.recurringBillConfigDetail?.totalPaymentCycles),t?.isRecurring===!0?a.jsxs(ki,{children:[a.jsx(vi,{children:`${ye.recurringBill.recurringCycle}
2
2
  ${n}/${c}`}),a.jsx(Ii,{})]}):void 0}function fi(e,t){const l=t.billActivities?.[0],n=t.billStage==="pending_approval"&&l?.areApprovalsSerialized===!0&&l?.currentPendingStepIndex===0;return e&&(t.billStage==="draft"||n)}const pt=L.div`
3
3
  margin-bottom: 20px;
4
4
  margin-top: 20px;
@@ -1,4 +1,4 @@
1
- import{j as k}from"./liveblocks-UQZFqaDN.js";import{a as V}from"./sentry-C0E1AQIe.js";import{h as ae,g as ne,u as se,i as oe,j as C,N as ie,n as re}from"./core-Ctjv24YM.js";import{I as ce,W as ue,aQ as de,z as E,x as pe,d as B,af as x,f as z,bH as le,au as me,s as P,av as M}from"./index-BJyv5Z6x.js";import{PT as fe,eV as G,tz as ye,Kd as Se,zu as ge,CW as Ie,FH as be,Gk as he,Hk as Te,Qe as De,Qf as Oe,Qg as ke,Qh as Ce,Qi as Ve,MG as we,Pg as Ae,MX as Ne,D_ as Fe,MY as _e,E2 as ve,la as xe,ge as ze,gd as Ee,gc as Be,rz as Pe,rq as Me,rn as Ue,l2 as Re,tI as Le,tG as U,bE as R,tU as L,cy as je}from"./zeni-epic-state-ym9j-rvL.js";import{n as Ge}from"./mui-DU4JyJ-_.js";import{d as j}from"./routePaths-C7N5VwuK.js";import{M as Qe}from"./MobileAppDrawer-DQwHFEP8.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},d=new t.Error().stack;d&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[d]="96a81eba-0d38-4d3c-be3f-2c5ba861f49a",t._sentryDebugIdIdentifier="sentry-dbid-96a81eba-0d38-4d3c-be3f-2c5ba861f49a")}catch{}})();const qe=Ge.div`
1
+ import{j as k}from"./liveblocks-DS8sOLD1.js";import{a as V}from"./sentry-B2Aew07S.js";import{h as ae,g as ne,u as se,i as oe,j as C,N as ie,n as re}from"./core-SRRzy8qJ.js";import{I as ce,W as ue,aQ as de,z as E,x as pe,d as B,af as x,f as z,bH as le,au as me,s as P,av as M}from"./index-BnX1nS7p.js";import{PT as fe,eV as G,tz as ye,Kd as Se,zu as ge,CW as Ie,FH as be,Gk as he,Hk as Te,Qe as De,Qf as Oe,Qg as ke,Qh as Ce,Qi as Ve,MG as we,Pg as Ae,MX as Ne,D_ as Fe,MY as _e,E2 as ve,la as xe,ge as ze,gd as Ee,gc as Be,rz as Pe,rq as Me,rn as Ue,l2 as Re,tI as Le,tG as U,bE as R,tU as L,cy as je}from"./zeni-epic-state-DcKqCCCg.js";import{n as Ge}from"./mui-DQ-jfgFM.js";import{d as j}from"./routePaths-DyfF54Mg.js";import{M as Qe}from"./MobileAppDrawer-DChLZMjE.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},d=new t.Error().stack;d&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[d]="96a81eba-0d38-4d3c-be3f-2c5ba861f49a",t._sentryDebugIdIdentifier="sentry-dbid-96a81eba-0d38-4d3c-be3f-2c5ba861f49a")}catch{}})();const qe=Ge.div`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as g}from"./liveblocks-UQZFqaDN.js";import{a as l}from"./sentry-C0E1AQIe.js";import{u as pe,h as he,g as Ce,j as H,i as fe,n as Se}from"./core-Ctjv24YM.js";import{Q as ge,da as be,z as ye,db as Pe,dd as z,de as Ie,b8 as W,x as we,d as $,df as B,dp as Ee,a as ke,f as Ae,a7 as Te,di as xe,dj as Ue,a2 as _e,dm as Oe,b4 as ve,dn as Qe}from"./index-BJyv5Z6x.js";import{gi as Fe,eU as G,eV as $e,fm as De,iH as Ve,iD as Le,eW as M,g3 as je,fY as Re,g0 as N,g4 as qe,g5 as He,g6 as Be,g7 as Me,g8 as Ne}from"./zeni-epic-state-ym9j-rvL.js";import{D as ze,n as V,P as We,S as Ge}from"./mui-DU4JyJ-_.js";import"./recharts-RL5R0Iqz.js";import"./analytics-BlxwN6GD.js";import"./plaid-Dtkg2fMC.js";import"./dnd-DdE4ICzz.js";import"./stripe-DMRn4zHo.js";import"./lottie-h9wdJ9gi.js";import"./lexical-z-P2V9ug.js";import"./pdf-BK4Cbxeo.js";import"./utils-hcCBORos.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="54233e37-95db-43cb-9a2a-44cdec4890d6",e._sentryDebugIdIdentifier="sentry-dbid-54233e37-95db-43cb-9a2a-44cdec4890d6")}catch{}})();const Y="chat-response-generated",Z="cards/ask",J="card_policy_hero";function D(e){return`/${e}/cards`}function K(e){return`/${e}/cards/policy`}const Ye=Se(function(e,a){const o=G(e),c=a.isSubmitting,d=Ue(e,{allUsers:a.allUsers,onCardPolicyVendorSearchTextChange:a.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:a.sessionFromUrl==="new_chat"&&o.uiState.currentChatSessionId==null,aiCfoView:o,isSubmitting:c,isNewChatSession:a.sessionFromUrl==="new_chat",isFullView:!0,tableDownloadEndPoint:`${_e}/tableDownload`,emailLinkQuestion:a.emailLinkQuestion,autoSubmitEmailLinkQuestion:a.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:a.onEmailLinkQuestionProcessed,isFileUploadEnabled:a.isFileUploadEnabled,isUploadPromoVisible:a.isUploadPromoVisible,onUploadPromoClose:a.onUploadPromoClose,...d}},function(e,a){const{location:o,currentTenant:c,userId:d,navigate:m,currentChatSessionId:h,allSessionsWithOrderedQuestionAnswers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,cardPolicyPageContext:U}=a,i=c.tenantEmailDomain,C=o.state?.referrer,p=C===J?K(i):D(i);return{onEventReceived:(n,t)=>{if(n===Y&&typeof t.text=="string"&&typeof t.metadata=="object"){const s=t,f=He(s.type),b=s.metadata.chat_session_id??null,{currentChatSession:y,currentQuestionAnswer:u,currentQuestionAnswerSummary:P}=W(E,b);f!=="answer"?$.trackAICFOChatResponseGenerated(f,u?.question.questionText??"",s.text,b,Qe(P,y),s.metadata.message_id??null):$.trackAICFOChatAnswerGenerated(s.text,u?.question.questionText??"",(s.follow_up_questions?.length??0)>0,!!s.assumptions,!!s.insights,s.visualization!=null,Be(s.visualization?.type??"")??null,b,s.summarized_title,s.metadata.message_id??null),e(Me({chatSessionId:s.metadata.chat_session_id,responseType:f,fetchState:{fetchState:"Completed",error:void 0}})),e(Ne({chatSessionId:s.metadata.chat_session_id,answerPayload:s,userId:d}))}},onSubmit:(n,t,s,f)=>{n&&ve(e,n,t,h,E,d,f,s,U)},updateCurrentInput:n=>{e(N(n))},onStopSubmit:()=>{},onUpdateScrollYOffset:n=>{e(qe(n))},onSelectSampleQuestion:()=>{},onBackClick:()=>{m(-1)},onCloseClick:()=>{m(p,{state:{...o.state}}),e(N(""))},togglePageView:()=>{m(p,{state:z(o.state)}),a.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{m(-1)},onNewChatClick:()=>{h!=null&&e(Re()),m(function(n){return`/${n}/${Z}`}(i),{state:{...o.state}})},onToggleCotCollapsed:(n,t)=>{e(je({questionAnswerId:n,isCollapsed:t}))},...Oe(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:x,currentChatSessionId:h,onAfterCardsCreationSubmit:()=>{a.setIsAiCfoOpen(!0),m(D(i),{state:{...o.state}})},onAfterCardPolicySubmit:()=>{a.setIsAiCfoOpen(!0),m(`/${i}/cards/policy`,{state:{...o.state}})}})}})(Te(xe)),{spendManagement:{chargeCard:{cardsAiCfoHero:X,cardPolicyAiCfoHero:ee}}}=ke.getLocalizedStrings(),A=X.pageTitle,Ze=ee.pageTitle,Je=X.chatHeaderSubtitle,Ke=ee.chatHeaderSubtitle,St=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:a}=ge(),o=pe(),c=he(),d=Ce(),[m,h]=l.useState(!1),{allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,onCardPolicyVendorSearchTextChange:U}=be();l.useEffect(()=>{o(Fe())},[o]);const i=H(r=>G(r)),C=ye.getSignedInUser(),{session_id:p}=fe(),n=H(r=>$e(r)),t=i.uiState.currentChatSessionId,s=n.tenantEmailDomain,{handleUploadPromoClose:f,isUploadPromoVisible:b}=Pe({isFileUploadEnabled:e,tenantEmailDomain:s}),y=d.state,u=y?.aiCfoInitialQuestion??null,P=!!y?.aiCfoShouldSubmit,I=y?.referrer===J,te=I?"card_policy":void 0,se=l.useMemo(()=>({title:I?Ze:A,subtitle:I?Ke:Je}),[I]),[ae,_]=l.useState(null),[oe,O]=l.useState(!1),v=l.useRef(!1);l.useEffect(()=>{v.current||u==null||u===""||(_(u),O(P),v.current=!0)},[u,P]);const ne=l.useCallback(()=>{_(null),O(!1),c(d.pathname,{replace:!0,state:z(d.state)})},[d.pathname,d.state,c]),ie=n.masterTOSInfo,S=ie?.isMasterTOSAccepted??!1,k=l.useRef(null);l.useEffect(()=>{if(S&&k.current!=null){const{question:r,shouldSubmit:w}=k.current;k.current=null,_(r),O(w),v.current=!1}},[S]);const{visitedSessions:L}=Ie(t),Q=i.fetchState,F=i.uiState.chatSessionsNextPageToken.hasMore||!i.uiState.chatSessionsFirstPageFetched,j=t!=null?i.fetchChatSessionHistoryByChatSessionId?.[t]?.fetchState??"Not-Started":"Not-Started",R=t==null||(i.uiState.chatHistoryNextPageToken[t]?.hasMore??!0),q=i.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:re}=W(q,t),le=re.length===0;l.useEffect(()=>{t!=null&&p!==t&&c(function(r,w){return`/${r}/${Z}/${w}`}(s,t),{state:{...d.state},replace:!0})},[t,p,s,c,d.state]),l.useEffect(()=>{p!=null&&t==null&&p!=="new_chat"&&o(De({sessionId:p,agentId:"controller"}))},[]);const de=l.useMemo(()=>({events:L.map(r=>`private-encrypted-chat-${r}.${Y}`),eventCallback:(r,w,me)=>me.onEventReceived(r,w)}),[L]);if(l.useEffect(()=>{Q!=="In-Progress"&&F&&o(Ve())},[Q,F,o]),l.useEffect(()=>{t!=null&&j!=="In-Progress"&&R&&C!=null&&Q==="Completed"&&!F&&o(Le(t,C.userId))},[j,R,t,C,o]),C==null)throw Error("Can't access Cards AI CFO page without signing in...");const ce=p??"new_chat",ue=t!=null&&i.responseStateByChatSessionId?.[t]?.answer?.fetchState==="In-Progress";return g.jsxs(et,{children:[g.jsx(we,{analytics:$,onLoad:r=>r.trackPageLoaded(Ae.Event.aiCFOPage)}),S?g.jsx(Ye,{...de,currentChatSessionId:t,allSessionsWithOrderedQuestionAnswers:q,allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,openOnboardingPage:()=>h(!0),userId:C.userId,setIsAiCfoOpen:a,navigate:c,sessionFromUrl:ce,location:d,isSubmitting:ue,isEmptyChatWithSession:le,customPageTitle:A,chatHeader:se,currentTenant:n,emailLinkQuestion:ae??void 0,autoSubmitEmailLinkQuestion:oe,onEmailLinkQuestionProcessed:ne,isFileUploadEnabled:e,isUploadPromoVisible:b,onUploadPromoClose:f,onCardPolicyVendorSearchTextChange:U,cardPolicyPageContext:te}):g.jsx(B,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>{c(I?K(s):D(s),{state:{...d.state}})},onCompleteClick:()=>{S||n.userRoleId==null||(u!=null&&u!==""&&(k.current={question:u,shouldSubmit:P}),o(M(n.userRoleId)))}}),g.jsx(ze,{anchor:"right",open:m,transitionDuration:250,PaperProps:{component:tt,style:{width:`${Ee}vw`}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>h(!1),children:g.jsx(Xe,{onClick:r=>r.stopPropagation(),children:g.jsx(B,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>h(!1),onCompleteClick:()=>{S||n.userRoleId==null||o(M(n.userRoleId)),h(!1)}})})})]})},Xe=V(Ge)`
1
+ import{j as g}from"./liveblocks-DS8sOLD1.js";import{a as l}from"./sentry-B2Aew07S.js";import{u as pe,h as he,g as Ce,j as H,i as fe,n as Se}from"./core-SRRzy8qJ.js";import{Q as ge,da as be,z as ye,db as Pe,dd as z,de as Ie,b8 as W,x as we,d as $,df as B,dp as Ee,a as ke,f as Ae,a7 as Te,di as xe,dj as Ue,a2 as _e,dm as Oe,b4 as ve,dn as Qe}from"./index-BnX1nS7p.js";import{gi as Fe,eU as G,eV as $e,fm as De,iH as Ve,iD as Le,eW as M,g3 as je,fY as Re,g0 as N,g4 as qe,g5 as He,g6 as Be,g7 as Me,g8 as Ne}from"./zeni-epic-state-DcKqCCCg.js";import{D as ze,n as V,P as We,S as Ge}from"./mui-DQ-jfgFM.js";import"./recharts-CHATJmXy.js";import"./analytics-C-A3qVJh.js";import"./plaid-DWZgMqW3.js";import"./dnd-CR8sMRK3.js";import"./stripe-DMRn4zHo.js";import"./lottie-Coq2aDEW.js";import"./lexical-qJrDnJMV.js";import"./pdf-D2Xq7623.js";import"./utils-D8kKiFqT.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="54233e37-95db-43cb-9a2a-44cdec4890d6",e._sentryDebugIdIdentifier="sentry-dbid-54233e37-95db-43cb-9a2a-44cdec4890d6")}catch{}})();const Y="chat-response-generated",Z="cards/ask",J="card_policy_hero";function D(e){return`/${e}/cards`}function K(e){return`/${e}/cards/policy`}const Ye=Se(function(e,a){const o=G(e),c=a.isSubmitting,d=Ue(e,{allUsers:a.allUsers,onCardPolicyVendorSearchTextChange:a.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:a.sessionFromUrl==="new_chat"&&o.uiState.currentChatSessionId==null,aiCfoView:o,isSubmitting:c,isNewChatSession:a.sessionFromUrl==="new_chat",isFullView:!0,tableDownloadEndPoint:`${_e}/tableDownload`,emailLinkQuestion:a.emailLinkQuestion,autoSubmitEmailLinkQuestion:a.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:a.onEmailLinkQuestionProcessed,isFileUploadEnabled:a.isFileUploadEnabled,isUploadPromoVisible:a.isUploadPromoVisible,onUploadPromoClose:a.onUploadPromoClose,...d}},function(e,a){const{location:o,currentTenant:c,userId:d,navigate:m,currentChatSessionId:h,allSessionsWithOrderedQuestionAnswers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,cardPolicyPageContext:U}=a,i=c.tenantEmailDomain,C=o.state?.referrer,p=C===J?K(i):D(i);return{onEventReceived:(n,t)=>{if(n===Y&&typeof t.text=="string"&&typeof t.metadata=="object"){const s=t,f=He(s.type),b=s.metadata.chat_session_id??null,{currentChatSession:y,currentQuestionAnswer:u,currentQuestionAnswerSummary:P}=W(E,b);f!=="answer"?$.trackAICFOChatResponseGenerated(f,u?.question.questionText??"",s.text,b,Qe(P,y),s.metadata.message_id??null):$.trackAICFOChatAnswerGenerated(s.text,u?.question.questionText??"",(s.follow_up_questions?.length??0)>0,!!s.assumptions,!!s.insights,s.visualization!=null,Be(s.visualization?.type??"")??null,b,s.summarized_title,s.metadata.message_id??null),e(Me({chatSessionId:s.metadata.chat_session_id,responseType:f,fetchState:{fetchState:"Completed",error:void 0}})),e(Ne({chatSessionId:s.metadata.chat_session_id,answerPayload:s,userId:d}))}},onSubmit:(n,t,s,f)=>{n&&ve(e,n,t,h,E,d,f,s,U)},updateCurrentInput:n=>{e(N(n))},onStopSubmit:()=>{},onUpdateScrollYOffset:n=>{e(qe(n))},onSelectSampleQuestion:()=>{},onBackClick:()=>{m(-1)},onCloseClick:()=>{m(p,{state:{...o.state}}),e(N(""))},togglePageView:()=>{m(p,{state:z(o.state)}),a.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{m(-1)},onNewChatClick:()=>{h!=null&&e(Re()),m(function(n){return`/${n}/${Z}`}(i),{state:{...o.state}})},onToggleCotCollapsed:(n,t)=>{e(je({questionAnswerId:n,isCollapsed:t}))},...Oe(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:x,currentChatSessionId:h,onAfterCardsCreationSubmit:()=>{a.setIsAiCfoOpen(!0),m(D(i),{state:{...o.state}})},onAfterCardPolicySubmit:()=>{a.setIsAiCfoOpen(!0),m(`/${i}/cards/policy`,{state:{...o.state}})}})}})(Te(xe)),{spendManagement:{chargeCard:{cardsAiCfoHero:X,cardPolicyAiCfoHero:ee}}}=ke.getLocalizedStrings(),A=X.pageTitle,Ze=ee.pageTitle,Je=X.chatHeaderSubtitle,Ke=ee.chatHeaderSubtitle,St=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:a}=ge(),o=pe(),c=he(),d=Ce(),[m,h]=l.useState(!1),{allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,onCardPolicyVendorSearchTextChange:U}=be();l.useEffect(()=>{o(Fe())},[o]);const i=H(r=>G(r)),C=ye.getSignedInUser(),{session_id:p}=fe(),n=H(r=>$e(r)),t=i.uiState.currentChatSessionId,s=n.tenantEmailDomain,{handleUploadPromoClose:f,isUploadPromoVisible:b}=Pe({isFileUploadEnabled:e,tenantEmailDomain:s}),y=d.state,u=y?.aiCfoInitialQuestion??null,P=!!y?.aiCfoShouldSubmit,I=y?.referrer===J,te=I?"card_policy":void 0,se=l.useMemo(()=>({title:I?Ze:A,subtitle:I?Ke:Je}),[I]),[ae,_]=l.useState(null),[oe,O]=l.useState(!1),v=l.useRef(!1);l.useEffect(()=>{v.current||u==null||u===""||(_(u),O(P),v.current=!0)},[u,P]);const ne=l.useCallback(()=>{_(null),O(!1),c(d.pathname,{replace:!0,state:z(d.state)})},[d.pathname,d.state,c]),ie=n.masterTOSInfo,S=ie?.isMasterTOSAccepted??!1,k=l.useRef(null);l.useEffect(()=>{if(S&&k.current!=null){const{question:r,shouldSubmit:w}=k.current;k.current=null,_(r),O(w),v.current=!1}},[S]);const{visitedSessions:L}=Ie(t),Q=i.fetchState,F=i.uiState.chatSessionsNextPageToken.hasMore||!i.uiState.chatSessionsFirstPageFetched,j=t!=null?i.fetchChatSessionHistoryByChatSessionId?.[t]?.fetchState??"Not-Started":"Not-Started",R=t==null||(i.uiState.chatHistoryNextPageToken[t]?.hasMore??!0),q=i.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:re}=W(q,t),le=re.length===0;l.useEffect(()=>{t!=null&&p!==t&&c(function(r,w){return`/${r}/${Z}/${w}`}(s,t),{state:{...d.state},replace:!0})},[t,p,s,c,d.state]),l.useEffect(()=>{p!=null&&t==null&&p!=="new_chat"&&o(De({sessionId:p,agentId:"controller"}))},[]);const de=l.useMemo(()=>({events:L.map(r=>`private-encrypted-chat-${r}.${Y}`),eventCallback:(r,w,me)=>me.onEventReceived(r,w)}),[L]);if(l.useEffect(()=>{Q!=="In-Progress"&&F&&o(Ve())},[Q,F,o]),l.useEffect(()=>{t!=null&&j!=="In-Progress"&&R&&C!=null&&Q==="Completed"&&!F&&o(Le(t,C.userId))},[j,R,t,C,o]),C==null)throw Error("Can't access Cards AI CFO page without signing in...");const ce=p??"new_chat",ue=t!=null&&i.responseStateByChatSessionId?.[t]?.answer?.fetchState==="In-Progress";return g.jsxs(et,{children:[g.jsx(we,{analytics:$,onLoad:r=>r.trackPageLoaded(Ae.Event.aiCFOPage)}),S?g.jsx(Ye,{...de,currentChatSessionId:t,allSessionsWithOrderedQuestionAnswers:q,allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,openOnboardingPage:()=>h(!0),userId:C.userId,setIsAiCfoOpen:a,navigate:c,sessionFromUrl:ce,location:d,isSubmitting:ue,isEmptyChatWithSession:le,customPageTitle:A,chatHeader:se,currentTenant:n,emailLinkQuestion:ae??void 0,autoSubmitEmailLinkQuestion:oe,onEmailLinkQuestionProcessed:ne,isFileUploadEnabled:e,isUploadPromoVisible:b,onUploadPromoClose:f,onCardPolicyVendorSearchTextChange:U,cardPolicyPageContext:te}):g.jsx(B,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>{c(I?K(s):D(s),{state:{...d.state}})},onCompleteClick:()=>{S||n.userRoleId==null||(u!=null&&u!==""&&(k.current={question:u,shouldSubmit:P}),o(M(n.userRoleId)))}}),g.jsx(ze,{anchor:"right",open:m,transitionDuration:250,PaperProps:{component:tt,style:{width:`${Ee}vw`}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>h(!1),children:g.jsx(Xe,{onClick:r=>r.stopPropagation(),children:g.jsx(B,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>h(!1),onCompleteClick:()=>{S||n.userRoleId==null||o(M(n.userRoleId)),h(!1)}})})})]})},Xe=V(Ge)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;
@@ -1,4 +1,4 @@
1
- import{j as c}from"./liveblocks-UQZFqaDN.js";import{h as de,g as Ce,i as Me,u as pe,j as o,N as ba,s as Dt,n as De,t as In,o as es,p as se}from"./core-Ctjv24YM.js";import{bt as Pe,RQ as as,RR as ts,eX as un,RS as kn,f4 as En,RT as An,RU as Dn,RV as _n,RW as Pn,f5 as wn,f6 as vn,RX as Tn,fg as Fn,fh as $a,RY as xn,RZ as ns,fa as rs,f9 as ss,R_ as cs,B_ as Bn,fj as ca,R$ as os,S0 as is,eZ as ds,eY as ls,fv as ze,fc as Rn,fb as Ln,S1 as us,fd as ms,Bv as Cs,Bu as ps,By as hs,BA as fs,fo as gs,eU as Un,S2 as Ss,S3 as bs,ft as On,S4 as ys,fu as bt,BG as Is,BD as ks,eV as fe,S5 as Qa,fy as we,fz as ve,fA as Te,gt as oa,cv as ia,S6 as da,S7 as _t,uN as za,kC as Ya,S8 as Za,Ce as ka,Cg as Qe,Ch as Pt,ks as jn,S9 as la,C2 as _a,Sa as Es,Sb as As,C5 as Ja,Sc as Ds,Qb as Xa,ff as Mn,Cb as ga,hS as _s,Sd as Nn,Se as ua,bo as Ps,Sf as ws,ge as et,gd as at,CL as vs,gc as tt,PT as Ts,Sg as Vn,co as Hn,cQ as Fs,Qa as wa,Dk as Gn,Sh as mn,CW as Pa,Si as $n,Dl as xs,QA as Bs,Dm as Rs,Er as Ls,u8 as Us,El as Os,Sj as js,Cf as ra,Sk as Ms,Sl as Ns,Sm as Vs,Sn as Hs,So as Gs,Sp as wt,Sq as $s,Cw as zn,Cp as zs,Sr as Ys,gv as Zs,CF as Yn,CJ as Zn,gu as Ks,Ss as Ws,D6 as Kn,St as qs,Su as Qs,Sv as Js,CH as Wn,Cs as qn,C8 as Qn,CB as Jn,Cz as Xn,CD as Xs,Sw as er,Sx as ec,fq as ac,fr as tc,fs as nc,Sy as nt,fk as ar,cR as vt,Sz as rc,SA as sc,SB as cc,SC as oc,CR as yt,Dd as ic,D9 as dc,CN as lc,Db as uc,D1 as mc,D3 as Cc,SD as tr,Dj as Ga,Ka as pc,SE as hc,SF as fc,SG as gc,SH as nr,SI as Sc,DG as bc,CV as rr,CQ as je,CU as yc,SJ as Ic,SK as kc,B$ as Ec,SL as sr,fe as cr,SM as Ac,C1 as Dc,C0 as Cn,SN as _c,SO as Pc,SP as wc,MH as vc,SQ as Tt,SR as Tc,xN as or,la as Fc,hI as xc,DL as Bc,SS as ir,f1 as Rc,f2 as Lc,ST as Uc,dh as Oc,fi as jc,DB as Mc,Dv as qe,bs as Nc,bJ as Vc,cA as Hc,bK as Gc,LU as $c}from"./zeni-epic-state-ym9j-rvL.js";import{I as Fe,cp as dr,k as _e,cq as lr,cr as ur,cs as zc,a as Xe,Z as Ft,ct as Yc,cu as Zc,Q as mr,c as Cr,X as pr,s as ye,W as le,U as K,ar as ya,cv as hr,cw as Kc,cx as Wc,z as re,w as va,ce as rt,cy as qc,cz as Qc,cA as Jc,q as Ta,aQ as Ye,br as xt,cB as Xc,y as Fa,i as st,m as Bt,d as J,a7 as ct,cC as eo,bE as Sa,cD as It,cE as ao,x as Rt,cF as to,au as fr,a2 as kt,cG as no,V as gr,f as Sr,cH as ro,cI as so,cJ as co,cK as oo,cL as io,cM as lo,o as Ka,cN as uo,cO as mo,cP as pt,$ as Co,cQ as po,cR as ho,cS as fo,cT as go,cU as So,a9 as bo}from"./index-BJyv5Z6x.js";import{n as Ne,D as br,S as yo}from"./mui-DU4JyJ-_.js";import{a as r}from"./sentry-C0E1AQIe.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-DZ2VqCuW.js";import{M as Ie}from"./MobileAppDrawer-DQwHFEP8.js";import{d as Lt}from"./recharts-RL5R0Iqz.js";import{g as Ae,a as Ba,b as yr,c as xe,d as Be,e as Je,f as ea,h as aa,A as Io,i as Ut,P as ko,j as Ot,s as Ia,k as Ir,l as sa,m as kr,n as Eo,o as Er,p as Ao,S as pn}from"./SetupPagesScreen-CVepw64Y.js";import{u as Ar}from"./useInitialThreadRequest-B13VgkiL.js";import ot from"./NotFoundScreen-DtHa7L00.js";import{u as jt}from"./useChargeCardPusherEvents-CaVuS_Mc.js";import{n as hn}from"./utils-hcCBORos.js";import{t as Do}from"./AddressScreen-FgxQZ6Pn.js";import"./analytics-BlxwN6GD.js";import"./plaid-Dtkg2fMC.js";import"./dnd-DdE4ICzz.js";import"./stripe-DMRn4zHo.js";import"./lottie-h9wdJ9gi.js";import"./lexical-z-P2V9ug.js";import"./pdf-BK4Cbxeo.js";import"./analyticsHelper-CrGhWq9e.js";import"./routePaths-C7N5VwuK.js";import"./BusinessVerificationPageScreen-CsuP5vKP.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]="a5636aca-02b8-4823-96dc-0cc560dadd01",e._sentryDebugIdIdentifier="sentry-dbid-a5636aca-02b8-4823-96dc-0cc560dadd01")}catch{}})();const _o=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}},Dr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:_o(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)}),{spendManagement:{chargeCard:{cardPolicyPage:fn}}}=Xe.getLocalizedStrings(),Po=e=>Rn(e,!1),wo=e=>Ln(e.name,!1);function vo(){const e=de(),n=Ce(),{tenantEmailDomain:t}=Me(),a=pe(),s=Fe(),y=Pe(s?.loggedInUserRoleMap),[f,S]=r.useState(!1),w=r.useCallback(P=>{S(P)},[]),l=r.useCallback(()=>{w(!0)},[w]),{isAiCfoAccessEnabled:m,onAskAiCfoClick:R}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect(()=>()=>{a(as()),a(ts()),a(un())},[a]);const v=o(P=>kn(P.cardPolicyState)),u=o(P=>En(P.cardPolicyState)),M=o(P=>An(P.cardPolicyState)),x=o(P=>Dn(P.cardPolicyState)),B=o(P=>_n(P.cardPolicyState)),p=o(P=>Pn(P.cardPolicyState)),h=o(P=>wn(P.cardPolicyState)),D=o(P=>vn(P.cardPolicyState)),d=o(P=>Tn(P.cardPolicyState)),_=o(P=>P.chargeCardConfigState.receiptRequiredAboveAmount.amount),k=o(P=>P.chargeCardConfigState.fetchState);r.useEffect(()=>{v!=="Completed"&&v!=="In-Progress"&&a(Fn())},[a,v]),r.useEffect(()=>{D==="Completed"&&d===""||D==="In-Progress"||a($a())},[a,D,d]);const j=o(P=>xn(P.createCardPolicyState)),A=o(P=>ns(P.createCardPolicyState)),I=o(P=>rs(P.cardPolicyState)),L=o(P=>ss(P.cardPolicyState)),i=o(P=>cs(P.createCardPolicyState)),C=o(P=>Bn(P));r.useEffect(()=>{C.fetchState==="Not-Started"&&a(ca(!1,!1,!1))},[C.fetchState,a]);const N=r.useMemo(()=>u.map(Po),[u]),G=r.useMemo(()=>h.map(wo),[h]),U=r.useMemo(()=>C.cards.filter(P=>!dr(P.status.code)).map(Dr),[C.cards]),O=v==="Completed"&&C.fetchState==="Completed"&&k==="Completed";r.useEffect(()=>{O&&i==null&&a(os({cardsMasterList:U,defaultRequireReceiptAmount:_,suggestedAllowMerchants:M,suggestedBlockMerchants:x,suggestedAllowCategories:B,suggestedBlockCategories:p}))},[k,a,O,i,U,_,M,x,B,p]);const z=r.useMemo(()=>Lt(P=>{a($a(P))},250),[a]);r.useEffect(()=>()=>{z.cancel()},[z]);const Y=r.useCallback(P=>{z(P)},[z]),b=j.fetchState,T=t!=null?`/${t}/cards/policy`:"..",Z=r.useCallback(()=>{const P=_e(n.state?.pathnameStackToGoBack),ee=P.poppedPathname??T;e(ee,{state:{pathnameStackToGoBack:P.newStack}})},[n.state,e,T]),q=r.useCallback(()=>{e(T)},[e,T]),E=r.useCallback(P=>{a(is(P))},[a]),V=r.useCallback(P=>{const ee=lr(P);a(ds({templates:[ee]}))},[a]),Q=r.useCallback(P=>{P.length!==0&&a(ls(P))},[a]),X=r.useCallback(()=>{a(un())},[a]),g=r.useRef(b);r.useEffect(()=>{const P=g.current;g.current=b,b==="Completed"&&P!=="Completed"&&A!=null&&(a(ze({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(T))},[a,b,A,e,T]);const F=b==="Error"?j.error?.message??fn.createPolicyGenericErrorMessage:void 0;return y&&t!=null?i==null?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:w}),c.jsx(ur,{showUploadDocumentSection:!0,navBarTitle:fn.createPageTitle,onBackClick:Z,onClickMenuIcon:l,isAiCfoAccessEnabled:m,onAskAiCfoClick:R})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:w}),c.jsx(zc,{formDraft:i,vendorSearchOptions:G,categorySearchOptions:N,isVendorSearchLoading:D==="In-Progress",onVendorSearchTextChange:Y,submitState:b,submitErrorMessage:F,documentUploadState:I,uploadedFileName:L,isAiCfoAccessEnabled:m,onAskAiCfoClick:R,onBackClick:Z,onCancelClick:q,onClickMenuIcon:l,onFormChange:E,onSubmit:V,onUploadDocument:Q,onRemoveDocument:X})]}):c.jsx(ba,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:To}}}=Xe.getLocalizedStrings(),Fo=e=>Rn(e,!1),xo=e=>Ln(e.name,!1);function Bo(){const e=de(),n=Ce(),{tenantEmailDomain:t,templateId:a}=Me(),s=pe(),y=Fe(),f=Pe(y?.loggedInUserRoleMap),[S,w]=r.useState(!1),l=r.useCallback(F=>{w(F)},[]),m=r.useCallback(()=>{l(!0)},[l]),{isAiCfoAccessEnabled:R,onAskAiCfoClick:v}=xa({mobileExploreReferrer:"Card Policy"}),u=o(F=>us(F)),M=o(F=>kn(F.cardPolicyState)),x=o(F=>En(F.cardPolicyState)),B=o(F=>An(F.cardPolicyState)),p=o(F=>Dn(F.cardPolicyState)),h=o(F=>_n(F.cardPolicyState)),D=o(F=>Pn(F.cardPolicyState)),d=o(F=>wn(F.cardPolicyState)),_=o(F=>vn(F.cardPolicyState)),k=o(F=>Tn(F.cardPolicyState)),j=o(F=>Bn(F)),A=o(F=>a!=null?ms(F.cardPolicyState,a):void 0),I=r.useMemo(()=>u.templateId===a&&u.formDraft!=null?u.formDraft:A!=null?Cs(A):void 0,[u.templateId,u.formDraft,A,a]);r.useEffect(()=>{if(a==null)return;const F=u.detailFetchState.fetchState;u.templateId===a&&(F==="Completed"||F==="In-Progress")||A!=null||s(ps(a))},[s,a,u.templateId,u.detailFetchState.fetchState,A]),r.useEffect(()=>{M!=="Completed"&&M!=="In-Progress"&&s(Fn())},[s,M]),r.useEffect(()=>{_==="Completed"&&k===""||_==="In-Progress"||s($a())},[s,_,k]);const L=o(F=>F.chargeCardConfigState.receiptRequiredAboveAmount.amount);r.useEffect(()=>{j.fetchState==="Not-Started"&&s(ca(!1,!1,!1))},[j.fetchState,s]);const i=r.useMemo(()=>x.map(Fo),[x]),C=r.useMemo(()=>d.map(xo),[d]),N=r.useMemo(()=>j.cards.filter(F=>!dr(F.status.code)).map(Dr),[j.cards]);Ft({isDataReady:I!=null});const G=r.useMemo(()=>{if(I!=null)return Yc({draft:I,cardRows:N,categorySearchOptions:i,vendorSearchOptions:C,defaultRequireReceiptAmount:L,suggestedAllowMerchants:B,suggestedBlockMerchants:p,suggestedAllowCategories:h,suggestedBlockCategories:D})},[I,N,i,C,L,B,p,h,D]),[U,O]=r.useState(void 0),z=r.useRef(!1);r.useEffect(()=>{z.current||U!=null||G==null||(z.current=!0,O(G))},[U,G]);const Y=r.useCallback(F=>{O(F)},[]),b=r.useMemo(()=>Lt(F=>{s($a(F))},250),[s]);r.useEffect(()=>()=>{b.cancel()},[b]);const T=r.useCallback(F=>{b(F)},[b]),Z=u.updateFetchState.fetchState,q=t!=null?`/${t}/cards/policy`:"..",E=r.useCallback(()=>{const F=_e(n.state?.pathnameStackToGoBack),P=F.poppedPathname??q;e(P,{state:{pathnameStackToGoBack:F.newStack}})},[n.state,e,q]),V=r.useCallback(()=>{e(q)},[e,q]),Q=r.useCallback(F=>{if(a==null)return;const P=lr(F);s(hs(P)),s(fs(a))},[s,a]),X=r.useRef(Z);r.useEffect(()=>{const F=X.current;X.current=Z,Z==="Completed"&&F!=="Completed"&&(s(ze({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(q))},[s,Z,e,q]);const g=Z==="Error"?u.updateFetchState.error?.message??To.updatePolicyGenericErrorMessage:void 0;return!f||t==null||a==null?c.jsx(ba,{to:"..",replace:!0}):U!=null&&M==="Completed"&&j.fetchState==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:l}),c.jsx(Zc,{templateName:u.template?.name??"",formDraft:U,vendorSearchOptions:C,categorySearchOptions:i,isVendorSearchLoading:_==="In-Progress",onVendorSearchTextChange:T,submitState:Z,submitErrorMessage:g,isAiCfoAccessEnabled:R,onAskAiCfoClick:v,onBackClick:E,onCancelClick:V,onClickMenuIcon:m,onFormChange:Y,onSubmit:Q})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:l}),c.jsx(ur,{showUploadDocumentSection:!1,navBarTitle:u.template?.name,onBackClick:E,onClickMenuIcon:m,isAiCfoAccessEnabled:R,onAskAiCfoClick:v})]})}function _r(e,n,t){return n?e.filter(a=>a!=null&&a.trim().length>0).slice(0,t):[]}function Pr(e){return o(n=>e==null||e===""?{chips:ht,isResolved:!1}:function(t){const a=t?.fetchState,s=a==="Completed"||a==="Error";return{chips:a==="Completed"?t?.suggestedQuestions??ht:ht,isResolved:s}}(gs(n,e)),Dt)}const ht=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Ro,subheadline:Lo,pageTitle:Uo}}}}=Xe.getLocalizedStrings(),Oo=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 jo(){const e=de(),n=Ce(),{tenantEmailDomain:t}=Me(),a=pe(),s=Fe(),y=Pe(s?.loggedInUserRoleMap),[f,S]=r.useState(!1),w=r.useCallback(b=>{S(b)},[]),l=r.useCallback(()=>{w(!0)},[w]),{useFeatureGate:m}=le(),{isFeatureEnabled:R}=m(K.isAiCfoFileUploadEnabled),{isFeatureEnabled:v}=m(K.isCardPolicyEnabled),{isAiCfoAccessEnabled:u,onAskAiCfoClick:M}=xa({mobileExploreReferrer:"Card Policy"}),x=o(b=>Ss(b)),B=o(b=>xn(b.createCardPolicyState)),p=o(b=>bs(b.createCardPolicyState)),h=o(b=>p==null?[]:On(b.aiCfoState,p).filter(T=>T.kind==="creating_policy"),Dt),D=B.fetchState==="In-Progress"?Math.max(h.length,1):0,d=o(b=>ys(b.createCardPolicyState)),_=ya(B.fetchState);r.useEffect(()=>{if(_==="In-Progress"&&B.fetchState==="Completed"&&p!=null)h.forEach(b=>{a(bt({chatSessionId:p,id:b.id,entityIds:d,kind:"created_policy"}))});else if(_==="In-Progress"&&B.fetchState==="Error"&&p!=null){h.forEach(T=>{a(bt({chatSessionId:p,id:T.id,kind:"errored_policy"}))});const b=B.error?.message!=null&&B.error.message.length>0?B.error.message:Xe.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;a(ze({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:b}]}))}},[B.error?.message,B.fetchState,a,p,d,h,_]);const k=x.fetchState.fetchState;r.useEffect(()=>{k!=="Not-Started"&&k!=="Error"||a(Is())},[a,k]);const j=x.archiveFetchState.fetchState,A=ya(j);r.useEffect(()=>{A==="In-Progress"&&j==="Completed"&&a(ze({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))},[j,a,A]);const I=r.useMemo(()=>x.templates.map(Oo),[x.templates]);Ft({isDataReady:x.fetchState.fetchState==="Completed"});const L=I.length>0||D>0,i=function(b){const{hasAnyPolicies:T,isChargeCardAdmin:Z,isFileUploadEnabled:q}=b,E=de(),V=Ce(),{tenantEmailDomain:Q}=Me(),{isAiCfoOpen:X,setIsAiCfoOpen:g}=mr(),F=Cr(),P=pr(),ee=o(ce=>Un(ce)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:W,isResolved:ke}=Pr("card_policy"),Se=r.useMemo(()=>_r(W,ke,3),[W,ke]),[ge,ae]=r.useState(""),ue=P&&F&&Q!=null&&!X,oe=r.useCallback(ce=>{if(Q==null)return;const Ea=ye(V.state?.pathnameStackToGoBack,V.pathname);E(`/${Q}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:Ea,referrer:"card_policy_hero",aiCfoInitialQuestion:ce,aiCfoShouldSubmit:ce!=null&&ce.trim().length>0}})},[V.pathname,V.state,E,Q]),te=r.useCallback(ce=>{ce.trim().length!==0&&(ae(""),oe(ce))},[oe]),Ze=r.useCallback(()=>{const ce=ge.trim();ce.length!==0&&(ae(""),oe(ce))},[ge,oe]),Ee=r.useCallback(()=>{},[]),ne=r.useCallback(ce=>{ae(ce)},[]),Ke=r.useCallback(()=>{g(!0)},[g]),Re=r.useCallback(()=>{oe(void 0)},[oe]);return r.useMemo(()=>{if(ue&&!T&&Z)return{aiAgentName:Uo,headline:Ro,subheadline:Lo,promptChips:Se,composer:{currentInput:ge,isSubmitting:ee,isFileUploadEnabled:q,onInputChange:ne,onSubmit:Ze,onStopSubmit:Ee},onPromptClick:te,onOpenSidePanel:Ke,onOpenFullView:Re,dataTestIdPrefix:"card-policy-ai-cfo-hero"}},[ge,T,ue,Z,q,ee,ne,Re,Ke,te,Ee,Ze,Se])}({hasAnyPolicies:L,isChargeCardAdmin:y,isFileUploadEnabled:R}),C=v&&i!=null?c.jsx(hr,{...i}):null,N=u&&C==null,G=r.useCallback(()=>{const b=_e(n.state?.pathnameStackToGoBack),T=b.poppedPathname??"..";e(T,{state:{pathnameStackToGoBack:b.newStack}})},[n.state,e]),U=r.useCallback(()=>{t!=null&&e(`/${t}/cards/policy/new`)},[e,t]),O=r.useCallback(b=>{t!=null&&e(`/${t}/cards/policy/${b}/edit`)},[e,t]),z=r.useCallback(b=>{a(ks(b))},[a]),Y=x.fetchState.fetchState;return!L&&Y!=="Completed"&&Y!=="Error"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:w}),c.jsx(Kc,{onBackClick:G,onNewPolicyClick:U,onClickMenuIcon:l,isAiCfoAccessEnabled:u,onAskAiCfoClick:M})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:w}),c.jsx(Wc,{policies:I,archivingTemplateId:x.archiveTargetTemplateId,pendingCreationCount:D,onBackClick:G,onNewPolicyClick:U,onEditPolicyClick:O,onArchivePolicyClick:z,onClickMenuIcon:l,policyAiCfoHero:C,isAiCfoAccessEnabled:N,onAskAiCfoClick:M})]})}function Mo(){const e=de(),{cardId:n}=Me(),t=pe(),a=re.getSignedInUser(),s=o(W=>fe(W)),y=Fe(),f=Pe(y?.loggedInUserRoleMap),{useFeatureGate:S}=le();if(a==null)throw Error("Can't access Add To Wallet Page without signing in...");const[w,l]=r.useState(!1),m=o(W=>Qa(W).firstViewAfterActivation);if(n==null)throw Error("Empty card id is not valid...");const R=s.userRole.includes("charge_card_user"),{isFeatureEnabled:v}=S(K.isChargeCardFeatureEnabled),u=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:M}=S(K.isDebitCardFeatureEnabled),x=we(s),B=ve(s),p=Te(M,s),h=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,D=xe({isDebitCardFeatureEnabled:M,isBankingOnlyTenant:p}),d=Be({isCardsOnlyTenant:x,isChargeCardFeatureEnabled:v,isBookKeepingTenant:B,isDebitCardProductVisible:D,chargeCardsCreditAccountLimit:h}),_=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,k=o(W=>oa(W,s.companyId)),j=ia(k.controllers),{creditAccount:A,creditAccountRepayment:I}=o(W=>da(W)),L=o(W=>W.classListState.fetchState),i=!R&&d&&u,C=o(W=>_t(W,n,i,d)),[N,G]=r.useState(!1),U=C.chargeCard,O=U?.cardCreatedByUser?.userId,z=o(W=>O!=null?za(W.userRoleState,O):void 0),Y=z?.accountingClassIDs[0],b=o(W=>Y!=null?Ya(W.classState,{classId:Y,reportId:"class_list"}):void 0),T=U?.cardHolderUser?.userId,Z=o(W=>T!=null?za(W.userRoleState,T):void 0),q=Z?.accountingClassIDs[0],E=o(W=>q!=null?Ya(W.classState,{classId:q,reportId:"class_list"}):void 0),V=U?.type.code==="business_physical_credit_card"||U?.type.code==="business_physical_debit_card",Q=U?.type.code==="business_physical_debit_card";r.useEffect(()=>{m&&w===!1&&V&&(l(!0),setTimeout(()=>{t(Za()),Q&&t(ze({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[m,w,V,Q]),r.useEffect(()=>{N||C.fetchState==="Completed"||C.fetchState==="In-Progress"||n==null||(G(!0),t(ka(n,i,!1)))},[N,C,n,t]),r.useEffect(()=>{if(C.fetchState==="Completed"&&(V===!1||V&&U?.status?.code!=="active"||U?.cardHolderUserId!==a.userId||m===!1&&w===!1||U?.type.code==="business_physical_debit_card"||U?.type.code==="business_virtual_debit_card")){const W=Ae(s.tenantEmailDomain,n,a,U,m);e(W)}},[C.fetchState,m,V]),r.useEffect(()=>{A.fetchState!=="Completed"&&A.fetchState!=="In-Progress"&&d&&u&&f&&t(Qe()),I.fetchState!=="Completed"&&I.fetchState!=="In-Progress"&&d&&u&&f&&t(Pt()),L!=="Completed"&&L!=="In-Progress"&&t(jn())},[A.fetchState,I.fetchState,t,d,u,f,L]);const X=()=>{if(a!=null&&n!=null){t(Za());const W=Ae(s.tenantEmailDomain,n,a);e(W)}},g=U?.type.code==="business_physical_debit_card"||U?.type.code==="business_virtual_debit_card",F=Je(d,D,_,u),P=Ba(d,u,f,A,I),ee=yr(g,C);return C.fetchState!=="Completed"?c.jsx(va,{fetchState:"In-Progress"}):c.jsxs(c.Fragment,{children:[c.jsx(rt,{showConfetti:m}),c.jsx(qc,{onGotItClick:X,isDebitCard:U?.type.code==="business_physical_debit_card",controllerEmails:j,isChargeCardFeatureEnabled:d,isDebitCardFeatureEnabled:D,isDebitCardSetupEnabled:_,isChargeCardSetupEnabled:u,productInformation:F,creditAccountInformation:P,debitAccountInformation:ee,chargeCardDetailView:C,creditAccount:A,classListFetchState:L,creditAccountRepayment:I,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:b?.className,cardHolderRoles:Z?.userRoles,cardHolderDepartmentName:E?.className})]})}const wr="charge-card-transaction-update",vr="charge-card-transaction-created",Tr="charge-card-transaction-declined",Fr="charge-card-transaction-updated",xr="charge-card-transaction-receipt-uploaded",ma="charge-card-status-update",Mt="charge-card-spending-updated",it="credit-account-balance-updated",dt="charge-card-created",Nt="charge-card-limit-updated",Vt="charge-card-limit-reset",Ht="charge-card-renamed",No="charge-card-department-updated",Br="charge-card-repayment-completed",Rr="charge-card-payment-date-updated",Ra="charge-card-cashback-redeemed",La="charge-card-cashback-earned",Ca=(e,n)=>e==null||e===""?[]:n.map(t=>`private-encrypted-${e}.${t}`),Vo=[La,Ra],Ho=De(function(e){const n=la(e);return{insightsData:n.insight,cashbackByPeriod:n.cashbackByPeriod,uiState:n.uiState,cashbackSummary:n.cashbackSummary}},function(e){return{onColumnSortConfigChanged:(n,t)=>{e(Es({uiState:{sortKey:n,sortOrder:t}}))}}})(Jc);function Go(){const e=de(),n=pe(),t=Ce(),a=re.getSignedInUser(),s=o(M=>fe(M)),{useFeatureGate:y}=le(),{isFeatureEnabled:f}=y(K.isCardsCommentingEnabled),[S,w]=r.useState(!1),l=o(M=>la(M)),m=Ar(s.companyId,{clearParams:l.fetchState==="Completed"}),R=r.useCallback(()=>{const M=_e(t.state?.pathnameStackToGoBack),x=M.poppedPathname??$o(s.tenantEmailDomain);e(x,{state:{pathnameStackToGoBack:M.newStack}})},[e,t,s.tenantEmailDomain]),v=ea(s);if(jt({events:Ca(v,Vo),onEvent:M=>{switch(M){case La:case Ra:return void n(_a(!0))}},onSubscribed:()=>{n(_a(!0))}}),r.useEffect(()=>{S||l.fetchState==="Completed"||l.fetchState==="In-Progress"||(w(!0),n(_a()))},[S,l,n]),a==null)throw Error("Can't access cashback detail page without signing in...");const u=l.cashbackSummary?.cashbackEarned?.amount!=null&&l.fetchState!=="Not-Started";return l.fetchState!=="In-Progress"||u?(l.cashbackSummary?.cashbackEarned?.amount??0)===0&&l.fetchState==="Completed"?c.jsx(ot,{}):c.jsx(Ho,{onBackClick:R,isCardsCommentingEnabled:f,initialOpenThreadRequest:m}):c.jsx(Qc,{onBackClick:R})}const $o=e=>`/${e}/cards`,zo={containerWidth:new Fa(100,58)},Yo=({appContent:e})=>{const n=Ta(),t=pe(),a=de(),{cardId:s}=Me(),y=Ce(),{useDynamicConfig:f}=le(),[S,w]=r.useState(!1),[l,m]=r.useState(!1),[R,v]=r.useState(!1),[u,M]=r.useState(!1),x=re.getSignedInUser();if(x==null)throw Error("Can't access onboarding card page without signing in...");const B=o(E=>fe(E));if(s==null)throw Error("Empty card id is not valid...");const{configValue:p}=f(Ye.zeniCardsConfig),h=p.max_charge_card_activation_attempts_by_card_id,D=o(E=>As(E,s)),d=D.chargeCard,_=o(E=>E.chargeCardConfigState.fetchState),{useFeatureGate:k}=le(),{isFeatureEnabled:j}=k(K.isChargeCardFeatureEnabled),{isFeatureEnabled:A}=k(K.isDebitCardFeatureEnabled),I=Te(A,B),L=xe({isDebitCardFeatureEnabled:A,isBankingOnlyTenant:I}),i=!!B.companyChargeCardInfo?.info?.isChargeCardEnabled,C=B.userRole.includes("charge_card_user"),N=we(B),G=ve(B),U=B.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,O=Be({isCardsOnlyTenant:N,isChargeCardFeatureEnabled:j,isBookKeepingTenant:G,isDebitCardProductVisible:L,chargeCardsCreditAccountLimit:U}),z=!C&&O&&i;r.useEffect(()=>{S===!1&&_!=="In-Progress"&&_!=="Completed"&&(t(Ja()),w(!0)),l===!1&&D.fetchState==="Not-Started"&&(m(!0),t(ka(s,z,O)))},[l,D.fetchState,S,_]);const Y=d?.type.code==="business_physical_credit_card"||d?.type.code==="business_physical_debit_card";r.useEffect(()=>{if(D.fetchState==="Completed"){if(R===!1&&(Y===!1||Y&&d?.status?.code!=="inactive"||d?.cardHolderUserId!==x.userId)){const E=Ae(B.tenantEmailDomain,s,x,d,!0),V=ye(y.state?.pathnameStackToGoBack,y.pathname);a(E,{state:{pathnameStackToGoBack:V}})}else if(R&&D.isRefreshingViewInBackground===!1&&d?.status?.code==="active"){t(Ds({chargeCardId:s}));const E=Ae(B.tenantEmailDomain,s,x,d,!0),V=ye(y.state?.pathnameStackToGoBack,y.pathname);t(Xa()),a(E,{state:{pathnameStackToGoBack:V}})}}},[D.fetchState,d?.type.code,R,D.isRefreshingViewInBackground]);const b=re.getZeniOtpTokenForCardHolder(s),T=o(E=>Mn(E.userState,x.userId)),Z=()=>{d?.status?.code!=="active"&&t(ga(s,!0))};r.useEffect(()=>{D.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&d?.cardActivationAttemptHistory.some(E=>E.statusCode==="success")===!0&&R===!1&&(setTimeout(Z,3e3),v(!0))},[D.updatePhysicalChargeCardAttemptFetchState.fetchState,d?.cardActivationAttemptHistory]);const q=E=>{M(E)};if(_!=="Completed"||d==null)return c.jsx(va,{fetchState:"In-Progress"});if(d.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(T?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(Wo,{children:[c.jsx(Ie,{isAppContentDrawerOpen:u,handleDrawerToggle:q}),c.jsx(Zo,{cardId:s,card:d,shippingAddressId:d.shippingAddressId,phone:T.phone,signedInUser:x,isSandboxEnv:xt(),chargeCardDetailState:D,signedInUserToken:b,navigate:a,currentTenant:B,location:y,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(Ko,{windowSize:n,children:e}):null]})},Zo=De(function(e,{chargeCardDetailState:n,shippingAddressId:t,location:a,cardId:s}){const y=_s(e.addressState,t);if(y==null)throw Error("Can't access shippingAddress.");const f=Nn(e,s),S=n.updateStatus,w=ua(e,!1,!1,!1);let l=!1;w.fetchState==="Completed"&&w.cards.length<=1&&(l=!0);const m=a.state?.message==="comingFromV2UrlPath";return{showActivatePage:n.chargeCard?.providerCardCreateTime!=null&&n.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Ps())||m,showMenuIcon:l,shippingAddress:y,vgsVaultId:st.cardVaultId,twoFAView:f,activationWaitStatus:S,isRefreshingViewInBackground:n.isRefreshingViewInBackground}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:y,chargeCardDetailState:f}=n,S=f.chargeCard?.cardProviderID,{tenantEmailDomain:w}=y;return{onGetOtp:l=>{S!=null&&e(tt(l,"ChargeCardHolder",a))},onUpdatePhysicalChargeCardAttempt:l=>{e(vs(a,l))},onResendOtp:l=>{S!=null&&e(at(l,"ChargeCardHolder",a))},onVerifyOtp:(l,m)=>{S!=null&&e(et(l,m,"ChargeCardHolder",a))},onVerifyOtpSuccess:l=>{l!=null&&re.saveZeniOtpTokenForCardHolder(l,a)},onCVVActivateSuccess:()=>{e(ws({chargeCardId:a}))},onBackClick:()=>{const l=_e(s.state?.pathnameStackToGoBack),m=l.poppedPathname==null||l.poppedPathname.includes("onboard")===!0?aa(w):l.poppedPathname;t(m,{state:{pathnameStackToGoBack:l.newStack}})}}})(Xc),Ko=Ne.div`
1
+ import{j as c}from"./liveblocks-DS8sOLD1.js";import{h as de,g as Ce,i as Me,u as pe,j as o,N as ba,s as Dt,n as De,t as In,o as es,p as se}from"./core-SRRzy8qJ.js";import{bt as Pe,RQ as as,RR as ts,eX as un,RS as kn,f4 as En,RT as An,RU as Dn,RV as _n,RW as Pn,f5 as wn,f6 as vn,RX as Tn,fg as Fn,fh as $a,RY as xn,RZ as ns,fa as rs,f9 as ss,R_ as cs,B_ as Bn,fj as ca,R$ as os,S0 as is,eZ as ds,eY as ls,fv as ze,fc as Rn,fb as Ln,S1 as us,fd as ms,Bv as Cs,Bu as ps,By as hs,BA as fs,fo as gs,eU as Un,S2 as Ss,S3 as bs,ft as On,S4 as ys,fu as bt,BG as Is,BD as ks,eV as fe,S5 as Qa,fy as we,fz as ve,fA as Te,gt as oa,cv as ia,S6 as da,S7 as _t,uN as za,kC as Ya,S8 as Za,Ce as ka,Cg as Qe,Ch as Pt,ks as jn,S9 as la,C2 as _a,Sa as Es,Sb as As,C5 as Ja,Sc as Ds,Qb as Xa,ff as Mn,Cb as ga,hS as _s,Sd as Nn,Se as ua,bo as Ps,Sf as ws,ge as et,gd as at,CL as vs,gc as tt,PT as Ts,Sg as Vn,co as Hn,cQ as Fs,Qa as wa,Dk as Gn,Sh as mn,CW as Pa,Si as $n,Dl as xs,QA as Bs,Dm as Rs,Er as Ls,u8 as Us,El as Os,Sj as js,Cf as ra,Sk as Ms,Sl as Ns,Sm as Vs,Sn as Hs,So as Gs,Sp as wt,Sq as $s,Cw as zn,Cp as zs,Sr as Ys,gv as Zs,CF as Yn,CJ as Zn,gu as Ks,Ss as Ws,D6 as Kn,St as qs,Su as Qs,Sv as Js,CH as Wn,Cs as qn,C8 as Qn,CB as Jn,Cz as Xn,CD as Xs,Sw as er,Sx as ec,fq as ac,fr as tc,fs as nc,Sy as nt,fk as ar,cR as vt,Sz as rc,SA as sc,SB as cc,SC as oc,CR as yt,Dd as ic,D9 as dc,CN as lc,Db as uc,D1 as mc,D3 as Cc,SD as tr,Dj as Ga,Ka as pc,SE as hc,SF as fc,SG as gc,SH as nr,SI as Sc,DG as bc,CV as rr,CQ as je,CU as yc,SJ as Ic,SK as kc,B$ as Ec,SL as sr,fe as cr,SM as Ac,C1 as Dc,C0 as Cn,SN as _c,SO as Pc,SP as wc,MH as vc,SQ as Tt,SR as Tc,xN as or,la as Fc,hI as xc,DL as Bc,SS as ir,f1 as Rc,f2 as Lc,ST as Uc,dh as Oc,fi as jc,DB as Mc,Dv as qe,bs as Nc,bJ as Vc,cA as Hc,bK as Gc,LU as $c}from"./zeni-epic-state-DcKqCCCg.js";import{I as Fe,cp as dr,k as _e,cq as lr,cr as ur,cs as zc,a as Xe,Z as Ft,ct as Yc,cu as Zc,Q as mr,c as Cr,X as pr,s as ye,W as le,U as K,ar as ya,cv as hr,cw as Kc,cx as Wc,z as re,w as va,ce as rt,cy as qc,cz as Qc,cA as Jc,q as Ta,aQ as Ye,br as xt,cB as Xc,y as Fa,i as st,m as Bt,d as J,a7 as ct,cC as eo,bE as Sa,cD as It,cE as ao,x as Rt,cF as to,au as fr,a2 as kt,cG as no,V as gr,f as Sr,cH as ro,cI as so,cJ as co,cK as oo,cL as io,cM as lo,o as Ka,cN as uo,cO as mo,cP as pt,$ as Co,cQ as po,cR as ho,cS as fo,cT as go,cU as So,a9 as bo}from"./index-BnX1nS7p.js";import{n as Ne,D as br,S as yo}from"./mui-DQ-jfgFM.js";import{a as r}from"./sentry-B2Aew07S.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-RYFll1PC.js";import{M as Ie}from"./MobileAppDrawer-DChLZMjE.js";import{d as Lt}from"./recharts-CHATJmXy.js";import{g as Ae,a as Ba,b as yr,c as xe,d as Be,e as Je,f as ea,h as aa,A as Io,i as Ut,P as ko,j as Ot,s as Ia,k as Ir,l as sa,m as kr,n as Eo,o as Er,p as Ao,S as pn}from"./SetupPagesScreen-DHP6inkV.js";import{u as Ar}from"./useInitialThreadRequest-8loDIspA.js";import ot from"./NotFoundScreen-DRRoMVDk.js";import{u as jt}from"./useChargeCardPusherEvents-iVaYEDl9.js";import{n as hn}from"./utils-D8kKiFqT.js";import{t as Do}from"./AddressScreen-DmitYkw7.js";import"./analytics-C-A3qVJh.js";import"./plaid-DWZgMqW3.js";import"./dnd-CR8sMRK3.js";import"./stripe-DMRn4zHo.js";import"./lottie-Coq2aDEW.js";import"./lexical-qJrDnJMV.js";import"./pdf-D2Xq7623.js";import"./analyticsHelper-CewoJ3Hu.js";import"./routePaths-DyfF54Mg.js";import"./BusinessVerificationPageScreen-tq2Pq8-k.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]="a5636aca-02b8-4823-96dc-0cc560dadd01",e._sentryDebugIdIdentifier="sentry-dbid-a5636aca-02b8-4823-96dc-0cc560dadd01")}catch{}})();const _o=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}},Dr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:_o(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)}),{spendManagement:{chargeCard:{cardPolicyPage:fn}}}=Xe.getLocalizedStrings(),Po=e=>Rn(e,!1),wo=e=>Ln(e.name,!1);function vo(){const e=de(),n=Ce(),{tenantEmailDomain:t}=Me(),a=pe(),s=Fe(),y=Pe(s?.loggedInUserRoleMap),[f,S]=r.useState(!1),w=r.useCallback(P=>{S(P)},[]),l=r.useCallback(()=>{w(!0)},[w]),{isAiCfoAccessEnabled:m,onAskAiCfoClick:R}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect(()=>()=>{a(as()),a(ts()),a(un())},[a]);const v=o(P=>kn(P.cardPolicyState)),u=o(P=>En(P.cardPolicyState)),M=o(P=>An(P.cardPolicyState)),x=o(P=>Dn(P.cardPolicyState)),B=o(P=>_n(P.cardPolicyState)),p=o(P=>Pn(P.cardPolicyState)),h=o(P=>wn(P.cardPolicyState)),D=o(P=>vn(P.cardPolicyState)),d=o(P=>Tn(P.cardPolicyState)),_=o(P=>P.chargeCardConfigState.receiptRequiredAboveAmount.amount),k=o(P=>P.chargeCardConfigState.fetchState);r.useEffect(()=>{v!=="Completed"&&v!=="In-Progress"&&a(Fn())},[a,v]),r.useEffect(()=>{D==="Completed"&&d===""||D==="In-Progress"||a($a())},[a,D,d]);const j=o(P=>xn(P.createCardPolicyState)),A=o(P=>ns(P.createCardPolicyState)),I=o(P=>rs(P.cardPolicyState)),L=o(P=>ss(P.cardPolicyState)),i=o(P=>cs(P.createCardPolicyState)),C=o(P=>Bn(P));r.useEffect(()=>{C.fetchState==="Not-Started"&&a(ca(!1,!1,!1))},[C.fetchState,a]);const N=r.useMemo(()=>u.map(Po),[u]),G=r.useMemo(()=>h.map(wo),[h]),U=r.useMemo(()=>C.cards.filter(P=>!dr(P.status.code)).map(Dr),[C.cards]),O=v==="Completed"&&C.fetchState==="Completed"&&k==="Completed";r.useEffect(()=>{O&&i==null&&a(os({cardsMasterList:U,defaultRequireReceiptAmount:_,suggestedAllowMerchants:M,suggestedBlockMerchants:x,suggestedAllowCategories:B,suggestedBlockCategories:p}))},[k,a,O,i,U,_,M,x,B,p]);const z=r.useMemo(()=>Lt(P=>{a($a(P))},250),[a]);r.useEffect(()=>()=>{z.cancel()},[z]);const Y=r.useCallback(P=>{z(P)},[z]),b=j.fetchState,T=t!=null?`/${t}/cards/policy`:"..",Z=r.useCallback(()=>{const P=_e(n.state?.pathnameStackToGoBack),ee=P.poppedPathname??T;e(ee,{state:{pathnameStackToGoBack:P.newStack}})},[n.state,e,T]),q=r.useCallback(()=>{e(T)},[e,T]),E=r.useCallback(P=>{a(is(P))},[a]),V=r.useCallback(P=>{const ee=lr(P);a(ds({templates:[ee]}))},[a]),Q=r.useCallback(P=>{P.length!==0&&a(ls(P))},[a]),X=r.useCallback(()=>{a(un())},[a]),g=r.useRef(b);r.useEffect(()=>{const P=g.current;g.current=b,b==="Completed"&&P!=="Completed"&&A!=null&&(a(ze({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(T))},[a,b,A,e,T]);const F=b==="Error"?j.error?.message??fn.createPolicyGenericErrorMessage:void 0;return y&&t!=null?i==null?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:w}),c.jsx(ur,{showUploadDocumentSection:!0,navBarTitle:fn.createPageTitle,onBackClick:Z,onClickMenuIcon:l,isAiCfoAccessEnabled:m,onAskAiCfoClick:R})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:w}),c.jsx(zc,{formDraft:i,vendorSearchOptions:G,categorySearchOptions:N,isVendorSearchLoading:D==="In-Progress",onVendorSearchTextChange:Y,submitState:b,submitErrorMessage:F,documentUploadState:I,uploadedFileName:L,isAiCfoAccessEnabled:m,onAskAiCfoClick:R,onBackClick:Z,onCancelClick:q,onClickMenuIcon:l,onFormChange:E,onSubmit:V,onUploadDocument:Q,onRemoveDocument:X})]}):c.jsx(ba,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:To}}}=Xe.getLocalizedStrings(),Fo=e=>Rn(e,!1),xo=e=>Ln(e.name,!1);function Bo(){const e=de(),n=Ce(),{tenantEmailDomain:t,templateId:a}=Me(),s=pe(),y=Fe(),f=Pe(y?.loggedInUserRoleMap),[S,w]=r.useState(!1),l=r.useCallback(F=>{w(F)},[]),m=r.useCallback(()=>{l(!0)},[l]),{isAiCfoAccessEnabled:R,onAskAiCfoClick:v}=xa({mobileExploreReferrer:"Card Policy"}),u=o(F=>us(F)),M=o(F=>kn(F.cardPolicyState)),x=o(F=>En(F.cardPolicyState)),B=o(F=>An(F.cardPolicyState)),p=o(F=>Dn(F.cardPolicyState)),h=o(F=>_n(F.cardPolicyState)),D=o(F=>Pn(F.cardPolicyState)),d=o(F=>wn(F.cardPolicyState)),_=o(F=>vn(F.cardPolicyState)),k=o(F=>Tn(F.cardPolicyState)),j=o(F=>Bn(F)),A=o(F=>a!=null?ms(F.cardPolicyState,a):void 0),I=r.useMemo(()=>u.templateId===a&&u.formDraft!=null?u.formDraft:A!=null?Cs(A):void 0,[u.templateId,u.formDraft,A,a]);r.useEffect(()=>{if(a==null)return;const F=u.detailFetchState.fetchState;u.templateId===a&&(F==="Completed"||F==="In-Progress")||A!=null||s(ps(a))},[s,a,u.templateId,u.detailFetchState.fetchState,A]),r.useEffect(()=>{M!=="Completed"&&M!=="In-Progress"&&s(Fn())},[s,M]),r.useEffect(()=>{_==="Completed"&&k===""||_==="In-Progress"||s($a())},[s,_,k]);const L=o(F=>F.chargeCardConfigState.receiptRequiredAboveAmount.amount);r.useEffect(()=>{j.fetchState==="Not-Started"&&s(ca(!1,!1,!1))},[j.fetchState,s]);const i=r.useMemo(()=>x.map(Fo),[x]),C=r.useMemo(()=>d.map(xo),[d]),N=r.useMemo(()=>j.cards.filter(F=>!dr(F.status.code)).map(Dr),[j.cards]);Ft({isDataReady:I!=null});const G=r.useMemo(()=>{if(I!=null)return Yc({draft:I,cardRows:N,categorySearchOptions:i,vendorSearchOptions:C,defaultRequireReceiptAmount:L,suggestedAllowMerchants:B,suggestedBlockMerchants:p,suggestedAllowCategories:h,suggestedBlockCategories:D})},[I,N,i,C,L,B,p,h,D]),[U,O]=r.useState(void 0),z=r.useRef(!1);r.useEffect(()=>{z.current||U!=null||G==null||(z.current=!0,O(G))},[U,G]);const Y=r.useCallback(F=>{O(F)},[]),b=r.useMemo(()=>Lt(F=>{s($a(F))},250),[s]);r.useEffect(()=>()=>{b.cancel()},[b]);const T=r.useCallback(F=>{b(F)},[b]),Z=u.updateFetchState.fetchState,q=t!=null?`/${t}/cards/policy`:"..",E=r.useCallback(()=>{const F=_e(n.state?.pathnameStackToGoBack),P=F.poppedPathname??q;e(P,{state:{pathnameStackToGoBack:F.newStack}})},[n.state,e,q]),V=r.useCallback(()=>{e(q)},[e,q]),Q=r.useCallback(F=>{if(a==null)return;const P=lr(F);s(hs(P)),s(fs(a))},[s,a]),X=r.useRef(Z);r.useEffect(()=>{const F=X.current;X.current=Z,Z==="Completed"&&F!=="Completed"&&(s(ze({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(q))},[s,Z,e,q]);const g=Z==="Error"?u.updateFetchState.error?.message??To.updatePolicyGenericErrorMessage:void 0;return!f||t==null||a==null?c.jsx(ba,{to:"..",replace:!0}):U!=null&&M==="Completed"&&j.fetchState==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:l}),c.jsx(Zc,{templateName:u.template?.name??"",formDraft:U,vendorSearchOptions:C,categorySearchOptions:i,isVendorSearchLoading:_==="In-Progress",onVendorSearchTextChange:T,submitState:Z,submitErrorMessage:g,isAiCfoAccessEnabled:R,onAskAiCfoClick:v,onBackClick:E,onCancelClick:V,onClickMenuIcon:m,onFormChange:Y,onSubmit:Q})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:l}),c.jsx(ur,{showUploadDocumentSection:!1,navBarTitle:u.template?.name,onBackClick:E,onClickMenuIcon:m,isAiCfoAccessEnabled:R,onAskAiCfoClick:v})]})}function _r(e,n,t){return n?e.filter(a=>a!=null&&a.trim().length>0).slice(0,t):[]}function Pr(e){return o(n=>e==null||e===""?{chips:ht,isResolved:!1}:function(t){const a=t?.fetchState,s=a==="Completed"||a==="Error";return{chips:a==="Completed"?t?.suggestedQuestions??ht:ht,isResolved:s}}(gs(n,e)),Dt)}const ht=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Ro,subheadline:Lo,pageTitle:Uo}}}}=Xe.getLocalizedStrings(),Oo=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 jo(){const e=de(),n=Ce(),{tenantEmailDomain:t}=Me(),a=pe(),s=Fe(),y=Pe(s?.loggedInUserRoleMap),[f,S]=r.useState(!1),w=r.useCallback(b=>{S(b)},[]),l=r.useCallback(()=>{w(!0)},[w]),{useFeatureGate:m}=le(),{isFeatureEnabled:R}=m(K.isAiCfoFileUploadEnabled),{isFeatureEnabled:v}=m(K.isCardPolicyEnabled),{isAiCfoAccessEnabled:u,onAskAiCfoClick:M}=xa({mobileExploreReferrer:"Card Policy"}),x=o(b=>Ss(b)),B=o(b=>xn(b.createCardPolicyState)),p=o(b=>bs(b.createCardPolicyState)),h=o(b=>p==null?[]:On(b.aiCfoState,p).filter(T=>T.kind==="creating_policy"),Dt),D=B.fetchState==="In-Progress"?Math.max(h.length,1):0,d=o(b=>ys(b.createCardPolicyState)),_=ya(B.fetchState);r.useEffect(()=>{if(_==="In-Progress"&&B.fetchState==="Completed"&&p!=null)h.forEach(b=>{a(bt({chatSessionId:p,id:b.id,entityIds:d,kind:"created_policy"}))});else if(_==="In-Progress"&&B.fetchState==="Error"&&p!=null){h.forEach(T=>{a(bt({chatSessionId:p,id:T.id,kind:"errored_policy"}))});const b=B.error?.message!=null&&B.error.message.length>0?B.error.message:Xe.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;a(ze({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:b}]}))}},[B.error?.message,B.fetchState,a,p,d,h,_]);const k=x.fetchState.fetchState;r.useEffect(()=>{k!=="Not-Started"&&k!=="Error"||a(Is())},[a,k]);const j=x.archiveFetchState.fetchState,A=ya(j);r.useEffect(()=>{A==="In-Progress"&&j==="Completed"&&a(ze({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))},[j,a,A]);const I=r.useMemo(()=>x.templates.map(Oo),[x.templates]);Ft({isDataReady:x.fetchState.fetchState==="Completed"});const L=I.length>0||D>0,i=function(b){const{hasAnyPolicies:T,isChargeCardAdmin:Z,isFileUploadEnabled:q}=b,E=de(),V=Ce(),{tenantEmailDomain:Q}=Me(),{isAiCfoOpen:X,setIsAiCfoOpen:g}=mr(),F=Cr(),P=pr(),ee=o(ce=>Un(ce)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:W,isResolved:ke}=Pr("card_policy"),Se=r.useMemo(()=>_r(W,ke,3),[W,ke]),[ge,ae]=r.useState(""),ue=P&&F&&Q!=null&&!X,oe=r.useCallback(ce=>{if(Q==null)return;const Ea=ye(V.state?.pathnameStackToGoBack,V.pathname);E(`/${Q}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:Ea,referrer:"card_policy_hero",aiCfoInitialQuestion:ce,aiCfoShouldSubmit:ce!=null&&ce.trim().length>0}})},[V.pathname,V.state,E,Q]),te=r.useCallback(ce=>{ce.trim().length!==0&&(ae(""),oe(ce))},[oe]),Ze=r.useCallback(()=>{const ce=ge.trim();ce.length!==0&&(ae(""),oe(ce))},[ge,oe]),Ee=r.useCallback(()=>{},[]),ne=r.useCallback(ce=>{ae(ce)},[]),Ke=r.useCallback(()=>{g(!0)},[g]),Re=r.useCallback(()=>{oe(void 0)},[oe]);return r.useMemo(()=>{if(ue&&!T&&Z)return{aiAgentName:Uo,headline:Ro,subheadline:Lo,promptChips:Se,composer:{currentInput:ge,isSubmitting:ee,isFileUploadEnabled:q,onInputChange:ne,onSubmit:Ze,onStopSubmit:Ee},onPromptClick:te,onOpenSidePanel:Ke,onOpenFullView:Re,dataTestIdPrefix:"card-policy-ai-cfo-hero"}},[ge,T,ue,Z,q,ee,ne,Re,Ke,te,Ee,Ze,Se])}({hasAnyPolicies:L,isChargeCardAdmin:y,isFileUploadEnabled:R}),C=v&&i!=null?c.jsx(hr,{...i}):null,N=u&&C==null,G=r.useCallback(()=>{const b=_e(n.state?.pathnameStackToGoBack),T=b.poppedPathname??"..";e(T,{state:{pathnameStackToGoBack:b.newStack}})},[n.state,e]),U=r.useCallback(()=>{t!=null&&e(`/${t}/cards/policy/new`)},[e,t]),O=r.useCallback(b=>{t!=null&&e(`/${t}/cards/policy/${b}/edit`)},[e,t]),z=r.useCallback(b=>{a(ks(b))},[a]),Y=x.fetchState.fetchState;return!L&&Y!=="Completed"&&Y!=="Error"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:w}),c.jsx(Kc,{onBackClick:G,onNewPolicyClick:U,onClickMenuIcon:l,isAiCfoAccessEnabled:u,onAskAiCfoClick:M})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:w}),c.jsx(Wc,{policies:I,archivingTemplateId:x.archiveTargetTemplateId,pendingCreationCount:D,onBackClick:G,onNewPolicyClick:U,onEditPolicyClick:O,onArchivePolicyClick:z,onClickMenuIcon:l,policyAiCfoHero:C,isAiCfoAccessEnabled:N,onAskAiCfoClick:M})]})}function Mo(){const e=de(),{cardId:n}=Me(),t=pe(),a=re.getSignedInUser(),s=o(W=>fe(W)),y=Fe(),f=Pe(y?.loggedInUserRoleMap),{useFeatureGate:S}=le();if(a==null)throw Error("Can't access Add To Wallet Page without signing in...");const[w,l]=r.useState(!1),m=o(W=>Qa(W).firstViewAfterActivation);if(n==null)throw Error("Empty card id is not valid...");const R=s.userRole.includes("charge_card_user"),{isFeatureEnabled:v}=S(K.isChargeCardFeatureEnabled),u=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:M}=S(K.isDebitCardFeatureEnabled),x=we(s),B=ve(s),p=Te(M,s),h=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,D=xe({isDebitCardFeatureEnabled:M,isBankingOnlyTenant:p}),d=Be({isCardsOnlyTenant:x,isChargeCardFeatureEnabled:v,isBookKeepingTenant:B,isDebitCardProductVisible:D,chargeCardsCreditAccountLimit:h}),_=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,k=o(W=>oa(W,s.companyId)),j=ia(k.controllers),{creditAccount:A,creditAccountRepayment:I}=o(W=>da(W)),L=o(W=>W.classListState.fetchState),i=!R&&d&&u,C=o(W=>_t(W,n,i,d)),[N,G]=r.useState(!1),U=C.chargeCard,O=U?.cardCreatedByUser?.userId,z=o(W=>O!=null?za(W.userRoleState,O):void 0),Y=z?.accountingClassIDs[0],b=o(W=>Y!=null?Ya(W.classState,{classId:Y,reportId:"class_list"}):void 0),T=U?.cardHolderUser?.userId,Z=o(W=>T!=null?za(W.userRoleState,T):void 0),q=Z?.accountingClassIDs[0],E=o(W=>q!=null?Ya(W.classState,{classId:q,reportId:"class_list"}):void 0),V=U?.type.code==="business_physical_credit_card"||U?.type.code==="business_physical_debit_card",Q=U?.type.code==="business_physical_debit_card";r.useEffect(()=>{m&&w===!1&&V&&(l(!0),setTimeout(()=>{t(Za()),Q&&t(ze({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[m,w,V,Q]),r.useEffect(()=>{N||C.fetchState==="Completed"||C.fetchState==="In-Progress"||n==null||(G(!0),t(ka(n,i,!1)))},[N,C,n,t]),r.useEffect(()=>{if(C.fetchState==="Completed"&&(V===!1||V&&U?.status?.code!=="active"||U?.cardHolderUserId!==a.userId||m===!1&&w===!1||U?.type.code==="business_physical_debit_card"||U?.type.code==="business_virtual_debit_card")){const W=Ae(s.tenantEmailDomain,n,a,U,m);e(W)}},[C.fetchState,m,V]),r.useEffect(()=>{A.fetchState!=="Completed"&&A.fetchState!=="In-Progress"&&d&&u&&f&&t(Qe()),I.fetchState!=="Completed"&&I.fetchState!=="In-Progress"&&d&&u&&f&&t(Pt()),L!=="Completed"&&L!=="In-Progress"&&t(jn())},[A.fetchState,I.fetchState,t,d,u,f,L]);const X=()=>{if(a!=null&&n!=null){t(Za());const W=Ae(s.tenantEmailDomain,n,a);e(W)}},g=U?.type.code==="business_physical_debit_card"||U?.type.code==="business_virtual_debit_card",F=Je(d,D,_,u),P=Ba(d,u,f,A,I),ee=yr(g,C);return C.fetchState!=="Completed"?c.jsx(va,{fetchState:"In-Progress"}):c.jsxs(c.Fragment,{children:[c.jsx(rt,{showConfetti:m}),c.jsx(qc,{onGotItClick:X,isDebitCard:U?.type.code==="business_physical_debit_card",controllerEmails:j,isChargeCardFeatureEnabled:d,isDebitCardFeatureEnabled:D,isDebitCardSetupEnabled:_,isChargeCardSetupEnabled:u,productInformation:F,creditAccountInformation:P,debitAccountInformation:ee,chargeCardDetailView:C,creditAccount:A,classListFetchState:L,creditAccountRepayment:I,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:b?.className,cardHolderRoles:Z?.userRoles,cardHolderDepartmentName:E?.className})]})}const wr="charge-card-transaction-update",vr="charge-card-transaction-created",Tr="charge-card-transaction-declined",Fr="charge-card-transaction-updated",xr="charge-card-transaction-receipt-uploaded",ma="charge-card-status-update",Mt="charge-card-spending-updated",it="credit-account-balance-updated",dt="charge-card-created",Nt="charge-card-limit-updated",Vt="charge-card-limit-reset",Ht="charge-card-renamed",No="charge-card-department-updated",Br="charge-card-repayment-completed",Rr="charge-card-payment-date-updated",Ra="charge-card-cashback-redeemed",La="charge-card-cashback-earned",Ca=(e,n)=>e==null||e===""?[]:n.map(t=>`private-encrypted-${e}.${t}`),Vo=[La,Ra],Ho=De(function(e){const n=la(e);return{insightsData:n.insight,cashbackByPeriod:n.cashbackByPeriod,uiState:n.uiState,cashbackSummary:n.cashbackSummary}},function(e){return{onColumnSortConfigChanged:(n,t)=>{e(Es({uiState:{sortKey:n,sortOrder:t}}))}}})(Jc);function Go(){const e=de(),n=pe(),t=Ce(),a=re.getSignedInUser(),s=o(M=>fe(M)),{useFeatureGate:y}=le(),{isFeatureEnabled:f}=y(K.isCardsCommentingEnabled),[S,w]=r.useState(!1),l=o(M=>la(M)),m=Ar(s.companyId,{clearParams:l.fetchState==="Completed"}),R=r.useCallback(()=>{const M=_e(t.state?.pathnameStackToGoBack),x=M.poppedPathname??$o(s.tenantEmailDomain);e(x,{state:{pathnameStackToGoBack:M.newStack}})},[e,t,s.tenantEmailDomain]),v=ea(s);if(jt({events:Ca(v,Vo),onEvent:M=>{switch(M){case La:case Ra:return void n(_a(!0))}},onSubscribed:()=>{n(_a(!0))}}),r.useEffect(()=>{S||l.fetchState==="Completed"||l.fetchState==="In-Progress"||(w(!0),n(_a()))},[S,l,n]),a==null)throw Error("Can't access cashback detail page without signing in...");const u=l.cashbackSummary?.cashbackEarned?.amount!=null&&l.fetchState!=="Not-Started";return l.fetchState!=="In-Progress"||u?(l.cashbackSummary?.cashbackEarned?.amount??0)===0&&l.fetchState==="Completed"?c.jsx(ot,{}):c.jsx(Ho,{onBackClick:R,isCardsCommentingEnabled:f,initialOpenThreadRequest:m}):c.jsx(Qc,{onBackClick:R})}const $o=e=>`/${e}/cards`,zo={containerWidth:new Fa(100,58)},Yo=({appContent:e})=>{const n=Ta(),t=pe(),a=de(),{cardId:s}=Me(),y=Ce(),{useDynamicConfig:f}=le(),[S,w]=r.useState(!1),[l,m]=r.useState(!1),[R,v]=r.useState(!1),[u,M]=r.useState(!1),x=re.getSignedInUser();if(x==null)throw Error("Can't access onboarding card page without signing in...");const B=o(E=>fe(E));if(s==null)throw Error("Empty card id is not valid...");const{configValue:p}=f(Ye.zeniCardsConfig),h=p.max_charge_card_activation_attempts_by_card_id,D=o(E=>As(E,s)),d=D.chargeCard,_=o(E=>E.chargeCardConfigState.fetchState),{useFeatureGate:k}=le(),{isFeatureEnabled:j}=k(K.isChargeCardFeatureEnabled),{isFeatureEnabled:A}=k(K.isDebitCardFeatureEnabled),I=Te(A,B),L=xe({isDebitCardFeatureEnabled:A,isBankingOnlyTenant:I}),i=!!B.companyChargeCardInfo?.info?.isChargeCardEnabled,C=B.userRole.includes("charge_card_user"),N=we(B),G=ve(B),U=B.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,O=Be({isCardsOnlyTenant:N,isChargeCardFeatureEnabled:j,isBookKeepingTenant:G,isDebitCardProductVisible:L,chargeCardsCreditAccountLimit:U}),z=!C&&O&&i;r.useEffect(()=>{S===!1&&_!=="In-Progress"&&_!=="Completed"&&(t(Ja()),w(!0)),l===!1&&D.fetchState==="Not-Started"&&(m(!0),t(ka(s,z,O)))},[l,D.fetchState,S,_]);const Y=d?.type.code==="business_physical_credit_card"||d?.type.code==="business_physical_debit_card";r.useEffect(()=>{if(D.fetchState==="Completed"){if(R===!1&&(Y===!1||Y&&d?.status?.code!=="inactive"||d?.cardHolderUserId!==x.userId)){const E=Ae(B.tenantEmailDomain,s,x,d,!0),V=ye(y.state?.pathnameStackToGoBack,y.pathname);a(E,{state:{pathnameStackToGoBack:V}})}else if(R&&D.isRefreshingViewInBackground===!1&&d?.status?.code==="active"){t(Ds({chargeCardId:s}));const E=Ae(B.tenantEmailDomain,s,x,d,!0),V=ye(y.state?.pathnameStackToGoBack,y.pathname);t(Xa()),a(E,{state:{pathnameStackToGoBack:V}})}}},[D.fetchState,d?.type.code,R,D.isRefreshingViewInBackground]);const b=re.getZeniOtpTokenForCardHolder(s),T=o(E=>Mn(E.userState,x.userId)),Z=()=>{d?.status?.code!=="active"&&t(ga(s,!0))};r.useEffect(()=>{D.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&d?.cardActivationAttemptHistory.some(E=>E.statusCode==="success")===!0&&R===!1&&(setTimeout(Z,3e3),v(!0))},[D.updatePhysicalChargeCardAttemptFetchState.fetchState,d?.cardActivationAttemptHistory]);const q=E=>{M(E)};if(_!=="Completed"||d==null)return c.jsx(va,{fetchState:"In-Progress"});if(d.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(T?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(Wo,{children:[c.jsx(Ie,{isAppContentDrawerOpen:u,handleDrawerToggle:q}),c.jsx(Zo,{cardId:s,card:d,shippingAddressId:d.shippingAddressId,phone:T.phone,signedInUser:x,isSandboxEnv:xt(),chargeCardDetailState:D,signedInUserToken:b,navigate:a,currentTenant:B,location:y,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(Ko,{windowSize:n,children:e}):null]})},Zo=De(function(e,{chargeCardDetailState:n,shippingAddressId:t,location:a,cardId:s}){const y=_s(e.addressState,t);if(y==null)throw Error("Can't access shippingAddress.");const f=Nn(e,s),S=n.updateStatus,w=ua(e,!1,!1,!1);let l=!1;w.fetchState==="Completed"&&w.cards.length<=1&&(l=!0);const m=a.state?.message==="comingFromV2UrlPath";return{showActivatePage:n.chargeCard?.providerCardCreateTime!=null&&n.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Ps())||m,showMenuIcon:l,shippingAddress:y,vgsVaultId:st.cardVaultId,twoFAView:f,activationWaitStatus:S,isRefreshingViewInBackground:n.isRefreshingViewInBackground}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:y,chargeCardDetailState:f}=n,S=f.chargeCard?.cardProviderID,{tenantEmailDomain:w}=y;return{onGetOtp:l=>{S!=null&&e(tt(l,"ChargeCardHolder",a))},onUpdatePhysicalChargeCardAttempt:l=>{e(vs(a,l))},onResendOtp:l=>{S!=null&&e(at(l,"ChargeCardHolder",a))},onVerifyOtp:(l,m)=>{S!=null&&e(et(l,m,"ChargeCardHolder",a))},onVerifyOtpSuccess:l=>{l!=null&&re.saveZeniOtpTokenForCardHolder(l,a)},onCVVActivateSuccess:()=>{e(ws({chargeCardId:a}))},onBackClick:()=>{const l=_e(s.state?.pathnameStackToGoBack),m=l.poppedPathname==null||l.poppedPathname.includes("onboard")===!0?aa(w):l.poppedPathname;t(m,{state:{pathnameStackToGoBack:l.newStack}})}}})(Xc),Ko=Ne.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: ${e=>`${zo.containerWidth.value(e.windowSize)}%`};
@@ -1 +1 @@
1
- import{j as m}from"./liveblocks-UQZFqaDN.js";import{a as g}from"./sentry-C0E1AQIe.js";import{h as w,u as x,g as T,i as k,j as O,n as E}from"./core-Ctjv24YM.js";import{z as N,bc as P,x as F,d as V,f as j,af as b,bd as A,au as L,av as U,s as z}from"./index-BJyv5Z6x.js";import{eV as D,gg as B,tz as M,gb as _,c6 as R,Pg as G,bn as Y,rz as H,rn as Q,l2 as Z,mD as S,Ph as $,bE as q,cy as C,mN as J,mQ as K}from"./zeni-epic-state-ym9j-rvL.js";import"./mui-DU4JyJ-_.js";import{d as W}from"./routePaths-C7N5VwuK.js";import{M as X}from"./MobileAppDrawer-DQwHFEP8.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new n.Error().stack;t&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[t]="1b7d0cd5-7a1a-4721-96b4-3973004aca60",n._sentryDebugIdIdentifier="sentry-dbid-1b7d0cd5-7a1a-4721-96b4-3973004aca60")}catch{}})();const ee=E(function(n){const t=_(n),i=N.getSignedInUser(),l=D(n),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=G(n.companyConfigState),a=n.countryListState?.byCountryListCode?.nationalityCountryList?.countries??[];return{isCompanyVerified:t.companyView?.company?.company?.companyBillPayInfo?.companyVerificationStatus?.code==="verified",companyPassportView:t,allIndustries:e.companyIndustries??[],allNationalityCountries:a,isDisabled:f,authParams:p,filesEndPoint:`${L.fileMicroServiceBaseUrl}`,isZeniUser:Y(i)}},function(n,t){const{companyId:i,currentTenant:l,navigate:c,location:p}=t,{tenantEmailDomain:f}=l;return{onScheduleClick:e=>{let a=e.href;a.includes("http")||(a="https://".concat(a)),window.open(a,"_blank")},onSaveAll:()=>{n(K())},onAddressClick:e=>{const a=W(f,e),o=z(p.state?.pathnameStackToGoBack,p.pathname);c(a,{state:{pathnameStackToGoBack:o}})},onResetClick:()=>{n(J({companyId:i}))},onBackClick:()=>{c("../")},onCompanyDetailsChanged:e=>{const{companyInfo:a,incInfo:o,taxDetails:r,zeniFinanceTeam:d}=e,{website:u}=a,{meetingLink:y}=d,{incDate:s}=o,{taxesFiledYears:h}=r,v={companyInfo:{...a,website:u!=""&&u!=null?C(u):void 0,meetingLink:y!=""&&y!=null?C(y):void 0,industry:a.industry.selectedOption,companyIndustryType:a.companyIndustryType?.selectedOption??void 0,companySubIndustry:a.companySubIndustry?.selectedOption??void 0,businessModel:a.businessModel.selectedOption??"",companySourceOfFunds:a.companySourceOfFunds?.selectedOption,companySourceOfFundsDescription:a.companySourceOfFundsDescription??void 0,countriesOfOperations:a.countriesOfOperations?.selectedOptions?.map(I=>I.length===2?I:U(I))??[],transactionVolume:a.transactionVolume?.selectedOption??void 0,transactionVolumeDescription:a.transactionVolumeDescription??void 0,regulatedStatus:a.regulatedStatus??void 0,regulatedStatusDescription:a.regulatedStatusDescription??void 0,usNexus:a.usNexus??void 0,usNexusTypes:a.usNexusTypes?.selectedOptions??[],purposeOfAccount:a.purposeOfAccount?.selectedOption??void 0,purposeOfAccountDescription:a.purposeOfAccountDescription??void 0},incInfo:{typeOfInc:o.typeOfInc.selectedOption??"",stateOfInc:o.stateOfInc.selectedOption??"",incDate:s!=null?q(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]}};n(S({companyDetails:v}))},onPrimaryContactDetailsUpdated:e=>{n(S({primaryContact:{userId:e.userId,email:e.email.trim(),firstName:e.name.firstName,lastName:e.name.lastName}}))},onNewCompanyOfficerAdded:e=>{n(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=>{n($(e))},onCompanyOfficerUpdated:e=>{n(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=>{n(Z({files:e}))},onDeleteFile:e=>{n(Q(e))},onEditFileName:(e,a)=>{n(H(e,a.split(".")[0]))}}})(A);function de(){const n=w(),t=x(),i=T(),{tenantEmailDomain:l}=k(),[c,p]=g.useState(!1),[f,e]=g.useState(!1),a=O(s=>s.companyViewState.passportView.fetchState),o=O(s=>s.companyConfigState.fetchState),r=O(s=>D(s)),d=r.companyId??N.getSignedInUserTenant(l)?.companyId;if(N.getSignedInUser()==null)throw Error("Can't access company details page without signing in...");g.useEffect(()=>{c||a!=="Not-Started"||d==null||(p(!0),t(B(d)))},[c,a,d,t]),g.useEffect(()=>{o==="Not-Started"&&t(M())},[o,t]);const u=s=>{e(s)},y=a==="Not-Started"||a==="In-Progress"||o==="Not-Started"||o==="In-Progress";return d!=null&&a==="Error"?m.jsx(P,{onGoHome:()=>n("../",{replace:!0}),onReload:()=>window.location.reload()}):m.jsxs(m.Fragment,{children:[m.jsx(F,{analytics:V,onLoad:s=>s.trackPageLoaded(j.Event.companyPassport,b(i)?"Settings":"Company Passport")}),b(i)?m.jsx(X,{isAppContentDrawerOpen:f,handleDrawerToggle:u}):null,m.jsx(ee,{companyId:d,navigate:n,location:i,isLoading:y,currentTenant:r,isSettings:b(i),onClickMenuIcon:()=>{u(!0)}})]})}export{de as C};
1
+ import{j as m}from"./liveblocks-DS8sOLD1.js";import{a as g}from"./sentry-B2Aew07S.js";import{h as w,u as x,g as T,i as k,j as O,n as E}from"./core-SRRzy8qJ.js";import{z as N,bc as P,x as F,d as V,f as j,af as b,bd as A,au as L,av as U,s as z}from"./index-BnX1nS7p.js";import{eV as D,gg as B,tz as M,gb as _,c6 as R,Pg as G,bn as Y,rz as H,rn as Q,l2 as Z,mD as S,Ph as $,bE as q,cy as C,mN as J,mQ as K}from"./zeni-epic-state-DcKqCCCg.js";import"./mui-DQ-jfgFM.js";import{d as W}from"./routePaths-DyfF54Mg.js";import{M as X}from"./MobileAppDrawer-DChLZMjE.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new n.Error().stack;t&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[t]="1b7d0cd5-7a1a-4721-96b4-3973004aca60",n._sentryDebugIdIdentifier="sentry-dbid-1b7d0cd5-7a1a-4721-96b4-3973004aca60")}catch{}})();const ee=E(function(n){const t=_(n),i=N.getSignedInUser(),l=D(n),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=G(n.companyConfigState),a=n.countryListState?.byCountryListCode?.nationalityCountryList?.countries??[];return{isCompanyVerified:t.companyView?.company?.company?.companyBillPayInfo?.companyVerificationStatus?.code==="verified",companyPassportView:t,allIndustries:e.companyIndustries??[],allNationalityCountries:a,isDisabled:f,authParams:p,filesEndPoint:`${L.fileMicroServiceBaseUrl}`,isZeniUser:Y(i)}},function(n,t){const{companyId:i,currentTenant:l,navigate:c,location:p}=t,{tenantEmailDomain:f}=l;return{onScheduleClick:e=>{let a=e.href;a.includes("http")||(a="https://".concat(a)),window.open(a,"_blank")},onSaveAll:()=>{n(K())},onAddressClick:e=>{const a=W(f,e),o=z(p.state?.pathnameStackToGoBack,p.pathname);c(a,{state:{pathnameStackToGoBack:o}})},onResetClick:()=>{n(J({companyId:i}))},onBackClick:()=>{c("../")},onCompanyDetailsChanged:e=>{const{companyInfo:a,incInfo:o,taxDetails:r,zeniFinanceTeam:d}=e,{website:u}=a,{meetingLink:y}=d,{incDate:s}=o,{taxesFiledYears:h}=r,v={companyInfo:{...a,website:u!=""&&u!=null?C(u):void 0,meetingLink:y!=""&&y!=null?C(y):void 0,industry:a.industry.selectedOption,companyIndustryType:a.companyIndustryType?.selectedOption??void 0,companySubIndustry:a.companySubIndustry?.selectedOption??void 0,businessModel:a.businessModel.selectedOption??"",companySourceOfFunds:a.companySourceOfFunds?.selectedOption,companySourceOfFundsDescription:a.companySourceOfFundsDescription??void 0,countriesOfOperations:a.countriesOfOperations?.selectedOptions?.map(I=>I.length===2?I:U(I))??[],transactionVolume:a.transactionVolume?.selectedOption??void 0,transactionVolumeDescription:a.transactionVolumeDescription??void 0,regulatedStatus:a.regulatedStatus??void 0,regulatedStatusDescription:a.regulatedStatusDescription??void 0,usNexus:a.usNexus??void 0,usNexusTypes:a.usNexusTypes?.selectedOptions??[],purposeOfAccount:a.purposeOfAccount?.selectedOption??void 0,purposeOfAccountDescription:a.purposeOfAccountDescription??void 0},incInfo:{typeOfInc:o.typeOfInc.selectedOption??"",stateOfInc:o.stateOfInc.selectedOption??"",incDate:s!=null?q(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]}};n(S({companyDetails:v}))},onPrimaryContactDetailsUpdated:e=>{n(S({primaryContact:{userId:e.userId,email:e.email.trim(),firstName:e.name.firstName,lastName:e.name.lastName}}))},onNewCompanyOfficerAdded:e=>{n(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=>{n($(e))},onCompanyOfficerUpdated:e=>{n(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=>{n(Z({files:e}))},onDeleteFile:e=>{n(Q(e))},onEditFileName:(e,a)=>{n(H(e,a.split(".")[0]))}}})(A);function de(){const n=w(),t=x(),i=T(),{tenantEmailDomain:l}=k(),[c,p]=g.useState(!1),[f,e]=g.useState(!1),a=O(s=>s.companyViewState.passportView.fetchState),o=O(s=>s.companyConfigState.fetchState),r=O(s=>D(s)),d=r.companyId??N.getSignedInUserTenant(l)?.companyId;if(N.getSignedInUser()==null)throw Error("Can't access company details page without signing in...");g.useEffect(()=>{c||a!=="Not-Started"||d==null||(p(!0),t(B(d)))},[c,a,d,t]),g.useEffect(()=>{o==="Not-Started"&&t(M())},[o,t]);const u=s=>{e(s)},y=a==="Not-Started"||a==="In-Progress"||o==="Not-Started"||o==="In-Progress";return d!=null&&a==="Error"?m.jsx(P,{onGoHome:()=>n("../",{replace:!0}),onReload:()=>window.location.reload()}):m.jsxs(m.Fragment,{children:[m.jsx(F,{analytics:V,onLoad:s=>s.trackPageLoaded(j.Event.companyPassport,b(i)?"Settings":"Company Passport")}),b(i)?m.jsx(X,{isAppContentDrawerOpen:f,handleDrawerToggle:u}):null,m.jsx(ee,{companyId:d,navigate:n,location:i,isLoading:y,currentTenant:r,isSettings:b(i),onClickMenuIcon:()=>{u(!0)}})]})}export{de as C};
@@ -1,4 +1,4 @@
1
- import{j as C}from"./liveblocks-UQZFqaDN.js";import{a}from"./sentry-C0E1AQIe.js";import{u as w,g as D,j as m,N as v}from"./core-Ctjv24YM.js";import{LQ as _,eV as A,f_ as L,o6 as O,gp as E,fZ as j,fw as U,LX as F}from"./zeni-epic-state-ym9j-rvL.js";import{u as $,z as p,L as g,a as k,o as H}from"./index-BJyv5Z6x.js";import{n as z}from"./mui-DU4JyJ-_.js";import{t as Q}from"./getLocaleForTenant-DnliJT-u.js";import{g as P,Q as R}from"./QBOConnectionScreen-BmcSCHav.js";import"./recharts-RL5R0Iqz.js";import"./analytics-BlxwN6GD.js";import"./plaid-Dtkg2fMC.js";import"./dnd-DdE4ICzz.js";import"./stripe-DMRn4zHo.js";import"./lottie-h9wdJ9gi.js";import"./lexical-z-P2V9ug.js";import"./pdf-BK4Cbxeo.js";import"./utils-hcCBORos.js";import"./empty-BgBFHjf_.js";import"./pdf-lib-BWuwD2_b.js";import"./index-DrylXWCT.js";import"./url-DASTrDxO.js";import"./index-B6LHkFfA.js";import"./decodeURIComponentSafe-Z8As9uQN.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new t.Error().stack;i&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[i]="29e09035-c883-4bb8-9937-baa69157deeb",t._sentryDebugIdIdentifier="sentry-dbid-29e09035-c883-4bb8-9937-baa69157deeb")}catch{}})();const V=z.div`
1
+ import{j as C}from"./liveblocks-DS8sOLD1.js";import{a}from"./sentry-B2Aew07S.js";import{u as w,g as D,j as m,N as v}from"./core-SRRzy8qJ.js";import{LQ as _,eV as A,f_ as L,o6 as O,gp as E,fZ as j,fw as U,LX as F}from"./zeni-epic-state-DcKqCCCg.js";import{u as $,z as p,L as g,a as k,o as H}from"./index-BnX1nS7p.js";import{n as z}from"./mui-DQ-jfgFM.js";import{t as Q}from"./getLocaleForTenant-DHWNDQcY.js";import{g as P,Q as R}from"./QBOConnectionScreen-Dxk5EKMF.js";import"./recharts-CHATJmXy.js";import"./analytics-C-A3qVJh.js";import"./plaid-DWZgMqW3.js";import"./dnd-CR8sMRK3.js";import"./stripe-DMRn4zHo.js";import"./lottie-Coq2aDEW.js";import"./lexical-qJrDnJMV.js";import"./pdf-D2Xq7623.js";import"./utils-D8kKiFqT.js";import"./empty-Btqk4ZK3.js";import"./pdf-lib-fB9Fkl6A.js";import"./index-DiKyQs4W.js";import"./url-BOKPP8B2.js";import"./index-6PBzTIZ2.js";import"./decodeURIComponentSafe-Bz-26BXW.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new t.Error().stack;i&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[i]="29e09035-c883-4bb8-9937-baa69157deeb",t._sentryDebugIdIdentifier="sentry-dbid-29e09035-c883-4bb8-9937-baa69157deeb")}catch{}})();const V=z.div`
2
2
  display: flex;
3
3
  flex: 1 1 auto;
4
4
  flex-direction: row;
@@ -0,0 +1 @@
1
+ import{j as i}from"./liveblocks-DS8sOLD1.js";import{z as n}from"./index-BnX1nS7p.js";import{g as d}from"./QBOConnectionScreen-Dxk5EKMF.js";import"./sentry-B2Aew07S.js";import{g as p,N as s}from"./core-SRRzy8qJ.js";import"./zeni-epic-state-DcKqCCCg.js";import"./recharts-CHATJmXy.js";import"./mui-DQ-jfgFM.js";import"./analytics-C-A3qVJh.js";import"./plaid-DWZgMqW3.js";import"./dnd-CR8sMRK3.js";import"./stripe-DMRn4zHo.js";import"./lottie-Coq2aDEW.js";import"./lexical-qJrDnJMV.js";import"./pdf-D2Xq7623.js";import"./utils-D8kKiFqT.js";import"./empty-Btqk4ZK3.js";import"./pdf-lib-fB9Fkl6A.js";import"./index-DiKyQs4W.js";import"./url-BOKPP8B2.js";import"./index-6PBzTIZ2.js";import"./decodeURIComponentSafe-Bz-26BXW.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new t.Error().stack;o&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[o]="817363c8-7f1d-4590-b58b-cef70b99ca15",t._sentryDebugIdIdentifier="sentry-dbid-817363c8-7f1d-4590-b58b-cef70b99ca15")}catch{}})();const U=()=>{const t=p(),{code:o,realmId:r,state:e}=d(t.search),m=n.getSignedInUser()?.userId??"";if(f(o,r,e,m)===!0){const a=`../../${e}/onboarding?code=${o}&realmId=${r}&state=auth_flow`;return i.jsx(s,{to:a})}return i.jsx(s,{to:"../../"})},f=(t,o,r,e)=>t!=""&&o!=""&&r!=""&&e!=null&&e!="";export{U as default,f as hasValidParams};
@@ -0,0 +1,30 @@
1
+ import{j as o}from"./liveblocks-DS8sOLD1.js";import{t as ft,A as Ne}from"./AddressScreen-DmitYkw7.js";import yt from"./NotFoundScreen-DRRoMVDk.js";import{a as d}from"./sentry-B2Aew07S.js";import{h as Ce,g as ke,u as H,i as Ie,j as _,N as j,n as Ee,l as ht,o as bt,p as Q}from"./core-SRRzy8qJ.js";import{$ as _e,I as ve,z as $,W as xe,U as M,B as St,s as N,x as ce,d as K,ap as nt,f as Ae,aq as Ct,q as kt,ar as $e,i as he,as as It,o as Ge,at as ze,au as Et,av as Qe,aw as _t}from"./index-BnX1nS7p.js";import{eV as W,fS as vt,fA as Oe,fy as Te,bs as xt,o4 as At,fO as Ot,bS as Tt,tj as wt,tm as Pt,MP as Dt,MQ as Ft,MR as jt,xH as Ut,Er as Bt,u8 as Vt,MS as Rt,k6 as be,k9 as at,Mk as Lt,bY as Mt,c6 as ue,tN as we,ty as Nt,MT as de,tO as ot,Kd as $t,la as st,MU as Gt,MV as zt,rg as Qt,hn as Kt,Mc as me,hk as qt,Md as Zt,xW as Ht,rk as Wt,hc as Yt,hf as Ke,MW as it,MX as Jt,D_ as Xt,MY as en,E2 as tn,tp as nn,tA as Se,MZ as an,M_ as on,k4 as sn,k7 as rn,t_ as cn,tM as dn,bE as qe,cy as un,tZ as Ze,rz as ln,rn as pn,l2 as mn,ge as gn,gd as fn,gc as yn,M$ as hn,ts as bn,t$ as Sn,u2 as Cn,u5 as kn,ub as In}from"./zeni-epic-state-DcKqCCCg.js";import{n as Pe}from"./mui-DQ-jfgFM.js";import{g as En,h as _n,q as ae}from"./QBOConnectionScreen-Dxk5EKMF.js";import{u as vn}from"./useEmailConnectResultRefresh-DEaO6bJX.js";import{u as xn}from"./useChargeCardPusherEvents-iVaYEDl9.js";import{u as An}from"./plaid-DWZgMqW3.js";import"./recharts-CHATJmXy.js";import"./analytics-C-A3qVJh.js";import"./dnd-CR8sMRK3.js";import"./stripe-DMRn4zHo.js";import"./lottie-Coq2aDEW.js";import"./lexical-qJrDnJMV.js";import"./pdf-D2Xq7623.js";import"./utils-D8kKiFqT.js";import"./empty-Btqk4ZK3.js";import"./pdf-lib-fB9Fkl6A.js";import"./index-DiKyQs4W.js";import"./url-BOKPP8B2.js";import"./index-6PBzTIZ2.js";import"./decodeURIComponentSafe-Bz-26BXW.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="c91c6ab0-7bab-4158-8cda-0b49f2d9e587",t._sentryDebugIdIdentifier="sentry-dbid-c91c6ab0-7bab-4158-8cda-0b49f2d9e587")}catch{}})();const On=Ee(function(t,s){const n=[];s.isApAgingFeatureEnabled===!1&&n.push("accounts_payable_aging"),s.isArAgingFeatureEnabled===!1&&n.push("accounts_receivable_aging"),s.shouldFetchZeniAccountsPromoCard===!1&&n.push("zeni_accounts_promo_card"),s.shouldFetchRewardsPlanCard===!1&&n.push("rewards_card"),s.isExpenseAutomationEnabledForUser===!1&&n.push("expense_automation_card");const a=Ot(t,n,s.signedInUser,s.isExpenseAutomationFeatureEnabledV2,s.isExpenseAutomationEnabledForUser,s.isTreasuryEnabled);return{dashboardFetchState:Tt(a.reportsInOrder.map(c=>({fetchState:c.fetchState,error:c.error}))).fetchState}},function(t,s){const{themeState:n,navigate:a,location:c}=s;return{onZeniLogoClick:()=>{n.toggle()},onDashboardFetchDone:()=>{const u=N(c.state?.pathnameStackToGoBack,c.pathname);a("../../dashboard",{state:{pathnameStackToGoBack:u,message:"activation"}})}}})(Ct),Tn=()=>{const t=Ce(),s=ke(),n=H(),a=_e(),[c,u]=d.useState(!1),[h,I]=d.useState(!1),{tenantEmailDomain:e}=Ie(),i=ve(),l=$.getSignedInUser(),{useFeatureGate:p}=xe(),{isFeatureEnabled:O}=p(M.isApAgingFeatureEnabled),{isFeatureEnabled:r}=p(M.isArAgingFeatureEnabled),{isFeatureEnabled:m}=p(M.isDepositAccountsFeatureEnabled),{isFeatureEnabled:v}=p(M.isReferralFeatureEnabled),{isFeatureEnabled:E}=p(M.isExpenseAutomationEnabledV2),{isFeatureEnabled:g}=p(M.isDebitCardFeatureEnabled),U=St(),b=_(k=>W(k)),{isFeatureEnabled:P}=p(M.isTreasuryEnabled),V=b.company!=null&&vt(b.company),y=P&&V,S=_(k=>k.onboardingCustomerViewState.fetchState),x=b.excludedResources,B=b.companyId??$.getSignedInUserTenant(e)?.companyId;if(l==null)throw Error("Can't access onboarding flow without signing in...");const D=Oe(g,b),A=Te(b),w=[],q=x?.resources?.find(k=>k.resource==="/reports/top_expenses")==null,G=x?.resources?.find(k=>k.resource==="/reports/task_card")==null,Y=b?.userRole!=null&&xt(b?.userRole),J=x?.resources?.find(k=>k.resource==="/bills")==null&&!Y,z=x?.resources?.find(k=>k.resource==="/reimbursements")==null;if(q===!1&&w.push("top_expenses"),G===!1&&w.push("task_card"),J===!1&&w.push("bill_pay_card","bill_pay_promo_card"),z===!1&&w.push("reimbursement_card","reimbursement_promo_card"),m===!1&&w.push("zeni_accounts_promo_card"),v===!1&&w.push("rewards_card"),d.useEffect(()=>{S!=="Completed"||c||D||A||(u(!0),n(At(l.userId,B,b.tenantId,!0,!1,w)))},[c,S,D,A,l,b.tenantId,n]),d.useEffect(()=>{(D||A)&&setTimeout(()=>{I(!0)},5e3)},[D,A]),S!=="Completed")return o.jsx(j,{to:"../"});if(S==="Completed"&&h){const k=N(s.state?.pathnameStackToGoBack,s.pathname);if(D)return o.jsx(j,{to:"../../checking",state:{...s.state,pathnameStackToGoBack:k,message:"activation"}});if(A)return o.jsx(j,{to:"../../cards",state:{...s.state,pathnameStackToGoBack:k,message:"activation"}})}return i?.loggedInUserRoleMap!=null?o.jsxs(o.Fragment,{children:[o.jsx(ce,{analytics:K,onLoad:k=>(F=>F.trackPageLoaded(Ae.Event.onboardingDashboardActivation))(k)}),o.jsx(On,{navigate:t,location:s,themeState:a,signedInUser:l,isApAgingFeatureEnabled:O,isArAgingFeatureEnabled:r,shouldFetchZeniAccountsPromoCard:m,shouldFetchRewardsPlanCard:v,isExpenseAutomationEnabledForUser:U,isExpenseAutomationFeatureEnabledV2:E,isTreasuryEnabled:y,loggedInUserRoleMap:i?.loggedInUserRoleMap})]}):o.jsx(nt,{})},ge=["reading_books","finance_graph","reconciliation","cfo_foundation"],fe=["llm_fine_tuning","rag_knowledge_graph","personalized_context"],He=(t,s)=>{const n=new Map(t.map(a=>[a.key,a]));return s.map(a=>{return c=n.get(a)?.status,c==="starting"||c==="building"?c:"idle";var c})},We=(t,s)=>{if(t.length===0)return!1;const n=new Map(t.map(a=>[a.key,a]));return s.every(a=>n.get(a)?.status==="ready")},wn=new Set(Rt),Ye=Pe.div`
2
+ display: flex;
3
+ height: 100vh;
4
+ background-color: ${t=>t.theme.colors.grey4};
5
+ `,Je=Pe.div`
6
+ display: flex;
7
+ flex-direction: column;
8
+ align-items: center;
9
+ flex: 1;
10
+ min-width: 0;
11
+
12
+ ${t=>t.skipLegacyDrawerOffset?`
13
+ width: 100%;
14
+ padding-left: ${Ge.sp0};
15
+ `:`
16
+ min-width: calc(100% - ${ze}px);
17
+ padding-left: ${ze}px;
18
+ `}
19
+
20
+ ${t=>t.theme.breakpoints.down("md")} {
21
+ width: 100%;
22
+ padding-left: ${Ge.sp0};
23
+ }
24
+
25
+ ${t=>t.windowSize!=="small"?"overflow: auto;":""}
26
+ `,Xe=Ee(function(t,s){const{companyId:n,isAdmin:a,currentTenant:c,isOnAddressPage:u}=s,h=$.getSignedInUser(),I=c.tenantId,e={userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:I??""},i=W(t),l=we(t,n),p=it(t),O=ue(c?.userRole??[])&&l.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",r=Jt(t.userRoleConfigState);return{onboardingCustomerView:l,analytics:K,isRefreshingViewInBackground:!1,isDisabled:O,companyTitles:r.companyTitles,connectedAccountProvider:i.company?.featuresActivationInfo.connectedAccountProvider??"",fileProps:{filesEndPoint:Et.fileMicroServiceBaseUrl,authParams:e},signedInUser:$.getSignedInUser(),currentTenant:i,isAdmin:a,isOnAddressPage:u,meetingUrl:"https://meetings.hubspot.com/niharn/zeni-onboarding-overview?embed=true",cardPaymentView:p,isCardPaymentPopupOpen:!1,stripeKey:he.stripeKey}},function(t,s){const{companyId:n,currentTenant:a,themeState:c,navigate:u,location:h}=s,{tenantEmailDomain:I}=a;return{onFetchLinkTokenClick:(e,i)=>{t(In(e,i))},onEstablishConnectionClick:(e,i)=>{t(kn(e,i))},onUpdatePaymentAccountStatus:(e,i,l)=>{t(Cn(e,i,l))},onUpdatePaymentAccountLoginStatus:(e,i)=>{t(Sn(!1,e,i))},onEstablishConnectionSuccess:()=>{t(bn(n,!0,!1))},handleOnConnectClick:()=>{K.trackOnboardingConnectQBO(),ae.handleClick()},updateQBOPopupState:e=>{t(de({isQBOPopupOpen:e}))},onCompanyOfficerUpdated:e=>{const i=e.map(l=>{const{officerType:p,userId:O,name:r,email:m,ssn:v,nationalityCountryCode:E,dob:g,phone:U,syncToken:b,selectDocument:P,role:V,ownership:y,isSelectedForVerification:S,userVerificationStatus:x,fileIds:B,isPhoneVerified:D}=l;let A;return P.selectDocumentType==="driverLicense"?A="driving_license":P.selectDocumentType==="passport"?A="passport":P.selectDocumentType==="stateId"?A="id_document":P.selectDocumentType==="ssnCard"&&(A="social_security_card"),{officerType:p,userId:O,firstName:r.firstName,lastName:r.lastName,email:m,ssn:v,nationalityCountryCode:E?.selectedOption!=null?Qe(E.selectedOption):void 0,phone:U,birthday:g!=null?qe(g?.toString()):g,syncToken:b,titleAtCompany:V.selectedOption,ownershipInCompany:y,documentTypeSelectedForVerification:A,isSelectedForVerification:S,userVerificationStatus:x,fileIds:B,additionalDocumentTypesRequestedForVerification:[],additionalSubmittedDocumentsForVerificationFileIds:[],areAdditionalDocumentsRequestedForVerification:!1,areAdditionalDocumentsSubmittedForVerification:!1,isPhoneVerified:D}});t(Ze({officers:i}))},onGetOtp:(e,i)=>{t(yn(e,"CustomerOnboarding")),i!=null&&t(hn({officerType:i,phone:e}))},onResendOtp:e=>{t(fn(e,"CustomerOnboarding"))},onVerifyOtp:(e,i)=>{t(gn(e,i,"CustomerOnboarding"))},updateFilesEntity:e=>{t(mn({files:e}))},onDeleteFile:e=>{t(pn(e))},onEditFileName:(e,i)=>{t(ln(e,i.split(".")[0]))},onCompanyDetailsChanged:e=>{const{companyDescription:i,companyIndustry:l,companyIndustryType:p,companyLegalName:O,companyTaxId:r,companyWebsite:m,companyPhone:v,primaryContactEmail:E,primaryContactName:g,primaryContactUserId:U,primaryContactSyncToken:b,syncToken:P,fileIds:V,typeOfIncorporation:y,stateOfIncorporation:S,incDate:x,companySourceOfFunds:B,companySourceOfFundsDescription:D,companySubIndustry:A,countriesOfOperations:w,purposeOfAccount:q,purposeOfAccountDescription:G,regulatedStatus:Y,regulatedStatusDescription:J,transactionVolume:z,transactionVolumeDescription:k,usNexus:F,usNexusTypes:oe}=e,R={companyId:n,companyDescription:i,companyIndustry:l.selectedOption,companyIndustryType:p?.selectedOption??"",companyLegalName:O,taxIdOrEIN:r,website:m!=""&&m!=null?un(m):void 0,phone:v,syncToken:P,fileIds:V,incDate:x!=null?qe(x?.toString()):x,typeOfIncorporation:y?.selectedOption??"",stateOfIncorporation:S?.selectedOption??"",companySourceOfFunds:B?.selectedOption??"",companySourceOfFundsDescription:D,companySubIndustry:A?.selectedOption??"",countriesOfOperations:w?.selectedOptions.map(X=>X.length===2?X:Qe(X))??[],purposeOfAccount:q?.selectedOption??"",purposeOfAccountDescription:G,regulatedStatus:Y??"",regulatedStatusDescription:J,transactionVolume:z?.selectedOption??"",transactionVolumeDescription:k,usNexus:F,usNexusTypes:oe?.selectedOptions??[]},le={userId:U,firstName:g.firstName,lastName:g.lastName,email:E,syncToken:b};t(Ze({companyDetails:R,primaryContactDetails:le}))},onAddressClick:(e,i)=>{const l=tt(I,e,i),p=N(h.state?.pathnameStackToGoBack,h.pathname);u(l,{state:{pathnameStackToGoBack:p}})},onRegisteredAddressClick:(e,i)=>{const l=tt(I,e,i),p=N(h.state?.pathnameStackToGoBack,h.pathname);u(l,{state:{pathnameStackToGoBack:p}})},onUpdateCustomerView:(e,i,l)=>{t(dn(n,!1,i,l,e))},onAddressEditHandler:e=>{if(e!=null){const i=ft(e);t(st({addressType:"subscription_billing_address",addressToCreate:i}))}},onSkipSetupClick:()=>{const e=N(h.state?.pathnameStackToGoBack,h.pathname);t(Se(n,!1,!1)),u("./activation",{state:{pathnameStackToGoBack:e}})},onUpdateStep:e=>{t(ot({step:e}))},onUpdateSubStep:e=>{t(cn({subStep:e}))},onZeniLogoClick:()=>{c.toggle()},handleLogOutClick:()=>{const e=N(h.state?.pathnameStackToGoBack,h.pathname);u("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleCockpitClick:()=>{window.open("/cockpit")},handleCreateCardSetupIntent:e=>{t(at(e))},handleConfirmCardSetupIntent:e=>{t(rn(e))},updateCardPaymentModalState:e=>{t(de({isCardPaymentPopupOpen:e}))},handleAddCardPaymentSource:(e,i,l)=>{t(sn(e,i,l))},handleFetchPaymentSources:()=>{t(be())},resetCardPaymentViewState:()=>{t(on())},handleResetCardPaymentErrorStatuses:()=>{t(an())},redirectToProductSuitePage:()=>{const e=N(h.state?.pathnameStackToGoBack,h.pathname);t(Se(n,!1,!1)),u(`/${I}/onboarding/thankyou`,{state:{pathnameStackToGoBack:e,message:"OnboardingThankyou"},replace:!0})},onAcknowledgeAiFinanceTeam:()=>{n!=null&&t(nn(n))},onIdentityDocumentUploadedForAutofill:e=>{if(n==null)return;const i=en(e.documentType);i!=null&&t(tn({target:"onboarding",companyId:n,officerType:e.officerType,fileId:e.fileId,documentType:i}))},onCompanyDocumentUploadedForAutofill:e=>{n!=null&&t(Xt({target:"onboarding",companyId:n,fileId:e.fileId,documentType:e.documentType}))}}})(It),re=({taxCFOCustomer:t=!1,isOnAddressPage:s=!1,appContent:n})=>{const a=Ce(),c=ke(),u=H(),h=kt(),I=_e(),[e,i]=d.useState(!1),[l,p]=d.useState(!1),[O,r]=d.useState(!1),{tenantEmailDomain:m}=Ie(),v=ve(),{useFeatureGate:E}=xe(),{isFeatureEnabled:g}=E(M.isDebitCardFeatureEnabled),U=ht("/:tenantEmailDomain/onboarding")!==null&&c.search?.includes("code"),b=_(f=>f.onboardingCustomerViewState.fetchState),P=_(f=>f.onboardingCustomerViewState.currentStep),V=_(f=>f.onboardingCustomerViewState.uiState),y=_(f=>W(f)),S=_(f=>f.userRoleConfigState.fetchState),x=_(f=>f.cardPaymentViewState),B=$e(x.addCardPaymentSourceStatus.fetchState),D=x.addCardPaymentSourceStatus.fetchState,{code:A,realmId:w,state:q}=En(c.search),G=y.externalConnections?.accounting[0],Y=G?.connectionType,J=G?.connectionName,z=G?.connectionId??"",k=$.getSignedInUser()?.userId??"";d.useEffect(()=>{l||(p(!0),u(be()))},[l,u]),d.useEffect(()=>{O||(at(["card"]),r(!0))},[O]),d.useEffect(()=>{B==="In-Progress"&&D==="Completed"&&u(be())},[B,D]),d.useEffect(()=>{_n(A,w,q,z,k)===!0&&y.externalConnections?.saveConnectionState!=="In-Progress"&&b==="Completed"&&(u(Lt(y.tenantId,{connection_type:Y??"accounting",connection_name:J??"quickbooks_online",authorization_code:A,realm_id:w,connection_id:z,user_id:k},Mt(window.location.origin+"/onboarding/auth"))),K.trackOnboardingSaveQBOConnection(w,z),a(c.pathname))},[A,w,q,c.pathname,b]),d.useEffect(()=>{ae.isInitiated===!1&&b==="Completed"&&ae.init("/onboarding/auth",y.tenantEmailDomain)},[b]);const F=y.companyId??$.getSignedInUserTenant(m)?.companyId,oe=ue(y?.userRole??[]),R=_(f=>we(f,F));d.useEffect(()=>{e||b!=="Not-Started"||F==null||(i(!0),u(Nt(F,!0,!U)))},[e,b,F]),d.useEffect(()=>{y.externalConnections?.saveConnectionState!=="Completed"&&y.externalConnections?.saveConnectionState!=="Error"||!V.isQBOPopupOpen||P!=="connect_ledger"||u(de({isQBOPopupOpen:!1}))},[y.externalConnections?.saveConnectionState]),d.useEffect(()=>{b==="Completed"&&U&&(u(ot({step:"connect_ledger"})),u(de({isQBOPopupOpen:!0})))},[U,b]),d.useEffect(()=>{S==="Not-Started"&&u($t(!0))},[S,u]);const le=$e(R.companyDetailsLocalData?.addressStatus);d.useEffect(()=>{R.companyDetailsLocalData?.registeredAddressStatus?.addressToCreate==null&&R.companyDetailsLocalData?.addressStatus?.addressToCreate!=null&&le==null&&u(st({addressType:"company_registered_address",addressToCreate:R.companyDetailsLocalData?.addressStatus?.addressToCreate}))},[R.companyDetailsLocalData?.addressStatus?.addressToCreate,R.companyDetailsLocalData?.registeredAddressStatus?.addressToCreate]);const X=R.isInterimEmailSent,De=$.getSignedInUser();if(De==null)throw Error("Can't access onboarding flow without signing in...");const rt=Oe(g,y),ct=Te(y),Fe=y.company?.companyOnboardingInfo.isOnboardingCompleted,je=f=>f.trackPageLoaded(Ae.Event.onboardingPage),Ue=y.productSettings.isOtherProductsEnabled,dt=y.productSettings.isTreasuryEnabled,Be=Pn({tenantEmailDomain:m??"",signedInUserEmail:De.userEmail??"",companyId:F}),Ve=(({companyId:f})=>{const L=H(),se=_(T=>T.onboardingCustomerViewState?.aiAgentsActivation),ee=_(T=>W(T).company?.companyOnboardingInfo?.onboardingInfo?.onboardingAiActivationInfo?.isOnboardingAiActivationViewed??!1),pe=d.useCallback(()=>{L(wt())},[L]);d.useEffect(()=>{pe()},[pe]);const Re=d.useCallback(()=>{f==null||f===""||ee||L(Pt(f))},[f,ee,L]),ut=d.useMemo(()=>{if(f==null||f==="")return[];const T=`private-encrypted-${f}`;return[`${T}.ledger-ingestion.counts-updated`,`${T}.ai-agents-activation.phase-changed`]},[f]),lt=d.useCallback((T,te)=>{if(te==null||typeof te!="object")return;const C=te;if(T!=="ledger-ingestion.counts-updated"){if(T==="ai-agents-activation.phase-changed"){const ie=typeof C.phase_key=="string"?C.phase_key:typeof C.key=="string"?C.key:"",Z=typeof C.status=="string"?C.status:"idle";if(ie==="")return;L(Ft({key:ie,status:Z==="starting"||Z==="building"||Z==="ready"?Z:"idle",startedAt:typeof C.started_at=="string"?C.started_at:void 0,completedAt:typeof C.completed_at=="string"?C.completed_at:void 0}))}}else L(Dt({customerCount:typeof C.customer_count=="number"?C.customer_count:void 0,glAccountCount:typeof C.gl_account_count=="number"?C.gl_account_count:void 0,targetTransactionCount:typeof C.target_transaction_count=="number"?C.target_transaction_count:void 0,transactionCount:typeof C.transaction_count=="number"?C.transaction_count:void 0,vendorCount:typeof C.vendor_count=="number"?C.vendor_count:void 0}))},[L]);return xn({events:ut,onEvent:lt,onSubscribed:pe}),d.useMemo(()=>{const T=se?.phases??[],te=He(T,ge),C=He(T,fe),ie=We(T,ge),Z=We(T,fe),Le=T.some(gt=>gt.status!=="idle"),ne=!ee&&!Le,Me=ee&&!Le,pt=Me?ge.map(()=>"building"):te,mt=Me?fe.map(()=>"building"):C;return{ledgerRowStatuses:ne?void 0:pt,backgroundRowStatuses:ne?void 0:mt,showLedgerReadyInLabel:ne?void 0:ie,showBackgroundReadyInLabel:ne?void 0:Z,forceContinueEnabled:!ne||void 0,counts:se?.counts,onContinueClicked:Re}},[se?.phases,se?.counts,ee,Re])})({companyId:F});if(Fe===!0){if(!Ue)return dt?o.jsx(j,{to:"../../treasury"}):rt?o.jsx(j,{to:"../../checking"}):ct?o.jsx(j,{to:"../../cards"}):o.jsx(j,{to:"../../dashboard"});const f=R.updateStatus.fetchState==="In-Progress";if(Ue&&!f)return t?o.jsxs(Ye,{children:[o.jsx(ce,{analytics:K,onLoad:L=>je(L)}),o.jsx(Xe,{navigate:a,location:c,companyId:F,currentTenant:y,isAdmin:oe,isOnAddressPage:s,themeState:I,googleAPIKey:he.googleMapsAPIKey,integrationsSectionProps:Be,aiAgentsActivationProps:Ve}),n!=null?o.jsx(Je,{windowSize:h,skipLegacyDrawerOffset:s&&y.productSettings.isOtherProductsEnabled!==!0,children:n}):null]}):o.jsx(j,{to:"../../onboarding/thankyou"})}else if(Fe===!1&&v?.loggedInUserRoleMap!=null)return X===!0?o.jsx(j,{to:"../../onboarding/thankyou"}):o.jsxs(Ye,{children:[o.jsx(ce,{analytics:K,onLoad:f=>je(f)}),o.jsx(Xe,{navigate:a,location:c,companyId:F,currentTenant:y,isAdmin:oe,isOnAddressPage:s,themeState:I,googleAPIKey:he.googleMapsAPIKey,integrationsSectionProps:Be,aiAgentsActivationProps:Ve}),n!=null?o.jsx(Je,{windowSize:h,skipLegacyDrawerOffset:s&&y.productSettings.isOtherProductsEnabled!==!0,children:n}):null]});return null},ye="external_integrations",Pn=({tenantEmailDomain:t,signedInUserEmail:s,companyId:n})=>{const a=H();vn();const{plaidAccounts:c,onAddPlaidAccount:u}=(({companyId:r})=>{const m=H(),v=_(S=>S.plaidAccountViewState.external_account.plaidConnectionDetails.link_external_account),E=_(S=>jt(S.paymentAccountState)),g=d.useRef(!1);d.useEffect(()=>{m(Ut())},[m]);const U=d.useCallback(S=>{m(Bt(S,r,"external_account",void 0,"link_external_account")),g.current=!1},[m,r]),b=d.useCallback(()=>{g.current=!1},[]),{open:P,ready:V}=An({token:v.linkToken??null,onSuccess:U,onExit:b});d.useEffect(()=>{g.current&&V&&(P(),g.current=!1)},[V,P]);const y=d.useCallback(()=>{g.current=!0,m(Vt("external_account","link_external_account"))},[m]);return{plaidAccounts:d.useMemo(()=>E.map(S=>{return{accountId:S.paymentAccountId,name:S.institutionDetails?.institutionName??S.accountName,mask:S.accountLast4Digits,balanceFormatted:(x=S.balances?.current?.amount,B=S.balances?.current?.currencySymbol,x==null?"":`${B??"$"}${x.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`),isActive:wn.has(S.providerVerificationStatus?.code??"")};var x,B}),[E]),onAddPlaidAccount:y}})({companyId:n}),h=_(r=>W(r)),I=_(r=>r.tenantState.fetchState),e=_(r=>Gt(r,n)),i=_(r=>zt(r,ye)),l=d.useMemo(()=>new Set(i.map(r=>r.additionalInfo).filter(r=>r!=null)),[i]),p=h.tenantId,O=ue(h.userRole??[]);return d.useEffect(()=>{a(Qt(ye))},[a]),d.useMemo(()=>({isAdmin:O,integrationsView:e,isLoading:I==="In-Progress",notifyMeRegisteredSlugs:l,saveChargeBeeState:e.externalConnections?.saveAPIKeyConnectionState??"Not-Started",saveChargeBeeError:e.externalConnections?.saveAPIKeyConnectionError?.message,saveHubSpotState:e.externalConnections?.saveOAuthConnectionState??"Not-Started",saveHubSpotError:e.externalConnections?.saveOAuthConnectionError?.message,saveConnectorCredentialsStateBySlug:e.externalConnections?.saveConnectorCredentialsStateBySlug??{},saveConnectorCredentialsErrorBySlug:Object.fromEntries(Object.entries(e.externalConnections?.saveConnectorCredentialsErrorBySlug??{}).map(([r,m])=>[r,m?.message])),deleteConnectionState:e.externalConnections?.deleteConnectionState??"Not-Started",deleteConnectionError:e.externalConnections?.deleteConnectionError?.message,onConnectGmail:()=>{a(Ke(p,"gmail",et()))},onConnectOutlook:()=>{a(Ke(p,"outlook",et()))},onConnectHubSpot:(r,m)=>{const v=e.externalConnections?.revenue?.find(g=>g.connectionName==="hubspot")?.connectionId;if(v==null)return;const E=`${window.location.origin}/oauth/hubspot/callback`;sessionStorage.setItem("hubspot_oauth_pending",JSON.stringify({client_id:r,client_secret:m,connection_id:v,redirect_uri:E,tenant_id:p})),window.location.href=`https://app.hubspot.com/oauth/authorize?client_id=${encodeURIComponent(r)}&scope=${encodeURIComponent("oauth crm.objects.deals.read crm.objects.owners.read")}&redirect_uri=${encodeURIComponent(E)}`},onDisconnect:(r,m)=>{a(Yt(p,r,me(m)))},onNotifyMe:r=>{a(Wt(ye,r,s))},onReconnectQBO:()=>{ae.init("/onboarding/auth",t),ae.handleClick()},onRefreshClick:()=>{e.integrations.refreshQBO.fetchState!=="In-Progress"&&a(Ht())},onSaveChargeBeeCredentials:(r,m)=>{const v=e.externalConnections?.revenue?.find(E=>E.connectionName==="chargebee")?.connectionId;v!=null&&a(qt(p,v,me("revenue"),Zt("chargebee"),{api_key:r,site:m}))},onSaveConnectorCredentials:r=>{a(Kt(p,me("payments"),r))},plaidAccounts:c,onAddPlaidAccount:u}),[O,e,I,l,p,s,t,a,c,u])};function et(){const t=new URL(window.location.href);return t.searchParams.set("onboarding_step","connect_data_source"),t.toString()}function tt(t,s,n){let a=`/${t}/onboarding/address`;return a=n!=null?a.concat(`/edit/${s}/${encodeURIComponent(n)}`):a.concat(`/new/${s}`),a}const Dn=Pe.div`
27
+ display: flex;
28
+ height: 100vh;
29
+ background-color: ${t=>t.theme.colors.grey4};
30
+ `,Fn=Ee(function(t,s){const{companyId:n,currentTenant:a}=s,c=we(t,n),u=it(t);return{hasVerifiedBankAccount:(c.paymentAccount?.providerVerificationStatus?.code?.includes("verified")??!1)||(u.bankAccountsList[0]?.providerVerificationStatus?.code?.includes("verified")??!1),isDisabled:ue(a?.userRole??[])&&c.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",signedInUser:$.getSignedInUser(),currentTenant:a,meetingUrl:"https://meetings.hubspot.com/niharn/zeni-onboarding-overview?embed=true"}},function(t,s){const{currentTenant:n,themeState:a,navigate:c,location:u}=s,{tenantEmailDomain:h}=n;return{onZeniLogoClick:()=>{a.toggle()},handleLogOutClick:()=>{const I=N(u.state?.pathnameStackToGoBack,u.pathname);c("/signout",{replace:!0,state:{pathnameStackToGoBack:I,message:"logout"}})},handleCockpitClick:()=>{window.open("/cockpit")},handleUpdatePaymentAddressDetailClick:()=>{const I=N(u.state?.pathnameStackToGoBack,u.pathname);c(`/${h}/onboarding/billing/edit`,{state:{pathnameStackToGoBack:I,message:"UpdatePaymentAddressDetail"}})}}})(_t),jn=()=>{const t=Ce(),s=H(),n=ke(),a=_e(),{useFeatureGate:c}=xe(),{isFeatureEnabled:u}=c(M.isDebitCardFeatureEnabled),{tenantEmailDomain:h}=Ie(),I=ve(),[e,i]=d.useState(!1);d.useEffect(()=>{e===!1&&n.state?.message==="OnboardingThankyou"&&i(!0)},[n.state]);const l=_(g=>W(g)),p=l.productSettings.isOtherProductsEnabled;d.useEffect(()=>{s(Se(O,!1,!p))},[]);const O=l.companyId??$.getSignedInUserTenant(h)?.companyId;if(I.loggedInUser==null)throw Error("Can't access onboarding flow without signing in...");const r=Oe(u,l),m=Te(l),v=_(g=>g.onboardingCustomerViewState.updateStatus.fetchState),E=l.company?.companyOnboardingInfo.isOnboardingCompleted;if(E===!0){const g={pathnameStackToGoBack:n.state?.pathnameStackToGoBack,message:"activation"};return r?o.jsx(j,{to:"../../checking",state:g,replace:!0}):m?o.jsx(j,{to:"../../cards",state:g,replace:!0}):o.jsx(j,{to:"../../dashboard",state:g,replace:!0})}return v==="Completed"&&E===!1&&I?.loggedInUserRoleMap!=null?o.jsxs(Dn,{children:[o.jsx(ce,{analytics:K,onLoad:g=>{g.trackPageLoaded(Ae.Event.onboardingInterimPage)}}),o.jsx(Fn,{navigate:t,showUpdatePaymentDetailButton:p,location:n,companyId:O,currentTenant:l,themeState:a,isVisitingFirstTime:e})]}):o.jsx(nt,{})};function ra(){return o.jsxs(bt,{children:[o.jsx(Q,{path:"/",element:o.jsx(re,{})}),o.jsx(Q,{path:"/billing/edit",element:o.jsx(re,{taxCFOCustomer:!0})}),o.jsx(Q,{path:"/thankyou",element:o.jsx(jn,{})}),o.jsx(Q,{path:"/activation",element:o.jsx(Tn,{})}),o.jsx(Q,{path:"/address/edit/:addressType/:addressId",element:o.jsx(re,{isOnAddressPage:!0,appContent:o.jsx(Ne,{})})}),o.jsx(Q,{path:"/address/new/:addressType",element:o.jsx(re,{isOnAddressPage:!0,appContent:o.jsx(Ne,{})})}),o.jsx(Q,{path:"*",element:o.jsx(yt,{})})]})}export{ra as default};