@zeniai/web-app-ui 5.4.17-dev → 5.4.18-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/assets/{AccountMappingScreen-DIZ1qWql.js → AccountMappingScreen-4Zeu95kU.js} +1 -1
  2. package/dist/assets/{ActualMatchingMatchDetailScreen-C6MMW6xe.js → ActualMatchingMatchDetailScreen-B6pl-MVl.js} +1 -1
  3. package/dist/assets/AddressRoutes-zjWkB0xf.js +1 -0
  4. package/dist/assets/{AddressScreen-CxRV-hrD.js → AddressScreen-Czlolp2X.js} +1 -1
  5. package/dist/assets/{AiCfoScreen-Ct8ctLoM.js → AiCfoScreen-BhfmD__h.js} +1 -1
  6. package/dist/assets/{AppDrawer-DDlKiLbC.js → AppDrawer-B7GEeTxi.js} +1 -1
  7. package/dist/assets/{BillPayApprovalRoutes-WPV-16X0.js → BillPayApprovalRoutes-B4dh4WxY.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-PQbxiOB3.js → BillPayRoutes-DZx-x_-P.js} +1 -1
  9. package/dist/assets/{BusinessVerificationPageScreen-DaAqJAwC.js → BusinessVerificationPageScreen-je1np7-9.js} +2 -2
  10. package/dist/assets/{CardsAiCfoScreen-CVenT1_U.js → CardsAiCfoScreen-abedaxWu.js} +1 -1
  11. package/dist/assets/{ChargeCardRoutes-uCAqAWIA.js → ChargeCardRoutes-Db9V9An_.js} +1 -1
  12. package/dist/assets/{CompanyPassportScreen-DtXzsb3x.js → CompanyPassportScreen-Db20J8Yl.js} +1 -1
  13. package/dist/assets/{ConnectionAuthScreen-BC1VQ6tg.js → ConnectionAuthScreen-BmJpUHtJ.js} +1 -1
  14. package/dist/assets/CustomerOnboardingAuthScreen-Deo-LVYJ.js +1 -0
  15. package/dist/assets/{CustomerOnboardingRoutes-B6np-cNh.js → CustomerOnboardingRoutes-De4sHn4O.js} +3 -3
  16. package/dist/assets/{DashboardRoutes-9dawbCei.js → DashboardRoutes-CCGs4e1_.js} +3 -3
  17. package/dist/assets/{DefaultTenantHome-BgSSAKid.js → DefaultTenantHome-BN__AQ5l.js} +1 -1
  18. package/dist/assets/{DomesticWireDetailScreen-u2HKaCWA.js → DomesticWireDetailScreen-6W-Er5_q.js} +3 -3
  19. package/dist/assets/{DrawerScreen-BmZb1i83.js → DrawerScreen-DUhkZI2Z.js} +1 -1
  20. package/dist/assets/{EntityDetailRoutes-DV-gNWAZ.js → EntityDetailRoutes-BrJAd36h.js} +1 -1
  21. package/dist/assets/{ExpenseAutomationRoutes-DJyIDCG4.js → ExpenseAutomationRoutes-DcjeaHHd.js} +1 -1
  22. package/dist/assets/{FallBackRoute--cXyuVDR.js → FallBackRoute-orqRsHMl.js} +2 -2
  23. package/dist/assets/{FeaturePreviewScreen-DjPPDYKv.js → FeaturePreviewScreen-Dcu53_tf.js} +1 -1
  24. package/dist/assets/{HubSpotOAuthCallbackScreen-DL6_G6pe.js → HubSpotOAuthCallbackScreen-ClZsPGpZ.js} +1 -1
  25. package/dist/assets/{InboxNotificationsProvider-Daf1RQwd.js → InboxNotificationsProvider-DiTDJFwP.js} +1 -1
  26. package/dist/assets/{InvoicingRoutes-DKlu_pXq.js → InvoicingRoutes-BTvzZ8JV.js} +2 -2
  27. package/dist/assets/{MagicLinkRoutes-BkZcOPcj.js → MagicLinkRoutes-V1DxaNiW.js} +5 -5
  28. package/dist/assets/{MagicLinkSignInScreen-CmIZfa-U.js → MagicLinkSignInScreen-DnCx8Y6G.js} +1 -1
  29. package/dist/assets/{MobileAppDrawer-DTqKEh3f.js → MobileAppDrawer-Bql3K6nh.js} +1 -1
  30. package/dist/assets/NotFoundScreen-CTik05r2.js +1 -0
  31. package/dist/assets/{NotificationRoutes-BwTXq37O.js → NotificationRoutes-wSm6mA8N.js} +1 -1
  32. package/dist/assets/{OAuthConsentScreen-NPetpQky.js → OAuthConsentScreen-BELrcqAy.js} +1 -1
  33. package/dist/assets/{PandLWithForecastRoutes-eI5sgFXq.js → PandLWithForecastRoutes-Dpao8SIb.js} +1 -1
  34. package/dist/assets/{PaymentLinkScreen-C3fxjzB1.js → PaymentLinkScreen-vbM_NtP3.js} +1 -1
  35. package/dist/assets/{PeopleRoutes-B4kdNKMm.js → PeopleRoutes-CJeBX2Ca.js} +1 -1
  36. package/dist/assets/PerformanceRoutes-W4NxEUmH.js +1 -0
  37. package/dist/assets/{Preview-Cr2n9zp9.js → Preview-Db0nRlxD.js} +1 -1
  38. package/dist/assets/{QBOConnectionScreen-BLLJy6Ug.js → QBOConnectionScreen-BEn_CddB.js} +1 -1
  39. package/dist/assets/{ReimbursementApprovalRoutes-DX03V50m.js → ReimbursementApprovalRoutes-CSZJghRB.js} +1 -1
  40. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-y6N7Iuxh.js → ReimbursementApprovalRuleDetailScreen-kqCAU4nf.js} +1 -1
  41. package/dist/assets/{ReimbursementRoutes-50C6Ebhr.js → ReimbursementRoutes-BUZKWvJ7.js} +1 -1
  42. package/dist/assets/{ReportsRoutes-CPbwIPP-.js → ReportsRoutes-BUZ4r7hx.js} +1 -1
  43. package/dist/assets/{RewardsRoutes-cADkol8X.js → RewardsRoutes-DuYZ4TXP.js} +1 -1
  44. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-Bb90T06-.js → ScheduleDetailsPrepaidExpensesScreen-DN2DZsFw.js} +4 -4
  45. package/dist/assets/{ScreenRoutes-BOM6GDiC.js → ScreenRoutes-CxP9HSCe.js} +2 -2
  46. package/dist/assets/{SettingsRoutes-Dd8PYfpt.js → SettingsRoutes-CCWla9X1.js} +6 -6
  47. package/dist/assets/{SetupPagesScreen-BY0N32JD.js → SetupPagesScreen-C5PRNruc.js} +1 -1
  48. package/dist/assets/{SignInScreen-DGgeSRO8.js → SignInScreen-BScZ138a.js} +1 -1
  49. package/dist/assets/{SignOutScreen-DPsA_-Qd.js → SignOutScreen-Bk-Y8Sbv.js} +1 -1
  50. package/dist/assets/{TaskListScreen-yze1VNuP.js → TaskListScreen-C7smUYFP.js} +2 -2
  51. package/dist/assets/{TaskRoutes-B5s7sZXk.js → TaskRoutes-DPcu4NRR.js} +2 -2
  52. package/dist/assets/{TransactionDetailRoutes-D5llvRhv.js → TransactionDetailRoutes-yEwix446.js} +1 -1
  53. package/dist/assets/{TransactionDetailScreen-CebcYk9B.js → TransactionDetailScreen-CHzsnTr9.js} +1 -1
  54. package/dist/assets/{TransactionListRoutes-PnEvh6qc.js → TransactionListRoutes-ChJOrV96.js} +1 -1
  55. package/dist/assets/{TreasuryRoutes-DbBm2doo.js → TreasuryRoutes-C24SAGLB.js} +1 -1
  56. package/dist/assets/{VendorsRoutes-CQjAHjxC.js → VendorsRoutes-CVu8jS5h.js} +1 -1
  57. package/dist/assets/{WiseConfirmationScreen-d0_FJyyD.js → WiseConfirmationScreen-Dt6hB5m-.js} +1 -1
  58. package/dist/assets/{ZeniAccountRoutes-CrROItmj.js → ZeniAccountRoutes-D3ONSR9y.js} +7 -7
  59. package/dist/assets/{ZeniAccountStatementScreen-DiwM8zAQ.js → ZeniAccountStatementScreen-CmfHt6Wr.js} +1 -1
  60. package/dist/assets/{accountMappingHelper-DHkHknqJ.js → accountMappingHelper-CHQgwqfy.js} +1 -1
  61. package/dist/assets/{analytics-CabaUa1L.js → analytics-D051O7ML.js} +1 -1
  62. package/dist/assets/{analyticsHelper-BOs1nNPv.js → analyticsHelper-DkNc3mKz.js} +1 -1
  63. package/dist/assets/{core-BQ6YlWys.js → core-BBlQ3ArL.js} +1 -1
  64. package/dist/assets/{decodeURIComponentSafe-D_MvDEMm.js → decodeURIComponentSafe-YbpxzvKa.js} +1 -1
  65. package/dist/assets/{dnd-DL41lZFs.js → dnd-CU3yeazS.js} +1 -1
  66. package/dist/assets/{empty-CmBSqEpE.js → empty-B3C-udVF.js} +1 -1
  67. package/dist/assets/{empty-mwfdcHvm.js → empty-BiAWzWBi.js} +1 -1
  68. package/dist/assets/{emptyVideoElement-BIOkPHF6.js → emptyVideoElement-CRPwTqUS.js} +1 -1
  69. package/dist/assets/{epic-PdviWWJR.js → epic-DwBfFPJQ.js} +1 -1
  70. package/dist/assets/{expenseAutomationHelper-Bn2j121J.js → expenseAutomationHelper-SA0jUIyg.js} +1 -1
  71. package/dist/assets/{getLocaleForTenant-jg4r2V28.js → getLocaleForTenant-DTPcYF0O.js} +1 -1
  72. package/dist/assets/{index-Bfsx1pdD.js → index--CQENyaz.js} +1 -1
  73. package/dist/assets/{index-BNuLRh9K.js → index-CaztP9tz.js} +1 -1
  74. package/dist/assets/{index-DZBfE5XI.js → index-ClwW47Zs.js} +899 -904
  75. package/dist/assets/{index-Du1SP9oT.js → index-MRZKoeCT.js} +2 -2
  76. package/dist/assets/{index-B7zYAj-7.js → index-ae04Qn4V.js} +1 -1
  77. package/dist/assets/{index-CamOdFyi.js → index-fVadamkP.js} +1 -1
  78. package/dist/assets/{index-Deo5Hnb2.js → index-jomr_c-N.js} +1 -1
  79. package/dist/assets/{index-BiyVMPcR.js → index-s4pcd-16.js} +1 -1
  80. package/dist/assets/{lexical-BmxGnuDE.js → lexical-DVH-xgq1.js} +1 -1
  81. package/dist/assets/{liveblocks-UAxYbctH.js → liveblocks-CuUK5O_2.js} +1 -1
  82. package/dist/assets/{lottie-BPF4ysWw.js → lottie-Du4lbH8J.js} +1 -1
  83. package/dist/assets/{mui-DYo6Z7Si.js → mui--aGBnNu2.js} +1 -1
  84. package/dist/assets/{pathToGoBack-CxX9ql3A.js → pathToGoBack-DOePc_e5.js} +1 -1
  85. package/dist/assets/{pdf-CHT1_0Mk.js → pdf-CrvsvvW3.js} +3 -3
  86. package/dist/assets/{pdf-lib-BMce44-8.js → pdf-lib-Cvsvldn7.js} +1 -1
  87. package/dist/assets/{plaid-BNcFec4W.js → plaid-7P9b69CP.js} +1 -1
  88. package/dist/assets/{pusher-C1AzfTgV.js → pusher-DdvpIMG0.js} +1 -1
  89. package/dist/assets/{react-DZjZzXEf.js → react-B8GJK4jq.js} +1 -1
  90. package/dist/assets/{react-CT8AAIAI.js → react-Bz6aBujY.js} +1 -1
  91. package/dist/assets/{react-BnffftLd.js → react-CUlf2ISA.js} +1 -1
  92. package/dist/assets/{react-CSOME4pA.js → react-CjVSd3S9.js} +1 -1
  93. package/dist/assets/{react-B13-Yejj.js → react-D-JjM7p6.js} +1 -1
  94. package/dist/assets/{react-CjoLUzLz.js → react-DoYRVAKa.js} +1 -1
  95. package/dist/assets/{recharts-VJtr9O-6.js → recharts-CkREU3LH.js} +1 -1
  96. package/dist/assets/{reportTimeframe-D2vFkQK6.js → reportTimeframe-ChAOzqo_.js} +1 -1
  97. package/dist/assets/{routePaths-CaZTJQOM.js → routePaths-D0jOibXk.js} +1 -1
  98. package/dist/assets/{sentry-CQfqw6mU.js → sentry-D0lP5-8e.js} +1 -1
  99. package/dist/assets/{stripSplatSuffix-TzoGXcwz.js → stripSplatSuffix-CFosfir7.js} +1 -1
  100. package/dist/assets/{url-dVvWrnA9.js → url-GwD82u5j.js} +1 -1
  101. package/dist/assets/{url-OL55dppf.js → url-nN4BnP9N.js} +1 -1
  102. package/dist/assets/useActualMatchingMatchDetail-nJ3hpXEY.js +1 -0
  103. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-B4OxQoVy.js → useAiCfoDashboardSuggestedQuestionsChips-usJW6KKQ.js} +1 -1
  104. package/dist/assets/useAskAiCfoHostNavButtonProps-CWWQxV2L.js +1 -0
  105. package/dist/assets/{useChargeCardPusherEvents-Gp7Qmy_v.js → useChargeCardPusherEvents-DPfHk-vM.js} +1 -1
  106. package/dist/assets/{useDeviceId-B6KB8W5T.js → useDeviceId-pp3Grc-z.js} +1 -1
  107. package/dist/assets/{useEmailConnectResultRefresh-DJgvOf06.js → useEmailConnectResultRefresh-B6j7j1rG.js} +1 -1
  108. package/dist/assets/{useEnsureVendorListLoaded-BbjOUcqm.js → useEnsureVendorListLoaded-COBYTL2U.js} +1 -1
  109. package/dist/assets/{useInitialThreadRequest-BpNcTGLt.js → useInitialThreadRequest-DmfmyzKI.js} +1 -1
  110. package/dist/assets/{useTaskManagerAccess-CP331xWN.js → useTaskManagerAccess-DrmpkeUw.js} +1 -1
  111. package/dist/assets/{useTaskManagerPusherEvents-BmjCwNse.js → useTaskManagerPusherEvents-CHhZ2DRZ.js} +1 -1
  112. package/dist/assets/{utils-BpLD-La5.js → utils-Ctp9Zfhk.js} +1 -1
  113. package/dist/assets/{withTransactionSidePanel-7NlWHlVm.js → withTransactionSidePanel-CKC1_4cy.js} +1 -1
  114. package/dist/assets/{zeni-epic-state-j9Po26Lg.js → zeni-epic-state-aUBx6G2Q.js} +3 -3
  115. package/dist/index.html +1 -1
  116. package/package.json +2 -2
  117. package/dist/assets/AddressRoutes-DneYortX.js +0 -1
  118. package/dist/assets/CustomerOnboardingAuthScreen-DGFpytn-.js +0 -1
  119. package/dist/assets/NotFoundScreen-CY-XFa3a.js +0 -1
  120. package/dist/assets/PerformanceRoutes-CT8b6LEZ.js +0 -1
  121. package/dist/assets/useActualMatchingMatchDetail-DglThU_y.js +0 -1
  122. package/dist/assets/useAskAiCfoHostNavButtonProps-DV6iNvbF.js +0 -1
