@zeniai/web-app-ui 5.3.58-dev → 5.3.58-qa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assets/{AccountMappingScreen-i9VnJUfN.js → AccountMappingScreen-CHe5ZDGP.js} +1 -1
  2. package/dist/assets/{ActualMatchingMatchDetailScreen-BezdP5hK.js → ActualMatchingMatchDetailScreen-C-SpCliN.js} +1 -1
  3. package/dist/assets/{AddressRoutes-Bdit2HAJ.js → AddressRoutes-D1soVd7h.js} +1 -1
  4. package/dist/assets/{AddressScreen-VFwclDOo.js → AddressScreen-Dsruahz2.js} +1 -1
  5. package/dist/assets/{AiCfoScreen-DxQtaOj7.js → AiCfoScreen-3zzxXdtv.js} +1 -1
  6. package/dist/assets/{AppDrawer-C6RwU25A.js → AppDrawer-DOUxHB1n.js} +1 -1
  7. package/dist/assets/{BillPayApprovalRoutes-DYWuhb41.js → BillPayApprovalRoutes-B0Nta3_I.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-C1JyoH4j.js → BillPayRoutes-B9TIHh4P.js} +1 -1
  9. package/dist/assets/{BusinessVerificationPageScreen-CGL4LCDJ.js → BusinessVerificationPageScreen-DrcWW1y2.js} +1 -1
  10. package/dist/assets/{CardsAiCfoScreen-DbF_UrIW.js → CardsAiCfoScreen-DlYyRzr9.js} +1 -1
  11. package/dist/assets/{ChargeCardRoutes-BZfJocDx.js → ChargeCardRoutes-DZRPdI1Z.js} +1 -1
  12. package/dist/assets/{CompanyPassportScreen-C4Q98a-_.js → CompanyPassportScreen-DAYszi2A.js} +1 -1
  13. package/dist/assets/{ConnectionAuthScreen-413EOD9J.js → ConnectionAuthScreen-BBBGS4jz.js} +1 -1
  14. package/dist/assets/{CustomerOnboardingAuthScreen-DGoLyCcj.js → CustomerOnboardingAuthScreen-CZDOwYAs.js} +1 -1
  15. package/dist/assets/{CustomerOnboardingRoutes-CUI-gFVx.js → CustomerOnboardingRoutes-CV-zX-f3.js} +1 -1
  16. package/dist/assets/{DashboardRoutes-CZU-ohC4.js → DashboardRoutes-B4rPAFsp.js} +1 -1
  17. package/dist/assets/{DefaultTenantHome-BIH8L2zP.js → DefaultTenantHome-D2yS26zu.js} +1 -1
  18. package/dist/assets/{DomesticWireDetailScreen-MDUoS_v9.js → DomesticWireDetailScreen-C3OQdqoM.js} +1 -1
  19. package/dist/assets/{DrawerScreen-BzNdt1AI.js → DrawerScreen-DcAKkP88.js} +1 -1
  20. package/dist/assets/{EntityDetailRoutes-Cn6snoxK.js → EntityDetailRoutes-Cf2odala.js} +1 -1
  21. package/dist/assets/{ExpenseAutomationRoutes-G_4mZDU-.js → ExpenseAutomationRoutes-2l3STf0l.js} +1 -1
  22. package/dist/assets/{FeaturePreviewScreen-C-uktVbl.js → FeaturePreviewScreen-B1Ivzvw1.js} +1 -1
  23. package/dist/assets/{HubSpotOAuthCallbackScreen-DPJHmsFd.js → HubSpotOAuthCallbackScreen-Doqpd6l9.js} +1 -1
  24. package/dist/assets/{InvoicingRoutes-De3ZOg_V.js → InvoicingRoutes-CQVQ-Y38.js} +1 -1
  25. package/dist/assets/{MagicLinkRoutes-D8WmClD4.js → MagicLinkRoutes-DcyXYSMX.js} +1 -1
  26. package/dist/assets/{MagicLinkSignInScreen-DUzZyQDK.js → MagicLinkSignInScreen-DSwu3x1a.js} +1 -1
  27. package/dist/assets/{MobileAppDrawer-nX8kGgUI.js → MobileAppDrawer-CdDtqWOO.js} +1 -1
  28. package/dist/assets/{NotFoundScreen-znPj3CVA.js → NotFoundScreen-ujna2tN5.js} +1 -1
  29. package/dist/assets/{NotificationRoutes-DQ95Eu44.js → NotificationRoutes-hJV6UzGh.js} +1 -1
  30. package/dist/assets/{OAuthConsentScreen-dDQYvFle.js → OAuthConsentScreen-CC7ydiAB.js} +1 -1
  31. package/dist/assets/{PandLWithForecastRoutes-CxDiuohR.js → PandLWithForecastRoutes-BlHGiHRN.js} +1 -1
  32. package/dist/assets/{PaymentLinkScreen-D586vchF.js → PaymentLinkScreen-DDprDsoQ.js} +1 -1
  33. package/dist/assets/{PeopleRoutes-Kyg4bRaa.js → PeopleRoutes-BlO3KG08.js} +1 -1
  34. package/dist/assets/{PerformanceRoutes-P-3150On.js → PerformanceRoutes-6Ca4X1Bq.js} +1 -1
  35. package/dist/assets/{QBOConnectionScreen-Bf8b_4PY.js → QBOConnectionScreen-ByT4Lz_O.js} +1 -1
  36. package/dist/assets/{ReimbursementApprovalRoutes-3BFLJn19.js → ReimbursementApprovalRoutes-BVIa8SJX.js} +1 -1
  37. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-BXMGleKX.js → ReimbursementApprovalRuleDetailScreen-BmA4MWUa.js} +1 -1
  38. package/dist/assets/{ReimbursementRoutes-CycF_Spp.js → ReimbursementRoutes-CRFGQISM.js} +1 -1
  39. package/dist/assets/{ReportsRoutes-Bu-WEiek.js → ReportsRoutes-s6sDyTPD.js} +1 -1
  40. package/dist/assets/{RewardsRoutes-P_7Rwvsn.js → RewardsRoutes-D_CDp-DT.js} +1 -1
  41. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-D7v-1M8j.js → ScheduleDetailsPrepaidExpensesScreen-CDMS-Kyu.js} +1 -1
  42. package/dist/assets/{ScreenRoutes-D5MH9SH5.js → ScreenRoutes-DGSfHb9l.js} +2 -2
  43. package/dist/assets/{SettingsRoutes-dfB8V5LJ.js → SettingsRoutes-C_k-hnnr.js} +1 -1
  44. package/dist/assets/{SetupPagesScreen-CiEvawPy.js → SetupPagesScreen-DAfX5Gik.js} +1 -1
  45. package/dist/assets/{SignInScreen-CvFNfCth.js → SignInScreen-C5hV08WY.js} +1 -1
  46. package/dist/assets/{SignOutScreen-m-IPtY4_.js → SignOutScreen-BW3JHrQP.js} +1 -1
  47. package/dist/assets/{TaskListScreen-8Fb8ti00.js → TaskListScreen-DKWXa0Uv.js} +1 -1
  48. package/dist/assets/{TaskRoutes-CiBAjLDk.js → TaskRoutes-uwwC8_Az.js} +1 -1
  49. package/dist/assets/{TransactionDetailRoutes-DgMv2RRC.js → TransactionDetailRoutes-9VQeLVZi.js} +1 -1
  50. package/dist/assets/{TransactionDetailScreen-DiUMYJym.js → TransactionDetailScreen-D87lkTI9.js} +1 -1
  51. package/dist/assets/{TransactionListRoutes-DIxo91Cd.js → TransactionListRoutes-CiDmnLCE.js} +1 -1
  52. package/dist/assets/{TreasuryRoutes-iyMNrkVz.js → TreasuryRoutes-3zDhHaKN.js} +1 -1
  53. package/dist/assets/{VendorsRoutes-Co_zhdIN.js → VendorsRoutes-BkvgN-45.js} +1 -1
  54. package/dist/assets/{WiseConfirmationScreen-DbcfT5oS.js → WiseConfirmationScreen-Ca5i9ss6.js} +1 -1
  55. package/dist/assets/{ZeniAccountRoutes-CtKmgkAm.js → ZeniAccountRoutes-BDqvTfgU.js} +1 -1
  56. package/dist/assets/{ZeniAccountStatementScreen-hSEFk11y.js → ZeniAccountStatementScreen-iAxQqIlV.js} +1 -1
  57. package/dist/assets/{analyticsHelper-DsmnThaa.js → analyticsHelper-vNgRVJkc.js} +1 -1
  58. package/dist/assets/{getLocaleForTenant-B7a_04KB.js → getLocaleForTenant-BAgQLN5V.js} +1 -1
  59. package/dist/assets/{index-DMDsYekO.js → index-DheSTGi7.js} +5 -5
  60. package/dist/assets/{routePaths-DtiHE0tS.js → routePaths-DrHt4RCx.js} +1 -1
  61. package/dist/assets/{useActualMatchingMatchDetail-BAqmIJo_.js → useActualMatchingMatchDetail-DXOytDvG.js} +1 -1
  62. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-yFi8Syac.js → useAiCfoDashboardSuggestedQuestionsChips-DRaJ3Gwb.js} +1 -1
  63. package/dist/assets/{useAskAiCfoHostNavButtonProps-BPjVLeQ1.js → useAskAiCfoHostNavButtonProps-DhY9V91R.js} +1 -1
  64. package/dist/assets/{useChargeCardPusherEvents-DFAQ6Tan.js → useChargeCardPusherEvents-Cwq1bouz.js} +1 -1
  65. package/dist/assets/{useEmailConnectResultRefresh-GEPB7d7i.js → useEmailConnectResultRefresh-2DUe5mQi.js} +1 -1
  66. package/dist/assets/{useInitialThreadRequest-B7Oi83EI.js → useInitialThreadRequest-Fj77Qh1B.js} +1 -1
  67. package/dist/assets/{useTaskManagerAccess-CZ3Xfg1w.js → useTaskManagerAccess-BOnqrzjJ.js} +1 -1
  68. package/dist/assets/{useTaskManagerPusherEvents-BPMYVmLa.js → useTaskManagerPusherEvents-jr7UAjj6.js} +1 -1
  69. package/dist/assets/{withTransactionSidePanel-BNIz03mj.js → withTransactionSidePanel-DdbBVvXc.js} +1 -1
  70. package/dist/index.html +1 -1
  71. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{j as s}from"./liveblocks-BF-IiX2V.js";import{a as r}from"./sentry-DQv7eTqs.js";import{u as D,h as A,i as R,j as C,t as Z,l as O,s as H,g as G,N as B,n as te,o as x}from"./core-C1MQ75FC.js";import{a9 as st,l as p,ar as _,V as m,cd as ct,ce as rt,cf as lt,cg as dt,ch as ut,ci as gt,cj as mt,ck as vt,cl as pt,cm as ft,cn as St,co as ht,p as W,cp as It,cq as Ct,af as ae,cr as Et,cs as kt,z as xe,ct as yt,cu as xt,cv as bt,cw as jt,cx as Pt,cy as Dt,cz as At,cA as Lt,Q as $t,aj as vn,cB as Ft,cC as wt,cD as Rt,cE as _t,cF as we,cG as Tt,cH as Ot,cI as Mt,cJ as Nt,cK as Ut,cL as Bt,t as Ke,h as pn,cM as Vt,cN as Ht,cO as qt,cP as zt,cQ as Qt,cR as Kt,cS as Zt}from"./index-DMDsYekO.js";import"./mui-D4JyxRuO.js";import{A as Q}from"./AddressScreen-VFwclDOo.js";import M from"./NotFoundScreen-znPj3CVA.js";import{ZN as Gt,ZO as Wt,vp as Ze,ZP as K,vS as se,ZQ as Re,ZR as ce,wt as be,wA as Xt,wF as fn,ZS as _e,wx as Sn,y7 as Ge,vR as We,ZT as Jt,ZU as hn,wQ as je,ZV as re,wU as Yt,ZW as ei,ZX as In,wX as Cn,z2 as ni,ZY as ve,ZZ as Xe,Z_ as En,vP as ti,Z$ as ii,vJ as oi,_0 as ai,yk as si,_1 as kn,yt as Je,_2 as ci,yq as ri,_3 as Te,gh as li,_4 as ee,_5 as ne,xa as di,vX as Ye,w0 as yn,v_ as ui,vU as gi,x3 as mi,w2 as vi,xc as pi,_6 as Pe,xl as xn,xj as X,xh as le,xg as fi,_7 as bn,yz as en,_8 as Si,vQ as jn,_9 as Oe,wb as De,w8 as Ae,wl as Pn,wk as Me,w5 as hi,we as Dn,wn as ie,fF as Ne,VA as An,vT as Ue,wi as Ii,wj as Ci,wh as Ei,_a as ki,wV as yi,wR as Ln,_b as $n,vD as nn,_c as xi,vz as bi,_d as ji,yF as Pi,yJ as q,yE as Di,xN as Be,_e as Ai,_f as Fn,yS as tn,_g as Li,yP as $i,_h as wn,xQ as Fi,xR as V,xU as wi,_i as Rn,y2 as Ie,_j as Ri,xb as _n,U6 as Tn,_k as _i,yc as Ti,_l as On,_m as Oi,_n as Mi,_o as Ni,zH as Ui,_p as Bi,_q as Mn,yZ as Nn,_r as Un,zF as Ce,_s as Vi,zC as Hi,_t as qi,_u as zi,_v as Qi,_w as Ki,_x as Zi,_y as on,_z as Gi,eg as Wi,zL as Xi,_A as Ve,xv as Ji,xq as Yi,_B as de,xG as Bn,xy as ue,xx as eo,xB as Vn,_C as no,xw as to,_D as Hn,z3 as qn,zu as an,zp as io,_E as oo,z4 as ao,_F as so,zv as co,zz as ro,_G as He,wv as zn,zg as lo,ww as uo,_H as go,_I as Qn,c8 as mo,ms as vo,mt as po,_J as sn,wu as ge,gl as fo,mz as So,zm as Kn,zX as ho,zj as Zn,uX as Io,zU as cn,uL as Co,zR as rn,hS as Eo,Uz as ln,UA as ko,Gf as Gn,hK as yo,_K as xo,Vp as bo,_L as jo,A0 as Ee,A1 as Po,_M as Do,_N as Wn,z_ as Ao,_O as Lo,_P as $o,yg as Fo,_Q as wo}from"./zeni-epic-state-Dmop9tB7.js";import{M as Ro}from"./MobileAppDrawer-nX8kGgUI.js";import{q as me}from"./QBOConnectionScreen-Bf8b_4PY.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.js";import"./InboxNotificationsProvider-zG7x1gLM.js";import"./useTaskManagerAccess-CZ3Xfg1w.js";import"./empty-DTjUxrNn.js";import"./pdf-lib-LgS50teK.js";import"./index-DBaQwW7d.js";import"./url-Eifk29FQ.js";import"./index-RA90NjT0.js";import"./decodeURIComponentSafe-BkSrHWOz.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]="e9a214af-d726-463a-99bf-12e8f90d1eeb",t._sentryDebugIdIdentifier="sentry-dbid-e9a214af-d726-463a-99bf-12e8f90d1eeb")}catch{}})();const $=({event:t,isReady:e=!0})=>e?s.jsx(st,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function _o(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,items:f,nextCursor:h,auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b}=C(Gt),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${n??""}/invoicing`,I=r.useCallback(((L,U)=>{const T=Wt(y,L,U,P);T!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:L,entityId:U,fromScreen:"audit_log"}),e(T))}),[P,e,y]);r.useEffect((()=>{const L=setTimeout((()=>d(a)),300);return()=>clearTimeout(L)}),[a]),r.useEffect((()=>{i&&t(Ze({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,t]);const j=g==="Not-Started"||g==="In-Progress"&&f.length===0,E=g==="In-Progress"&&f.length>0,F=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:F}),s.jsx(ct,{auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b,entries:f,hasMore:S,isLoading:j,isLoadingMore:E,searchValue:a,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&t(Ze({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function pe(t,e=!1){const n=D(),i=C((c=>K(c).productNextCursor!=null)),a=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&&a!=null&&n(se({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function fe(t,e,n,i){const[a,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]),a}const To=new Set(["plan"]),Oo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&t(Sn({action:a,id:i}))}:void 0,onEditChange:a=>{i!==""&&t(_e({id:i,localData:a}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),t(fn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(Xt({action:o,id:a,parentItemId:i}))}}}))(rt);function Mo(){const t=D(),e=A(),{item_id:n,tenantEmailDomain:i}=R(),[a]=Z(),{areTenantIdsInSync:o}=_(),c=(d=a.get("kind"))!=null&&To.has(d)?d:"plan";var d;const l=C((k=>Re(k,n))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(t(ce({id:n})),()=>{t(ce({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(be({id:n,kind:c}))}),[o,n,c,t]);const g=r.useCallback((k=>t(be({cacheOverride:!0,id:k,kind:c}))),[t,c]),S=fe(l.fetchState,l.isFormLoading,n,g),f=u==="Completed"&&!l.isFormLoading;pe(o,!0);const[h,P]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&P(n)}),[n,f]);const b=h!==n&&(u==="Not-Started"||u==="In-Progress"||l.isFormLoading);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Oo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:b,view:l},S)]})}const No=new Set(["addon","charge","plan"]),Uo=new Set(["plan"]),Bo=O((function(t,e){const n=Re(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:a}=e,o=a!=null?`${n}/catalog/${encodeURIComponent(a)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),t(ce({id:a})),e.navigate(`${n}/catalog`)},onChange:c=>{t(_e({id:a,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),t(fn({id:a}))}}}))(lt);function Vo(){const t=D(),e=A(),{item_id:n,tenantEmailDomain:i}=R(),[a]=Z(),{areTenantIdsInSync:o}=_(),c=n!=null,d=a.get("type"),l=d!=null&&No.has(d)?d:void 0,v=(u=a.get("kind"))!=null&&Uo.has(u)?u:"plan";var u;const g=C((S=>Re(S,n)));return pe(o,!0),r.useEffect((()=>{o&&t(be({id:n,kind:v}))}),[o,n,v,t]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||t(_e({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const S=g.savedItemId??n,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),t(ce({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),s.jsx(Bo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const Ho={addons:"addon",all:"item",charges:"charge",plans:"plan"},qo=O((function(t,e){const n=K(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,c=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Ho[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(Sn({action:Jt(d),id:c}))},onLoadMore:()=>{if(a)return e.planNextCursor!=null&&t(We({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?We({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(dt);function zo(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),P=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),b=C((L=>K(L))),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 L=setTimeout((()=>v(a)),300);return()=>clearTimeout(L)}),[a]),r.useEffect((()=>{i&&t(Ge({cacheOverride:!1,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[i,t,h,P,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==y?.field||S?.dir!==y?.dir)&&t(Ge({cacheOverride:!0,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[k,y,i,t,h,P,f,S]),N(b.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),s.jsx(qo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:a,sortState:u,planFilters:h,productFilters:P,sort:S,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:F,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Qo=O((function(t,e){const n=hn(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,a=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(ei({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:a}),t(Yt({id:i}))}}}))(ut);function Ko(){const t=D(),e=A(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),{fetchState:o,savedCouponId:c}=C((d=>hn(d,n)));return r.useEffect((()=>{a&&t(je({id:n}))}),[a,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]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCouponFormPage}),s.jsx(Qo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Zo=O((function(t){const e=In(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:a=>{e(En(a))},onSubmit:()=>{const a=ii(t.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(oi(a))}}}))(mt);function Go(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),[i]=Z(),{areTenantIdsInSync:a}=_(),o=i.get("customerId"),c=C((I=>In(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(Cn),g=C((I=>ni(I))),S=C(ve),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,P=f||h,b=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(Xe()),()=>{t(Xe())})),[t]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,t(En({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{a&&t(ti({cacheOverride:!1}))}),[a,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]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),P?s.jsx(gt,{}):s.jsx(Zo,{navigate:e,tenantEmailDomain:n})]})}const Wo=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)}`)}}}))(vt);function Xo(){const t=D(),e=A(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),o=C((d=>ai(d,n??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(si({id:n}))}),[a,n,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Wo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const Jo=O((function(t){const e=kn(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(ri({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function Yo(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,creditNoteListFetchState:b}=C((y=>{const I=kn(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(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(Je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Je({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),s.jsx(Jo,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>t(ci(y)),onSortChange:v})]})}const Xn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},ea=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(Pe({id:i,localData:a}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onDiscardEdit:()=>{t(X(le)),t(fi({id:i}))},onOpenAddress:()=>{const a=Xn(e.tenantEmailDomain??"",le,i),o=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),t(Pe({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(pi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>t(vi({body:c,customerId:i,email:a,subject:o})),onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function na(){const t=D(),e=A(),n=G(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=_(),c=C((T=>Te(T,i))),d=c.pageFetchState.fetchState,l=d==="Completed"&&!c.isFormLoading,[v,u]=r.useState(!1),[g,S]=r.useState(!1),[f,h]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&h(i)}),[i,l]);const P=f===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(li({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&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(di({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&j&&t(Ye({customerId:i}))}),[o,i,t,j]);const L=r.useCallback((T=>t(yn({id:T}))),[t]),U=fe(c.fetchState,c.isFormLoading,i,L);return N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ea,{customerId:i??"",editView:c,hasLoadedRecord:P,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{t(ee()),i!=null&&j&&t(Ye({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),S(!0)}},U),s.jsx(ft,{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(gi({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:T=>{i!=null&&t(ui({customerId:i,data:T}))}}),s.jsx(St,{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:()=>{S(!1),t(ne())},onSubmit:({amount:T,description:Y})=>{i!=null&&t(mi({amount:T,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:Y}))}})]})}const ta=O((function(t,e){const n=Te(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,a=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(bn({id:i})),t(X(le)),e.navigate(`${n}/customers`)},onChange:c=>{t(Pe({id:i,localData:c}))},onOpenAddress:()=>{const c=Xn(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:a}),t(xn({id:i}))}}}))(It);function ia(){const t=D(),e=A(),n=G(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=_(),{fetchState:c,savedCustomerId:d}=C((l=>Te(l,i)));return r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(v),t(bn({id:i}))}}),[c,d,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerFormPage}),s.jsx(ta,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const oa=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,a)=>{switch(a){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(jn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ct);function aa(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,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(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(en({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(en({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),s.jsx(oa,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>t(Si(y)),onSortChange:v})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),sa=O((function(t,e){const{filters:n,sessionId:i,view:a}=e,o=i==null?void 0:a.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(a,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:a,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",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>a(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&t(Ae({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&t(Me(o))},onRollback:S?()=>{o!=null&&t(Pn(o))}:void 0}}))(Et);function ca(){const t=D(),e=A(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),[o,c]=r.useState({}),d=C(Oe),l=Le(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(De(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const f=setTimeout((()=>{t(Ae({...o,sessionId:n}))}),300);return()=>clearTimeout(f)}),[a,t,o,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!a||n==null||!u)return;const f=setInterval((()=>{t(De(n)),t(Ae({...o,sessionId:n}))}),3e3);return()=>clearInterval(f)}),[a,t,o,u,n]);const g=r.useMemo((()=>{if(n==null)return;const f=new URLSearchParams;o.moduleId!=null&&f.set("module_id",o.moduleId),o.level!=null&&f.set("level",o.level),o.outcome!=null&&f.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&f.set("search",o.search.trim());const h=f.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(sa,{downloadUrl:g,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const Jn=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=Jn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ra=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const c=o??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(Me(o)),a(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Pn(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(kt);function la(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),a=C(Oe);r.useEffect((()=>{i&&(t(hi()),t(Dn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ra,{navigate:e,tenantEmailDomain:n,view:a})]})}const da=O((function(t,e){const{activeId:n,integrationsView:i,settings:a,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:a?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:a?.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:a}=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(Ei())},onGoToIntegrations:()=>{i(`/${a}/invoicing/settings`)},onGoToOverview:()=>i(`/${a}/invoicing/overview`),onRetry:()=>{n!=null&&t(Me(n))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),n!=null&&t(Ci(n))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),t(Ii({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(yt);function ua(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),a=C(Cn),o=C(Ne).companyId??xe.getSignedInUserTenant(n??"")?.companyId,c=C((f=>An(f,o))),d=C(Oe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(t(Ue()),t(Dn()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(Jn(h))}catch{return null}})(n);f!=null&&t(ie(f))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const g=u?.status,S=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{t(De(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,t]),r.useEffect((()=>{g==="done"&&(t(ie(null)),oe(n,null))}),[t,g,n]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportMigratePage}),s.jsx(da,{activeId:v,integrationsView:c,navigate:e,settings:a,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ga=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{t(Ln({action:a,id:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),t(yi({data:a,id:i}))}}}))(xt);function ma(){const t=D(),e=A(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),o=C((h=>ki(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((()=>{a&&t(je({id:n}))}),[a,n,t]);const S=r.useCallback((h=>t(je({cacheOverride:!0,id:h}))),[t]),f=fe(o.fetchState,o.isFormLoading,n,S);return N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(ga,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},f)]})}const va=O((function(t){const e=$n(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,a)=>{t(Ln({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(bi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function pa(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=$n(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(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&t(nn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(nn({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),s.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>t(xi(I)),onSortChange:v})]})}const fa=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,a=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:a?()=>t(q({action:"cancel",id:i})):void 0,onResolve:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(q({action:"resolve",id:i}))}:void 0,onResume:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(q({action:"resume",id:i}))}:void 0,onRetry:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(q({action:"retry",id:i}))}:void 0}}))(Pt);function Sa(){const t=D(),e=A(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),o=C((E=>ji(E,n??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[S,f]=r.useState(),[h,P]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[]),k=r.useCallback((()=>{if(n==null)return;t(Pi({id:n})),v("idle"),g(!1);const E=o.emailPreview.preview;f(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),P(!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((()=>{a&&n!=null&&t(Di({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&d!=null&&t(Be({invoiceId:d}))}),[a,d,t]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[n]),r.useEffect((()=>{a||(v("idle"),g(!1),f(void 0),P(!1))}),[a]),r.useEffect((()=>{h&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(n!=null&&t(Ai({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)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(fa,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:j,onSendEmail:k}),s.jsx(jt,{initialDraft:S,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 ha=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",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,a)=>{a!=="retry"&&a!=="resume"&&a!=="resolve"&&a!=="cancel"||t(q({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t($i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Dt);function Ia(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,dunningCaseListFetchState:b}=C((y=>{const I=Fn(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(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(tn({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),s.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>t(Li(y)),onSortChange:v})]})}const Ca=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:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},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:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),t(wi({data:{due_date:a.due_date!==""?a.due_date:void 0,notes:a.notes.trim()!==""?a.notes.split(`
1
+ import{j as s}from"./liveblocks-BF-IiX2V.js";import{a as r}from"./sentry-DQv7eTqs.js";import{u as D,h as A,i as R,j as C,t as Z,l as O,s as H,g as G,N as B,n as te,o as x}from"./core-C1MQ75FC.js";import{a9 as st,l as p,ar as _,V as m,cd as ct,ce as rt,cf as lt,cg as dt,ch as ut,ci as gt,cj as mt,ck as vt,cl as pt,cm as ft,cn as St,co as ht,p as W,cp as It,cq as Ct,af as ae,cr as Et,cs as kt,z as xe,ct as yt,cu as xt,cv as bt,cw as jt,cx as Pt,cy as Dt,cz as At,cA as Lt,Q as $t,aj as vn,cB as Ft,cC as wt,cD as Rt,cE as _t,cF as we,cG as Tt,cH as Ot,cI as Mt,cJ as Nt,cK as Ut,cL as Bt,t as Ke,h as pn,cM as Vt,cN as Ht,cO as qt,cP as zt,cQ as Qt,cR as Kt,cS as Zt}from"./index-DheSTGi7.js";import"./mui-D4JyxRuO.js";import{A as Q}from"./AddressScreen-Dsruahz2.js";import M from"./NotFoundScreen-ujna2tN5.js";import{ZN as Gt,ZO as Wt,vp as Ze,ZP as K,vS as se,ZQ as Re,ZR as ce,wt as be,wA as Xt,wF as fn,ZS as _e,wx as Sn,y7 as Ge,vR as We,ZT as Jt,ZU as hn,wQ as je,ZV as re,wU as Yt,ZW as ei,ZX as In,wX as Cn,z2 as ni,ZY as ve,ZZ as Xe,Z_ as En,vP as ti,Z$ as ii,vJ as oi,_0 as ai,yk as si,_1 as kn,yt as Je,_2 as ci,yq as ri,_3 as Te,gh as li,_4 as ee,_5 as ne,xa as di,vX as Ye,w0 as yn,v_ as ui,vU as gi,x3 as mi,w2 as vi,xc as pi,_6 as Pe,xl as xn,xj as X,xh as le,xg as fi,_7 as bn,yz as en,_8 as Si,vQ as jn,_9 as Oe,wb as De,w8 as Ae,wl as Pn,wk as Me,w5 as hi,we as Dn,wn as ie,fF as Ne,VA as An,vT as Ue,wi as Ii,wj as Ci,wh as Ei,_a as ki,wV as yi,wR as Ln,_b as $n,vD as nn,_c as xi,vz as bi,_d as ji,yF as Pi,yJ as q,yE as Di,xN as Be,_e as Ai,_f as Fn,yS as tn,_g as Li,yP as $i,_h as wn,xQ as Fi,xR as V,xU as wi,_i as Rn,y2 as Ie,_j as Ri,xb as _n,U6 as Tn,_k as _i,yc as Ti,_l as On,_m as Oi,_n as Mi,_o as Ni,zH as Ui,_p as Bi,_q as Mn,yZ as Nn,_r as Un,zF as Ce,_s as Vi,zC as Hi,_t as qi,_u as zi,_v as Qi,_w as Ki,_x as Zi,_y as on,_z as Gi,eg as Wi,zL as Xi,_A as Ve,xv as Ji,xq as Yi,_B as de,xG as Bn,xy as ue,xx as eo,xB as Vn,_C as no,xw as to,_D as Hn,z3 as qn,zu as an,zp as io,_E as oo,z4 as ao,_F as so,zv as co,zz as ro,_G as He,wv as zn,zg as lo,ww as uo,_H as go,_I as Qn,c8 as mo,ms as vo,mt as po,_J as sn,wu as ge,gl as fo,mz as So,zm as Kn,zX as ho,zj as Zn,uX as Io,zU as cn,uL as Co,zR as rn,hS as Eo,Uz as ln,UA as ko,Gf as Gn,hK as yo,_K as xo,Vp as bo,_L as jo,A0 as Ee,A1 as Po,_M as Do,_N as Wn,z_ as Ao,_O as Lo,_P as $o,yg as Fo,_Q as wo}from"./zeni-epic-state-Dmop9tB7.js";import{M as Ro}from"./MobileAppDrawer-CdDtqWOO.js";import{q as me}from"./QBOConnectionScreen-ByT4Lz_O.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.js";import"./InboxNotificationsProvider-zG7x1gLM.js";import"./useTaskManagerAccess-BOnqrzjJ.js";import"./empty-DTjUxrNn.js";import"./pdf-lib-LgS50teK.js";import"./index-DBaQwW7d.js";import"./url-Eifk29FQ.js";import"./index-RA90NjT0.js";import"./decodeURIComponentSafe-BkSrHWOz.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]="e9a214af-d726-463a-99bf-12e8f90d1eeb",t._sentryDebugIdIdentifier="sentry-dbid-e9a214af-d726-463a-99bf-12e8f90d1eeb")}catch{}})();const $=({event:t,isReady:e=!0})=>e?s.jsx(st,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function _o(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,items:f,nextCursor:h,auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b}=C(Gt),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${n??""}/invoicing`,I=r.useCallback(((L,U)=>{const T=Wt(y,L,U,P);T!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:L,entityId:U,fromScreen:"audit_log"}),e(T))}),[P,e,y]);r.useEffect((()=>{const L=setTimeout((()=>d(a)),300);return()=>clearTimeout(L)}),[a]),r.useEffect((()=>{i&&t(Ze({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,t]);const j=g==="Not-Started"||g==="In-Progress"&&f.length===0,E=g==="In-Progress"&&f.length>0,F=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:F}),s.jsx(ct,{auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b,entries:f,hasMore:S,isLoading:j,isLoadingMore:E,searchValue:a,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&t(Ze({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function pe(t,e=!1){const n=D(),i=C((c=>K(c).productNextCursor!=null)),a=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&&a!=null&&n(se({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function fe(t,e,n,i){const[a,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]),a}const To=new Set(["plan"]),Oo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&t(Sn({action:a,id:i}))}:void 0,onEditChange:a=>{i!==""&&t(_e({id:i,localData:a}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),t(fn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(Xt({action:o,id:a,parentItemId:i}))}}}))(rt);function Mo(){const t=D(),e=A(),{item_id:n,tenantEmailDomain:i}=R(),[a]=Z(),{areTenantIdsInSync:o}=_(),c=(d=a.get("kind"))!=null&&To.has(d)?d:"plan";var d;const l=C((k=>Re(k,n))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(t(ce({id:n})),()=>{t(ce({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(be({id:n,kind:c}))}),[o,n,c,t]);const g=r.useCallback((k=>t(be({cacheOverride:!0,id:k,kind:c}))),[t,c]),S=fe(l.fetchState,l.isFormLoading,n,g),f=u==="Completed"&&!l.isFormLoading;pe(o,!0);const[h,P]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&P(n)}),[n,f]);const b=h!==n&&(u==="Not-Started"||u==="In-Progress"||l.isFormLoading);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Oo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:b,view:l},S)]})}const No=new Set(["addon","charge","plan"]),Uo=new Set(["plan"]),Bo=O((function(t,e){const n=Re(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:a}=e,o=a!=null?`${n}/catalog/${encodeURIComponent(a)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),t(ce({id:a})),e.navigate(`${n}/catalog`)},onChange:c=>{t(_e({id:a,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),t(fn({id:a}))}}}))(lt);function Vo(){const t=D(),e=A(),{item_id:n,tenantEmailDomain:i}=R(),[a]=Z(),{areTenantIdsInSync:o}=_(),c=n!=null,d=a.get("type"),l=d!=null&&No.has(d)?d:void 0,v=(u=a.get("kind"))!=null&&Uo.has(u)?u:"plan";var u;const g=C((S=>Re(S,n)));return pe(o,!0),r.useEffect((()=>{o&&t(be({id:n,kind:v}))}),[o,n,v,t]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||t(_e({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const S=g.savedItemId??n,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),t(ce({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),s.jsx(Bo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const Ho={addons:"addon",all:"item",charges:"charge",plans:"plan"},qo=O((function(t,e){const n=K(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,c=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Ho[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(Sn({action:Jt(d),id:c}))},onLoadMore:()=>{if(a)return e.planNextCursor!=null&&t(We({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?We({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(dt);function zo(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),P=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),b=C((L=>K(L))),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 L=setTimeout((()=>v(a)),300);return()=>clearTimeout(L)}),[a]),r.useEffect((()=>{i&&t(Ge({cacheOverride:!1,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[i,t,h,P,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==y?.field||S?.dir!==y?.dir)&&t(Ge({cacheOverride:!0,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[k,y,i,t,h,P,f,S]),N(b.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),s.jsx(qo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:a,sortState:u,planFilters:h,productFilters:P,sort:S,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:F,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Qo=O((function(t,e){const n=hn(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,a=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(ei({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:a}),t(Yt({id:i}))}}}))(ut);function Ko(){const t=D(),e=A(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),{fetchState:o,savedCouponId:c}=C((d=>hn(d,n)));return r.useEffect((()=>{a&&t(je({id:n}))}),[a,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]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCouponFormPage}),s.jsx(Qo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Zo=O((function(t){const e=In(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:a=>{e(En(a))},onSubmit:()=>{const a=ii(t.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(oi(a))}}}))(mt);function Go(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),[i]=Z(),{areTenantIdsInSync:a}=_(),o=i.get("customerId"),c=C((I=>In(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(Cn),g=C((I=>ni(I))),S=C(ve),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,P=f||h,b=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(Xe()),()=>{t(Xe())})),[t]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,t(En({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{a&&t(ti({cacheOverride:!1}))}),[a,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]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),P?s.jsx(gt,{}):s.jsx(Zo,{navigate:e,tenantEmailDomain:n})]})}const Wo=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)}`)}}}))(vt);function Xo(){const t=D(),e=A(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),o=C((d=>ai(d,n??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(si({id:n}))}),[a,n,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Wo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const Jo=O((function(t){const e=kn(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(ri({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function Yo(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,creditNoteListFetchState:b}=C((y=>{const I=kn(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(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(Je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Je({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),s.jsx(Jo,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>t(ci(y)),onSortChange:v})]})}const Xn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},ea=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(Pe({id:i,localData:a}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onDiscardEdit:()=>{t(X(le)),t(fi({id:i}))},onOpenAddress:()=>{const a=Xn(e.tenantEmailDomain??"",le,i),o=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),t(Pe({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(pi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>t(vi({body:c,customerId:i,email:a,subject:o})),onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function na(){const t=D(),e=A(),n=G(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=_(),c=C((T=>Te(T,i))),d=c.pageFetchState.fetchState,l=d==="Completed"&&!c.isFormLoading,[v,u]=r.useState(!1),[g,S]=r.useState(!1),[f,h]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&h(i)}),[i,l]);const P=f===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(li({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&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(di({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&j&&t(Ye({customerId:i}))}),[o,i,t,j]);const L=r.useCallback((T=>t(yn({id:T}))),[t]),U=fe(c.fetchState,c.isFormLoading,i,L);return N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ea,{customerId:i??"",editView:c,hasLoadedRecord:P,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{t(ee()),i!=null&&j&&t(Ye({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),S(!0)}},U),s.jsx(ft,{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(gi({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:T=>{i!=null&&t(ui({customerId:i,data:T}))}}),s.jsx(St,{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:()=>{S(!1),t(ne())},onSubmit:({amount:T,description:Y})=>{i!=null&&t(mi({amount:T,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:Y}))}})]})}const ta=O((function(t,e){const n=Te(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,a=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(bn({id:i})),t(X(le)),e.navigate(`${n}/customers`)},onChange:c=>{t(Pe({id:i,localData:c}))},onOpenAddress:()=>{const c=Xn(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:a}),t(xn({id:i}))}}}))(It);function ia(){const t=D(),e=A(),n=G(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=_(),{fetchState:c,savedCustomerId:d}=C((l=>Te(l,i)));return r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(v),t(bn({id:i}))}}),[c,d,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerFormPage}),s.jsx(ta,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const oa=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,a)=>{switch(a){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(jn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ct);function aa(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,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(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(en({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(en({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),s.jsx(oa,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>t(Si(y)),onSortChange:v})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),sa=O((function(t,e){const{filters:n,sessionId:i,view:a}=e,o=i==null?void 0:a.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(a,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:a,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",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>a(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&t(Ae({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&t(Me(o))},onRollback:S?()=>{o!=null&&t(Pn(o))}:void 0}}))(Et);function ca(){const t=D(),e=A(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),[o,c]=r.useState({}),d=C(Oe),l=Le(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(De(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const f=setTimeout((()=>{t(Ae({...o,sessionId:n}))}),300);return()=>clearTimeout(f)}),[a,t,o,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!a||n==null||!u)return;const f=setInterval((()=>{t(De(n)),t(Ae({...o,sessionId:n}))}),3e3);return()=>clearInterval(f)}),[a,t,o,u,n]);const g=r.useMemo((()=>{if(n==null)return;const f=new URLSearchParams;o.moduleId!=null&&f.set("module_id",o.moduleId),o.level!=null&&f.set("level",o.level),o.outcome!=null&&f.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&f.set("search",o.search.trim());const h=f.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(sa,{downloadUrl:g,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const Jn=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=Jn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ra=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const c=o??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(Me(o)),a(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Pn(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(kt);function la(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),a=C(Oe);r.useEffect((()=>{i&&(t(hi()),t(Dn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ra,{navigate:e,tenantEmailDomain:n,view:a})]})}const da=O((function(t,e){const{activeId:n,integrationsView:i,settings:a,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:a?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:a?.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:a}=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(Ei())},onGoToIntegrations:()=>{i(`/${a}/invoicing/settings`)},onGoToOverview:()=>i(`/${a}/invoicing/overview`),onRetry:()=>{n!=null&&t(Me(n))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),n!=null&&t(Ci(n))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),t(Ii({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(yt);function ua(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),a=C(Cn),o=C(Ne).companyId??xe.getSignedInUserTenant(n??"")?.companyId,c=C((f=>An(f,o))),d=C(Oe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(t(Ue()),t(Dn()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(Jn(h))}catch{return null}})(n);f!=null&&t(ie(f))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const g=u?.status,S=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{t(De(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,t]),r.useEffect((()=>{g==="done"&&(t(ie(null)),oe(n,null))}),[t,g,n]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportMigratePage}),s.jsx(da,{activeId:v,integrationsView:c,navigate:e,settings:a,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ga=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{t(Ln({action:a,id:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),t(yi({data:a,id:i}))}}}))(xt);function ma(){const t=D(),e=A(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),o=C((h=>ki(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((()=>{a&&t(je({id:n}))}),[a,n,t]);const S=r.useCallback((h=>t(je({cacheOverride:!0,id:h}))),[t]),f=fe(o.fetchState,o.isFormLoading,n,S);return N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(ga,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},f)]})}const va=O((function(t){const e=$n(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,a)=>{t(Ln({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(bi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function pa(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=$n(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(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&t(nn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(nn({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),s.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>t(xi(I)),onSortChange:v})]})}const fa=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,a=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:a?()=>t(q({action:"cancel",id:i})):void 0,onResolve:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(q({action:"resolve",id:i}))}:void 0,onResume:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(q({action:"resume",id:i}))}:void 0,onRetry:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(q({action:"retry",id:i}))}:void 0}}))(Pt);function Sa(){const t=D(),e=A(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),o=C((E=>ji(E,n??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[S,f]=r.useState(),[h,P]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[]),k=r.useCallback((()=>{if(n==null)return;t(Pi({id:n})),v("idle"),g(!1);const E=o.emailPreview.preview;f(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),P(!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((()=>{a&&n!=null&&t(Di({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&d!=null&&t(Be({invoiceId:d}))}),[a,d,t]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[n]),r.useEffect((()=>{a||(v("idle"),g(!1),f(void 0),P(!1))}),[a]),r.useEffect((()=>{h&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(n!=null&&t(Ai({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)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(fa,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:j,onSendEmail:k}),s.jsx(jt,{initialDraft:S,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 ha=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",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,a)=>{a!=="retry"&&a!=="resume"&&a!=="resolve"&&a!=="cancel"||t(q({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t($i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Dt);function Ia(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,dunningCaseListFetchState:b}=C((y=>{const I=Fn(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(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(tn({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),s.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>t(Li(y)),onSortChange:v})]})}const Ca=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:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},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:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),t(wi({data:{due_date:a.due_date!==""?a.due_date:void 0,notes:a.notes.trim()!==""?a.notes.split(`
2
2
  `).map((o=>o.trim())).filter((o=>o!=="")).map((o=>({note:o}))):void 0,po_number:a.po_number!==""?a.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceReminderSent,{invoiceId:i}),t(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onVoid:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:a}))}}}))(At);function Ea(){const t=D(),e=A(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),o=C((g=>wn(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((()=>{a&&n!=null&&t(Fi({invoiceId:n}))}),[a,n,t]),N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Ca,{invoiceId:n??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:o})]})}const ka=O((function(t){const e=Rn(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,a)=>{switch(a){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,a)=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:a}))},onLoadMore:()=>{e.nextCursor!=null&&t(_n({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Lt);function ya(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,invoiceListFetchState:b,voidingInvoiceId:k}=C((I=>{const j=Rn(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(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&t(Ie({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ie({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoicesListPage,isReady:y}),s.jsx(ka,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,voidingInvoiceId:k,onSearchChange:o,onStatusChange:I=>{t(Ri(I)),t(Ie({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v})]})}function dn(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),i=$t(),a=vn(),[o,c]=r.useState(!1),{acceptTermsState:d,status:l}=C(Tn),v=_i(i?.loggedInUserRoleMap),u=`/${n}/invoicing`,g=S=>{c(S)};return l==="completed"?s.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?s.jsx(B,{to:`${u}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(Ro,{isAppContentDrawerOpen:o,handleDrawerToggle:g}),s.jsx(Ft,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{t(Ti())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{g(!0)}})]})}const xa=O((function(t,e){const n=On(t,e.invoiceId),{invoice:i,localData:a,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:a,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:a=>{t(Bi({localData:a}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Ui())}}}))(wt);function ba(){const t=D(),e=A(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),{fetchState:o,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=C((f=>On(f,n??""))),u=`/${i}/invoicing`,g=r.useRef(null);r.useEffect((()=>{t(Oi()),g.current=null}),[t,n]),r.useEffect((()=>{a&&n!=null&&t(Be({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{c!=null&&n!=null&&o==="Completed"&&g.current!==n&&(g.current=n,t(Mi({localData:Ni(c)})))}),[t,o,c,n]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(xa,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const ja=O((function(t){return{invoicingOverview:Mn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{t(Nn(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`)}}}))(Rt);function Pa(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),o=C((c=>Mn(c).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Nn(a))}),[i,t,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingOverviewPage,isReady:o}),s.jsx(ja,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const Da=O((function(t){const e=Un(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{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(Hi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(_t);function Aa(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,transactionListFetchState:b,transactions:k}=C((F=>{const L=Un(F);return{activeType:L.activeTab,appliedSearch:L.filters.search,appliedSort:L.sort,nextCursor:L.nextCursor,transactionListFetchState:L.fetchState,transactions:L.transactions}}),H),y=b==="Completed",I=`/${n}/invoicing`,j=r.useCallback((F=>{const L=k.find((T=>T.id===F)),U=L?.linkedInvoices?.[0]?.invoiceID??L?.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 L=k.find((U=>U.id===F))?.customerID;L!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:L,fromScreen:"payments_list",toScreen:"customer"}),e(`${I}/customers/${encodeURIComponent(L)}`))}),[e,I,k]);return r.useEffect((()=>{const F=setTimeout((()=>d(a)),300);return()=>clearTimeout(F)}),[a]),r.useEffect((()=>{i&&t(Ce({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ce({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingPaymentsListPage,isReady:y}),s.jsx(Da,{navigate:e,tenantEmailDomain:n,activeType:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onTypeChange:F=>{t(Vi(F)),t(Ce({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v,onViewTransactionCustomer:E,onViewTransactionInvoice:j})]})}const La=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 un(){const t=D(),e=A(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=_(),o=n!=null&&n!=="",c=C(ve),d=C((E=>qi(E))),l=C(zi),v=C((E=>wn(E,n??""))),u=v.invoice,g=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Qi()),S.current=null,f.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?Be({invoiceId:n}):jn({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&u!=null&&n!=null&&v.fetchState==="Completed"&&S.current!==n&&(S.current=n,t(Ki({contextInvoiceId:n,localData:Zi(u)})))}),[t,u,n,v.fetchState,o]),r.useEffect((()=>{if(o)return;const E=d.localData.customerId;E!==""&&E!==f.current&&(f.current=E,t(_n({filters:{customerId:E},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&t(on({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 P=r.useMemo((()=>c.customers.map((E=>({id:E.id,name:La(E)})))),[c.customers]),b=C((E=>Gi(E,d.localData.customerId))),k=r.useMemo((()=>b.map((E=>{return{amountDue:(F=E.amountDue,L=Wi.currencySymbol,Ot("0,0.00",F,L)),amountDueValue:E.amountDue,id:E.id,label:E.invoiceNumber};var F,L}))),[b]),y=r.useMemo((()=>{if(!o||u==null)return;const E=u.currencyCode??"USD",F=u.amountDue?.amount??0;return{amountDue:we("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 s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingRecordPaymentPage,isReady:j}),s.jsx(Tt,{customers:P,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(on({localData:E}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:o?n:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),t(Xi(o?n??void 0:void 0))}})]})}const Yn=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},$a=(t,e)=>{if(t==null)return;const n=we("0,0",t);return e!=null?`${n}/${e}`:n},$e=(t,e,n)=>{const i=[t,$a(e,n)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},ke=t=>t.priceCode!=null&&t.priceCode.trim()!=="",Fa=t=>({billingCycles:t.billingCycles,billingPeriod:t.period,billingPeriodUnit:t.periodUnit,label:t.name??t.id,subtitle:$e(t.productCode,t.displayPrice??t.price,t.periodUnit),value:t.priceCode}),wa=t=>({label:t.name??t.couponCode??t.id,value:t.couponCode??t.id}),Ra=O((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.products.filter((c=>c.itemType==="addon")).filter(ke).map((c=>({label:c.name??c.id,subtitle:$e(c.productCode,c.displayPrice??c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:o,charges:n.products.filter((c=>c.itemType==="charge")).filter(ke).map((c=>({label:c.name??c.id,subtitle:$e(c.productCode,c.displayPrice??c.price,void 0),value:c.priceCode}))),coupons:n.coupons.map(wa),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.filter(ke).map(Fa),shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),t(Vn({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:c=>{t(de({id:i,localData:c}))},onChangeTermEnd:a?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(eo({id:i}))},onOpenAddress:()=>{const c=Yn(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(Bn({id:i}))},onCancelSubscription:a?c=>{o("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(c,d)=>{c!=="pause"?o(c):o(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Mt);function _a(){const t=D(),e=A(),n=G(),{subscription_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=_(),c=C((k=>Ve(k,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,g=u==="Completed"&&!c.isFormLoading,[S,f]=r.useState(g?i:void 0);r.useEffect((()=>{i!=null&&g&&f(i)}),[i,g]);const h=S===i;pe(o),r.useEffect((()=>{o&&i!=null&&t(Ji({id:i}))}),[o,i,t]);const P=r.useCallback((k=>t(Yi({id:k}))),[t]),b=fe(c.fetchState,c.isFormLoading,i,P);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionDetailPage,isReady:g}),s.jsx(Ra,{hasLoadedRecord:h,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:n,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},b)]})}const Ta=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},Oa=(t,e)=>{if(t==null)return;const n=we("0,0",t);return e!=null?`${n}/${e}`:n},Fe=(t,e,n)=>{const i=[t,Oa(e,n)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},Ma=t=>({label:Ta(t),value:t.id}),ye=t=>t.priceCode!=null&&t.priceCode.trim()!=="",Na=t=>({billingCycles:t.billingCycles,billingPeriod:t.period,billingPeriodUnit:t.periodUnit,label:t.name??t.id,subtitle:Fe(t.productCode,t.displayPrice??t.price,t.periodUnit),trialPeriod:t.trialPeriod,trialPeriodUnit:t.trialPeriodUnit,value:t.priceCode}),Ua=t=>({label:t.name??t.couponCode??t.id,value:t.couponCode??t.id}),Ba=O((function(t,e){const n=Ve(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.products.filter((i=>i.itemType==="addon")).filter(ye).map((i=>({label:i.name??i.id,subtitle:Fe(i.productCode,i.displayPrice??i.price,i.periodUnit),value:i.priceCode}))),charges:n.products.filter((i=>i.itemType==="charge")).filter(ye).map((i=>({label:i.name??i.id,subtitle:Fe(i.productCode,i.displayPrice??i.price,void 0),value:i.priceCode}))),coupons:n.coupons.map(Ua),customers:n.customers.map(Ma),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.filter(ye).map(Na),shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionFormCancelled),t(Hn({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=Yn(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:a}),t(Bn({id:i}))}}}))(Nt);function Va(){const t=D(),e=A(),n=G(),{subscription_id:i,tenantEmailDomain:a}=R(),[o]=Z(),{areTenantIdsInSync:c}=_(),d=o.get("customerId"),{fetchState:l,savedSubscriptionId:v}=C((S=>no(S,i))),u=C((S=>Ve(S,i).localData));pe(c),r.useEffect((()=>{c&&t(to({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 S=v??i,f=S!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${a}/invoicing/subscriptions`;e(f),t(Hn({id:i}))}}),[l,v,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionFormPage}),s.jsx(Ba,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Ha=O((function(t){const e=qn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,c)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:o,subscriptionId:a}),t(Vn({action:o,id:a,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const c=o?.trim()??"";c!==""&&i(a,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(a,o,c)=>{o!=="pause"?i(a,o):i(a,o,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&t(ao({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ut);function qa(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),[a,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:S,appliedSearch:f,appliedSort:h,nextCursor:P,subscriptionListFetchState:b,runningActionSubscriptionId:k}=C((j=>{const E=qn(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(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(an({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(an({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]);const I=r.useRef(k);return r.useEffect((()=>{const j=I.current!=null&&k==null;I.current=k,j&&i&&t(io())}),[k,i,t]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionsListPage,isReady:y}),s.jsx(Ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningActionSubscriptionId:k,onSearchChange:o,onStatusChange:j=>t(oo(j)),onSortChange:v})]})}const za=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(m.Event.invoicingTransactionCaptured,{transactionId:i}),t(ro({action:"capture",id:i}))}:void 0}}))(Bt);function Qa(){const t=D(),e=A(),{tenantEmailDomain:n,transaction_id:i}=R(),{areTenantIdsInSync:a}=_(),o=C((d=>so(d,i??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(co({id:i}))}),[a,i,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(za,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function et(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=D(),{areTenantIdsInSync:c}=_(),d=C(He),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(a&&v!=="Not-Started"||o(zn()),n&&o(lo()))}),[c,o,e,n,a]),r.useEffect((()=>{e&&c&&l&&i&&o(uo())}),[c,o,e,l,i]),{isQboConnected:l,qboView:d}}const Ka={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function J(t){const e=D(),{areTenantIdsInSync:n}=_(),{tenantEmailDomain:i}=R(),{fetchState:a,fieldHelp:o,logoFile:c,saveState:d,settings:l,stripeConnectState:v}=C(go),{configError:u,configFetchState:g,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:P}=C(Qn),b=C(He);et({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const k=C(Ne),y=t==="dunning"||t==="quickbooks",I=k.companyId??xe.getSignedInUserTenant(i??"")?.companyId,j=C((w=>An(w,I))),E=mo(k.userRole??[]),F=k.tenantId??"",L=xe.getSignedInUser(),U={userId:L?.userId??"",sessionId:L?.zeniSessionId??"",tenantId:F},T=c?.fileId,Y=C((w=>T!=null&&T!==""?vo(w,T):void 0)),qe=C((w=>T!=null&&T!==""?po(w,T):void 0)),nt=T!=null&&T!==""&&Y!=null?{[T]:Y}:{},tt=T!=null&&T!==""&&qe!=null?{[T]:qe}:{};r.useEffect((()=>(e(sn()),()=>{e(sn())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Ue()))}),[n,e,a]),r.useEffect((()=>{n&&y&&g==="Not-Started"&&e(ge())}),[n,e,g,y]),r.useEffect((()=>{if(!n)return;const w=L?.userId;w!=null&&w!==""&&F!==""&&Ke.shouldFetchActiveTenant(F)&&(Ke.markActiveTenantFetchStarted(F),e(fo(w,F,L?.zeniSessionId)))}),[n,e,L?.userId,L?.zeniSessionId,F]);const it=S.length>0||f.length>0,ot=a==="Not-Started"||a==="In-Progress"&&l==null||y&&!it&&(g==="Not-Started"||g==="In-Progress"),at=a==="Completed"&&(!y||g==="Completed"),ze=j.externalConnections?.revenue?.find((w=>w.connectionName==="chargebee"))?.connectionId,Se=ae?.invoicingMicroServiceBaseUrl,Qe=Se!=null&&Se.length>0?`${Se}/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(rn(w)),onDisconnect:(w,z)=>{F!==""&&e(yo(F,w,ln(z)))},onDisconnectStripe:()=>e(cn()),onReconnectQBO:()=>{const w=k.tenantEmailDomain??i??"";me.init("/connection/auth",w),me.handleClick()},onRefreshQBO:()=>{j.integrations.refreshQBO.fetchState!=="In-Progress"&&e(Gn())},onSaveChargeBeeCredentials:(w,z)=>{ze!=null&&F!==""&&e(Eo(F,ze,ln("revenue"),ko("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:Qe};return{authParams:U,deleteFileStatusById:nt,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:ae?.fileMicroServiceBaseUrl??"",integrationsSectionProps:he,isInvoicingPageReady:at,isLoading:ot,isSaving:d.fetchState==="In-Progress",isStripeBusy:v.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:P,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:Qe,updateFileStatusById:tt,onConnectStripe:w=>e(rn(w)),onDeleteFile:w=>e(Co(w,F)),onDisconnectStripe:()=>e(cn()),onEditFileName:(w,z)=>e(Io(w,z.split(".")[0],F)),onReconnectQBO:he.onReconnectQBO,onRefreshQBO:he.onRefreshQBO,onRetryQboSyncTask:w=>e(Zn(w)),onSave:w=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:t??"hub"}),e(ho({settings:w,snackbarSection:Ka[t??""]}))},onStartQboBackfill:w=>e(Kn(w)),updateFilesEntity:w=>{p.trackInvoicingActionClick(m.Event.invoicingLogoUploaded),e(So({files:w}))}}}function gn({appContent:t}){const e=A(),n=G(),i=D(),{tenantEmailDomain:a}=R(),o=J("branding"),c=C((v=>xo(v))),d=C((v=>bo(Ee,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(jo()),i(X(Ee)))}),[c.saveState.fetchState,i]);const l=pn(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Vt,{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(Do({localData:v}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{const v=`/${a}/invoicing/settings/branding/${Ee}/`,u=W(n.state?.pathnameStackToGoBack,n.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Po()),updateFilesEntity:o.updateFilesEntity})]})}function Za(){const t=A(),e=J("dunning");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Ht,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Ga(){const t=A(),e=J("integrations");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(qt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Wa(){const t=A(),e=J("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(zt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Xa=O((function(t){const e=Wn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t($o({localData:e}))},onReset:()=>{t(Lo())},onRetryTask:e=>{t(Zn(e))},onSave:()=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:"quickbooks"}),t(Ao())},onStartBackfill:e=>{t(Kn(e))}}}))(Qt);function Ja(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),i=C(Ne),{configFetchState:a,settingsFetchState:o}=C(Wn);return r.useEffect((()=>{o!=="Not-Started"&&o!=="Error"||t(Ue())}),[t,o]),r.useEffect((()=>{a==="Not-Started"&&t(ge())}),[a,t]),et({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage}),s.jsx(Xa,{onBackClick:()=>e(".."),onReconnect:()=>{me.init("/connection/auth",i.tenantEmailDomain??n??""),me.handleClick()},onRefresh:()=>t(Gn())})]})}const Ya={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function es(){const t=vn(),e=D(),n=A(),[i,a]=Z(),o=J(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=C(Qn),g=i.get("tab");return r.useEffect((()=>{if(g==null)return;const S=Ya[g];a({},{replace:!0}),S!=null&&n(S,{replace:!0})}),[g,n,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Kt,{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(Fo())}})]})}function mn(){return s.jsxs(te,{children:[s.jsx(x,{index:!0,element:s.jsx(es,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(Wa,{})}),s.jsx(x,{path:"branding",element:s.jsx(gn,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(gn,{appContent:s.jsx(Q,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(Ga,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Za,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(Ja,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function Ds(){const t=D(),e=A(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=_(),{enableState:a,fetchState:o,status:c}=C(Tn),d=pn(a.fetchState),l=`/${n}/invoicing`,v=r.useRef(!1),u=C((g=>He(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(zn())}),[i,t,u]),r.useEffect((()=>{d==="In-Progress"&&a.fetchState==="Completed"&&(e(`${l}/catalog`),t(wo()))}),[d,a.fetchState,l,t,e]),c==null&&o!=="Error"?s.jsx(Zt,{fetchState:"In-Progress"}):c==="not_started"?s.jsxs(te,{children:[s.jsx(x,{path:"promo",element:s.jsx(dn,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(te,{children:[s.jsx(x,{path:"promo",element:s.jsx(dn,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(mn,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(te,{children:[s.jsx(x,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx(Pa,{})}),s.jsx(x,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(aa,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(ia,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(Q,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(na,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(Q,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(qa,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(Va,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(Q,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(_a,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(Q,{})}),s.jsx(x,{path:"invoices",element:s.jsx(ya,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(Go,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(Ea,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(un,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(ba,{})}),s.jsx(x,{path:"payments",element:s.jsx(Aa,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(un,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(Qa,{})}),s.jsx(x,{path:"credits",element:s.jsx(Yo,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(Xo,{})}),s.jsx(x,{path:"discounts",element:s.jsx(pa,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(Ko,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(ma,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Ia,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Sa,{})}),s.jsx(x,{path:"catalog",element:s.jsx(zo,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(Vo,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Mo,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(mn,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(_o,{})}),s.jsx(x,{path:"data_import",element:s.jsx(la,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(ua,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(ca,{})}),s.jsx(x,{path:"*",element:s.jsx(M,{})})]})}export{Ds as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-BF-IiX2V.js";import{i as S,l as g,h as C,g as y,u as ee,t as ae,j as E,N as te,n as ne,o as p}from"./core-C1MQ75FC.js";import{Us as k,Ut as v,Uu as T,Jw as D,Ji as U,Uv as B,Uw as oe,Ux as ie,Jm as se,gi as $,Jt as le,Jq as re}from"./zeni-epic-state-Dmop9tB7.js";import{a2 as x,J as r,a3 as de,l 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,f 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-DMDsYekO.js";import{n as m}from"./mui-D4JyxRuO.js";import f from"./NotFoundScreen-znPj3CVA.js";import{a as I}from"./sentry-DQv7eTqs.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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]="3daf38a7-4517-4bbc-89cc-8c8d8e2a79e1",e._sentryDebugIdIdentifier="sentry-dbid-3daf38a7-4517-4bbc-89cc-8c8d8e2a79e1")}catch{}})();const Ie=m.div`
1
+ import{j as a}from"./liveblocks-BF-IiX2V.js";import{i as S,l as g,h as C,g as y,u as ee,t as ae,j as E,N as te,n as ne,o as p}from"./core-C1MQ75FC.js";import{Us as k,Ut as v,Uu as T,Jw as D,Ji as U,Uv as B,Uw as oe,Ux as ie,Jm as se,gi as $,Jt as le,Jq as re}from"./zeni-epic-state-Dmop9tB7.js";import{a2 as x,J as r,a3 as de,l 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,f 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-DheSTGi7.js";import{n as m}from"./mui-D4JyxRuO.js";import f from"./NotFoundScreen-ujna2tN5.js";import{a as I}from"./sentry-DQv7eTqs.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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]="3daf38a7-4517-4bbc-89cc-8c8d8e2a79e1",e._sentryDebugIdIdentifier="sentry-dbid-3daf38a7-4517-4bbc-89cc-8c8d8e2a79e1")}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 f}from"./liveblocks-BF-IiX2V.js";import{a as u}from"./sentry-DQv7eTqs.js";import{u as O,g as _,h as w,t as V,j as l,N as L}from"./core-C1MQ75FC.js";import{z as r,E as M,G as P,U as A,l as N,V as X,$,a0 as q,X as G}from"./index-DMDsYekO.js";import{fF as R,TX as W,Uo as B,Uf as H,gi as J,gk as K,Uk as Q,gU as Y,dj as Z,Up as ee,Uq as te}from"./zeni-epic-state-Dmop9tB7.js";import{n as ne}from"./mui-D4JyxRuO.js";import{u as ae}from"./useDeviceId-BrccfFDF.js";import{f as se}from"./analyticsHelper-DsmnThaa.js";import{t as ie}from"./getLocaleForTenant-B7a_04KB.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="5fd1021f-aef7-4043-af35-a0246b6d5706",t._sentryDebugIdIdentifier="sentry-dbid-5fd1021f-aef7-4043-af35-a0246b6d5706")}catch{}})();const T=(t,s)=>t!=null&&t.length>0&&s==="magic_links";function Te(){const t=O(),s=_(),m=w(),[y]=V(),n=y.get("token"),p=y.get("stytch_token_type"),g=r.getMagicLinkCodeVerifier(),i=ae(),{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)),I=l((e=>e.tenantState.signInState)),h=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),a=l((e=>e.tenantState.loggedInUser)),o=l((e=>R(e))),k=l((e=>W(e))),D=r.getSignedInUser(),v=M().mode;u.useEffect((()=>{a?.zeniSessionId==null&&n!=null&&T(n,p)&&i!=null&&g!=null&&(r.saveMagicLinkTriggered(n),t(B(n,i,g)))}),[n,p,t,i,g,a?.zeniSessionId]),u.useEffect((()=>{I!=="In-Progress"||S!=="Completed"&&b!=="Completed"||a?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(a,a.zeniSessionId),r.saveSignedInUserTenants(H(k.tenantsInOrder),a.zeniSessionId),J(a.userId,a.zeniSessionId,o.tenantId),t(K(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(Q("Completed")),P.updateAppLocaleID(ie(o)),se(a,o,v,void 0,k.tenantsInOrder),Y().then((()=>{const e=G();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin(X.Event.loginSuccess,"email",Z(o.productSettings))}),2e3))}),[I,S,b,a,o,k,v,s.state,t]);const E=u.useCallback((()=>{m("/signin/auth")}),[m]),j=u.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),F=u.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(te(e,i,c,d))}),[i,n,t,c,d]);if(h==="Completed"&&d!=null)return f.jsx($,{phoneNumber:C,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:E});if(I==="In-Progress"&&S==="Completed"&&a?.zeniSessionId!=null&&o!=null||D!=null){const e=s.state?.origin??"/";return f.jsx(L,{to:e,state:{...s.state,origin:""}})}if(!T(n,p)||g==null||h==="Error"){const e=s.state?.origin??"/",U=n!=null&&r.getLastUsedMagicLinkToken()===n;return f.jsx(L,{to:e,state:{...s.state,origin:"",magicLinkAlreadyUsed:U,magicLinkExpired:!U&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&a?.zeniSessionId==null)}})}return f.jsx(oe,{"data-testid":"smooth-loader",children:f.jsx(q,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
1
+ import{j as f}from"./liveblocks-BF-IiX2V.js";import{a as u}from"./sentry-DQv7eTqs.js";import{u as O,g as _,h as w,t as V,j as l,N as L}from"./core-C1MQ75FC.js";import{z as r,E as M,G as P,U as A,l as N,V as X,$,a0 as q,X as G}from"./index-DheSTGi7.js";import{fF as R,TX as W,Uo as B,Uf as H,gi as J,gk as K,Uk as Q,gU as Y,dj as Z,Up as ee,Uq as te}from"./zeni-epic-state-Dmop9tB7.js";import{n as ne}from"./mui-D4JyxRuO.js";import{u as ae}from"./useDeviceId-BrccfFDF.js";import{f as se}from"./analyticsHelper-vNgRVJkc.js";import{t as ie}from"./getLocaleForTenant-BAgQLN5V.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="5fd1021f-aef7-4043-af35-a0246b6d5706",t._sentryDebugIdIdentifier="sentry-dbid-5fd1021f-aef7-4043-af35-a0246b6d5706")}catch{}})();const T=(t,s)=>t!=null&&t.length>0&&s==="magic_links";function Te(){const t=O(),s=_(),m=w(),[y]=V(),n=y.get("token"),p=y.get("stytch_token_type"),g=r.getMagicLinkCodeVerifier(),i=ae(),{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)),I=l((e=>e.tenantState.signInState)),h=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),a=l((e=>e.tenantState.loggedInUser)),o=l((e=>R(e))),k=l((e=>W(e))),D=r.getSignedInUser(),v=M().mode;u.useEffect((()=>{a?.zeniSessionId==null&&n!=null&&T(n,p)&&i!=null&&g!=null&&(r.saveMagicLinkTriggered(n),t(B(n,i,g)))}),[n,p,t,i,g,a?.zeniSessionId]),u.useEffect((()=>{I!=="In-Progress"||S!=="Completed"&&b!=="Completed"||a?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(a,a.zeniSessionId),r.saveSignedInUserTenants(H(k.tenantsInOrder),a.zeniSessionId),J(a.userId,a.zeniSessionId,o.tenantId),t(K(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(Q("Completed")),P.updateAppLocaleID(ie(o)),se(a,o,v,void 0,k.tenantsInOrder),Y().then((()=>{const e=G();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin(X.Event.loginSuccess,"email",Z(o.productSettings))}),2e3))}),[I,S,b,a,o,k,v,s.state,t]);const E=u.useCallback((()=>{m("/signin/auth")}),[m]),j=u.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),F=u.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(te(e,i,c,d))}),[i,n,t,c,d]);if(h==="Completed"&&d!=null)return f.jsx($,{phoneNumber:C,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:E});if(I==="In-Progress"&&S==="Completed"&&a?.zeniSessionId!=null&&o!=null||D!=null){const e=s.state?.origin??"/";return f.jsx(L,{to:e,state:{...s.state,origin:""}})}if(!T(n,p)||g==null||h==="Error"){const e=s.state?.origin??"/",U=n!=null&&r.getLastUsedMagicLinkToken()===n;return f.jsx(L,{to:e,state:{...s.state,origin:"",magicLinkAlreadyUsed:U,magicLinkExpired:!U&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&a?.zeniSessionId==null)}})}return f.jsx(oe,{"data-testid":"smooth-loader",children:f.jsx(q,{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 D}from"./liveblocks-BF-IiX2V.js";import{a as m}from"./sentry-DQv7eTqs.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as F}from"./core-C1MQ75FC.js";import{fF as ne,TY as xe,TZ as se,g9 as Ue,fE as Ne,U6 as Pe,T$ as Re,U0 as Ve,p$ as Oe,gm as Le,U3 as b,U8 as je,U9 as Q,gn as Ze,Ua as ze,E9 as He,h1 as Ye,cV as qe,Ub as We,g8 as Je,go as Ke}from"./zeni-epic-state-Dmop9tB7.js";import{w as Qe,i as Xe,O as ea,o as aa,c as ta,f as na,u as sa,S as c,g as oa,e as ia,z as ra,d as da,n as ca,D as la,s as ua,q as ma,r as X,L as fa,F as ha,H as ba,p as S,l as ee,x as pa,P as ae,A as ga,C as Sa}from"./index-DMDsYekO.js";import{D as Ea}from"./mui-D4JyxRuO.js";import{u as ka}from"./InboxNotificationsProvider-zG7x1gLM.js";import{u as Ca}from"./useTaskManagerAccess-CZ3Xfg1w.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]="5b9bcb15-0f42-4810-9571-50ca60f491d8",l._sentryDebugIdIdentifier="sentry-dbid-5b9bcb15-0f42-4810-9571-50ca60f491d8")}catch{}})();const Ta=Qe((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),E=ea(),n=Me(),B=Ue(),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]=m.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,x=F("/:tenantEmailDomain/reports")!==null,f=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:U}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,U),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),N=t((e=>Re(e))),{isFeatureEnabled:T}=d(c.isReferralFeatureEnabled),v=t((e=>Ve(e)));m.useEffect((()=>{C&&T&&!f&&v.fetchState==="Not-Started"&&r(Oe(!0))}),[C,T,v.fetchState,f]);const _=t((e=>e.tenantState)),me=t((e=>_.fetchState==="Completed"?Le(e):[])),g=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:fe}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),P=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Ee=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>b(e).totalUnreadCount)),Ce=t((e=>b(e).reducedFetchCountState)),R=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),V=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),O=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:L,isLoading:j,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Te}=ka();m.useEffect((()=>{const e=setTimeout((()=>Te?.()),0);return()=>clearTimeout(e)})),m.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]),m.useEffect((()=>{C&&k&&!f&&O.fetchState==="Not-Started"&&B.tenantId!=null&&r(je("task_manager","dashboard"))}),[C,k,f,O.fetchState,B.tenantId,r]),m.useEffect((()=>{f||I.fetchState!=="Not-Started"||r(Q({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[f,I.fetchState,r]),m.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(Q({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ce,count:ke},H=s!=null?ra.getSignedInUserTenant(s):null,Y=t((e=>H?.tenantId!=null?Ze(e,H.tenantId):void 0)),h=[];fe===!1&&h.push("accounts_payable_aging"),he===!1&&h.push("accounts_receivable_aging"),h.push("zeni_accounts_promo_card","treasury_promo_card"),T===!1&&h.push("rewards_card"),P===!1&&h.push("expense_automation_card");const q=t((e=>ze(e,h).fetchState)),W=t((e=>He(e).fetchState)),ye=A&&(q==="Completed"||q==="Error")||x&&(W==="Completed"||W==="Error")||!A&&!x?void 0:"disabled",we=m.useMemo((()=>Ye(o.userRole)),[o.userRole]),Ae=qe(we),ve=o?.rewardsLastViewedTime==null,_e=p?.userEmail!=null&&N.fetchState==="Completed"&&We(N.notificationSettings,p.userEmail,U,o,k),J=da(),Fe=J&&ca(a);return D.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:D.jsx(la,{signedInUser:p,currentTenantId:_.currentTenantId??"",tenants:_.fetchState==="Completed"?me:Y!=null?[Y]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Ee,isNotificationsTabVisible:_e,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:P,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:T,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:J,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=S(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=S(a.state?.pathnameStackToGoBack,a.pathname);n("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMenuChange:e=>{if(i(!1),s==null)return;if(e.type==="invoicing")return void n(`../${s}/invoicing/overview`,{state:{pathnameStackToGoBack:S(a.state?.pathnameStackToGoBack,a.pathname),referrer:"Sidebar"}});if(e.type==="ai_cfo"){if(ee.trackAICFOChatScreenStateChanged("viewed","left_menu",G??null,null),!oe)return void pa({location:a,navigate:n,mergeState:{referrer:"Sidebar"}});const y=S(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=S(a.state?.pathnameStackToGoBack,a.pathname),K=e.type,De=ae(K)&&K!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),De&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Be=ga(e.type);Sa(e.type)?(G!=null&&r(Ke()),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(fa.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{E.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Je({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),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)&&xe(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return D.jsx(Ta,{...l,...a})};export{Ba as M};
1
+ import{j as D}from"./liveblocks-BF-IiX2V.js";import{a as m}from"./sentry-DQv7eTqs.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as F}from"./core-C1MQ75FC.js";import{fF as ne,TY as xe,TZ as se,g9 as Ue,fE as Ne,U6 as Pe,T$ as Re,U0 as Ve,p$ as Oe,gm as Le,U3 as b,U8 as je,U9 as Q,gn as Ze,Ua as ze,E9 as He,h1 as Ye,cV as qe,Ub as We,g8 as Je,go as Ke}from"./zeni-epic-state-Dmop9tB7.js";import{w as Qe,i as Xe,O as ea,o as aa,c as ta,f as na,u as sa,S as c,g as oa,e as ia,z as ra,d as da,n as ca,D as la,s as ua,q as ma,r as X,L as fa,F as ha,H as ba,p as S,l as ee,x as pa,P as ae,A as ga,C as Sa}from"./index-DheSTGi7.js";import{D as Ea}from"./mui-D4JyxRuO.js";import{u as ka}from"./InboxNotificationsProvider-zG7x1gLM.js";import{u as Ca}from"./useTaskManagerAccess-BOnqrzjJ.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]="5b9bcb15-0f42-4810-9571-50ca60f491d8",l._sentryDebugIdIdentifier="sentry-dbid-5b9bcb15-0f42-4810-9571-50ca60f491d8")}catch{}})();const Ta=Qe((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),E=ea(),n=Me(),B=Ue(),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]=m.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,x=F("/:tenantEmailDomain/reports")!==null,f=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:U}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,U),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),N=t((e=>Re(e))),{isFeatureEnabled:T}=d(c.isReferralFeatureEnabled),v=t((e=>Ve(e)));m.useEffect((()=>{C&&T&&!f&&v.fetchState==="Not-Started"&&r(Oe(!0))}),[C,T,v.fetchState,f]);const _=t((e=>e.tenantState)),me=t((e=>_.fetchState==="Completed"?Le(e):[])),g=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:fe}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),P=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Ee=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>b(e).totalUnreadCount)),Ce=t((e=>b(e).reducedFetchCountState)),R=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),V=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),O=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:L,isLoading:j,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Te}=ka();m.useEffect((()=>{const e=setTimeout((()=>Te?.()),0);return()=>clearTimeout(e)})),m.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]),m.useEffect((()=>{C&&k&&!f&&O.fetchState==="Not-Started"&&B.tenantId!=null&&r(je("task_manager","dashboard"))}),[C,k,f,O.fetchState,B.tenantId,r]),m.useEffect((()=>{f||I.fetchState!=="Not-Started"||r(Q({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[f,I.fetchState,r]),m.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(Q({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ce,count:ke},H=s!=null?ra.getSignedInUserTenant(s):null,Y=t((e=>H?.tenantId!=null?Ze(e,H.tenantId):void 0)),h=[];fe===!1&&h.push("accounts_payable_aging"),he===!1&&h.push("accounts_receivable_aging"),h.push("zeni_accounts_promo_card","treasury_promo_card"),T===!1&&h.push("rewards_card"),P===!1&&h.push("expense_automation_card");const q=t((e=>ze(e,h).fetchState)),W=t((e=>He(e).fetchState)),ye=A&&(q==="Completed"||q==="Error")||x&&(W==="Completed"||W==="Error")||!A&&!x?void 0:"disabled",we=m.useMemo((()=>Ye(o.userRole)),[o.userRole]),Ae=qe(we),ve=o?.rewardsLastViewedTime==null,_e=p?.userEmail!=null&&N.fetchState==="Completed"&&We(N.notificationSettings,p.userEmail,U,o,k),J=da(),Fe=J&&ca(a);return D.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:D.jsx(la,{signedInUser:p,currentTenantId:_.currentTenantId??"",tenants:_.fetchState==="Completed"?me:Y!=null?[Y]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Ee,isNotificationsTabVisible:_e,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:P,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:T,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:J,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=S(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=S(a.state?.pathnameStackToGoBack,a.pathname);n("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMenuChange:e=>{if(i(!1),s==null)return;if(e.type==="invoicing")return void n(`../${s}/invoicing/overview`,{state:{pathnameStackToGoBack:S(a.state?.pathnameStackToGoBack,a.pathname),referrer:"Sidebar"}});if(e.type==="ai_cfo"){if(ee.trackAICFOChatScreenStateChanged("viewed","left_menu",G??null,null),!oe)return void pa({location:a,navigate:n,mergeState:{referrer:"Sidebar"}});const y=S(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=S(a.state?.pathnameStackToGoBack,a.pathname),K=e.type,De=ae(K)&&K!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),De&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Be=ga(e.type);Sa(e.type)?(G!=null&&r(Ke()),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(fa.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{E.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Je({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),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)&&xe(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return D.jsx(Ta,{...l,...a})};export{Ba as M};
@@ -1 +1 @@
1
- import{j as e}from"./liveblocks-BF-IiX2V.js";import{h as r,l as n}from"./core-C1MQ75FC.js";import{an as i}from"./index-DMDsYekO.js";import"./mui-D4JyxRuO.js";import"./sentry-DQv7eTqs.js";import"./zeni-epic-state-Dmop9tB7.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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
+ import{j as e}from"./liveblocks-BF-IiX2V.js";import{h as r,l as n}from"./core-C1MQ75FC.js";import{an as i}from"./index-DheSTGi7.js";import"./mui-D4JyxRuO.js";import"./sentry-DQv7eTqs.js";import"./zeni-epic-state-Dmop9tB7.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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-BF-IiX2V.js";import ut from"./NotFoundScreen-znPj3CVA.js";import{a as k}from"./sentry-DQv7eTqs.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 O}from"./core-C1MQ75FC.js";import{cA as It,T$ as z,fF as H,h1 as Tt,U3 as b,a0Y as K,U9 as m,TZ as y,Ar as j,G6 as Ct,a0Z as At,TY as yt,Ub as Et,Aw as _t,a0_ as $,br as F,gh as x,AA as Q,a0$ as Nt,cM as wt,cF as Bt}from"./zeni-epic-state-Dmop9tB7.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-DMDsYekO.js";import"./mui-D4JyxRuO.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-BPjVLeQ1.js";import{u as Lt}from"./useTaskManagerAccess-CZ3Xfg1w.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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]="ca90de76-8d92-4392-9f60-c3b0e9b4a6d7",t._sentryDebugIdIdentifier="sentry-dbid-ca90de76-8d92-4392-9f60-c3b0e9b4a6d7")}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)}))})),Yt=St((function(t,l){const n=z(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=b(t),f=H(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(Q("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(K(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(Q("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)),qt=()=>{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=>z(e))),s=S((e=>H(e))),{useFeatureGate:d}=vt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Rt({isDataReady:!0});const X=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:Y,fetchMore:q,isFetchingMore:Z,hasFetchedAll:J}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(L!==c&&c!=null&&o(K(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&&Y===!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}:(Z||J===!0||q==null||q(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(y({totalCount:_.length,unreadCount:A.length},"comments")),o(At(ct))}}),[E,G,Z,C,J,Y,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(Yt,{tenantEmailDomain:n,loggedInUserRoleMap:X,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(O,{path:"/:selectedTab",element:N.jsx(qt,{})}),N.jsx(O,{path:"*",element:N.jsx(ut,{})})]})}export{me as default};
1
+ import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-BF-IiX2V.js";import ut from"./NotFoundScreen-ujna2tN5.js";import{a as k}from"./sentry-DQv7eTqs.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 O}from"./core-C1MQ75FC.js";import{cA as It,T$ as z,fF as H,h1 as Tt,U3 as b,a0Y as K,U9 as m,TZ as y,Ar as j,G6 as Ct,a0Z as At,TY as yt,Ub as Et,Aw as _t,a0_ as $,br as F,gh as x,AA as Q,a0$ as Nt,cM as wt,cF as Bt}from"./zeni-epic-state-Dmop9tB7.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-DheSTGi7.js";import"./mui-D4JyxRuO.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-DhY9V91R.js";import{u as Lt}from"./useTaskManagerAccess-BOnqrzjJ.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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]="ca90de76-8d92-4392-9f60-c3b0e9b4a6d7",t._sentryDebugIdIdentifier="sentry-dbid-ca90de76-8d92-4392-9f60-c3b0e9b4a6d7")}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)}))})),Yt=St((function(t,l){const n=z(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=b(t),f=H(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(Q("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(K(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(Q("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)),qt=()=>{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=>z(e))),s=S((e=>H(e))),{useFeatureGate:d}=vt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Rt({isDataReady:!0});const X=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:Y,fetchMore:q,isFetchingMore:Z,hasFetchedAll:J}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(L!==c&&c!=null&&o(K(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&&Y===!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}:(Z||J===!0||q==null||q(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(y({totalCount:_.length,unreadCount:A.length},"comments")),o(At(ct))}}),[E,G,Z,C,J,Y,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(Yt,{tenantEmailDomain:n,loggedInUserRoleMap:X,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(O,{path:"/:selectedTab",element:N.jsx(qt,{})}),N.jsx(O,{path:"*",element:N.jsx(ut,{})})]})}export{me as default};
@@ -1 +1 @@
1
- import{j as m}from"./liveblocks-BF-IiX2V.js";import{a as r}from"./sentry-DQv7eTqs.js";import{u as A,g as C,j as o,N as j}from"./core-C1MQ75FC.js";import{UC as D,fF as P,gm as x,UD as z,UE as M,UF as R,UG as F,pS as k,Th as L}from"./zeni-epic-state-Dmop9tB7.js";import{z as h,ai as I}from"./index-DMDsYekO.js";import"./mui-D4JyxRuO.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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]="3724efc3-4fda-4390-93e0-9ae4a539d6c6",n._sentryDebugIdIdentifier="sentry-dbid-3724efc3-4fda-4390-93e0-9ae4a539d6c6")}catch{}})();function ee(){const n=A(),a=C(),{params:t,error:i}=r.useMemo((()=>D(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(),f=o((e=>P(e))),l=o((e=>x(e))),d=o((e=>e.tenantState.fetchState)),y=o(z),S=o(M),c=o(R),[U,v]=r.useState(null),[E,b]=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((()=>{c!=null&&c!==""&&(window.location.href=c)}),[c]);const _=r.useMemo((()=>{if(f?.tenantId!=null)return f.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((T=>T.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[f?.tenantId,l]),u=U??_;return i!=null?m.jsx(I,{variant:"invalid_params",paramsError:i}):p?m.jsx(I,{variant:"signed_in",clientName:w,userEmail:s?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:u,onSelectTenant:v,approveError:E??S,isApproving:y==="In-Progress",showAllowButton:u!=null,onApprove:()=>{t!=null&&s!=null&&u!=null&&n(L(s.userId,s.zeniSessionId??void 0,u,t.clientId,t.redirectUri,t.codeChallenge,t.codeChallengeMethod,t.state,t.responseType))},onDeny:()=>{if(t!=null)try{const e=new URL(t.redirectUri);e.searchParams.set("error","access_denied"),e.searchParams.set("error_description","The user denied the request"),e.searchParams.set("state",t.state),window.location.href=e.toString()}catch{b("Unable to deny: redirect_uri is not a valid URL. Close this window or contact support.")}}}):m.jsx(j,{to:"/signin/auth",state:{origin:a.pathname+a.search},replace:!0})}export{ee as default};
1
+ import{j as m}from"./liveblocks-BF-IiX2V.js";import{a as r}from"./sentry-DQv7eTqs.js";import{u as A,g as C,j as o,N as j}from"./core-C1MQ75FC.js";import{UC as D,fF as P,gm as x,UD as z,UE as M,UF as R,UG as F,pS as k,Th as L}from"./zeni-epic-state-Dmop9tB7.js";import{z as h,ai as I}from"./index-DheSTGi7.js";import"./mui-D4JyxRuO.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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]="3724efc3-4fda-4390-93e0-9ae4a539d6c6",n._sentryDebugIdIdentifier="sentry-dbid-3724efc3-4fda-4390-93e0-9ae4a539d6c6")}catch{}})();function ee(){const n=A(),a=C(),{params:t,error:i}=r.useMemo((()=>D(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(),f=o((e=>P(e))),l=o((e=>x(e))),d=o((e=>e.tenantState.fetchState)),y=o(z),S=o(M),c=o(R),[U,v]=r.useState(null),[E,b]=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((()=>{c!=null&&c!==""&&(window.location.href=c)}),[c]);const _=r.useMemo((()=>{if(f?.tenantId!=null)return f.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((T=>T.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[f?.tenantId,l]),u=U??_;return i!=null?m.jsx(I,{variant:"invalid_params",paramsError:i}):p?m.jsx(I,{variant:"signed_in",clientName:w,userEmail:s?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:u,onSelectTenant:v,approveError:E??S,isApproving:y==="In-Progress",showAllowButton:u!=null,onApprove:()=>{t!=null&&s!=null&&u!=null&&n(L(s.userId,s.zeniSessionId??void 0,u,t.clientId,t.redirectUri,t.codeChallenge,t.codeChallengeMethod,t.state,t.responseType))},onDeny:()=>{if(t!=null)try{const e=new URL(t.redirectUri);e.searchParams.set("error","access_denied"),e.searchParams.set("error_description","The user denied the request"),e.searchParams.set("state",t.state),window.location.href=e.toString()}catch{b("Unable to deny: redirect_uri is not a valid URL. Close this window or contact support.")}}}):m.jsx(j,{to:"/signin/auth",state:{origin:a.pathname+a.search},replace:!0})}export{ee as default};
@@ -1 +1 @@
1
- import{j as n}from"./liveblocks-BF-IiX2V.js";import{h as Z,u as H,g as J,i as K,j as d,l as X,n as ee,o as C}from"./core-C1MQ75FC.js";import{fF as w,Ac as O,v5 as ae,Vu as M,v0 as T,bq as te,b$ as se,v1 as oe,Vv as re,Vc as S,ei as ne,D_ as ce,Vw as ie,Em as le,d_ as de,dZ as me}from"./zeni-epic-state-Dmop9tB7.js";import{aj as fe,z as pe,ar as ue,at as he,Q as Fe,o as _,S as V,a9 as ge,l as B,aE as be,p as Ie}from"./index-DMDsYekO.js";import"./mui-D4JyxRuO.js";import Ce from"./NotFoundScreen-znPj3CVA.js";import{F as Se}from"./FeaturePreviewScreen-C-uktVbl.js";import{a as F}from"./sentry-DQv7eTqs.js";import{u as Te}from"./useAskAiCfoHostNavButtonProps-BPjVLeQ1.js";import{u as ye}from"./useInitialThreadRequest-B7Oi83EI.js";import{t as Ae}from"./routePaths-DtiHE0tS.js";import{M as De}from"./MobileAppDrawer-nX8kGgUI.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.js";import"./InboxNotificationsProvider-zG7x1gLM.js";import"./useTaskManagerAccess-CZ3Xfg1w.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]="cca3b659-e035-4cc7-932a-c7d9520f5e66",s._sentryDebugIdIdentifier="sentry-dbid-cca3b659-e035-4cc7-932a-c7d9520f5e66")}catch{}})();const y=(s,e,a,o)=>{if(s!=e){const r=o??"";s!=null&&s.length>0?a(`../${e}${r}`,{replace:!0}):a(`${e}${r}`,{replace:!0})}},xe=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(T(a)),y(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 U(){const s=fe(),e=Z(),a=H(),o=J(),{forecastId:r,tenantEmailDomain:c}=K(),[p,u]=F.useState(!1),[m,A]=F.useState(!1),g=pe.getSignedInUser(),D=d((t=>w(t))),N=D.company?.companyInfo.firstMonthOfFY??1,i=d((t=>O(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),x=d((t=>t.profitAndLossState)),E=d((t=>t.reportUIOptionsState.selectedForecast)),j=t=>x.pandLByForecastID[t]!=null&&oe(t,x).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:b}=ue();he({isDataReady:l});const{isAiCfoAccessEnabled:$,onAskAiCfoClick:q}=Te({mobileExploreReferrer:"Forecast"});F.useEffect((()=>{if(!p&&b)u(!0),l||a(ae());else if(l&&!m){A(!0);const t=((f,R,v)=>R!=null?f.forecasts.findIndex((I=>I.id===R)):v!=null?f.forecasts.findIndex((I=>I.id===v)):f.forecasts.length>0?0:-1)(i,r,E?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=E?.index?(a(M(i.forecasts[t].id,t)),y(r,i.forecasts[t].id,e,o.search)):r==null&&t!==-1&&y(void 0,i.forecasts[t].id,e,o.search),t!==-1&&!j(i.forecasts[t].id)&&b&&a(T(i.forecasts[t].id))}}),[p,u,a,l,i,m,A,O,T,b]);const k=Fe(),G=k?.loggedInUserRole!=null&&te(k.loggedInUserRole),{useFeatureGate:W}=_(),{isFeatureEnabled:L}=W(V.isReportsCommentingEnabled),Y=ye(L?D?.companyId:void 0,{clearParams:l&&m}),[z,Q]=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=>{Q(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(ge,{analytics:B,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(De,{isAppContentDrawerOpen:z,handleDrawerToggle:P}),n.jsx(xe,{firstMonthOfFY:N,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:j,meetingUrl:se(h.toString()),hasTransactionAccess:G,isAiCfoAccessEnabled:$,onAskAiCfoClick:q,isReportsCommentingEnabled:L,initialOpenThreadRequest:Y,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(U,{})}),n.jsx(C,{path:"/:forecastId",element:n.jsx(U,{})}),n.jsx(C,{path:"/:forecastId/*",element:n.jsx(Ce,{})})]})}export{He as default};
1
+ import{j as n}from"./liveblocks-BF-IiX2V.js";import{h as Z,u as H,g as J,i as K,j as d,l as X,n as ee,o as C}from"./core-C1MQ75FC.js";import{fF as w,Ac as O,v5 as ae,Vu as M,v0 as T,bq as te,b$ as se,v1 as oe,Vv as re,Vc as S,ei as ne,D_ as ce,Vw as ie,Em as le,d_ as de,dZ as me}from"./zeni-epic-state-Dmop9tB7.js";import{aj as fe,z as pe,ar as ue,at as he,Q as Fe,o as _,S as V,a9 as ge,l as B,aE as be,p as Ie}from"./index-DheSTGi7.js";import"./mui-D4JyxRuO.js";import Ce from"./NotFoundScreen-ujna2tN5.js";import{F as Se}from"./FeaturePreviewScreen-B1Ivzvw1.js";import{a as F}from"./sentry-DQv7eTqs.js";import{u as Te}from"./useAskAiCfoHostNavButtonProps-DhY9V91R.js";import{u as ye}from"./useInitialThreadRequest-Fj77Qh1B.js";import{t as Ae}from"./routePaths-DrHt4RCx.js";import{M as De}from"./MobileAppDrawer-CdDtqWOO.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.js";import"./InboxNotificationsProvider-zG7x1gLM.js";import"./useTaskManagerAccess-BOnqrzjJ.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]="cca3b659-e035-4cc7-932a-c7d9520f5e66",s._sentryDebugIdIdentifier="sentry-dbid-cca3b659-e035-4cc7-932a-c7d9520f5e66")}catch{}})();const y=(s,e,a,o)=>{if(s!=e){const r=o??"";s!=null&&s.length>0?a(`../${e}${r}`,{replace:!0}):a(`${e}${r}`,{replace:!0})}},xe=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(T(a)),y(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 U(){const s=fe(),e=Z(),a=H(),o=J(),{forecastId:r,tenantEmailDomain:c}=K(),[p,u]=F.useState(!1),[m,A]=F.useState(!1),g=pe.getSignedInUser(),D=d((t=>w(t))),N=D.company?.companyInfo.firstMonthOfFY??1,i=d((t=>O(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),x=d((t=>t.profitAndLossState)),E=d((t=>t.reportUIOptionsState.selectedForecast)),j=t=>x.pandLByForecastID[t]!=null&&oe(t,x).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:b}=ue();he({isDataReady:l});const{isAiCfoAccessEnabled:$,onAskAiCfoClick:q}=Te({mobileExploreReferrer:"Forecast"});F.useEffect((()=>{if(!p&&b)u(!0),l||a(ae());else if(l&&!m){A(!0);const t=((f,R,v)=>R!=null?f.forecasts.findIndex((I=>I.id===R)):v!=null?f.forecasts.findIndex((I=>I.id===v)):f.forecasts.length>0?0:-1)(i,r,E?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=E?.index?(a(M(i.forecasts[t].id,t)),y(r,i.forecasts[t].id,e,o.search)):r==null&&t!==-1&&y(void 0,i.forecasts[t].id,e,o.search),t!==-1&&!j(i.forecasts[t].id)&&b&&a(T(i.forecasts[t].id))}}),[p,u,a,l,i,m,A,O,T,b]);const k=Fe(),G=k?.loggedInUserRole!=null&&te(k.loggedInUserRole),{useFeatureGate:W}=_(),{isFeatureEnabled:L}=W(V.isReportsCommentingEnabled),Y=ye(L?D?.companyId:void 0,{clearParams:l&&m}),[z,Q]=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=>{Q(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(ge,{analytics:B,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(De,{isAppContentDrawerOpen:z,handleDrawerToggle:P}),n.jsx(xe,{firstMonthOfFY:N,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:j,meetingUrl:se(h.toString()),hasTransactionAccess:G,isAiCfoAccessEnabled:$,onAskAiCfoClick:q,isReportsCommentingEnabled:L,initialOpenThreadRequest:Y,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(U,{})}),n.jsx(C,{path:"/:forecastId",element:n.jsx(U,{})}),n.jsx(C,{path:"/:forecastId/*",element:n.jsx(Ce,{})})]})}export{He as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-BF-IiX2V.js";import{a as p}from"./sentry-DQv7eTqs.js";import{I as d,J as r,aa as m,ae as f,af as h}from"./index-DMDsYekO.js";import"./mui-D4JyxRuO.js";import{i as y}from"./core-C1MQ75FC.js";import"./zeni-epic-state-Dmop9tB7.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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]="66bdd2db-a060-4670-9d3a-ab2391de9900",e._sentryDebugIdIdentifier="sentry-dbid-66bdd2db-a060-4670-9d3a-ab2391de9900")}catch{}})();const g=d("div")`
1
+ import{j as a}from"./liveblocks-BF-IiX2V.js";import{a as p}from"./sentry-DQv7eTqs.js";import{I as d,J as r,aa as m,ae as f,af as h}from"./index-DheSTGi7.js";import"./mui-D4JyxRuO.js";import{i as y}from"./core-C1MQ75FC.js";import"./zeni-epic-state-Dmop9tB7.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.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]="66bdd2db-a060-4670-9d3a-ab2391de9900",e._sentryDebugIdIdentifier="sentry-dbid-66bdd2db-a060-4670-9d3a-ab2391de9900")}catch{}})();const g=d("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-BF-IiX2V.js";import{Vq as re,fF as Y,l$ as G,d_ as J,dZ as le,Sh as N,UP as de,CX as Ee,Vr as Q,CM as je,D5 as Le,C$ as ce,CQ as pe,D3 as Te,D0 as ve,Vs as ue,sq as Ve,g6 as Ae,gD as Fe,Vt as _,CU as me,CT as ge,D8 as Re,c8 as Oe}from"./zeni-epic-state-Dmop9tB7.js";import{a2 as fe,o as X,S as H,z as K,g as Ce,M as he,ag as ye,aA as be,aB as Ze,ac as Se,J as R,ah as De,G as M,aC as Ue,ar as Be,at as $e,a9 as ze,l as we,V as _e,p as He,aD as Ge,Q as Ke}from"./index-DMDsYekO.js";import{D as xe,n as W,S as Ie}from"./mui-D4JyxRuO.js";import ae from"./NotFoundScreen-znPj3CVA.js";import{a as d}from"./sentry-DQv7eTqs.js";import{u as ee,i as Me,j as g,h as We,g as qe,l as Qe,n as se,o as z}from"./core-C1MQ75FC.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-BPjVLeQ1.js";import{M as Je}from"./MobileAppDrawer-nX8kGgUI.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.js";import"./InboxNotificationsProvider-zG7x1gLM.js";import"./useTaskManagerAccess-CZ3Xfg1w.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]="8f2c9163-416f-4043-8edf-e58d5e5f7e5d",e._sentryDebugIdIdentifier="sentry-dbid-8f2c9163-416f-4043-8edf-e58d5e5f7e5d")}catch{}})();const Ne={overlayWidth:new Se(100,100,48)},te=M.getLocalizedStrings().peoplePage.invitePage,ne=M.getLocalizedStrings().common,Xe=({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}=Me(),r=g((l=>re(l))),p=g((l=>Y(l))),P=g((l=>G(l))),{useFeatureGate:x}=X(),{isFeatureEnabled:I}=x(H.isDebitCardFeatureEnabled),E=J(I,p),T=le(p),v=N(p),U=de(p),B=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,w=!E&&P&&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(H.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:v,isAccountingClassesEnabled:P,isReimbursementDisabled:B===!1,isZeniAccountsDisabled:u===!1,isChargeCardDisabled:y,isTreasuryDisabled:F===!1,isLiteRoleDisabled:U===!1,isBankingOnlyTenant:E,isCardsOnlyTenant:T,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(v))},onCloseClick:V,isLoading:w||r.person==null},o={onOkClick:()=>{S(!1),h()},onCancelClick:()=>{S(!1)}};return d.useEffect((()=>{w===!1&&D!=null&&m(Ee(D))}),[w,D]),d.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&h()}),[r.updatePersonState.fetchState]),a.jsx(xe,{anchor:"right",open:i,PaperProps:{style:{width:Ne.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(Pe,{children:te.discardDescription}),primaryButtonText:ne.yes,secondaryButtonText:ne.no,action:o,isEditPopup:!0}):null,a.jsx(Ze,{...s})]})})},ea=W(Ie)`
1
+ import{j as a}from"./liveblocks-BF-IiX2V.js";import{Vq as re,fF as Y,l$ as G,d_ as J,dZ as le,Sh as N,UP as de,CX as Ee,Vr as Q,CM as je,D5 as Le,C$ as ce,CQ as pe,D3 as Te,D0 as ve,Vs as ue,sq as Ve,g6 as Ae,gD as Fe,Vt as _,CU as me,CT as ge,D8 as Re,c8 as Oe}from"./zeni-epic-state-Dmop9tB7.js";import{a2 as fe,o as X,S as H,z as K,g as Ce,M as he,ag as ye,aA as be,aB as Ze,ac as Se,J as R,ah as De,G as M,aC as Ue,ar as Be,at as $e,a9 as ze,l as we,V as _e,p as He,aD as Ge,Q as Ke}from"./index-DheSTGi7.js";import{D as xe,n as W,S as Ie}from"./mui-D4JyxRuO.js";import ae from"./NotFoundScreen-ujna2tN5.js";import{a as d}from"./sentry-DQv7eTqs.js";import{u as ee,i as Me,j as g,h as We,g as qe,l as Qe,n as se,o as z}from"./core-C1MQ75FC.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-DhY9V91R.js";import{M as Je}from"./MobileAppDrawer-CdDtqWOO.js";import"./recharts-BEOxWuh3.js";import"./analytics-Ckbn2qr2.js";import"./plaid-CD2DDkpy.js";import"./dnd-64pfrglk.js";import"./stripe-cKAAJElX.js";import"./lottie-CWNAcXJv.js";import"./lexical-TkcJlpM_.js";import"./pdf-Cj_veg-U.js";import"./utils-G6VVxCSd.js";import"./InboxNotificationsProvider-zG7x1gLM.js";import"./useTaskManagerAccess-BOnqrzjJ.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]="8f2c9163-416f-4043-8edf-e58d5e5f7e5d",e._sentryDebugIdIdentifier="sentry-dbid-8f2c9163-416f-4043-8edf-e58d5e5f7e5d")}catch{}})();const Ne={overlayWidth:new Se(100,100,48)},te=M.getLocalizedStrings().peoplePage.invitePage,ne=M.getLocalizedStrings().common,Xe=({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}=Me(),r=g((l=>re(l))),p=g((l=>Y(l))),P=g((l=>G(l))),{useFeatureGate:x}=X(),{isFeatureEnabled:I}=x(H.isDebitCardFeatureEnabled),E=J(I,p),T=le(p),v=N(p),U=de(p),B=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,w=!E&&P&&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(H.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:v,isAccountingClassesEnabled:P,isReimbursementDisabled:B===!1,isZeniAccountsDisabled:u===!1,isChargeCardDisabled:y,isTreasuryDisabled:F===!1,isLiteRoleDisabled:U===!1,isBankingOnlyTenant:E,isCardsOnlyTenant:T,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(v))},onCloseClick:V,isLoading:w||r.person==null},o={onOkClick:()=>{S(!1),h()},onCancelClick:()=>{S(!1)}};return d.useEffect((()=>{w===!1&&D!=null&&m(Ee(D))}),[w,D]),d.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&h()}),[r.updatePersonState.fetchState]),a.jsx(xe,{anchor:"right",open:i,PaperProps:{style:{width:Ne.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(Pe,{children:te.discardDescription}),primaryButtonText:ne.yes,secondaryButtonText:ne.no,action:o,isEditPopup:!0}):null,a.jsx(Ze,{...s})]})})},ea=W(Ie)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;