@zeniai/web-app-ui 5.4.10-dev → 5.4.11-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.
- package/dist/assets/{AccountMappingScreen-BT4O8HTD.js → AccountMappingScreen-CMj3JkGt.js} +2 -2
- package/dist/assets/ActualMatchingMatchDetailScreen-Dd_vJSSr.js +1 -0
- package/dist/assets/AddressRoutes-7FdlQcLM.js +1 -0
- package/dist/assets/AddressScreen-BbgME8aO.js +9 -0
- package/dist/assets/{AiCfoScreen-RbcUBAdM.js → AiCfoScreen-CU1e2Oi8.js} +5 -5
- package/dist/assets/{AppDrawer-Sa4LLULj.js → AppDrawer-Dm9C8j__.js} +1 -1
- package/dist/assets/{BillPayApprovalRoutes-BbNV-MR5.js → BillPayApprovalRoutes-GN_PKZBM.js} +1 -1
- package/dist/assets/{BillPayRoutes-uNYLvj5o.js → BillPayRoutes-7abJ7Y81.js} +8 -8
- package/dist/assets/{BusinessVerificationPageScreen-ibSIK2nI.js → BusinessVerificationPageScreen-8VbyEZWD.js} +2 -2
- package/dist/assets/CardsAiCfoScreen-BcEHiZtA.js +14 -0
- package/dist/assets/{ChargeCardRoutes-CO87Ou5-.js → ChargeCardRoutes-BR5_qY8y.js} +9 -9
- package/dist/assets/CompanyPassportScreen-L6OY8AwA.js +1 -0
- package/dist/assets/ConnectionAuthScreen-F-iZ536h.js +11 -0
- package/dist/assets/CustomerOnboardingAuthScreen-Gnqx1b1N.js +1 -0
- package/dist/assets/{CustomerOnboardingRoutes-BynW3iC3.js → CustomerOnboardingRoutes-3OH4ZWPk.js} +3 -3
- package/dist/assets/{DashboardRoutes-ndbO6Qws.js → DashboardRoutes-X31R7cQf.js} +4 -4
- package/dist/assets/{DefaultTenantHome-2hNb0a3U.js → DefaultTenantHome-FpeIWNLr.js} +1 -1
- package/dist/assets/DomesticWireDetailScreen-BZbvzqXc.js +18 -0
- package/dist/assets/{DrawerScreen-b7QdOhuW.js → DrawerScreen-CmgVB1Zi.js} +1 -1
- package/dist/assets/EntityDetailRoutes-5IMi-E-b.js +1 -0
- package/dist/assets/{ExpenseAutomationRoutes-C6_zyg5Q.js → ExpenseAutomationRoutes-DH5uN2wQ.js} +6 -6
- package/dist/assets/{FeaturePreviewScreen-B5U7lEG-.js → FeaturePreviewScreen-Cnh2Fe6t.js} +1 -1
- package/dist/assets/HubSpotOAuthCallbackScreen-C94ZBMtd.js +1 -0
- package/dist/assets/InboxNotificationsProvider-CJt6vmnU.js +1 -0
- package/dist/assets/{InvoicingRoutes-C4zfN1Wc.js → InvoicingRoutes-Q-6aUqgu.js} +2 -2
- package/dist/assets/{MagicLinkRoutes-BDl3Flj2.js → MagicLinkRoutes-CR6ShXCQ.js} +20 -20
- package/dist/assets/MagicLinkSignInScreen-CBjgwG_1.js +12 -0
- package/dist/assets/{MobileAppDrawer-DVldqyUl.js → MobileAppDrawer-B4_Hh2uX.js} +1 -1
- package/dist/assets/NotFoundScreen-CxVO6BUm.js +1 -0
- package/dist/assets/{NotificationRoutes-UAhv091T.js → NotificationRoutes-CDa5TISi.js} +1 -1
- package/dist/assets/OAuthConsentScreen-D8WvwiVN.js +1 -0
- package/dist/assets/PandLWithForecastRoutes-CiaozOzI.js +1 -0
- package/dist/assets/PaymentLinkScreen-BN13u2tw.js +21 -0
- package/dist/assets/PeopleRoutes-B5eZw1Xs.js +22 -0
- package/dist/assets/PerformanceRoutes-B5KqyHoS.js +1 -0
- package/dist/assets/{Preview-CU7aguP4.js → Preview-gj_-pUjR.js} +1 -1
- package/dist/assets/QBOConnectionScreen-BD6w4pxT.js +101 -0
- package/dist/assets/{ReimbursementApprovalRoutes-DrsMWkl8.js → ReimbursementApprovalRoutes-_wQ1m-SZ.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRuleDetailScreen-Dw7QQEoQ.js → ReimbursementApprovalRuleDetailScreen-CQJ7WhRf.js} +1 -1
- package/dist/assets/ReimbursementRoutes-mHGAbMEo.js +68 -0
- package/dist/assets/{ReportsRoutes-B5lACyrL.js → ReportsRoutes-DNdr9gVu.js} +1 -1
- package/dist/assets/RewardsRoutes-CRQaDmuu.js +1 -0
- package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-LwZh192V.js → ScheduleDetailsPrepaidExpensesScreen-Bgrqk-Br.js} +5 -5
- package/dist/assets/ScreenRoutes-Cix6ynkH.js +2 -0
- package/dist/assets/{SettingsRoutes-DEHUtOgG.js → SettingsRoutes-CXzUd0P6.js} +6 -6
- package/dist/assets/{SetupPagesScreen-Dv6lGRG5.js → SetupPagesScreen-DzLiX5R5.js} +5 -5
- package/dist/assets/SignInScreen-VX0iUVME.js +1 -0
- package/dist/assets/SignOutScreen-BXVxv4o-.js +9 -0
- package/dist/assets/{TaskListScreen-8hq6cEbk.js → TaskListScreen-Dv5TjArL.js} +2 -2
- package/dist/assets/TaskRoutes-aDI7RZCK.js +9 -0
- package/dist/assets/TransactionDetailRoutes-C0gGgGik.js +1 -0
- package/dist/assets/{TransactionDetailScreen-It6ORIbN.js → TransactionDetailScreen-BsGN3Yd5.js} +2 -2
- package/dist/assets/{TransactionListRoutes-BTjkHFVX.js → TransactionListRoutes-_bc9UoMG.js} +1 -1
- package/dist/assets/{TreasuryRoutes-Bys8F57E.js → TreasuryRoutes-C7ABXX2A.js} +6 -6
- package/dist/assets/{VendorsRoutes-abjQ1HGQ.js → VendorsRoutes-BlorNbi4.js} +11 -11
- package/dist/assets/WiseConfirmationScreen-DhPTIeWc.js +12 -0
- package/dist/assets/{ZeniAccountRoutes-DlvpS2Bq.js → ZeniAccountRoutes-QObrERl4.js} +11 -11
- package/dist/assets/ZeniAccountStatementScreen-BHlw6cTG.js +9 -0
- package/dist/assets/{accountMappingHelper-C9fFA6EC.js → accountMappingHelper-BbISzw1n.js} +1 -1
- package/dist/assets/{analytics-C3OBHjEG.js → analytics-C4ICDJLl.js} +1 -1
- package/dist/assets/{analyticsHelper-exrV7AE9.js → analyticsHelper-CPHVprda.js} +1 -1
- package/dist/assets/{core-o-ca34AJ.js → core-C4Vfz6Ll.js} +1 -1
- package/dist/assets/{decodeURIComponentSafe-CdLVPaCS.js → decodeURIComponentSafe-CYsmEPcV.js} +1 -1
- package/dist/assets/{dnd-sqKp8sUm.js → dnd-kAQqqaX2.js} +1 -1
- package/dist/assets/{empty-CynSKeaU.js → empty-asCy4wrm.js} +1 -1
- package/dist/assets/{empty-BnmFWJHQ.js → empty-uRyODf4S.js} +1 -1
- package/dist/assets/{emptyVideoElement-BUTaximG.js → emptyVideoElement-79iYt27c.js} +1 -1
- package/dist/assets/epic-B2pHLhBD.js +2 -0
- package/dist/assets/expenseAutomationHelper-hmRJBbGd.js +1 -0
- package/dist/assets/{getLocaleForTenant-CBmE-ohA.js → getLocaleForTenant-DJIJUZ-c.js} +1 -1
- package/dist/assets/{index-BLrePuqf.js → index-BTd7WWV0.js} +1 -1
- package/dist/assets/{index-Btt0Zihe.js → index-B_kv_EmZ.js} +1 -1
- package/dist/assets/{index-Bqod5kmp.js → index-Bg8f4cim.js} +1 -1
- package/dist/assets/{index-Bx2gJO4r.js → index-CJ_pjNEa.js} +7 -7
- package/dist/assets/{index-j2p4Lnj3.js → index-Doknm_HP.js} +1 -1
- package/dist/assets/index-E3novWwq.js +1 -0
- package/dist/assets/{index-D4vHXZ_y.js → index-UMoTq5JU.js} +2 -2
- package/dist/assets/index-pA4BduR_.js +1 -0
- package/dist/assets/{lexical-CEO4_NFb.js → lexical-SeD-pdYj.js} +1 -1
- package/dist/assets/liveblocks-DZUXZ-JO.js +59 -0
- package/dist/assets/{lottie-Dl8uwTmw.js → lottie-txhqSe8x.js} +1 -1
- package/dist/assets/{mui-cK5UWUvi.js → mui-C0PYnbt1.js} +1 -1
- package/dist/assets/{pathToGoBack-Bk8jMuE9.js → pathToGoBack-DF1y-0ht.js} +1 -1
- package/dist/assets/{pdf-BNJo5ucI.js → pdf-bOGTjHnz.js} +5 -5
- package/dist/assets/{pdf-lib-C69QvBGc.js → pdf-lib-BsfRp21l.js} +1 -1
- package/dist/assets/{plaid-C8bTkbCG.js → plaid-hQES7k9Y.js} +1 -1
- package/dist/assets/{pusher-C6PXikRK.js → pusher-BoH5mrch.js} +1 -1
- package/dist/assets/{react-BgHw6ZMD.js → react-BQ6jUfzX.js} +1 -1
- package/dist/assets/{react-BCP4YdKf.js → react-BgJrrMxk.js} +1 -1
- package/dist/assets/{react-BfzBm-jN.js → react-Boil267a.js} +1 -1
- package/dist/assets/{react-CTNewL67.js → react-DXSBT-1v.js} +1 -1
- package/dist/assets/{react-UiIuY6Fo.js → react-ZM05SSz2.js} +1 -1
- package/dist/assets/{react-ixvlVzZ9.js → react-qLaRPrw4.js} +1 -1
- package/dist/assets/{recharts-DK1tbN_A.js → recharts-rN5v_P87.js} +1 -1
- package/dist/assets/{reportTimeframe-6FnDbaGY.js → reportTimeframe-C5AD1AL2.js} +1 -1
- package/dist/assets/{routePaths-DBf4ybcn.js → routePaths-DYebh4Li.js} +1 -1
- package/dist/assets/{sentry-Buwow292.js → sentry-DfoGRlTp.js} +1 -1
- package/dist/assets/{stripSplatSuffix-BKbpznmZ.js → stripSplatSuffix-Db8ayksN.js} +1 -1
- package/dist/assets/{url-B_oojQRK.js → url-B-JScRaX.js} +1 -1
- package/dist/assets/{url-C7oPARVv.js → url-BtS-4pap.js} +1 -1
- package/dist/assets/{useActualMatchingMatchDetail-DBoUtV2d.js → useActualMatchingMatchDetail-DPtaMcdm.js} +1 -1
- package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-D_VhexUa.js → useAiCfoDashboardSuggestedQuestionsChips-D2InIpSO.js} +1 -1
- package/dist/assets/useAskAiCfoHostNavButtonProps-k11tYjVi.js +1 -0
- package/dist/assets/{useChargeCardPusherEvents-B6OwhCNo.js → useChargeCardPusherEvents-Bf7Vv0PE.js} +1 -1
- package/dist/assets/{useDeviceId-CeB6LWI8.js → useDeviceId-_3Ay4Sah.js} +1 -1
- package/dist/assets/useEmailConnectResultRefresh-BCLtP2Ad.js +1 -0
- package/dist/assets/useEnsureVendorListLoaded-Bud-c91I.js +1 -0
- package/dist/assets/{useInitialThreadRequest-C3w5IRp7.js → useInitialThreadRequest-BVMcY486.js} +1 -1
- package/dist/assets/useTaskManagerAccess-Cp8R2Cu9.js +1 -0
- package/dist/assets/{useTaskManagerPusherEvents-LOx5aVW8.js → useTaskManagerPusherEvents-p1TIydvw.js} +1 -1
- package/dist/assets/utils-CmKqkYr5.js +36 -0
- package/dist/assets/{withTransactionSidePanel-CVCleugc.js → withTransactionSidePanel-btBdqPWA.js} +5 -5
- package/dist/assets/{zeni-epic-state-MQ0qdl-Q.js → zeni-epic-state-DmXGRK_Y.js} +4 -4
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/ActualMatchingMatchDetailScreen-Ce_XDU4u.js +0 -1
- package/dist/assets/AddressRoutes-BQEPn0Yr.js +0 -1
- package/dist/assets/AddressScreen-D2FVWJY-.js +0 -9
- package/dist/assets/CardsAiCfoScreen-CkEc2DEo.js +0 -14
- package/dist/assets/CompanyPassportScreen-DJeoMdCg.js +0 -1
- package/dist/assets/ConnectionAuthScreen-Bf2Ucb1Q.js +0 -11
- package/dist/assets/CustomerOnboardingAuthScreen-D3RbfqTk.js +0 -1
- package/dist/assets/DomesticWireDetailScreen-BqDioG6P.js +0 -18
- package/dist/assets/EntityDetailRoutes-aGFvyTv5.js +0 -1
- package/dist/assets/HubSpotOAuthCallbackScreen-Dr1Xep8u.js +0 -1
- package/dist/assets/InboxNotificationsProvider-Cph6MP0g.js +0 -1
- package/dist/assets/MagicLinkSignInScreen-Bie6nkkJ.js +0 -12
- package/dist/assets/NotFoundScreen-BXfz4Cwt.js +0 -1
- package/dist/assets/OAuthConsentScreen-yv2un5zc.js +0 -1
- package/dist/assets/PandLWithForecastRoutes-DZO_Ak_R.js +0 -1
- package/dist/assets/PaymentLinkScreen-DgjQbdJS.js +0 -21
- package/dist/assets/PeopleRoutes-CBBW0nYr.js +0 -22
- package/dist/assets/PerformanceRoutes-CIoRY1pR.js +0 -1
- package/dist/assets/QBOConnectionScreen-CI47ZrlS.js +0 -100
- package/dist/assets/ReimbursementRoutes-BiacT-VJ.js +0 -68
- package/dist/assets/RewardsRoutes-26PBDRkk.js +0 -1
- package/dist/assets/ScreenRoutes-CdEeBqiV.js +0 -2
- package/dist/assets/SignInScreen-CzvdRg4U.js +0 -1
- package/dist/assets/SignOutScreen-DfTRMdjb.js +0 -9
- package/dist/assets/TaskRoutes-C1KzEFV7.js +0 -9
- package/dist/assets/TransactionDetailRoutes-BB45JvGj.js +0 -1
- package/dist/assets/WiseConfirmationScreen-DewxnFTy.js +0 -12
- package/dist/assets/ZeniAccountStatementScreen-DVR6RIK2.js +0 -9
- package/dist/assets/epic-bBvrG0DE.js +0 -2
- package/dist/assets/expenseAutomationHelper-8n6GRk1T.js +0 -1
- package/dist/assets/index-BzW-Y7Lk.js +0 -1
- package/dist/assets/index-Cmb8jqqj.js +0 -1
- package/dist/assets/liveblocks-BdMPZzDQ.js +0 -59
- package/dist/assets/useAskAiCfoHostNavButtonProps-B6lOnQ69.js +0 -1
- package/dist/assets/useEmailConnectResultRefresh-t37-D3lN.js +0 -1
- package/dist/assets/useEnsureVendorListLoaded-BmranjK0.js +0 -1
- package/dist/assets/useTaskManagerAccess-By_NjZen.js +0 -1
- package/dist/assets/utils-D4KfE2cr.js +0 -36
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as c}from"./liveblocks-BdMPZzDQ.js";import{a as r}from"./sentry-Buwow292.js";import{u as $,h as L,i as R,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-o-ca34AJ.js";import{a7 as st,m as g,ap as F,S as l,ce as rt,cf as dt,cg as lt,ch as ut,ci as gt,cj as mt,ck as vt,cl as pt,cm as St,cn as ft,co as It,cp as ht,n as ce,cq as Ct,cr as kt,z as te,ad as pe,cs as Et,ct as yt,cu as bt,cv as xt,cw as At,cx as Dt,cy as jt,cz as $t,cA as Lt,cB as Pt,V as wt,ah as pn,cC as Rt,cD as _t,cE as Ft,cF as Tt,cG as Ot,cH as Mt,cI as Nt,cJ as Ut,cK as Bt,cL as Vt,cM as Ht,t as en,l as Ue,cN as qt,cO as Qt,cP as zt,cQ as Kt,cR as Gt,cS as Wt,Z as Yt,bu as Jt}from"./index-Bx2gJO4r.js";import"./mui-cK5UWUvi.js";import{A as Z}from"./AddressScreen-D2FVWJY-.js";import M from"./NotFoundScreen-BXfz4Cwt.js";import{_R as Zt,_S as Xt,vA as nn,v as ei,_T as X,wb as Se,_U as Be,_V as W,wO as Pe,wV as ni,dY as Sn,wZ as fn,_W as Ve,wS as ti,yy as tn,wa as on,_X as In,_Y as Y,x8 as we,xc as ii,_Z as oi,xm as ai,__ as hn,xf as Cn,z6 as ci,_$ as he,$0 as an,$1 as kn,w6 as si,$2 as ri,v_ as di,$3 as li,yL as ui,$4 as En,yU as be,$5 as gi,yR as mi,$6 as He,gk as qe,$7 as le,$8 as ue,xu as vi,wg as cn,wl as yn,wj as pi,wd as Si,xn as fi,wn as Ii,xw as hi,c$ as bn,$9 as Re,xF as xn,xD as Q,xB as G,xA as Ci,$a as fe,y$ as xe,$b as ki,w8 as An,$c as Qe,fI as Ce,ww as _e,wt as Fe,wG as Dn,wF as ze,wq as Ei,wz as jn,wI as me,Wp as $n,wc as Ke,wD as yi,wE as bi,wC as xi,$d as Ai,xd as Di,x9 as Ln,$e as Pn,vR as Ae,$f as ji,vK as $i,$g as Li,z5 as Pi,za as K,z4 as wi,yc as ke,$h as Ri,$i as wn,zj as De,$j as _i,zg as Fi,$k as Rn,yf as Ti,yg as q,yj as Oi,$l as _n,yt as je,$m as Mi,xv as Fn,UV as Tn,$n as Ni,yD as Ui,$o as On,$p as sn,$q as Bi,$r as Vi,A6 as Hi,$s as qi,$t as Mn,zq as Nn,$u as Un,A4 as $e,$v as Qi,A1 as zi,$w as Ki,$x as Gi,$y as Wi,$z as Yi,$A as Ji,$B as rn,$C as Zi,ei as Xi,Aa as eo,$D as Ge,xP as no,xK as to,d1 as Te,$E as ee,xT as Bn,x$ as Vn,$F as We,xU as ie,y4 as io,y7 as Hn,$G as oo,$H as Oe,y3 as ao,$I as qn,zV as Le,zQ as co,$J as so,zv as ro,$K as lo,zW as uo,z_ as go,$L as Ye,wQ as Qn,zH as mo,wR as vo,$M as po,$N as zn,ca as So,mw as fo,mx as Io,$O as dn,wP as ne,go as ho,mD as Co,zN as Kn,Am as ko,zK as Gn,v6 as Eo,uW as yo,hW as bo,Vm as ln,Vn as xo,GO as Wn,Aj as Ao,hO as Do,Ag as jo,$P as $o,$Q as Lo,As as Po,Ar as wo,$R as Ro,$S as Yn,Ap as _o,$T as Fo,$U as To,yH as Oo,$V as Mo}from"./zeni-epic-state-MQ0qdl-Q.js";import{M as No}from"./MobileAppDrawer-DVldqyUl.js";import{q as Ie}from"./QBOConnectionScreen-CI47ZrlS.js";import"./recharts-DK1tbN_A.js";import"./analytics-C3OBHjEG.js";import"./plaid-C8bTkbCG.js";import"./dnd-sqKp8sUm.js";import"./stripe-cKAAJElX.js";import"./lottie-Dl8uwTmw.js";import"./lexical-CEO4_NFb.js";import"./pdf-BNJo5ucI.js";import"./utils-D4KfE2cr.js";import"./InboxNotificationsProvider-Cph6MP0g.js";import"./useTaskManagerAccess-By_NjZen.js";import"./empty-BnmFWJHQ.js";import"./pdf-lib-C69QvBGc.js";import"./index-BLrePuqf.js";import"./url-C7oPARVv.js";import"./index-Cmb8jqqj.js";import"./decodeURIComponentSafe-CdLVPaCS.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]="7003d49a-2449-4282-a685-53735e93fe6e",t._sentryDebugIdIdentifier="sentry-dbid-7003d49a-2449-4282-a685-53735e93fe6e")}catch{}})();const w=({event:t,isReady:e=!0})=>e?c.jsx(st,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Uo(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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(Zt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((_,U)=>{const T=Xt(D,_,U,C);T!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:_,entityId:U,fromScreen:"audit_log",toScreen:_}),e(T))}),[C,e,D]);r.useEffect((()=>{const _=setTimeout((()=>u(a)),300);return()=>clearTimeout(_)}),[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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingAuditLogPage,isReady:j}),c.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(),s=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Me(i[u])])));return{fieldsChanged:o,formValues:s}}function Ee(t,e=!1){const n=$(),i=E((s=>X(s).productNextCursor!=null)),a=E((s=>X(s).productNextCursor)),o=E((s=>X(s).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 se(t,e,n,i){const[a,o]=r.useState(0),[s,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((()=>{s&&!e&&(u(!1),o((p=>p+1)))}),[s,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=$(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=(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(W({id:n})),()=>{t(W({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(Pe({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t(Pe({cacheOverride:!0,id:y,kind:s}))),[t,s]),S=se(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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemDetailPage,isReady:f}),c.jsx(Vo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,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(W({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(W({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=$(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=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(W({id:n}))}),0)})),[n,t]),r.useEffect((()=>{o&&t(Pe({id:n,kind:p}))}),[o,n,p,t]),r.useEffect((()=>{s||d==null||m.localData.catalogType===d||t(Ve({localData:{...m.localData,catalogType:d}}))}),[s,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(W({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemFormPage}),c.jsx(zo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:s,itemId:n})]})}const Go={addons:"addon",all:"item",charges:"charge",plans:"plan"},Wo=O((function(t,e){const n=X(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=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:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="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 s=Go[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,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 Yo(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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=>X(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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogPage,isReady:k}),c.jsx(Wo,{navigate:e,tenantEmailDomain:n,activeTab:s,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(Y({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(Y({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 Zo(){const t=$(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),{fetchState:o,savedCouponId:s}=E((d=>In(d,n))),u=r.useRef();return r.useEffect((()=>(clearTimeout(u.current),()=>{u.current=setTimeout((()=>{t(Y({id:n}))}),0)})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=s??n,p=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(p),t(Y({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCouponFormPage}),c.jsx(Jo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Xo=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=$(),e=L(),{tenantEmailDomain:n}=R(),[i]=oe(),{areTenantIdsInSync:a}=F(),o=i.get("customerId"),s=E((b=>hn(b))),u=s.fetchState,d=s.localData,p=s.savedInvoiceId,v=E(Cn),m=E((b=>ci(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(si({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]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),C?c.jsx(mt,{}):c.jsx(Xo,{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=$(),e=L(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((u=>li(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ui({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditDetailPage,isReady:s}),c.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=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditsListPage,isReady:y}),c.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 Zn=(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(Re({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=Zn(e.tenantEmailDomain??"",G,i),o=ce(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(Re({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(hi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Ii({body:s,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 ca(){const t=$(),e=L(),n=ae(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),s=E((T=>He(T,i))),u=s.pageFetchState.fetchState,d=u==="Completed"&&!s.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}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,k=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;k.current!=="Error"&&T==="Error"&&t(qe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),k.current=T}),[t,s.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(cn({customerId:i}))}),[o,i,t,A]);const _=r.useCallback((T=>t(yn({id:T}))),[t]),U=se(s.fetchState,s.isFormLoading,i,_);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),c.jsx(aa,{customerId:i??"",editView:s,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(cn({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ue()),S(!0)}},U),c.jsx(ft,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:p,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.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})))}}),c.jsx(It,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.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:s.record.invoicingCustomer?.preferredCurrencyCode,description:de})))}})]})}const sa=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(Re({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Zn(e.tenantEmailDomain??"",G,i),s=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(o,{state:{pathnameStackToGoBack:s}})},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=$(),e=L(),n=ae(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),{fetchState:s,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(s==="Completed"){const m=u??i,S=m!=null?`/${a}/invoicing/customers/${encodeURIComponent(m)}`:`/${a}/invoicing/customers`;e(S),t(fe({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerFormPage}),c.jsx(sa,{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=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomersListPage,isReady:y}),c.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:s}=e,u=o==null?void 0:s.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(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],d=Ne(s,a),p=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.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(Fe({...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=$(),e=L(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),[o,s]=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(_e(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const C=setTimeout((()=>{t(Fe({...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(_e(n)),t(Fe({...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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(ua,{authParams:p,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Xn=t=>`invoicing_active_migration:${t}`,ve=(t,e)=>{if(t!=null&&t!=="")try{const n=Xn(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 s=o??null;t(me(s)),ve(i,s),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=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),a=E(Qe);r.useEffect((()=>{i&&(t(Ei()),t(jn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ma,{navigate:e,tenantEmailDomain:n,view:a})]})}const pa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,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:s,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=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),a=E(Cn),o=E(Ce),s=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=>$n(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(Xn(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(_e(S))}),3e3);return()=>clearInterval(h)}),[i,S,C,t]),r.useEffect((()=>{I==="done"&&(t(me(null)),ve(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportMigratePage}),c.jsx(pa,{activeId:S,authParams:s,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(Ln({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=$(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((I=>Ai(I,n))),s=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(Y({id:n})),()=>{t(Y({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]);const S=r.useCallback((I=>t(we({cacheOverride:!0,id:I}))),[t]),f=se(o.fetchState,o.isFormLoading,n,S);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),c.jsx(fa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},f)]})}const ha=O((function(t){const e=Pn(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(Ln({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t($i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(At);function Ca(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,couponListFetchState:h,runningDiscountActionId:y}=E((b=>{const A=Pn(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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountsListPage,isReady:D}),c.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,s={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,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(K({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(K({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(K({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(K({action:"retry",id:i}))}:void 0}}))(jt);function Ea(){const t=$(),e=L(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((k=>Li(k,n??""))),s=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(Pi({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(wi({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(Ri({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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(ka,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.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=wn(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((s=>s.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(Fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))($t);function ba(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,dunningCaseListFetchState:h,dunningCases:y}=E((b=>{const A=wn(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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningListPage,isReady:D}),c.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(_i(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:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},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:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(s,{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 c}from"./liveblocks-DZUXZ-JO.js";import{a as r}from"./sentry-DfoGRlTp.js";import{u as $,h as L,i as R,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-C4Vfz6Ll.js";import{a7 as st,m as g,ap as F,S as l,ce as rt,cf as dt,cg as lt,ch as ut,ci as gt,cj as mt,ck as vt,cl as pt,cm as ft,cn as St,co as It,cp as ht,n as ce,cq as Ct,cr as kt,z as te,ad as pe,cs as Et,ct as yt,cu as bt,cv as xt,cw as At,cx as Dt,cy as jt,cz as $t,cA as Lt,cB as Pt,V as wt,ah as pn,cC as Rt,cD as _t,cE as Ft,cF as Tt,cG as Ot,cH as Mt,cI as Nt,cJ as Ut,cK as Bt,cL as Vt,cM as Ht,t as en,l as Ue,cN as qt,cO as Qt,cP as zt,cQ as Kt,cR as Gt,cS as Wt,Z as Yt,bu as Jt}from"./index-CJ_pjNEa.js";import"./mui-C0PYnbt1.js";import{A as X}from"./AddressScreen-BbgME8aO.js";import M from"./NotFoundScreen-CxVO6BUm.js";import{_N as Xt,_O as Zt,vw as nn,v as ei,_P as Z,w7 as fe,_Q as Be,_R as W,wK as Pe,wR as ni,dU as fn,wV as Sn,_S as Ve,wO as ti,yu as tn,w6 as on,_T as In,_U as Y,x4 as we,x8 as ii,_V as oi,xi as ai,_W as hn,xb as Cn,z2 as ci,_X as he,_Y as an,_Z as kn,w2 as si,__ as ri,vW as di,_$ as li,yH as ui,$0 as En,yQ as be,$1 as gi,yN as mi,$2 as He,gg as qe,$3 as le,$4 as ue,xq as vi,wc as cn,wh as yn,wf as pi,w9 as fi,xj as Si,wj as Ii,xs as hi,cX as bn,$5 as Re,xB as xn,xz as Q,xx as G,xw as Ci,$6 as Se,yX as xe,$7 as ki,w4 as An,$8 as Qe,fE as Ce,ws as _e,wp as Fe,wC as Dn,wB as ze,wm as Ei,wv as jn,wE as me,Wl as $n,w8 as Ke,wz as yi,wA as bi,wy as xi,$9 as Ai,x9 as Di,x5 as Ln,$a as Pn,vN as Ae,$b as ji,vG as $i,$c as Li,z1 as Pi,z6 as K,z0 as wi,y8 as ke,$d as Ri,$e as wn,zf as De,$f as _i,zc as Fi,$g as Rn,yb as Ti,yc as q,yf as Oi,$h as _n,yp as je,$i as Mi,xr as Fn,UR as Tn,$j as Ni,yz as Ui,$k as On,$l as sn,$m as Bi,$n as Vi,A2 as Hi,$o as qi,$p as Mn,zm as Nn,$q as Un,A0 as $e,$r as Qi,zZ as zi,$s as Ki,$t as Gi,$u as Wi,$v as Yi,$w as Ji,$x as rn,$y as Xi,ee as Zi,A6 as eo,$z as Ge,xL as no,xG as to,cZ as Te,$A as ee,xP as Bn,xX as Vn,$B as We,xQ as ie,y0 as io,y3 as Hn,$C as oo,$D as Oe,x$ as ao,$E as qn,zR as Le,zM as co,$F as so,zr as ro,$G as lo,zS as uo,zW as go,$H as Ye,wM as Qn,zD as mo,wN as vo,$I as po,$J as zn,c6 as fo,ms as So,mt as Io,$K as dn,wL as ne,gk as ho,mz as Co,zJ as Kn,Ai as ko,zG as Gn,v2 as Eo,uS as yo,hS as bo,Vi as ln,Vj as xo,GK as Wn,Af as Ao,hK as Do,Ac as jo,$L as $o,$M as Lo,Ao as Po,An as wo,$N as Ro,$O as Yn,Al as _o,$P as Fo,$Q as To,yD as Oo,$R as Mo}from"./zeni-epic-state-DmXGRK_Y.js";import{M as No}from"./MobileAppDrawer-B4_Hh2uX.js";import{q as Ie}from"./QBOConnectionScreen-BD6w4pxT.js";import"./recharts-rN5v_P87.js";import"./analytics-C4ICDJLl.js";import"./plaid-hQES7k9Y.js";import"./dnd-kAQqqaX2.js";import"./stripe-cKAAJElX.js";import"./lottie-txhqSe8x.js";import"./lexical-SeD-pdYj.js";import"./pdf-bOGTjHnz.js";import"./utils-CmKqkYr5.js";import"./InboxNotificationsProvider-CJt6vmnU.js";import"./useTaskManagerAccess-Cp8R2Cu9.js";import"./url-BtS-4pap.js";import"./empty-uRyODf4S.js";import"./pdf-lib-BsfRp21l.js";import"./index-BTd7WWV0.js";import"./index-E3novWwq.js";import"./decodeURIComponentSafe-CYsmEPcV.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]="a13b658a-7084-45b7-b08f-97f16ecf2c2a",t._sentryDebugIdIdentifier="sentry-dbid-a13b658a-7084-45b7-b08f-97f16ecf2c2a")}catch{}})();const w=({event:t,isReady:e=!0})=>e?c.jsx(st,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Uo(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:f,items:S,nextCursor:I,auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h}=E(Xt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((_,U)=>{const T=Zt(D,_,U,C);T!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:_,entityId:U,fromScreen:"audit_log",toScreen:_}),e(T))}),[C,e,D]);r.useEffect((()=>{const _=setTimeout((()=>u(a)),300);return()=>clearTimeout(_)}),[a]),r.useEffect((()=>{i&&t(nn({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&S.length===0,k=m==="In-Progress"&&S.length>0,j=m==="Completed";return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingAuditLogPage,isReady:j}),c.jsx(rt,{auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h,entries:S,hasMore:f,isLoading:A,isLoadingMore:k,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{f&&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(),s=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Me(i[u])])));return{fieldsChanged:o,formValues:s}}function Ee(t,e=!1){const n=$(),i=E((s=>Z(s).productNextCursor!=null)),a=E((s=>Z(s).productNextCursor)),o=E((s=>Z(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(fe({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(fe({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function se(t,e,n,i){const[a,o]=r.useState(0),[s,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((()=>{s&&!e&&(u(!1),o((p=>p+1)))}),[s,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,fn(e.view.plan))}),t(Sn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(ni({action:o,id:a,parentItemId:i}))}}}))(dt);function Ho(){const t=$(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=(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(W({id:n})),()=>{t(W({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(Pe({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t(Pe({cacheOverride:!0,id:y,kind:s}))),[t,s]),f=se(d.fetchState,d.isFormLoading,n,m),S=v==="Completed"&&!d.isFormLoading;Ee(o,!0);const[I,C]=r.useState(S?n:void 0);r.useEffect((()=>{n!=null&&S&&C(n)}),[n,S]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||d.isFormLoading);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemDetailPage,isReady:S}),c.jsx(Vo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:d},f)]})}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(W({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(W({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ve({id:i,localData:o}))},onSubmit:()=>{t(Sn({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?fn(t):void 0)}),n.onSubmit()}}}))(lt);function Ko(){const t=$(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=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((S=>Be(S,n)));Ee(o,!0);const f=r.useRef();return r.useEffect((()=>(clearTimeout(f.current),()=>{f.current=setTimeout((()=>{t(W({id:n}))}),0)})),[n,t]),r.useEffect((()=>{o&&t(Pe({id:n,kind:p}))}),[o,n,p,t]),r.useEffect((()=>{s||d==null||m.localData.catalogType===d||t(Ve({localData:{...m.localData,catalogType:d}}))}),[s,d,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??n,I=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(I),t(W({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemFormPage}),c.jsx(zo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:s,itemId:n})]})}const Go={addons:"addon",all:"item",charges:"charge",plans:"plan"},Wo=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,s=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:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="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 s=Go[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,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(fe({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}):fe({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Yo(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[d,p]=r.useState(""),[v,m]=r.useState(null),f=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),S=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:S,type:"plan"})),[S]),C=r.useMemo((()=>({search:S,type:"addon|charge"})),[S]),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:f,productSort:f}))}),[i,t,I,C,f]),r.useEffect((()=>{i&&(S!==y||f?.field!==D?.field||f?.dir!==D?.dir)&&t(tn({cacheOverride:!0,planFilters:I,productFilters:C,planSort:f,productSort:f}))}),[y,D,i,t,I,C,S,f]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogPage,isReady:k}),c.jsx(Wo,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:v,planFilters:I,productFilters:C,sort:f,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(Y({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(Y({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=$(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),{fetchState:o,savedCouponId:s}=E((d=>In(d,n))),u=r.useRef();return r.useEffect((()=>(clearTimeout(u.current),()=>{u.current=setTimeout((()=>{t(Y({id:n}))}),0)})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=s??n,p=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(p),t(Y({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCouponFormPage}),c.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=$(),e=L(),{tenantEmailDomain:n}=R(),[i]=oe(),{areTenantIdsInSync:a}=F(),o=i.get("customerId"),s=E((b=>hn(b))),u=s.fetchState,d=s.localData,p=s.savedInvoiceId,v=E(Cn),m=E((b=>ci(b))),f=E(he),S=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=f.fetchState==="Not-Started"||f.fetchState==="In-Progress"&&f.customers.length===0,C=S||I,h=m.fetchState==="Completed"&&f.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(si({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]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),C?c.jsx(mt,{}):c.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=$(),e=L(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((u=>li(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ui({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditDetailPage,isReady:s}),c.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})))}}}))(ft);function oa(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,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!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditsListPage,isReady:y}),c.jsx(ia,{navigate:e,tenantEmailDomain:n,activeStatus:f,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(Re({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=ce(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(Re({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(hi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Ii({body:s,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 ca(){const t=$(),e=L(),n=ae(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),s=E((T=>He(T,i))),u=s.pageFetchState.fetchState,d=u==="Completed"&&!s.isFormLoading,[p,v]=r.useState(!1),[m,f]=r.useState(!1),[S,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const C=S===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,k=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;k.current!=="Error"&&T==="Error"&&t(qe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),k.current=T}),[t,s.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&&(f(!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(cn({customerId:i}))}),[o,i,t,A]);const _=r.useCallback((T=>t(yn({id:T}))),[t]),U=se(s.fetchState,s.isFormLoading,i,_);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),c.jsx(aa,{customerId:i??"",editView:s,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(cn({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ue()),f(!0)}},U),c.jsx(St,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:p,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(fi({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})))}}),c.jsx(It,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.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:()=>{f(!1),t(ue())},onSubmit:({amount:T,description:de})=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(Si({amount:T,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:de})))}})]})}const sa=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(Se({id:i})),t(Q(G)),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(Se({id:i})),t(Q(G)),e.navigate(`${n}/customers`)},onChange:o=>{t(Re({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Xn(e.tenantEmailDomain??"",G,i),s=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(o,{state:{pathnameStackToGoBack:s}})},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=$(),e=L(),n=ae(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),{fetchState:s,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(Se({id:i})),t(Q(G))}),0))})),[i,t]),r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const m=u??i,f=m!=null?`/${a}/invoicing/customers/${encodeURIComponent(m)}`:`/${a}/invoicing/customers`;e(f),t(Se({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerFormPage}),c.jsx(sa,{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=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,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!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomersListPage,isReady:y}),c.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:f,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:s}=e,u=o==null?void 0:s.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(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],d=Ne(s,a),p=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.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(Fe({...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=$(),e=L(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),[o,s]=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(_e(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const C=setTimeout((()=>{t(Fe({...o,sessionId:n}))}),300);return()=>clearTimeout(C)}),[a,t,o,n]);const f=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!f)return;const C=setInterval((()=>{t(_e(n)),t(Fe({...o,sessionId:n}))}),3e3);return()=>clearInterval(C)}),[a,t,o,f,n]);const S=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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(ua,{authParams:p,csvDownloadUrl:S,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}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 s=o??null;t(me(s)),ve(i,s),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=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),a=E(Qe);r.useEffect((()=>{i&&(t(Ei()),t(jn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ma,{navigate:e,tenantEmailDomain:n,view:a})]})}const pa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:d,sessionDetail:p,sessions:v}=u,m=a.externalConnections?.revenue?.find((S=>S.connectionName==="chargebee")),f=n!=null?p[n]:void 0;return{authParams:i,templatesDownloadUrl:s,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:f??v.find((S=>S.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 fa(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),a=E(Cn),o=E(Ce),s=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=>$n(h,d))),v=E(Qe),{activeMigrationSessionId:m}=v,f=m??void 0,S=f!=null?v.sessionDetail[f]??v.sessions.find((h=>h.id===f)):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=S?.status,C=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||f==null||!C)return;const h=setInterval((()=>{t(_e(f))}),3e3);return()=>clearInterval(h)}),[i,f,C,t]),r.useEffect((()=>{I==="done"&&(t(me(null)),ve(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportMigratePage}),c.jsx(pa,{activeId:f,authParams:s,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 Sa=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(Ln({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=$(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((I=>Ai(I,n))),s=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(Y({id:n})),()=>{t(Y({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]);const f=r.useCallback((I=>t(we({cacheOverride:!0,id:I}))),[t]),S=se(o.fetchState,o.isFormLoading,n,f);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),c.jsx(Sa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},S)]})}const ha=O((function(t){const e=Pn(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(Ln({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t($i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(At);function Ca(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,couponListFetchState:h,runningDiscountActionId:y}=E((b=>{const A=Pn(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!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:f,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,s={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,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(K({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(K({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(K({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(K({action:"retry",id:i}))}:void 0}}))(jt);function Ea(){const t=$(),e=L(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((k=>Li(k,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,p]=r.useState("idle"),[v,m]=r.useState(!1),[f,S]=r.useState(),[I,C]=r.useState(!1),h=r.useCallback((()=>{p("idle"),m(!1),S(void 0),C(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Pi({id:n})),p("idle"),m(!1);const k=o.emailPreview.preview;S(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(wi({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(ke({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{p("idle"),m(!1),S(void 0),C(!1)}),[n]),r.useEffect((()=>{a||(p("idle"),m(!1),S(void 0),C(!1))}),[a]),r.useEffect((()=>{I&&f==null&&o.emailPreview.preview!=null&&S({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,f,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t(Ri({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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(ka,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(Dt,{initialDraft:f,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=wn(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((s=>s.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(Fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))($t);function ba(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,dunningCaseListFetchState:h,dunningCases:y}=E((b=>{const A=wn(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!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(De({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningListPage,isReady:D}),c.jsx(ya,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,dunningCases:y,nextCursor:C,onSearchChange:o,onStatusChange:b=>{t(_i(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:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},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:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(s,{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:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
|
|
3
|
-
`).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:s.po_number!==""?s.po_number:null},invoiceId:i}))},onSendReminder:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(q({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(q({action:"void",invoiceId:i,body:s}))}}}))(Lt);function Aa(){const t=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((f=>Rn(f,n??""))),s=o.pageFetchState.fetchState,u=s==="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=se(o.actionState.fetchState,o.fetchState==="In-Progress",n,m);return N(s)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingInvoiceDetailPage,isReady:u}),c.jsx(xa,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},S)]})}const Da=O((function(t){const e=_n(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((s=>s.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(Fn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Pt);function ja(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=E((A=>{const k=_n(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)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingInvoicesListPage,isReady:b}),c.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=$(),e=L(),{tenantEmailDomain:n}=R(),i=wt(),a=pn(),[o,s]=r.useState(!1),{acceptTermsState:u,status:d}=E(Tn),p=Ni(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,m=S=>{s(S)};return d==="completed"?c.jsx(H,{to:`${v}/overview`,replace:!0}):d==="settings"&&p?c.jsx(H,{to:`${v}/settings`,replace:!0}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPromoPage}),c.jsx(No,{isAppContentDrawerOpen:o,handleDrawerToggle:m}),c.jsx(Rt,{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 $a=O((function(t,e){const n=On(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:s,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:s.fetchState==="Error"?s.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:s.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())}}}))(_t);function La(){const t=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),{fetchState:o,invoice:s,isPageReady:u,issuedCreditNoteId:d,submitState:p}=E((f=>On(f,n??""))),v=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>(t(sn()),m.current=null,()=>{t(sn())})),[t,n]),r.useEffect((()=>{a&&n!=null&&t(ke({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{s!=null&&n!=null&&o==="Completed"&&m.current!==n&&(m.current=n,t(Bi({localData:Vi(s)})))}),[t,o,s,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]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingIssueCreditNotePage,isReady:u}),c.jsx($a,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Pa=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`)}}}))(Ft);function wa(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a]=r.useState((()=>{const s=new Date;return{month:s.getMonth()+1,year:s.getFullYear()}})),o=E((s=>Mn(s).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Nn(a))}),[i,t,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingOverviewPage,isReady:o}),c.jsx(Pa,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const Ra=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 _a(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeType:S,appliedSearch:f,appliedSort:I,nextCursor:C,transactionListFetchState:h,transactions:y}=E((j=>{const _=Un(j);return{activeType:_.activeTab,appliedSearch:_.filters.search,appliedSort:_.sort,nextCursor:_.nextCursor,transactionListFetchState:_.fetchState,transactions:_.transactions}}),z),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const _=y.find((T=>T.id===j)),U=_?.linkedInvoices?.[0]?.invoiceID??_?.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 _=y.find((U=>U.id===j))?.customerID;_!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:_,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(_)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t($e({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t($e({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPaymentsListPage,isReady:D}),c.jsx(Ra,{navigate:e,tenantEmailDomain:n,activeType:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onTypeChange:j=>{t(Qi(j)),t($e({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p,onViewTransactionCustomer:k,onViewTransactionInvoice:A})]})}const Fa=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=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=n!=null&&n!=="",s=E(he),u=E((k=>Ki(k))),d=E(Gi),p=E((k=>Rn(k,n??""))),v=p.invoice,m=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Wi()),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(Yi({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(Fn({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((()=>s.customers.map((k=>({id:k.id,name:Fa(k)})))),[s.customers]),h=E((k=>Zi(k,u.localData.customerId))),y=r.useMemo((()=>h.map((k=>{return{amountDue:(j=k.amountDue,_=Xi.currencySymbol,Nt("0,0.00",j,_)),amountDueValue:k.amountDue,id:k.id,label:k.invoiceNumber};var j,_}))),[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 c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingRecordPaymentPage,isReady:A}),c.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(eo(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=(s,u)=>{const{subscription:d}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:s,amount:d?.mrr?.amount,customerId:d?.customerID,fromScreen:"subscription_detail",status:d?.status,subscriptionId:i}),t(Hn({action:s,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:s=>{t(ee({id:i,localData:s}))},onChangeTermEnd:a?s=>{const u=s?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(s)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Q(ie)),t(io({id:i}))},onOpenAddress:()=>{const s=et(e.tenantEmailDomain??"",ie,i),u=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onCloseEstimate:()=>{t(We())},onRequestEstimate:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Vn({id:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEdited,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Bn({id:i}))},onCancelSubscription:a?s=>{o("cancel",{cancel_reason_code:s.cancelReasonCode,end_of_term:!1,...s.cancelReason!=null&&s.cancelReason.trim()!==""?{cancel_reason:s.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(s,u)=>{s!=="pause"?o(s):o(s,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))(Ut);function Oa(){const t=$(),e=L(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),s=E((y=>Ge(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:d,subscriptionMetadataEditAllowedFromStatuses:p}=s,v=s.pageFetchState.fetchState,m=v==="Completed"&&!s.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=se(s.fetchState,s.isFormLoading,i,C);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionDetailPage,isReady:m}),c.jsx(Ta,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:s,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(We())},onRequestEstimate:()=>{t(Vn({id:i}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const a=et(e.tenantEmailDomain??"",ie,i),o=ce(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=$(),e=L(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=R(),[o]=oe(),{areTenantIdsInSync:s}=F(),u=o.get("customerId"),{fetchState:d,savedSubscriptionId:p}=E((C=>oo(C,i))),v=E((C=>Ge(C,i).localData));Ee(s);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(We())}),0))})),[i,t]),r.useEffect((()=>{s&&t(ao({subscriptionId:i}))}),[s,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]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionFormPage}),c.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,s)=>{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:s}))};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 s=o?.trim()??"";s!==""&&i(a,"change_term_end",{term_ends_at:s})},onSubscriptionAction:(a,o,s)=>{o!=="pause"?i(a,o):i(a,o,s!=null&&s.trim()!==""?{resume_date:s.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=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{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(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]);const A=r.useRef(y);return r.useEffect((()=>{const k=A.current!=null&&y==null;A.current=y,k&&i&&t(co())}),[y,i,t]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionsListPage,isReady:b}),c.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(so(k)),t(Le({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=$(),e=L(),{tenantEmailDomain:n,transaction_id:i}=R(),{areTenantIdsInSync:a}=F(),o=E((u=>lo(u,i??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(uo({id:i}))}),[a,i,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingTransactionDetailPage,isReady:s}),c.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=$(),{areTenantIdsInSync:s}=F(),u=E(Ye),d=u.connection?.connected===!0,p=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&s&&(a&&p!=="Not-Started"||o(Qn()),n&&o(mo()))}),[s,o,e,n,a]),r.useEffect((()=>{e&&s&&d&&i&&o(vo())}),[s,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=$(),{areTenantIdsInSync:n}=F(),{tenantEmailDomain:i}=R(),{fetchState:a,fieldHelp:o,logoFile:s,saveState:u,settings:d,stripeConnectState:p}=E(po),{configError:v,configFetchState:m,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C}=E(zn),h=E(Ye);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((P=>$n(P,b))),k=So(y.userRole??[]),j=y.tenantId??"",_=te.getSignedInUser(),U={userId:_?.userId??"",sessionId:_?.zeniSessionId??"",tenantId:j},T=s?.fileId,de=E((P=>T!=null&&T!==""?fo(P,T):void 0)),Je=E((P=>T!=null&&T!==""?Io(P,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 P=_?.userId;P!=null&&P!==""&&j!==""&&en.shouldFetchActiveTenant(j)&&(en.markActiveTenantFetchStarted(j),e(ho(P,j,_?.zeniSessionId)))}),[n,e,_?.userId,_?.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"),ct=a==="Completed"&&(!D||m==="Completed"),Ze=A.externalConnections?.revenue?.find((P=>P.connectionName==="chargebee"))?.connectionId,ye=pe?.invoicingMicroServiceBaseUrl,Xe=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:P=>{g.trackInvoicingActionClick(l.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(jo(P))},onDisconnect:(P,V)=>{j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingIntegrationDisconnected,{entity:V,entityId:P,fromScreen:t??"hub"}),e(Do(j,P,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 P=y.tenantEmailDomain??i??"";Ie.init("/connection/auth",P),Ie.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Wn()))},onSaveChargeBeeCredentials:(P,V)=>{Ze!=null&&j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(bo(j,Ze,ln("revenue"),xo("chargebee"),{api_key:P,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:Xe};return{authParams:U,deleteFileStatusById:tt,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:pe?.fileMicroServiceBaseUrl??"",integrationsSectionProps:J,isInvoicingPageReady:ct,isLoading:at,isSaving:u.fetchState==="In-Progress",isStripeBusy:p.fetchState==="In-Progress",logoFile:s,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:Xe,updateFileStatusById:it,onConnectStripe:J.onConnectStripe,onDeleteFile:P=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(yo(P,j))},onDisconnectStripe:J.onDisconnectStripe,onEditFileName:(P,V)=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(Eo(P,V.split(".")[0],j))},onReconnectQBO:J.onReconnectQBO,onRefreshQBO:J.onRefreshQBO,onRetryQboSyncTask:P=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:P,fromScreen:t??"hub"}),e(Gn(P))},onSave:P=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys(P).filter((V=>JSON.stringify(P[V])!==JSON.stringify(d?.[V]))),tab:t??"hub"}),e(ko({settings:P,snackbarSection:qa[t??""]}))},onStartQboBackfill:P=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Kn(P))},updateFilesEntity:P=>{g.trackInvoicingActionClick(l.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(Co({files:P}))}}}function mn({appContent:t}){const e=L(),n=ae(),i=$(),{tenantEmailDomain:a}=R(),o=re("branding"),s=E((d=>$o(d)));r.useEffect((()=>{s.saveState.fetchState==="Completed"&&i(Lo())}),[s.saveState.fetchState,i]);const u=Ue(s.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&s.saveState.fetchState==="Completed"&&e("..")}),[u,s.saveState.fetchState,e]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(qt,{address:s.address,fieldHelp:s.fieldHelp,addressLabel:s.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:s.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:s.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:d=>{i(Ro({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/${wo}/`,p=ce(n.state?.pathnameStackToGoBack,n.pathname);e(d,{state:{pathnameStackToGoBack:p}})},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{tab:"branding"}),i(Po())},updateFilesEntity:o.updateFilesEntity})]})}function Qa(){const t=L(),e=re("dunning");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),c.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=L(),e=re("integrations");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(zt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ka(){const t=L(),e=re("payment-destination");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),c.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"],Wa=O((function(t){const e=Yn(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(Fo())},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 Ya(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),i=E(Ce),{configFetchState:a,localData:o,savedLocalData:s,saveState:u,settingsFetchState:d}=E(Yn),p=r.useMemo((()=>{return m=o,S=s,[...[...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,s]),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}),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingQboSettingsPage}),c.jsx(Wa,{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(Wn())},onSave:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:p,tab:"quickbooks"}),t(_o())}})]})}const Ja={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Za(){const t=pn(),e=$(),n=L(),[i,a]=oe(),o=re(),{canEnableInvoicing:s,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]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Wt,{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:s,isQboConfigured:p,isStripePaymentsReady:v,onEnableInvoicingClick:d?void 0:()=>{g.trackInvoicingActionClick(l.Event.invoicingEnableClicked),e(Oo())}})]})}function vn(){return c.jsxs(ge,{children:[c.jsx(x,{index:!0,element:c.jsx(Za,{})}),c.jsx(x,{path:"payment-destination",element:c.jsx(Ka,{})}),c.jsx(x,{path:"branding",element:c.jsx(mn,{})}),c.jsx(x,{path:"branding/:addressType",element:c.jsx(mn,{appContent:c.jsx(Z,{isSubPage:!0,hideAddressBackButton:!0})})}),c.jsx(x,{path:"integrations",element:c.jsx(za,{})}),c.jsx(x,{path:"dunning",element:c.jsx(Qa,{})}),c.jsx(x,{path:"quickbooks",element:c.jsx(Ya,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:"..",replace:!0})})]})}function Ac(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),{enableState:a,fetchState:o,status:s}=E(Tn),u=Ue(a.fetchState),d=`/${n}/invoicing`,p=r.useRef(!1),v=E((m=>Ye(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]),s!=null||o==="Error"&&p.current?s==null?c.jsx(Jt,{onGoHome:()=>e(`/${n??""}`),onReload:()=>t(ne({cacheOverride:!0}))}):s==="not_started"?c.jsxs(ge,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/promo`,replace:!0})})]}):s==="settings"?c.jsxs(ge,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/settings`,replace:!0})})]}):c.jsxs(ge,{children:[c.jsx(x,{path:"/",element:c.jsx(H,{to:"overview",replace:!0})}),c.jsx(x,{path:"overview",element:c.jsx(wa,{})}),c.jsx(x,{path:"promo",element:c.jsx(H,{to:`${d}/overview`,replace:!0})}),c.jsx(x,{path:"customers",element:c.jsx(la,{})}),c.jsx(x,{path:"customers/new",element:c.jsx(ra,{})}),c.jsx(x,{path:"customers/new/:addressType",element:c.jsx(Z,{})}),c.jsx(x,{path:"customers/:customer_id",element:c.jsx(ca,{})}),c.jsx(x,{path:"customers/:customer_id/:addressType",element:c.jsx(Z,{})}),c.jsx(x,{path:"subscriptions",element:c.jsx(Ba,{})}),c.jsx(x,{path:"subscriptions/new",element:c.jsx(Na,{})}),c.jsx(x,{path:"subscriptions/new/:addressType",element:c.jsx(Z,{})}),c.jsx(x,{path:"subscriptions/:subscription_id",element:c.jsx(Oa,{})}),c.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:c.jsx(Z,{})}),c.jsx(x,{path:"invoices",element:c.jsx(ja,{})}),c.jsx(x,{path:"invoices/create",element:c.jsx(ea,{})}),c.jsx(x,{path:"invoices/:invoice_id",element:c.jsx(Aa,{})}),c.jsx(x,{path:"invoices/:invoice_id/record-payment",element:c.jsx(gn,{})}),c.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:c.jsx(La,{})}),c.jsx(x,{path:"payments",element:c.jsx(_a,{})}),c.jsx(x,{path:"payments/record",element:c.jsx(gn,{})}),c.jsx(x,{path:"payments/:transaction_id",element:c.jsx(Ha,{})}),c.jsx(x,{path:"credits",element:c.jsx(oa,{})}),c.jsx(x,{path:"credits/:credit_note_id",element:c.jsx(ta,{})}),c.jsx(x,{path:"discounts",element:c.jsx(Ca,{})}),c.jsx(x,{path:"discounts/new",element:c.jsx(Zo,{})}),c.jsx(x,{path:"discounts/:coupon_id",element:c.jsx(Ia,{})}),c.jsx(x,{path:"dunning",element:c.jsx(ba,{})}),c.jsx(x,{path:"dunning/:case_id",element:c.jsx(Ea,{})}),c.jsx(x,{path:"catalog",element:c.jsx(Yo,{})}),c.jsx(x,{path:"catalog/new",element:c.jsx(Ko,{})}),c.jsx(x,{path:"catalog/:item_id",element:c.jsx(Ho,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"audit_log",element:c.jsx(Uo,{})}),c.jsx(x,{path:"data_import",element:c.jsx(va,{})}),c.jsx(x,{path:"data_import/migrate",element:c.jsx(Sa,{})}),c.jsx(x,{path:"data_import/:sessionId",element:c.jsx(ga,{})}),c.jsx(x,{path:"*",element:c.jsx(M,{})})]}):c.jsx(Yt,{fetchState:"In-Progress"})}export{Ac as default};
|
|
3
|
+
`).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:s.po_number!==""?s.po_number:null},invoiceId:i}))},onSendReminder:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(q({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(q({action:"void",invoiceId:i,body:s}))}}}))(Lt);function Aa(){const t=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((S=>Rn(S,n??""))),s=o.pageFetchState.fetchState,u=s==="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((S=>t(ke({invoiceId:S}))),[t]),f=se(o.actionState.fetchState,o.fetchState==="In-Progress",n,m);return N(s)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingInvoiceDetailPage,isReady:u}),c.jsx(xa,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},f)]})}const Da=O((function(t){const e=_n(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((s=>s.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(Fn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Pt);function ja(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=E((A=>{const k=_n(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!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(je({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingInvoicesListPage,isReady:b}),c.jsx(Da,{navigate:e,tenantEmailDomain:n,activeStatus:f,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=$(),e=L(),{tenantEmailDomain:n}=R(),i=wt(),a=pn(),[o,s]=r.useState(!1),{acceptTermsState:u,status:d}=E(Tn),p=Ni(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,m=f=>{s(f)};return d==="completed"?c.jsx(H,{to:`${v}/overview`,replace:!0}):d==="settings"&&p?c.jsx(H,{to:`${v}/settings`,replace:!0}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPromoPage}),c.jsx(No,{isAppContentDrawerOpen:o,handleDrawerToggle:m}),c.jsx(Rt,{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 $a=O((function(t,e){const n=On(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:s,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:s.fetchState==="Error"?s.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:s.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())}}}))(_t);function La(){const t=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),{fetchState:o,invoice:s,isPageReady:u,issuedCreditNoteId:d,submitState:p}=E((S=>On(S,n??""))),v=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>(t(sn()),m.current=null,()=>{t(sn())})),[t,n]),r.useEffect((()=>{a&&n!=null&&t(ke({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{s!=null&&n!=null&&o==="Completed"&&m.current!==n&&(m.current=n,t(Bi({localData:Vi(s)})))}),[t,o,s,n]);const f=r.useRef(p.fetchState);return r.useEffect((()=>{const S=f.current;f.current=p.fetchState,S!=="Completed"&&p.fetchState==="Completed"&&d!=null&&e(`${v}/credits/${encodeURIComponent(d)}`)}),[d,e,p.fetchState,v]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingIssueCreditNotePage,isReady:u}),c.jsx($a,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Pa=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`)}}}))(Ft);function wa(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a]=r.useState((()=>{const s=new Date;return{month:s.getMonth()+1,year:s.getFullYear()}})),o=E((s=>Mn(s).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Nn(a))}),[i,t,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingOverviewPage,isReady:o}),c.jsx(Pa,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const Ra=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 _a(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeType:f,appliedSearch:S,appliedSort:I,nextCursor:C,transactionListFetchState:h,transactions:y}=E((j=>{const _=Un(j);return{activeType:_.activeTab,appliedSearch:_.filters.search,appliedSort:_.sort,nextCursor:_.nextCursor,transactionListFetchState:_.fetchState,transactions:_.transactions}}),z),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const _=y.find((T=>T.id===j)),U=_?.linkedInvoices?.[0]?.invoiceID??_?.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 _=y.find((U=>U.id===j))?.customerID;_!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:_,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(_)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t($e({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t($e({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPaymentsListPage,isReady:D}),c.jsx(Ra,{navigate:e,tenantEmailDomain:n,activeType:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onTypeChange:j=>{t(Qi(j)),t($e({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p,onViewTransactionCustomer:k,onViewTransactionInvoice:A})]})}const Fa=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=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=n!=null&&n!=="",s=E(he),u=E((k=>Ki(k))),d=E(Gi),p=E((k=>Rn(k,n??""))),v=p.invoice,m=`/${i}/invoicing`,f=r.useRef(null),S=r.useRef("");r.useEffect((()=>{t(Wi()),f.current=null,S.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"&&f.current!==n&&(f.current=n,t(Yi({contextInvoiceId:n,localData:Ji(v)})))}),[t,v,n,p.fetchState,o]),r.useEffect((()=>{if(o)return;const k=u.localData.customerId;k!==""&&k!==S.current&&(S.current=k,t(Fn({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((()=>s.customers.map((k=>({id:k.id,name:Fa(k)})))),[s.customers]),h=E((k=>Xi(k,u.localData.customerId))),y=r.useMemo((()=>h.map((k=>{return{amountDue:(j=k.amountDue,_=Zi.currencySymbol,Nt("0,0.00",j,_)),amountDueValue:k.amountDue,id:k.id,label:k.invoiceNumber};var j,_}))),[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 c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingRecordPaymentPage,isReady:A}),c.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(eo(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=(s,u)=>{const{subscription:d}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:s,amount:d?.mrr?.amount,customerId:d?.customerID,fromScreen:"subscription_detail",status:d?.status,subscriptionId:i}),t(Hn({action:s,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:s=>{t(ee({id:i,localData:s}))},onChangeTermEnd:a?s=>{const u=s?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(s)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Q(ie)),t(io({id:i}))},onOpenAddress:()=>{const s=et(e.tenantEmailDomain??"",ie,i),u=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onCloseEstimate:()=>{t(We())},onRequestEstimate:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Vn({id:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEdited,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Bn({id:i}))},onCancelSubscription:a?s=>{o("cancel",{cancel_reason_code:s.cancelReasonCode,end_of_term:!1,...s.cancelReason!=null&&s.cancelReason.trim()!==""?{cancel_reason:s.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(s,u)=>{s!=="pause"?o(s):o(s,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))(Ut);function Oa(){const t=$(),e=L(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),s=E((y=>Ge(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:d,subscriptionMetadataEditAllowedFromStatuses:p}=s,v=s.pageFetchState.fetchState,m=v==="Completed"&&!s.isFormLoading,[f,S]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&S(i)}),[i,m]);const I=f===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=se(s.fetchState,s.isFormLoading,i,C);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionDetailPage,isReady:m}),c.jsx(Ta,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:s,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(We())},onRequestEstimate:()=>{t(Vn({id:i}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const a=et(e.tenantEmailDomain??"",ie,i),o=ce(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=$(),e=L(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=R(),[o]=oe(),{areTenantIdsInSync:s}=F(),u=o.get("customerId"),{fetchState:d,savedSubscriptionId:p}=E((C=>oo(C,i))),v=E((C=>Ge(C,i).localData));Ee(s);const m=r.useRef(!1),f=r.useCallback((()=>{m.current=!0}),[]),S=r.useRef();r.useEffect((()=>(clearTimeout(S.current),m.current=!1,()=>{m.current||(S.current=setTimeout((()=>{t(Oe({id:i})),t(Q(ie)),t(We())}),0))})),[i,t]),r.useEffect((()=>{s&&t(ao({subscriptionId:i}))}),[s,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]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionFormPage}),c.jsx(Ma,{keepDraftOnLeave:f,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,s)=>{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:s}))};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 s=o?.trim()??"";s!==""&&i(a,"change_term_end",{term_ends_at:s})},onSubscriptionAction:(a,o,s)=>{o!=="pause"?i(a,o):i(a,o,s!=null&&s.trim()!==""?{resume_date:s.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=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,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:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,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(Le({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Le({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]);const A=r.useRef(y);return r.useEffect((()=>{const k=A.current!=null&&y==null;A.current=y,k&&i&&t(co())}),[y,i,t]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionsListPage,isReady:b}),c.jsx(Ua,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:k=>{t(so(k)),t(Le({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=$(),e=L(),{tenantEmailDomain:n,transaction_id:i}=R(),{areTenantIdsInSync:a}=F(),o=E((u=>lo(u,i??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(uo({id:i}))}),[a,i,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingTransactionDetailPage,isReady:s}),c.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=$(),{areTenantIdsInSync:s}=F(),u=E(Ye),d=u.connection?.connected===!0,p=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&s&&(a&&p!=="Not-Started"||o(Qn()),n&&o(mo()))}),[s,o,e,n,a]),r.useEffect((()=>{e&&s&&d&&i&&o(vo())}),[s,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=$(),{areTenantIdsInSync:n}=F(),{tenantEmailDomain:i}=R(),{fetchState:a,fieldHelp:o,logoFile:s,saveState:u,settings:d,stripeConnectState:p}=E(po),{configError:v,configFetchState:m,dunningScheduleActionOptions:f,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C}=E(zn),h=E(Ye);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((P=>$n(P,b))),k=fo(y.userRole??[]),j=y.tenantId??"",_=te.getSignedInUser(),U={userId:_?.userId??"",sessionId:_?.zeniSessionId??"",tenantId:j},T=s?.fileId,de=E((P=>T!=null&&T!==""?So(P,T):void 0)),Je=E((P=>T!=null&&T!==""?Io(P,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 P=_?.userId;P!=null&&P!==""&&j!==""&&en.shouldFetchActiveTenant(j)&&(en.markActiveTenantFetchStarted(j),e(ho(P,j,_?.zeniSessionId)))}),[n,e,_?.userId,_?.zeniSessionId,j]);const ot=f.length>0||S.length>0,at=a==="Not-Started"||a==="In-Progress"&&d==null||D&&!ot&&(m==="Not-Started"||m==="In-Progress"),ct=a==="Completed"&&(!D||m==="Completed"),Xe=A.externalConnections?.revenue?.find((P=>P.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:P=>{g.trackInvoicingActionClick(l.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(jo(P))},onDisconnect:(P,V)=>{j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingIntegrationDisconnected,{entity:V,entityId:P,fromScreen:t??"hub"}),e(Do(j,P,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 P=y.tenantEmailDomain??i??"";Ie.init("/connection/auth",P),Ie.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Wn()))},onSaveChargeBeeCredentials:(P,V)=>{Xe!=null&&j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(bo(j,Xe,ln("revenue"),xo("chargebee"),{api_key:P,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:f,filesEndPoint:pe?.fileMicroServiceBaseUrl??"",integrationsSectionProps:J,isInvoicingPageReady:ct,isLoading:at,isSaving:u.fetchState==="In-Progress",isStripeBusy:p.fetchState==="In-Progress",logoFile:s,qboAccountMappingKindOptions:S,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:P=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(yo(P,j))},onDisconnectStripe:J.onDisconnectStripe,onEditFileName:(P,V)=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(Eo(P,V.split(".")[0],j))},onReconnectQBO:J.onReconnectQBO,onRefreshQBO:J.onRefreshQBO,onRetryQboSyncTask:P=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:P,fromScreen:t??"hub"}),e(Gn(P))},onSave:P=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys(P).filter((V=>JSON.stringify(P[V])!==JSON.stringify(d?.[V]))),tab:t??"hub"}),e(ko({settings:P,snackbarSection:qa[t??""]}))},onStartQboBackfill:P=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Kn(P))},updateFilesEntity:P=>{g.trackInvoicingActionClick(l.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(Co({files:P}))}}}function mn({appContent:t}){const e=L(),n=ae(),i=$(),{tenantEmailDomain:a}=R(),o=re("branding"),s=E((d=>$o(d)));r.useEffect((()=>{s.saveState.fetchState==="Completed"&&i(Lo())}),[s.saveState.fetchState,i]);const u=Ue(s.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&s.saveState.fetchState==="Completed"&&e("..")}),[u,s.saveState.fetchState,e]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(qt,{address:s.address,fieldHelp:s.fieldHelp,addressLabel:s.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:s.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:s.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:d=>{i(Ro({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/${wo}/`,p=ce(n.state?.pathnameStackToGoBack,n.pathname);e(d,{state:{pathnameStackToGoBack:p}})},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{tab:"branding"}),i(Po())},updateFilesEntity:o.updateFilesEntity})]})}function Qa(){const t=L(),e=re("dunning");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),c.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=L(),e=re("integrations");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(zt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ka(){const t=L(),e=re("payment-destination");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),c.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"],Wa=O((function(t){const e=Yn(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(Fo())},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 Ya(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),i=E(Ce),{configFetchState:a,localData:o,savedLocalData:s,saveState:u,settingsFetchState:d}=E(Yn),p=r.useMemo((()=>{return m=o,f=s,[...[...new Set([...Object.keys(m.accountIdByMappingCode),...Object.keys(f.accountIdByMappingCode)])].some((S=>(m.accountIdByMappingCode[S]??"")!==(f.accountIdByMappingCode[S]??"")))?["account_mappings"]:[],...Ga.filter((S=>m[S]!==f[S]))];var m,f}),[o,s]),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}),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingQboSettingsPage}),c.jsx(Wa,{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(Wn())},onSave:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:p,tab:"quickbooks"}),t(_o())}})]})}const Ja={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Xa(){const t=pn(),e=$(),n=L(),[i,a]=oe(),o=re(),{canEnableInvoicing:s,isEnablingInvoicing:u,isInvoicingEnabled:d,isQboConfigured:p,isStripeConnected:v}=E(zn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const f=Ja[m];a({},{replace:!0}),f!=null&&n(f,{replace:!0})}),[m,n,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Wt,{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:s,isQboConfigured:p,isStripePaymentsReady:v,onEnableInvoicingClick:d?void 0:()=>{g.trackInvoicingActionClick(l.Event.invoicingEnableClicked),e(Oo())}})]})}function vn(){return c.jsxs(ge,{children:[c.jsx(x,{index:!0,element:c.jsx(Xa,{})}),c.jsx(x,{path:"payment-destination",element:c.jsx(Ka,{})}),c.jsx(x,{path:"branding",element:c.jsx(mn,{})}),c.jsx(x,{path:"branding/:addressType",element:c.jsx(mn,{appContent:c.jsx(X,{isSubPage:!0,hideAddressBackButton:!0})})}),c.jsx(x,{path:"integrations",element:c.jsx(za,{})}),c.jsx(x,{path:"dunning",element:c.jsx(Qa,{})}),c.jsx(x,{path:"quickbooks",element:c.jsx(Ya,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:"..",replace:!0})})]})}function Ac(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),{enableState:a,fetchState:o,status:s}=E(Tn),u=Ue(a.fetchState),d=`/${n}/invoicing`,p=r.useRef(!1),v=E((m=>Ye(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]),s!=null||o==="Error"&&p.current?s==null?c.jsx(Jt,{onGoHome:()=>e(`/${n??""}`),onReload:()=>t(ne({cacheOverride:!0}))}):s==="not_started"?c.jsxs(ge,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/promo`,replace:!0})})]}):s==="settings"?c.jsxs(ge,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/settings`,replace:!0})})]}):c.jsxs(ge,{children:[c.jsx(x,{path:"/",element:c.jsx(H,{to:"overview",replace:!0})}),c.jsx(x,{path:"overview",element:c.jsx(wa,{})}),c.jsx(x,{path:"promo",element:c.jsx(H,{to:`${d}/overview`,replace:!0})}),c.jsx(x,{path:"customers",element:c.jsx(la,{})}),c.jsx(x,{path:"customers/new",element:c.jsx(ra,{})}),c.jsx(x,{path:"customers/new/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"customers/:customer_id",element:c.jsx(ca,{})}),c.jsx(x,{path:"customers/:customer_id/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"subscriptions",element:c.jsx(Ba,{})}),c.jsx(x,{path:"subscriptions/new",element:c.jsx(Na,{})}),c.jsx(x,{path:"subscriptions/new/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"subscriptions/:subscription_id",element:c.jsx(Oa,{})}),c.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"invoices",element:c.jsx(ja,{})}),c.jsx(x,{path:"invoices/create",element:c.jsx(ea,{})}),c.jsx(x,{path:"invoices/:invoice_id",element:c.jsx(Aa,{})}),c.jsx(x,{path:"invoices/:invoice_id/record-payment",element:c.jsx(gn,{})}),c.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:c.jsx(La,{})}),c.jsx(x,{path:"payments",element:c.jsx(_a,{})}),c.jsx(x,{path:"payments/record",element:c.jsx(gn,{})}),c.jsx(x,{path:"payments/:transaction_id",element:c.jsx(Ha,{})}),c.jsx(x,{path:"credits",element:c.jsx(oa,{})}),c.jsx(x,{path:"credits/:credit_note_id",element:c.jsx(ta,{})}),c.jsx(x,{path:"discounts",element:c.jsx(Ca,{})}),c.jsx(x,{path:"discounts/new",element:c.jsx(Xo,{})}),c.jsx(x,{path:"discounts/:coupon_id",element:c.jsx(Ia,{})}),c.jsx(x,{path:"dunning",element:c.jsx(ba,{})}),c.jsx(x,{path:"dunning/:case_id",element:c.jsx(Ea,{})}),c.jsx(x,{path:"catalog",element:c.jsx(Yo,{})}),c.jsx(x,{path:"catalog/new",element:c.jsx(Ko,{})}),c.jsx(x,{path:"catalog/:item_id",element:c.jsx(Ho,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"audit_log",element:c.jsx(Uo,{})}),c.jsx(x,{path:"data_import",element:c.jsx(va,{})}),c.jsx(x,{path:"data_import/migrate",element:c.jsx(fa,{})}),c.jsx(x,{path:"data_import/:sessionId",element:c.jsx(ga,{})}),c.jsx(x,{path:"*",element:c.jsx(M,{})})]}):c.jsx(Yt,{fetchState:"In-Progress"})}export{Ac as default};
|