@@ -1 +1 @@
1
- import{n as s}from"./liveblocks-UAxYbctH.js";import{j as c}from"./core-BQ6YlWys.js";import{fI as f}from"./zeni-epic-state-j9Po26Lg.js";import"./sentry-CQfqw6mU.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]="25fc1afa-344c-4436-b7c0-ce0cb6697f63",e._sentryDebugIdIdentifier="sentry-dbid-25fc1afa-344c-4436-b7c0-ce0cb6697f63")}catch{}})();const b=()=>c((e=>f(e))).tenantId==null?{inboxNotifications:[],isLoading:!1,isFetchingMore:!1,hasFetchedAll:!0,fetchMore:()=>null}:(()=>{const{inboxNotifications:e,isLoading:o,isFetchingMore:i,hasFetchedAll:t,fetchMore:n}=s();return{inboxNotifications:e,isLoading:o,isFetchingMore:i,hasFetchedAll:t,fetchMore:n}})();export{b as u};
1
+ import{n as s}from"./liveblocks-CuUK5O_2.js";import{j as c}from"./core-BBlQ3ArL.js";import{fI as f}from"./zeni-epic-state-aUBx6G2Q.js";import"./sentry-D0lP5-8e.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]="25fc1afa-344c-4436-b7c0-ce0cb6697f63",e._sentryDebugIdIdentifier="sentry-dbid-25fc1afa-344c-4436-b7c0-ce0cb6697f63")}catch{}})();const b=()=>c((e=>f(e))).tenantId==null?{inboxNotifications:[],isLoading:!1,isFetchingMore:!1,hasFetchedAll:!0,fetchMore:()=>null}:(()=>{const{inboxNotifications:e,isLoading:o,isFetchingMore:i,hasFetchedAll:t,fetchMore:n}=s();return{inboxNotifications:e,isLoading:o,isFetchingMore:i,hasFetchedAll:t,fetchMore:n}})();export{b as u};
@@ -1,3 +1,3 @@
1
- import{j as s}from"./liveblocks-UAxYbctH.js";import{a as r}from"./sentry-CQfqw6mU.js";import{u as L,h as P,i as $,j as E,t as oe,l as O,s as z,g as ae,N as H,n as ge,o as x}from"./core-BQ6YlWys.js";import{a9 as ct,d as g,aC as _,U as l,du as rt,dv as dt,dw as lt,dx as ut,dy as gt,dz as mt,dA as vt,dB as pt,dC as St,dD as ft,dE as It,dF as ht,s as se,dG as Ct,dH as kt,z as te,af as pe,dI as Et,dJ as yt,dK as bt,dL as xt,dM as At,dN as Dt,dO as jt,dP as Lt,dQ as Pt,dR as wt,V as Rt,az as pn,dS as $t,dT as Ft,dU as _t,dV as Tt,dW as Ot,dX as Mt,dY as Nt,dZ as Ut,d_ as Bt,d$ as Vt,e0 as Ht,t as en,q as Ue,e1 as qt,e2 as Qt,e3 as zt,e4 as Kt,e5 as Gt,e6 as Yt,Z as Wt,aZ as Jt}from"./index-DZBfE5XI.js";import"./mui-DYo6Z7Si.js";import{A as X}from"./AddressScreen-CxRV-hrD.js";import M from"./NotFoundScreen-CY-XFa3a.js";import{a28 as Xt,a29 as Zt,vG as nn,v as ei,a2a as Z,wh as Se,a2b as Be,a2c as Y,wU as we,w$ as ni,dI as Sn,x3 as fn,a2d as Ve,wY as ti,yE as tn,wg as on,a2e as In,a2f as W,xe as Re,xi as ii,a2g as oi,xs as ai,a2h as hn,xl as Cn,zc as si,a2i as he,a2j as an,a2k as kn,wc as ci,a2l as ri,w4 as di,a2m as li,yR as ui,a2n as En,y_ as be,a2o as gi,yX as mi,a2p as He,gk as qe,a2q as le,a2r as ue,xA as vi,wm as sn,wr as yn,wp as pi,wj as Si,xt as fi,wt as Ii,xC as hi,cP as bn,a2s as $e,xL as xn,xJ as Q,xH as G,xG as Ci,a2t as fe,z5 as xe,a2u as ki,we as An,a2v as Qe,fI as Ce,wC as Fe,wz as _e,wM as Dn,wL as ze,ww as Ei,wF as jn,wO as me,Yd as Ln,wi as Ke,wJ as yi,wK as bi,wI as xi,a2w as Ai,xj as Di,xf as Pn,a2x as wn,vX as Ae,a2y as ji,vQ as Li,a2z as Pi,zb as wi,zg as K,za as Ri,yi as ke,a2A as $i,a2B as Rn,zp as De,a2C as Fi,zm as _i,a2D as $n,yl as Ti,ym as q,yp as Oi,a2E as Fn,yz as je,a2F as Mi,xB as _n,U_ as Tn,a2G as Ni,yJ as Ui,a2H as On,a2I as cn,a2J as Bi,a2K as Vi,Ac as Hi,a2L as qi,a2M as Mn,zw as Nn,a2N as Un,Aa as Le,a2O as Qi,A7 as zi,a2P as Ki,a2Q as Gi,a2R as Yi,a2S as Wi,a2T as Ji,a2U as rn,a2V as Xi,Ag as Zi,ea as eo,a2W as Ge,xV as no,xQ as to,cR as Te,a2X as ee,xZ as Bn,y5 as Vn,a2Y as Ye,x_ as ie,ya as io,yd as Hn,a2Z as oo,a2_ as Oe,y9 as ao,a2$ as qn,z$ as Pe,zW as so,a30 as co,zB as ro,a31 as lo,A0 as uo,A4 as go,a32 as We,wW as Qn,zN as mo,wX as vo,a33 as po,a34 as zn,c7 as So,mD as fo,mE as Io,a35 as dn,wV as ne,go as ho,mK as Co,zT as Kn,As as ko,zQ as Gn,vc as Eo,v0 as yo,i1 as bo,Vl as ln,Vm as xo,GT as Yn,Ap as Ao,hV as Do,Am as jo,a36 as Lo,a37 as Po,Ay as wo,Ax as Ro,a38 as $o,a39 as Wn,Av as Fo,a3a as _o,a3b as To,yN as Oo,a3c as Mo}from"./zeni-epic-state-j9Po26Lg.js";import{M as No}from"./MobileAppDrawer-DTqKEh3f.js";import{q as Ie}from"./QBOConnectionScreen-BLLJy6Ug.js";import"./recharts-VJtr9O-6.js";import"./analytics-CabaUa1L.js";import"./plaid-BNcFec4W.js";import"./dnd-DL41lZFs.js";import"./stripe-cKAAJElX.js";import"./lottie-BPF4ysWw.js";import"./lexical-BmxGnuDE.js";import"./pdf-CHT1_0Mk.js";import"./utils-BpLD-La5.js";import"./InboxNotificationsProvider-Daf1RQwd.js";import"./useTaskManagerAccess-CP331xWN.js";import"./empty-mwfdcHvm.js";import"./pdf-lib-BMce44-8.js";import"./index-Bfsx1pdD.js";import"./url-OL55dppf.js";import"./index-B7zYAj-7.js";import"./decodeURIComponentSafe-D_MvDEMm.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="ab09d77e-0a01-4800-b6a1-6d61c5840df3",t._sentryDebugIdIdentifier="sentry-dbid-ab09d77e-0a01-4800-b6a1-6d61c5840df3")}catch{}})();const R=({event:t,isReady:e=!0})=>e?s.jsx(ct,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Uo(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),{fetchState:m,hasMore:S,items:f,nextCursor:I,auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h}=E(Xt),y=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),D=`/${n??""}/invoicing`,b=r.useCallback(((F,U)=>{const T=Zt(D,F,U,C);T!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:F,entityId:U,fromScreen:"audit_log",toScreen:F}),e(T))}),[C,e,D]);r.useEffect((()=>{const F=setTimeout((()=>u(a)),300);return()=>clearTimeout(F)}),[a]),r.useEffect((()=>{i&&t(nn({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&f.length===0,k=m==="In-Progress"&&f.length>0,j=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingAuditLogPage,isReady:j}),s.jsx(rt,{auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h,entries:f,hasMore:S,isLoading:A,isLoadingMore:k,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{S&&I!=null&&t(nn({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:p})]})}const Jn=["company","email","firstName","invoiceNotes","lastName","notes","phone","vatNumber"],Me=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:Array.isArray(t)?t.map(Me):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map((([e,n])=>[e,Me(n)]))):null;function B(t,e,n=[]){const i=t,a=e,o=[...new Set([...Object.keys(i),...Object.keys(a??{})])].filter((u=>{if(a==null)return(d=i[u])!=null&&d!==""&&(Array.isArray(d)?d.length>0:typeof d!="object"||Object.keys(d).length>0);var d;return!(i[u]==null&&a[u]==null)&&!ei(i[u],a[u])})).sort(),c=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Me(i[u])])));return{fieldsChanged:o,formValues:c}}function Ee(t,e=!1){const n=L(),i=E((c=>Z(c).productNextCursor!=null)),a=E((c=>Z(c).productNextCursor)),o=E((c=>Z(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(Se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(Se({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function ce(t,e,n,i){const[a,o]=r.useState(0),[c,u]=r.useState(!1),d=r.useRef(t);return r.useEffect((()=>{const p=d.current==="In-Progress";d.current=t,t==="Completed"&&p&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{c&&!e&&(u(!1),o((p=>p+1)))}),[c,e]),a}const Bo=new Set(["plan"]),Vo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(l.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ti({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(Ve({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemEdited,{itemId:i,mode:"edit",...B(e.view.localData,Sn(e.view.plan))}),t(fn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(ni({action:o,id:a,parentItemId:i}))}}}))(dt);function Ho(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=$(),[a]=oe(),{areTenantIdsInSync:o}=_(),c=(u=a.get("kind"))!=null&&Bo.has(u)?u:"plan";var u;const d=E((y=>Be(y,n))),{pageFetchState:p}=d,v=p.fetchState;r.useEffect((()=>(t(Y({id:n})),()=>{t(Y({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(we({id:n,kind:c}))}),[o,n,c,t]);const m=r.useCallback((y=>t(we({cacheOverride:!0,id:y,kind:c}))),[t,c]),S=ce(d.fetchState,d.isFormLoading,n,m),f=v==="Completed"&&!d.isFormLoading;Ee(o,!0);const[I,C]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&C(n)}),[n,f]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||d.isFormLoading);return N(v)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Vo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:h,view:d},S)]})}const qo=new Set(["addon","charge","plan"]),Qo=new Set(["plan"]),zo=O((function(t,e){const n=Be(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedItem:n.plan,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e,a=i!=null?`${n}/catalog/${encodeURIComponent(i)}`:`${n}/catalog`;return{onBack:()=>{t(Y({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(Y({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ve({id:i,localData:o}))},onSubmit:()=>{t(fn({id:i}))}}}),(function({savedItem:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemSaved,{itemId:i.itemId,mode:e.mode,...B(e.localData,t!=null?Sn(t):void 0)}),n.onSubmit()}}}))(lt);function Ko(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=$(),[a]=oe(),{areTenantIdsInSync:o}=_(),c=n!=null,u=a.get("type"),d=u!=null&&qo.has(u)?u:void 0,p=(v=a.get("kind"))!=null&&Qo.has(v)?v:"plan";var v;const m=E((f=>Be(f,n)));Ee(o,!0);const S=r.useRef();return r.useEffect((()=>(clearTimeout(S.current),()=>{S.current=setTimeout((()=>{t(Y({id:n}))}),0)})),[n,t]),r.useEffect((()=>{o&&t(we({id:n,kind:p}))}),[o,n,p,t]),r.useEffect((()=>{c||d==null||m.localData.catalogType===d||t(Ve({localData:{...m.localData,catalogType:d}}))}),[c,d,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const f=m.savedItemId??n,I=f!=null?`/${i}/invoicing/catalog/${encodeURIComponent(f)}`:`/${i}/invoicing/catalog`;e(I),t(Y({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCatalogItemFormPage}),s.jsx(zo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:c,itemId:n})]})}const Go={addons:"addon",all:"item",charges:"charge",plans:"plan"},Yo=O((function(t,e){const n=Z(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,c=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,planRows:n.planRows,productRows:n.productRows}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Go[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,u)=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(on({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(Se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?on({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):Se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Wo(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState("plans"),[d,p]=r.useState(""),[v,m]=r.useState(null),S=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),f=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),C=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),h=E((j=>Z(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,k=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>p(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1,planFilters:I,productFilters:C,planSort:S,productSort:S}))}),[i,t,I,C,S]),r.useEffect((()=>{i&&(f!==y||S?.field!==D?.field||S?.dir!==D?.dir)&&t(tn({cacheOverride:!0,planFilters:I,productFilters:C,planSort:S,productSort:S}))}),[y,D,i,t,I,C,f,S]),N(h.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCatalogPage,isReady:k}),s.jsx(Yo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:a,sortState:v,planFilters:I,productFilters:C,sort:S,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:m})]})}const Jo=O((function(t,e){const n=In(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCoupon:n.coupon,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>{t(W({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(W({id:i})),e.navigate(`${n}/discounts`)},onChange:o=>{t(oi({id:i,localData:o}))},onSubmit:()=>{t(ii({id:i}))}}}),(function({savedCoupon:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponSaved,{couponId:i.couponId,mode:e.mode,...B(e.localData,t!=null?ai(t):void 0)}),n.onSubmit()}}}))(gt);function Xo(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),{fetchState:o,savedCouponId:c}=E((d=>In(d,n))),u=r.useRef();return r.useEffect((()=>(clearTimeout(u.current),()=>{u.current=setTimeout((()=>{t(W({id:n}))}),0)})),[n,t]),r.useEffect((()=>{a&&t(Re({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=c??n,p=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(p),t(W({id:n}))}}),[o,c,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCouponFormPage}),s.jsx(Jo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Zo=O((function(t){const e=hn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(kn(a))},onSubmit:()=>{const a=ri(t.localData);g.trackInvoicingActionClick(l.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length,mode:"create",...B(t.localData,void 0,["memo"])}),e(di(a))}}}))(vt);function ea(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),[i]=oe(),{areTenantIdsInSync:a}=_(),o=i.get("customerId"),c=E((b=>hn(b))),u=c.fetchState,d=c.localData,p=c.savedInvoiceId,v=E(Cn),m=E((b=>si(b))),S=E(he),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,C=f||I,h=m.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(an()),()=>{t(an())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||d.customerId!==""||(y.current=!0,t(kn({...d,customerId:o})))}),[o,d,t]),r.useEffect((()=>{a&&t(ci({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=p!=null?`/${n}/invoicing/invoices/${encodeURIComponent(p)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,p,e,n]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),C?s.jsx(mt,{}):s.jsx(Zo,{navigate:e,tenantEmailDomain:n})]})}const na=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(pt);function ta(){const t=L(),e=P(),{credit_note_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=E((u=>li(u,n??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ui({id:n}))}),[a,n,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(na,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const ia=O((function(t){const e=En(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(mi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(St);function oa(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,creditNoteListFetchState:h}=E((D=>{const b=En(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(be({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCreditsListPage,isReady:y}),s.jsx(ia,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(gi(D)),t(be({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Xn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},aa=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t($e({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(Q(G)),t(Ci({id:i}))},onOpenAddress:()=>{const a=Xn(e.tenantEmailDomain??"",G,i),o=se(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerEdited,{customerId:i,mode:"edit",...B(a,e.editView.record.invoicingCustomer!=null?bn(e.editView.record.invoicingCustomer):void 0,Jn)}),t($e({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(hi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Ii({body:c,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function sa(){const t=L(),e=P(),n=ae(),{customer_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=_(),c=E((T=>He(T,i))),u=c.pageFetchState.fetchState,d=u==="Completed"&&!c.isFormLoading,[p,v]=r.useState(!1),[m,S]=r.useState(!1),[f,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const C=f===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=c,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=c.record,k=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const T=c.record.sendLinkState.fetchState;k.current!=="Error"&&T==="Error"&&t(qe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),k.current=T}),[t,c.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(le()),t(ue()),()=>{t(le()),t(ue())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(vi({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(sn({customerId:i}))}),[o,i,t,A]);const F=r.useCallback((T=>t(yn({id:T}))),[t]),U=ce(c.fetchState,c.isFormLoading,i,F);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),s.jsx(aa,{customerId:i??"",editView:c,hasLoadedRecord:C,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(le()),i!=null&&A&&t(sn({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ue()),S(!0)}},U),s.jsx(ft,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:p,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(Si({customerId:i}))},onClose:()=>{v(!1),t(le())},onSavePaymentMethod:T=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(pi({customerId:i,data:T})))}}),s.jsx(It,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:m,submitSucceeded:y.fetchState==="Completed",onClose:()=>{S(!1),t(ue())},onSubmit:({amount:T,description:de})=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(fi({amount:T,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:de})))}})]})}const ca=O((function(t,e){const n=He(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCustomer:n.record.invoicingCustomer}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>{t(fe({id:i})),t(Q(G)),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(fe({id:i})),t(Q(G)),e.navigate(`${n}/customers`)},onChange:o=>{t($e({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Xn(e.tenantEmailDomain??"",G,i),c=se(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(o,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{t(xn({id:i}))}}}),(function({savedCustomer:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerSaved,{customerId:i.customerId,mode:e.mode,...B(e.localData,t!=null?bn(t):void 0,Jn)}),n.onSubmit()}}}))(Ct);function ra(){const t=L(),e=P(),n=ae(),{customer_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=_(),{fetchState:c,savedCustomerId:u}=E((m=>He(m,i))),d=r.useRef(!1),p=r.useCallback((()=>{d.current=!0}),[]),v=r.useRef();return r.useEffect((()=>(clearTimeout(v.current),d.current=!1,()=>{d.current||(v.current=setTimeout((()=>{t(fe({id:i})),t(Q(G))}),0))})),[i,t]),r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(c==="Completed"){const m=u??i,S=m!=null?`/${a}/invoicing/customers/${encodeURIComponent(m)}`:`/${a}/invoicing/customers`;e(S),t(fe({id:i}))}}),[c,u,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCustomerFormPage}),s.jsx(ca,{customerId:i,keepDraftOnLeave:p,location:n,navigate:e,tenantEmailDomain:a})]})}const da=O((function(t){const e=he(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(An({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(kt);function la(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,customerListFetchState:h}=E((D=>{const b=he(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCustomersListPage,isReady:y}),s.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(ki(D)),t(xe({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Ne=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ua=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:c}=e,u=o==null?void 0:c.diagnosticsBySession[o],d=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:d==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:d==="Not-Started"||d==="In-Progress",isLoadingMore:d==="In-Progress"&&(u?.items.length??0)>0,session:Ne(c,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:c}=e,u=a==null?void 0:c.diagnosticsBySession[a],d=Ne(c,a),p=c.actionStateByKind.retry?.fetchState==="In-Progress",v=c.actionStateByKind.rollback?.fetchState==="In-Progress",m=d?.status==="done"&&d.rollback_available_until!=null&&new Date(d.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(_e({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:d?.status!=="failed"||p?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(ze(a)))},onRollback:m?()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(Dn(a)))}:void 0}}))(Et);function ga(){const t=L(),e=P(),{sessionId:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),[o,c]=r.useState({}),u=E(Qe),d=E(Ce),p=r.useMemo((()=>{const C=te.getSignedInUser();return{userId:C?.userId??"",sessionId:C?.zeniSessionId??"",tenantId:d.tenantId}}),[d.tenantId]),v=Ne(u,n),m=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(Fe(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const C=setTimeout((()=>{t(_e({...o,sessionId:n}))}),300);return()=>clearTimeout(C)}),[a,t,o,n]);const S=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!S)return;const C=setInterval((()=>{t(Fe(n)),t(_e({...o,sessionId:n}))}),3e3);return()=>clearInterval(C)}),[a,t,o,S,n]);const f=r.useMemo((()=>{if(n==null)return"";const C=new URLSearchParams;o.moduleId!=null&&C.set("module_id",o.moduleId),o.level!=null&&C.set("level",o.level),o.outcome!=null&&C.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&C.set("search",o.search.trim());const h=C.toString();return`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=m?.fetch.fetchState??"Not-Started";return N(I)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),s.jsx(ua,{authParams:p,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:c})]})}const Zn=t=>`invoicing_active_migration:${t}`,ve=(t,e)=>{if(t!=null&&t!=="")try{const n=Zn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ma=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const c=o??null;t(me(c)),ve(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(ze(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Dn(o))},onViewSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(yt);function va(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),a=E(Qe);r.useEffect((()=>{i&&(t(Ei()),t(jn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ma,{navigate:e,tenantEmailDomain:n,view:a})]})}const pa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:c,view:u}=e,{actionStateByKind:d,sessionDetail:p,sessions:v}=u,m=a.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),S=n!=null?p[n]:void 0;return{authParams:i,templatesDownloadUrl:c,chargebeeConnected:o?.chargebee_connected===!0||(m?.isValid??!1),chargebeeConnectorAvailable:m!=null,chargebeeSite:o?.chargebee_site,connectError:d.connect?.error?.message,connecting:d.connect?.fetchState==="In-Progress",retrying:d.retry?.fetchState==="In-Progress",session:S??v.find((f=>f.id===n)),starting:d.start?.fetchState==="In-Progress",uploading:d.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(l.Event.invoicingChargebeeConnectClicked),t(xi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(ze(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportStarted),n!=null&&t(bi(n))},onUpload:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportFileUploaded),t(yi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(bt);function Sa(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),a=E(Cn),o=E(Ce),c=r.useMemo((()=>{const h=te.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,d=o.companyId??te.getSignedInUserTenant(n??"")?.companyId,p=E((h=>Ln(h,d))),v=E(Qe),{activeMigrationSessionId:m}=v,S=m??void 0,f=S!=null?v.sessionDetail[S]??v.sessions.find((h=>h.id===S)):void 0;r.useEffect((()=>{i&&(t(Ke()),t(jn()))}),[i,t]),r.useEffect((()=>{if(m!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Zn(y))}catch{return null}})(n);h!=null&&t(me(h))}),[m,t,n]),r.useEffect((()=>{ve(n,m)}),[m,n]);const I=f?.status,C=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||S==null||!C)return;const h=setInterval((()=>{t(Fe(S))}),3e3);return()=>clearInterval(h)}),[i,S,C,t]),r.useEffect((()=>{I==="done"&&(t(me(null)),ve(n,null))}),[t,I,n]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDataImportMigratePage}),s.jsx(pa,{activeId:S,authParams:c,integrationsView:p,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(me(null)),ve(n,null),e(`/${n}/invoicing/data_import`)}})]})}const fa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(Pn({action:a,id:i}))},onSaveEdit:a=>{const{coupon:o}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingCouponEdited,{couponId:i,mode:"edit",...B(a,{invoice_name:o?.invoiceName,invoice_notes:o?.invoiceNotes,max_redemptions:o?.maxRedemptions,name:o?.name},["invoice_notes"])}),t(Di({data:a,id:i}))}}}))(xt);function Ia(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=E((I=>Ai(I,n))),c=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,d=u==="Completed",[p,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const m=p===n;r.useEffect((()=>(t(W({id:n})),()=>{t(W({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(Re({id:n}))}),[a,n,t]);const S=r.useCallback((I=>t(Re({cacheOverride:!0,id:I}))),[t]),f=ce(o.fetchState,o.isFormLoading,n,S);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),s.jsx(fa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},f)]})}const ha=O((function(t){const e=wn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(Pn({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(Li({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(At);function Ca(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,couponListFetchState:h,runningDiscountActionId:y}=E((b=>{const A=wn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ae({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDiscountsListPage,isReady:D}),s.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>{t(ji(b)),t(Ae({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const ka=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",step:n.step}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,c={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...c,action:"cancel",fromScreen:"dunning_detail"}),t(K({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...c,action:"resolve",fromScreen:"dunning_detail"}),t(K({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...c,action:"resume",fromScreen:"dunning_detail"}),t(K({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...c,action:"retry",fromScreen:"dunning_detail"}),t(K({action:"retry",id:i}))}:void 0}}))(jt);function Ea(){const t=L(),e=P(),{case_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=E((k=>Pi(k,n??""))),c=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,p]=r.useState("idle"),[v,m]=r.useState(!1),[S,f]=r.useState(),[I,C]=r.useState(!1),h=r.useCallback((()=>{p("idle"),m(!1),f(void 0),C(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(wi({id:n})),p("idle"),m(!1);const k=o.emailPreview.preview;f(k==null?void 0:{body:k.body,cc:k.cc,subject:k.subject,to:k.to}),C(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((k=>{n!=null&&d!=="pending"&&(m(!1),p("pending"),g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(K({action:"send-email",body:k,id:n})))}),[n,t,d,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(Ri({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(ke({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{p("idle"),m(!1),f(void 0),C(!1)}),[n]),r.useEffect((()=>{a||(p("idle"),m(!1),f(void 0),C(!1))}),[a]),r.useEffect((()=>{I&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t($i({id:n})),h()):v&&o.actionState.fetchState==="Error"&&p("failed"):m(!0))}),[n,h,t,d,v,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(ka,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),s.jsx(Dt,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:d==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:d==="failed"?o.actionState.error?.message:void 0})]})}const ya=O((function(t){const e=Rn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,stepById:e.stepById,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((c=>c.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...i(a),action:o}),t(K({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(_i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Lt);function ba(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,dunningCaseListFetchState:h,dunningCases:y}=E((b=>{const A=Rn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(De({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(De({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDunningListPage,isReady:D}),s.jsx(ya,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,dunningCases:y,nextCursor:C,onSearchChange:o,onStatusChange:b=>{t(Fi(b)),t(De({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const xa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:c=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(c)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(q({action:"regenerate",invoiceId:i}))},onSaveEdit:c=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(c,{due_date:a?.dueDate?.format("YYYY-MM-DD")??"",notes:(a?.notes??[]).map((u=>u.note)).filter((u=>u!=null&&u!=="")).join(`
1
+ import{j as s}from"./liveblocks-CuUK5O_2.js";import{a as r}from"./sentry-D0lP5-8e.js";import{u as L,h as P,i as $,j as E,t as oe,l as O,s as z,g as ae,N as H,n as me,o as x}from"./core-BBlQ3ArL.js";import{a9 as ct,d as m,aC as _,U as l,du as rt,dv as dt,dw as lt,dx as ut,dy as mt,dz as gt,dA as vt,dB as pt,dC as St,dD as ft,dE as It,dF as ht,q as se,dG as Ct,dH as kt,z as te,af as pe,dI as Et,dJ as yt,dK as bt,dL as xt,dM as At,dN as Dt,dO as jt,dP as Lt,dQ as Pt,dR as wt,V as Rt,az as pn,dS as $t,dT as Ft,dU as _t,dV as Tt,dW as Ot,dX as Mt,dY as Nt,dZ as Ut,d_ as Bt,d$ as Vt,e0 as Ht,t as en,m as Ue,e1 as qt,e2 as Qt,e3 as zt,e4 as Kt,e5 as Gt,e6 as Yt,Z as Wt,aZ as Jt}from"./index-ClwW47Zs.js";import"./mui--aGBnNu2.js";import{A as X}from"./AddressScreen-Czlolp2X.js";import M from"./NotFoundScreen-CTik05r2.js";import{a28 as Xt,a29 as Zt,vG as nn,v as ei,a2a as Z,wh as Se,a2b as Be,a2c as Y,wU as we,w$ as ni,dI as Sn,x3 as fn,a2d as Ve,wY as ti,yE as tn,wg as on,a2e as In,a2f as W,xe as Re,xi as ii,a2g as oi,xs as ai,a2h as hn,xl as Cn,zc as si,a2i as he,a2j as an,a2k as kn,wc as ci,a2l as ri,w4 as di,a2m as li,yR as ui,a2n as En,y_ as be,a2o as mi,yX as gi,a2p as He,gk as qe,a2q as le,a2r as ue,xA as vi,wm as sn,wr as yn,wp as pi,wj as Si,xt as fi,wt as Ii,xC as hi,cP as bn,a2s as $e,xL as xn,xJ as Q,xH as G,xG as Ci,a2t as fe,z5 as xe,a2u as ki,we as An,a2v as Qe,fI as Ce,wC as Fe,wz as _e,wM as Dn,wL as ze,ww as Ei,wF as jn,wO as ge,Yd as Ln,wi as Ke,wJ as yi,wK as bi,wI as xi,a2w as Ai,xj as Di,xf as Pn,a2x as wn,vX as Ae,a2y as ji,vQ as Li,a2z as Pi,zb as wi,zg as K,za as Ri,yi as ke,a2A as $i,a2B as Rn,zp as De,a2C as Fi,zm as _i,a2D as $n,yl as Ti,ym as q,yp as Oi,a2E as Fn,yz as je,a2F as Mi,xB as _n,U_ as Tn,a2G as Ni,yJ as Ui,a2H as On,a2I as cn,a2J as Bi,a2K as Vi,Ac as Hi,a2L as qi,a2M as Mn,zw as Nn,a2N as Un,Aa as Le,a2O as Qi,A7 as zi,a2P as Ki,a2Q as Gi,a2R as Yi,a2S as Wi,a2T as Ji,a2U as rn,a2V as Xi,Ag as Zi,ea as eo,a2W as Ge,xV as no,xQ as to,cR as Te,a2X as ee,xZ as Bn,y5 as Vn,a2Y as Ye,x_ as ie,ya as io,yd as Hn,a2Z as oo,a2_ as Oe,y9 as ao,a2$ as qn,z$ as Pe,zW as so,a30 as co,zB as ro,a31 as lo,A0 as uo,A4 as mo,a32 as We,wW as Qn,zN as go,wX as vo,a33 as po,a34 as zn,c7 as So,mD as fo,mE as Io,a35 as dn,wV as ne,go as ho,mK as Co,zT as Kn,As as ko,zQ as Gn,vc as Eo,v0 as yo,i1 as bo,Vl as ln,Vm as xo,GT as Yn,Ap as Ao,hV as Do,Am as jo,a36 as Lo,a37 as Po,Ay as wo,Ax as Ro,a38 as $o,a39 as Wn,Av as Fo,a3a as _o,a3b as To,yN as Oo,a3c as Mo}from"./zeni-epic-state-aUBx6G2Q.js";import{M as No}from"./MobileAppDrawer-Bql3K6nh.js";import{q as Ie}from"./QBOConnectionScreen-BEn_CddB.js";import"./recharts-CkREU3LH.js";import"./analytics-D051O7ML.js";import"./plaid-7P9b69CP.js";import"./dnd-CU3yeazS.js";import"./stripe-cKAAJElX.js";import"./lottie-Du4lbH8J.js";import"./lexical-DVH-xgq1.js";import"./pdf-CrvsvvW3.js";import"./utils-Ctp9Zfhk.js";import"./InboxNotificationsProvider-DiTDJFwP.js";import"./useTaskManagerAccess-DrmpkeUw.js";import"./empty-BiAWzWBi.js";import"./pdf-lib-Cvsvldn7.js";import"./index--CQENyaz.js";import"./url-nN4BnP9N.js";import"./index-ae04Qn4V.js";import"./decodeURIComponentSafe-YbpxzvKa.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="36b65a20-dfea-491d-9556-12c8223c4295",t._sentryDebugIdIdentifier="sentry-dbid-36b65a20-dfea-491d-9556-12c8223c4295")}catch{}})();const R=({event:t,isReady:e=!0})=>e?s.jsx(ct,{analytics:m,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Uo(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),{fetchState:g,hasMore:S,items:f,nextCursor:I,auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h}=E(Xt),y=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),D=`/${n??""}/invoicing`,b=r.useCallback(((F,U)=>{const T=Zt(D,F,U,C);T!=null&&(m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:F,entityId:U,fromScreen:"audit_log",toScreen:F}),e(T))}),[C,e,D]);r.useEffect((()=>{const F=setTimeout((()=>u(a)),300);return()=>clearTimeout(F)}),[a]),r.useEffect((()=>{i&&t(nn({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=g==="Not-Started"||g==="In-Progress"&&f.length===0,k=g==="In-Progress"&&f.length>0,j=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingAuditLogPage,isReady:j}),s.jsx(rt,{auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h,entries:f,hasMore:S,isLoading:A,isLoadingMore:k,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{S&&I!=null&&t(nn({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:p})]})}const Jn=["company","email","firstName","invoiceNotes","lastName","notes","phone","vatNumber"],Me=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:Array.isArray(t)?t.map(Me):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map((([e,n])=>[e,Me(n)]))):null;function B(t,e,n=[]){const i=t,a=e,o=[...new Set([...Object.keys(i),...Object.keys(a??{})])].filter((u=>{if(a==null)return(d=i[u])!=null&&d!==""&&(Array.isArray(d)?d.length>0:typeof d!="object"||Object.keys(d).length>0);var d;return!(i[u]==null&&a[u]==null)&&!ei(i[u],a[u])})).sort(),c=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Me(i[u])])));return{fieldsChanged:o,formValues:c}}function Ee(t,e=!1){const n=L(),i=E((c=>Z(c).productNextCursor!=null)),a=E((c=>Z(c).productNextCursor)),o=E((c=>Z(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(Se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(Se({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function ce(t,e,n,i){const[a,o]=r.useState(0),[c,u]=r.useState(!1),d=r.useRef(t);return r.useEffect((()=>{const p=d.current==="In-Progress";d.current=t,t==="Completed"&&p&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{c&&!e&&(u(!1),o((p=>p+1)))}),[c,e]),a}const Bo=new Set(["plan"]),Vo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(m.trackInvoicingActionClick(l.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ti({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(Ve({id:i,localData:a}))},onSaveEdit:()=>{m.trackInvoicingActionClick(l.Event.invoicingCatalogItemEdited,{itemId:i,mode:"edit",...B(e.view.localData,Sn(e.view.plan))}),t(fn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(ni({action:o,id:a,parentItemId:i}))}}}))(dt);function Ho(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=$(),[a]=oe(),{areTenantIdsInSync:o}=_(),c=(u=a.get("kind"))!=null&&Bo.has(u)?u:"plan";var u;const d=E((y=>Be(y,n))),{pageFetchState:p}=d,v=p.fetchState;r.useEffect((()=>(t(Y({id:n})),()=>{t(Y({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(we({id:n,kind:c}))}),[o,n,c,t]);const g=r.useCallback((y=>t(we({cacheOverride:!0,id:y,kind:c}))),[t,c]),S=ce(d.fetchState,d.isFormLoading,n,g),f=v==="Completed"&&!d.isFormLoading;Ee(o,!0);const[I,C]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&C(n)}),[n,f]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||d.isFormLoading);return N(v)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Vo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:h,view:d},S)]})}const qo=new Set(["addon","charge","plan"]),Qo=new Set(["plan"]),zo=O((function(t,e){const n=Be(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedItem:n.plan,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e,a=i!=null?`${n}/catalog/${encodeURIComponent(i)}`:`${n}/catalog`;return{onBack:()=>{t(Y({id:i})),e.navigate(a)},onCancel:()=>{m.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(Y({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ve({id:i,localData:o}))},onSubmit:()=>{t(fn({id:i}))}}}),(function({savedItem:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{m.trackInvoicingActionClick(l.Event.invoicingCatalogItemSaved,{itemId:i.itemId,mode:e.mode,...B(e.localData,t!=null?Sn(t):void 0)}),n.onSubmit()}}}))(lt);function Ko(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=$(),[a]=oe(),{areTenantIdsInSync:o}=_(),c=n!=null,u=a.get("type"),d=u!=null&&qo.has(u)?u:void 0,p=(v=a.get("kind"))!=null&&Qo.has(v)?v:"plan";var v;const g=E((f=>Be(f,n)));Ee(o,!0);const S=r.useRef();return r.useEffect((()=>(clearTimeout(S.current),()=>{S.current=setTimeout((()=>{t(Y({id:n}))}),0)})),[n,t]),r.useEffect((()=>{o&&t(we({id:n,kind:p}))}),[o,n,p,t]),r.useEffect((()=>{c||d==null||g.localData.catalogType===d||t(Ve({localData:{...g.localData,catalogType:d}}))}),[c,d,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const f=g.savedItemId??n,I=f!=null?`/${i}/invoicing/catalog/${encodeURIComponent(f)}`:`/${i}/invoicing/catalog`;e(I),t(Y({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCatalogItemFormPage}),s.jsx(zo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:c,itemId:n})]})}const Go={addons:"addon",all:"item",charges:"charge",plans:"plan"},Yo=O((function(t,e){const n=Z(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,c=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,planRows:n.planRows,productRows:n.productRows}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Go[e.activeTab];m.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,u)=>{m.trackInvoicingActionClick(l.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(m.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(on({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(Se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?on({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):Se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Wo(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState("plans"),[d,p]=r.useState(""),[v,g]=r.useState(null),S=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),f=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),C=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),h=E((j=>Z(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,k=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>p(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1,planFilters:I,productFilters:C,planSort:S,productSort:S}))}),[i,t,I,C,S]),r.useEffect((()=>{i&&(f!==y||S?.field!==D?.field||S?.dir!==D?.dir)&&t(tn({cacheOverride:!0,planFilters:I,productFilters:C,planSort:S,productSort:S}))}),[y,D,i,t,I,C,f,S]),N(h.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCatalogPage,isReady:k}),s.jsx(Yo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:a,sortState:v,planFilters:I,productFilters:C,sort:S,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:g})]})}const Jo=O((function(t,e){const n=In(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCoupon:n.coupon,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>{t(W({id:i})),e.navigate(a)},onCancel:()=>{m.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(W({id:i})),e.navigate(`${n}/discounts`)},onChange:o=>{t(oi({id:i,localData:o}))},onSubmit:()=>{t(ii({id:i}))}}}),(function({savedCoupon:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{m.trackInvoicingActionClick(l.Event.invoicingCouponSaved,{couponId:i.couponId,mode:e.mode,...B(e.localData,t!=null?ai(t):void 0)}),n.onSubmit()}}}))(mt);function Xo(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),{fetchState:o,savedCouponId:c}=E((d=>In(d,n))),u=r.useRef();return r.useEffect((()=>(clearTimeout(u.current),()=>{u.current=setTimeout((()=>{t(W({id:n}))}),0)})),[n,t]),r.useEffect((()=>{a&&t(Re({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=c??n,p=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(p),t(W({id:n}))}}),[o,c,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCouponFormPage}),s.jsx(Jo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Zo=O((function(t){const e=hn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{m.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(kn(a))},onSubmit:()=>{const a=ri(t.localData);m.trackInvoicingActionClick(l.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length,mode:"create",...B(t.localData,void 0,["memo"])}),e(di(a))}}}))(vt);function ea(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),[i]=oe(),{areTenantIdsInSync:a}=_(),o=i.get("customerId"),c=E((b=>hn(b))),u=c.fetchState,d=c.localData,p=c.savedInvoiceId,v=E(Cn),g=E((b=>si(b))),S=E(he),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&v==null,I=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,C=f||I,h=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(an()),()=>{t(an())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||d.customerId!==""||(y.current=!0,t(kn({...d,customerId:o})))}),[o,d,t]),r.useEffect((()=>{a&&t(ci({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=p!=null?`/${n}/invoicing/invoices/${encodeURIComponent(p)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,p,e,n]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),C?s.jsx(gt,{}):s.jsx(Zo,{navigate:e,tenantEmailDomain:n})]})}const na=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(pt);function ta(){const t=L(),e=P(),{credit_note_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=E((u=>li(u,n??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ui({id:n}))}),[a,n,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(na,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const ia=O((function(t){const e=En(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{m.trackInvoicingActionClick(l.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(m.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(gi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(St);function oa(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,creditNoteListFetchState:h}=E((D=>{const b=En(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(be({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:g,sort:v}))}),[i,t,g,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCreditsListPage,isReady:y}),s.jsx(ia,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:g,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(mi(D)),t(be({cacheOverride:!1,filters:g,sort:v}))},onSortChange:p})]})}const Xn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},aa=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t($e({id:i,localData:a}))},onCreateInvoice:()=>{m.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{m.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{m.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(Q(G)),t(Ci({id:i}))},onOpenAddress:()=>{const a=Xn(e.tenantEmailDomain??"",G,i),o=se(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{m.trackInvoicingActionClick(l.Event.invoicingCustomerEdited,{customerId:i,mode:"edit",...B(a,e.editView.record.invoicingCustomer!=null?bn(e.editView.record.invoicingCustomer):void 0,Jn)}),t($e({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(hi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>{m.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Ii({body:c,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function sa(){const t=L(),e=P(),n=ae(),{customer_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=_(),c=E((T=>He(T,i))),u=c.pageFetchState.fetchState,d=u==="Completed"&&!c.isFormLoading,[p,v]=r.useState(!1),[g,S]=r.useState(!1),[f,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const C=f===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=c,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=c.record,k=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const T=c.record.sendLinkState.fetchState;k.current!=="Error"&&T==="Error"&&t(qe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),k.current=T}),[t,c.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(le()),t(ue()),()=>{t(le()),t(ue())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(vi({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(sn({customerId:i}))}),[o,i,t,A]);const F=r.useCallback((T=>t(yn({id:T}))),[t]),U=ce(c.fetchState,c.isFormLoading,i,F);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),s.jsx(aa,{customerId:i??"",editView:c,hasLoadedRecord:C,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{m.trackInvoicingActionClick(l.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(le()),i!=null&&A&&t(sn({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ue()),S(!0)}},U),s.jsx(ft,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:p,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(Si({customerId:i}))},onClose:()=>{v(!1),t(le())},onSavePaymentMethod:T=>{i!=null&&(m.trackInvoicingActionClick(l.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(pi({customerId:i,data:T})))}}),s.jsx(It,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:g,submitSucceeded:y.fetchState==="Completed",onClose:()=>{S(!1),t(ue())},onSubmit:({amount:T,description:de})=>{i!=null&&(m.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(fi({amount:T,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:de})))}})]})}const ca=O((function(t,e){const n=He(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCustomer:n.record.invoicingCustomer}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>{t(fe({id:i})),t(Q(G)),e.navigate(a)},onCancel:()=>{m.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(fe({id:i})),t(Q(G)),e.navigate(`${n}/customers`)},onChange:o=>{t($e({id:i,localData:o}))},onOpenAddress:()=>{m.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Xn(e.tenantEmailDomain??"",G,i),c=se(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(o,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{t(xn({id:i}))}}}),(function({savedCustomer:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{m.trackInvoicingActionClick(l.Event.invoicingCustomerSaved,{customerId:i.customerId,mode:e.mode,...B(e.localData,t!=null?bn(t):void 0,Jn)}),n.onSubmit()}}}))(Ct);function ra(){const t=L(),e=P(),n=ae(),{customer_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=_(),{fetchState:c,savedCustomerId:u}=E((g=>He(g,i))),d=r.useRef(!1),p=r.useCallback((()=>{d.current=!0}),[]),v=r.useRef();return r.useEffect((()=>(clearTimeout(v.current),d.current=!1,()=>{d.current||(v.current=setTimeout((()=>{t(fe({id:i})),t(Q(G))}),0))})),[i,t]),r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(c==="Completed"){const g=u??i,S=g!=null?`/${a}/invoicing/customers/${encodeURIComponent(g)}`:`/${a}/invoicing/customers`;e(S),t(fe({id:i}))}}),[c,u,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCustomerFormPage}),s.jsx(ca,{customerId:i,keepDraftOnLeave:p,location:n,navigate:e,tenantEmailDomain:a})]})}const da=O((function(t){const e=he(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{m.trackInvoicingActionClick(l.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{m.trackInvoicingActionClick(l.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":m.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":m.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":m.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(m.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(An({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(kt);function la(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,customerListFetchState:h}=E((D=>{const b=he(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:g,sort:v}))}),[i,t,g,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingCustomersListPage,isReady:y}),s.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:g,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(ki(D)),t(xe({cacheOverride:!1,filters:g,sort:v}))},onSortChange:p})]})}const Ne=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ua=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:c}=e,u=o==null?void 0:c.diagnosticsBySession[o],d=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:d==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:d==="Not-Started"||d==="In-Progress",isLoadingMore:d==="In-Progress"&&(u?.items.length??0)>0,session:Ne(c,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:c}=e,u=a==null?void 0:c.diagnosticsBySession[a],d=Ne(c,a),p=c.actionStateByKind.retry?.fetchState==="In-Progress",v=c.actionStateByKind.rollback?.fetchState==="In-Progress",g=d?.status==="done"&&d.rollback_available_until!=null&&new Date(d.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(_e({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:d?.status!=="failed"||p?void 0:()=>{a!=null&&(m.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(ze(a)))},onRollback:g?()=>{a!=null&&(m.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(Dn(a)))}:void 0}}))(Et);function ma(){const t=L(),e=P(),{sessionId:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),[o,c]=r.useState({}),u=E(Qe),d=E(Ce),p=r.useMemo((()=>{const C=te.getSignedInUser();return{userId:C?.userId??"",sessionId:C?.zeniSessionId??"",tenantId:d.tenantId}}),[d.tenantId]),v=Ne(u,n),g=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(Fe(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const C=setTimeout((()=>{t(_e({...o,sessionId:n}))}),300);return()=>clearTimeout(C)}),[a,t,o,n]);const S=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!S)return;const C=setInterval((()=>{t(Fe(n)),t(_e({...o,sessionId:n}))}),3e3);return()=>clearInterval(C)}),[a,t,o,S,n]);const f=r.useMemo((()=>{if(n==null)return"";const C=new URLSearchParams;o.moduleId!=null&&C.set("module_id",o.moduleId),o.level!=null&&C.set("level",o.level),o.outcome!=null&&C.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&C.set("search",o.search.trim());const h=C.toString();return`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=g?.fetch.fetchState??"Not-Started";return N(I)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),s.jsx(ua,{authParams:p,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:c})]})}const Zn=t=>`invoicing_active_migration:${t}`,ve=(t,e)=>{if(t!=null&&t!=="")try{const n=Zn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ga=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const c=o??null;t(ge(c)),ve(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{m.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{m.trackInvoicingActionClick(l.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{m.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(ze(o)),a(o)},onRollbackSession:o=>{m.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Dn(o))},onViewSession:o=>{m.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(yt);function va(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),a=E(Qe);r.useEffect((()=>{i&&(t(Ei()),t(jn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ga,{navigate:e,tenantEmailDomain:n,view:a})]})}const pa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:c,view:u}=e,{actionStateByKind:d,sessionDetail:p,sessions:v}=u,g=a.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),S=n!=null?p[n]:void 0;return{authParams:i,templatesDownloadUrl:c,chargebeeConnected:o?.chargebee_connected===!0||(g?.isValid??!1),chargebeeConnectorAvailable:g!=null,chargebeeSite:o?.chargebee_site,connectError:d.connect?.error?.message,connecting:d.connect?.fetchState==="In-Progress",retrying:d.retry?.fetchState==="In-Progress",session:S??v.find((f=>f.id===n)),starting:d.start?.fetchState==="In-Progress",uploading:d.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{m.trackInvoicingActionClick(l.Event.invoicingChargebeeConnectClicked),t(xi())},onGoToIntegrations:()=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(m.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(ze(n)))},onSaveLater:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportStarted),n!=null&&t(bi(n))},onUpload:o=>{m.trackInvoicingActionClick(l.Event.invoicingImportFileUploaded),t(yi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(bt);function Sa(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),a=E(Cn),o=E(Ce),c=r.useMemo((()=>{const h=te.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,d=o.companyId??te.getSignedInUserTenant(n??"")?.companyId,p=E((h=>Ln(h,d))),v=E(Qe),{activeMigrationSessionId:g}=v,S=g??void 0,f=S!=null?v.sessionDetail[S]??v.sessions.find((h=>h.id===S)):void 0;r.useEffect((()=>{i&&(t(Ke()),t(jn()))}),[i,t]),r.useEffect((()=>{if(g!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Zn(y))}catch{return null}})(n);h!=null&&t(ge(h))}),[g,t,n]),r.useEffect((()=>{ve(n,g)}),[g,n]);const I=f?.status,C=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||S==null||!C)return;const h=setInterval((()=>{t(Fe(S))}),3e3);return()=>clearInterval(h)}),[i,S,C,t]),r.useEffect((()=>{I==="done"&&(t(ge(null)),ve(n,null))}),[t,I,n]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDataImportMigratePage}),s.jsx(pa,{activeId:S,authParams:c,integrationsView:p,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(ge(null)),ve(n,null),e(`/${n}/invoicing/data_import`)}})]})}const fa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{m.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(Pn({action:a,id:i}))},onSaveEdit:a=>{const{coupon:o}=e.editView;m.trackInvoicingActionClick(l.Event.invoicingCouponEdited,{couponId:i,mode:"edit",...B(a,{invoice_name:o?.invoiceName,invoice_notes:o?.invoiceNotes,max_redemptions:o?.maxRedemptions,name:o?.name},["invoice_notes"])}),t(Di({data:a,id:i}))}}}))(xt);function Ia(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=E((I=>Ai(I,n))),c=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,d=u==="Completed",[p,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const g=p===n;r.useEffect((()=>(t(W({id:n})),()=>{t(W({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(Re({id:n}))}),[a,n,t]);const S=r.useCallback((I=>t(Re({cacheOverride:!0,id:I}))),[t]),f=ce(o.fetchState,o.isFormLoading,n,S);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),s.jsx(fa,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},f)]})}const ha=O((function(t){const e=wn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{m.trackInvoicingActionClick(l.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{m.trackInvoicingActionClick(l.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{m.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(Pn({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(m.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(Li({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(At);function Ca(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,couponListFetchState:h,runningDiscountActionId:y}=E((b=>{const A=wn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ae({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:g,sort:v}))}),[i,t,g,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDiscountsListPage,isReady:D}),s.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:g,sort:v,nextCursor:C,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>{t(ji(b)),t(Ae({cacheOverride:!1,filters:g,sort:v}))},onSortChange:p})]})}const ka=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",step:n.step}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,c={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{m.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...c,action:"cancel",fromScreen:"dunning_detail"}),t(K({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{m.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...c,action:"resolve",fromScreen:"dunning_detail"}),t(K({action:"resolve",id:i}))}:void 0,onResume:a?()=>{m.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...c,action:"resume",fromScreen:"dunning_detail"}),t(K({action:"resume",id:i}))}:void 0,onRetry:a?()=>{m.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...c,action:"retry",fromScreen:"dunning_detail"}),t(K({action:"retry",id:i}))}:void 0}}))(jt);function Ea(){const t=L(),e=P(),{case_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=E((k=>Pi(k,n??""))),c=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,p]=r.useState("idle"),[v,g]=r.useState(!1),[S,f]=r.useState(),[I,C]=r.useState(!1),h=r.useCallback((()=>{p("idle"),g(!1),f(void 0),C(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(wi({id:n})),p("idle"),g(!1);const k=o.emailPreview.preview;f(k==null?void 0:{body:k.body,cc:k.cc,subject:k.subject,to:k.to}),C(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((k=>{n!=null&&d!=="pending"&&(g(!1),p("pending"),m.trackInvoicingActionClick(l.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(K({action:"send-email",body:k,id:n})))}),[n,t,d,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(Ri({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(ke({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{p("idle"),g(!1),f(void 0),C(!1)}),[n]),r.useEffect((()=>{a||(p("idle"),g(!1),f(void 0),C(!1))}),[a]),r.useEffect((()=>{I&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t($i({id:n})),h()):v&&o.actionState.fetchState==="Error"&&p("failed"):g(!0))}),[n,h,t,d,v,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(ka,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),s.jsx(Dt,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:d==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:d==="failed"?o.actionState.error?.message:void 0})]})}const ya=O((function(t){const e=Rn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,stepById:e.stepById,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((c=>c.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{m.trackInvoicingActionClick(l.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(m.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...i(a),action:o}),t(K({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(m.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(_i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Lt);function ba(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,dunningCaseListFetchState:h,dunningCases:y}=E((b=>{const A=Rn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(De({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(De({cacheOverride:!0,filters:g,sort:v}))}),[i,t,g,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDunningListPage,isReady:D}),s.jsx(ya,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:g,sort:v,dunningCases:y,nextCursor:C,onSearchChange:o,onStatusChange:b=>{t(Fi(b)),t(De({cacheOverride:!1,filters:g,sort:v}))},onSortChange:p})]})}const xa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:c=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(c)}`)},onIssueCreditNote:()=>{m.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{m.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{m.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(q({action:"regenerate",invoiceId:i}))},onSaveEdit:c=>{m.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(c,{due_date:a?.dueDate?.format("YYYY-MM-DD")??"",notes:(a?.notes??[]).map((u=>u.note)).filter((u=>u!=null&&u!=="")).join(`
2
2
  `),po_number:a?.poNumber??""},["notes"])}),t(Oi({data:{due_date:c.due_date!==""?c.due_date:void 0,notes:c.notes.trim()!==""?c.notes.split(`
3
- `).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:c.po_number!==""?c.po_number:null},invoiceId:i}))},onSendReminder:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(q({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:c=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:c,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(c)}`)},onVoid:c=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(q({action:"void",invoiceId:i,body:c}))}}}))(Pt);function Aa(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=E((f=>$n(f,n??""))),c=o.pageFetchState.fetchState,u=c==="Completed",[d,p]=r.useState(u?n:void 0);r.useEffect((()=>{n!=null&&u&&p(n)}),[n,u]);const v=d===n;r.useEffect((()=>{a&&n!=null&&t(Ti({invoiceId:n}))}),[a,n,t]);const m=r.useCallback((f=>t(ke({invoiceId:f}))),[t]),S=ce(o.actionState.fetchState,o.fetchState==="In-Progress",n,m);return N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingInvoiceDetailPage,isReady:u}),s.jsx(xa,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},S)]})}const Da=O((function(t){const e=Fn(t),{fetchState:n}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:n==="Not-Started"||n==="In-Progress"&&e.invoices.length===0,isLoadingMore:n==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.invoices.find((c=>c.id===a));return{amount:o?.total?.amount,customerId:o?.customerID,fromScreen:"invoices_list",invoiceId:a,status:o?.status}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRowClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{switch(o){case"recordPayment":g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/record-payment`);break;case"issueCreditNote":g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/issue-credit-note`);break;case"sendReminder":g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,i(a)),t(q({action:"send-reminder",invoiceId:a}));break;case"regenerate":g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,i(a)),t(q({action:"regenerate",invoiceId:a}));break;case"void":g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a}))}},onVoidInvoice:(a,o)=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"invoices",status:e.activeStatus}),t(_n({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(wt);function ja(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=E((A=>{const k=Fn(A);return{activeStatus:k.activeTab,appliedSearch:k.filters.search,appliedSort:A.invoicingInvoiceListState.sort,nextCursor:k.nextCursor,invoiceListFetchState:k.fetchState,voidingInvoiceId:k.runningActionId,invoices:k.invoices}}),z),b=h==="Completed";return r.useEffect((()=>{const A=setTimeout((()=>u(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(je({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingInvoicesListPage,isReady:b}),s.jsx(Da,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,invoices:D,nextCursor:C,voidingInvoiceId:y,onSearchChange:o,onStatusChange:A=>{t(Mi(A)),t(je({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}function un(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),i=Rt(),a=pn(),[o,c]=r.useState(!1),{acceptTermsState:u,status:d}=E(Tn),p=Ni(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,m=S=>{c(S)};return d==="completed"?s.jsx(H,{to:`${v}/overview`,replace:!0}):d==="settings"&&p?s.jsx(H,{to:`${v}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingPromoPage}),s.jsx(No,{isAppContentDrawerOpen:o,handleDrawerToggle:m}),s.jsx($t,{analytics:g,isAccepting:u.fetchState==="In-Progress",isReadOnlyUser:!p,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{g.trackInvoicingActionClick(l.Event.invoicingTermsAccepted),t(Ui())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{m(!0)}})]})}const La=O((function(t,e){const n=On(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:c,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:u}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:a=>{t(qi({localData:a}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Hi())}}}))(Ft);function Pa(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),{fetchState:o,invoice:c,isPageReady:u,issuedCreditNoteId:d,submitState:p}=E((f=>On(f,n??""))),v=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>(t(cn()),m.current=null,()=>{t(cn())})),[t,n]),r.useEffect((()=>{a&&n!=null&&t(ke({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{c!=null&&n!=null&&o==="Completed"&&m.current!==n&&(m.current=n,t(Bi({localData:Vi(c)})))}),[t,o,c,n]);const S=r.useRef(p.fetchState);return r.useEffect((()=>{const f=S.current;S.current=p.fetchState,f!=="Completed"&&p.fetchState==="Completed"&&d!=null&&e(`${v}/credits/${encodeURIComponent(d)}`)}),[d,e,p.fetchState,v]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingIssueCreditNotePage,isReady:u}),s.jsx(La,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const wa=O((function(t){return{invoicingOverview:Mn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingOverviewRefreshed),t(Nn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(_t);function Ra(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),o=E((c=>Mn(c).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Nn(a))}),[i,t,a]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingOverviewPage,isReady:o}),s.jsx(wa,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const $a=O((function(t){const e=Un(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"payments",tab:e.activeType}),t(zi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Tt);function Fa(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:I,nextCursor:C,transactionListFetchState:h,transactions:y}=E((j=>{const F=Un(j);return{activeType:F.activeTab,appliedSearch:F.filters.search,appliedSort:F.sort,nextCursor:F.nextCursor,transactionListFetchState:F.fetchState,transactions:F.transactions}}),z),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const F=y.find((T=>T.id===j)),U=F?.linkedInvoices?.[0]?.invoiceID??F?.invoiceID;U!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${b}/invoices/${encodeURIComponent(U)}`))}),[e,b,y]),k=r.useCallback((j=>{const F=y.find((U=>U.id===j))?.customerID;F!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:F,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(F)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(Le({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Le({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingPaymentsListPage,isReady:D}),s.jsx($a,{navigate:e,tenantEmailDomain:n,activeType:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onTypeChange:j=>{t(Qi(j)),t(Le({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p,onViewTransactionCustomer:k,onViewTransactionInvoice:A})]})}const _a=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function gn(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=n!=null&&n!=="",c=E(he),u=E((k=>Ki(k))),d=E(Gi),p=E((k=>$n(k,n??""))),v=p.invoice,m=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Yi()),S.current=null,f.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?ke({invoiceId:n}):An({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&v!=null&&n!=null&&p.fetchState==="Completed"&&S.current!==n&&(S.current=n,t(Wi({contextInvoiceId:n,localData:Ji(v)})))}),[t,v,n,p.fetchState,o]),r.useEffect((()=>{if(o)return;const k=u.localData.customerId;k!==""&&k!==f.current&&(f.current=k,t(_n({filters:{customerId:k},keepExistingListItems:!1})),u.localData.invoiceToLink!==""&&t(rn({localData:{...u.localData,customerId:k,invoiceToLink:""}})))}),[t,u.localData,o]);const I=r.useRef(d.fetchState);r.useEffect((()=>{const k=I.current;if(I.current=d.fetchState,k!=="Completed"&&d.fetchState==="Completed"){if(d.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(d.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,d.fetchState,d.recordedInvoiceId,m]);const C=r.useMemo((()=>c.customers.map((k=>({id:k.id,name:_a(k)})))),[c.customers]),h=E((k=>Xi(k,u.localData.customerId))),y=r.useMemo((()=>h.map((k=>{return{amountDue:(j=k.amountDue,F=eo.currencySymbol,Nt("0,0.00",j,F)),amountDueValue:k.amountDue,id:k.id,label:k.invoiceNumber};var j,F}))),[h]),D=r.useMemo((()=>{if(!o||v==null)return;const k=v.currencyCode??"USD",j=v.amountDue?.amount??0;return{amountDue:Ot("0,0.00",v.amountDue),amountDueValue:j,currencyCode:k,customerName:v.customerName??v.customerID,invoiceId:v.id,invoiceNumber:v.invoiceNumber??v.id}}),[v,o]),b=o?`${m}/invoices/${encodeURIComponent(n??"")}`:`${m}/payments`,A=!o||p.fetchState==="Completed"&&u.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingRecordPaymentPage,isReady:A}),s.jsx(Mt,{customers:C,fieldHelp:u.fieldHelp,errorMessage:d.fetchState==="Error"?d.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:u.gatewayOptions,invoiceContext:D,invoiceOptions:y,isSubmitting:d.fetchState==="In-Progress",localData:u.localData,mode:o?"invoice":"customer",paymentMethodOptions:u.paymentMethodOptions,onBack:()=>{e(b)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentCancelled),e(b)},onChange:k=>{t(rn({localData:k}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRecorded,{customerId:u.localData.customerId,invoiceId:o?n:u.localData.invoiceToLink,paymentMethod:u.localData.paymentMethod}),t(Zi(o?n??void 0:void 0))}})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Ta=O((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:o,charges:n.charges,coupons:n.coupons,estimate:n.estimate,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(c,u)=>{const{subscription:d}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:c,amount:d?.mrr?.amount,customerId:d?.customerID,fromScreen:"subscription_detail",status:d?.status,subscriptionId:i}),t(Hn({action:c,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:c=>{t(ee({id:i,localData:c}))},onChangeTermEnd:a?c=>{const u=c?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:c=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Q(ie)),t(io({id:i}))},onOpenAddress:()=>{const c=et(e.tenantEmailDomain??"",ie,i),u=se(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onCloseEstimate:()=>{t(Ye())},onRequestEstimate:c=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,{mode:"edit",subscriptionId:i,...B(c,Te(e.editView.subscription))}),t(ee({id:i,localData:c})),t(Vn({id:i}))},onSaveEdit:c=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEdited,{mode:"edit",subscriptionId:i,...B(c,Te(e.editView.subscription))}),t(ee({id:i,localData:c})),t(Bn({id:i}))},onCancelSubscription:a?c=>{o("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(c,u)=>{c!=="pause"?o(c):o(c,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))(Ut);function Oa(){const t=L(),e=P(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=_(),c=E((y=>Ge(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:d,subscriptionMetadataEditAllowedFromStatuses:p}=c,v=c.pageFetchState.fetchState,m=v==="Completed"&&!c.isFormLoading,[S,f]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&f(i)}),[i,m]);const I=S===i;Ee(o),r.useEffect((()=>{o&&i!=null&&t(no({id:i}))}),[o,i,t]);const C=r.useCallback((y=>t(to({id:y}))),[t]),h=ce(c.fetchState,c.isFormLoading,i,C);return N(v)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingSubscriptionDetailPage,isReady:m}),s.jsx(Ta,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:c,lifecycleActionOptions:d,location:n,metadataEditAllowedFromStatuses:p,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},h)]})}const Ma=O((function(t,e){const n=Ge(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,estimate:n.estimate,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,savedSubscription:n.subscription,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e;return{onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionFormCancelled),t(Oe({id:i})),t(Q(ie)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{t(ee({id:i,localData:a}))},onCloseEstimate:()=>{t(Ye())},onRequestEstimate:()=>{t(Vn({id:i}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const a=et(e.tenantEmailDomain??"",ie,i),o=se(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(a,{state:{pathnameStackToGoBack:o}})},onSubmit:()=>{t(Bn({id:i}))}}}),(function({savedSubscription:t,...e},n,i){const a=()=>({mode:e.mode,subscriptionId:i.subscriptionId,...B(e.localData,t!=null?Te(t):void 0)});return{...i,...e,...n,onRequestEstimate:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,a()),n.onRequestEstimate()},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionSaved,a()),n.onSubmit()}}}))(Bt);function Na(){const t=L(),e=P(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=$(),[o]=oe(),{areTenantIdsInSync:c}=_(),u=o.get("customerId"),{fetchState:d,savedSubscriptionId:p}=E((C=>oo(C,i))),v=E((C=>Ge(C,i).localData));Ee(c);const m=r.useRef(!1),S=r.useCallback((()=>{m.current=!0}),[]),f=r.useRef();r.useEffect((()=>(clearTimeout(f.current),m.current=!1,()=>{m.current||(f.current=setTimeout((()=>{t(Oe({id:i})),t(Q(ie)),t(Ye())}),0))})),[i,t]),r.useEffect((()=>{c&&t(ao({subscriptionId:i}))}),[c,i,t]);const I=r.useRef(!1);return r.useEffect((()=>{I.current||i!=null||u==null||u===""||v.customerId!==""||(I.current=!0,t(ee({id:i,localData:{...v,customerId:u}})))}),[u,i,v,t]),r.useEffect((()=>{if(d==="Completed"){const C=p??i,h=C!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(C)}`:`/${a}/invoicing/subscriptions`;e(h),t(Oe({id:i}))}}),[d,p,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingSubscriptionFormPage}),s.jsx(Ma,{keepDraftOnLeave:S,location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Ua=O((function(t){const e=qn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,c)=>{const u=e.subscriptions.find((d=>d.id===a));g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:o,amount:u?.mrr?.amount,customerId:u?.customerID,fromScreen:"subscriptions_list",status:u?.status,subscriptionId:a}),t(Hn({action:o,id:a,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const c=o?.trim()??"";c!==""&&i(a,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(a,o,c)=>{o!=="pause"?i(a,o):i(a,o,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"subscriptions",status:e.activeStatus}),t(ro({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Vt);function Ba(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,subscriptionListFetchState:h,runningActionSubscriptionId:y,subscriptions:D}=E((k=>{const j=qn(k);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,subscriptionListFetchState:j.fetchState,runningActionSubscriptionId:j.runningActionId??null,subscriptions:j.subscriptions}}),z),b=h==="Completed";r.useEffect((()=>{const k=setTimeout((()=>u(a)),300);return()=>clearTimeout(k)}),[a]),r.useEffect((()=>{i&&t(Pe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Pe({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]);const A=r.useRef(y);return r.useEffect((()=>{const k=A.current!=null&&y==null;A.current=y,k&&i&&t(so())}),[y,i,t]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingSubscriptionsListPage,isReady:b}),s.jsx(Ua,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:k=>{t(co(k)),t(Pe({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Va=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{g.trackInvoicingActionClick(l.Event.invoicingTransactionCaptured,{transactionId:i}),t(go({action:"capture",id:i}))}:void 0}}))(Ht);function Ha(){const t=L(),e=P(),{tenantEmailDomain:n,transaction_id:i}=$(),{areTenantIdsInSync:a}=_(),o=E((u=>lo(u,i??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(uo({id:i}))}),[a,i,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Va,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function nt(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=L(),{areTenantIdsInSync:c}=_(),u=E(We),d=u.connection?.connected===!0,p=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(a&&p!=="Not-Started"||o(Qn()),n&&o(mo()))}),[c,o,e,n,a]),r.useEffect((()=>{e&&c&&d&&i&&o(vo())}),[c,o,e,d,i]),{isQboConnected:d,qboView:u}}const qa={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function re(t){const e=L(),{areTenantIdsInSync:n}=_(),{tenantEmailDomain:i}=$(),{fetchState:a,fieldHelp:o,logoFile:c,saveState:u,settings:d,stripeConnectState:p}=E(po),{configError:v,configFetchState:m,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C}=E(zn),h=E(We);nt({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=E(Ce),D=t==="dunning"||t==="quickbooks",b=y.companyId??te.getSignedInUserTenant(i??"")?.companyId,A=E((w=>Ln(w,b))),k=So(y.userRole??[]),j=y.tenantId??"",F=te.getSignedInUser(),U={userId:F?.userId??"",sessionId:F?.zeniSessionId??"",tenantId:j},T=c?.fileId,de=E((w=>T!=null&&T!==""?fo(w,T):void 0)),Je=E((w=>T!=null&&T!==""?Io(w,T):void 0)),tt=T!=null&&T!==""&&de!=null?{[T]:de}:{},it=T!=null&&T!==""&&Je!=null?{[T]:Je}:{};r.useEffect((()=>(e(dn()),()=>{e(dn())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Ke()))}),[n,e,a]),r.useEffect((()=>{n&&D&&m==="Not-Started"&&e(ne())}),[n,e,m,D]),r.useEffect((()=>{if(!n)return;const w=F?.userId;w!=null&&w!==""&&j!==""&&en.shouldFetchActiveTenant(j)&&(en.markActiveTenantFetchStarted(j),e(ho(w,j,F?.zeniSessionId)))}),[n,e,F?.userId,F?.zeniSessionId,j]);const ot=S.length>0||f.length>0,at=a==="Not-Started"||a==="In-Progress"&&d==null||D&&!ot&&(m==="Not-Started"||m==="In-Progress"),st=a==="Completed"&&(!D||m==="Completed"),Xe=A.externalConnections?.revenue?.find((w=>w.connectionName==="chargebee"))?.connectionId,ye=pe?.invoicingMicroServiceBaseUrl,Ze=ye!=null&&ye.length>0?`${ye}/1.0/webhooks/stripe`:"",J={deleteConnectionError:A.externalConnections?.deleteConnectionError?.message,deleteConnectionState:A.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:A,isAdmin:k,isStripeBusy:p.fetchState==="In-Progress",onConnectStripe:w=>{g.trackInvoicingActionClick(l.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(jo(w))},onDisconnect:(w,V)=>{j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingIntegrationDisconnected,{entity:V,entityId:w,fromScreen:t??"hub"}),e(Do(j,w,ln(V))))},onDisconnectStripe:()=>{g.trackInvoicingActionClick(l.Event.invoicingStripeDisconnected,{fromScreen:t??"hub"}),e(Ao())},onReconnectQBO:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:t??"hub"});const w=y.tenantEmailDomain??i??"";Ie.init("/connection/auth",w),Ie.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Yn()))},onSaveChargeBeeCredentials:(w,V)=>{Xe!=null&&j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(bo(j,Xe,ln("revenue"),xo("chargebee"),{api_key:w,site:V})))},saveChargeBeeError:A.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:A.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ze};return{authParams:U,deleteFileStatusById:tt,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:pe?.fileMicroServiceBaseUrl??"",integrationsSectionProps:J,isInvoicingPageReady:st,isLoading:at,isSaving:u.fetchState==="In-Progress",isStripeBusy:p.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C,qboView:h,saveErrorMessage:u.fetchState==="Error"?u.error?.message??"Failed to save settings.":D&&m==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ze,updateFileStatusById:it,onConnectStripe:J.onConnectStripe,onDeleteFile:w=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(yo(w,j))},onDisconnectStripe:J.onDisconnectStripe,onEditFileName:(w,V)=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(Eo(w,V.split(".")[0],j))},onReconnectQBO:J.onReconnectQBO,onRefreshQBO:J.onRefreshQBO,onRetryQboSyncTask:w=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:w,fromScreen:t??"hub"}),e(Gn(w))},onSave:w=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys(w).filter((V=>JSON.stringify(w[V])!==JSON.stringify(d?.[V]))),tab:t??"hub"}),e(ko({settings:w,snackbarSection:qa[t??""]}))},onStartQboBackfill:w=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Kn(w))},updateFilesEntity:w=>{g.trackInvoicingActionClick(l.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(Co({files:w}))}}}function mn({appContent:t}){const e=P(),n=ae(),i=L(),{tenantEmailDomain:a}=$(),o=re("branding"),c=E((d=>Lo(d)));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&i(Po())}),[c.saveState.fetchState,i]);const u=Ue(c.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[u,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(qt,{address:c.address,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:c.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:d=>{i($o({localData:d}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"branding",fromScreen:"settings_branding"});const d=`/${a}/invoicing/settings/branding/${Ro}/`,p=se(n.state?.pathnameStackToGoBack,n.pathname);e(d,{state:{pathnameStackToGoBack:p}})},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{tab:"branding"}),i(wo())},updateFilesEntity:o.updateFilesEntity})]})}function Qa(){const t=P(),e=re("dunning");return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Qt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function za(){const t=P(),e=re("integrations");return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(zt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ka(){const t=P(),e=re("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Kt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Ga=["autoCreateItems","closedPeriodVoidAsCreditMemo","customerMatching","isSyncEnabled","syncStartDate","trackingCategoriesEnabled"],Ya=O((function(t){const e=Wn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,salesTaxPostingAccountName:e.salesTaxPostingAccountName,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(To({localData:e}))},onReset:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsReset,{tab:"quickbooks"}),t(_o())},onRetryTask:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:e,fromScreen:"settings_qbo"}),t(Gn(e))},onStartBackfill:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:"settings_qbo"}),t(Kn(e))}}}))(Gt);function Wa(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),i=E(Ce),{configFetchState:a,localData:o,savedLocalData:c,saveState:u,settingsFetchState:d}=E(Wn),p=r.useMemo((()=>{return m=o,S=c,[...[...new Set([...Object.keys(m.accountIdByMappingCode),...Object.keys(S.accountIdByMappingCode)])].some((f=>(m.accountIdByMappingCode[f]??"")!==(S.accountIdByMappingCode[f]??"")))?["account_mappings"]:[],...Ga.filter((f=>m[f]!==S[f]))];var m,S}),[o,c]),v=Ue(u.fetchState);return r.useEffect((()=>{v==="In-Progress"&&u.fetchState==="Completed"&&e("..")}),[e,v,u.fetchState]),r.useEffect((()=>{d!=="Not-Started"&&d!=="Error"||t(Ke())}),[t,d]),r.useEffect((()=>{a==="Not-Started"&&t(ne())}),[a,t]),nt({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingQboSettingsPage}),s.jsx(Ya,{onBackClick:()=>e(".."),onReconnect:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:"settings_qbo"}),Ie.init("/connection/auth",i.tenantEmailDomain??n??""),Ie.handleClick()},onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:"settings_qbo"}),t(Yn())},onSave:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:p,tab:"quickbooks"}),t(Fo())}})]})}const Ja={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Xa(){const t=pn(),e=L(),n=P(),[i,a]=oe(),o=re(),{canEnableInvoicing:c,isEnablingInvoicing:u,isInvoicingEnabled:d,isQboConfigured:p,isStripeConnected:v}=E(zn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const S=Ja[m];a({},{replace:!0}),S!=null&&n(S,{replace:!0})}),[m,n,a]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Yt,{analytics:g,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:u,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:c,isQboConfigured:p,isStripePaymentsReady:v,onEnableInvoicingClick:d?void 0:()=>{g.trackInvoicingActionClick(l.Event.invoicingEnableClicked),e(Oo())}})]})}function vn(){return s.jsxs(ge,{children:[s.jsx(x,{index:!0,element:s.jsx(Xa,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(Ka,{})}),s.jsx(x,{path:"branding",element:s.jsx(mn,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(mn,{appContent:s.jsx(X,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(za,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Qa,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(Wa,{})}),s.jsx(x,{path:"*",element:s.jsx(H,{to:"..",replace:!0})})]})}function As(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),{enableState:a,fetchState:o,status:c}=E(Tn),u=Ue(a.fetchState),d=`/${n}/invoicing`,p=r.useRef(!1),v=E((m=>We(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||p.current||(p.current=!0,t(ne({cacheOverride:!1}))):t(ne({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&v==="Not-Started"&&t(Qn())}),[i,t,v]),r.useEffect((()=>{u==="In-Progress"&&a.fetchState==="Completed"&&(e(`${d}/catalog`),t(Mo()))}),[u,a.fetchState,d,t,e]),c!=null||o==="Error"&&p.current?c==null?s.jsx(Jt,{onGoHome:()=>e(`/${n??""}`),onReload:()=>t(ne({cacheOverride:!0}))}):c==="not_started"?s.jsxs(ge,{children:[s.jsx(x,{path:"promo",element:s.jsx(un,{})}),s.jsx(x,{path:"*",element:s.jsx(H,{to:`${d}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(ge,{children:[s.jsx(x,{path:"promo",element:s.jsx(un,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(vn,{})}),s.jsx(x,{path:"*",element:s.jsx(H,{to:`${d}/settings`,replace:!0})})]}):s.jsxs(ge,{children:[s.jsx(x,{path:"/",element:s.jsx(H,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx(Ra,{})}),s.jsx(x,{path:"promo",element:s.jsx(H,{to:`${d}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(la,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(ra,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(X,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(sa,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(X,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(Ba,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(Na,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(X,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(Oa,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(X,{})}),s.jsx(x,{path:"invoices",element:s.jsx(ja,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(ea,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(Aa,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(gn,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(Pa,{})}),s.jsx(x,{path:"payments",element:s.jsx(Fa,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(gn,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(Ha,{})}),s.jsx(x,{path:"credits",element:s.jsx(oa,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(ta,{})}),s.jsx(x,{path:"discounts",element:s.jsx(Ca,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(Xo,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(Ia,{})}),s.jsx(x,{path:"dunning",element:s.jsx(ba,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Ea,{})}),s.jsx(x,{path:"catalog",element:s.jsx(Wo,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(Ko,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Ho,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(vn,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(Uo,{})}),s.jsx(x,{path:"data_import",element:s.jsx(va,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(Sa,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(ga,{})}),s.jsx(x,{path:"*",element:s.jsx(M,{})})]}):s.jsx(Wt,{fetchState:"In-Progress"})}export{As as default};
3
+ `).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:c.po_number!==""?c.po_number:null},invoiceId:i}))},onSendReminder:()=>{m.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(q({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:c=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:c,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(c)}`)},onVoid:c=>{m.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(q({action:"void",invoiceId:i,body:c}))}}}))(Pt);function Aa(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=E((f=>$n(f,n??""))),c=o.pageFetchState.fetchState,u=c==="Completed",[d,p]=r.useState(u?n:void 0);r.useEffect((()=>{n!=null&&u&&p(n)}),[n,u]);const v=d===n;r.useEffect((()=>{a&&n!=null&&t(Ti({invoiceId:n}))}),[a,n,t]);const g=r.useCallback((f=>t(ke({invoiceId:f}))),[t]),S=ce(o.actionState.fetchState,o.fetchState==="In-Progress",n,g);return N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingInvoiceDetailPage,isReady:u}),s.jsx(xa,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},S)]})}const Da=O((function(t){const e=Fn(t),{fetchState:n}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:n==="Not-Started"||n==="In-Progress"&&e.invoices.length===0,isLoadingMore:n==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.invoices.find((c=>c.id===a));return{amount:o?.total?.amount,customerId:o?.customerID,fromScreen:"invoices_list",invoiceId:a,status:o?.status}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{m.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:a=>{m.trackInvoicingActionClick(l.Event.invoicingInvoiceRowClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{switch(o){case"recordPayment":m.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/record-payment`);break;case"issueCreditNote":m.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/issue-credit-note`);break;case"sendReminder":m.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,i(a)),t(q({action:"send-reminder",invoiceId:a}));break;case"regenerate":m.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,i(a)),t(q({action:"regenerate",invoiceId:a}));break;case"void":m.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a}))}},onVoidInvoice:(a,o)=>{m.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&(m.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"invoices",status:e.activeStatus}),t(_n({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(wt);function ja(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=E((A=>{const k=Fn(A);return{activeStatus:k.activeTab,appliedSearch:k.filters.search,appliedSort:A.invoicingInvoiceListState.sort,nextCursor:k.nextCursor,invoiceListFetchState:k.fetchState,voidingInvoiceId:k.runningActionId,invoices:k.invoices}}),z),b=h==="Completed";return r.useEffect((()=>{const A=setTimeout((()=>u(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(je({cacheOverride:!0,filters:g,sort:v}))}),[i,t,g,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingInvoicesListPage,isReady:b}),s.jsx(Da,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:g,sort:v,invoices:D,nextCursor:C,voidingInvoiceId:y,onSearchChange:o,onStatusChange:A=>{t(Mi(A)),t(je({cacheOverride:!1,filters:g,sort:v}))},onSortChange:p})]})}function un(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),i=Rt(),a=pn(),[o,c]=r.useState(!1),{acceptTermsState:u,status:d}=E(Tn),p=Ni(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,g=S=>{c(S)};return d==="completed"?s.jsx(H,{to:`${v}/overview`,replace:!0}):d==="settings"&&p?s.jsx(H,{to:`${v}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingPromoPage}),s.jsx(No,{isAppContentDrawerOpen:o,handleDrawerToggle:g}),s.jsx($t,{analytics:m,isAccepting:u.fetchState==="In-Progress",isReadOnlyUser:!p,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{m.trackInvoicingActionClick(l.Event.invoicingTermsAccepted),t(Ui())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{g(!0)}})]})}const La=O((function(t,e){const n=On(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:c,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:u}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:a=>{t(qi({localData:a}))},onSubmit:()=>{m.trackInvoicingActionClick(l.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Hi())}}}))(Ft);function Pa(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),{fetchState:o,invoice:c,isPageReady:u,issuedCreditNoteId:d,submitState:p}=E((f=>On(f,n??""))),v=`/${i}/invoicing`,g=r.useRef(null);r.useEffect((()=>(t(cn()),g.current=null,()=>{t(cn())})),[t,n]),r.useEffect((()=>{a&&n!=null&&t(ke({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{c!=null&&n!=null&&o==="Completed"&&g.current!==n&&(g.current=n,t(Bi({localData:Vi(c)})))}),[t,o,c,n]);const S=r.useRef(p.fetchState);return r.useEffect((()=>{const f=S.current;S.current=p.fetchState,f!=="Completed"&&p.fetchState==="Completed"&&d!=null&&e(`${v}/credits/${encodeURIComponent(d)}`)}),[d,e,p.fetchState,v]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingIssueCreditNotePage,isReady:u}),s.jsx(La,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const wa=O((function(t){return{invoicingOverview:Mn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{m.trackInvoicingActionClick(l.Event.invoicingOverviewRefreshed),t(Nn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{m.trackInvoicingActionClick(l.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{m.trackInvoicingActionClick(l.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{m.trackInvoicingActionClick(l.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(_t);function Ra(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),o=E((c=>Mn(c).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Nn(a))}),[i,t,a]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingOverviewPage,isReady:o}),s.jsx(wa,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const $a=O((function(t){const e=Un(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{m.trackInvoicingActionClick(l.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(m.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"payments",tab:e.activeType}),t(zi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Tt);function Fa(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:I,nextCursor:C,transactionListFetchState:h,transactions:y}=E((j=>{const F=Un(j);return{activeType:F.activeTab,appliedSearch:F.filters.search,appliedSort:F.sort,nextCursor:F.nextCursor,transactionListFetchState:F.fetchState,transactions:F.transactions}}),z),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const F=y.find((T=>T.id===j)),U=F?.linkedInvoices?.[0]?.invoiceID??F?.invoiceID;U!=null&&(m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${b}/invoices/${encodeURIComponent(U)}`))}),[e,b,y]),k=r.useCallback((j=>{const F=y.find((U=>U.id===j))?.customerID;F!=null&&(m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:F,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(F)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(Le({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Le({cacheOverride:!0,filters:g,sort:v}))}),[i,t,g,v,f,I]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingPaymentsListPage,isReady:D}),s.jsx($a,{navigate:e,tenantEmailDomain:n,activeType:S,searchValue:a,sortState:d,filters:g,sort:v,nextCursor:C,onSearchChange:o,onTypeChange:j=>{t(Qi(j)),t(Le({cacheOverride:!1,filters:g,sort:v}))},onSortChange:p,onViewTransactionCustomer:k,onViewTransactionInvoice:A})]})}const _a=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function mn(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=_(),o=n!=null&&n!=="",c=E(he),u=E((k=>Ki(k))),d=E(Gi),p=E((k=>$n(k,n??""))),v=p.invoice,g=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Yi()),S.current=null,f.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?ke({invoiceId:n}):An({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&v!=null&&n!=null&&p.fetchState==="Completed"&&S.current!==n&&(S.current=n,t(Wi({contextInvoiceId:n,localData:Ji(v)})))}),[t,v,n,p.fetchState,o]),r.useEffect((()=>{if(o)return;const k=u.localData.customerId;k!==""&&k!==f.current&&(f.current=k,t(_n({filters:{customerId:k},keepExistingListItems:!1})),u.localData.invoiceToLink!==""&&t(rn({localData:{...u.localData,customerId:k,invoiceToLink:""}})))}),[t,u.localData,o]);const I=r.useRef(d.fetchState);r.useEffect((()=>{const k=I.current;if(I.current=d.fetchState,k!=="Completed"&&d.fetchState==="Completed"){if(d.recordedInvoiceId!=null)return void e(`${g}/invoices/${encodeURIComponent(d.recordedInvoiceId)}`);e(`${g}/payments`)}}),[e,d.fetchState,d.recordedInvoiceId,g]);const C=r.useMemo((()=>c.customers.map((k=>({id:k.id,name:_a(k)})))),[c.customers]),h=E((k=>Xi(k,u.localData.customerId))),y=r.useMemo((()=>h.map((k=>{return{amountDue:(j=k.amountDue,F=eo.currencySymbol,Nt("0,0.00",j,F)),amountDueValue:k.amountDue,id:k.id,label:k.invoiceNumber};var j,F}))),[h]),D=r.useMemo((()=>{if(!o||v==null)return;const k=v.currencyCode??"USD",j=v.amountDue?.amount??0;return{amountDue:Ot("0,0.00",v.amountDue),amountDueValue:j,currencyCode:k,customerName:v.customerName??v.customerID,invoiceId:v.id,invoiceNumber:v.invoiceNumber??v.id}}),[v,o]),b=o?`${g}/invoices/${encodeURIComponent(n??"")}`:`${g}/payments`,A=!o||p.fetchState==="Completed"&&u.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingRecordPaymentPage,isReady:A}),s.jsx(Mt,{customers:C,fieldHelp:u.fieldHelp,errorMessage:d.fetchState==="Error"?d.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:u.gatewayOptions,invoiceContext:D,invoiceOptions:y,isSubmitting:d.fetchState==="In-Progress",localData:u.localData,mode:o?"invoice":"customer",paymentMethodOptions:u.paymentMethodOptions,onBack:()=>{e(b)},onCancel:()=>{m.trackInvoicingActionClick(l.Event.invoicingRecordPaymentCancelled),e(b)},onChange:k=>{t(rn({localData:k}))},onSubmit:()=>{m.trackInvoicingActionClick(l.Event.invoicingPaymentRecorded,{customerId:u.localData.customerId,invoiceId:o?n:u.localData.invoiceToLink,paymentMethod:u.localData.paymentMethod}),t(Zi(o?n??void 0:void 0))}})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Ta=O((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:o,charges:n.charges,coupons:n.coupons,estimate:n.estimate,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(c,u)=>{const{subscription:d}=e.editView;m.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:c,amount:d?.mrr?.amount,customerId:d?.customerID,fromScreen:"subscription_detail",status:d?.status,subscriptionId:i}),t(Hn({action:c,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:c=>{t(ee({id:i,localData:c}))},onChangeTermEnd:a?c=>{const u=c?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:c=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Q(ie)),t(io({id:i}))},onOpenAddress:()=>{const c=et(e.tenantEmailDomain??"",ie,i),u=se(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onCloseEstimate:()=>{t(Ye())},onRequestEstimate:c=>{m.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,{mode:"edit",subscriptionId:i,...B(c,Te(e.editView.subscription))}),t(ee({id:i,localData:c})),t(Vn({id:i}))},onSaveEdit:c=>{m.trackInvoicingActionClick(l.Event.invoicingSubscriptionEdited,{mode:"edit",subscriptionId:i,...B(c,Te(e.editView.subscription))}),t(ee({id:i,localData:c})),t(Bn({id:i}))},onCancelSubscription:a?c=>{o("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(c,u)=>{c!=="pause"?o(c):o(c,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))(Ut);function Oa(){const t=L(),e=P(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=_(),c=E((y=>Ge(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:d,subscriptionMetadataEditAllowedFromStatuses:p}=c,v=c.pageFetchState.fetchState,g=v==="Completed"&&!c.isFormLoading,[S,f]=r.useState(g?i:void 0);r.useEffect((()=>{i!=null&&g&&f(i)}),[i,g]);const I=S===i;Ee(o),r.useEffect((()=>{o&&i!=null&&t(no({id:i}))}),[o,i,t]);const C=r.useCallback((y=>t(to({id:y}))),[t]),h=ce(c.fetchState,c.isFormLoading,i,C);return N(v)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingSubscriptionDetailPage,isReady:g}),s.jsx(Ta,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:c,lifecycleActionOptions:d,location:n,metadataEditAllowedFromStatuses:p,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},h)]})}const Ma=O((function(t,e){const n=Ge(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,estimate:n.estimate,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,savedSubscription:n.subscription,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e;return{onCancel:()=>{m.trackInvoicingActionClick(l.Event.invoicingSubscriptionFormCancelled),t(Oe({id:i})),t(Q(ie)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{t(ee({id:i,localData:a}))},onCloseEstimate:()=>{t(Ye())},onRequestEstimate:()=>{t(Vn({id:i}))},onOpenAddress:()=>{m.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const a=et(e.tenantEmailDomain??"",ie,i),o=se(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(a,{state:{pathnameStackToGoBack:o}})},onSubmit:()=>{t(Bn({id:i}))}}}),(function({savedSubscription:t,...e},n,i){const a=()=>({mode:e.mode,subscriptionId:i.subscriptionId,...B(e.localData,t!=null?Te(t):void 0)});return{...i,...e,...n,onRequestEstimate:()=>{m.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,a()),n.onRequestEstimate()},onSubmit:()=>{m.trackInvoicingActionClick(l.Event.invoicingSubscriptionSaved,a()),n.onSubmit()}}}))(Bt);function Na(){const t=L(),e=P(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=$(),[o]=oe(),{areTenantIdsInSync:c}=_(),u=o.get("customerId"),{fetchState:d,savedSubscriptionId:p}=E((C=>oo(C,i))),v=E((C=>Ge(C,i).localData));Ee(c);const g=r.useRef(!1),S=r.useCallback((()=>{g.current=!0}),[]),f=r.useRef();r.useEffect((()=>(clearTimeout(f.current),g.current=!1,()=>{g.current||(f.current=setTimeout((()=>{t(Oe({id:i})),t(Q(ie)),t(Ye())}),0))})),[i,t]),r.useEffect((()=>{c&&t(ao({subscriptionId:i}))}),[c,i,t]);const I=r.useRef(!1);return r.useEffect((()=>{I.current||i!=null||u==null||u===""||v.customerId!==""||(I.current=!0,t(ee({id:i,localData:{...v,customerId:u}})))}),[u,i,v,t]),r.useEffect((()=>{if(d==="Completed"){const C=p??i,h=C!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(C)}`:`/${a}/invoicing/subscriptions`;e(h),t(Oe({id:i}))}}),[d,p,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingSubscriptionFormPage}),s.jsx(Ma,{keepDraftOnLeave:S,location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Ua=O((function(t){const e=qn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,c)=>{const u=e.subscriptions.find((d=>d.id===a));m.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:o,amount:u?.mrr?.amount,customerId:u?.customerID,fromScreen:"subscriptions_list",status:u?.status,subscriptionId:a}),t(Hn({action:o,id:a,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{m.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{m.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const c=o?.trim()??"";c!==""&&i(a,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(a,o,c)=>{o!=="pause"?i(a,o):i(a,o,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{m.trackInvoicingActionClick(l.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&(m.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"subscriptions",status:e.activeStatus}),t(ro({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Vt);function Ba(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,subscriptionListFetchState:h,runningActionSubscriptionId:y,subscriptions:D}=E((k=>{const j=qn(k);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,subscriptionListFetchState:j.fetchState,runningActionSubscriptionId:j.runningActionId??null,subscriptions:j.subscriptions}}),z),b=h==="Completed";r.useEffect((()=>{const k=setTimeout((()=>u(a)),300);return()=>clearTimeout(k)}),[a]),r.useEffect((()=>{i&&t(Pe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Pe({cacheOverride:!0,filters:g,sort:v}))}),[i,t,g,v,f,I]);const A=r.useRef(y);return r.useEffect((()=>{const k=A.current!=null&&y==null;A.current=y,k&&i&&t(so())}),[y,i,t]),N(h)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingSubscriptionsListPage,isReady:b}),s.jsx(Ua,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:g,sort:v,nextCursor:C,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:k=>{t(co(k)),t(Pe({cacheOverride:!1,filters:g,sort:v}))},onSortChange:p})]})}const Va=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{m.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{m.trackInvoicingActionClick(l.Event.invoicingTransactionCaptured,{transactionId:i}),t(mo({action:"capture",id:i}))}:void 0}}))(Ht);function Ha(){const t=L(),e=P(),{tenantEmailDomain:n,transaction_id:i}=$(),{areTenantIdsInSync:a}=_(),o=E((u=>lo(u,i??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(uo({id:i}))}),[a,i,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Va,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function nt(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=L(),{areTenantIdsInSync:c}=_(),u=E(We),d=u.connection?.connected===!0,p=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(a&&p!=="Not-Started"||o(Qn()),n&&o(go()))}),[c,o,e,n,a]),r.useEffect((()=>{e&&c&&d&&i&&o(vo())}),[c,o,e,d,i]),{isQboConnected:d,qboView:u}}const qa={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function re(t){const e=L(),{areTenantIdsInSync:n}=_(),{tenantEmailDomain:i}=$(),{fetchState:a,fieldHelp:o,logoFile:c,saveState:u,settings:d,stripeConnectState:p}=E(po),{configError:v,configFetchState:g,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C}=E(zn),h=E(We);nt({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=E(Ce),D=t==="dunning"||t==="quickbooks",b=y.companyId??te.getSignedInUserTenant(i??"")?.companyId,A=E((w=>Ln(w,b))),k=So(y.userRole??[]),j=y.tenantId??"",F=te.getSignedInUser(),U={userId:F?.userId??"",sessionId:F?.zeniSessionId??"",tenantId:j},T=c?.fileId,de=E((w=>T!=null&&T!==""?fo(w,T):void 0)),Je=E((w=>T!=null&&T!==""?Io(w,T):void 0)),tt=T!=null&&T!==""&&de!=null?{[T]:de}:{},it=T!=null&&T!==""&&Je!=null?{[T]:Je}:{};r.useEffect((()=>(e(dn()),()=>{e(dn())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Ke()))}),[n,e,a]),r.useEffect((()=>{n&&D&&g==="Not-Started"&&e(ne())}),[n,e,g,D]),r.useEffect((()=>{if(!n)return;const w=F?.userId;w!=null&&w!==""&&j!==""&&en.shouldFetchActiveTenant(j)&&(en.markActiveTenantFetchStarted(j),e(ho(w,j,F?.zeniSessionId)))}),[n,e,F?.userId,F?.zeniSessionId,j]);const ot=S.length>0||f.length>0,at=a==="Not-Started"||a==="In-Progress"&&d==null||D&&!ot&&(g==="Not-Started"||g==="In-Progress"),st=a==="Completed"&&(!D||g==="Completed"),Xe=A.externalConnections?.revenue?.find((w=>w.connectionName==="chargebee"))?.connectionId,ye=pe?.invoicingMicroServiceBaseUrl,Ze=ye!=null&&ye.length>0?`${ye}/1.0/webhooks/stripe`:"",J={deleteConnectionError:A.externalConnections?.deleteConnectionError?.message,deleteConnectionState:A.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:A,isAdmin:k,isStripeBusy:p.fetchState==="In-Progress",onConnectStripe:w=>{m.trackInvoicingActionClick(l.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(jo(w))},onDisconnect:(w,V)=>{j!==""&&(m.trackInvoicingActionClick(l.Event.invoicingIntegrationDisconnected,{entity:V,entityId:w,fromScreen:t??"hub"}),e(Do(j,w,ln(V))))},onDisconnectStripe:()=>{m.trackInvoicingActionClick(l.Event.invoicingStripeDisconnected,{fromScreen:t??"hub"}),e(Ao())},onReconnectQBO:()=>{m.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:t??"hub"});const w=y.tenantEmailDomain??i??"";Ie.init("/connection/auth",w),Ie.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(m.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Yn()))},onSaveChargeBeeCredentials:(w,V)=>{Xe!=null&&j!==""&&(m.trackInvoicingActionClick(l.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(bo(j,Xe,ln("revenue"),xo("chargebee"),{api_key:w,site:V})))},saveChargeBeeError:A.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:A.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ze};return{authParams:U,deleteFileStatusById:tt,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:pe?.fileMicroServiceBaseUrl??"",integrationsSectionProps:J,isInvoicingPageReady:st,isLoading:at,isSaving:u.fetchState==="In-Progress",isStripeBusy:p.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C,qboView:h,saveErrorMessage:u.fetchState==="Error"?u.error?.message??"Failed to save settings.":D&&g==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ze,updateFileStatusById:it,onConnectStripe:J.onConnectStripe,onDeleteFile:w=>{m.trackInvoicingActionClick(l.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(yo(w,j))},onDisconnectStripe:J.onDisconnectStripe,onEditFileName:(w,V)=>{m.trackInvoicingActionClick(l.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(Eo(w,V.split(".")[0],j))},onReconnectQBO:J.onReconnectQBO,onRefreshQBO:J.onRefreshQBO,onRetryQboSyncTask:w=>{m.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:w,fromScreen:t??"hub"}),e(Gn(w))},onSave:w=>{m.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys(w).filter((V=>JSON.stringify(w[V])!==JSON.stringify(d?.[V]))),tab:t??"hub"}),e(ko({settings:w,snackbarSection:qa[t??""]}))},onStartQboBackfill:w=>{m.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Kn(w))},updateFilesEntity:w=>{m.trackInvoicingActionClick(l.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(Co({files:w}))}}}function gn({appContent:t}){const e=P(),n=ae(),i=L(),{tenantEmailDomain:a}=$(),o=re("branding"),c=E((d=>Lo(d)));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&i(Po())}),[c.saveState.fetchState,i]);const u=Ue(c.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[u,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(qt,{address:c.address,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:c.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:d=>{i($o({localData:d}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{m.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"branding",fromScreen:"settings_branding"});const d=`/${a}/invoicing/settings/branding/${Ro}/`,p=se(n.state?.pathnameStackToGoBack,n.pathname);e(d,{state:{pathnameStackToGoBack:p}})},onSubmit:()=>{m.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{tab:"branding"}),i(wo())},updateFilesEntity:o.updateFilesEntity})]})}function Qa(){const t=P(),e=re("dunning");return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Qt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function za(){const t=P(),e=re("integrations");return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(zt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ka(){const t=P(),e=re("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Kt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Ga=["autoCreateItems","closedPeriodVoidAsCreditMemo","customerMatching","isSyncEnabled","syncStartDate","trackingCategoriesEnabled"],Ya=O((function(t){const e=Wn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,salesTaxPostingAccountName:e.salesTaxPostingAccountName,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(To({localData:e}))},onReset:()=>{m.trackInvoicingActionClick(l.Event.invoicingSettingsReset,{tab:"quickbooks"}),t(_o())},onRetryTask:e=>{m.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:e,fromScreen:"settings_qbo"}),t(Gn(e))},onStartBackfill:e=>{m.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:"settings_qbo"}),t(Kn(e))}}}))(Gt);function Wa(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),i=E(Ce),{configFetchState:a,localData:o,savedLocalData:c,saveState:u,settingsFetchState:d}=E(Wn),p=r.useMemo((()=>{return g=o,S=c,[...[...new Set([...Object.keys(g.accountIdByMappingCode),...Object.keys(S.accountIdByMappingCode)])].some((f=>(g.accountIdByMappingCode[f]??"")!==(S.accountIdByMappingCode[f]??"")))?["account_mappings"]:[],...Ga.filter((f=>g[f]!==S[f]))];var g,S}),[o,c]),v=Ue(u.fetchState);return r.useEffect((()=>{v==="In-Progress"&&u.fetchState==="Completed"&&e("..")}),[e,v,u.fetchState]),r.useEffect((()=>{d!=="Not-Started"&&d!=="Error"||t(Ke())}),[t,d]),r.useEffect((()=>{a==="Not-Started"&&t(ne())}),[a,t]),nt({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingQboSettingsPage}),s.jsx(Ya,{onBackClick:()=>e(".."),onReconnect:()=>{m.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:"settings_qbo"}),Ie.init("/connection/auth",i.tenantEmailDomain??n??""),Ie.handleClick()},onRefresh:()=>{m.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:"settings_qbo"}),t(Yn())},onSave:()=>{m.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:p,tab:"quickbooks"}),t(Fo())}})]})}const Ja={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Xa(){const t=pn(),e=L(),n=P(),[i,a]=oe(),o=re(),{canEnableInvoicing:c,isEnablingInvoicing:u,isInvoicingEnabled:d,isQboConfigured:p,isStripeConnected:v}=E(zn),g=i.get("tab");return r.useEffect((()=>{if(g==null)return;const S=Ja[g];a({},{replace:!0}),S!=null&&n(S,{replace:!0})}),[g,n,a]),s.jsxs(s.Fragment,{children:[s.jsx(R,{event:l.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Yt,{analytics:m,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:u,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:c,isQboConfigured:p,isStripePaymentsReady:v,onEnableInvoicingClick:d?void 0:()=>{m.trackInvoicingActionClick(l.Event.invoicingEnableClicked),e(Oo())}})]})}function vn(){return s.jsxs(me,{children:[s.jsx(x,{index:!0,element:s.jsx(Xa,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(Ka,{})}),s.jsx(x,{path:"branding",element:s.jsx(gn,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(gn,{appContent:s.jsx(X,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(za,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Qa,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(Wa,{})}),s.jsx(x,{path:"*",element:s.jsx(H,{to:"..",replace:!0})})]})}function As(){const t=L(),e=P(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=_(),{enableState:a,fetchState:o,status:c}=E(Tn),u=Ue(a.fetchState),d=`/${n}/invoicing`,p=r.useRef(!1),v=E((g=>We(g).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||p.current||(p.current=!0,t(ne({cacheOverride:!1}))):t(ne({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&v==="Not-Started"&&t(Qn())}),[i,t,v]),r.useEffect((()=>{u==="In-Progress"&&a.fetchState==="Completed"&&(e(`${d}/catalog`),t(Mo()))}),[u,a.fetchState,d,t,e]),c!=null||o==="Error"&&p.current?c==null?s.jsx(Jt,{onGoHome:()=>e(`/${n??""}`),onReload:()=>t(ne({cacheOverride:!0}))}):c==="not_started"?s.jsxs(me,{children:[s.jsx(x,{path:"promo",element:s.jsx(un,{})}),s.jsx(x,{path:"*",element:s.jsx(H,{to:`${d}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(me,{children:[s.jsx(x,{path:"promo",element:s.jsx(un,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(vn,{})}),s.jsx(x,{path:"*",element:s.jsx(H,{to:`${d}/settings`,replace:!0})})]}):s.jsxs(me,{children:[s.jsx(x,{path:"/",element:s.jsx(H,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx(Ra,{})}),s.jsx(x,{path:"promo",element:s.jsx(H,{to:`${d}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(la,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(ra,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(X,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(sa,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(X,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(Ba,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(Na,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(X,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(Oa,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(X,{})}),s.jsx(x,{path:"invoices",element:s.jsx(ja,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(ea,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(Aa,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(mn,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(Pa,{})}),s.jsx(x,{path:"payments",element:s.jsx(Fa,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(mn,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(Ha,{})}),s.jsx(x,{path:"credits",element:s.jsx(oa,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(ta,{})}),s.jsx(x,{path:"discounts",element:s.jsx(Ca,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(Xo,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(Ia,{})}),s.jsx(x,{path:"dunning",element:s.jsx(ba,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Ea,{})}),s.jsx(x,{path:"catalog",element:s.jsx(Wo,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(Ko,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Ho,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(vn,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(Uo,{})}),s.jsx(x,{path:"data_import",element:s.jsx(va,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(Sa,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(ma,{})}),s.jsx(x,{path:"*",element:s.jsx(M,{})})]}):s.jsx(Wt,{fetchState:"In-Progress"})}export{As as default};
@@ -1,4 +1,4 @@
1
- import{j as t}from"./liveblocks-UAxYbctH.js";import{i as S,l as g,h as C,g as y,u as ee,t as te,j as E,N as ae,n as ne,o as p}from"./core-BQ6YlWys.js";import{Ve as k,Vf as j,Vg as V,K8 as D,JW as T,Vh as B,Vi as oe,Vj as ie,J_ as se,gl as $,K5 as le,K2 as de}from"./zeni-epic-state-j9Po26Lg.js";import{a2 as x,R as d,a3 as re,d as v,_ as K,a4 as ce,a5 as me,a6 as pe,s as G,p as ue,N as he,a7 as ge,j as xe,m as fe,a8 as we,a9 as be,a0 as Se,aa as ye,ab as ke,ac as je,ad as ve}from"./index-DZBfE5XI.js";import{n as m,u as $e}from"./mui-DYo6Z7Si.js";import f from"./NotFoundScreen-CY-XFa3a.js";import{a as I}from"./sentry-CQfqw6mU.js";import"./recharts-VJtr9O-6.js";import"./analytics-CabaUa1L.js";import"./plaid-BNcFec4W.js";import"./dnd-DL41lZFs.js";import"./stripe-cKAAJElX.js";import"./lottie-BPF4ysWw.js";import"./lexical-BmxGnuDE.js";import"./pdf-CHT1_0Mk.js";import"./utils-BpLD-La5.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]="34b29b45-dca4-4fa8-9ee4-e9765d9c514d",e._sentryDebugIdIdentifier="sentry-dbid-34b29b45-dca4-4fa8-9ee4-e9765d9c514d")}catch{}})();const Ie=m.div`
1
+ import{j as t}from"./liveblocks-CuUK5O_2.js";import{i as S,l as g,h as C,g as y,u as ee,t as te,j as E,N as ae,n as ne,o as p}from"./core-BBlQ3ArL.js";import{Ve as k,Vf as v,Vg as V,K8 as D,JW as T,Vh as B,Vi as oe,Vj as ie,J_ as se,gl as $,K5 as le,K2 as de}from"./zeni-epic-state-aUBx6G2Q.js";import{a2 as x,R as d,a3 as re,d as j,_ as K,a4 as ce,a5 as me,a6 as pe,q as G,p as ue,N as he,a7 as ge,h as xe,k as fe,a8 as be,a9 as we,a0 as Se,aa as ye,ab as ke,ac as ve,ad as je}from"./index-ClwW47Zs.js";import{n as m,u as $e}from"./mui--aGBnNu2.js";import f from"./NotFoundScreen-CTik05r2.js";import{a as I}from"./sentry-D0lP5-8e.js";import"./recharts-CkREU3LH.js";import"./analytics-D051O7ML.js";import"./plaid-7P9b69CP.js";import"./dnd-CU3yeazS.js";import"./stripe-cKAAJElX.js";import"./lottie-Du4lbH8J.js";import"./lexical-DVH-xgq1.js";import"./pdf-CrvsvvW3.js";import"./utils-Ctp9Zfhk.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]="3ec056d6-37ab-4533-980d-266b7f4bfc1e",e._sentryDebugIdIdentifier="sentry-dbid-3ec056d6-37ab-4533-980d-266b7f4bfc1e")}catch{}})();const Ie=m.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -7,7 +7,7 @@ import{j as t}from"./liveblocks-UAxYbctH.js";import{i as S,l as g,h as C,g as y,
7
7
  align-items: center;
8
8
  background-color: ${e=>e.theme.colors.grey4};
9
9
  box-shadow: ${e=>`0px 2px ${d.sp1} ${e.theme.colors.dropShadowNormal}`};
10
- `,Ce=g((function(e){const a=k(e),n=j(e),{companyName:o}=a;return{companyName:o,isDisabled:a.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,magicLinkViewState:a}}),(function(e,a){const{vendorId:n,billId:o}=a;return{onFetchBankName:i=>{e(T(i))},onSaveHandler:i=>{v.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(V({data:l}))}}}))(re);function F(){const e=x(),{vendorId:a,billId:n}=S();return a==null||n==null?t.jsx(f,{}):t.jsx(t.Fragment,{children:t.jsx(Ie,{windowSize:e,children:t.jsx(Ce,{vendorId:a,billId:n})})})}const De=m.div`
10
+ `,Ce=g((function(e){const a=k(e),n=v(e),{companyName:o}=a;return{companyName:o,isDisabled:a.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,magicLinkViewState:a}}),(function(e,a){const{vendorId:n,billId:o}=a;return{onFetchBankName:i=>{e(T(i))},onSaveHandler:i=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(V({data:l}))}}}))(re);function F(){const e=x(),{vendorId:a,billId:n}=S();return a==null||n==null?t.jsx(f,{}):t.jsx(t.Fragment,{children:t.jsx(Ie,{windowSize:e,children:t.jsx(Ce,{vendorId:a,billId:n})})})}const De=m.div`
11
11
  display: flex;
12
12
  height: 100vh;
13
13
  width: 100%;
@@ -25,7 +25,7 @@ import{j as t}from"./liveblocks-UAxYbctH.js";import{i as S,l as g,h as C,g as y,
25
25
  align-items: center;
26
26
  background-color: ${e=>e.theme.colors.grey4};
27
27
  box-shadow: ${e=>`0px 2px ${d.sp1} ${e.theme.colors.dropShadowNormal}`};
28
- `,Ne=g((function(e){const a=k(e),n=j(e),o=B(e),{companyName:i}=a;return{companyName:i,isDisabled:a.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:a}}),(function(e,a){const{navigate:n,location:o,vendorId:i,billId:l}=a;return{onFetchBankName:s=>{e(T(s))},onSaveHandler:s=>{v.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:r}=s;e(V({data:r}))},onAddressClick:()=>{const s=o.pathname.replace("us-domestic","address"),r=G(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:r}})}}}))(pe);function Ee(){const e=C(),a=y(),n=x(),{vendorId:o,billId:i}=S();return o==null||i==null?t.jsx(f,{}):t.jsx(t.Fragment,{children:t.jsx(Le,{windowSize:n,children:t.jsx(Ne,{location:a,navigate:e,vendorId:o,billId:i})})})}const Fe=m.div`
28
+ `,Ne=g((function(e){const a=k(e),n=v(e),o=B(e),{companyName:i}=a;return{companyName:i,isDisabled:a.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:a}}),(function(e,a){const{navigate:n,location:o,vendorId:i,billId:l}=a;return{onFetchBankName:s=>{e(T(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:r}=s;e(V({data:r}))},onAddressClick:()=>{const s=o.pathname.replace("us-domestic","address"),r=G(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:r}})}}}))(pe);function Ee(){const e=C(),a=y(),n=x(),{vendorId:o,billId:i}=S();return o==null||i==null?t.jsx(f,{}):t.jsx(t.Fragment,{children:t.jsx(Le,{windowSize:n,children:t.jsx(Ne,{location:a,navigate:e,vendorId:o,billId:i})})})}const Fe=m.div`
29
29
  display: flex;
30
30
  height: 100%;
31
31
  width: 100%;
@@ -34,7 +34,7 @@ import{j as t}from"./liveblocks-UAxYbctH.js";import{i as S,l as g,h as C,g as y,
34
34
  align-items: center;
35
35
  background-color: ${e=>e.theme.colors.grey4};
36
36
  box-shadow: ${e=>`0px 2px ${d.sp1} ${e.theme.colors.dropShadowNormal}`};
37
- `,Ve=g((function(e){const a=k(e),n=j(e),o=B(e),{companyName:i}=a;return{companyName:i,isDisabled:a.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:a}}),(function(e,a){const{navigate:n,location:o,vendorId:i,billId:l}=a;return{onFetchBankNameBySwift:s=>{e(se(s))},onSaveHandler:s=>{v.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"international",i,l,a.isLocalCurrencyEnabled))},onBankDetailsUpdated:s=>{const{internationalWireSwiftAccountSection:r}=s;e(ie({data:r}))},onAddressClick:()=>{const s=o.pathname.replace("international","address"),r=G(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:r}})}}}))(ge);function Te(){const e=C(),a=y(),n=x(),{vendorId:o,billId:i}=S(),{useFeatureGate:l}=ue(),{isFeatureEnabled:s}=l(he.isBillPayLocalCurrencyFeatureEnabled);return o==null||i==null?t.jsx(f,{}):t.jsx(Fe,{windowSize:n,children:t.jsx(Ve,{location:a,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Ke={containerWidth:new je(100,58)},Ge=m(ye)`
37
+ `,Ve=g((function(e){const a=k(e),n=v(e),o=B(e),{companyName:i}=a;return{companyName:i,isDisabled:a.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:a}}),(function(e,a){const{navigate:n,location:o,vendorId:i,billId:l}=a;return{onFetchBankNameBySwift:s=>{e(se(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"international",i,l,a.isLocalCurrencyEnabled))},onBankDetailsUpdated:s=>{const{internationalWireSwiftAccountSection:r}=s;e(ie({data:r}))},onAddressClick:()=>{const s=o.pathname.replace("international","address"),r=G(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:r}})}}}))(ge);function Te(){const e=C(),a=y(),n=x(),{vendorId:o,billId:i}=S(),{useFeatureGate:l}=ue(),{isFeatureEnabled:s}=l(he.isBillPayLocalCurrencyFeatureEnabled);return o==null||i==null?t.jsx(f,{}):t.jsx(Fe,{windowSize:n,children:t.jsx(Ve,{location:a,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Ke={containerWidth:new ve(100,58)},Ge=m(ye)`
38
38
  width: ${d.sp4};
39
39
  height: ${d.sp4};
40
40
  margin-bottom: ${d.sp3};
@@ -69,4 +69,4 @@ import{j as t}from"./liveblocks-UAxYbctH.js";import{i as S,l as g,h as C,g as y,
69
69
  width: ${e=>e.windowSize=="small"?"auto":"42%"};
70
70
  background-color: ${e=>e.windowSize==="small"?e.theme.colors.grey4:e.theme.colors.background};
71
71
  margin-top: ${e=>e.windowSize==="small"?e.isAddressPage?"0px":"186px":"unset"};
72
- `,We=g((function(e,a){return{file:a.file,type:a.type}}))(ke);function h({appContent:e}){const a=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=te(),r=s.get("token"),M=n.pathname.includes("address"),w=x(),_=xe(),A=$e(),b=fe(),H=()=>{_.toggle()},W=E((u=>k(u))),J=E((u=>j(u))),{authParams:U,fetchState:c,billAttachment:R,billFetchState:P,companyName:q,currencySymbol:O,amount:Q}=W,{tenantId:z,userId:L,sessionId:N}=U,{fetchState:X,internationalBankAccountCreateStatus:Y}=J;return I.useEffect((()=>{$()}),[]),I.useEffect((()=>{b&&c==="Not-Started"&&i!=null&&o!=null&&r!=null&&a(le(i,o,r))}),[b,c,i,o,r,a]),I.useEffect((()=>{b&&c==="Completed"&&($(L,N,z),l!=null&&a(de(l)))}),[c,b,L,N,z,l,a]),c==="Error"?t.jsx(f,{}):X==="Completed"||Y.fetchState==="Completed"?($(),t.jsx(ae,{to:"../../../../../../../bank/account/save/success",replace:!0,relative:"path"})):c==="In-Progress"?t.jsx(we,{fetchState:c,style:{height:"100vh",backgroundColor:A.colors.grey5,boxShadow:`0px 2px ${d.sp1} ${A.colors.dropShadowNormal}`}}):t.jsxs(t.Fragment,{children:[c==="Completed"&&P==="Completed"&&t.jsx(be,{analytics:v,onLoad:u=>(Z=>Z.trackBillPayMagicLinkPageLoad(o??"",i??"",q,l??"",Je(n.pathname),O,Q))(u)}),t.jsxs(Me,{windowSize:w,children:[w!=="small"?t.jsx(Ge,{onClick:H}):null,t.jsx(He,{windowSize:w,isAddressPage:M,children:P==="In-Progress"?t.jsx(Se,{size:"ExtraLarge",start:!0}):t.jsx(We,{file:R,type:"bill"})}),t.jsx(_e,{windowSize:w,children:e})]})]})}const Je=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function Ue(){return t.jsx(ve,{})}function rt(){return t.jsxs(ne,{children:[t.jsx(p,{path:"bank/account/save/success",element:t.jsx(Ue,{})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:t.jsx(h,{appContent:t.jsx(F,{})})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:t.jsx(h,{appContent:t.jsx(F,{})})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/address",element:t.jsx(h,{appContent:t.jsx(Ae,{isSubPage:!0})})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/us-domestic",element:t.jsx(h,{appContent:t.jsx(Ee,{})})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/international",element:t.jsx(h,{appContent:t.jsx(Te,{})})}),t.jsx(p,{path:"*",element:t.jsx(f,{})})]})}export{rt as default};
72
+ `,We=g((function(e,a){return{file:a.file,type:a.type}}))(ke);function h({appContent:e}){const a=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=te(),r=s.get("token"),M=n.pathname.includes("address"),b=x(),_=xe(),A=$e(),w=fe(),H=()=>{_.toggle()},W=E((u=>k(u))),J=E((u=>v(u))),{authParams:U,fetchState:c,billAttachment:O,billFetchState:P,companyName:R,currencySymbol:q,amount:Q}=W,{tenantId:z,userId:L,sessionId:N}=U,{fetchState:X,internationalBankAccountCreateStatus:Y}=J;return I.useEffect((()=>{$()}),[]),I.useEffect((()=>{w&&c==="Not-Started"&&i!=null&&o!=null&&r!=null&&a(le(i,o,r))}),[w,c,i,o,r,a]),I.useEffect((()=>{w&&c==="Completed"&&($(L,N,z),l!=null&&a(de(l)))}),[c,w,L,N,z,l,a]),c==="Error"?t.jsx(f,{}):X==="Completed"||Y.fetchState==="Completed"?($(),t.jsx(ae,{to:"../../../../../../../bank/account/save/success",replace:!0,relative:"path"})):c==="In-Progress"?t.jsx(be,{fetchState:c,style:{height:"100vh",backgroundColor:A.colors.grey5,boxShadow:`0px 2px ${d.sp1} ${A.colors.dropShadowNormal}`}}):t.jsxs(t.Fragment,{children:[c==="Completed"&&P==="Completed"&&t.jsx(we,{analytics:j,onLoad:u=>(Z=>Z.trackBillPayMagicLinkPageLoad(o??"",i??"",R,l??"",Je(n.pathname),q,Q))(u)}),t.jsxs(Me,{windowSize:b,children:[b!=="small"?t.jsx(Ge,{onClick:H}):null,t.jsx(He,{windowSize:b,isAddressPage:M,children:P==="In-Progress"?t.jsx(Se,{size:"ExtraLarge",start:!0}):t.jsx(We,{file:O,type:"bill"})}),t.jsx(_e,{windowSize:b,children:e})]})]})}const Je=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function Ue(){return t.jsx(je,{})}function rt(){return t.jsxs(ne,{children:[t.jsx(p,{path:"bank/account/save/success",element:t.jsx(Ue,{})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:t.jsx(h,{appContent:t.jsx(F,{})})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:t.jsx(h,{appContent:t.jsx(F,{})})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/address",element:t.jsx(h,{appContent:t.jsx(Ae,{isSubPage:!0})})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/us-domestic",element:t.jsx(h,{appContent:t.jsx(Ee,{})})}),t.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/international",element:t.jsx(h,{appContent:t.jsx(Te,{})})}),t.jsx(p,{path:"*",element:t.jsx(f,{})})]})}export{rt as default};