@zeniai/web-app-ui 5.3.60-dev → 5.3.60-next
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-OTCvFKAs.js → AccountMappingScreen-CG8HjcPf.js} +1 -1
- package/dist/assets/{ActualMatchingMatchDetailScreen-Ddq4J5sg.js → ActualMatchingMatchDetailScreen-BgJKvXph.js} +1 -1
- package/dist/assets/AddressRoutes-D-ATzT1Q.js +1 -0
- package/dist/assets/{AddressScreen-CuQf3s8q.js → AddressScreen-DiUUtXor.js} +1 -1
- package/dist/assets/{AiCfoScreen-BgTDaGf4.js → AiCfoScreen-CORGt5Wb.js} +1 -1
- package/dist/assets/{AppDrawer-bng0VCuv.js → AppDrawer-DoxNhBkI.js} +1 -1
- package/dist/assets/{BillPayApprovalRoutes-Db4JJOs3.js → BillPayApprovalRoutes-CdhPl8P5.js} +1 -1
- package/dist/assets/{BillPayRoutes-CofiiHGN.js → BillPayRoutes-CkEqFj94.js} +1 -1
- package/dist/assets/{BusinessVerificationPageScreen-DwzljLxu.js → BusinessVerificationPageScreen-Dz0_9Ijg.js} +1 -1
- package/dist/assets/{CardsAiCfoScreen-DqWhmXDu.js → CardsAiCfoScreen-CLxIFPTi.js} +1 -1
- package/dist/assets/{ChargeCardRoutes-BhxHwcna.js → ChargeCardRoutes-DUC0_Rnq.js} +1 -1
- package/dist/assets/{CompanyPassportScreen-Cq_Jl6eA.js → CompanyPassportScreen-CKHgIqAh.js} +1 -1
- package/dist/assets/{ConnectionAuthScreen-CN7vC5Lh.js → ConnectionAuthScreen-CVN0vtIU.js} +1 -1
- package/dist/assets/CustomerOnboardingAuthScreen-3PIXm9Gc.js +1 -0
- package/dist/assets/{CustomerOnboardingRoutes-DerRwWxa.js → CustomerOnboardingRoutes-BW7qQgDH.js} +1 -1
- package/dist/assets/{DashboardRoutes-CdhNJjxd.js → DashboardRoutes-BBI2B6M8.js} +1 -1
- package/dist/assets/{DefaultTenantHome-CPyL5zne.js → DefaultTenantHome-guvQ_iYL.js} +1 -1
- package/dist/assets/{DomesticWireDetailScreen-KBHUrZXC.js → DomesticWireDetailScreen-p5z5JwFe.js} +1 -1
- package/dist/assets/{DrawerScreen-CmeOQk44.js → DrawerScreen-DmHBy9eu.js} +1 -1
- package/dist/assets/{EntityDetailRoutes-DNML7NGc.js → EntityDetailRoutes-HWcj1x9A.js} +1 -1
- package/dist/assets/{ExpenseAutomationRoutes-B37l5cbK.js → ExpenseAutomationRoutes-ChuGRcf0.js} +1 -1
- package/dist/assets/{FeaturePreviewScreen-68s5xf6H.js → FeaturePreviewScreen-cTqlV8kw.js} +1 -1
- package/dist/assets/{HubSpotOAuthCallbackScreen-zGT1SpK9.js → HubSpotOAuthCallbackScreen-DmpuRTYI.js} +1 -1
- package/dist/assets/{InboxNotificationsProvider-CyKlvG2Y.js → InboxNotificationsProvider-C4Xl3N_I.js} +1 -1
- package/dist/assets/{InvoicingRoutes-Bwp4XHw-.js → InvoicingRoutes-Bz-v6tW_.js} +1 -1
- package/dist/assets/{MagicLinkRoutes-bitAdvX2.js → MagicLinkRoutes-CXwLzoJI.js} +1 -1
- package/dist/assets/{MagicLinkSignInScreen-DsFhNMfg.js → MagicLinkSignInScreen-ReI397gl.js} +1 -1
- package/dist/assets/{MobileAppDrawer-CEUnI4Hq.js → MobileAppDrawer-ohji3E0D.js} +1 -1
- package/dist/assets/NotFoundScreen-BtojPFV3.js +1 -0
- package/dist/assets/{NotificationRoutes-CzTXLnSQ.js → NotificationRoutes-BHt_WwzN.js} +1 -1
- package/dist/assets/{OAuthConsentScreen-DIQdwdj0.js → OAuthConsentScreen-EHK42t0Q.js} +1 -1
- package/dist/assets/{PandLWithForecastRoutes-Bat6wWmW.js → PandLWithForecastRoutes-D7BxHFnv.js} +1 -1
- package/dist/assets/{PaymentLinkScreen-DHk3aoli.js → PaymentLinkScreen-BmsWyReK.js} +1 -1
- package/dist/assets/{PeopleRoutes-DtUDDJM6.js → PeopleRoutes-DrtUVgkC.js} +1 -1
- package/dist/assets/{PerformanceRoutes-D5HwwbTh.js → PerformanceRoutes-BO9mQmw6.js} +1 -1
- package/dist/assets/{Preview-CZ0GCEJL.js → Preview-C35Q0tY2.js} +1 -1
- package/dist/assets/{QBOConnectionScreen-BQoGaMQE.js → QBOConnectionScreen-WC7OnIde.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRoutes-BK9uuIKY.js → ReimbursementApprovalRoutes-BrdP7bZB.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRuleDetailScreen-F1ZTr5x4.js → ReimbursementApprovalRuleDetailScreen-D98dGsOX.js} +1 -1
- package/dist/assets/{ReimbursementRoutes-DpVJpUFo.js → ReimbursementRoutes-CmCZ2i0G.js} +1 -1
- package/dist/assets/{ReportsRoutes-CJ9kE_wP.js → ReportsRoutes-DRNAFE3P.js} +1 -1
- package/dist/assets/{RewardsRoutes-CwplkHJv.js → RewardsRoutes-VbgQUOuS.js} +1 -1
- package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-DrMO2pGO.js → ScheduleDetailsPrepaidExpensesScreen-BVSBGxCW.js} +1 -1
- package/dist/assets/{ScreenRoutes-DO1Jugio.js → ScreenRoutes-CgwmPGok.js} +2 -2
- package/dist/assets/{SettingsRoutes-BmznpXzr.js → SettingsRoutes-HwrxDBoJ.js} +1 -1
- package/dist/assets/{SetupPagesScreen-Cm4dUOsa.js → SetupPagesScreen-Bp4MxoSU.js} +1 -1
- package/dist/assets/{SignInScreen-56X4PW_b.js → SignInScreen-DDAW-je3.js} +1 -1
- package/dist/assets/{SignOutScreen-B_hfCYTR.js → SignOutScreen-xg2nffYd.js} +1 -1
- package/dist/assets/{TaskListScreen-C7PSOkmX.js → TaskListScreen-DRgpIAUu.js} +1 -1
- package/dist/assets/{TaskRoutes-DWHGMswW.js → TaskRoutes-Dl3oCL6-.js} +1 -1
- package/dist/assets/TransactionDetailRoutes-BmDSwmsg.js +1 -0
- package/dist/assets/{TransactionDetailScreen-CYUZs5ic.js → TransactionDetailScreen-D81kXW_9.js} +1 -1
- package/dist/assets/{TransactionListRoutes-m1Z6O0Bz.js → TransactionListRoutes-C39G2svX.js} +1 -1
- package/dist/assets/{TreasuryRoutes-CW2OBmMw.js → TreasuryRoutes-BDYnLaYC.js} +1 -1
- package/dist/assets/{VendorsRoutes-DGnb78MD.js → VendorsRoutes-Bm8XylPn.js} +1 -1
- package/dist/assets/{WiseConfirmationScreen-Bw7w4niL.js → WiseConfirmationScreen-DeC-tUFE.js} +1 -1
- package/dist/assets/{ZeniAccountRoutes-DNjiYls5.js → ZeniAccountRoutes-o27eIDR1.js} +1 -1
- package/dist/assets/{ZeniAccountStatementScreen-C-VbWsI7.js → ZeniAccountStatementScreen-BbkR8t34.js} +1 -1
- package/dist/assets/{accountMappingHelper-DvMpHGhQ.js → accountMappingHelper-DsWulQNd.js} +1 -1
- package/dist/assets/{analytics-DsLgvapu.js → analytics-DHz0W6ee.js} +1 -1
- package/dist/assets/{analyticsHelper-gYymmE6t.js → analyticsHelper-CNF4X1L3.js} +1 -1
- package/dist/assets/{core-Bmb_Ak_Y.js → core-CBgcohKl.js} +1 -1
- package/dist/assets/{decodeURIComponentSafe-DJ_E_YWK.js → decodeURIComponentSafe-B8wth54g.js} +1 -1
- package/dist/assets/{dnd-DkMLkYx6.js → dnd-f7VjRKNv.js} +1 -1
- package/dist/assets/{empty-6UqLgG3D.js → empty-CuWyrybz.js} +1 -1
- package/dist/assets/{empty-BbS1Gl6y.js → empty-KDIggwFg.js} +1 -1
- package/dist/assets/{emptyVideoElement-Cg24RrEN.js → emptyVideoElement-xhkWkwAm.js} +1 -1
- package/dist/assets/{epic-od0XiBtR.js → epic--AadAq3B.js} +1 -1
- package/dist/assets/{expenseAutomationHelper-BLkNr7mV.js → expenseAutomationHelper-DyHogR1f.js} +1 -1
- package/dist/assets/{getLocaleForTenant-M0-025vr.js → getLocaleForTenant-DJlcQPmW.js} +1 -1
- package/dist/assets/{index-CUXZSXN9.js → index-BnFrZwPR.js} +1 -1
- package/dist/assets/{index-D0iVGaq0.js → index-BryzBMy8.js} +1 -1
- package/dist/assets/{index-DmPWzVbe.js → index-COFn4Lui.js} +1 -1
- package/dist/assets/{index-CG_-PpoJ.js → index-Csj-fAR5.js} +2 -2
- package/dist/assets/{index-C1klq1uS.js → index-DAOzM7eN.js} +1 -1
- package/dist/assets/{index-CAdK_ZH1.js → index-Df2ds6q_.js} +1 -1
- package/dist/assets/{index-iXP_lIgR.js → index-Dxpayzr2.js} +8 -8
- package/dist/assets/{index-BI4aIWd1.js → index-r4tjL442.js} +1 -1
- package/dist/assets/{lexical-CmLRktxM.js → lexical-C3EylrlT.js} +1 -1
- package/dist/assets/{liveblocks-DQvQWdbA.js → liveblocks-BuehHs6O.js} +1 -1
- package/dist/assets/{lottie-DxPNrDu0.js → lottie-Hll5C5f2.js} +1 -1
- package/dist/assets/{mui-DtqowzCa.js → mui-Cb9eDKBr.js} +1 -1
- package/dist/assets/{pathToGoBack-DAUO1SpT.js → pathToGoBack-Cd7lBADO.js} +1 -1
- package/dist/assets/{pdf-DPSRzf4S.js → pdf-CIjq4lBs.js} +3 -3
- package/dist/assets/{pdf-lib-BGH3tK3M.js → pdf-lib-B6v5xA2O.js} +1 -1
- package/dist/assets/{plaid-C4EwuB54.js → plaid-7nNyVbzF.js} +1 -1
- package/dist/assets/{pusher-DENoTc4H.js → pusher-tkMH32uI.js} +1 -1
- package/dist/assets/{react-BEi84bd1.js → react-CDY2cCdn.js} +1 -1
- package/dist/assets/{react-CaHzQu7m.js → react-CWGmSSnm.js} +1 -1
- package/dist/assets/{react-DMC1LPH7.js → react-DJZvEoZP.js} +1 -1
- package/dist/assets/{react-CJrSlsYG.js → react-DXo2_yFS.js} +1 -1
- package/dist/assets/{react-tVtZHhG5.js → react-Da-oM-bE.js} +1 -1
- package/dist/assets/{react-BNEuXZaz.js → react-MseeXV8X.js} +1 -1
- package/dist/assets/{recharts-zLURHmb5.js → recharts-Byvkx40G.js} +1 -1
- package/dist/assets/{routePaths-DBrqXAiF.js → routePaths-B-L_6QzQ.js} +1 -1
- package/dist/assets/{sentry-CL2gFEWd.js → sentry-D8HyV7mS.js} +1 -1
- package/dist/assets/{stripSplatSuffix-D0cwiSKA.js → stripSplatSuffix-CFEl-9z0.js} +1 -1
- package/dist/assets/{url-DGroeH_d.js → url-CIxROwIS.js} +1 -1
- package/dist/assets/{url-hKPtSW1M.js → url-CRbSh4Tu.js} +1 -1
- package/dist/assets/{useActualMatchingMatchDetail-DsEAJr6P.js → useActualMatchingMatchDetail-Cum7P8RW.js} +1 -1
- package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-DxxiH1BU.js → useAiCfoDashboardSuggestedQuestionsChips-DZa_r4n_.js} +1 -1
- package/dist/assets/{useAskAiCfoHostNavButtonProps-BUhRapTx.js → useAskAiCfoHostNavButtonProps-D10pewSQ.js} +1 -1
- package/dist/assets/{useChargeCardPusherEvents-CGwCqNyp.js → useChargeCardPusherEvents-IS3z6PSf.js} +1 -1
- package/dist/assets/{useDeviceId-Bs3TbfVF.js → useDeviceId-BI6f3BPa.js} +1 -1
- package/dist/assets/{useEmailConnectResultRefresh-D-3aFs_D.js → useEmailConnectResultRefresh-Ct07z7Cx.js} +1 -1
- package/dist/assets/{useInitialThreadRequest-BPGlnuVj.js → useInitialThreadRequest-eERa3iZO.js} +1 -1
- package/dist/assets/{useTaskManagerAccess-BEPhAxkZ.js → useTaskManagerAccess-BNjTqV_h.js} +1 -1
- package/dist/assets/{useTaskManagerPusherEvents-CPjVZZAl.js → useTaskManagerPusherEvents-dnN4yDqv.js} +1 -1
- package/dist/assets/{utils-J_9y2_nC.js → utils-Co2o080j.js} +1 -1
- package/dist/assets/{withTransactionSidePanel-CFMLZxW0.js → withTransactionSidePanel-BcR5QH3v.js} +1 -1
- package/dist/assets/{zeni-epic-state-ZMlib3rE.js → zeni-epic-state-CiYCRFt8.js} +3 -3
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/AddressRoutes-BVPZraVE.js +0 -1
- package/dist/assets/CustomerOnboardingAuthScreen-BeKfP3VD.js +0 -1
- package/dist/assets/NotFoundScreen-DJ8NhjqE.js +0 -1
- package/dist/assets/TransactionDetailRoutes-CxmxwjCr.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as a}from"./liveblocks-DQvQWdbA.js";import{a as r}from"./sentry-CL2gFEWd.js";import{u as L,h as A,i as R,j as C,t as G,l as O,s as H,g as Z,N as B,n as te,o as x}from"./core-Bmb_Ak_Y.js";import{a9 as nt,k as p,ar as _,V as m,cd as tt,ce as it,cf as ot,cg as at,ch as st,ci as ct,cj as rt,ck as lt,cl as dt,cm as ut,cn as gt,co as mt,p as W,cp as vt,cq as pt,af as ae,cr as St,cs as ft,z as ke,ct as ht,cu as It,cv as Ct,cw as Et,cx as kt,cy as yt,cz as xt,cA as bt,K as jt,aj as ln,cB as Dt,cC as Lt,cD as At,cE as Pt,cF as $t,cG as Ft,cH as wt,cI as Rt,cJ as _t,cK as Tt,cL as Ot,t as Ve,j as dn,cM as Mt,cN as Nt,cO as Ut,cP as Bt,cQ as Vt,cR as Ht,cS as qt}from"./index-iXP_lIgR.js";import"./mui-DtqowzCa.js";import{A as Q}from"./AddressScreen-CuQf3s8q.js";import M from"./NotFoundScreen-DJ8NhjqE.js";import{ZQ as zt,ZR as Qt,vp as He,ZS as K,vS as se,ZT as Ae,ZU as ce,wt as ye,wA as Kt,wF as un,ZV as Pe,wx as gn,y7 as qe,vR as ze,ZW as Gt,ZX as mn,wQ as xe,ZY as re,wU as Zt,ZZ as Wt,Z_ as vn,wX as pn,z2 as Xt,Z$ as ve,_0 as Qe,_1 as Sn,vP as Jt,_2 as Yt,vJ as ei,_3 as ni,yk as ti,_4 as fn,yt as Ke,_5 as ii,yq as oi,_6 as $e,gh as ai,_7 as ee,_8 as ne,xa as si,vX as Ge,w0 as hn,v_ as ci,vU as ri,x3 as li,w2 as di,xc as ui,_9 as be,xl as In,xj as X,xh as le,xg as gi,_a as Cn,yz as Ze,_b as mi,vQ as En,_c as Fe,wb as je,w8 as De,wl as kn,wk as we,w5 as vi,we as yn,wn as ie,fF as Re,VC as xn,vT as _e,wi as pi,wj as Si,wh as fi,_d as hi,wV as Ii,wR as bn,_e as jn,vD as We,_f as Ci,vz as Ei,_g as ki,yF as yi,yJ as q,yE as xi,xN as Te,_h as bi,_i as Dn,yS as Xe,_j as ji,yP as Di,_k as Ln,xQ as Li,xR as V,xU as Ai,_l as An,y2 as Ie,_m as Pi,xb as Pn,U8 as $n,_n as $i,yc as Fi,_o as Fn,_p as wi,_q as Ri,_r as _i,zH as Ti,_s as Oi,_t as wn,yZ as Rn,_u as _n,zF as Ce,_v as Mi,zC as Ni,_w as Ui,_x as Bi,_y as Vi,_z as Hi,_A as qi,_B as Je,_C as zi,eg as Qi,zL as Ki,_D as Oe,xv as Gi,xq as Zi,_E as de,xG as Tn,xy as ue,xx as Wi,xB as On,_F as Xi,xw as Ji,_G as Mn,z3 as Nn,zu as Ye,zp as Yi,_H as eo,z4 as no,_I as to,zv as io,zz as oo,_J as Me,wv as Un,zg as ao,ww as so,_K as co,_L as Bn,c8 as ro,ms as lo,mt as uo,_M as en,wu as ge,gl as go,mz as mo,zm as Vn,zX as vo,zj as Hn,uX as po,zU as nn,uL as So,zR as tn,hS as fo,UB as on,UC as ho,Gh as qn,hK as Io,_N as Co,Vr as Eo,_O as ko,A0 as Ee,A1 as yo,_P as xo,_Q as zn,z_ as bo,_R as jo,_S as Do,yg as Lo,_T as Ao}from"./zeni-epic-state-ZMlib3rE.js";import{M as Po}from"./MobileAppDrawer-CEUnI4Hq.js";import{q as me}from"./QBOConnectionScreen-BQoGaMQE.js";import"./recharts-zLURHmb5.js";import"./analytics-DsLgvapu.js";import"./plaid-C4EwuB54.js";import"./dnd-DkMLkYx6.js";import"./stripe-cKAAJElX.js";import"./lottie-DxPNrDu0.js";import"./lexical-CmLRktxM.js";import"./pdf-DPSRzf4S.js";import"./utils-J_9y2_nC.js";import"./InboxNotificationsProvider-CyKlvG2Y.js";import"./useTaskManagerAccess-BEPhAxkZ.js";import"./empty-6UqLgG3D.js";import"./pdf-lib-BGH3tK3M.js";import"./index-DmPWzVbe.js";import"./url-hKPtSW1M.js";import"./index-CAdK_ZH1.js";import"./decodeURIComponentSafe-DJ_E_YWK.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]="fdd16e8d-e4d1-4d89-9266-7259722e3c69",t._sentryDebugIdIdentifier="sentry-dbid-fdd16e8d-e4d1-4d89-9266-7259722e3c69")}catch{}})();const $=({event:t,isReady:e=!0})=>e?a.jsx(nt,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function $o(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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:g,hasMore:f,items:S,nextCursor:h,auditLogEntityRouteOptions:D,auditLogListSortFieldOptions:b}=C(zt),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${n??""}/invoicing`,I=r.useCallback(((P,U)=>{const T=Qt(y,P,U,D);T!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:P,entityId:U,fromScreen:"audit_log"}),e(T))}),[D,e,y]);r.useEffect((()=>{const P=setTimeout((()=>d(s)),300);return()=>clearTimeout(P)}),[s]),r.useEffect((()=>{i&&t(He({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,t]);const j=g==="Not-Started"||g==="In-Progress"&&S.length===0,E=g==="In-Progress"&&S.length>0,F=g==="Completed";return N(g)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:F}),a.jsx(tt,{auditLogEntityRouteOptions:D,auditLogListSortFieldOptions:b,entries:S,hasMore:f,isLoading:j,isLoadingMore:E,searchValue:s,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{f&&h!=null&&t(He({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function pe(t,e=!1){const n=L(),i=C((c=>K(c).productNextCursor!=null)),s=C((c=>K(c).productNextCursor)),o=C((c=>K(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&s!=null&&n(se({cursor:s,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,s])}function Se(t,e,n,i){const[s,o]=r.useState(0),[c,d]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const v=l.current==="In-Progress";l.current=t,t==="Completed"&&v&&n!=null&&(d(!0),i(n))}),[t,n,i]),r.useEffect((()=>{c&&!e&&(d(!1),o((v=>v+1)))}),[c,e]),s}const Fo=new Set(["plan"]),wo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?s=>{i!==""&&t(gn({action:s,id:i}))}:void 0,onEditChange:s=>{i!==""&&t(Pe({id:i,localData:s}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),t(un({id:i}))},onSubFamilyLifecycleAction:(s,o)=>{i!==""&&t(Kt({action:o,id:s,parentItemId:i}))}}}))(it);function Ro(){const t=L(),e=A(),{item_id:n,tenantEmailDomain:i}=R(),[s]=G(),{areTenantIdsInSync:o}=_(),c=(d=s.get("kind"))!=null&&Fo.has(d)?d:"plan";var d;const l=C((k=>Ae(k,n))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(t(ce({id:n})),()=>{t(ce({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(ye({id:n,kind:c}))}),[o,n,c,t]);const g=r.useCallback((k=>t(ye({cacheOverride:!0,id:k,kind:c}))),[t,c]),f=Se(l.fetchState,l.isFormLoading,n,g),S=u==="Completed"&&!l.isFormLoading;pe(o,!0);const[h,D]=r.useState(S?n:void 0);r.useEffect((()=>{n!=null&&S&&D(n)}),[n,S]);const b=h!==n&&(u==="Not-Started"||u==="In-Progress"||l.isFormLoading);return N(u)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:S}),a.jsx(wo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:b,view:l},f)]})}const _o=new Set(["addon","charge","plan"]),To=new Set(["plan"]),Oo=O((function(t,e){const n=Ae(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,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:s}=e,o=s!=null?`${n}/catalog/${encodeURIComponent(s)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),t(ce({id:s})),e.navigate(`${n}/catalog`)},onChange:c=>{t(Pe({id:s,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),t(un({id:s}))}}}))(ot);function Mo(){const t=L(),e=A(),{item_id:n,tenantEmailDomain:i}=R(),[s]=G(),{areTenantIdsInSync:o}=_(),c=n!=null,d=s.get("type"),l=d!=null&&_o.has(d)?d:void 0,v=(u=s.get("kind"))!=null&&To.has(u)?u:"plan";var u;const g=C((f=>Ae(f,n)));return pe(o,!0),r.useEffect((()=>{o&&t(ye({id:n,kind:v}))}),[o,n,v,t]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||t(Pe({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const f=g.savedItemId??n,S=f!=null?`/${i}/invoicing/catalog/${encodeURIComponent(f)}`:`/${i}/invoicing/catalog`;e(S),t(ce({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),a.jsx(Oo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const No={addons:"addon",all:"item",charges:"charge",plans:"plan"},Uo=O((function(t,e){const n=K(t),i=e.activeTab==="plans",s=e.activeTab==="all",o=i?n.plans:s?[...n.plans,...n.products]:n.products,c=i||s&&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:s&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",s=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=No[e.activeTab];p.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(gn({action:Gt(d),id:c}))},onLoadMore:()=>{if(s)return e.planNextCursor!=null&&t(ze({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?ze({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(at);function Bo(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),f=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),S=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:S,type:"plan"})),[S]),D=r.useMemo((()=>({search:S,type:"addon|charge"})),[S]),b=C((P=>K(P))),k=b.planFilters.search,y=b.planSort,I=b.planNextCursor,j=b.productNextCursor,E=b.fetchState==="Completed",F=b.runningActionId??null;return r.useEffect((()=>{const P=setTimeout((()=>v(s)),300);return()=>clearTimeout(P)}),[s]),r.useEffect((()=>{i&&t(qe({cacheOverride:!1,planFilters:h,productFilters:D,planSort:f,productSort:f}))}),[i,t,h,D,f]),r.useEffect((()=>{i&&(S!==k||f?.field!==y?.field||f?.dir!==y?.dir)&&t(qe({cacheOverride:!0,planFilters:h,productFilters:D,planSort:f,productSort:f}))}),[k,y,i,t,h,D,S,f]),N(b.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),a.jsx(Uo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:s,sortState:u,planFilters:h,productFilters:D,sort:f,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:F,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Vo=O((function(t,e){const n=mn(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,s=i!=null?"edit":"create",o=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),t(re({id:i})),e.navigate(`${n}/discounts`)},onChange:c=>{t(Wt({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:s}),t(Zt({id:i}))}}}))(st);function Ho(){const t=L(),e=A(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),{fetchState:o,savedCouponId:c}=C((d=>mn(d,n)));return r.useEffect((()=>{s&&t(xe({id:n}))}),[s,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(re({id:n}))}}),[o,c,n,t,e,i]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCouponFormPage}),a.jsx(Vo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const qo=O((function(t){const e=vn(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(m.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:s=>{e(Sn(s))},onSubmit:()=>{const s=Yt(t.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:s.customer_id,lineItemCount:s.line_items?.length}),e(ei(s))}}}))(rt);function zo(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),[i]=G(),{areTenantIdsInSync:s}=_(),o=i.get("customerId"),c=C((I=>vn(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(pn),g=C((I=>Xt(I))),f=C(ve),S=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=f.fetchState==="Not-Started"||f.fetchState==="In-Progress"&&f.customers.length===0,D=S||h,b=g.fetchState==="Completed"&&f.fetchState==="Completed";r.useEffect((()=>(t(Qe()),()=>{t(Qe())})),[t]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,t(Sn({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{s&&t(Jt({cacheOverride:!1}))}),[s,t]);const y=r.useRef(d);return r.useEffect((()=>{const I=y.current;if(y.current=d,I!=="Completed"&&d==="Completed"){const j=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(j)}}),[d,v,e,n]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),D?a.jsx(ct,{}):a.jsx(qo,{navigate:e,tenantEmailDomain:n})]})}const Qo=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(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(lt);function Ko(){const t=L(),e=A(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),o=C((d=>ni(d,n??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{s&&n!=null&&t(ti({id:n}))}),[s,n,t]),N(o.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),a.jsx(Qo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const Go=O((function(t){const e=fn(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(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(oi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(dt);function Zo(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,creditNoteListFetchState:b}=C((y=>{const I=fn(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(s)),300);return()=>clearTimeout(y)}),[s]),r.useEffect((()=>{i&&t(Ke({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ke({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),a.jsx(Go,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(ii(y)),onSortChange:v})]})}const Qn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Wo=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:s=>{t(be({id:i,localData:s}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:s,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(s)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onDiscardEdit:()=>{t(X(le)),t(gi({id:i}))},onOpenAddress:()=>{const s=Qn(e.tenantEmailDomain??"",le,i),o=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:s=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),t(be({id:i,localData:s})),t(In({id:i}))},onFetchPaymentLinkEmailPreview:s=>t(ui({cacheOverride:s,customerId:i})),onSendPaymentLink:(s,o,c)=>t(di({body:c,customerId:i,email:s,subject:o})),onSubscriptionClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)}}}))(mt);function Xo(){const t=L(),e=A(),n=Z(),{customer_id:i,tenantEmailDomain:s}=R(),{areTenantIdsInSync:o}=_(),c=C((T=>$e(T,i))),d=c.pageFetchState.fetchState,l=d==="Completed"&&!c.isFormLoading,[v,u]=r.useState(!1),[g,f]=r.useState(!1),[S,h]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&h(i)}),[i,l]);const D=S===i,{plaidTokenFetchState:b,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:y,setupIntentFetchState:I,stripeConnected:j}=c.record,E=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const T=c.record.sendLinkState.fetchState;E.current!=="Error"&&T==="Error"&&t(ai({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),E.current=T}),[t,c.record.sendLinkState.fetchState]);const F=I.fetchState==="Error"?I.error?.message??"Failed to start card setup.":y.fetchState==="Error"?y.error?.message??"Failed to save payment method.":b.fetchState==="Error"?b.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&&(f(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(si({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&j&&t(Ge({customerId:i}))}),[o,i,t,j]);const P=r.useCallback((T=>t(hn({id:T}))),[t]),U=Se(c.fetchState,c.isFormLoading,i,P);return N(d)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),a.jsx(Wo,{customerId:i??"",editView:c,hasLoadedRecord:D,location:n,navigate:e,tenantEmailDomain:s,onAddPaymentMethod:()=>{t(ee()),i!=null&&j&&t(Ge({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),f(!0)}},U),a.jsx(ut,{errorMessage:F,isCreatingSetupIntent:I.fetchState==="In-Progress",isSaving:y.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:y.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:j,onChooseCard:()=>{i!=null&&t(ri({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:T=>{i!=null&&t(ci({customerId:i,data:T}))}}),a.jsx(gt,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:g,submitSucceeded:k.fetchState==="Completed",onClose:()=>{f(!1),t(ne())},onSubmit:({amount:T,description:Y})=>{i!=null&&t(li({amount:T,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:Y}))}})]})}const Jo=O((function(t,e){const n=$e(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,s=i!=null?"edit":"create",o=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),t(Cn({id:i})),t(X(le)),e.navigate(`${n}/customers`)},onChange:c=>{t(be({id:i,localData:c}))},onOpenAddress:()=>{const c=Qn(e.tenantEmailDomain??"",le,i),d=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:s}),t(In({id:i}))}}}))(vt);function Yo(){const t=L(),e=A(),n=Z(),{customer_id:i,tenantEmailDomain:s}=R(),{areTenantIdsInSync:o}=_(),{fetchState:c,savedCustomerId:d}=C((l=>$e(l,i)));return r.useEffect((()=>{o&&i!=null&&t(hn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${s}/invoicing/customers/${encodeURIComponent(l)}`:`/${s}/invoicing/customers`;e(v),t(Cn({id:i}))}}),[c,d,i,t,e,s]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomerFormPage}),a.jsx(Jo,{customerId:i,location:n,navigate:e,tenantEmailDomain:s})]})}const ea=O((function(t){const e=ve(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(m.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,s)=>{switch(s){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(En({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function na(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,customerListFetchState:b}=C((y=>{const I=ve(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(s)),300);return()=>clearTimeout(y)}),[s]),r.useEffect((()=>{i&&t(Ze({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ze({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),a.jsx(ea,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(mi(y)),onSortChange:v})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ta=O((function(t,e){const{filters:n,sessionId:i,view:s}=e,o=i==null?void 0:s.diagnosticsBySession[i],c=o?.fetch.fetchState??"Not-Started";return{diagnostics:o?.items??[],errorMessage:c==="Error"?o?.fetch.error?.message:void 0,expired:o?.expired??!1,filters:n,hasMore:o?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(o?.items.length??0)>0,session:Le(s,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:s,sessionId:o,tenantEmailDomain:c,view:d}=e,l=o==null?void 0:d.diagnosticsBySession[o],v=Le(d,o),u=d.actionStateByKind.retry?.fetchState==="In-Progress",g=d.actionStateByKind.rollback?.fetchState==="In-Progress",f=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>s(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&t(De({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&t(we(o))},onRollback:f?()=>{o!=null&&t(kn(o))}:void 0}}))(St);function ia(){const t=L(),e=A(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),[o,c]=r.useState({}),d=C(Fe),l=Le(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{s&&n!=null&&t(je(n))}),[s,t,n]),r.useEffect((()=>{if(!s||n==null)return;const S=setTimeout((()=>{t(De({...o,sessionId:n}))}),300);return()=>clearTimeout(S)}),[s,t,o,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!s||n==null||!u)return;const S=setInterval((()=>{t(je(n)),t(De({...o,sessionId:n}))}),3e3);return()=>clearInterval(S)}),[s,t,o,u,n]);const g=r.useMemo((()=>{if(n==null)return;const S=new URLSearchParams;o.moduleId!=null&&S.set("module_id",o.moduleId),o.level!=null&&S.set("level",o.level),o.outcome!=null&&S.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&S.set("search",o.search.trim());const h=S.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),f=v?.fetch.fetchState??"Not-Started";return N(f)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&f!=="Not-Started"}),a.jsx(ta,{downloadUrl:g,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const Kn=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=Kn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},oa=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:s,statusRows:o}=e.view;return{isLoading:!(s.fetchState!=="Not-Started"&&s.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,s=o=>{const c=o??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),s(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),s()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(we(o)),s(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(kn(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(ft);function aa(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),s=C(Fe);r.useEffect((()=>{i&&(t(vi()),t(yn()))}),[i,t]);const o=s.statusFetch.fetchState==="Completed"&&s.sessionsFetch.fetchState==="Completed";return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),a.jsx(oa,{navigate:e,tenantEmailDomain:n,view:s})]})}const sa=O((function(t,e){const{activeId:n,integrationsView:i,settings:s,view:o}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=o,v=i.externalConnections?.revenue?.find((g=>g.connectionName==="chargebee")),u=n!=null?d[n]:void 0;return{chargebeeConnected:s?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:s?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((g=>g.id===n)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:s}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded);const o=ae?.invoicingMicroServiceBaseUrl,c=o!=null&&o.length>0?o:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),t(fi())},onGoToIntegrations:()=>{i(`/${s}/invoicing/settings`)},onGoToOverview:()=>i(`/${s}/invoicing/overview`),onRetry:()=>{n!=null&&t(we(n))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),n!=null&&t(Si(n))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),t(pi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${s}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(ht);function ca(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),s=C(pn),o=C(Re).companyId??ke.getSignedInUserTenant(n??"")?.companyId,c=C((S=>xn(S,o))),d=C(Fe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((S=>S.id===v)):void 0;r.useEffect((()=>{i&&(t(_e()),t(yn()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const S=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(Kn(h))}catch{return null}})(n);S!=null&&t(ie(S))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const g=u?.status,f=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!f)return;const S=setInterval((()=>{t(je(v))}),3e3);return()=>clearInterval(S)}),[i,v,f,t]),r.useEffect((()=>{g==="done"&&(t(ie(null)),oe(n,null))}),[t,g,n]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportMigratePage}),a.jsx(sa,{activeId:v,integrationsView:c,navigate:e,settings:s,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ra=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:s=>{t(bn({action:s,id:i}))},onSaveEdit:s=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),t(Ii({data:s,id:i}))}}}))(It);function la(){const t=L(),e=A(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),o=C((h=>hi(h,n))),c=o.actionState.fetchState==="In-Progress",d=o.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&u(n)}),[n,l]);const g=v===n;r.useEffect((()=>(t(re({id:n})),()=>{t(re({id:n}))})),[n,t]),r.useEffect((()=>{s&&t(xe({id:n}))}),[s,n,t]);const f=r.useCallback((h=>t(xe({cacheOverride:!0,id:h}))),[t]),S=Se(o.fetchState,o.isFormLoading,n,f);return N(d)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),a.jsx(ra,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},S)]})}const da=O((function(t){const e=jn(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(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,s)=>{t(bn({action:s,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Ei({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ct);function ua(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=jn(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,couponListFetchState:j.fetchState,runningDiscountActionId:j.runningActionId??null}}),H),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(s)),300);return()=>clearTimeout(I)}),[s]),r.useEffect((()=>{i&&t(We({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(We({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),a.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>t(Ci(I)),onSortChange:v})]})}const ga=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,s=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:o=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCancel:s?()=>t(q({action:"cancel",id:i})):void 0,onResolve:s?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(q({action:"resolve",id:i}))}:void 0,onResume:s?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(q({action:"resume",id:i}))}:void 0,onRetry:s?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(q({action:"retry",id:i}))}:void 0}}))(kt);function ma(){const t=L(),e=A(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),o=C((E=>ki(E,n??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[f,S]=r.useState(),[h,D]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),S(void 0),D(!1)}),[]),k=r.useCallback((()=>{if(n==null)return;t(yi({id:n})),v("idle"),g(!1);const E=o.emailPreview.preview;S(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),D(!0)}),[n,t,o.emailPreview.preview]),y=r.useCallback((E=>{n!=null&&l!=="pending"&&(g(!1),v("pending"),p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(q({action:"send-email",body:E,id:n})))}),[n,t,l]),I=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{s&&n!=null&&t(xi({id:n}))}),[s,n,t]),r.useEffect((()=>{s&&d!=null&&t(Te({invoiceId:d}))}),[s,d,t]),r.useEffect((()=>{v("idle"),g(!1),S(void 0),D(!1)}),[n]),r.useEffect((()=>{s||(v("idle"),g(!1),S(void 0),D(!1))}),[s]),r.useEffect((()=>{h&&f==null&&o.emailPreview.preview!=null&&S({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,f,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(n!=null&&t(bi({id:n})),b()):u&&o.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[n,b,t,l,u,o.actionState.fetchState]);const j=d!=null&&o.linkedInvoice?.id===d?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),a.jsx(ga,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:j,onSendEmail:k}),a.jsx(Et,{initialDraft:f,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:b,onSend:y,open:h,preview:I,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const va=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",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(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,s)=>{s!=="retry"&&s!=="resume"&&s!=="resolve"&&s!=="cancel"||t(q({action:s,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Di({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(yt);function pa(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,dunningCaseListFetchState:b}=C((y=>{const I=Dn(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(s)),300);return()=>clearTimeout(y)}),[s]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),a.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(ji(y)),onSortChange:v})]})}const Sa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),t(Ai({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
|
|
1
|
+
import{j as a}from"./liveblocks-BuehHs6O.js";import{a as r}from"./sentry-D8HyV7mS.js";import{u as L,h as A,i as R,j as C,t as G,l as O,s as H,g as Z,N as B,n as te,o as x}from"./core-CBgcohKl.js";import{a9 as nt,k as p,ar as _,V as m,cd as tt,ce as it,cf as ot,cg as at,ch as st,ci as ct,cj as rt,ck as lt,cl as dt,cm as ut,cn as gt,co as mt,p as W,cp as vt,cq as pt,af as ae,cr as St,cs as ft,z as ke,ct as ht,cu as It,cv as Ct,cw as Et,cx as kt,cy as yt,cz as xt,cA as bt,K as jt,aj as ln,cB as Dt,cC as Lt,cD as At,cE as Pt,cF as $t,cG as Ft,cH as wt,cI as Rt,cJ as _t,cK as Tt,cL as Ot,t as Ve,j as dn,cM as Mt,cN as Nt,cO as Ut,cP as Bt,cQ as Vt,cR as Ht,cS as qt}from"./index-Dxpayzr2.js";import"./mui-Cb9eDKBr.js";import{A as Q}from"./AddressScreen-DiUUtXor.js";import M from"./NotFoundScreen-BtojPFV3.js";import{ZQ as zt,ZR as Qt,vp as He,ZS as K,vS as se,ZT as Ae,ZU as ce,wt as ye,wA as Kt,wF as un,ZV as Pe,wx as gn,y7 as qe,vR as ze,ZW as Gt,ZX as mn,wQ as xe,ZY as re,wU as Zt,ZZ as Wt,Z_ as vn,wX as pn,z2 as Xt,Z$ as ve,_0 as Qe,_1 as Sn,vP as Jt,_2 as Yt,vJ as ei,_3 as ni,yk as ti,_4 as fn,yt as Ke,_5 as ii,yq as oi,_6 as $e,gh as ai,_7 as ee,_8 as ne,xa as si,vX as Ge,w0 as hn,v_ as ci,vU as ri,x3 as li,w2 as di,xc as ui,_9 as be,xl as In,xj as X,xh as le,xg as gi,_a as Cn,yz as Ze,_b as mi,vQ as En,_c as Fe,wb as je,w8 as De,wl as kn,wk as we,w5 as vi,we as yn,wn as ie,fF as Re,VC as xn,vT as _e,wi as pi,wj as Si,wh as fi,_d as hi,wV as Ii,wR as bn,_e as jn,vD as We,_f as Ci,vz as Ei,_g as ki,yF as yi,yJ as q,yE as xi,xN as Te,_h as bi,_i as Dn,yS as Xe,_j as ji,yP as Di,_k as Ln,xQ as Li,xR as V,xU as Ai,_l as An,y2 as Ie,_m as Pi,xb as Pn,U8 as $n,_n as $i,yc as Fi,_o as Fn,_p as wi,_q as Ri,_r as _i,zH as Ti,_s as Oi,_t as wn,yZ as Rn,_u as _n,zF as Ce,_v as Mi,zC as Ni,_w as Ui,_x as Bi,_y as Vi,_z as Hi,_A as qi,_B as Je,_C as zi,eg as Qi,zL as Ki,_D as Oe,xv as Gi,xq as Zi,_E as de,xG as Tn,xy as ue,xx as Wi,xB as On,_F as Xi,xw as Ji,_G as Mn,z3 as Nn,zu as Ye,zp as Yi,_H as eo,z4 as no,_I as to,zv as io,zz as oo,_J as Me,wv as Un,zg as ao,ww as so,_K as co,_L as Bn,c8 as ro,ms as lo,mt as uo,_M as en,wu as ge,gl as go,mz as mo,zm as Vn,zX as vo,zj as Hn,uX as po,zU as nn,uL as So,zR as tn,hS as fo,UB as on,UC as ho,Gh as qn,hK as Io,_N as Co,Vr as Eo,_O as ko,A0 as Ee,A1 as yo,_P as xo,_Q as zn,z_ as bo,_R as jo,_S as Do,yg as Lo,_T as Ao}from"./zeni-epic-state-CiYCRFt8.js";import{M as Po}from"./MobileAppDrawer-ohji3E0D.js";import{q as me}from"./QBOConnectionScreen-WC7OnIde.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.js";import"./InboxNotificationsProvider-C4Xl3N_I.js";import"./useTaskManagerAccess-BNjTqV_h.js";import"./empty-CuWyrybz.js";import"./pdf-lib-B6v5xA2O.js";import"./index-COFn4Lui.js";import"./url-CRbSh4Tu.js";import"./index-Df2ds6q_.js";import"./decodeURIComponentSafe-B8wth54g.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]="fdd16e8d-e4d1-4d89-9266-7259722e3c69",t._sentryDebugIdIdentifier="sentry-dbid-fdd16e8d-e4d1-4d89-9266-7259722e3c69")}catch{}})();const $=({event:t,isReady:e=!0})=>e?a.jsx(nt,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function $o(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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:g,hasMore:f,items:S,nextCursor:h,auditLogEntityRouteOptions:D,auditLogListSortFieldOptions:b}=C(zt),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${n??""}/invoicing`,I=r.useCallback(((P,U)=>{const T=Qt(y,P,U,D);T!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:P,entityId:U,fromScreen:"audit_log"}),e(T))}),[D,e,y]);r.useEffect((()=>{const P=setTimeout((()=>d(s)),300);return()=>clearTimeout(P)}),[s]),r.useEffect((()=>{i&&t(He({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,t]);const j=g==="Not-Started"||g==="In-Progress"&&S.length===0,E=g==="In-Progress"&&S.length>0,F=g==="Completed";return N(g)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:F}),a.jsx(tt,{auditLogEntityRouteOptions:D,auditLogListSortFieldOptions:b,entries:S,hasMore:f,isLoading:j,isLoadingMore:E,searchValue:s,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{f&&h!=null&&t(He({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function pe(t,e=!1){const n=L(),i=C((c=>K(c).productNextCursor!=null)),s=C((c=>K(c).productNextCursor)),o=C((c=>K(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&s!=null&&n(se({cursor:s,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,s])}function Se(t,e,n,i){const[s,o]=r.useState(0),[c,d]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const v=l.current==="In-Progress";l.current=t,t==="Completed"&&v&&n!=null&&(d(!0),i(n))}),[t,n,i]),r.useEffect((()=>{c&&!e&&(d(!1),o((v=>v+1)))}),[c,e]),s}const Fo=new Set(["plan"]),wo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?s=>{i!==""&&t(gn({action:s,id:i}))}:void 0,onEditChange:s=>{i!==""&&t(Pe({id:i,localData:s}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),t(un({id:i}))},onSubFamilyLifecycleAction:(s,o)=>{i!==""&&t(Kt({action:o,id:s,parentItemId:i}))}}}))(it);function Ro(){const t=L(),e=A(),{item_id:n,tenantEmailDomain:i}=R(),[s]=G(),{areTenantIdsInSync:o}=_(),c=(d=s.get("kind"))!=null&&Fo.has(d)?d:"plan";var d;const l=C((k=>Ae(k,n))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(t(ce({id:n})),()=>{t(ce({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(ye({id:n,kind:c}))}),[o,n,c,t]);const g=r.useCallback((k=>t(ye({cacheOverride:!0,id:k,kind:c}))),[t,c]),f=Se(l.fetchState,l.isFormLoading,n,g),S=u==="Completed"&&!l.isFormLoading;pe(o,!0);const[h,D]=r.useState(S?n:void 0);r.useEffect((()=>{n!=null&&S&&D(n)}),[n,S]);const b=h!==n&&(u==="Not-Started"||u==="In-Progress"||l.isFormLoading);return N(u)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:S}),a.jsx(wo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:b,view:l},f)]})}const _o=new Set(["addon","charge","plan"]),To=new Set(["plan"]),Oo=O((function(t,e){const n=Ae(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,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:s}=e,o=s!=null?`${n}/catalog/${encodeURIComponent(s)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),t(ce({id:s})),e.navigate(`${n}/catalog`)},onChange:c=>{t(Pe({id:s,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),t(un({id:s}))}}}))(ot);function Mo(){const t=L(),e=A(),{item_id:n,tenantEmailDomain:i}=R(),[s]=G(),{areTenantIdsInSync:o}=_(),c=n!=null,d=s.get("type"),l=d!=null&&_o.has(d)?d:void 0,v=(u=s.get("kind"))!=null&&To.has(u)?u:"plan";var u;const g=C((f=>Ae(f,n)));return pe(o,!0),r.useEffect((()=>{o&&t(ye({id:n,kind:v}))}),[o,n,v,t]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||t(Pe({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const f=g.savedItemId??n,S=f!=null?`/${i}/invoicing/catalog/${encodeURIComponent(f)}`:`/${i}/invoicing/catalog`;e(S),t(ce({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),a.jsx(Oo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const No={addons:"addon",all:"item",charges:"charge",plans:"plan"},Uo=O((function(t,e){const n=K(t),i=e.activeTab==="plans",s=e.activeTab==="all",o=i?n.plans:s?[...n.plans,...n.products]:n.products,c=i||s&&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:s&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",s=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=No[e.activeTab];p.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(gn({action:Gt(d),id:c}))},onLoadMore:()=>{if(s)return e.planNextCursor!=null&&t(ze({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?ze({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(at);function Bo(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),f=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),S=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:S,type:"plan"})),[S]),D=r.useMemo((()=>({search:S,type:"addon|charge"})),[S]),b=C((P=>K(P))),k=b.planFilters.search,y=b.planSort,I=b.planNextCursor,j=b.productNextCursor,E=b.fetchState==="Completed",F=b.runningActionId??null;return r.useEffect((()=>{const P=setTimeout((()=>v(s)),300);return()=>clearTimeout(P)}),[s]),r.useEffect((()=>{i&&t(qe({cacheOverride:!1,planFilters:h,productFilters:D,planSort:f,productSort:f}))}),[i,t,h,D,f]),r.useEffect((()=>{i&&(S!==k||f?.field!==y?.field||f?.dir!==y?.dir)&&t(qe({cacheOverride:!0,planFilters:h,productFilters:D,planSort:f,productSort:f}))}),[k,y,i,t,h,D,S,f]),N(b.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),a.jsx(Uo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:s,sortState:u,planFilters:h,productFilters:D,sort:f,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:F,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Vo=O((function(t,e){const n=mn(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,s=i!=null?"edit":"create",o=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),t(re({id:i})),e.navigate(`${n}/discounts`)},onChange:c=>{t(Wt({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:s}),t(Zt({id:i}))}}}))(st);function Ho(){const t=L(),e=A(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),{fetchState:o,savedCouponId:c}=C((d=>mn(d,n)));return r.useEffect((()=>{s&&t(xe({id:n}))}),[s,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(re({id:n}))}}),[o,c,n,t,e,i]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCouponFormPage}),a.jsx(Vo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const qo=O((function(t){const e=vn(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(m.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:s=>{e(Sn(s))},onSubmit:()=>{const s=Yt(t.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:s.customer_id,lineItemCount:s.line_items?.length}),e(ei(s))}}}))(rt);function zo(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),[i]=G(),{areTenantIdsInSync:s}=_(),o=i.get("customerId"),c=C((I=>vn(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(pn),g=C((I=>Xt(I))),f=C(ve),S=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=f.fetchState==="Not-Started"||f.fetchState==="In-Progress"&&f.customers.length===0,D=S||h,b=g.fetchState==="Completed"&&f.fetchState==="Completed";r.useEffect((()=>(t(Qe()),()=>{t(Qe())})),[t]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,t(Sn({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{s&&t(Jt({cacheOverride:!1}))}),[s,t]);const y=r.useRef(d);return r.useEffect((()=>{const I=y.current;if(y.current=d,I!=="Completed"&&d==="Completed"){const j=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(j)}}),[d,v,e,n]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),D?a.jsx(ct,{}):a.jsx(qo,{navigate:e,tenantEmailDomain:n})]})}const Qo=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(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(lt);function Ko(){const t=L(),e=A(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),o=C((d=>ni(d,n??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{s&&n!=null&&t(ti({id:n}))}),[s,n,t]),N(o.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),a.jsx(Qo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const Go=O((function(t){const e=fn(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(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(oi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(dt);function Zo(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,creditNoteListFetchState:b}=C((y=>{const I=fn(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(s)),300);return()=>clearTimeout(y)}),[s]),r.useEffect((()=>{i&&t(Ke({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ke({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),a.jsx(Go,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(ii(y)),onSortChange:v})]})}const Qn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Wo=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:s=>{t(be({id:i,localData:s}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:s,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(s)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onDiscardEdit:()=>{t(X(le)),t(gi({id:i}))},onOpenAddress:()=>{const s=Qn(e.tenantEmailDomain??"",le,i),o=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:s=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),t(be({id:i,localData:s})),t(In({id:i}))},onFetchPaymentLinkEmailPreview:s=>t(ui({cacheOverride:s,customerId:i})),onSendPaymentLink:(s,o,c)=>t(di({body:c,customerId:i,email:s,subject:o})),onSubscriptionClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)}}}))(mt);function Xo(){const t=L(),e=A(),n=Z(),{customer_id:i,tenantEmailDomain:s}=R(),{areTenantIdsInSync:o}=_(),c=C((T=>$e(T,i))),d=c.pageFetchState.fetchState,l=d==="Completed"&&!c.isFormLoading,[v,u]=r.useState(!1),[g,f]=r.useState(!1),[S,h]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&h(i)}),[i,l]);const D=S===i,{plaidTokenFetchState:b,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:y,setupIntentFetchState:I,stripeConnected:j}=c.record,E=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const T=c.record.sendLinkState.fetchState;E.current!=="Error"&&T==="Error"&&t(ai({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),E.current=T}),[t,c.record.sendLinkState.fetchState]);const F=I.fetchState==="Error"?I.error?.message??"Failed to start card setup.":y.fetchState==="Error"?y.error?.message??"Failed to save payment method.":b.fetchState==="Error"?b.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&&(f(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(si({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&j&&t(Ge({customerId:i}))}),[o,i,t,j]);const P=r.useCallback((T=>t(hn({id:T}))),[t]),U=Se(c.fetchState,c.isFormLoading,i,P);return N(d)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),a.jsx(Wo,{customerId:i??"",editView:c,hasLoadedRecord:D,location:n,navigate:e,tenantEmailDomain:s,onAddPaymentMethod:()=>{t(ee()),i!=null&&j&&t(Ge({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),f(!0)}},U),a.jsx(ut,{errorMessage:F,isCreatingSetupIntent:I.fetchState==="In-Progress",isSaving:y.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:y.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:j,onChooseCard:()=>{i!=null&&t(ri({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:T=>{i!=null&&t(ci({customerId:i,data:T}))}}),a.jsx(gt,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:g,submitSucceeded:k.fetchState==="Completed",onClose:()=>{f(!1),t(ne())},onSubmit:({amount:T,description:Y})=>{i!=null&&t(li({amount:T,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:Y}))}})]})}const Jo=O((function(t,e){const n=$e(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,s=i!=null?"edit":"create",o=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),t(Cn({id:i})),t(X(le)),e.navigate(`${n}/customers`)},onChange:c=>{t(be({id:i,localData:c}))},onOpenAddress:()=>{const c=Qn(e.tenantEmailDomain??"",le,i),d=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:s}),t(In({id:i}))}}}))(vt);function Yo(){const t=L(),e=A(),n=Z(),{customer_id:i,tenantEmailDomain:s}=R(),{areTenantIdsInSync:o}=_(),{fetchState:c,savedCustomerId:d}=C((l=>$e(l,i)));return r.useEffect((()=>{o&&i!=null&&t(hn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${s}/invoicing/customers/${encodeURIComponent(l)}`:`/${s}/invoicing/customers`;e(v),t(Cn({id:i}))}}),[c,d,i,t,e,s]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomerFormPage}),a.jsx(Jo,{customerId:i,location:n,navigate:e,tenantEmailDomain:s})]})}const ea=O((function(t){const e=ve(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(m.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,s)=>{switch(s){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(En({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function na(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,customerListFetchState:b}=C((y=>{const I=ve(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(s)),300);return()=>clearTimeout(y)}),[s]),r.useEffect((()=>{i&&t(Ze({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ze({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),a.jsx(ea,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(mi(y)),onSortChange:v})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ta=O((function(t,e){const{filters:n,sessionId:i,view:s}=e,o=i==null?void 0:s.diagnosticsBySession[i],c=o?.fetch.fetchState??"Not-Started";return{diagnostics:o?.items??[],errorMessage:c==="Error"?o?.fetch.error?.message:void 0,expired:o?.expired??!1,filters:n,hasMore:o?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(o?.items.length??0)>0,session:Le(s,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:s,sessionId:o,tenantEmailDomain:c,view:d}=e,l=o==null?void 0:d.diagnosticsBySession[o],v=Le(d,o),u=d.actionStateByKind.retry?.fetchState==="In-Progress",g=d.actionStateByKind.rollback?.fetchState==="In-Progress",f=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>s(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&t(De({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&t(we(o))},onRollback:f?()=>{o!=null&&t(kn(o))}:void 0}}))(St);function ia(){const t=L(),e=A(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),[o,c]=r.useState({}),d=C(Fe),l=Le(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{s&&n!=null&&t(je(n))}),[s,t,n]),r.useEffect((()=>{if(!s||n==null)return;const S=setTimeout((()=>{t(De({...o,sessionId:n}))}),300);return()=>clearTimeout(S)}),[s,t,o,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!s||n==null||!u)return;const S=setInterval((()=>{t(je(n)),t(De({...o,sessionId:n}))}),3e3);return()=>clearInterval(S)}),[s,t,o,u,n]);const g=r.useMemo((()=>{if(n==null)return;const S=new URLSearchParams;o.moduleId!=null&&S.set("module_id",o.moduleId),o.level!=null&&S.set("level",o.level),o.outcome!=null&&S.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&S.set("search",o.search.trim());const h=S.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),f=v?.fetch.fetchState??"Not-Started";return N(f)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&f!=="Not-Started"}),a.jsx(ta,{downloadUrl:g,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const Kn=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=Kn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},oa=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:s,statusRows:o}=e.view;return{isLoading:!(s.fetchState!=="Not-Started"&&s.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,s=o=>{const c=o??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),s(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),s()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(we(o)),s(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(kn(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(ft);function aa(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),s=C(Fe);r.useEffect((()=>{i&&(t(vi()),t(yn()))}),[i,t]);const o=s.statusFetch.fetchState==="Completed"&&s.sessionsFetch.fetchState==="Completed";return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),a.jsx(oa,{navigate:e,tenantEmailDomain:n,view:s})]})}const sa=O((function(t,e){const{activeId:n,integrationsView:i,settings:s,view:o}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=o,v=i.externalConnections?.revenue?.find((g=>g.connectionName==="chargebee")),u=n!=null?d[n]:void 0;return{chargebeeConnected:s?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:s?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((g=>g.id===n)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:s}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded);const o=ae?.invoicingMicroServiceBaseUrl,c=o!=null&&o.length>0?o:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),t(fi())},onGoToIntegrations:()=>{i(`/${s}/invoicing/settings`)},onGoToOverview:()=>i(`/${s}/invoicing/overview`),onRetry:()=>{n!=null&&t(we(n))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),n!=null&&t(Si(n))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),t(pi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${s}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(ht);function ca(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),s=C(pn),o=C(Re).companyId??ke.getSignedInUserTenant(n??"")?.companyId,c=C((S=>xn(S,o))),d=C(Fe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((S=>S.id===v)):void 0;r.useEffect((()=>{i&&(t(_e()),t(yn()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const S=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(Kn(h))}catch{return null}})(n);S!=null&&t(ie(S))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const g=u?.status,f=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!f)return;const S=setInterval((()=>{t(je(v))}),3e3);return()=>clearInterval(S)}),[i,v,f,t]),r.useEffect((()=>{g==="done"&&(t(ie(null)),oe(n,null))}),[t,g,n]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDataImportMigratePage}),a.jsx(sa,{activeId:v,integrationsView:c,navigate:e,settings:s,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ra=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:s=>{t(bn({action:s,id:i}))},onSaveEdit:s=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),t(Ii({data:s,id:i}))}}}))(It);function la(){const t=L(),e=A(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),o=C((h=>hi(h,n))),c=o.actionState.fetchState==="In-Progress",d=o.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&u(n)}),[n,l]);const g=v===n;r.useEffect((()=>(t(re({id:n})),()=>{t(re({id:n}))})),[n,t]),r.useEffect((()=>{s&&t(xe({id:n}))}),[s,n,t]);const f=r.useCallback((h=>t(xe({cacheOverride:!0,id:h}))),[t]),S=Se(o.fetchState,o.isFormLoading,n,f);return N(d)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),a.jsx(ra,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},S)]})}const da=O((function(t){const e=jn(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(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,s)=>{t(bn({action:s,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Ei({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ct);function ua(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=jn(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,couponListFetchState:j.fetchState,runningDiscountActionId:j.runningActionId??null}}),H),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(s)),300);return()=>clearTimeout(I)}),[s]),r.useEffect((()=>{i&&t(We({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(We({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),a.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>t(Ci(I)),onSortChange:v})]})}const ga=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,s=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:o=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCancel:s?()=>t(q({action:"cancel",id:i})):void 0,onResolve:s?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(q({action:"resolve",id:i}))}:void 0,onResume:s?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(q({action:"resume",id:i}))}:void 0,onRetry:s?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(q({action:"retry",id:i}))}:void 0}}))(kt);function ma(){const t=L(),e=A(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),o=C((E=>ki(E,n??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[f,S]=r.useState(),[h,D]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),S(void 0),D(!1)}),[]),k=r.useCallback((()=>{if(n==null)return;t(yi({id:n})),v("idle"),g(!1);const E=o.emailPreview.preview;S(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),D(!0)}),[n,t,o.emailPreview.preview]),y=r.useCallback((E=>{n!=null&&l!=="pending"&&(g(!1),v("pending"),p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(q({action:"send-email",body:E,id:n})))}),[n,t,l]),I=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{s&&n!=null&&t(xi({id:n}))}),[s,n,t]),r.useEffect((()=>{s&&d!=null&&t(Te({invoiceId:d}))}),[s,d,t]),r.useEffect((()=>{v("idle"),g(!1),S(void 0),D(!1)}),[n]),r.useEffect((()=>{s||(v("idle"),g(!1),S(void 0),D(!1))}),[s]),r.useEffect((()=>{h&&f==null&&o.emailPreview.preview!=null&&S({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,f,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(n!=null&&t(bi({id:n})),b()):u&&o.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[n,b,t,l,u,o.actionState.fetchState]);const j=d!=null&&o.linkedInvoice?.id===d?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),a.jsx(ga,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:j,onSendEmail:k}),a.jsx(Et,{initialDraft:f,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:b,onSend:y,open:h,preview:I,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const va=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",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(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,s)=>{s!=="retry"&&s!=="resume"&&s!=="resolve"&&s!=="cancel"||t(q({action:s,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Di({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(yt);function pa(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,dunningCaseListFetchState:b}=C((y=>{const I=Dn(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(s)),300);return()=>clearTimeout(y)}),[s]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),a.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(ji(y)),onSortChange:v})]})}const Sa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),t(Ai({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
|
|
2
2
|
`).map((o=>o.trim())).filter((o=>o!=="")).map((o=>({note:o}))):void 0,po_number:s.po_number!==""?s.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceReminderSent,{invoiceId:i}),t(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:s}))}}}))(xt);function fa(){const t=L(),e=A(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),o=C((g=>Ln(g,n??""))),c=o.pageFetchState.fetchState,d=c==="Completed",[l,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const u=l===n;return r.useEffect((()=>{s&&n!=null&&t(Li({invoiceId:n}))}),[s,n,t]),N(c)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),a.jsx(Sa,{invoiceId:n??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:o})]})}const ha=O((function(t){const e=An(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(m.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,s)=>{switch(s){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,s)=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:s}))},onLoadMore:()=>{e.nextCursor!=null&&t(Pn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function Ia(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,invoiceListFetchState:b,voidingInvoiceId:k}=C((I=>{const j=An(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:I.invoicingInvoiceListState.sort,nextCursor:j.nextCursor,invoiceListFetchState:j.fetchState,voidingInvoiceId:j.runningActionId}}),H),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(s)),300);return()=>clearTimeout(I)}),[s]),r.useEffect((()=>{i&&t(Ie({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ie({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingInvoicesListPage,isReady:y}),a.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,voidingInvoiceId:k,onSearchChange:o,onStatusChange:I=>{t(Pi(I)),t(Ie({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v})]})}function an(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),i=jt(),s=ln(),[o,c]=r.useState(!1),{acceptTermsState:d,status:l}=C($n),v=$i(i?.loggedInUserRoleMap),u=`/${n}/invoicing`,g=f=>{c(f)};return l==="completed"?a.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?a.jsx(B,{to:`${u}/settings`,replace:!0}):a.jsxs(a.Fragment,{children:[a.jsx(Po,{isAppContentDrawerOpen:o,handleDrawerToggle:g}),a.jsx(Dt,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:s("invoicing_promo"),onAcceptClick:()=>{t(Fi())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{g(!0)}})]})}const Ca=O((function(t,e){const n=Fn(t,e.invoiceId),{invoice:i,localData:s,reasonCodeOptions:o,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:s,reasonCodeOptions:o,typeOptions:d}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:s=>{t(Oi({localData:s}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Ti())}}}))(Lt);function Ea(){const t=L(),e=A(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),{fetchState:o,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=C((S=>Fn(S,n??""))),u=`/${i}/invoicing`,g=r.useRef(null);r.useEffect((()=>{t(wi()),g.current=null}),[t,n]),r.useEffect((()=>{s&&n!=null&&t(Te({invoiceId:n}))}),[s,t,n]),r.useEffect((()=>{c!=null&&n!=null&&o==="Completed"&&g.current!==n&&(g.current=n,t(Ri({localData:_i(c)})))}),[t,o,c,n]);const f=r.useRef(v.fetchState);return r.useEffect((()=>{const S=f.current;f.current=v.fetchState,S!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),a.jsx(Ca,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const ka=O((function(t){return{invoicingOverview:wn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{t(Rn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(At);function ya(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),o=C((c=>wn(c).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Rn(s))}),[i,t,s]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingOverviewPage,isReady:o}),a.jsx(ka,{navigate:e,selectedPeriod:s,tenantEmailDomain:n})]})}const xa=O((function(t){const e=_n(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(m.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(Ni({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Pt);function ba(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:f,appliedSearch:S,appliedSort:h,nextCursor:D,transactionListFetchState:b,transactions:k}=C((F=>{const P=_n(F);return{activeType:P.activeTab,appliedSearch:P.filters.search,appliedSort:P.sort,nextCursor:P.nextCursor,transactionListFetchState:P.fetchState,transactions:P.transactions}}),H),y=b==="Completed",I=`/${n}/invoicing`,j=r.useCallback((F=>{const P=k.find((T=>T.id===F)),U=P?.linkedInvoices?.[0]?.invoiceID??P?.invoiceID;U!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${I}/invoices/${encodeURIComponent(U)}`))}),[e,I,k]),E=r.useCallback((F=>{const P=k.find((U=>U.id===F))?.customerID;P!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:P,fromScreen:"payments_list",toScreen:"customer"}),e(`${I}/customers/${encodeURIComponent(P)}`))}),[e,I,k]);return r.useEffect((()=>{const F=setTimeout((()=>d(s)),300);return()=>clearTimeout(F)}),[s]),r.useEffect((()=>{i&&t(Ce({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ce({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingPaymentsListPage,isReady:y}),a.jsx(xa,{navigate:e,tenantEmailDomain:n,activeType:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onTypeChange:F=>{t(Mi(F)),t(Ce({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v,onViewTransactionCustomer:E,onViewTransactionInvoice:j})]})}const ja=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function sn(){const t=L(),e=A(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:s}=_(),o=n!=null&&n!=="",c=C(ve),d=C((E=>Ui(E))),l=C(Bi),v=C((E=>Ln(E,n??""))),u=v.invoice,g=`/${i}/invoicing`,f=r.useRef(null),S=r.useRef("");r.useEffect((()=>{t(Vi()),f.current=null,S.current=""}),[t,n]),r.useEffect((()=>{s&&t(o&&n!=null?Te({invoiceId:n}):En({filters:{},keepExistingListItems:!1}))}),[s,t,n,o]),r.useEffect((()=>{o&&u!=null&&n!=null&&v.fetchState==="Completed"&&f.current!==n&&(f.current=n,t(Hi({contextInvoiceId:n,localData:qi(u)})))}),[t,u,n,v.fetchState,o]),r.useEffect((()=>{if(o)return;const E=d.localData.customerId;E!==""&&E!==S.current&&(S.current=E,t(Pn({filters:{customerId:E},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&t(Je({localData:{...d.localData,customerId:E,invoiceToLink:""}})))}),[t,d.localData,o]);const h=r.useRef(l.fetchState);r.useEffect((()=>{const E=h.current;if(h.current=l.fetchState,E!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${g}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${g}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,g]);const D=r.useMemo((()=>c.customers.map((E=>({id:E.id,name:ja(E)})))),[c.customers]),b=C((E=>zi(E,d.localData.customerId))),k=r.useMemo((()=>b.map((E=>{return{amountDue:(F=E.amountDue,P=Qi.currencySymbol,wt("0,0.00",F,P)),amountDueValue:E.amountDue,id:E.id,label:E.invoiceNumber};var F,P}))),[b]),y=r.useMemo((()=>{if(!o||u==null)return;const E=u.currencyCode??"USD",F=u.amountDue?.amount??0;return{amountDue:$t("0,0.00",u.amountDue),amountDueValue:F,currencyCode:E,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,o]),I=o?`${g}/invoices/${encodeURIComponent(n??"")}`:`${g}/payments`,j=!o||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingRecordPaymentPage,isReady:j}),a.jsx(Ft,{customers:D,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:y,invoiceOptions:k,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:o?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(I)},onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentCancelled),e(I)},onChange:E=>{t(Je({localData:E}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:o?n:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),t(Ki(o?n??void 0:void 0))}})]})}const Gn=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Da=O((function(t,e){const{editView:n}=e,i=n.subscription,s=i?.status,o=s!=null&&e.commercialEditAllowedFromStatuses.includes(s);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:o,charges:n.charges,coupons:n.coupons,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,s=i!=="",o=(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),t(On({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:c=>{t(de({id:i,localData:c}))},onChangeTermEnd:s?c=>{const d=c?.trim()??"";d!==""&&o("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(X(ue)),t(Wi({id:i}))},onOpenAddress:()=>{const c=Gn(e.tenantEmailDomain??"",ue,i),d=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${n}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionEdited,{subscriptionId:i}),t(de({id:i,localData:c})),t(Tn({id:i}))},onCancelSubscription:s?c=>{o("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:s?(c,d)=>{c!=="pause"?o(c):o(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Rt);function La(){const t=L(),e=A(),n=Z(),{subscription_id:i,tenantEmailDomain:s}=R(),{areTenantIdsInSync:o}=_(),c=C((k=>Oe(k,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,g=u==="Completed"&&!c.isFormLoading,[f,S]=r.useState(g?i:void 0);r.useEffect((()=>{i!=null&&g&&S(i)}),[i,g]);const h=f===i;pe(o),r.useEffect((()=>{o&&i!=null&&t(Gi({id:i}))}),[o,i,t]);const D=r.useCallback((k=>t(Zi({id:k}))),[t]),b=Se(c.fetchState,c.isFormLoading,i,D);return N(u)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSubscriptionDetailPage,isReady:g}),a.jsx(Da,{hasLoadedRecord:h,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:n,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:s},b)]})}const Aa=O((function(t,e){const n=Oe(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,s=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionFormCancelled),t(Mn({id:i})),t(X(ue)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:o=>{t(de({id:i,localData:o}))},onOpenAddress:()=>{const o=Gn(e.tenantEmailDomain??"",ue,i),c=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionSaved,{mode:s}),t(Tn({id:i}))}}}))(_t);function Pa(){const t=L(),e=A(),n=Z(),{subscription_id:i,tenantEmailDomain:s}=R(),[o]=G(),{areTenantIdsInSync:c}=_(),d=o.get("customerId"),{fetchState:l,savedSubscriptionId:v}=C((f=>Xi(f,i))),u=C((f=>Oe(f,i).localData));pe(c),r.useEffect((()=>{c&&t(Ji({subscriptionId:i}))}),[c,i,t]);const g=r.useRef(!1);return r.useEffect((()=>{g.current||i!=null||d==null||d===""||u.customerId!==""||(g.current=!0,t(de({id:i,localData:{...u,customerId:d}})))}),[d,i,u,t]),r.useEffect((()=>{if(l==="Completed"){const f=v??i,S=f!=null?`/${s}/invoicing/subscriptions/${encodeURIComponent(f)}`:`/${s}/invoicing/subscriptions`;e(S),t(Mn({id:i}))}}),[l,v,i,t,e,s]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSubscriptionFormPage}),a.jsx(Aa,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:s})]})}const $a=O((function(t){const e=Nn(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=(s,o,c)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:o,subscriptionId:s}),t(On({action:o,id:s,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(s,o)=>{const c=o?.trim()??"";c!==""&&i(s,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(s,o,c)=>{o!=="pause"?i(s,o):i(s,o,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(s,o)=>{i(s,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionRowClicked,{subscriptionId:s}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&t(no({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Tt);function Fa(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[s,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:f,appliedSearch:S,appliedSort:h,nextCursor:D,subscriptionListFetchState:b,runningActionSubscriptionId:k}=C((j=>{const E=Nn(j);return{activeStatus:E.activeTab,appliedSearch:E.filters.search,appliedSort:E.sort,nextCursor:E.nextCursor,subscriptionListFetchState:E.fetchState,runningActionSubscriptionId:E.runningActionId??null}}),H),y=b==="Completed";r.useEffect((()=>{const j=setTimeout((()=>d(s)),300);return()=>clearTimeout(j)}),[s]),r.useEffect((()=>{i&&t(Ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==S||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ye({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,S,h]);const I=r.useRef(k);return r.useEffect((()=>{const j=I.current!=null&&k==null;I.current=k,j&&i&&t(Yi())}),[k,i,t]),N(b)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSubscriptionsListPage,isReady:y}),a.jsx($a,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:s,sortState:l,filters:g,sort:u,nextCursor:D,runningActionSubscriptionId:k,onSearchChange:o,onStatusChange:j=>t(eo(j)),onSortChange:v})]})}const wa=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:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onInvoiceClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:s,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(s)}`)},onSubscriptionClick:s=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(m.Event.invoicingTransactionCaptured,{transactionId:i}),t(oo({action:"capture",id:i}))}:void 0}}))(Ot);function Ra(){const t=L(),e=A(),{tenantEmailDomain:n,transaction_id:i}=R(),{areTenantIdsInSync:s}=_(),o=C((d=>to(d,i??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{s&&i!=null&&t(io({id:i}))}),[s,i,t]),N(o.fetchState)?a.jsx(M,{}):a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingTransactionDetailPage,isReady:c}),a.jsx(wa,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function Zn(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:s=!1}=t,o=L(),{areTenantIdsInSync:c}=_(),d=C(Me),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(s&&v!=="Not-Started"||o(Un()),n&&o(ao()))}),[c,o,e,n,s]),r.useEffect((()=>{e&&c&&l&&i&&o(so())}),[c,o,e,l,i]),{isQboConnected:l,qboView:d}}const _a={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function J(t){const e=L(),{areTenantIdsInSync:n}=_(),{tenantEmailDomain:i}=R(),{fetchState:s,fieldHelp:o,logoFile:c,saveState:d,settings:l,stripeConnectState:v}=C(co),{configError:u,configFetchState:g,dunningScheduleActionOptions:f,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:h,qboSyncStatusOptions:D}=C(Bn),b=C(Me);Zn({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const k=C(Re),y=t==="dunning"||t==="quickbooks",I=k.companyId??ke.getSignedInUserTenant(i??"")?.companyId,j=C((w=>xn(w,I))),E=ro(k.userRole??[]),F=k.tenantId??"",P=ke.getSignedInUser(),U={userId:P?.userId??"",sessionId:P?.zeniSessionId??"",tenantId:F},T=c?.fileId,Y=C((w=>T!=null&&T!==""?lo(w,T):void 0)),Ne=C((w=>T!=null&&T!==""?uo(w,T):void 0)),Wn=T!=null&&T!==""&&Y!=null?{[T]:Y}:{},Xn=T!=null&&T!==""&&Ne!=null?{[T]:Ne}:{};r.useEffect((()=>(e(en()),()=>{e(en())})),[e]),r.useEffect((()=>{n&&(s!=="Not-Started"&&s!=="Error"||e(_e()))}),[n,e,s]),r.useEffect((()=>{n&&y&&g==="Not-Started"&&e(ge())}),[n,e,g,y]),r.useEffect((()=>{if(!n)return;const w=P?.userId;w!=null&&w!==""&&F!==""&&Ve.shouldFetchActiveTenant(F)&&(Ve.markActiveTenantFetchStarted(F),e(go(w,F,P?.zeniSessionId)))}),[n,e,P?.userId,P?.zeniSessionId,F]);const Jn=f.length>0||S.length>0,Yn=s==="Not-Started"||s==="In-Progress"&&l==null||y&&!Jn&&(g==="Not-Started"||g==="In-Progress"),et=s==="Completed"&&(!y||g==="Completed"),Ue=j.externalConnections?.revenue?.find((w=>w.connectionName==="chargebee"))?.connectionId,fe=ae?.invoicingMicroServiceBaseUrl,Be=fe!=null&&fe.length>0?`${fe}/1.0/webhooks/stripe`:"",he={deleteConnectionError:j.externalConnections?.deleteConnectionError?.message,deleteConnectionState:j.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:j,isAdmin:E,isStripeBusy:v.fetchState==="In-Progress",onConnectStripe:w=>e(tn(w)),onDisconnect:(w,z)=>{F!==""&&e(Io(F,w,on(z)))},onDisconnectStripe:()=>e(nn()),onReconnectQBO:()=>{const w=k.tenantEmailDomain??i??"";me.init("/connection/auth",w),me.handleClick()},onRefreshQBO:()=>{j.integrations.refreshQBO.fetchState!=="In-Progress"&&e(qn())},onSaveChargeBeeCredentials:(w,z)=>{Ue!=null&&F!==""&&e(fo(F,Ue,on("revenue"),ho("chargebee"),{api_key:w,site:z}))},saveChargeBeeError:j.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:j.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Be};return{authParams:U,deleteFileStatusById:Wn,fieldHelp:o,dunningScheduleActionOptions:f,filesEndPoint:ae?.fileMicroServiceBaseUrl??"",integrationsSectionProps:he,isInvoicingPageReady:et,isLoading:Yn,isSaving:d.fetchState==="In-Progress",isStripeBusy:v.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:h,qboSyncStatusOptions:D,qboView:b,saveErrorMessage:d.fetchState==="Error"?d.error?.message??"Failed to save settings.":y&&g==="Error"?u?.message??"Failed to load invoicing configuration.":void 0,settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Be,updateFileStatusById:Xn,onConnectStripe:w=>e(tn(w)),onDeleteFile:w=>e(So(w,F)),onDisconnectStripe:()=>e(nn()),onEditFileName:(w,z)=>e(po(w,z.split(".")[0],F)),onReconnectQBO:he.onReconnectQBO,onRefreshQBO:he.onRefreshQBO,onRetryQboSyncTask:w=>e(Hn(w)),onSave:w=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:t??"hub"}),e(vo({settings:w,snackbarSection:_a[t??""]}))},onStartQboBackfill:w=>e(Vn(w)),updateFilesEntity:w=>{p.trackInvoicingActionClick(m.Event.invoicingLogoUploaded),e(mo({files:w}))}}}function cn({appContent:t}){const e=A(),n=Z(),i=L(),{tenantEmailDomain:s}=R(),o=J("branding"),c=C((v=>Co(v))),d=C((v=>Eo(Ee,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(ko()),i(X(Ee)))}),[c.saveState.fetchState,i]);const l=dn(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),a.jsx(Mt,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:c.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(xo({localData:v}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{const v=`/${s}/invoicing/settings/branding/${Ee}/`,u=W(n.state?.pathnameStackToGoBack,n.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(yo()),updateFilesEntity:o.updateFilesEntity})]})}function Ta(){const t=A(),e=J("dunning");return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),a.jsx(Nt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Oa(){const t=A(),e=J("integrations");return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),a.jsx(Ut,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ma(){const t=A(),e=J("payment-destination");return a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),a.jsx(Bt,{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 Na=O((function(t){const e=zn(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(Do({localData:e}))},onReset:()=>{t(jo())},onRetryTask:e=>{t(Hn(e))},onSave:()=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:"quickbooks"}),t(bo())},onStartBackfill:e=>{t(Vn(e))}}}))(Vt);function Ua(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),i=C(Re),{configFetchState:s,settingsFetchState:o}=C(zn);return r.useEffect((()=>{o!=="Not-Started"&&o!=="Error"||t(_e())}),[t,o]),r.useEffect((()=>{s==="Not-Started"&&t(ge())}),[s,t]),Zn({fetchSyncHealth:!0,loadAccountingPickers:!0}),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage}),a.jsx(Na,{onBackClick:()=>e(".."),onReconnect:()=>{me.init("/connection/auth",i.tenantEmailDomain??n??""),me.handleClick()},onRefresh:()=>t(qn())})]})}const Ba={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Va(){const t=ln(),e=L(),n=A(),[i,s]=G(),o=J(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=C(Bn),g=i.get("tab");return r.useEffect((()=>{if(g==null)return;const f=Ba[g];s({},{replace:!0}),f!=null&&n(f,{replace:!0})}),[g,n,s]),a.jsxs(a.Fragment,{children:[a.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),a.jsx(Ht,{analytics:p,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:d,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Lo())}})]})}function rn(){return a.jsxs(te,{children:[a.jsx(x,{index:!0,element:a.jsx(Va,{})}),a.jsx(x,{path:"payment-destination",element:a.jsx(Ma,{})}),a.jsx(x,{path:"branding",element:a.jsx(cn,{})}),a.jsx(x,{path:"branding/:addressType",element:a.jsx(cn,{appContent:a.jsx(Q,{isSubPage:!0,hideAddressBackButton:!0})})}),a.jsx(x,{path:"integrations",element:a.jsx(Oa,{})}),a.jsx(x,{path:"dunning",element:a.jsx(Ta,{})}),a.jsx(x,{path:"quickbooks",element:a.jsx(Ua,{})}),a.jsx(x,{path:"*",element:a.jsx(B,{to:"..",replace:!0})})]})}function Ss(){const t=L(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),{enableState:s,fetchState:o,status:c}=C($n),d=dn(s.fetchState),l=`/${n}/invoicing`,v=r.useRef(!1),u=C((g=>Me(g).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||v.current||(v.current=!0,t(ge({cacheOverride:!1}))):t(ge({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&u==="Not-Started"&&t(Un())}),[i,t,u]),r.useEffect((()=>{d==="In-Progress"&&s.fetchState==="Completed"&&(e(`${l}/catalog`),t(Ao()))}),[d,s.fetchState,l,t,e]),c==null&&o!=="Error"?a.jsx(qt,{fetchState:"In-Progress"}):c==="not_started"?a.jsxs(te,{children:[a.jsx(x,{path:"promo",element:a.jsx(an,{})}),a.jsx(x,{path:"*",element:a.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?a.jsxs(te,{children:[a.jsx(x,{path:"promo",element:a.jsx(an,{})}),a.jsx(x,{path:"settings/*",element:a.jsx(rn,{})}),a.jsx(x,{path:"*",element:a.jsx(B,{to:`${l}/settings`,replace:!0})})]}):a.jsxs(te,{children:[a.jsx(x,{path:"/",element:a.jsx(B,{to:"overview",replace:!0})}),a.jsx(x,{path:"overview",element:a.jsx(ya,{})}),a.jsx(x,{path:"promo",element:a.jsx(B,{to:`${l}/overview`,replace:!0})}),a.jsx(x,{path:"customers",element:a.jsx(na,{})}),a.jsx(x,{path:"customers/new",element:a.jsx(Yo,{})}),a.jsx(x,{path:"customers/new/:addressType",element:a.jsx(Q,{})}),a.jsx(x,{path:"customers/:customer_id",element:a.jsx(Xo,{})}),a.jsx(x,{path:"customers/:customer_id/:addressType",element:a.jsx(Q,{})}),a.jsx(x,{path:"subscriptions",element:a.jsx(Fa,{})}),a.jsx(x,{path:"subscriptions/new",element:a.jsx(Pa,{})}),a.jsx(x,{path:"subscriptions/new/:addressType",element:a.jsx(Q,{})}),a.jsx(x,{path:"subscriptions/:subscription_id",element:a.jsx(La,{})}),a.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:a.jsx(Q,{})}),a.jsx(x,{path:"invoices",element:a.jsx(Ia,{})}),a.jsx(x,{path:"invoices/create",element:a.jsx(zo,{})}),a.jsx(x,{path:"invoices/:invoice_id",element:a.jsx(fa,{})}),a.jsx(x,{path:"invoices/:invoice_id/record-payment",element:a.jsx(sn,{})}),a.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:a.jsx(Ea,{})}),a.jsx(x,{path:"payments",element:a.jsx(ba,{})}),a.jsx(x,{path:"payments/record",element:a.jsx(sn,{})}),a.jsx(x,{path:"payments/:transaction_id",element:a.jsx(Ra,{})}),a.jsx(x,{path:"credits",element:a.jsx(Zo,{})}),a.jsx(x,{path:"credits/:credit_note_id",element:a.jsx(Ko,{})}),a.jsx(x,{path:"discounts",element:a.jsx(ua,{})}),a.jsx(x,{path:"discounts/new",element:a.jsx(Ho,{})}),a.jsx(x,{path:"discounts/:coupon_id",element:a.jsx(la,{})}),a.jsx(x,{path:"dunning",element:a.jsx(pa,{})}),a.jsx(x,{path:"dunning/:case_id",element:a.jsx(ma,{})}),a.jsx(x,{path:"catalog",element:a.jsx(Bo,{})}),a.jsx(x,{path:"catalog/new",element:a.jsx(Mo,{})}),a.jsx(x,{path:"catalog/:item_id",element:a.jsx(Ro,{})}),a.jsx(x,{path:"settings/*",element:a.jsx(rn,{})}),a.jsx(x,{path:"audit_log",element:a.jsx($o,{})}),a.jsx(x,{path:"data_import",element:a.jsx(aa,{})}),a.jsx(x,{path:"data_import/migrate",element:a.jsx(ca,{})}),a.jsx(x,{path:"data_import/:sessionId",element:a.jsx(ia,{})}),a.jsx(x,{path:"*",element:a.jsx(M,{})})]})}export{Ss as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t}from"./liveblocks-
|
|
1
|
+
import{j as t}from"./liveblocks-BuehHs6O.js";import{i as S,l as g,h as C,g as y,u as ee,t as te,j as E,N as ae,n as ne,o as p}from"./core-CBgcohKl.js";import{Uu as k,Uv as v,Uw as T,Jy as D,Jk as U,Ux as B,Uy as oe,Uz as ie,Jo as se,gi as $,Jv as le,Js as re}from"./zeni-epic-state-CiYCRFt8.js";import{a2 as x,H as r,a3 as de,k as j,_ as G,a4 as ce,a5 as me,a6 as pe,p as J,o as ue,S as he,a7 as ge,O as xe,E as fe,e as we,a8 as be,a9 as Se,a0 as ye,aa as ke,ab as ve,ac as je,ad as $e}from"./index-Dxpayzr2.js";import{n as m}from"./mui-Cb9eDKBr.js";import f from"./NotFoundScreen-BtojPFV3.js";import{a as I}from"./sentry-D8HyV7mS.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="b542e5ff-f569-4c94-ab05-47235204c79f",e._sentryDebugIdIdentifier="sentry-dbid-b542e5ff-f569-4c94-ab05-47235204c79f")}catch{}})();const Ie=m.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
height: 100%;
|
|
4
4
|
width: 100%;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as u}from"./liveblocks-
|
|
1
|
+
import{j as u}from"./liveblocks-BuehHs6O.js";import{a as g}from"./sentry-D8HyV7mS.js";import{u as O,g as _,h as w,t as V,j as l,N as L}from"./core-CBgcohKl.js";import{z as r,E as M,G as P,U as A,k as N,V as $,$ as q,a0 as G,Y as R}from"./index-Dxpayzr2.js";import{fF as W,TZ as Y,Uq as Z,Uh as B,gi as H,gk as J,Um as K,gU as Q,dj as X,Ur as ee,Us as te}from"./zeni-epic-state-CiYCRFt8.js";import{n as ne}from"./mui-Cb9eDKBr.js";import{u as se}from"./useDeviceId-BI6f3BPa.js";import{f as ae}from"./analyticsHelper-CNF4X1L3.js";import{t as ie}from"./getLocaleForTenant-DJlcQPmW.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.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]="61d49e01-f580-4606-8e7e-75decca31fbc",t._sentryDebugIdIdentifier="sentry-dbid-61d49e01-f580-4606-8e7e-75decca31fbc")}catch{}})();const T=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Te(){const t=O(),a=_(),m=w(),[y]=V(),n=y.get("token"),p=y.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:C,magicLinkEmail:c,verifyDeviceFetchState:x,resendVerifyDeviceOTPFetchState:z}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),b=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))),k=l((e=>Y(e))),D=r.getSignedInUser(),v=M().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&T(n,p)&&i!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(Z(n,i,f)))}),[n,p,t,i,f,s?.zeniSessionId]),g.useEffect((()=>{h!=="In-Progress"||S!=="Completed"&&b!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants(B(k.tenantsInOrder),s.zeniSessionId),H(s.userId,s.zeniSessionId,o.tenantId),t(J(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(K("Completed")),P.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,k.tenantsInOrder),Q().then((()=>{const e=R();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin($.Event.loginSuccess,"email",X(o.productSettings))}),2e3))}),[h,S,b,s,o,k,v,a.state,t]);const E=g.useCallback((()=>{m("/signin/auth")}),[m]),j=g.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),F=g.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 u.jsx(q,{phoneNumber:C,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:E});if(h==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||D!=null){const e=a.state?.origin??"/";return u.jsx(L,{to:e,state:{...a.state,origin:""}})}if(!T(n,p)||f==null||I==="Error"){const e=a.state?.origin??"/",U=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(L,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:U,magicLinkExpired:!U&&(r.isMagicLinkTriggered(n??"")||I==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.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-BuehHs6O.js";import{a as f}from"./sentry-D8HyV7mS.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as F}from"./core-CBgcohKl.js";import{fF as ne,T_ as Ue,T$ as se,g9 as xe,fE as Ne,U8 as Pe,U1 as Re,U2 as Ve,p$ as Oe,gm as Le,U5 as h,Ua as je,Ub as K,gn as Ze,Uc as ze,Eb as qe,h1 as He,cV as Ye,Ud as Qe,g8 as We,go as Je}from"./zeni-epic-state-CiYCRFt8.js";import{w as Ke,i as Xe,O as ea,o as aa,c as ta,e as na,u as sa,S as c,f as oa,Q as ia,z as ra,d as da,l as ca,N as la,r as ua,n as fa,q as X,L as ma,C as ba,D as ha,p as g,k as ee,x as pa,I as ae,A as Sa,B as ga}from"./index-Dxpayzr2.js";import{D as Ea}from"./mui-Cb9eDKBr.js";import{u as ka}from"./InboxNotificationsProvider-C4Xl3N_I.js";import{u as Ca}from"./useTaskManagerAccess-BNjTqV_h.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]="994bf8b4-2edc-472f-b29c-86d4a830f60a",l._sentryDebugIdIdentifier="sentry-dbid-994bf8b4-2edc-472f-b29c-86d4a830f60a")}catch{}})();const Ta=Ke((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),E=ea(),n=Me(),B=xe(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:k}=Ca(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Ne(e))),{status:ie}=t(Pe),G=$.uiState.currentChatSessionId,C=na(),{setLoading:re}=sa(),[w,M]=f.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,U=F("/:tenantEmailDomain/reports")!==null,m=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:x}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,x),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),N=t((e=>Re(e))),{isFeatureEnabled:T}=d(c.isReferralFeatureEnabled),v=t((e=>Ve(e)));f.useEffect((()=>{C&&T&&!m&&v.fetchState==="Not-Started"&&r(Oe(!0))}),[C,T,v.fetchState,m]);const D=t((e=>e.tenantState)),fe=t((e=>D.fetchState==="Completed"?Le(e):[])),S=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:me}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:be}=d(c.isArAgingFeatureEnabled),P=ia(),{isFeatureEnabled:he}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarNewYearAnimationEnabled),Ee=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>h(e).totalUnreadCount)),Ce=t((e=>h(e).reducedFetchCountState)),R=t((e=>h(e).notificationDetailsByTab.tasks.uiState.unreadCount)),V=t((e=>h(e).notificationDetailsByTab.comments.uiState.unreadCount)),O=t((e=>h(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>h(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:L,isLoading:j,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Te}=ka();f.useEffect((()=>{const e=setTimeout((()=>Te?.()),0);return()=>clearTimeout(e)})),f.useEffect((()=>{if(j===!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)}),[j,Z,z]),f.useEffect((()=>{C&&k&&!m&&O.fetchState==="Not-Started"&&B.tenantId!=null&&r(je("task_manager","dashboard"))}),[C,k,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:Ce,count:ke},q=s!=null?ra.getSignedInUserTenant(s):null,H=t((e=>q?.tenantId!=null?Ze(e,q.tenantId):void 0)),b=[];me===!1&&b.push("accounts_payable_aging"),be===!1&&b.push("accounts_receivable_aging"),b.push("zeni_accounts_promo_card","treasury_promo_card"),T===!1&&b.push("rewards_card"),P===!1&&b.push("expense_automation_card");const Y=t((e=>ze(e,b).fetchState)),Q=t((e=>qe(e).fetchState)),ye=A&&(Y==="Completed"||Y==="Error")||U&&(Q==="Completed"||Q==="Error")||!A&&!U?void 0:"disabled",we=f.useMemo((()=>He(o.userRole)),[o.userRole]),Ae=Ye(we),ve=o?.rewardsLastViewedTime==null,De=p?.userEmail!=null&&N.fetchState==="Completed"&&Qe(N.notificationSettings,p.userEmail,x,o,k),W=da(),Fe=W&&ca(a);return _.jsx(Ea,{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:X(a),isInvoicing:fa(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Ee,isNotificationsTabVisible:De,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:P,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:T,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:W,onNotificationIconClick:()=>{i(!1);let e=R===0&&V>0?"notifications/comments":"notifications/tasks";X(a)&&(e=R===0&&V>0?"../../notifications/comments":"../../notifications/tasks");const u=g(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=g(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:g(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=g(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=g(a.state?.pathnameStackToGoBack,a.pathname),J=e.type,_e=ae(J)&&J!=="command_center";if(ae(e.type)&&S[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(S[o.tenantId].month,S[o.tenantId].year,"Sidebar"),_e&&S[o.tenantId]!=null){const y=S[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Be=Sa(e.type);ga(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),ba({dispatch:r,navigate:n,pathToNavigate:ha(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{E.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(We({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:he,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:Se,newYearAnimationEnabled:ge})})})),Ba=l=>{const i=te(),s=t((E=>ne(E))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(E,n)=>{Xe(n)&&Ue(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return _.jsx(Ta,{...l,...a})};export{Ba as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./liveblocks-BuehHs6O.js";import{h as r,l as n}from"./core-CBgcohKl.js";import{an as i}from"./index-Dxpayzr2.js";import"./mui-Cb9eDKBr.js";import"./sentry-D8HyV7mS.js";import"./zeni-epic-state-CiYCRFt8.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.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]="3be885cb-07f5-4896-9ae7-ddcb5a1e09f4",o._sentryDebugIdIdentifier="sentry-dbid-3be885cb-07f5-4896-9ae7-ddcb5a1e09f4")}catch{}})();const a=n(null,(function(o,t){return{onGoBack:()=>{t.navigate(-1)},onGoHome:()=>{t.navigate("/")}}}))(i);function _(){const o=r();return e.jsx(a,{navigate:o})}export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-
|
|
1
|
+
import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-BuehHs6O.js";import ut from"./NotFoundScreen-BtojPFV3.js";import{a as k}from"./sentry-D8HyV7mS.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 Y}from"./core-CBgcohKl.js";import{cA as It,U1 as J,fF as K,h1 as Tt,U5 as b,a0$ as Q,Ub as m,T$ as y,Ar as j,G8 as Ct,a10 as At,T_ as yt,Ud as Et,Aw as _t,a11 as $,br as F,gh as x,AA as z,a12 as Nt,cM as wt,cF as Bt}from"./zeni-epic-state-CiYCRFt8.js";import{ar as xt,c as Ut,o as vt,S as Dt,at as Rt,dL as Gt,p as w,dM as Pt,w as Mt,dN as $t,i as Ft,a5 as jt}from"./index-Dxpayzr2.js";import"./mui-Cb9eDKBr.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-D10pewSQ.js";import{u as Lt}from"./useTaskManagerAccess-BNjTqV_h.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.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]="1ab247ee-68d3-4701-961a-8c2e39630cf9",t._sentryDebugIdIdentifier="sentry-dbid-1ab247ee-68d3-4701-961a-8c2e39630cf9")}catch{}})();const Wt=(t,l)=>new Promise(((n,h)=>{const g=t.map((c=>new Promise((o=>{l(c),o()}))));Promise.all(g).then((()=>{setTimeout((()=>{n()}),2e3)})).catch((c=>{h(c)}))})),qt=St((function(t,l){const n=J(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=b(t),f=K(t),{currentTab:I}=o;return{notificationView:o,isNotificationSettingsVisible:h.userEmail!=null&&Et(n.notificationSettings,h.userEmail,g,f,c),isDisabled:o.notificationDetailsByTab[I].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:o,navigate:f,markInboxNotificationAsRead:I,fetchMoreCommentsNotifications:v}=l;return{onNotificationClick:(a,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,T=w(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,T=w(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}d==="unread"&&t(z("task_manager","read",[a],!1))},onCommentNotificationClick:(a,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(I(a),t($([a],F())));let i=`/${h}/${r[1]}`;const T=w(n.state?.pathnameStackToGoBack,n.pathname);r[1].startsWith("reimbursement")&&!wt(g)&&(i="not-found"),r[1].startsWith("bill")&&!Bt(g)&&(i="not-found"),f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,s)=>{t(y(a,s))},onUpdateNotificationTabState:(a,s)=>{t(m(a,s))},onUpdateNotificationViewCurrentTabAndSubTab:(a,s)=>{t(Q(a,s));const d=`../${a}`,r=w(n.state?.pathnameStackToGoBack,n.pathname);f(d,{state:{pathnameStackToGoBack:r}})},onUpdateNotificationViewSubTab:a=>{t(Nt(a))},onFetchMoreNotifications:(a,s)=>{if(a==="tasks"){const d=[];s==="all"?d.push("read","unread"):s!=="mentions"&&d.push(s),t(j("task_manager","dashboard",d))}else v?.()},onUpdateNotificationStatus:(a,s,d,r)=>{a==="tasks"?t(z("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(I(i),t($([i],F())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(y({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")),Wt(o,I).then((()=>{t($(o,F())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(y({unreadCount:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))})).catch((s=>{t(m({markAsAllReadState:{fetchState:"Error",error:s}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onBackClick:()=>{const a=jt(n.state?.pathnameStackToGoBack),s=a.poppedPathname??"../../dashboard";f(s,{state:{pathnameStackToGoBack:a.newStack}})},onSettingsClick:()=>{const a=w(n.state?.pathnameStackToGoBack,n.pathname);f("../../settings/notifications",{state:{pathnameStackToGoBack:a}})}}}))(Mt($t)),Ht=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=It(h??""),o=gt(),f=Ut(),[I,v]=k.useState(!1),a=S((e=>J(e))),s=S((e=>K(e))),{useFeatureGate:d}=vt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Rt({isDataReady:!0});const Z=Tt(s.userRole);if(s==null||n==null||s.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)),L=S((e=>b(e).currentTab)),D=S((e=>b(e).currentSubTab)),tt=S((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),R=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)),st=Gt().allUsers,{inboxNotifications:B,isLoading:E,hasFetchedAll:C,isFetchingMore:G,fetchMore:ot}=mt(),{threads:W,isLoading:q,fetchMore:H,isFetchingMore:O,hasFetchedAll:X}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(L!==c&&c!=null&&o(Q(c)),c==null){const e=`../${L}`,p=w(l.state?.pathnameStackToGoBack,l.pathname);t(e,{state:{pathnameStackToGoBack:p}})}}),[c]),k.useEffect((()=>{tt.fetchState==="Not-Started"&&o(m({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[]),k.useEffect((()=>{if(E===!1&&C===!0&&s?.companyId!=null&&B!=null){const e=`dashboard_${s.companyId}`,p=B.filter((A=>A.roomId===e&&A.readAt==null)).length;o(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),o(y({unreadCount:p},"comments"))}}),[E,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&o(j("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>ot?.()),0);return()=>clearTimeout(e)}));const P=E||G===!0||C!==!0||E||G===!0||C!==!0;k.useEffect((()=>{P&&R!=="In-Progress"?o(m({fetchState:"In-Progress",error:void 0},"comments")):P||R!=="In-Progress"||o(m({fetchState:"Completed",error:void 0},"comments"))}),[P,R]),k.useEffect((()=>{o(y({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&I===!1&&(v(!0),o(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(E===!1&&q===!1&&B!=null&&W!=null){const e=`dashboard_${s.companyId}`,p=B.filter((u=>u.roomId===e)).filter((u=>Pt(u.kind))),A=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const M=W.find((dt=>{return dt.id===((U=u).kind==="thread"?U.threadId:"subjectId"in U?U.subjectId:void 0);var U}));return M!=null?{inboxNotification:{...u,threadId:M.id},thread:M}:(O||X===!0||H==null||H(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(y({totalCount:_.length,unreadCount:A.length},"comments")),o(At(ct))}}),[E,G,O,C,X,q,B?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if(Ft(p)){const A=yt(p.mode);if(A==="dashboard"&&o(y({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];D==="all"?_.push("read","unread"):D!=="mentions"&&_.push(D),o(j("task_manager",A,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=Lt(f);return N.jsx(qt,{tenantEmailDomain:n,loggedInUserRoleMap:Z,signedInUser:f,externalNotificationsUnreadCount:et,location:l,navigate:t,isDebitCardFeatureEnabled:r,isTaskManagerAccessEnabled:rt,users:st,markInboxNotificationAsRead:it,allUnreadCommentsNotificationIds:at,isAiCfoAccessEnabled:i,onAskAiCfoClick:T,...nt})};function me(){return N.jsxs(bt,{children:[N.jsx(Y,{path:"/:selectedTab",element:N.jsx(Ht,{})}),N.jsx(Y,{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-BuehHs6O.js";import{a as r}from"./sentry-D8HyV7mS.js";import{u as j,g as A,j as o,N as C}from"./core-CBgcohKl.js";import{UE as P,fF as x,gm as z,UF as D,UG as M,UH as R,UI as F,pS as k,Tj as L}from"./zeni-epic-state-CiYCRFt8.js";import{z as h,ai as I}from"./index-Dxpayzr2.js";import"./mui-Cb9eDKBr.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.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]="e3455a42-91d2-4bba-97a0-8d29f99e4003",n._sentryDebugIdIdentifier="sentry-dbid-e3455a42-91d2-4bba-97a0-8d29f99e4003")}catch{}})();function ee(){const n=j(),a=A(),{params:t,error:i}=r.useMemo((()=>P(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=>x(e))),l=o((e=>z(e))),d=o((e=>e.tenantState.fetchState)),y=o(D),b=o(M),u=o(R),[S,U]=r.useState(null),[v,E]=r.useState(null);r.useEffect((()=>{document.querySelector("#app-shell-loader")?.remove()}),[]),r.useEffect((()=>()=>{n(F())}),[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((T=>T.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[m?.tenantId,l]),c=S??_;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:U,approveError:v??b,isApproving:y==="In-Progress",showAllowButton:c!=null,onApprove:()=>{t!=null&&s!=null&&c!=null&&n(L(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{E("Unable to deny: redirect_uri is not a valid URL. Close this window or contact support.")}}}):f.jsx(C,{to:"/signin/auth",state:{origin:a.pathname+a.search},replace:!0})}export{ee as default};
|
package/dist/assets/{PandLWithForecastRoutes-Bat6wWmW.js → PandLWithForecastRoutes-D7BxHFnv.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./liveblocks-
|
|
1
|
+
import{j as n}from"./liveblocks-BuehHs6O.js";import{h as Z,u as H,g as J,i as Q,j as d,l as X,n as ee,o as C}from"./core-CBgcohKl.js";import{fF as w,Ac as U,v5 as ae,Vw as M,v0 as y,bq as te,b$ as se,v1 as oe,Vx as re,Ve as S,ei as ne,E0 as ce,Vy as ie,Eo as le,d_ as de,dZ as me}from"./zeni-epic-state-CiYCRFt8.js";import{aj as fe,z as pe,ar as ue,at as he,K as Fe,o as _,S as V,a9 as ge,k as B,aE as be,p as Ie}from"./index-Dxpayzr2.js";import"./mui-Cb9eDKBr.js";import Ce from"./NotFoundScreen-BtojPFV3.js";import{F as Se}from"./FeaturePreviewScreen-cTqlV8kw.js";import{a as F}from"./sentry-D8HyV7mS.js";import{u as ye}from"./useAskAiCfoHostNavButtonProps-D10pewSQ.js";import{u as Te}from"./useInitialThreadRequest-eERa3iZO.js";import{t as Ae}from"./routePaths-B-L_6QzQ.js";import{M as xe}from"./MobileAppDrawer-ohji3E0D.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.js";import"./InboxNotificationsProvider-C4Xl3N_I.js";import"./useTaskManagerAccess-BNjTqV_h.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]="c0448635-f5ba-42ed-a87a-7b75fa49f4be",s._sentryDebugIdIdentifier="sentry-dbid-c0448635-f5ba-42ed-a87a-7b75fa49f4be")}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})}},Ee=X((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:B}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(M(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=Ae(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=Z(),a=H(),o=J(),{forecastId:r,tenantEmailDomain:c}=Q(),[p,u]=F.useState(!1),[m,A]=F.useState(!1),g=pe.getSignedInUser(),x=d((t=>w(t))),N=x.company?.companyInfo.firstMonthOfFY??1,i=d((t=>U(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),E=d((t=>t.profitAndLossState)),D=d((t=>t.reportUIOptionsState.selectedForecast)),j=t=>E.pandLByForecastID[t]!=null&&oe(t,E).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:b}=ue();he({isDataReady:l});const{isAiCfoAccessEnabled:$,onAskAiCfoClick:q}=ye({mobileExploreReferrer:"Forecast"});F.useEffect((()=>{if(!p&&b)u(!0),l||a(ae());else if(l&&!m){A(!0);const t=((f,R,O)=>R!=null?f.forecasts.findIndex((I=>I.id===R)):O!=null?f.forecasts.findIndex((I=>I.id===O)):f.forecasts.length>0?0:-1)(i,r,D?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=D?.index?(a(M(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&&!j(i.forecasts[t].id)&&b&&a(y(i.forecasts[t].id))}}),[p,u,a,l,i,m,A,U,y,b]);const k=Fe(),G=k?.loggedInUserRole!=null&&te(k.loggedInUserRole),{useFeatureGate:Y}=_(),{isFeatureEnabled:L}=Y(V.isReportsCommentingEnabled),W=Te(L?x?.companyId:void 0,{clearParams:l&&m}),[z,K]=F.useState(!1),h=new URL(s("forecast_pandl"));h.searchParams.set("firstname",g?.firstName??""),h.searchParams.set("lastname",g?.lastName??""),h.searchParams.set("email",g?.userEmail??"");const P=t=>{K(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(ge,{analytics:B,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(xe,{isAppContentDrawerOpen:z,handleDrawerToggle:P}),n.jsx(Ee,{firstMonthOfFY:N,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:j,meetingUrl:se(h.toString()),hasTransactionAccess:G,isAiCfoAccessEnabled:$,onAskAiCfoClick:q,isReportsCommentingEnabled:L,initialOpenThreadRequest:W,onClickMenuIcon:()=>{P(!0)}})]})}function He(){const s=d((c=>w(c))),{useFeatureGate:e}=_(),{isFeatureEnabled:a}=e(V.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{He as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as r}from"./liveblocks-
|
|
1
|
+
import{j as r}from"./liveblocks-BuehHs6O.js";import{a as p}from"./sentry-D8HyV7mS.js";import{F as c,H as a,aa as m,ae as f,af as h}from"./index-Dxpayzr2.js";import"./mui-Cb9eDKBr.js";import{i as y}from"./core-CBgcohKl.js";import"./zeni-epic-state-CiYCRFt8.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.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]="a629afc2-cb2d-4239-93c8-c48b807e180b",e._sentryDebugIdIdentifier="sentry-dbid-a629afc2-cb2d-4239-93c8-c48b807e180b")}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-BuehHs6O.js";import{Vs as re,fF as Y,l$ as G,d_ as N,dZ as le,Sj as Q,UR as de,CX as Pe,Vt as q,CM as je,D5 as Le,C$ as ce,CQ as pe,D3 as ve,D0 as Te,Vu as ue,sq as Ve,g6 as Ae,gD as Fe,Vv as H,CU as me,CT as ge,D8 as Re,c8 as Oe}from"./zeni-epic-state-CiYCRFt8.js";import{a2 as fe,o as J,S as _,z as K,f as Ce,X as he,ag as ye,aA as be,aB as Ze,ac as Se,H as R,ah as De,G as W,aC as Ue,ar as Be,at as $e,a9 as ze,k as we,V as He,p as _e,aD as Ge,K as Ke}from"./index-Dxpayzr2.js";import{D as xe,n as M,S as Ie}from"./mui-Cb9eDKBr.js";import ae from"./NotFoundScreen-BtojPFV3.js";import{a as d}from"./sentry-D8HyV7mS.js";import{u as ee,i as We,j as g,h as Me,g as Xe,l as qe,n as se,o as z}from"./core-CBgcohKl.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-D10pewSQ.js";import{M as Ne}from"./MobileAppDrawer-ohji3E0D.js";import"./recharts-Byvkx40G.js";import"./analytics-DHz0W6ee.js";import"./plaid-7nNyVbzF.js";import"./dnd-f7VjRKNv.js";import"./stripe-cKAAJElX.js";import"./lottie-Hll5C5f2.js";import"./lexical-C3EylrlT.js";import"./pdf-CIjq4lBs.js";import"./utils-Co2o080j.js";import"./InboxNotificationsProvider-C4Xl3N_I.js";import"./useTaskManagerAccess-BNjTqV_h.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]="abdeb8c9-ee05-46f0-8ad9-7e0618979de5",e._sentryDebugIdIdentifier="sentry-dbid-abdeb8c9-ee05-46f0-8ad9-7e0618979de5")}catch{}})();const Qe={overlayWidth:new Se(100,100,48)},te=W.getLocalizedStrings().peoplePage.invitePage,ne=W.getLocalizedStrings().common,Je=({companyId:e,managersListView:t,companyPassportView:c,classListView:n,mode:f,isEditPeopleDrawerOpen:i,closeDrawerHandler:b})=>{const C=fe(),m=ee(),[O,Z]=d.useState(!1),[k,S]=d.useState(!1),{userId:D}=We(),r=g((l=>re(l))),p=g((l=>Y(l))),E=g((l=>G(l))),{useFeatureGate:x}=J(),{isFeatureEnabled:I}=x(_.isDebitCardFeatureEnabled),P=N(I,p),v=le(p),T=Q(p),U=de(p),B=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,w=!P&&E&&n.fetchState!=="Completed"||t.fetchState!=="Completed"||c.fetchState!=="Completed"||e==null;if(K.getSignedInUser()==null)throw Error("Can't access invite people page without signing in...");const h=()=>{m(q()),b()},V=()=>{O===!0?S(!0):h()},$=c.companyView?.controllers?.map((l=>l.user)),u=!!p.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:j}=x(_.isChargeCardFeatureEnabled),L=Ce(p,j,I),{isCardsHidden:A}=he(p?.tenantId),y=!L||A,F=p.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",s={peopleDetails:r,classList:n.classes,managersList:t.users,controllersList:$,mode:f,isZeniTenant:T,isAccountingClassesEnabled:E,isReimbursementDisabled:B===!1,isZeniAccountsDisabled:u===!1,isChargeCardDisabled:y,isTreasuryDisabled:F===!1,isLiteRoleDisabled:U===!1,isBankingOnlyTenant:P,isCardsOnlyTenant:v,onResetClick:h,onDeleteUser:l=>{m(pe(l.userId,l.userRole.userRoleId))},onPeopleLocalDataUpdated:l=>{m(ce({peopleLocalData:l})),Z(!0)},onSaveClick:()=>{m(f==="zeni_only"?je(e):Le(T))},onCloseClick:V,isLoading:w||r.person==null},o={onOkClick:()=>{S(!1),h()},onCancelClick:()=>{S(!1)}};return d.useEffect((()=>{w===!1&&D!=null&&m(Pe(D))}),[w,D]),d.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&h()}),[r.updatePersonState.fetchState]),a.jsx(xe,{anchor:"right",open:i,PaperProps:{style:{width:Qe.overlayWidth.valuePercentage(C),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:ye.overlayDark,cursor:"pointer"}}},onClose:V,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(Ze,{...s})]})})},ea=M(Ie)`
|
|
2
2
|
display: flex;
|
|
3
3
|
min-height: 100%;
|
|
4
4
|
flex-direction: column;
|