@zeniai/web-app-ui 5.3.29-dev → 5.3.29-qa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AccountMappingScreen-CDcb3dR7.js → AccountMappingScreen-Bim1Hr_z.js} +1 -1
- package/dist/assets/AddressRoutes-CdDnkC-7.js +1 -0
- package/dist/assets/{AddressScreen-KciR_hsZ.js → AddressScreen-Dyq7f1j-.js} +1 -1
- package/dist/assets/{AiCfoScreen-CL9wzpIP.js → AiCfoScreen-BAtt2kQC.js} +1 -1
- package/dist/assets/{AppDrawer-CBFgx_xO.js → AppDrawer-BGKn6F8p.js} +1 -1
- package/dist/assets/{BillPayApprovalRoutes-DmmLz8dY.js → BillPayApprovalRoutes-Cf5w1Fd_.js} +1 -1
- package/dist/assets/{BillPayRoutes-C_uGbX5e.js → BillPayRoutes-DDeK4O3Z.js} +1 -1
- package/dist/assets/{BusinessVerificationPageScreen-CBOgxA4z.js → BusinessVerificationPageScreen-BhpdMjkc.js} +1 -1
- package/dist/assets/{CardsAiCfoScreen-B8SHn0bs.js → CardsAiCfoScreen-BmeTr_5u.js} +1 -1
- package/dist/assets/{ChargeCardRoutes-Dkpm3e49.js → ChargeCardRoutes-Y_ZnY6a9.js} +1 -1
- package/dist/assets/{CompanyPassportScreen-C-SlqPHT.js → CompanyPassportScreen-BChXj6Kk.js} +1 -1
- package/dist/assets/{ConnectionAuthScreen-IHk0kFrL.js → ConnectionAuthScreen-DboT0gK7.js} +1 -1
- package/dist/assets/CustomerOnboardingAuthScreen-C9C7O3K1.js +1 -0
- package/dist/assets/{CustomerOnboardingRoutes-BRdsXEtS.js → CustomerOnboardingRoutes-CRNi6Rqr.js} +1 -1
- package/dist/assets/{DashboardRoutes-CLhCpuhB.js → DashboardRoutes-CzNNddHy.js} +1 -1
- package/dist/assets/{DefaultTenantHome-Btkw8Ap3.js → DefaultTenantHome-CmugmZX7.js} +1 -1
- package/dist/assets/{DomesticWireDetailScreen-Dzk5sa_d.js → DomesticWireDetailScreen-C2hFGwu0.js} +1 -1
- package/dist/assets/{DrawerScreen-Cq2VoXGn.js → DrawerScreen-lK0vJxIS.js} +1 -1
- package/dist/assets/{EntityDetailRoutes-CTolGUo8.js → EntityDetailRoutes-BSm0QeV6.js} +1 -1
- package/dist/assets/{ExpenseAutomationRoutes-Dsuu9sFZ.js → ExpenseAutomationRoutes-CVR_qG3c.js} +1 -1
- package/dist/assets/{FeaturePreviewScreen-h7p9MMUf.js → FeaturePreviewScreen-CVnp0bZd.js} +1 -1
- package/dist/assets/{HubSpotOAuthCallbackScreen-BTzQvozK.js → HubSpotOAuthCallbackScreen-Ck10qQ6V.js} +1 -1
- package/dist/assets/{InboxNotificationsProvider-Y2y35nP6.js → InboxNotificationsProvider-MlM0K3gF.js} +1 -1
- package/dist/assets/{InvoicingRoutes-MDlqxyil.js → InvoicingRoutes-Q8vi5u3U.js} +1 -1
- package/dist/assets/{MagicLinkRoutes-CP3vqiHe.js → MagicLinkRoutes-B3omwZ45.js} +1 -1
- package/dist/assets/{MagicLinkSignInScreen-BMClM24d.js → MagicLinkSignInScreen-D8Vs7E-F.js} +1 -1
- package/dist/assets/{MobileAppDrawer-DLiH8K3Y.js → MobileAppDrawer-DigqZbbY.js} +1 -1
- package/dist/assets/NotFoundScreen-C_nzijM_.js +1 -0
- package/dist/assets/{NotificationRoutes-Dhiufflf.js → NotificationRoutes-DKgxAwSp.js} +1 -1
- package/dist/assets/{OAuthConsentScreen-Ca-lx4xM.js → OAuthConsentScreen-DY5NR4TR.js} +1 -1
- package/dist/assets/{PandLWithForecastRoutes-aW5WT5CH.js → PandLWithForecastRoutes-5el-0Lj7.js} +1 -1
- package/dist/assets/{PaymentLinkScreen-C2OZJlFd.js → PaymentLinkScreen-fA05KlxQ.js} +1 -1
- package/dist/assets/{PeopleRoutes-B2NEnvyj.js → PeopleRoutes-DJYa775V.js} +1 -1
- package/dist/assets/{PerformanceRoutes-DphKMt6B.js → PerformanceRoutes-CrDIRhB1.js} +1 -1
- package/dist/assets/{Preview-BeiBQxK-.js → Preview-CzyJ4PGQ.js} +1 -1
- package/dist/assets/{QBOConnectionScreen-O0kY1C3B.js → QBOConnectionScreen-ByKxBz2v.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRoutes-Dzvw2fZr.js → ReimbursementApprovalRoutes-CGtOCJ7F.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRuleDetailScreen-BaxtZSL2.js → ReimbursementApprovalRuleDetailScreen-CuE7ORwk.js} +1 -1
- package/dist/assets/{ReimbursementRoutes-DmbcBT5E.js → ReimbursementRoutes-6nUym5eB.js} +1 -1
- package/dist/assets/{ReportsRoutes-BQmYqXvS.js → ReportsRoutes-s2hJ2RsR.js} +1 -1
- package/dist/assets/{RewardsRoutes-DvgOSJy0.js → RewardsRoutes-C-di4Yoz.js} +1 -1
- package/dist/assets/{ScreenRoutes-D76vOiPC.js → ScreenRoutes-BhCi8qGV.js} +2 -2
- package/dist/assets/{SettingsRoutes-DNrMSB0r.js → SettingsRoutes-AaNqIdby.js} +1 -1
- package/dist/assets/{SetupPagesScreen-28K-Ej_i.js → SetupPagesScreen-BgHIeOKB.js} +1 -1
- package/dist/assets/{SignInScreen-JKxT9Chm.js → SignInScreen-DCTVuESb.js} +1 -1
- package/dist/assets/{SignOutScreen-DkhnXWYi.js → SignOutScreen-Dl74ZT33.js} +1 -1
- package/dist/assets/{TaskListScreen-D13comxS.js → TaskListScreen-D4isBRlx.js} +1 -1
- package/dist/assets/{TaskRoutes-BOftPZQw.js → TaskRoutes-BWLw4wFO.js} +1 -1
- package/dist/assets/TransactionDetailRoutes-BLhI-0B0.js +1 -0
- package/dist/assets/{TransactionDetailScreen-B1_fDc_7.js → TransactionDetailScreen-IKPgPc-W.js} +1 -1
- package/dist/assets/{TransactionListRoutes-DQwcR30R.js → TransactionListRoutes-Bu8kgDQQ.js} +1 -1
- package/dist/assets/{TreasuryRoutes-Dnwm_7bw.js → TreasuryRoutes-CZBiOy69.js} +1 -1
- package/dist/assets/{VendorsRoutes-BCbNpFFW.js → VendorsRoutes-KMa9llQ2.js} +1 -1
- package/dist/assets/{WiseConfirmationScreen-mPs6_3sL.js → WiseConfirmationScreen-tpmS2fpR.js} +1 -1
- package/dist/assets/{ZeniAccountRoutes-CQnM-9GW.js → ZeniAccountRoutes-DpPln-Iv.js} +1 -1
- package/dist/assets/{ZeniAccountStatementScreen-CTIued6H.js → ZeniAccountStatementScreen-C_X33S2u.js} +1 -1
- package/dist/assets/{accountMappingHelper-CJgy_TdU.js → accountMappingHelper-BIF4Ld_b.js} +1 -1
- package/dist/assets/{analytics-drf9tsEq.js → analytics-B5-t19F2.js} +1 -1
- package/dist/assets/{analyticsHelper-CDqT9wg1.js → analyticsHelper-5kEw8e8E.js} +1 -1
- package/dist/assets/{core-OUhaP0nM.js → core-C5rVvNoh.js} +1 -1
- package/dist/assets/{decodeURIComponentSafe-CoJI0rbl.js → decodeURIComponentSafe-ChlmY296.js} +1 -1
- package/dist/assets/{dnd-XtKnRPbJ.js → dnd-DqvXOfHm.js} +1 -1
- package/dist/assets/{empty-CJaMNnL0.js → empty-BTHEbwNZ.js} +1 -1
- package/dist/assets/{empty-DC6SKf2K.js → empty-D5lwiblX.js} +1 -1
- package/dist/assets/{emptyVideoElement-b-LZRj6t.js → emptyVideoElement-I-9RXuP2.js} +1 -1
- package/dist/assets/{epic-Cg0CX13O.js → epic-DYPr57kS.js} +1 -1
- package/dist/assets/{expenseAutomationHelper-DlI9q6Vn.js → expenseAutomationHelper-DT3oLJj6.js} +1 -1
- package/dist/assets/{getLocaleForTenant-aTGgtilb.js → getLocaleForTenant-DQ9OiUn_.js} +1 -1
- package/dist/assets/{index-BjnriIg-.js → index-BTTzX8oM.js} +8 -8
- package/dist/assets/{index-Ic-s4E7h.js → index-Bue9AeKl.js} +1 -1
- package/dist/assets/{index-DmRkUvqd.js → index-CGyxP256.js} +1 -1
- package/dist/assets/{index-B1OJLTM8.js → index-CZcqif3N.js} +2 -2
- package/dist/assets/{index-9ur6Fy2d.js → index-CibO_KMz.js} +1 -1
- package/dist/assets/{index-DkPv0SRW.js → index-DCp3lIjg.js} +1 -1
- package/dist/assets/{index-DWbw7UWG.js → index-DMhoHJcD.js} +1 -1
- package/dist/assets/{index-BEdQXZ7l.js → index-De1cB3Ka.js} +1 -1
- package/dist/assets/{lexical-cGeYDtsl.js → lexical-BO1ifV0W.js} +1 -1
- package/dist/assets/{liveblocks-QA8yK6T_.js → liveblocks-BhGApeF9.js} +1 -1
- package/dist/assets/{lottie-DaBLQBPb.js → lottie-CSUQXsXJ.js} +1 -1
- package/dist/assets/{mui-BtZD__8k.js → mui-AVx3Hg0F.js} +1 -1
- package/dist/assets/{pathToGoBack-C7Q0VFSf.js → pathToGoBack-CW7sD0XS.js} +1 -1
- package/dist/assets/{pdf-BMGNA2GO.js → pdf-B6tAgCXh.js} +3 -3
- package/dist/assets/{pdf-lib-BukwiyrA.js → pdf-lib-u-Ml-CIk.js} +1 -1
- package/dist/assets/{plaid-Bbika4Gn.js → plaid-BuoWWOAj.js} +1 -1
- package/dist/assets/{pusher-9ZM5Kdsl.js → pusher-D8sdZANA.js} +1 -1
- package/dist/assets/{react-Cvhq9zob.js → react-BslW5-Xl.js} +1 -1
- package/dist/assets/{react-SMF3sABx.js → react-DAMRot7g.js} +1 -1
- package/dist/assets/{react-BbnUu-8y.js → react-DbafCI99.js} +1 -1
- package/dist/assets/{react-DyjJC6aa.js → react-DzRqKqJZ.js} +1 -1
- package/dist/assets/{react-_5p9PyE0.js → react-Sh9CA0od.js} +1 -1
- package/dist/assets/{react-B7VQZShg.js → react-q70XtbNu.js} +1 -1
- package/dist/assets/{recharts-CnI5kYGO.js → recharts-uwVP8vj-.js} +1 -1
- package/dist/assets/{routePaths-Cz-sxWeK.js → routePaths-Cx9L8hBM.js} +1 -1
- package/dist/assets/{sentry-DX8X0N2R.js → sentry-B98sAG37.js} +1 -1
- package/dist/assets/{url-DKOm_9Da.js → url-RaJlDbzw.js} +1 -1
- package/dist/assets/{url-DEE9M609.js → url-qe19dJXu.js} +1 -1
- package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-CCxuDvI3.js → useAiCfoDashboardSuggestedQuestionsChips-C7_zR2C_.js} +1 -1
- package/dist/assets/{useAskAiCfoHostNavButtonProps-B4mPUD91.js → useAskAiCfoHostNavButtonProps-Ddvy6nOQ.js} +1 -1
- package/dist/assets/{useChargeCardPusherEvents-u2vXo3UU.js → useChargeCardPusherEvents-XPXgI-Bx.js} +1 -1
- package/dist/assets/{useDeviceId-Bunv1-ta.js → useDeviceId-6INyJgde.js} +1 -1
- package/dist/assets/{useEmailConnectResultRefresh-DRqxGzlR.js → useEmailConnectResultRefresh-98NnzJRh.js} +1 -1
- package/dist/assets/{useInitialThreadRequest-BR_6LodZ.js → useInitialThreadRequest-DuL5mYzq.js} +1 -1
- package/dist/assets/{useTaskManagerAccess-3mEVnK_N.js → useTaskManagerAccess-vcnpqvQT.js} +1 -1
- package/dist/assets/{utils-CHDSUF0P.js → utils-B1bcOxs7.js} +1 -1
- package/dist/assets/{withTransactionSidePanel-DRyJqOb1.js → withTransactionSidePanel-F28FfzEK.js} +1 -1
- package/dist/assets/{zeni-epic-state-DzFY1eNZ.js → zeni-epic-state-BVExw1ei.js} +3 -3
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/AddressRoutes-loJi-MTb.js +0 -1
- package/dist/assets/CustomerOnboardingAuthScreen-9EVdL7z6.js +0 -1
- package/dist/assets/NotFoundScreen-CBOeKuhG.js +0 -1
- package/dist/assets/TransactionDetailRoutes-Br_-ul_i.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as s}from"./liveblocks-QA8yK6T_.js";import{a as r}from"./sentry-DX8X0N2R.js";import{u as P,h as A,i as F,j as E,t as W,l as O,s as Z,g as Y,N as B,n as te,o as y}from"./core-OUhaP0nM.js";import{a6 as lt,h as p,ao as T,Q as g,c9 as dt,ca as ut,cb as gt,cc as mt,cd as vt,ce as pt,cf as ft,cg as St,ch as ht,ci as Ct,cj as It,ck as Et,cl as kt,cm as yt,p as J,cn as xt,co as bt,ac as ae,cp as jt,cq as Dt,z as Se,cr as Pt,cs as At,ct as Lt,cu as $t,cv as wt,cw as Ft,cx as Tt,cy as Rt,V as Ot,ag as Sn,cz as _t,cA as Mt,cB as Nt,cC as Ut,cD as Bt,cE as Vt,cF as Zt,cG as Ht,cH as qt,t as Ke,g as hn,cI as Kt,cJ as Qt,cK as Gt,cL as zt,cM as Wt,cN as Yt,cO as Jt}from"./index-BjnriIg-.js";import"./mui-BtZD__8k.js";import{A as K}from"./AddressScreen-KciR_hsZ.js";import M from"./NotFoundScreen-CBOeKuhG.js";import{YY as Xt,YZ as ei,uM as Qe,Y_ as je,Y$ as Q,vQ as Ge,vX as ni,w0 as Cn,Z0 as De,Z1 as In,vU as En,Z2 as Pe,vS as kn,yw as ti,vT as ii,Z3 as G,vd as se,vM as oi,xn as ze,vc as he,Z4 as ai,Z5 as yn,w7 as si,Z6 as z,we as ci,Z7 as ri,Z8 as xn,Z9 as bn,yi as li,Za as de,Zb as We,Zc as jn,va as di,Zd as ui,v4 as gi,Ze as mi,xA as vi,Zf as Dn,xJ as Ye,Zg as pi,xG as fi,Zh as Ae,gd as Si,Zi as ee,Zj as ne,wt as hi,vi as Je,Zk as Le,vn as Pn,vl as Ci,vf as Ii,wm as Ei,vp as ki,wv as yi,Zl as Ce,wC as An,wA as Ie,Fm as $e,xP as Xe,Zm as xi,vb as we,Zn as Fe,vy as Ee,vv as ke,vI as Ln,vH as Te,vs as bi,vB as $n,vK as ie,fB as Re,UL as wn,ve as Oe,vF as ji,vG as Di,vE as Pi,Zo as Ai,wa as en,wf as Li,wb as Fn,Zp as Tn,u_ as nn,Zq as $i,uW as Rn,Zr as wi,xV as Fi,xZ as H,xU as Ti,x1 as _e,Zs as Ri,Zt as On,y6 as tn,Zu as Oi,y3 as _i,Zv as _n,x4 as Mi,x5 as V,x8 as Ni,Zw as Mn,xi as me,Zx as Ui,wu as Nn,Tj as Un,Zy as Bi,xs as Vi,Zz as Bn,ZA as Zi,ZB as Hi,ZC as qi,yX as Ki,ZD as Qi,ZE as Vn,yd as Zn,ZF as Hn,yV as ve,ZG as Gi,yS as zi,ZH as Wi,ZI as Yi,ZJ as Ji,ZK as Xi,ZL as eo,ZM as on,ZN as no,y$ as to,ZO as Me,wM as an,ZP as Ne,ZQ as ce,wW as qn,wR as Kn,wP as ye,ZR as io,wH as oo,yj as Qn,yK as sn,yF as ao,ZS as so,yk as co,ZT as ro,yL as lo,yP as uo,ZU as go,ZV as Gn,c7 as mo,mo as vo,mp as po,ZW as cn,vR as re,gh as fo,uc as So,mv as ho,yC as zn,zb as Co,yz as Wn,ui as Io,z8 as rn,u6 as Eo,z5 as ln,hP as ko,TL as dn,TM as yo,Fy as Yn,hH as xo,ZX as bo,UA as jo,ZY as Do,zh as pe,zi as Po,ZZ as Ao,Z_ as Jn,ze as Lo,Z$ as $o,_0 as wo,xw as Fo,_1 as To}from"./zeni-epic-state-DzFY1eNZ.js";import{M as Ro}from"./MobileAppDrawer-DLiH8K3Y.js";import{q as le}from"./QBOConnectionScreen-O0kY1C3B.js";import"./recharts-CnI5kYGO.js";import"./analytics-drf9tsEq.js";import"./plaid-Bbika4Gn.js";import"./dnd-XtKnRPbJ.js";import"./stripe-cKAAJElX.js";import"./lottie-DaBLQBPb.js";import"./lexical-cGeYDtsl.js";import"./pdf-BMGNA2GO.js";import"./utils-CHDSUF0P.js";import"./InboxNotificationsProvider-Y2y35nP6.js";import"./useTaskManagerAccess-3mEVnK_N.js";import"./empty-CJaMNnL0.js";import"./pdf-lib-BukwiyrA.js";import"./index-DWbw7UWG.js";import"./url-DKOm_9Da.js";import"./index-DmRkUvqd.js";import"./decodeURIComponentSafe-CoJI0rbl.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]="b12010f2-2ce3-4fda-a998-c12e113cf413",t._sentryDebugIdIdentifier="sentry-dbid-b12010f2-2ce3-4fda-a998-c12e113cf413")}catch{}})();const w=({event:t,isReady:e=!0})=>e?s.jsx(lt,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Oo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:k}=E(Xt),x=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),b=`/${n??""}/invoicing`,I=r.useCallback(((_,R)=>{const U=ei(b,_,R,j);U!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{entity:_,entityId:R,fromScreen:"audit_log"}),e(U))}),[j,e,b]);r.useEffect((()=>{const _=setTimeout((()=>d(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&t(Qe({filters:x,keepExistingListItems:!1,sort:u}))}),[i,x,u,t]);const D=m==="Not-Started"||m==="In-Progress"&&f.length===0,C=m==="In-Progress"&&f.length>0,L=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingAuditLogPage,isReady:L}),s.jsx(dt,{auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:k,entries:f,hasMore:S,isLoading:D,isLoadingMore:C,searchValue:o,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&t(Qe({cursor:h,filters:x,keepExistingListItems:!0,sort:u}))},onSearchChange:a,onSortChange:v})]})}const _o=new Set(["plan"]),Xn=[],Mo=In((t=>t.length>0?t:Xn),mt),No=In((t=>t.length>0?t:Xn),gt),Uo=O((function(t,e){const{view:n}=e;return{groupedAccountOptions:Mo(n.qboAccountHierarchy),groupedClassOptions:No(n.qboClassHierarchy),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!==""?o=>{i!==""&&t(En({action:o,id:i}))}:void 0,onEditChange:o=>{i!==""&&t(De({id:i,localData:o}))},onSaveEdit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemEdited,{itemId:i}),t(Cn({id:i}))},onSubFamilyLifecycleAction:(o,a)=>{i!==""&&t(ni({action:a,id:o,parentItemId:i}))}}}))(ut);function Bo(){const t=P(),e=A(),{item_id:n,tenantEmailDomain:i}=F(),[o]=W(),{areTenantIdsInSync:a}=T(),c=(d=o.get("kind"))!=null&&_o.has(d)?d:"plan";var d;const l=E((k=>je(k,n))),{pageFetchState:v,plan:u}=l,m=v.fetchState;r.useEffect((()=>(t(Q()),()=>{t(Q())})),[t]),r.useEffect((()=>{a&&t(Ge({id:n,kind:c}))}),[a,n,c,t]);const[S,f]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(t(Q()),t(Ge({cacheOverride:!0,id:n,kind:c})),f((k=>k+1)))}),[l.fetchState,t,n,c]);const h=u==null&&(m==="Not-Started"||m==="In-Progress"),j=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogItemDetailPage,isReady:j}),s.jsx(Uo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:h,view:l},S)]})}function Ue(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:o=!1}=t,a=P(),{areTenantIdsInSync:c}=T(),d=E(Pe),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(o&&v!=="Not-Started"||a(kn()),n&&a(ti()))}),[c,a,e,n,o]),r.useEffect((()=>{e&&c&&l&&i&&a(ii())}),[c,a,e,l,i]),{isQboConnected:l,qboView:d}}function Be(t,e=!1){const n=P(),i=E((c=>G(c).productNextCursor!=null)),o=E((c=>G(c).productNextCursor)),a=E((c=>G(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&a!=="Not-Started"||n(se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&a!=="In-Progress"&&i&&o!=null&&n(se({cursor:o,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,a,i,o])}const Vo=new Set(["addon","charge","plan"]),Zo=new Set(["plan"]),Ho=O((function(t,e){const n=je(t,e.itemId);return{fieldHelp:n.fieldHelp,isQboPickerDataLoading:n.isQboPickerDataLoading,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,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",localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:o}=e,a=o!=null?`${n}/catalog/${encodeURIComponent(o)}`:`${n}/catalog`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemFormCancelled),t(Q()),e.navigate(`${n}/catalog`)},onChange:c=>{t(De({id:o,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemSaved,{mode:i}),t(Cn({id:o}))}}}))(vt);function qo(){const t=P(),e=A(),{item_id:n,tenantEmailDomain:i}=F(),[o]=W(),{areTenantIdsInSync:a}=T(),c=n!=null,d=o.get("type"),l=d!=null&&Vo.has(d)?d:void 0,v=(u=o.get("kind"))!=null&&Zo.has(u)?u:"plan";var u;const m=E((S=>je(S,n)));return Be(a,!0),Ue({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{a&&n!=null&&t(oi({id:n,kind:v}))}),[a,n,v,t]),r.useEffect((()=>{c||l==null||m.localData.catalogType===l||t(De({localData:{...m.localData,catalogType:l}}))}),[c,l,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??n,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),t(Q())}}),[m.fetchState,m.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogItemFormPage}),s.jsx(Ho,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const Ko={addons:"addon",all:"item",charges:"charge",plans:"plan"},Qo=O((function(t,e){const n=G(t),i=e.activeTab==="plans",o=e.activeTab==="all",a=i?n.plans:o?[...n.plans,...n.products]:n.products,c=i||o&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:o&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&a.length===0,isLoadingMore:c==="In-Progress"&&a.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",o=e.activeTab==="all",a=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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Ko[e.activeTab];p.trackInvoicingActionClick(g.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(En({action:ai(d),id:c}))},onLoadMore:()=>{if(o)return e.planNextCursor!=null&&t(he({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})));a!=null&&t(i?he({cursor:a,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:a,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function Go(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,m]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),j=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),k=E((_=>G(_))),x=k.planFilters.search,b=k.planSort,I=k.planNextCursor,D=k.productNextCursor,C=k.fetchState==="Completed",L=k.runningActionId??null;return r.useEffect((()=>{const _=setTimeout((()=>v(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&t(ze({cacheOverride:!1,planFilters:h,productFilters:j,planSort:S,productSort:S}))}),[i,t,h,j,S]),r.useEffect((()=>{i&&(f!==x||S?.field!==b?.field||S?.dir!==b?.dir)&&t(ze({cacheOverride:!0,planFilters:h,productFilters:j,planSort:S,productSort:S}))}),[x,b,i,t,h,j,f,S]),N(k.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogPage,isReady:C}),s.jsx(Qo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:o,sortState:u,planFilters:h,productFilters:j,sort:S,planNextCursor:I,productNextCursor:D,runningCatalogItemActionId:L,onSearchChange:a,onTabChange:d,onSortChange:m})]})}const zo=O((function(t,e){const n=yn(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,isSubmitting:n.fetchState==="In-Progress",localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponFormCancelled),t(z()),e.navigate(`${n}/discounts`)},onChange:c=>{t(ri({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponSaved,{mode:o}),t(ci({id:i}))}}}))(ft);function Wo(){const t=P(),e=A(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),{fetchState:a,savedCouponId:c}=E((d=>yn(d,n)));return r.useEffect((()=>{o&&n!=null&&t(si({id:n}))}),[o,n,t]),r.useEffect((()=>{if(a==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(z())}}),[a,c,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCouponFormPage}),s.jsx(zo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Yo=O((function(t){const e=xn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:o=>{e(jn(o))},onSubmit:()=>{const o=ui(t.localData);p.trackInvoicingActionClick(g.Event.invoicingInvoiceCreated,{customerId:o.customer_id,lineItemCount:o.line_items?.length}),e(gi(o))}}}))(ht);function Jo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),[i]=W(),{areTenantIdsInSync:o}=T(),a=i.get("customerId"),c=E((I=>xn(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=E(bn),m=E((I=>li(I))),S=E(de),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,j=f||h,k=m.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(We()),()=>{t(We())})),[t]);const x=r.useRef(!1);r.useEffect((()=>{x.current||a==null||a===""||l.customerId!==""||(x.current=!0,t(jn({...l,customerId:a})))}),[a,l,t]),r.useEffect((()=>{o&&t(di({cacheOverride:!1}))}),[o,t]);const b=r.useRef(d);return r.useEffect((()=>{const I=b.current;if(b.current=d,I!=="Completed"&&d==="Completed"){const D=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(D)}}),[d,v,e,n]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreateInvoicePage,isReady:k}),j?s.jsx(St,{}):s.jsx(Yo,{navigate:e,tenantEmailDomain:n})]})}const Xo=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=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(Ct);function ea(){const t=P(),e=A(),{credit_note_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((d=>mi(d,n??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&n!=null&&t(vi({id:n}))}),[o,n,t]),N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Xo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:a})]})}const na=O((function(t){const e=Dn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(It);function ta(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,creditNoteListFetchState:k}=E((b=>{const I=Dn(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),Z),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ye({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreditsListPage,isReady:x}),s.jsx(na,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(pi(b)),onSortChange:v})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},ia=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:n.record.invoicingCustomer==null&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),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:o=>{t(Ce({id:i,localData:o}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onOpenAddress:()=>{const o=et(e.tenantEmailDomain??"",Ie,i),a=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:a}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerEdited,{customerId:i}),t(Ce({id:i,localData:o})),t(An({id:i}))},onFetchPaymentLinkEmailPreview:o=>t(yi({cacheOverride:o,customerId:i})),onSendPaymentLink:(o,a,c)=>t(ki({body:c,customerId:i,email:o,subject:a})),onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)}}}))(yt);function oa(){const t=P(),e=A(),n=Y(),{customer_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),c=E((L=>Ae(L,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[m,S]=r.useState(!1),{plaidTokenFetchState:f,promotionalCreditSubmitState:h}=c,{paymentMethodSaveState:j,setupIntentFetchState:k,stripeConnected:x}=c.record,b=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const L=c.record.sendLinkState.fetchState;b.current!=="Error"&&L==="Error"&&t(Si({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),b.current=L}),[t,c.record.sendLinkState.fetchState]);const I=k.fetchState==="Error"?k.error?.message??"Failed to start card setup.":j.fetchState==="Error"?j.error?.message??"Failed to save payment method.":f.fetchState==="Error"?f.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(ee()),t(ne()),()=>{t(ee()),t(ne())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{a&&i!=null&&t(hi({id:i}))}),[a,i,t]),r.useEffect((()=>{a&&i!=null&&x&&t(Je({customerId:i}))}),[a,i,t,x]);const[D,C]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(t(Le()),i!=null&&t(Pn({id:i})),C((L=>L+1)))}),[c.fetchState,t,i]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ia,{customerId:i??"",editView:c,location:n,navigate:e,tenantEmailDomain:o,onAddPaymentMethod:()=>{t(ee()),i!=null&&x&&t(Je({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),S(!0)}},D),s.jsx(Et,{errorMessage:I,isCreatingSetupIntent:k.fetchState==="In-Progress",isSaving:j.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:j.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:x,onChooseCard:()=>{i!=null&&t(Ii({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:L=>{i!=null&&t(Ci({customerId:i,data:L}))}}),s.jsx(kt,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:h.fetchState==="Error"?h.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:h.fetchState==="In-Progress",open:m,submitSucceeded:h.fetchState==="Completed",onClose:()=>{S(!1),t(ne())},onSubmit:({amount:L,description:_})=>{i!=null&&t(Ei({amount:L,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:_}))}})]})}const aa=O((function(t,e){const n=Ae(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",localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerFormCancelled),t(Le()),t($e(Ie)),e.navigate(`${n}/customers`)},onChange:c=>{t(Ce({id:i,localData:c}))},onOpenAddress:()=>{const c=et(e.tenantEmailDomain??"",Ie,i),d=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerSaved,{mode:o}),t(An({id:i}))}}}))(xt);function sa(){const t=P(),e=A(),n=Y(),{customer_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),{fetchState:c,savedCustomerId:d}=E((l=>Ae(l,i)));return r.useEffect((()=>{a&&i!=null&&t(Pn({id:i}))}),[a,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${o}/invoicing/customers/${encodeURIComponent(l)}`:`/${o}/invoicing/customers`;e(v),t(Le())}}),[c,d,i,t,e,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomerFormPage}),s.jsx(aa,{customerId:i,location:n,navigate:e,tenantEmailDomain:o})]})}const ca=O((function(t){const e=de(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,o)=>{switch(o){case"createInvoice":e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&t(we({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function ra(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,customerListFetchState:k}=E((b=>{const I=de(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),Z),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomersListPage,isReady:x}),s.jsx(ca,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(xi(b)),onSortChange:v})]})}const xe=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),la=O((function(t,e){const{filters:n,sessionId:i,view:o}=e,a=i==null?void 0:o.diagnosticsBySession[i],c=a?.fetch.fetchState??"Not-Started";return{diagnostics:a?.items??[],errorMessage:c==="Error"?a?.fetch.error?.message:void 0,expired:a?.expired??!1,filters:n,hasMore:a?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(a?.items.length??0)>0,session:xe(o,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:o,sessionId:a,tenantEmailDomain:c,view:d}=e,l=a==null?void 0:d.diagnosticsBySession[a],v=xe(d,a),u=d.actionStateByKind.retry?.fetchState==="In-Progress",m=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!m;return{onBack:()=>o(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&l?.nextCursor!=null&&t(ke({...i,cursor:l.nextCursor,sessionId:a}))},onRetry:v?.status!=="failed"||u?void 0:()=>{a!=null&&t(Te(a))},onRollback:S?()=>{a!=null&&t(Ln(a))}:void 0}}))(jt);function da(){const t=P(),e=A(),{sessionId:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),[a,c]=r.useState({}),d=E(Fe),l=xe(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{o&&n!=null&&t(Ee(n))}),[o,t,n]),r.useEffect((()=>{if(!o||n==null)return;const f=setTimeout((()=>{t(ke({...a,sessionId:n}))}),300);return()=>clearTimeout(f)}),[o,t,a,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!o||n==null||!u)return;const f=setInterval((()=>{t(Ee(n)),t(ke({...a,sessionId:n}))}),3e3);return()=>clearInterval(f)}),[o,t,a,u,n]);const m=r.useMemo((()=>{if(n==null)return;const f=new URLSearchParams;a.moduleId!=null&&f.set("module_id",a.moduleId),a.level!=null&&f.set("level",a.level),a.outcome!=null&&f.set("outcome",a.outcome),a.search!=null&&a.search.trim()!==""&&f.set("search",a.search.trim());const h=f.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[a,n]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(la,{downloadUrl:m,filters:a,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const nt=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=nt(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ua=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:o,statusRows:a}=e.view;return{isLoading:!(o.fetchState!=="Not-Started"&&o.fetchState!=="In-Progress"||a.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:a}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,o=a=>{const c=a??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"continue",sessionId:a}),o(a)},onNewImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingNewImportClicked),o()},onRetrySession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"retry",sessionId:a}),t(Te(a)),o(a)},onRollbackSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"rollback",sessionId:a}),t(Ln(a))},onViewSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"view_details",sessionId:a}),n(`/${i}/invoicing/data_import/${encodeURIComponent(a)}`)}}}))(Dt);function ga(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),o=E(Fe);r.useEffect((()=>{i&&(t(bi()),t($n()))}),[i,t]);const a=o.statusFetch.fetchState==="Completed"&&o.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportHubPage,isReady:a}),s.jsx(ua,{navigate:e,tenantEmailDomain:n,view:o})]})}const ma=O((function(t,e){const{activeId:n,integrationsView:i,settings:o,view:a}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=a,v=i.externalConnections?.revenue?.find((m=>m.connectionName==="chargebee")),u=n!=null?d[n]:void 0;return{chargebeeConnected:o?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:o?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((m=>m.id===n)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:o}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportTemplatesDownloaded);const a=ae?.invoicingMicroServiceBaseUrl,c=a!=null&&a.length>0?a:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(g.Event.invoicingChargebeeConnectClicked),t(Pi())},onGoToIntegrations:()=>{i(`/${o}/invoicing/settings`)},onGoToOverview:()=>i(`/${o}/invoicing/overview`),onRetry:()=>{n!=null&&t(Te(n))},onSaveLater:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportStarted),n!=null&&t(Di(n))},onUpload:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportFileUploaded),t(ji({files:a}))},onViewDetails:n==null?void 0:()=>i(`/${o}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(Pt);function va(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),o=E(bn),a=E(Re).companyId??Se.getSignedInUserTenant(n??"")?.companyId,c=E((f=>wn(f,a))),d=E(Fe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(t(Oe()),t($n()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(nt(h))}catch{return null}})(n);f!=null&&t(ie(f))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const m=u?.status,S=m==="scanning"||m==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{t(Ee(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,t]),r.useEffect((()=>{m==="done"&&(t(ie(null)),oe(n,null))}),[t,m,n]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportMigratePage}),s.jsx(ma,{activeId:v,integrationsView:c,navigate:e,settings:o,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const pa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:n.coupon==null&&(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:o=>{t(Fn({action:o,id:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCouponEdited,{couponId:i}),t(Li({data:o,id:i}))}}}))(At);function fa(){const t=P(),e=A(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((m=>Ai(m,n))),c=a.actionState.fetchState==="In-Progress",d=a.pageFetchState.fetchState,l=d==="Completed";r.useEffect((()=>(t(z()),()=>{t(z())})),[t]),r.useEffect((()=>{o&&t(en({id:n}))}),[o,n,t]);const[v,u]=r.useState(0);return r.useEffect((()=>{a.fetchState==="Completed"&&(t(z()),t(en({cacheOverride:!0,id:n})),u((m=>m+1)))}),[a.fetchState,t,n]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(pa,{couponId:n??"",discountLifecycleActionOptions:a.discountLifecycleActionOptions,editView:a,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},v)]})}const Sa=O((function(t){const e=Tn(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=>{p.trackInvoicingActionClick(g.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,o)=>{t(Fn({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Rn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Lt);function ha(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,couponListFetchState:k,runningDiscountActionId:x}=E((I=>{const D=Tn(I);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:D.sort,nextCursor:D.nextCursor,couponListFetchState:D.fetchState,runningDiscountActionId:D.runningActionId??null}}),Z),b=k==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(o)),300);return()=>clearTimeout(I)}),[o]),r.useEffect((()=>{i&&t(nn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(nn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDiscountsListPage,isReady:b}),s.jsx(Sa,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningDiscountActionId:x,onSearchChange:a,onStatusChange:I=>t($i(I)),onSortChange:v})]})}const Ca=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"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,o=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:a=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCancel:o?()=>t(H({action:"cancel",id:i})):void 0,onResolve:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(H({action:"resolve",id:i}))}:void 0,onResume:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(H({action:"resume",id:i}))}:void 0,onRetry:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(H({action:"retry",id:i}))}:void 0}}))(wt);function Ia(){const t=P(),e=A(),{case_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((C=>wi(C,n??""))),c=a.fetchState==="Completed",d=a.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,m]=r.useState(!1),[S,f]=r.useState(),[h,j]=r.useState(!1),k=r.useCallback((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[]),x=r.useCallback((()=>{if(n==null)return;t(Fi({id:n})),v("idle"),m(!1);const C=a.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),j(!0)}),[n,t,a.emailPreview.preview]),b=r.useCallback((C=>{n!=null&&l!=="pending"&&(m(!1),v("pending"),p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(H({action:"send-email",body:C,id:n})))}),[n,t,l]),I=r.useMemo((()=>a.emailPreview.preview==null?void 0:{bodyToken:a.emailPreview.preview.bodyToken,renderedHtmlTemplate:a.emailPreview.preview.renderedHtmlTemplate,subjectToken:a.emailPreview.preview.subjectToken}),[a.emailPreview.preview]);r.useEffect((()=>{o&&n!=null&&t(Ti({id:n}))}),[o,n,t]),r.useEffect((()=>{o&&d!=null&&t(_e({invoiceId:d}))}),[o,d,t]),r.useEffect((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[n]),r.useEffect((()=>{o||(v("idle"),m(!1),f(void 0),j(!1))}),[o]),r.useEffect((()=>{h&&S==null&&a.emailPreview.preview!=null&&f({body:a.emailPreview.preview.body,cc:a.emailPreview.preview.cc,subject:a.emailPreview.preview.subject,to:a.emailPreview.preview.to})}),[a.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(a.actionState.fetchState!=="In-Progress"?u&&a.actionState.fetchState==="Completed"?(n!=null&&t(Ri({id:n})),k()):u&&a.actionState.fetchState==="Error"&&v("failed"):m(!0))}),[n,k,t,l,u,a.actionState.fetchState]);const D=d!=null&&a.linkedInvoice?.id===d?a.linkedInvoice.dunningAttempts:void 0;return N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:a,dunningAttempts:D,onSendEmail:x}),s.jsx($t,{initialDraft:S,isPreviewLoading:a.emailPreview.fetchState==="Not-Started"||a.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:k,onSend:b,open:h,preview:I,previewErrorMessage:a.emailPreview.fetchState==="Error"?a.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?a.actionState.error?.message:void 0})]})}const Ea=O((function(t){const e=On(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,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:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||t(H({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(_i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ft);function ka(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,dunningCaseListFetchState:k}=E((b=>{const I=On(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),Z),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(tn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDunningListPage,isReady:x}),s.jsx(Ea,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(Oi(b)),onSortChange:v})]})}const ya=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:n.invoice==null&&(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;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceEdited,{invoiceId:i}),t(Ni({data:{due_date:o.due_date!==""?o.due_date:void 0,notes:o.notes.trim()!==""?o.notes.split(`
|
|
1
|
+
import{j as s}from"./liveblocks-BhGApeF9.js";import{a as r}from"./sentry-B98sAG37.js";import{u as P,h as A,i as F,j as E,t as W,l as O,s as Z,g as Y,N as B,n as te,o as y}from"./core-C5rVvNoh.js";import{a6 as lt,h as p,ao as T,Q as g,c9 as dt,ca as ut,cb as gt,cc as mt,cd as vt,ce as pt,cf as ft,cg as St,ch as ht,ci as Ct,cj as It,ck as Et,cl as kt,cm as yt,p as J,cn as xt,co as bt,ac as ae,cp as jt,cq as Dt,z as Se,cr as Pt,cs as At,ct as Lt,cu as $t,cv as wt,cw as Ft,cx as Tt,cy as Rt,V as Ot,ag as Sn,cz as _t,cA as Mt,cB as Nt,cC as Ut,cD as Bt,cE as Vt,cF as Zt,cG as Ht,cH as qt,t as Ke,g as hn,cI as Kt,cJ as Qt,cK as Gt,cL as zt,cM as Wt,cN as Yt,cO as Jt}from"./index-BTTzX8oM.js";import"./mui-AVx3Hg0F.js";import{A as K}from"./AddressScreen-Dyq7f1j-.js";import M from"./NotFoundScreen-C_nzijM_.js";import{YY as Xt,YZ as ei,uM as Qe,Y_ as je,Y$ as Q,vQ as Ge,vX as ni,w0 as Cn,Z0 as De,Z1 as In,vU as En,Z2 as Pe,vS as kn,yw as ti,vT as ii,Z3 as G,vd as se,vM as oi,xn as ze,vc as he,Z4 as ai,Z5 as yn,w7 as si,Z6 as z,we as ci,Z7 as ri,Z8 as xn,Z9 as bn,yi as li,Za as de,Zb as We,Zc as jn,va as di,Zd as ui,v4 as gi,Ze as mi,xA as vi,Zf as Dn,xJ as Ye,Zg as pi,xG as fi,Zh as Ae,gd as Si,Zi as ee,Zj as ne,wt as hi,vi as Je,Zk as Le,vn as Pn,vl as Ci,vf as Ii,wm as Ei,vp as ki,wv as yi,Zl as Ce,wC as An,wA as Ie,Fm as $e,xP as Xe,Zm as xi,vb as we,Zn as Fe,vy as Ee,vv as ke,vI as Ln,vH as Te,vs as bi,vB as $n,vK as ie,fB as Re,UL as wn,ve as Oe,vF as ji,vG as Di,vE as Pi,Zo as Ai,wa as en,wf as Li,wb as Fn,Zp as Tn,u_ as nn,Zq as $i,uW as Rn,Zr as wi,xV as Fi,xZ as H,xU as Ti,x1 as _e,Zs as Ri,Zt as On,y6 as tn,Zu as Oi,y3 as _i,Zv as _n,x4 as Mi,x5 as V,x8 as Ni,Zw as Mn,xi as me,Zx as Ui,wu as Nn,Tj as Un,Zy as Bi,xs as Vi,Zz as Bn,ZA as Zi,ZB as Hi,ZC as qi,yX as Ki,ZD as Qi,ZE as Vn,yd as Zn,ZF as Hn,yV as ve,ZG as Gi,yS as zi,ZH as Wi,ZI as Yi,ZJ as Ji,ZK as Xi,ZL as eo,ZM as on,ZN as no,y$ as to,ZO as Me,wM as an,ZP as Ne,ZQ as ce,wW as qn,wR as Kn,wP as ye,ZR as io,wH as oo,yj as Qn,yK as sn,yF as ao,ZS as so,yk as co,ZT as ro,yL as lo,yP as uo,ZU as go,ZV as Gn,c7 as mo,mo as vo,mp as po,ZW as cn,vR as re,gh as fo,uc as So,mv as ho,yC as zn,zb as Co,yz as Wn,ui as Io,z8 as rn,u6 as Eo,z5 as ln,hP as ko,TL as dn,TM as yo,Fy as Yn,hH as xo,ZX as bo,UA as jo,ZY as Do,zh as pe,zi as Po,ZZ as Ao,Z_ as Jn,ze as Lo,Z$ as $o,_0 as wo,xw as Fo,_1 as To}from"./zeni-epic-state-BVExw1ei.js";import{M as Ro}from"./MobileAppDrawer-DigqZbbY.js";import{q as le}from"./QBOConnectionScreen-ByKxBz2v.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";import"./InboxNotificationsProvider-MlM0K3gF.js";import"./useTaskManagerAccess-vcnpqvQT.js";import"./empty-BTHEbwNZ.js";import"./pdf-lib-u-Ml-CIk.js";import"./index-DMhoHJcD.js";import"./url-RaJlDbzw.js";import"./index-CGyxP256.js";import"./decodeURIComponentSafe-ChlmY296.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]="b12010f2-2ce3-4fda-a998-c12e113cf413",t._sentryDebugIdIdentifier="sentry-dbid-b12010f2-2ce3-4fda-a998-c12e113cf413")}catch{}})();const w=({event:t,isReady:e=!0})=>e?s.jsx(lt,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Oo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:k}=E(Xt),x=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),b=`/${n??""}/invoicing`,I=r.useCallback(((_,R)=>{const U=ei(b,_,R,j);U!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{entity:_,entityId:R,fromScreen:"audit_log"}),e(U))}),[j,e,b]);r.useEffect((()=>{const _=setTimeout((()=>d(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&t(Qe({filters:x,keepExistingListItems:!1,sort:u}))}),[i,x,u,t]);const D=m==="Not-Started"||m==="In-Progress"&&f.length===0,C=m==="In-Progress"&&f.length>0,L=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingAuditLogPage,isReady:L}),s.jsx(dt,{auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:k,entries:f,hasMore:S,isLoading:D,isLoadingMore:C,searchValue:o,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&t(Qe({cursor:h,filters:x,keepExistingListItems:!0,sort:u}))},onSearchChange:a,onSortChange:v})]})}const _o=new Set(["plan"]),Xn=[],Mo=In((t=>t.length>0?t:Xn),mt),No=In((t=>t.length>0?t:Xn),gt),Uo=O((function(t,e){const{view:n}=e;return{groupedAccountOptions:Mo(n.qboAccountHierarchy),groupedClassOptions:No(n.qboClassHierarchy),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!==""?o=>{i!==""&&t(En({action:o,id:i}))}:void 0,onEditChange:o=>{i!==""&&t(De({id:i,localData:o}))},onSaveEdit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemEdited,{itemId:i}),t(Cn({id:i}))},onSubFamilyLifecycleAction:(o,a)=>{i!==""&&t(ni({action:a,id:o,parentItemId:i}))}}}))(ut);function Bo(){const t=P(),e=A(),{item_id:n,tenantEmailDomain:i}=F(),[o]=W(),{areTenantIdsInSync:a}=T(),c=(d=o.get("kind"))!=null&&_o.has(d)?d:"plan";var d;const l=E((k=>je(k,n))),{pageFetchState:v,plan:u}=l,m=v.fetchState;r.useEffect((()=>(t(Q()),()=>{t(Q())})),[t]),r.useEffect((()=>{a&&t(Ge({id:n,kind:c}))}),[a,n,c,t]);const[S,f]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(t(Q()),t(Ge({cacheOverride:!0,id:n,kind:c})),f((k=>k+1)))}),[l.fetchState,t,n,c]);const h=u==null&&(m==="Not-Started"||m==="In-Progress"),j=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogItemDetailPage,isReady:j}),s.jsx(Uo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:h,view:l},S)]})}function Ue(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:o=!1}=t,a=P(),{areTenantIdsInSync:c}=T(),d=E(Pe),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(o&&v!=="Not-Started"||a(kn()),n&&a(ti()))}),[c,a,e,n,o]),r.useEffect((()=>{e&&c&&l&&i&&a(ii())}),[c,a,e,l,i]),{isQboConnected:l,qboView:d}}function Be(t,e=!1){const n=P(),i=E((c=>G(c).productNextCursor!=null)),o=E((c=>G(c).productNextCursor)),a=E((c=>G(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&a!=="Not-Started"||n(se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&a!=="In-Progress"&&i&&o!=null&&n(se({cursor:o,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,a,i,o])}const Vo=new Set(["addon","charge","plan"]),Zo=new Set(["plan"]),Ho=O((function(t,e){const n=je(t,e.itemId);return{fieldHelp:n.fieldHelp,isQboPickerDataLoading:n.isQboPickerDataLoading,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,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",localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:o}=e,a=o!=null?`${n}/catalog/${encodeURIComponent(o)}`:`${n}/catalog`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemFormCancelled),t(Q()),e.navigate(`${n}/catalog`)},onChange:c=>{t(De({id:o,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemSaved,{mode:i}),t(Cn({id:o}))}}}))(vt);function qo(){const t=P(),e=A(),{item_id:n,tenantEmailDomain:i}=F(),[o]=W(),{areTenantIdsInSync:a}=T(),c=n!=null,d=o.get("type"),l=d!=null&&Vo.has(d)?d:void 0,v=(u=o.get("kind"))!=null&&Zo.has(u)?u:"plan";var u;const m=E((S=>je(S,n)));return Be(a,!0),Ue({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{a&&n!=null&&t(oi({id:n,kind:v}))}),[a,n,v,t]),r.useEffect((()=>{c||l==null||m.localData.catalogType===l||t(De({localData:{...m.localData,catalogType:l}}))}),[c,l,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??n,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),t(Q())}}),[m.fetchState,m.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogItemFormPage}),s.jsx(Ho,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const Ko={addons:"addon",all:"item",charges:"charge",plans:"plan"},Qo=O((function(t,e){const n=G(t),i=e.activeTab==="plans",o=e.activeTab==="all",a=i?n.plans:o?[...n.plans,...n.products]:n.products,c=i||o&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:o&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&a.length===0,isLoadingMore:c==="In-Progress"&&a.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",o=e.activeTab==="all",a=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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Ko[e.activeTab];p.trackInvoicingActionClick(g.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(En({action:ai(d),id:c}))},onLoadMore:()=>{if(o)return e.planNextCursor!=null&&t(he({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})));a!=null&&t(i?he({cursor:a,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:a,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function Go(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,m]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),j=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),k=E((_=>G(_))),x=k.planFilters.search,b=k.planSort,I=k.planNextCursor,D=k.productNextCursor,C=k.fetchState==="Completed",L=k.runningActionId??null;return r.useEffect((()=>{const _=setTimeout((()=>v(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&t(ze({cacheOverride:!1,planFilters:h,productFilters:j,planSort:S,productSort:S}))}),[i,t,h,j,S]),r.useEffect((()=>{i&&(f!==x||S?.field!==b?.field||S?.dir!==b?.dir)&&t(ze({cacheOverride:!0,planFilters:h,productFilters:j,planSort:S,productSort:S}))}),[x,b,i,t,h,j,f,S]),N(k.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogPage,isReady:C}),s.jsx(Qo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:o,sortState:u,planFilters:h,productFilters:j,sort:S,planNextCursor:I,productNextCursor:D,runningCatalogItemActionId:L,onSearchChange:a,onTabChange:d,onSortChange:m})]})}const zo=O((function(t,e){const n=yn(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,isSubmitting:n.fetchState==="In-Progress",localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponFormCancelled),t(z()),e.navigate(`${n}/discounts`)},onChange:c=>{t(ri({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponSaved,{mode:o}),t(ci({id:i}))}}}))(ft);function Wo(){const t=P(),e=A(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),{fetchState:a,savedCouponId:c}=E((d=>yn(d,n)));return r.useEffect((()=>{o&&n!=null&&t(si({id:n}))}),[o,n,t]),r.useEffect((()=>{if(a==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(z())}}),[a,c,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCouponFormPage}),s.jsx(zo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Yo=O((function(t){const e=xn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:o=>{e(jn(o))},onSubmit:()=>{const o=ui(t.localData);p.trackInvoicingActionClick(g.Event.invoicingInvoiceCreated,{customerId:o.customer_id,lineItemCount:o.line_items?.length}),e(gi(o))}}}))(ht);function Jo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),[i]=W(),{areTenantIdsInSync:o}=T(),a=i.get("customerId"),c=E((I=>xn(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=E(bn),m=E((I=>li(I))),S=E(de),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,j=f||h,k=m.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(We()),()=>{t(We())})),[t]);const x=r.useRef(!1);r.useEffect((()=>{x.current||a==null||a===""||l.customerId!==""||(x.current=!0,t(jn({...l,customerId:a})))}),[a,l,t]),r.useEffect((()=>{o&&t(di({cacheOverride:!1}))}),[o,t]);const b=r.useRef(d);return r.useEffect((()=>{const I=b.current;if(b.current=d,I!=="Completed"&&d==="Completed"){const D=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(D)}}),[d,v,e,n]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreateInvoicePage,isReady:k}),j?s.jsx(St,{}):s.jsx(Yo,{navigate:e,tenantEmailDomain:n})]})}const Xo=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=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(Ct);function ea(){const t=P(),e=A(),{credit_note_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((d=>mi(d,n??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&n!=null&&t(vi({id:n}))}),[o,n,t]),N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Xo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:a})]})}const na=O((function(t){const e=Dn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(It);function ta(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,creditNoteListFetchState:k}=E((b=>{const I=Dn(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),Z),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ye({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreditsListPage,isReady:x}),s.jsx(na,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(pi(b)),onSortChange:v})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},ia=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:n.record.invoicingCustomer==null&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),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:o=>{t(Ce({id:i,localData:o}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onOpenAddress:()=>{const o=et(e.tenantEmailDomain??"",Ie,i),a=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:a}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerEdited,{customerId:i}),t(Ce({id:i,localData:o})),t(An({id:i}))},onFetchPaymentLinkEmailPreview:o=>t(yi({cacheOverride:o,customerId:i})),onSendPaymentLink:(o,a,c)=>t(ki({body:c,customerId:i,email:o,subject:a})),onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)}}}))(yt);function oa(){const t=P(),e=A(),n=Y(),{customer_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),c=E((L=>Ae(L,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[m,S]=r.useState(!1),{plaidTokenFetchState:f,promotionalCreditSubmitState:h}=c,{paymentMethodSaveState:j,setupIntentFetchState:k,stripeConnected:x}=c.record,b=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const L=c.record.sendLinkState.fetchState;b.current!=="Error"&&L==="Error"&&t(Si({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),b.current=L}),[t,c.record.sendLinkState.fetchState]);const I=k.fetchState==="Error"?k.error?.message??"Failed to start card setup.":j.fetchState==="Error"?j.error?.message??"Failed to save payment method.":f.fetchState==="Error"?f.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(ee()),t(ne()),()=>{t(ee()),t(ne())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{a&&i!=null&&t(hi({id:i}))}),[a,i,t]),r.useEffect((()=>{a&&i!=null&&x&&t(Je({customerId:i}))}),[a,i,t,x]);const[D,C]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(t(Le()),i!=null&&t(Pn({id:i})),C((L=>L+1)))}),[c.fetchState,t,i]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ia,{customerId:i??"",editView:c,location:n,navigate:e,tenantEmailDomain:o,onAddPaymentMethod:()=>{t(ee()),i!=null&&x&&t(Je({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),S(!0)}},D),s.jsx(Et,{errorMessage:I,isCreatingSetupIntent:k.fetchState==="In-Progress",isSaving:j.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:j.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:x,onChooseCard:()=>{i!=null&&t(Ii({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:L=>{i!=null&&t(Ci({customerId:i,data:L}))}}),s.jsx(kt,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:h.fetchState==="Error"?h.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:h.fetchState==="In-Progress",open:m,submitSucceeded:h.fetchState==="Completed",onClose:()=>{S(!1),t(ne())},onSubmit:({amount:L,description:_})=>{i!=null&&t(Ei({amount:L,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:_}))}})]})}const aa=O((function(t,e){const n=Ae(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",localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerFormCancelled),t(Le()),t($e(Ie)),e.navigate(`${n}/customers`)},onChange:c=>{t(Ce({id:i,localData:c}))},onOpenAddress:()=>{const c=et(e.tenantEmailDomain??"",Ie,i),d=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerSaved,{mode:o}),t(An({id:i}))}}}))(xt);function sa(){const t=P(),e=A(),n=Y(),{customer_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),{fetchState:c,savedCustomerId:d}=E((l=>Ae(l,i)));return r.useEffect((()=>{a&&i!=null&&t(Pn({id:i}))}),[a,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${o}/invoicing/customers/${encodeURIComponent(l)}`:`/${o}/invoicing/customers`;e(v),t(Le())}}),[c,d,i,t,e,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomerFormPage}),s.jsx(aa,{customerId:i,location:n,navigate:e,tenantEmailDomain:o})]})}const ca=O((function(t){const e=de(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,o)=>{switch(o){case"createInvoice":e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&t(we({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function ra(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,customerListFetchState:k}=E((b=>{const I=de(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),Z),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomersListPage,isReady:x}),s.jsx(ca,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(xi(b)),onSortChange:v})]})}const xe=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),la=O((function(t,e){const{filters:n,sessionId:i,view:o}=e,a=i==null?void 0:o.diagnosticsBySession[i],c=a?.fetch.fetchState??"Not-Started";return{diagnostics:a?.items??[],errorMessage:c==="Error"?a?.fetch.error?.message:void 0,expired:a?.expired??!1,filters:n,hasMore:a?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(a?.items.length??0)>0,session:xe(o,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:o,sessionId:a,tenantEmailDomain:c,view:d}=e,l=a==null?void 0:d.diagnosticsBySession[a],v=xe(d,a),u=d.actionStateByKind.retry?.fetchState==="In-Progress",m=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!m;return{onBack:()=>o(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&l?.nextCursor!=null&&t(ke({...i,cursor:l.nextCursor,sessionId:a}))},onRetry:v?.status!=="failed"||u?void 0:()=>{a!=null&&t(Te(a))},onRollback:S?()=>{a!=null&&t(Ln(a))}:void 0}}))(jt);function da(){const t=P(),e=A(),{sessionId:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),[a,c]=r.useState({}),d=E(Fe),l=xe(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{o&&n!=null&&t(Ee(n))}),[o,t,n]),r.useEffect((()=>{if(!o||n==null)return;const f=setTimeout((()=>{t(ke({...a,sessionId:n}))}),300);return()=>clearTimeout(f)}),[o,t,a,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!o||n==null||!u)return;const f=setInterval((()=>{t(Ee(n)),t(ke({...a,sessionId:n}))}),3e3);return()=>clearInterval(f)}),[o,t,a,u,n]);const m=r.useMemo((()=>{if(n==null)return;const f=new URLSearchParams;a.moduleId!=null&&f.set("module_id",a.moduleId),a.level!=null&&f.set("level",a.level),a.outcome!=null&&f.set("outcome",a.outcome),a.search!=null&&a.search.trim()!==""&&f.set("search",a.search.trim());const h=f.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[a,n]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(la,{downloadUrl:m,filters:a,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const nt=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=nt(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ua=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:o,statusRows:a}=e.view;return{isLoading:!(o.fetchState!=="Not-Started"&&o.fetchState!=="In-Progress"||a.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:a}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,o=a=>{const c=a??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"continue",sessionId:a}),o(a)},onNewImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingNewImportClicked),o()},onRetrySession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"retry",sessionId:a}),t(Te(a)),o(a)},onRollbackSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"rollback",sessionId:a}),t(Ln(a))},onViewSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"view_details",sessionId:a}),n(`/${i}/invoicing/data_import/${encodeURIComponent(a)}`)}}}))(Dt);function ga(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),o=E(Fe);r.useEffect((()=>{i&&(t(bi()),t($n()))}),[i,t]);const a=o.statusFetch.fetchState==="Completed"&&o.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportHubPage,isReady:a}),s.jsx(ua,{navigate:e,tenantEmailDomain:n,view:o})]})}const ma=O((function(t,e){const{activeId:n,integrationsView:i,settings:o,view:a}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=a,v=i.externalConnections?.revenue?.find((m=>m.connectionName==="chargebee")),u=n!=null?d[n]:void 0;return{chargebeeConnected:o?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:o?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((m=>m.id===n)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:o}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportTemplatesDownloaded);const a=ae?.invoicingMicroServiceBaseUrl,c=a!=null&&a.length>0?a:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(g.Event.invoicingChargebeeConnectClicked),t(Pi())},onGoToIntegrations:()=>{i(`/${o}/invoicing/settings`)},onGoToOverview:()=>i(`/${o}/invoicing/overview`),onRetry:()=>{n!=null&&t(Te(n))},onSaveLater:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportStarted),n!=null&&t(Di(n))},onUpload:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportFileUploaded),t(ji({files:a}))},onViewDetails:n==null?void 0:()=>i(`/${o}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(Pt);function va(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),o=E(bn),a=E(Re).companyId??Se.getSignedInUserTenant(n??"")?.companyId,c=E((f=>wn(f,a))),d=E(Fe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(t(Oe()),t($n()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(nt(h))}catch{return null}})(n);f!=null&&t(ie(f))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const m=u?.status,S=m==="scanning"||m==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{t(Ee(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,t]),r.useEffect((()=>{m==="done"&&(t(ie(null)),oe(n,null))}),[t,m,n]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportMigratePage}),s.jsx(ma,{activeId:v,integrationsView:c,navigate:e,settings:o,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const pa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:n.coupon==null&&(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:o=>{t(Fn({action:o,id:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCouponEdited,{couponId:i}),t(Li({data:o,id:i}))}}}))(At);function fa(){const t=P(),e=A(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((m=>Ai(m,n))),c=a.actionState.fetchState==="In-Progress",d=a.pageFetchState.fetchState,l=d==="Completed";r.useEffect((()=>(t(z()),()=>{t(z())})),[t]),r.useEffect((()=>{o&&t(en({id:n}))}),[o,n,t]);const[v,u]=r.useState(0);return r.useEffect((()=>{a.fetchState==="Completed"&&(t(z()),t(en({cacheOverride:!0,id:n})),u((m=>m+1)))}),[a.fetchState,t,n]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(pa,{couponId:n??"",discountLifecycleActionOptions:a.discountLifecycleActionOptions,editView:a,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},v)]})}const Sa=O((function(t){const e=Tn(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=>{p.trackInvoicingActionClick(g.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,o)=>{t(Fn({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Rn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Lt);function ha(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,couponListFetchState:k,runningDiscountActionId:x}=E((I=>{const D=Tn(I);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:D.sort,nextCursor:D.nextCursor,couponListFetchState:D.fetchState,runningDiscountActionId:D.runningActionId??null}}),Z),b=k==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(o)),300);return()=>clearTimeout(I)}),[o]),r.useEffect((()=>{i&&t(nn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(nn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDiscountsListPage,isReady:b}),s.jsx(Sa,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningDiscountActionId:x,onSearchChange:a,onStatusChange:I=>t($i(I)),onSortChange:v})]})}const Ca=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"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,o=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:a=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCancel:o?()=>t(H({action:"cancel",id:i})):void 0,onResolve:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(H({action:"resolve",id:i}))}:void 0,onResume:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(H({action:"resume",id:i}))}:void 0,onRetry:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(H({action:"retry",id:i}))}:void 0}}))(wt);function Ia(){const t=P(),e=A(),{case_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((C=>wi(C,n??""))),c=a.fetchState==="Completed",d=a.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,m]=r.useState(!1),[S,f]=r.useState(),[h,j]=r.useState(!1),k=r.useCallback((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[]),x=r.useCallback((()=>{if(n==null)return;t(Fi({id:n})),v("idle"),m(!1);const C=a.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),j(!0)}),[n,t,a.emailPreview.preview]),b=r.useCallback((C=>{n!=null&&l!=="pending"&&(m(!1),v("pending"),p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(H({action:"send-email",body:C,id:n})))}),[n,t,l]),I=r.useMemo((()=>a.emailPreview.preview==null?void 0:{bodyToken:a.emailPreview.preview.bodyToken,renderedHtmlTemplate:a.emailPreview.preview.renderedHtmlTemplate,subjectToken:a.emailPreview.preview.subjectToken}),[a.emailPreview.preview]);r.useEffect((()=>{o&&n!=null&&t(Ti({id:n}))}),[o,n,t]),r.useEffect((()=>{o&&d!=null&&t(_e({invoiceId:d}))}),[o,d,t]),r.useEffect((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[n]),r.useEffect((()=>{o||(v("idle"),m(!1),f(void 0),j(!1))}),[o]),r.useEffect((()=>{h&&S==null&&a.emailPreview.preview!=null&&f({body:a.emailPreview.preview.body,cc:a.emailPreview.preview.cc,subject:a.emailPreview.preview.subject,to:a.emailPreview.preview.to})}),[a.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(a.actionState.fetchState!=="In-Progress"?u&&a.actionState.fetchState==="Completed"?(n!=null&&t(Ri({id:n})),k()):u&&a.actionState.fetchState==="Error"&&v("failed"):m(!0))}),[n,k,t,l,u,a.actionState.fetchState]);const D=d!=null&&a.linkedInvoice?.id===d?a.linkedInvoice.dunningAttempts:void 0;return N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:a,dunningAttempts:D,onSendEmail:x}),s.jsx($t,{initialDraft:S,isPreviewLoading:a.emailPreview.fetchState==="Not-Started"||a.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:k,onSend:b,open:h,preview:I,previewErrorMessage:a.emailPreview.fetchState==="Error"?a.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?a.actionState.error?.message:void 0})]})}const Ea=O((function(t){const e=On(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,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:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||t(H({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(_i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ft);function ka(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,dunningCaseListFetchState:k}=E((b=>{const I=On(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),Z),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(tn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDunningListPage,isReady:x}),s.jsx(Ea,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(Oi(b)),onSortChange:v})]})}const ya=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:n.invoice==null&&(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;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceEdited,{invoiceId:i}),t(Ni({data:{due_date:o.due_date!==""?o.due_date:void 0,notes:o.notes.trim()!==""?o.notes.split(`
|
|
2
2
|
`).map((a=>a.trim())).filter((a=>a!=="")).map((a=>({note:a}))):void 0,po_number:o.po_number!==""?o.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceReminderSent,{invoiceId:i}),t(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onVoid:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:o}))}}}))(Tt);function xa(){const t=P(),e=A(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((l=>_n(l,n??""))),c=a.pageFetchState.fetchState,d=c==="Completed";return r.useEffect((()=>{o&&n!=null&&t(Mi({invoiceId:n}))}),[o,n,t]),N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(ya,{invoiceId:n??"",navigate:e,tenantEmailDomain:i,view:a})]})}const ba=O((function(t){const e=Mn(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`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{switch(o){case"recordPayment":e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":t(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":t(V({action:"regenerate",invoiceId:i}));break;case"void":t(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,o)=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&t(Nn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Rt);function ja(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,invoiceListFetchState:k,voidingInvoiceId:x}=E((I=>{const D=Mn(I);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:I.invoicingInvoiceListState.sort,nextCursor:D.nextCursor,invoiceListFetchState:D.fetchState,voidingInvoiceId:D.runningActionId}}),Z),b=k==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(o)),300);return()=>clearTimeout(I)}),[o]),r.useEffect((()=>{i&&t(me({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(me({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingInvoicesListPage,isReady:b}),s.jsx(ba,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,voidingInvoiceId:x,onSearchChange:a,onStatusChange:I=>{t(Ui(I)),t(me({cacheOverride:!1,filters:m,sort:u}))},onSortChange:v})]})}function un(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),i=Ot(),o=Sn(),[a,c]=r.useState(!1),{acceptTermsState:d,status:l}=E(Un),v=Bi(i?.loggedInUserRoleMap),u=`/${n}/invoicing`,m=S=>{c(S)};return l==="completed"?s.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?s.jsx(B,{to:`${u}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(Ro,{isAppContentDrawerOpen:a,handleDrawerToggle:m}),s.jsx(_t,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:o("invoicing_promo"),onAcceptClick:()=>{t(Vi())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{m(!0)}})]})}const Da=O((function(t,e){const n=Bn(t,e.invoiceId),{invoice:i,localData:o,reasonCodeOptions:a,submitState:c,typeOptions:d}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:o,reasonCodeOptions:a,typeOptions:d}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:o=>{t(Qi({localData:o}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Ki())}}}))(Mt);function Pa(){const t=P(),e=A(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),{fetchState:a,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=E((f=>Bn(f,n??""))),u=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>{t(Zi()),m.current=null}),[t,n]),r.useEffect((()=>{o&&n!=null&&t(_e({invoiceId:n}))}),[o,t,n]),r.useEffect((()=>{c!=null&&n!=null&&a==="Completed"&&m.current!==n&&(m.current=n,t(Hi({localData:qi(c)})))}),[t,a,c,n]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Da,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Aa=O((function(t){return{invoicingOverview:Vn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{t(Zn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(g.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(g.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(Nt);function La(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),a=E((c=>Vn(c).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Zn(o))}),[i,t,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingOverviewPage,isReady:a}),s.jsx(Aa,{navigate:e,selectedPeriod:o,tenantEmailDomain:n})]})}const $a=O((function(t){const e=Hn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(zi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ut);function wa(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:h,nextCursor:j,transactionListFetchState:k,transactions:x}=E((L=>{const _=Hn(L);return{activeType:_.activeTab,appliedSearch:_.filters.search,appliedSort:_.sort,nextCursor:_.nextCursor,transactionListFetchState:_.fetchState,transactions:_.transactions}}),Z),b=k==="Completed",I=`/${n}/invoicing`,D=r.useCallback((L=>{const _=x.find((U=>U.id===L)),R=_?.linkedInvoices?.[0]?.invoiceID??_?.invoiceID;R!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:R,toScreen:"invoice"}),e(`${I}/invoices/${encodeURIComponent(R)}`))}),[e,I,x]),C=r.useCallback((L=>{const _=x.find((R=>R.id===L))?.customerID;_!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:_,fromScreen:"payments_list",toScreen:"customer"}),e(`${I}/customers/${encodeURIComponent(_)}`))}),[e,I,x]);return r.useEffect((()=>{const L=setTimeout((()=>d(o)),300);return()=>clearTimeout(L)}),[o]),r.useEffect((()=>{i&&t(ve({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(ve({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingPaymentsListPage,isReady:b}),s.jsx($a,{navigate:e,tenantEmailDomain:n,activeType:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onTypeChange:L=>{t(Gi(L)),t(ve({cacheOverride:!1,filters:m,sort:u}))},onSortChange:v,onViewTransactionCustomer:C,onViewTransactionInvoice:D})]})}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},gn=(t,e)=>new Intl.NumberFormat("en-US",{currency:e,style:"currency"}).format(t);function mn(){const t=P(),e=A(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=n!=null&&n!=="",c=E(de),d=E((C=>Wi(C))),l=E(Yi),v=E((C=>_n(C,n??""))),u=v.invoice,m=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Ji()),S.current=null,f.current=""}),[t,n]),r.useEffect((()=>{o&&t(a&&n!=null?_e({invoiceId:n}):we({filters:{},keepExistingListItems:!1}))}),[o,t,n,a]),r.useEffect((()=>{a&&u!=null&&n!=null&&v.fetchState==="Completed"&&S.current!==n&&(S.current=n,t(Xi({contextInvoiceId:n,localData:eo(u)})))}),[t,u,n,v.fetchState,a]),r.useEffect((()=>{if(a)return;const C=d.localData.customerId;C!==""&&C!==f.current&&(f.current=C,t(Nn({filters:{customerId:C},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&t(on({localData:{...d.localData,customerId:C,invoiceToLink:""}})))}),[t,d.localData,a]);const h=r.useRef(l.fetchState);r.useEffect((()=>{const C=h.current;if(h.current=l.fetchState,C!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,m]);const j=r.useMemo((()=>c.customers.map((C=>({id:C.id,name:Fa(C)})))),[c.customers]),k=E((C=>no(C,d.localData.customerId))),x=r.useMemo((()=>k.map((C=>({amountDue:gn(C.amountDue,"USD"),amountDueValue:C.amountDue,id:C.id,label:C.invoiceNumber})))),[k]),b=r.useMemo((()=>{if(!a||u==null)return;const C=u.currencyCode??"USD",L=u.amountDue?.amount??0;return{amountDue:gn(L,C),amountDueValue:L,currencyCode:C,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,a]),I=a?`${m}/invoices/${encodeURIComponent(n??"")}`:`${m}/payments`,D=!a||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingRecordPaymentPage,isReady:D}),s.jsx(Bt,{customers:j,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:b,invoiceOptions:x,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:a?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(I)},onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentCancelled),e(I)},onChange:C=>{t(on({localData:C}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:a?n:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),t(to(a?n??void 0:void 0))}})]})}const tt=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Ta=(t,e)=>{if(t==null)return;const n=new Intl.NumberFormat("en-US",{currency:t.currencyCode??"USD",maximumFractionDigits:0,style:"currency"}).format(t.amount);return e!=null?`${n}/${e}`:n},it=(t,e,n)=>{const i=[t,Ta(e,n)].filter((o=>o!=null&&o!=="")).join(" · ");return i!==""?i:void 0},vn=t=>t.priceCode!=null&&t.priceCode.trim()!=="",Ra=t=>({billingCycles:t.billingCycles,billingPeriod:t.period,billingPeriodUnit:t.periodUnit,label:t.name??t.id,subtitle:it(t.productCode,t.price,t.periodUnit),value:t.priceCode}),Oa=t=>({label:t.name??t.couponCode??t.id,value:t.couponCode??t.id}),_a=O((function(t,e){const{editView:n}=e,i=n.subscription,o=i?.status,a=o!=null&&e.commercialEditAllowedFromStatuses.includes(o);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.products.filter((c=>c.itemType==="addon")).filter(vn).map((c=>({label:c.name??c.id,subtitle:it(c.productCode,c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:a,coupons:n.coupons.map(Oa),isLoading:n.subscription==null&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans.filter(vn).map(Ra),shippingAddressLabel:n.shippingAddressLabel,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=="",a=(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),t(Kn({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:c=>{t(ce({id:i,localData:c}))},onChangeTermEnd:o?c=>{const d=c?.trim()??"";d!==""&&a("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onOpenAddress:()=>{const c=tt(e.tenantEmailDomain??"",ye,i),d=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${n}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionEdited,{subscriptionId:i}),t(ce({id:i,localData:c})),t(qn({id:i}))},onCancelSubscription:o?c=>{a("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:o?(c,d)=>{c!=="pause"?a(c):a(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Vt);function Ma(){const t=P(),e=A(),n=Y(),{subscription_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),c=E((h=>Me(h,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,m=u==="Completed";Be(a),r.useEffect((()=>{a&&i!=null&&t(an({id:i}))}),[a,i,t]);const[S,f]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(t(Ne()),t(an({cacheOverride:!0,id:i})),f((h=>h+1)))}),[c.fetchState,t,i]),N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSubscriptionDetailPage,isReady:m}),s.jsx(_a,{commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:n,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:o},S)]})}const Na=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},Ua=(t,e)=>{if(t==null)return;const n=new Intl.NumberFormat("en-US",{currency:t.currencyCode??"USD",maximumFractionDigits:0,style:"currency"}).format(t.amount);return e!=null?`${n}/${e}`:n},be=(t,e,n)=>{const i=[t,Ua(e,n)].filter((o=>o!=null&&o!=="")).join(" · ");return i!==""?i:void 0},Ba=t=>({label:Na(t),value:t.id}),fe=t=>t.priceCode!=null&&t.priceCode.trim()!=="",Va=t=>({billingCycles:t.billingCycles,billingPeriod:t.period,billingPeriodUnit:t.periodUnit,label:t.name??t.id,subtitle:be(t.productCode,t.price,t.periodUnit),trialPeriod:t.trialPeriod,trialPeriodUnit:t.trialPeriodUnit,value:t.priceCode}),Za=t=>({label:t.name??t.couponCode??t.id,value:t.couponCode??t.id}),Ha=O((function(t,e){const n=Me(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.products.filter((i=>i.itemType==="addon")).filter(fe).map((i=>({label:i.name??i.id,subtitle:be(i.productCode,i.price,i.periodUnit),value:i.priceCode}))),charges:n.products.filter((i=>i.itemType==="charge")).filter(fe).map((i=>({label:i.name??i.id,subtitle:be(i.productCode,i.price,void 0),value:i.priceCode}))),coupons:n.coupons.map(Za),customers:n.customers.map(Ba),errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",localData:n.localData,mode:n.mode,plans:n.plans.filter(fe).map(Va),shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionFormCancelled),t(Ne()),t($e(ye)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{t(ce({id:i,localData:a}))},onOpenAddress:()=>{const a=tt(e.tenantEmailDomain??"",ye,i),c=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionSaved,{mode:o}),t(qn({id:i}))}}}))(Zt);function qa(){const t=P(),e=A(),n=Y(),{subscription_id:i,tenantEmailDomain:o}=F(),[a]=W(),{areTenantIdsInSync:c}=T(),d=a.get("customerId"),{fetchState:l,savedSubscriptionId:v}=E((S=>io(S,i))),u=E((S=>Me(S,i).localData));Be(c),r.useEffect((()=>{c&&(t(we({filters:{},keepExistingListItems:!1})),t(he({filters:{type:"plan"},keepExistingListItems:!1})),t(Rn({filters:{},keepExistingListItems:!1})),i!=null&&t(oo({id:i})))}),[c,i,t]);const m=r.useRef(!1);return r.useEffect((()=>{m.current||i!=null||d==null||d===""||u.customerId!==""||(m.current=!0,t(ce({id:i,localData:{...u,customerId:d}})))}),[d,i,u,t]),r.useEffect((()=>{if(l==="Completed"){const S=v??i,f=S!=null?`/${o}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${o}/invoicing/subscriptions`;e(f),t(Ne())}}),[l,v,i,t,e,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSubscriptionFormPage}),s.jsx(Ha,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:o})]})}const Ka=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=(o,a,c)=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionLifecycleAction,{action:a,subscriptionId:o}),t(Kn({action:a,id:o,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(o,a)=>{const c=a?.trim()??"";c!==""&&i(o,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(o,a,c)=>{a!=="pause"?i(o,a):i(o,a,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(o,a)=>{i(o,"cancel",{cancel_reason_code:a.cancelReasonCode,end_of_term:!1,...a.cancelReason!=null&&a.cancelReason.trim()!==""?{cancel_reason:a.cancelReason.trim()}:{}})},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionRowClicked,{subscriptionId:o}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&t(co({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ht);function Qa(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,subscriptionListFetchState:k,runningActionSubscriptionId:x}=E((D=>{const C=Qn(D);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,subscriptionListFetchState:C.fetchState,runningActionSubscriptionId:C.runningActionId??null}}),Z),b=k==="Completed";r.useEffect((()=>{const D=setTimeout((()=>d(o)),300);return()=>clearTimeout(D)}),[o]),r.useEffect((()=>{i&&t(sn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(sn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]);const I=r.useRef(x);return r.useEffect((()=>{const D=I.current!=null&&x==null;I.current=x,D&&i&&t(ao())}),[x,i,t]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSubscriptionsListPage,isReady:b}),s.jsx(Ka,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningActionSubscriptionId:x,onSearchChange:a,onStatusChange:D=>t(so(D)),onSortChange:v})]})}const Ga=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:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(g.Event.invoicingTransactionCaptured,{transactionId:i}),t(uo({action:"capture",id:i}))}:void 0}}))(qt);function za(){const t=P(),e=A(),{tenantEmailDomain:n,transaction_id:i}=F(),{areTenantIdsInSync:o}=T(),a=E((d=>ro(d,i??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&i!=null&&t(lo({id:i}))}),[o,i,t]),N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Ga,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:a})]})}const Wa={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function X(t){const e=P(),{areTenantIdsInSync:n}=T(),{tenantEmailDomain:i}=F(),{fetchState:o,fieldHelp:a,saveState:c,settings:d,stripeConnectState:l}=E(go),{configError:v,configFetchState:u,dunningScheduleActionOptions:m,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:f,qboSyncStatusOptions:h}=E(Gn),j=E(Pe);Ue({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const k=E(Re),x=t==="dunning"||t==="quickbooks",b=k.companyId??Se.getSignedInUserTenant(i??"")?.companyId,I=E(($=>wn($,b))),D=mo(k.userRole??[]),C=k.tenantId??"",L=Se.getSignedInUser(),_={userId:L?.userId??"",sessionId:L?.zeniSessionId??"",tenantId:C},R=d?.logo_file_id,U=E(($=>R!=null&&R!==""?$.fileState.fileByFileId[R]:void 0)),Ve=E(($=>R!=null&&R!==""?vo($,R):void 0)),Ze=E(($=>R!=null&&R!==""?po($,R):void 0)),ot=R!=null&&R!==""&&Ve!=null?{[R]:Ve}:{},at=R!=null&&R!==""&&Ze!=null?{[R]:Ze}:{};r.useEffect((()=>(e(cn()),()=>{e(cn())})),[e]),r.useEffect((()=>{n&&(o!=="Not-Started"&&o!=="Error"||e(Oe()))}),[n,e,o]),r.useEffect((()=>{n&&x&&u==="Not-Started"&&e(re())}),[n,e,u,x]),r.useEffect((()=>{if(!n)return;const $=L?.userId;$!=null&&$!==""&&C!==""&&Ke.shouldFetchActiveTenant(C)&&(Ke.markActiveTenantFetchStarted(C),e(fo($,C,L?.zeniSessionId)))}),[n,e,L?.userId,L?.zeniSessionId,C]),r.useEffect((()=>{n&&R!=null&&R!==""&&C!==""&&U==null&&e(So(R,C))}),[n,e,U,R,C]);const st=m.length>0||S.length>0,ct=o==="Not-Started"||o==="In-Progress"&&d==null||x&&!st&&(u==="Not-Started"||u==="In-Progress"),rt=o==="Completed"&&(!x||u==="Completed"),He=I.externalConnections?.revenue?.find(($=>$.connectionName==="chargebee"))?.connectionId,ue=ae?.invoicingMicroServiceBaseUrl,qe=ue!=null&&ue.length>0?`${ue}/1.0/webhooks/stripe`:"",ge={deleteConnectionError:I.externalConnections?.deleteConnectionError?.message,deleteConnectionState:I.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:I,isAdmin:D,isStripeBusy:l.fetchState==="In-Progress",onConnectStripe:$=>e(ln($)),onDisconnect:($,q)=>{C!==""&&e(xo(C,$,dn(q)))},onDisconnectStripe:()=>e(rn()),onReconnectQBO:()=>{const $=k.tenantEmailDomain??i??"";le.init("/connection/auth",$),le.handleClick()},onRefreshQBO:()=>{I.integrations.refreshQBO.fetchState!=="In-Progress"&&e(Yn())},onSaveChargeBeeCredentials:($,q)=>{He!=null&&C!==""&&e(ko(C,He,dn("revenue"),yo("chargebee"),{api_key:$,site:q}))},saveChargeBeeError:I.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:I.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:l.fetchState==="Error"?l.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe};return{authParams:_,deleteFileStatusById:ot,fieldHelp:a,dunningScheduleActionOptions:m,filesEndPoint:ae?.fileMicroServiceBaseUrl??"",integrationsSectionProps:ge,isInvoicingPageReady:rt,isLoading:ct,isSaving:c.fetchState==="In-Progress",isStripeBusy:l.fetchState==="In-Progress",logoFile:U,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:f,qboSyncStatusOptions:h,qboView:j,saveErrorMessage:c.fetchState==="Error"?c.error?.message??"Failed to save settings.":x&&u==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:l.fetchState==="Error"?l.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe,updateFileStatusById:at,onConnectStripe:$=>e(ln($)),onDeleteFile:$=>e(Eo($)),onDisconnectStripe:()=>e(rn()),onEditFileName:($,q)=>e(Io($,q)),onReconnectQBO:ge.onReconnectQBO,onRefreshQBO:ge.onRefreshQBO,onRetryQboSyncTask:$=>e(Wn($)),onSave:$=>{p.trackInvoicingActionClick(g.Event.invoicingSettingsSaved,{tab:t??"hub"}),e(Co({settings:$,snackbarSection:Wa[t??""]}))},onStartQboBackfill:$=>e(zn($)),updateFilesEntity:$=>{p.trackInvoicingActionClick(g.Event.invoicingLogoUploaded),e(ho({files:$}))}}}function pn({appContent:t}){const e=A(),n=Y(),i=P(),{tenantEmailDomain:o}=F(),a=X("branding"),c=E((v=>bo(v))),d=E((v=>jo(pe,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(Do()),i($e(pe)))}),[c.saveState.fetchState,i]);const l=hn(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:a.isInvoicingPageReady}),s.jsx(Kt,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:t,authParams:a.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:a.deleteFileStatusById,filesEndPoint:a.filesEndPoint,isLoading:a.isLoading,isSaving:a.isSaving,localData:c.localData,saveErrorMessage:a.saveErrorMessage,settings:a.settings,updateFileStatusById:a.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(Ao({localData:v}))},onDeleteFile:a.onDeleteFile,onEditFileName:a.onEditFileName,onOpenAddress:()=>{const v=`/${o}/invoicing/settings/branding/${pe}/`,u=J(n.state?.pathnameStackToGoBack,n.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Po()),updateFilesEntity:a.updateFilesEntity})]})}function Ya(){const t=A(),e=X("dunning");return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Qt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Ja(){const t=A(),e=X("integrations");return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Gt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Xa(){const t=A(),e=X("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(zt,{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 es=O((function(t){const e=Jn(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,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(wo({localData:e}))},onReset:()=>{t($o())},onRetryTask:e=>{t(Wn(e))},onSave:()=>{p.trackInvoicingActionClick(g.Event.invoicingSettingsSaved,{tab:"quickbooks"}),t(Lo())},onStartBackfill:e=>{t(zn(e))}}}))(Wt);function ns(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),i=E(Re),{configFetchState:o,settingsFetchState:a}=E(Jn);return r.useEffect((()=>{a!=="Not-Started"&&a!=="Error"||t(Oe())}),[t,a]),r.useEffect((()=>{o==="Not-Started"&&t(re())}),[o,t]),Ue({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage}),s.jsx(es,{onBackClick:()=>e(".."),onReconnect:()=>{le.init("/connection/auth",i.tenantEmailDomain??n??""),le.handleClick()},onRefresh:()=>t(Yn())})]})}const ts={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function is(){const t=Sn(),e=P(),n=A(),[i,o]=W(),a=X(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=E(Gn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const S=ts[m];o({},{replace:!0}),S!=null&&n(S,{replace:!0})}),[m,n,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:a.isInvoicingPageReady}),s.jsx(Yt,{analytics:p,integrationsSectionProps:{...a.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:d,isLoading:a.isLoading,meetingUrl:t("invoicing_settings"),settings:a.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Fo())}})]})}function fn(){return s.jsxs(te,{children:[s.jsx(y,{index:!0,element:s.jsx(is,{})}),s.jsx(y,{path:"payment-destination",element:s.jsx(Xa,{})}),s.jsx(y,{path:"branding",element:s.jsx(pn,{})}),s.jsx(y,{path:"branding/:addressType",element:s.jsx(pn,{appContent:s.jsx(K,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(y,{path:"integrations",element:s.jsx(Ja,{})}),s.jsx(y,{path:"dunning",element:s.jsx(Ya,{})}),s.jsx(y,{path:"quickbooks",element:s.jsx(ns,{})}),s.jsx(y,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function $s(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),{enableState:o,fetchState:a,status:c}=E(Un),d=hn(o.fetchState),l=`/${n}/invoicing`,v=r.useRef(!1),u=E((m=>Pe(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(a!=="Not-Started"?a!=="Error"||v.current||(v.current=!0,t(re({cacheOverride:!1}))):t(re({cacheOverride:!1})))}),[i,t,a]),r.useEffect((()=>{i&&u==="Not-Started"&&t(kn())}),[i,t,u]),r.useEffect((()=>{d==="In-Progress"&&o.fetchState==="Completed"&&(e(`${l}/catalog`),t(To()))}),[d,o.fetchState,l,t,e]),c==null&&a!=="Error"?s.jsx(Jt,{}):c==="not_started"?s.jsxs(te,{children:[s.jsx(y,{path:"promo",element:s.jsx(un,{})}),s.jsx(y,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(te,{children:[s.jsx(y,{path:"promo",element:s.jsx(un,{})}),s.jsx(y,{path:"settings/*",element:s.jsx(fn,{})}),s.jsx(y,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(te,{children:[s.jsx(y,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(y,{path:"overview",element:s.jsx(La,{})}),s.jsx(y,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(y,{path:"customers",element:s.jsx(ra,{})}),s.jsx(y,{path:"customers/new",element:s.jsx(sa,{})}),s.jsx(y,{path:"customers/new/:addressType",element:s.jsx(K,{})}),s.jsx(y,{path:"customers/:customer_id",element:s.jsx(oa,{})}),s.jsx(y,{path:"customers/:customer_id/:addressType",element:s.jsx(K,{})}),s.jsx(y,{path:"subscriptions",element:s.jsx(Qa,{})}),s.jsx(y,{path:"subscriptions/new",element:s.jsx(qa,{})}),s.jsx(y,{path:"subscriptions/new/:addressType",element:s.jsx(K,{})}),s.jsx(y,{path:"subscriptions/:subscription_id",element:s.jsx(Ma,{})}),s.jsx(y,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(K,{})}),s.jsx(y,{path:"invoices",element:s.jsx(ja,{})}),s.jsx(y,{path:"invoices/create",element:s.jsx(Jo,{})}),s.jsx(y,{path:"invoices/:invoice_id",element:s.jsx(xa,{})}),s.jsx(y,{path:"invoices/:invoice_id/record-payment",element:s.jsx(mn,{})}),s.jsx(y,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(Pa,{})}),s.jsx(y,{path:"payments",element:s.jsx(wa,{})}),s.jsx(y,{path:"payments/record",element:s.jsx(mn,{})}),s.jsx(y,{path:"payments/:transaction_id",element:s.jsx(za,{})}),s.jsx(y,{path:"credits",element:s.jsx(ta,{})}),s.jsx(y,{path:"credits/:credit_note_id",element:s.jsx(ea,{})}),s.jsx(y,{path:"discounts",element:s.jsx(ha,{})}),s.jsx(y,{path:"discounts/new",element:s.jsx(Wo,{})}),s.jsx(y,{path:"discounts/:coupon_id",element:s.jsx(fa,{})}),s.jsx(y,{path:"dunning",element:s.jsx(ka,{})}),s.jsx(y,{path:"dunning/:case_id",element:s.jsx(Ia,{})}),s.jsx(y,{path:"catalog",element:s.jsx(Go,{})}),s.jsx(y,{path:"catalog/new",element:s.jsx(qo,{})}),s.jsx(y,{path:"catalog/:item_id",element:s.jsx(Bo,{})}),s.jsx(y,{path:"settings/*",element:s.jsx(fn,{})}),s.jsx(y,{path:"audit_log",element:s.jsx(Oo,{})}),s.jsx(y,{path:"data_import",element:s.jsx(ga,{})}),s.jsx(y,{path:"data_import/migrate",element:s.jsx(va,{})}),s.jsx(y,{path:"data_import/:sessionId",element:s.jsx(da,{})}),s.jsx(y,{path:"*",element:s.jsx(M,{})})]})}export{$s as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as a}from"./liveblocks-
|
|
1
|
+
import{j as a}from"./liveblocks-BhGApeF9.js";import{i as S,l as g,h as C,g as y,u as ee,t as ae,j as L,N as te,n as ne,o as p}from"./core-C5rVvNoh.js";import{TE as k,TF as v,TG as F,IM as D,Iy as G,TH as B,TI as oe,TJ as ie,IC as se,ge as j,IJ as le,IG as re}from"./zeni-epic-state-BVExw1ei.js";import{$ as x,H as r,a0 as de,h as I,U as H,a1 as ce,a2 as me,a3 as pe,p as M,O as ue,y as he,a4 as ge,_ as xe,E as fe,e as we,a5 as be,a6 as Se,Y as ye,a7 as ke,a8 as ve,a9 as Ie,aa as je}from"./index-BTTzX8oM.js";import{n as m}from"./mui-AVx3Hg0F.js";import f from"./NotFoundScreen-C_nzijM_.js";import{a as $}from"./sentry-B98sAG37.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b5338576-ad79-4aaa-9e54-6c99a5e894fb",e._sentryDebugIdIdentifier="sentry-dbid-b5338576-ad79-4aaa-9e54-6c99a5e894fb")}catch{}})();const $e=m.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
height: 100%;
|
|
4
4
|
width: 100%;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as g}from"./liveblocks-
|
|
1
|
+
import{j as g}from"./liveblocks-BhGApeF9.js";import{a as u}from"./sentry-B98sAG37.js";import{u as U,g as w,h as _,t as A,j as l,N as L}from"./core-C5rVvNoh.js";import{z as r,E as M,G as P,N as V,h as N,Q as B,X as R,Y as G,S as Q}from"./index-BTTzX8oM.js";import{fB as W,Tb as X,TA as Y,Tr as $,ge as q,gg as H,Tw as J,gR as K,df as Z,TB as ee,TC as te}from"./zeni-epic-state-BVExw1ei.js";import{n as ne}from"./mui-AVx3Hg0F.js";import{u as se}from"./useDeviceId-6INyJgde.js";import{f as ae}from"./analyticsHelper-5kEw8e8E.js";import{t as ie}from"./getLocaleForTenant-DQ9OiUn_.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="08a84dc7-9361-4313-97f3-ebe345ea4448",t._sentryDebugIdIdentifier="sentry-dbid-08a84dc7-9361-4313-97f3-ebe345ea4448")}catch{}})();const C=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Ce(){const t=U(),a=w(),m=_(),[k]=A(),n=k.get("token"),p=k.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:x,magicLinkEmail:c,verifyDeviceFetchState:z,resendVerifyDeviceOTPFetchState:D}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),y=l((e=>e.tenantState.activeTenantFetchState.fetchState)),h=l((e=>e.tenantState.signInState)),I=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),s=l((e=>e.tenantState.loggedInUser)),o=l((e=>W(e))),b=l((e=>X(e))),E=r.getSignedInUser(),T=M().mode;u.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&C(n,p)&&i!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(Y(n,i,f)))}),[n,p,t,i,f,s?.zeniSessionId]),u.useEffect((()=>{h!=="In-Progress"||S!=="Completed"&&y!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants($(b.tenantsInOrder),s.zeniSessionId),q(s.userId,s.zeniSessionId,o.tenantId),t(H(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(J("Completed")),P.updateAppLocaleID(ie(o)),ae(s,o,T,void 0,b.tenantsInOrder),K().then((()=>{const e=Q();e!=null&&V(e)})),setTimeout((()=>{N.trackLogin(B.Event.loginSuccess,"email",Z(o.productSettings))}),2e3))}),[h,S,y,s,o,b,T,a.state,t]);const j=u.useCallback((()=>{m("/signin/auth")}),[m]),F=u.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),O=u.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(te(e,i,c,d))}),[i,n,t,c,d]);if(I==="Completed"&&d!=null)return g.jsx(R,{phoneNumber:x,verifyOtpFetchState:z.fetchState,resendVerifyDeviceOTPFetchState:D,onResendOtp:F,onVerifyOtp:O,onCancelVerifyDevice:j});if(h==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||E!=null){const e=a.state?.origin??"/";return g.jsx(L,{to:e,state:{...a.state,origin:""}})}if(!C(n,p)||f==null||I==="Error"){const e=a.state?.origin??"/",v=n!=null&&r.getLastUsedMagicLinkToken()===n;return g.jsx(L,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:v,magicLinkExpired:!v&&(r.isMagicLinkTriggered(n??"")||I==="Error"&&s?.zeniSessionId==null)}})}return g.jsx(oe,{"data-testid":"smooth-loader",children:g.jsx(G,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as _}from"./liveblocks-
|
|
1
|
+
import{j as _}from"./liveblocks-BhGApeF9.js";import{a as f}from"./sentry-B98sAG37.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as F}from"./core-C5rVvNoh.js";import{fB as ne,Tc as xe,Td as se,g5 as Ne,fA as Pe,Tj as Re,Te as je,Tf as Ve,pX as Oe,gi as Le,Ti as b,Tl as Ue,Tm as K,gj as Ze,Tn as ze,Dr as qe,g_ as He,cS as We,To as Ye,g4 as Xe,gk as Je}from"./zeni-epic-state-BVExw1ei.js";import{w as Ke,i as Qe,_ as ea,O as aa,c as ta,e as na,u as sa,y as c,f as oa,W as ia,z as ra,d as da,j as ca,F as la,n as ua,k as fa,l as Q,L as ma,A as ha,B as ba,p as S,h as ee,q as pa,I as ae,v as ga,x as Sa}from"./index-BTTzX8oM.js";import{D as ka}from"./mui-AVx3Hg0F.js";import{u as Ta}from"./InboxNotificationsProvider-MlM0K3gF.js";import{u as Ea}from"./useTaskManagerAccess-vcnpqvQT.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new l.Error().stack;i&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[i]="222abc58-f96a-47df-9298-a02bc56e2ea9",l._sentryDebugIdIdentifier="sentry-dbid-222abc58-f96a-47df-9298-a02bc56e2ea9")}catch{}})();const Ca=Ke((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),k=ea(),n=Me(),B=Ne(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:T}=Ea(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Pe(e))),{status:ie}=t(Re),G=$.uiState.currentChatSessionId,E=na(),{setLoading:re}=sa(),[w,M]=f.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,x=F("/:tenantEmailDomain/reports")!==null,m=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:N}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,N),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),P=t((e=>je(e))),{isFeatureEnabled:C}=d(c.isReferralFeatureEnabled),v=t((e=>Ve(e)));f.useEffect((()=>{E&&C&&!m&&v.fetchState==="Not-Started"&&r(Oe(!0))}),[E,C,v.fetchState,m]);const D=t((e=>e.tenantState)),fe=t((e=>D.fetchState==="Completed"?Le(e):[])),g=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:me}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),R=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),ke=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",Te=t((e=>b(e).totalUnreadCount)),Ee=t((e=>b(e).reducedFetchCountState)),j=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),V=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),O=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:L,isLoading:U,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Ce}=Ta();f.useEffect((()=>{const e=setTimeout((()=>Ce?.()),0);return()=>clearTimeout(e)})),f.useEffect((()=>{if(U===!1&&Z===!1&&z===!0)if(o?.companyId!=null&&L!=null){const e=`dashboard_${o.companyId}`;M(L.filter((u=>u.roomId===e&&u.readAt==null)).length)}else M(0)}),[U,Z,z]),f.useEffect((()=>{E&&T&&!m&&O.fetchState==="Not-Started"&&B.tenantId!=null&&r(Ue("task_manager","dashboard"))}),[E,T,m,O.fetchState,B.tenantId,r]),f.useEffect((()=>{m||I.fetchState!=="Not-Started"||r(K({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[m,I.fetchState,r]),f.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(K({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ee,count:Te},q=s!=null?ra.getSignedInUserTenant(s):null,H=t((e=>q?.tenantId!=null?Ze(e,q.tenantId):void 0)),h=[];me===!1&&h.push("accounts_payable_aging"),he===!1&&h.push("accounts_receivable_aging"),h.push("zeni_accounts_promo_card","treasury_promo_card"),C===!1&&h.push("rewards_card"),R===!1&&h.push("expense_automation_card");const W=t((e=>ze(e,h).fetchState)),Y=t((e=>qe(e).fetchState)),ye=A&&(W==="Completed"||W==="Error")||x&&(Y==="Completed"||Y==="Error")||!A&&!x?void 0:"disabled",we=f.useMemo((()=>He(o.userRole)),[o.userRole]),Ae=We(we),ve=o?.rewardsLastViewedTime==null,De=p?.userEmail!=null&&P.fetchState==="Completed"&&Ye(P.notificationSettings,p.userEmail,N,o,T),X=da(),Fe=X&&ca(a);return _.jsx(ka,{container:window.document.body,variant:"temporary",open:l,onClose:()=>i(!1),PaperProps:{sx:{width:240,zIndex:8,borderRight:"none",backgroundImage:"none"}},ModalProps:{keepMounted:!0},children:_.jsx(la,{signedInUser:p,currentTenantId:D.currentTenantId??"",tenants:D.fetchState==="Completed"?fe:H!=null?[H]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:Q(a),isInvoicing:fa(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:ke,isNotificationsTabVisible:De,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:R,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:C,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:X,onNotificationIconClick:()=>{i(!1);let e=j===0&&V>0?"notifications/comments":"notifications/tasks";Q(a)&&(e=j===0&&V>0?"../../notifications/comments":"../../notifications/tasks");const u=S(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=S(a.state?.pathnameStackToGoBack,a.pathname);n("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMenuChange:e=>{if(i(!1),s==null)return;if(e.type==="invoicing")return void n(`../${s}/invoicing/overview`,{state:{pathnameStackToGoBack:S(a.state?.pathnameStackToGoBack,a.pathname),referrer:"Sidebar"}});if(e.type==="ai_cfo"){if(ee.trackAICFOChatScreenStateChanged("viewed","left_menu",G??null,null),!oe)return void pa({location:a,navigate:n,mergeState:{referrer:"Sidebar"}});const y=S(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=S(a.state?.pathnameStackToGoBack,a.pathname),J=e.type,_e=ae(J)&&J!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),_e&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Be=ga(e.type);Sa(e.type)?(G!=null&&r(Je()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Be}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})},handleMyProfileClick:()=>{i(!1),n(`/${s}/settings/my_profile`)},handleReferralsClick:()=>{i(!1),n(`/${s}/rewards`)},handleBackClick:()=>{n(`/${s}/dashboard`)},handleTenantSelect:e=>{re(ma.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{k.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Xe({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:T,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),Ba=l=>{const i=te(),s=t((k=>ne(k))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(k,n)=>{Qe(n)&&xe(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return _.jsx(Ca,{...l,...a})};export{Ba as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./liveblocks-BhGApeF9.js";import{h as r,l as i}from"./core-C5rVvNoh.js";import{ak as n}from"./index-BTTzX8oM.js";import"./mui-AVx3Hg0F.js";import"./sentry-B98sAG37.js";import"./zeni-epic-state-BVExw1ei.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new o.Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="e1fe4b0b-a509-4443-892f-577d1dfd5036",o._sentryDebugIdIdentifier="sentry-dbid-e1fe4b0b-a509-4443-892f-577d1dfd5036")}catch{}})();const a=i(null,(function(o,t){return{onGoBack:()=>{t.navigate(-1)},onGoHome:()=>{t.navigate("/")}}}))(n);function _(){const o=r();return e.jsx(a,{navigate:o})}export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{m as mt,a as lt,n as ft,j as N}from"./liveblocks-
|
|
1
|
+
import{m as mt,a as lt,n as ft,j as N}from"./liveblocks-BhGApeF9.js";import ut from"./NotFoundScreen-C_nzijM_.js";import{a as k}from"./sentry-B98sAG37.js";import{h as ht,g as pt,i as kt,u as gt,j as S,l as St,n as bt,o as W}from"./core-C5rVvNoh.js";import{cz as It,Te as Y,fB as H,g_ as Tt,Ti as b,a09 as Q,Tm as m,Td as E,zJ as j,Fp as Ct,a0a as yt,Tc as Et,To as At,zO as _t,a0b as F,br as $,gd as x,zS as X,a0c as Nt,cL as Bt,cE as wt}from"./zeni-epic-state-BVExw1ei.js";import{ao as xt,c as vt,O as Rt,y as Dt,aq as Pt,dI as Gt,p as B,dJ as Ut,w as Mt,dK as Ft,i as $t,a2 as jt}from"./index-BTTzX8oM.js";import"./mui-AVx3Hg0F.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-Ddvy6nOQ.js";import{u as zt}from"./useTaskManagerAccess-vcnpqvQT.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new t.Error().stack;l&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[l]="e4587881-5996-4727-b331-94277a0a83e6",t._sentryDebugIdIdentifier="sentry-dbid-e4587881-5996-4727-b331-94277a0a83e6")}catch{}})();const Lt=(t,l)=>new Promise(((n,h)=>{const g=t.map((c=>new Promise((s=>{l(c),s()}))));Promise.all(g).then((()=>{setTimeout((()=>{n()}),2e3)})).catch((c=>{h(c)}))})),qt=St((function(t,l){const n=Y(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,s=b(t),f=H(t),{currentTab:I}=s;return{notificationView:s,isNotificationSettingsVisible:h.userEmail!=null&&At(n.notificationSettings,h.userEmail,g,f,c),isDisabled:s.notificationDetailsByTab[I].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:s,navigate:f,markInboxNotificationAsRead:I,fetchMoreCommentsNotifications:R}=l;return{onNotificationClick:(a,o,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${o}`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}d==="unread"&&t(X("task_manager","read",[a],!1))},onCommentNotificationClick:(a,o,d)=>{const r=o.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(I(a),t(F([a],$())));let i=`/${h}/${r[1]}`;const T=B(n.state?.pathnameStackToGoBack,n.pathname);r[1].startsWith("reimbursement")&&!Bt(g)&&(i="not-found"),r[1].startsWith("bill")&&!wt(g)&&(i="not-found"),f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,o)=>{t(E(a,o))},onUpdateNotificationTabState:(a,o)=>{t(m(a,o))},onUpdateNotificationViewCurrentTabAndSubTab:(a,o)=>{t(Q(a,o));const d=`../${a}`,r=B(n.state?.pathnameStackToGoBack,n.pathname);f(d,{state:{pathnameStackToGoBack:r}})},onUpdateNotificationViewSubTab:a=>{t(Nt(a))},onFetchMoreNotifications:(a,o)=>{if(a==="tasks"){const d=[];o==="all"?d.push("read","unread"):o!=="mentions"&&d.push(o),t(j("task_manager","dashboard",d))}else R?.()},onUpdateNotificationStatus:(a,o,d,r)=>{a==="tasks"?t(X("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(I(i),t(F([i],$())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(E({unreadCount:c-r.length>0?c-r.length:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))}),(i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})).catch((i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onMarkAllNotificationsAsRead:a=>{a==="tasks"?t(_t("task_manager","read")):(t(m({markAsAllReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Lt(s,I).then((()=>{t(F(s,$())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(E({unreadCount:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))})).catch((o=>{t(m({markAsAllReadState:{fetchState:"Error",error:o}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onBackClick:()=>{const a=jt(n.state?.pathnameStackToGoBack),o=a.poppedPathname??"../../dashboard";f(o,{state:{pathnameStackToGoBack:a.newStack}})},onSettingsClick:()=>{const a=B(n.state?.pathnameStackToGoBack,n.pathname);f("../../settings/notifications",{state:{pathnameStackToGoBack:a}})}}}))(Mt(Ft)),Ot=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=It(h??""),s=gt(),f=vt(),[I,R]=k.useState(!1),a=S((e=>Y(e))),o=S((e=>H(e))),{useFeatureGate:d}=Rt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Pt({isDataReady:!0});const Z=Tt(o.userRole);if(o==null||n==null||o.companyId==null)throw Error("Can't access notifications page without current tenant...");if(f==null)throw Error("Can't access notifications page without signed in...");const V=S((e=>b(e).notificationDetailsByTab.tasks.fetchState)),z=S((e=>b(e).currentTab)),D=S((e=>b(e).currentSubTab)),tt=S((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),P=S((e=>b(e).notificationDetailsByTab.comments.fetchState)),et=S((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),at=S((e=>b(e).allExternalNotifications)).filter((e=>e.inboxNotification.readAt==null)).map((e=>e.inboxNotification.id)),ot=Gt().allUsers,{inboxNotifications:w,isLoading:A,hasFetchedAll:C,isFetchingMore:G,fetchMore:st}=mt(),{threads:L,isLoading:q,fetchMore:O,isFetchingMore:J,hasFetchedAll:K}=lt({query:{metadata:{companyId:o.companyId,application:"dashboard"}}});k.useEffect((()=>{if(z!==c&&c!=null&&s(Q(c)),c==null){const e=`../${z}`,p=B(l.state?.pathnameStackToGoBack,l.pathname);t(e,{state:{pathnameStackToGoBack:p}})}}),[c]),k.useEffect((()=>{tt.fetchState==="Not-Started"&&s(m({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[]),k.useEffect((()=>{if(A===!1&&C===!0&&o?.companyId!=null&&w!=null){const e=`dashboard_${o.companyId}`,p=w.filter((y=>y.roomId===e&&y.readAt==null)).length;s(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),s(E({unreadCount:p},"comments"))}}),[A,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&s(j("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>st?.()),0);return()=>clearTimeout(e)}));const U=A||G===!0||C!==!0||A||G===!0||C!==!0;k.useEffect((()=>{U&&P!=="In-Progress"?s(m({fetchState:"In-Progress",error:void 0},"comments")):U||P!=="In-Progress"||s(m({fetchState:"Completed",error:void 0},"comments"))}),[U,P]),k.useEffect((()=>{s(E({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&I===!1&&(R(!0),s(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(A===!1&&q===!1&&w!=null&&L!=null){const e=`dashboard_${o.companyId}`,p=w.filter((u=>u.roomId===e)).filter((u=>Ut(u.kind))),y=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const M=L.find((dt=>{return dt.id===((v=u).kind==="thread"?v.threadId:"subjectId"in v?v.subjectId:void 0);var v}));return M!=null?{inboxNotification:{...u,threadId:M.id},thread:M}:(J||K===!0||O==null||O(),null)})).filter((u=>u!=null));s(m({allNotificationsIds:_},"comments")),s(E({totalCount:_.length,unreadCount:y.length},"comments")),s(yt(ct))}}),[A,G,J,C,K,q,w?.length]);const nt={events:o.userRoleId!=null?[`private-encrypted-${o.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if($t(p)){const y=Et(p.mode);if(y==="dashboard"&&s(E({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];D==="all"?_.push("read","unread"):D!=="mentions"&&_.push(D),s(j("task_manager",y,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=zt(f);return N.jsx(qt,{tenantEmailDomain:n,loggedInUserRoleMap:Z,signedInUser:f,externalNotificationsUnreadCount:et,location:l,navigate:t,isDebitCardFeatureEnabled:r,isTaskManagerAccessEnabled:rt,users:ot,markInboxNotificationAsRead:it,allUnreadCommentsNotificationIds:at,isAiCfoAccessEnabled:i,onAskAiCfoClick:T,...nt})};function me(){return N.jsxs(bt,{children:[N.jsx(W,{path:"/:selectedTab",element:N.jsx(Ot,{})}),N.jsx(W,{path:"*",element:N.jsx(ut,{})})]})}export{me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as f}from"./liveblocks-
|
|
1
|
+
import{j as f}from"./liveblocks-BhGApeF9.js";import{a as r}from"./sentry-B98sAG37.js";import{u as A,g as P,j as o,N as j}from"./core-C5rVvNoh.js";import{TO as x,fB as C,gi as R,TP as z,TQ as D,TR as M,TS as L,pO as k,Sx as N}from"./zeni-epic-state-BVExw1ei.js";import{z as h,af as I}from"./index-BTTzX8oM.js";import"./mui-AVx3Hg0F.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new n.Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="16dd0a8e-1340-4daa-9641-635e37c9391a",n._sentryDebugIdIdentifier="sentry-dbid-16dd0a8e-1340-4daa-9641-635e37c9391a")}catch{}})();function ee(){const n=A(),a=P(),{params:t,error:i}=r.useMemo((()=>x(a.search)),[a.search]),w=r.useMemo((()=>new URLSearchParams(a.search).get("client_name")??t?.clientId??"Unknown Application"),[a.search,t]),p=h.isSignedIn(),s=h.getSignedInUser(),m=o((e=>C(e))),l=o((e=>R(e))),d=o((e=>e.tenantState.fetchState)),y=o(z),S=o(D),u=o(M),[v,T]=r.useState(null),[E,b]=r.useState(null);r.useEffect((()=>{document.querySelector("#app-shell-loader")?.remove()}),[]),r.useEffect((()=>()=>{n(L())}),[n,a.search]),r.useEffect((()=>{i!=null&&console.warn("[OAuthConsent] invalid params:",i)}),[i]);const g=r.useRef(!1);r.useEffect((()=>{p&&s!=null&&!g.current&&(d!=="Not-Started"&&d!=="Error"||(g.current=!0,n(k(s.userId,s.zeniSessionId??void 0))))}),[p,s,d,n]),r.useEffect((()=>{u!=null&&u!==""&&(window.location.href=u)}),[u]);const _=r.useMemo((()=>{if(m?.tenantId!=null)return m.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((U=>U.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[m?.tenantId,l]),c=v??_;return i!=null?f.jsx(I,{variant:"invalid_params",paramsError:i}):p?f.jsx(I,{variant:"signed_in",clientName:w,userEmail:s?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:c,onSelectTenant:T,approveError:E??S,isApproving:y==="In-Progress",showAllowButton:c!=null,onApprove:()=>{t!=null&&s!=null&&c!=null&&n(N(s.userId,s.zeniSessionId??void 0,c,t.clientId,t.redirectUri,t.codeChallenge,t.codeChallengeMethod,t.state,t.responseType))},onDeny:()=>{if(t!=null)try{const e=new URL(t.redirectUri);e.searchParams.set("error","access_denied"),e.searchParams.set("error_description","The user denied the request"),e.searchParams.set("state",t.state),window.location.href=e.toString()}catch{b("Unable to deny: redirect_uri is not a valid URL. Close this window or contact support.")}}}):f.jsx(j,{to:"/signin/auth",state:{origin:a.pathname+a.search},replace:!0})}export{ee as default};
|
package/dist/assets/{PandLWithForecastRoutes-aW5WT5CH.js → PandLWithForecastRoutes-5el-0Lj7.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./liveblocks-
|
|
1
|
+
import{j as n}from"./liveblocks-BhGApeF9.js";import{h as J,u as K,g as Q,i as X,j as d,l as Z,n as ee,o as C}from"./core-C5rVvNoh.js";import{fB as M,zu as R,us as ae,UF as w,un as y,bq as te,b_ as se,uo as oe,UG as re,Un as S,e8 as ne,Dg as ce,UH as ie,DE as le,dV as de,dU as me}from"./zeni-epic-state-BVExw1ei.js";import{ag as fe,z as pe,ao as ue,aq as he,V as ge,O as q,y as B,a6 as Fe,h as _,aB as be,p as Ie}from"./index-BTTzX8oM.js";import"./mui-AVx3Hg0F.js";import Ce from"./NotFoundScreen-C_nzijM_.js";import{F as Se}from"./FeaturePreviewScreen-CVnp0bZd.js";import{a as g}from"./sentry-B98sAG37.js";import{u as ye}from"./useAskAiCfoHostNavButtonProps-Ddvy6nOQ.js";import{u as Te}from"./useInitialThreadRequest-DuL5mYzq.js";import{t as De}from"./routePaths-Cx9L8hBM.js";import{M as Ae}from"./MobileAppDrawer-DigqZbbY.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";import"./InboxNotificationsProvider-MlM0K3gF.js";import"./useTaskManagerAccess-vcnpqvQT.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new s.Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="bcab5081-9e6f-40ee-ad70-3f86b739c710",s._sentryDebugIdIdentifier="sentry-dbid-bcab5081-9e6f-40ee-ad70-3f86b739c710")}catch{}})();const T=(s,e,a,o)=>{if(s!=e){const r=o??"";s!=null&&s.length>0?a(`../${e}${r}`,{replace:!0}):a(`${e}${r}`,{replace:!0})}},xe=Z((function(s){const e=re(s),a={},o=e.pandLReportWithForecast.uiState.nodeCollapseState;return Object.keys(o).forEach((r=>{a[r]=o[r]===!1})),{selectedTimeframe:e.selectedTimeframe,isForecastVsActualOn:e.isForecastVsActualOn,compareMode:e.compareMode,forecastList:e.forecastList,selectedForecast:e.selectedForecast,pandLreport:e.pandLReportWithForecast,scrollPosition:e.pandLReportWithForecast.uiState.scrollPosition,nodeOpenStatus:a,type:"name+balances_forecast",analytics:_}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(w(a,o)),e.isPandLReportFetched(a)||s(y(a)),T(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(le(a))},onForecastVsActualsCompareToggle:a=>{s(ie(a)),s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(ce(e.firstMonthOfFY,a,0,[]))},onAccountBalanceClick:e.hasTransactionAccess!==!0?void 0:(a,o)=>{let r,c;const p=a.accountName===""?a.accountDescription:a.accountName;if(o.balanceTimeFrame==="month"||o.balanceTimeFrame==="quarter"?(r=o.balanceTimeFrame,c=ne(o)):o.balanceTimeFrame==="year"?(r="quarter",c={startDate:o.endDate.startOf("quarter"),endDate:o.endDate}):console.error(`timeframe ${o.balanceTimeFrame} is not supported`),c!=null&&r!=null){const u=De(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=Ie(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(S({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(be);function v(){const s=fe(),e=J(),a=K(),o=Q(),{forecastId:r,tenantEmailDomain:c}=X(),[p,u]=g.useState(!1),[m,D]=g.useState(!1),F=pe.getSignedInUser(),A=d((t=>M(t))),G=A.company?.companyInfo.firstMonthOfFY??1,i=d((t=>R(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),x=d((t=>t.profitAndLossState)),j=d((t=>t.reportUIOptionsState.selectedForecast)),E=t=>x.pandLByForecastID[t]!=null&&oe(t,x).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:b}=ue();he({isDataReady:l});const{isAiCfoAccessEnabled:N,onAskAiCfoClick:V}=ye({mobileExploreReferrer:"Forecast"});g.useEffect((()=>{if(!p&&b)u(!0),l||a(ae());else if(l&&!m){D(!0);const t=((f,P,O)=>P!=null?f.forecasts.findIndex((I=>I.id===P)):O!=null?f.forecasts.findIndex((I=>I.id===O)):f.forecasts.length>0?0:-1)(i,r,j?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=j?.index?(a(w(i.forecasts[t].id,t)),T(r,i.forecasts[t].id,e,o.search)):r==null&&t!==-1&&T(void 0,i.forecasts[t].id,e,o.search),t!==-1&&!E(i.forecasts[t].id)&&b&&a(y(i.forecasts[t].id))}}),[p,u,a,l,i,m,D,R,y,b]);const U=ge(),$=U?.loggedInUserRole!=null&&te(U.loggedInUserRole),{useFeatureGate:W}=q(),{isFeatureEnabled:k}=W(B.isReportsCommentingEnabled),Y=Te(k?A?.companyId:void 0,{clearParams:l&&m}),[z,H]=g.useState(!1),h=new URL(s("forecast_pandl"));h.searchParams.set("firstname",F?.firstName??""),h.searchParams.set("lastname",F?.lastName??""),h.searchParams.set("email",F?.userEmail??"");const L=t=>{H(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(Fe,{analytics:_,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(Ae,{isAppContentDrawerOpen:z,handleDrawerToggle:L}),n.jsx(xe,{firstMonthOfFY:G,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:E,meetingUrl:se(h.toString()),hasTransactionAccess:$,isAiCfoAccessEnabled:N,onAskAiCfoClick:V,isReportsCommentingEnabled:k,initialOpenThreadRequest:Y,onClickMenuIcon:()=>{L(!0)}})]})}function Ke(){const s=d((c=>M(c))),{useFeatureGate:e}=q(),{isFeatureEnabled:a}=e(B.isDebitCardFeatureEnabled),o=de(a,s),r=me(s);return o===!0||r===!0?n.jsx(Se,{}):n.jsxs(ee,{children:[n.jsx(C,{path:"/",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId/*",element:n.jsx(Ce,{})})]})}export{Ke as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as a}from"./liveblocks-
|
|
1
|
+
import{j as a}from"./liveblocks-BhGApeF9.js";import{a as p}from"./sentry-B98sAG37.js";import{C as c,H as r,a7 as m,ab as f,ac as h}from"./index-BTTzX8oM.js";import"./mui-AVx3Hg0F.js";import{i as y}from"./core-C5rVvNoh.js";import"./zeni-epic-state-BVExw1ei.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="14a769ae-f041-4637-9426-dab994959d93",e._sentryDebugIdIdentifier="sentry-dbid-14a769ae-f041-4637-9426-dab994959d93")}catch{}})();const g=c("div")`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
width: 100%;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as a}from"./liveblocks-
|
|
1
|
+
import{j as a}from"./liveblocks-BhGApeF9.js";import{UB as re,fB as Y,lX as G,dV as N,dU as le,Rx as X,T_ as ce,Cd as Pe,UC as Q,C2 as je,Cn as Le,Ch as de,C6 as pe,Cl as Te,Ci as ve,UD as ue,rI as Ae,g2 as Re,gA as Ve,UE as H,Ca as me,C9 as ge,Cq as Oe,c7 as Fe}from"./zeni-epic-state-BVExw1ei.js";import{$ as Ce,O as J,y as _,z as K,f as fe,K as he,ad as ye,ax as be,ay as Ue,a9 as Se,H as O,ae as we,G as W,az as Be,ao as Ze,aq as $e,a6 as ze,h as xe,Q as He,p as _e,aA as Ge,V as Ke}from"./index-BTTzX8oM.js";import{D as De,n as M,S as Ie}from"./mui-AVx3Hg0F.js";import ae from"./NotFoundScreen-C_nzijM_.js";import{a as c}from"./sentry-B98sAG37.js";import{u as ee,i as We,j as g,h as Me,g as qe,l as Qe,n as se,o as z}from"./core-C5rVvNoh.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-Ddvy6nOQ.js";import{M as Ne}from"./MobileAppDrawer-DigqZbbY.js";import"./recharts-uwVP8vj-.js";import"./analytics-B5-t19F2.js";import"./plaid-BuoWWOAj.js";import"./dnd-DqvXOfHm.js";import"./stripe-cKAAJElX.js";import"./lottie-CSUQXsXJ.js";import"./lexical-BO1ifV0W.js";import"./pdf-B6tAgCXh.js";import"./utils-B1bcOxs7.js";import"./InboxNotificationsProvider-MlM0K3gF.js";import"./useTaskManagerAccess-vcnpqvQT.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="77b241c0-59b6-4332-a5a0-22edce18a188",e._sentryDebugIdIdentifier="sentry-dbid-77b241c0-59b6-4332-a5a0-22edce18a188")}catch{}})();const Xe={overlayWidth:new Se(100,100,48)},te=W.getLocalizedStrings().peoplePage.invitePage,ne=W.getLocalizedStrings().common,Je=({companyId:e,managersListView:t,companyPassportView:d,classListView:n,mode:C,isEditPeopleDrawerOpen:i,closeDrawerHandler:b})=>{const f=Ce(),m=ee(),[F,U]=c.useState(!1),[k,S]=c.useState(!1),{userId:w}=We(),r=g((l=>re(l))),p=g((l=>Y(l))),E=g((l=>G(l))),{useFeatureGate:D}=J(),{isFeatureEnabled:I}=D(_.isDebitCardFeatureEnabled),P=N(I,p),T=le(p),v=X(p),B=ce(p),Z=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,x=!P&&E&&n.fetchState!=="Completed"||t.fetchState!=="Completed"||d.fetchState!=="Completed"||e==null;if(K.getSignedInUser()==null)throw Error("Can't access invite people page without signing in...");const h=()=>{m(Q()),b()},A=()=>{F===!0?S(!0):h()},$=d.companyView?.controllers?.map((l=>l.user)),u=!!p.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:j}=D(_.isChargeCardFeatureEnabled),L=fe(p,j,I),{isCardsHidden:R}=he(p?.tenantId),y=!L||R,V=p.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",s={peopleDetails:r,classList:n.classes,managersList:t.users,controllersList:$,mode:C,isZeniTenant:v,isAccountingClassesEnabled:E,isReimbursementDisabled:Z===!1,isZeniAccountsDisabled:u===!1,isChargeCardDisabled:y,isTreasuryDisabled:V===!1,isLiteRoleDisabled:B===!1,isBankingOnlyTenant:P,isCardsOnlyTenant:T,onResetClick:h,onDeleteUser:l=>{m(pe(l.userId,l.userRole.userRoleId))},onPeopleLocalDataUpdated:l=>{m(de({peopleLocalData:l})),U(!0)},onSaveClick:()=>{m(C==="zeni_only"?je(e):Le(v))},onCloseClick:A,isLoading:x||r.person==null},o={onOkClick:()=>{S(!1),h()},onCancelClick:()=>{S(!1)}};return c.useEffect((()=>{x===!1&&w!=null&&m(Pe(w))}),[x,w]),c.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&h()}),[r.updatePersonState.fetchState]),a.jsx(De,{anchor:"right",open:i,PaperProps:{style:{width:Xe.overlayWidth.valuePercentage(f),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:ye.overlayDark,cursor:"pointer"}}},onClose:A,children:a.jsxs(ea,{onClick:l=>l.stopPropagation(),children:[k===!0?a.jsx(be,{titleComponent:a.jsx(ke,{children:te.discardTitle}),descriptionComponent:a.jsx(Ee,{children:te.discardDescription}),primaryButtonText:ne.yes,secondaryButtonText:ne.no,action:o,isEditPopup:!0}):null,a.jsx(Ue,{...s})]})})},ea=M(Ie)`
|
|
2
2
|
display: flex;
|
|
3
3
|
min-height: 100%;
|
|
4
4
|
flex-direction: column;
|