@zeniai/web-app-ui 5.4.4-dev → 5.4.5-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AccountMappingScreen-C0sMMini.js → AccountMappingScreen-DgVzljDc.js} +1 -1
- package/dist/assets/{ActualMatchingMatchDetailScreen-BfKQWQ-e.js → ActualMatchingMatchDetailScreen-_5MEPuqh.js} +1 -1
- package/dist/assets/AddressRoutes-D4kr05si.js +1 -0
- package/dist/assets/{AddressScreen-VWWvSvnK.js → AddressScreen-D8ZFS5c0.js} +1 -1
- package/dist/assets/{AiCfoScreen-BamobQFS.js → AiCfoScreen-CzSEfznp.js} +1 -1
- package/dist/assets/{AppDrawer-B3isfNtc.js → AppDrawer-C0iSZDhf.js} +1 -1
- package/dist/assets/{BillPayApprovalRoutes-DML5uyv7.js → BillPayApprovalRoutes-BrI6P4-A.js} +1 -1
- package/dist/assets/{BillPayRoutes-Dz3J41fh.js → BillPayRoutes-VVOzQb6d.js} +1 -1
- package/dist/assets/{BusinessVerificationPageScreen-CUyBqVMc.js → BusinessVerificationPageScreen-B5zW-1OI.js} +1 -1
- package/dist/assets/{CardsAiCfoScreen-3kYy1cSH.js → CardsAiCfoScreen-COAk2SXT.js} +1 -1
- package/dist/assets/{ChargeCardRoutes-Ce-nS1EB.js → ChargeCardRoutes-Qh1BAbU5.js} +1 -1
- package/dist/assets/{CompanyPassportScreen-C5Y2nsJz.js → CompanyPassportScreen-CPi-skMc.js} +1 -1
- package/dist/assets/{ConnectionAuthScreen-BWpiejbj.js → ConnectionAuthScreen-1lF2u2mO.js} +1 -1
- package/dist/assets/CustomerOnboardingAuthScreen-CfeNT1gf.js +1 -0
- package/dist/assets/{CustomerOnboardingRoutes-2FkvuUlZ.js → CustomerOnboardingRoutes-DxCjOIdb.js} +1 -1
- package/dist/assets/{DashboardRoutes-MBJ2Rwn4.js → DashboardRoutes-D9dE1l9y.js} +1 -1
- package/dist/assets/{DefaultTenantHome-Ckt1T4NG.js → DefaultTenantHome-C5tEozmd.js} +1 -1
- package/dist/assets/{DomesticWireDetailScreen-hTt1-04T.js → DomesticWireDetailScreen-BGxh9kEX.js} +1 -1
- package/dist/assets/{DrawerScreen-CqE9SdRB.js → DrawerScreen-ShiARaEV.js} +1 -1
- package/dist/assets/{EntityDetailRoutes-BefrbPGo.js → EntityDetailRoutes-Bscpdn_Y.js} +1 -1
- package/dist/assets/{ExpenseAutomationRoutes-BpwrasRp.js → ExpenseAutomationRoutes-DPnqaue1.js} +1 -1
- package/dist/assets/{FeaturePreviewScreen-Co6qUDUn.js → FeaturePreviewScreen-Ctjpdyze.js} +1 -1
- package/dist/assets/{HubSpotOAuthCallbackScreen-BX8B9Pey.js → HubSpotOAuthCallbackScreen-CzHy-IWj.js} +1 -1
- package/dist/assets/{InboxNotificationsProvider-DK30Cxb5.js → InboxNotificationsProvider-NVGRbeaR.js} +1 -1
- package/dist/assets/{InvoicingRoutes-wjH_4S5b.js → InvoicingRoutes-Cv-Ei3vB.js} +1 -1
- package/dist/assets/{MagicLinkRoutes-BGZtjWHW.js → MagicLinkRoutes-C1MXI8KG.js} +1 -1
- package/dist/assets/{MagicLinkSignInScreen-Cs9gnZ1G.js → MagicLinkSignInScreen-mk3nG4eV.js} +1 -1
- package/dist/assets/{MobileAppDrawer-DdKhHPz6.js → MobileAppDrawer-B2nfLEqA.js} +1 -1
- package/dist/assets/NotFoundScreen-C75AzqPX.js +1 -0
- package/dist/assets/{NotificationRoutes-BJrlVoAS.js → NotificationRoutes-Ch-hXfgR.js} +1 -1
- package/dist/assets/{OAuthConsentScreen-NQWhKp0n.js → OAuthConsentScreen-Pl6BuRRz.js} +1 -1
- package/dist/assets/{PandLWithForecastRoutes-BHXDuog4.js → PandLWithForecastRoutes-DZOk2Qlj.js} +1 -1
- package/dist/assets/{PaymentLinkScreen-DiMYCNqK.js → PaymentLinkScreen-rksYmkZI.js} +1 -1
- package/dist/assets/{PeopleRoutes-CQNqQ1me.js → PeopleRoutes-DHxlyYnb.js} +1 -1
- package/dist/assets/{PerformanceRoutes-DOHSTCGW.js → PerformanceRoutes-DkrYXjpO.js} +1 -1
- package/dist/assets/{Preview-CkpRPhZT.js → Preview-DPHyWgeF.js} +1 -1
- package/dist/assets/{QBOConnectionScreen-awYitbDx.js → QBOConnectionScreen-ZmZgKCHJ.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRoutes-hM97Cpf-.js → ReimbursementApprovalRoutes-BtLwC5vW.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRuleDetailScreen-CkqblogQ.js → ReimbursementApprovalRuleDetailScreen-DcmwfEys.js} +1 -1
- package/dist/assets/{ReimbursementRoutes-8kNGLexU.js → ReimbursementRoutes-UkIsGL1r.js} +1 -1
- package/dist/assets/{ReportsRoutes-BlAnes6-.js → ReportsRoutes-CU9WQQpS.js} +1 -1
- package/dist/assets/{RewardsRoutes-CyQwdmPN.js → RewardsRoutes-BX_YNtbv.js} +1 -1
- package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-BzaDyP8o.js → ScheduleDetailsPrepaidExpensesScreen-Drx9l8ju.js} +1 -1
- package/dist/assets/{ScreenRoutes-B2IjeoFT.js → ScreenRoutes-BRC0VWLy.js} +2 -2
- package/dist/assets/{SettingsRoutes-C-qOYbgc.js → SettingsRoutes-CwvDUTEI.js} +1 -1
- package/dist/assets/{SetupPagesScreen-BRXuNvft.js → SetupPagesScreen-C1rz4uPo.js} +1 -1
- package/dist/assets/{SignInScreen-BHelb_vc.js → SignInScreen-D6up85E6.js} +1 -1
- package/dist/assets/{SignOutScreen-1qrT9Vlz.js → SignOutScreen-BRyD_h9W.js} +1 -1
- package/dist/assets/{TaskListScreen-xVsQI_eD.js → TaskListScreen-BFk5J8_J.js} +1 -1
- package/dist/assets/{TaskRoutes-Dp3N4y8R.js → TaskRoutes-cYV1K1Do.js} +1 -1
- package/dist/assets/{TransactionDetailRoutes-D7CnkfZ-.js → TransactionDetailRoutes-D2aDGo40.js} +1 -1
- package/dist/assets/{TransactionDetailScreen-C5LaW58p.js → TransactionDetailScreen-Doi5ALkW.js} +1 -1
- package/dist/assets/{TransactionListRoutes-DstR_S7R.js → TransactionListRoutes-D2f7LizJ.js} +1 -1
- package/dist/assets/{TreasuryRoutes-B_pMyVCn.js → TreasuryRoutes-BvsOAhXf.js} +1 -1
- package/dist/assets/{VendorsRoutes-BBAxMr84.js → VendorsRoutes-Dwwqnsa9.js} +1 -1
- package/dist/assets/{WiseConfirmationScreen-G9VKtOTo.js → WiseConfirmationScreen-C83xa1zE.js} +1 -1
- package/dist/assets/{ZeniAccountRoutes-Dz075FIl.js → ZeniAccountRoutes-C5ew3jhQ.js} +1 -1
- package/dist/assets/{ZeniAccountStatementScreen-DnyNKaBX.js → ZeniAccountStatementScreen-1UWKM9sd.js} +1 -1
- package/dist/assets/{accountMappingHelper-Cer8E1sV.js → accountMappingHelper-ChJRZDFu.js} +1 -1
- package/dist/assets/{analytics-CLGfyryt.js → analytics-BkXKjaSH.js} +1 -1
- package/dist/assets/{analyticsHelper-Czoo9Dek.js → analyticsHelper-D5oPBeHb.js} +1 -1
- package/dist/assets/{core-DK2mlr3J.js → core-DKqX1MvM.js} +1 -1
- package/dist/assets/{decodeURIComponentSafe-BKcGsnNf.js → decodeURIComponentSafe-BrmecbO9.js} +1 -1
- package/dist/assets/{dnd-DmMNaNZl.js → dnd-CTBYmQk9.js} +1 -1
- package/dist/assets/{empty-DOVgNO3g.js → empty-Dvx7pCoK.js} +1 -1
- package/dist/assets/{empty-sfAxWxLt.js → empty-HYxrV6m3.js} +1 -1
- package/dist/assets/{emptyVideoElement-DTYtNwkj.js → emptyVideoElement-BLv8qGNQ.js} +1 -1
- package/dist/assets/{epic-y78AsHxX.js → epic-CYCKkTDw.js} +1 -1
- package/dist/assets/{expenseAutomationHelper-Zkyue3Dd.js → expenseAutomationHelper-CYxvY8UV.js} +1 -1
- package/dist/assets/{getLocaleForTenant-D5HAIAMI.js → getLocaleForTenant-DXE0mqRD.js} +1 -1
- package/dist/assets/{index-Dsu8OkDH.js → index-B-oBJcTm.js} +1 -1
- package/dist/assets/{index-BtWyAIYh.js → index-BQ7-b1up.js} +1 -1
- package/dist/assets/{index-CCZBKhvn.js → index-C2FcaV_5.js} +1 -1
- package/dist/assets/{index-BhJVst5Q.js → index-CU2m3m-_.js} +2 -2
- package/dist/assets/{index-BZ4Qj2TG.js → index-DD4RgEdp.js} +1 -1
- package/dist/assets/{index-C9USztB0.js → index-DFpeEF9q.js} +1 -1
- package/dist/assets/{index-kVHvLKqq.js → index-Dgy1xiQh.js} +1 -1
- package/dist/assets/{index-gWeKimie.js → index-VO1FF9fC.js} +2275 -2275
- package/dist/assets/{lexical-D8I0sdIn.js → lexical-BBNKXOAq.js} +1 -1
- package/dist/assets/{liveblocks-B-cSKONY.js → liveblocks-CzEOPLmF.js} +1 -1
- package/dist/assets/{lottie-BeDznxFN.js → lottie-ByL7llpj.js} +1 -1
- package/dist/assets/{mui-BJpEKNBi.js → mui-Bhz49yKC.js} +1 -1
- package/dist/assets/{pathToGoBack-D7_vOHuo.js → pathToGoBack-Dd8RCHkO.js} +1 -1
- package/dist/assets/{pdf-BhuhJSrH.js → pdf-DKcIxepG.js} +3 -3
- package/dist/assets/{pdf-lib-BqU855ht.js → pdf-lib-IgS2Okos.js} +1 -1
- package/dist/assets/{plaid-DunXUDAB.js → plaid-Bs1vGF7f.js} +1 -1
- package/dist/assets/{pusher-BnWPIhw-.js → pusher-DMVxRFTg.js} +1 -1
- package/dist/assets/{react-Qn7QPAQq.js → react-CveMndCS.js} +1 -1
- package/dist/assets/{react-CBzJjLru.js → react-D30b6JcR.js} +1 -1
- package/dist/assets/{react-BGClwsYW.js → react-DAOsmcom.js} +1 -1
- package/dist/assets/{react-CBF8F-ZT.js → react-DGyxzQca.js} +1 -1
- package/dist/assets/{react-zHX8D5UO.js → react-DMQagPRx.js} +1 -1
- package/dist/assets/{react-Bae77ap2.js → react-YOdQ427t.js} +1 -1
- package/dist/assets/{recharts-Be6UzieB.js → recharts-zD9lBvAv.js} +1 -1
- package/dist/assets/{reportTimeframe-BrIqDmjp.js → reportTimeframe-BNlFMmzn.js} +1 -1
- package/dist/assets/{routePaths-DgH42pPu.js → routePaths-BDzQ5Jh8.js} +1 -1
- package/dist/assets/{sentry-CBW8f2n5.js → sentry-9QW1WlhM.js} +1 -1
- package/dist/assets/{stripSplatSuffix-BsiGB3YN.js → stripSplatSuffix-D8V3Vwti.js} +1 -1
- package/dist/assets/{url-D7y7ILZi.js → url-BS9T78Nm.js} +1 -1
- package/dist/assets/{url-r_uX_Du7.js → url-CKXRQoNl.js} +1 -1
- package/dist/assets/{useActualMatchingMatchDetail-CIhcpdac.js → useActualMatchingMatchDetail-BU-35ZAo.js} +1 -1
- package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-CuzjEAdK.js → useAiCfoDashboardSuggestedQuestionsChips-CQBObrzE.js} +1 -1
- package/dist/assets/{useAskAiCfoHostNavButtonProps-DFSreI-K.js → useAskAiCfoHostNavButtonProps-CKCM0miP.js} +1 -1
- package/dist/assets/{useChargeCardPusherEvents-BVk2uSYN.js → useChargeCardPusherEvents-BRSqCi1d.js} +1 -1
- package/dist/assets/{useDeviceId-obcLL4xN.js → useDeviceId-DnWM1QX-.js} +1 -1
- package/dist/assets/{useEmailConnectResultRefresh-CEI-SlUJ.js → useEmailConnectResultRefresh-CRbPRPlZ.js} +1 -1
- package/dist/assets/{useEnsureVendorListLoaded-BNcE3E-O.js → useEnsureVendorListLoaded-CXNIYmTm.js} +1 -1
- package/dist/assets/{useInitialThreadRequest-DMCoEJNN.js → useInitialThreadRequest-BfeP-cDj.js} +1 -1
- package/dist/assets/{useTaskManagerAccess-w-zZOzku.js → useTaskManagerAccess-CZsCSMny.js} +1 -1
- package/dist/assets/{useTaskManagerPusherEvents-B4FiXQud.js → useTaskManagerPusherEvents-BFozChkZ.js} +1 -1
- package/dist/assets/{utils-3QzZ60R1.js → utils-Ciaf9ZZY.js} +1 -1
- package/dist/assets/{withTransactionSidePanel-BlvW61M9.js → withTransactionSidePanel-B_1Xn5r_.js} +1 -1
- package/dist/assets/{zeni-epic-state-B2izbHLH.js → zeni-epic-state-4S4FDL12.js} +3 -3
- package/dist/index.html +1 -1
- package/package.json +4 -4
- package/dist/assets/AddressRoutes-DYo3I9gy.js +0 -1
- package/dist/assets/CustomerOnboardingAuthScreen-BUex-BSl.js +0 -1
- package/dist/assets/NotFoundScreen-B-BYYP4T.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{j as c}from"./liveblocks-B-cSKONY.js";import{a as r}from"./sentry-CBW8f2n5.js";import{u as L,h as $,i as _,j as E,t as oe,l as O,s as z,g as ae,N as H,n as ge,o as x}from"./core-DK2mlr3J.js";import{a6 as st,k as g,ao as F,R as l,cd as rt,ce as dt,cf as lt,cg as ut,ch as gt,ci as mt,cj as vt,ck as pt,cl as ft,cm as St,cn as It,co as ht,p as ce,cp as Ct,cq as kt,z as te,ac as pe,cr as Et,cs as yt,ct as bt,cu as xt,cv as At,cw as Dt,cx as jt,cy as Lt,cz as $t,cA as Pt,V as wt,ag as pn,cB as _t,cC as Rt,cD as Ft,cE as Tt,cF as Ot,cG as Mt,cH as Nt,cI as Ut,cJ as Bt,cK as Vt,cL as Ht,t as en,j as Ue,cM as qt,cN as Qt,cO as zt,cP as Kt,cQ as Gt,cR as Wt,cS as Yt,bt as Jt}from"./index-gWeKimie.js";import"./mui-BJpEKNBi.js";import{A as X}from"./AddressScreen-VWWvSvnK.js";import M from"./NotFoundScreen-B-BYYP4T.js";import{_G as Xt,_H as Zt,vw as nn,v as ei,_I as Z,w7 as fe,_J as Be,_K as W,wK as Pe,wR as ni,dY as fn,wV as Sn,_L as Ve,wO as ti,yu as tn,w6 as on,_M as In,_N as Y,x4 as we,x8 as ii,_O as oi,xi as ai,_P as hn,xb as Cn,z2 as ci,_Q as he,_R as an,_S as kn,w2 as si,_T as ri,vW as di,_U as li,yH as ui,_V as En,yQ as be,_W as gi,yN as mi,_X as He,gk as qe,_Y as le,_Z as ue,xq as vi,wc as cn,wh as yn,wf as pi,w9 as fi,xj as Si,wj as Ii,xs as hi,c$ as bn,__ as _e,xB as xn,xz as Q,xx as G,xw as Ci,_$ as Se,yX as xe,$0 as ki,w4 as An,$1 as Qe,fI as Ce,ws as Re,wp as Fe,wC as Dn,wB as ze,wm as Ei,wv as jn,wE as me,Wk as Ln,w8 as Ke,wz as yi,wA as bi,wy as xi,$2 as Ai,x9 as Di,x5 as $n,$3 as Pn,vN as Ae,$4 as ji,vG as Li,$5 as $i,z1 as Pi,z6 as K,z0 as wi,y8 as ke,$6 as _i,$7 as wn,zf as De,$8 as Ri,zc as Fi,$9 as _n,yb as Ti,yc as q,yf as Oi,$a as Rn,yp as je,$b as Mi,xr as Fn,UR as Tn,$c as Ni,yz as Ui,$d as On,$e as sn,$f as Bi,$g as Vi,A2 as Hi,$h as qi,$i as Mn,zm as Nn,$j as Un,A0 as Le,$k as Qi,zZ as zi,$l as Ki,$m as Gi,$n as Wi,$o as Yi,$p as Ji,$q as rn,$r as Xi,ei as Zi,A6 as eo,$s as Ge,xL as no,xG as to,d1 as Te,$t as ee,xP as Bn,xX as Vn,$u as We,xQ as ie,y0 as io,y3 as Hn,$v as oo,$w as Oe,x$ as ao,$x as qn,zR as $e,zM as co,$y as so,zr as ro,$z as lo,zS as uo,zW as go,$A as Ye,wM as Qn,zD as mo,wN as vo,$B as po,$C as zn,ca as fo,mw as So,mx as Io,$D as dn,wL as ne,go as ho,mD as Co,zJ as Kn,Ai as ko,zG as Gn,v2 as Eo,uS as yo,hW as bo,Vi as ln,Vj as xo,GK as Wn,Af as Ao,hO as Do,Ac as jo,$E as Lo,$F as $o,Ao as Po,An as wo,$G as _o,$H as Yn,Al as Ro,$I as Fo,$J as To,yD as Oo,$K as Mo}from"./zeni-epic-state-B2izbHLH.js";import{M as No}from"./MobileAppDrawer-DdKhHPz6.js";import{q as Ie}from"./QBOConnectionScreen-awYitbDx.js";import"./recharts-Be6UzieB.js";import"./analytics-CLGfyryt.js";import"./plaid-DunXUDAB.js";import"./dnd-DmMNaNZl.js";import"./stripe-cKAAJElX.js";import"./lottie-BeDznxFN.js";import"./lexical-D8I0sdIn.js";import"./pdf-BhuhJSrH.js";import"./utils-3QzZ60R1.js";import"./InboxNotificationsProvider-DK30Cxb5.js";import"./useTaskManagerAccess-w-zZOzku.js";import"./empty-DOVgNO3g.js";import"./pdf-lib-BqU855ht.js";import"./index-Dsu8OkDH.js";import"./url-r_uX_Du7.js";import"./index-kVHvLKqq.js";import"./decodeURIComponentSafe-BKcGsnNf.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]="12d96b94-c222-443f-90e8-dc8d97f1b956",t._sentryDebugIdIdentifier="sentry-dbid-12d96b94-c222-443f-90e8-dc8d97f1b956")}catch{}})();const w=({event:t,isReady:e=!0})=>e?c.jsx(st,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Uo(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),{fetchState:m,hasMore:f,items:S,nextCursor:I,auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h}=E(Xt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((R,U)=>{const T=Zt(D,R,U,C);T!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:R,entityId:U,fromScreen:"audit_log",toScreen:R}),e(T))}),[C,e,D]);r.useEffect((()=>{const R=setTimeout((()=>u(a)),300);return()=>clearTimeout(R)}),[a]),r.useEffect((()=>{i&&t(nn({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&S.length===0,k=m==="In-Progress"&&S.length>0,j=m==="Completed";return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingAuditLogPage,isReady:j}),c.jsx(rt,{auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h,entries:S,hasMore:f,isLoading:A,isLoadingMore:k,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{f&&I!=null&&t(nn({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:p})]})}const Jn=["company","email","firstName","invoiceNotes","lastName","notes","phone","vatNumber"],Me=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:Array.isArray(t)?t.map(Me):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map((([e,n])=>[e,Me(n)]))):null;function B(t,e,n=[]){const i=t,a=e,o=[...new Set([...Object.keys(i),...Object.keys(a??{})])].filter((u=>{if(a==null)return(d=i[u])!=null&&d!==""&&(Array.isArray(d)?d.length>0:typeof d!="object"||Object.keys(d).length>0);var d;return!(i[u]==null&&a[u]==null)&&!ei(i[u],a[u])})).sort(),s=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Me(i[u])])));return{fieldsChanged:o,formValues:s}}function Ee(t,e=!1){const n=L(),i=E((s=>Z(s).productNextCursor!=null)),a=E((s=>Z(s).productNextCursor)),o=E((s=>Z(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(fe({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(fe({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function se(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),d=r.useRef(t);return r.useEffect((()=>{const p=d.current==="In-Progress";d.current=t,t==="Completed"&&p&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((p=>p+1)))}),[s,e]),a}const Bo=new Set(["plan"]),Vo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(l.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ti({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(Ve({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemEdited,{itemId:i,mode:"edit",...B(e.view.localData,fn(e.view.plan))}),t(Sn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(ni({action:o,id:a,parentItemId:i}))}}}))(dt);function Ho(){const t=L(),e=$(),{item_id:n,tenantEmailDomain:i}=_(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=(u=a.get("kind"))!=null&&Bo.has(u)?u:"plan";var u;const d=E((y=>Be(y,n))),{pageFetchState:p}=d,v=p.fetchState;r.useEffect((()=>(t(W({id:n})),()=>{t(W({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(Pe({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t(Pe({cacheOverride:!0,id:y,kind:s}))),[t,s]),f=se(d.fetchState,d.isFormLoading,n,m),S=v==="Completed"&&!d.isFormLoading;Ee(o,!0);const[I,C]=r.useState(S?n:void 0);r.useEffect((()=>{n!=null&&S&&C(n)}),[n,S]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||d.isFormLoading);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemDetailPage,isReady:S}),c.jsx(Vo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:d},f)]})}const qo=new Set(["addon","charge","plan"]),Qo=new Set(["plan"]),zo=O((function(t,e){const n=Be(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedItem:n.plan,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e,a=i!=null?`${n}/catalog/${encodeURIComponent(i)}`:`${n}/catalog`;return{onBack:()=>{t(W({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(W({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ve({id:i,localData:o}))},onSubmit:()=>{t(Sn({id:i}))}}}),(function({savedItem:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemSaved,{itemId:i.itemId,mode:e.mode,...B(e.localData,t!=null?fn(t):void 0)}),n.onSubmit()}}}))(lt);function Ko(){const t=L(),e=$(),{item_id:n,tenantEmailDomain:i}=_(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=n!=null,u=a.get("type"),d=u!=null&&qo.has(u)?u:void 0,p=(v=a.get("kind"))!=null&&Qo.has(v)?v:"plan";var v;const m=E((S=>Be(S,n)));Ee(o,!0);const f=r.useRef();return r.useEffect((()=>(clearTimeout(f.current),()=>{f.current=setTimeout((()=>{t(W({id:n}))}),0)})),[n,t]),r.useEffect((()=>{o&&t(Pe({id:n,kind:p}))}),[o,n,p,t]),r.useEffect((()=>{s||d==null||m.localData.catalogType===d||t(Ve({localData:{...m.localData,catalogType:d}}))}),[s,d,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??n,I=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(I),t(W({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemFormPage}),c.jsx(zo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:s,itemId:n})]})}const Go={addons:"addon",all:"item",charges:"charge",plans:"plan"},Wo=O((function(t,e){const n=Z(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="In-Progress"&&o.length>0,planRows:n.planRows,productRows:n.productRows}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Go[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(on({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(fe({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?on({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):fe({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Yo(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[d,p]=r.useState(""),[v,m]=r.useState(null),f=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),S=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:S,type:"plan"})),[S]),C=r.useMemo((()=>({search:S,type:"addon|charge"})),[S]),h=E((j=>Z(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,k=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>p(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1,planFilters:I,productFilters:C,planSort:f,productSort:f}))}),[i,t,I,C,f]),r.useEffect((()=>{i&&(S!==y||f?.field!==D?.field||f?.dir!==D?.dir)&&t(tn({cacheOverride:!0,planFilters:I,productFilters:C,planSort:f,productSort:f}))}),[y,D,i,t,I,C,S,f]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogPage,isReady:k}),c.jsx(Wo,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:v,planFilters:I,productFilters:C,sort:f,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:m})]})}const Jo=O((function(t,e){const n=In(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCoupon:n.coupon,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>{t(Y({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(Y({id:i})),e.navigate(`${n}/discounts`)},onChange:o=>{t(oi({id:i,localData:o}))},onSubmit:()=>{t(ii({id:i}))}}}),(function({savedCoupon:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponSaved,{couponId:i.couponId,mode:e.mode,...B(e.localData,t!=null?ai(t):void 0)}),n.onSubmit()}}}))(gt);function Xo(){const t=L(),e=$(),{coupon_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),{fetchState:o,savedCouponId:s}=E((d=>In(d,n))),u=r.useRef();return r.useEffect((()=>(clearTimeout(u.current),()=>{u.current=setTimeout((()=>{t(Y({id:n}))}),0)})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=s??n,p=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(p),t(Y({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCouponFormPage}),c.jsx(Jo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Zo=O((function(t){const e=hn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(kn(a))},onSubmit:()=>{const a=ri(t.localData);g.trackInvoicingActionClick(l.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length,mode:"create",...B(t.localData,void 0,["memo"])}),e(di(a))}}}))(vt);function ea(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),[i]=oe(),{areTenantIdsInSync:a}=F(),o=i.get("customerId"),s=E((b=>hn(b))),u=s.fetchState,d=s.localData,p=s.savedInvoiceId,v=E(Cn),m=E((b=>ci(b))),f=E(he),S=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=f.fetchState==="Not-Started"||f.fetchState==="In-Progress"&&f.customers.length===0,C=S||I,h=m.fetchState==="Completed"&&f.fetchState==="Completed";r.useEffect((()=>(t(an()),()=>{t(an())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||d.customerId!==""||(y.current=!0,t(kn({...d,customerId:o})))}),[o,d,t]),r.useEffect((()=>{a&&t(si({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=p!=null?`/${n}/invoicing/invoices/${encodeURIComponent(p)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,p,e,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),C?c.jsx(mt,{}):c.jsx(Zo,{navigate:e,tenantEmailDomain:n})]})}const na=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(pt);function ta(){const t=L(),e=$(),{credit_note_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),o=E((u=>li(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ui({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(na,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const ia=O((function(t){const e=En(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(mi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(ft);function oa(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,creditNoteListFetchState:h}=E((D=>{const b=En(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(be({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditsListPage,isReady:y}),c.jsx(ia,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(gi(D)),t(be({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Xn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},aa=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(_e({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(Q(G)),t(Ci({id:i}))},onOpenAddress:()=>{const a=Xn(e.tenantEmailDomain??"",G,i),o=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerEdited,{customerId:i,mode:"edit",...B(a,e.editView.record.invoicingCustomer!=null?bn(e.editView.record.invoicingCustomer):void 0,Jn)}),t(_e({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(hi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Ii({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function ca(){const t=L(),e=$(),n=ae(),{customer_id:i,tenantEmailDomain:a}=_(),{areTenantIdsInSync:o}=F(),s=E((T=>He(T,i))),u=s.pageFetchState.fetchState,d=u==="Completed"&&!s.isFormLoading,[p,v]=r.useState(!1),[m,f]=r.useState(!1),[S,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const C=S===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,k=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;k.current!=="Error"&&T==="Error"&&t(qe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),k.current=T}),[t,s.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(le()),t(ue()),()=>{t(le()),t(ue())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(f(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(vi({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(cn({customerId:i}))}),[o,i,t,A]);const R=r.useCallback((T=>t(yn({id:T}))),[t]),U=se(s.fetchState,s.isFormLoading,i,R);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),c.jsx(aa,{customerId:i??"",editView:s,hasLoadedRecord:C,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(le()),i!=null&&A&&t(cn({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ue()),f(!0)}},U),c.jsx(St,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:p,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(fi({customerId:i}))},onClose:()=>{v(!1),t(le())},onSavePaymentMethod:T=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(pi({customerId:i,data:T})))}}),c.jsx(It,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:m,submitSucceeded:y.fetchState==="Completed",onClose:()=>{f(!1),t(ue())},onSubmit:({amount:T,description:de})=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(Si({amount:T,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:de})))}})]})}const sa=O((function(t,e){const n=He(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCustomer:n.record.invoicingCustomer}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>{t(Se({id:i})),t(Q(G)),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(Se({id:i})),t(Q(G)),e.navigate(`${n}/customers`)},onChange:o=>{t(_e({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Xn(e.tenantEmailDomain??"",G,i),s=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(o,{state:{pathnameStackToGoBack:s}})},onSubmit:()=>{t(xn({id:i}))}}}),(function({savedCustomer:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerSaved,{customerId:i.customerId,mode:e.mode,...B(e.localData,t!=null?bn(t):void 0,Jn)}),n.onSubmit()}}}))(Ct);function ra(){const t=L(),e=$(),n=ae(),{customer_id:i,tenantEmailDomain:a}=_(),{areTenantIdsInSync:o}=F(),{fetchState:s,savedCustomerId:u}=E((m=>He(m,i))),d=r.useRef(!1),p=r.useCallback((()=>{d.current=!0}),[]),v=r.useRef();return r.useEffect((()=>(clearTimeout(v.current),d.current=!1,()=>{d.current||(v.current=setTimeout((()=>{t(Se({id:i})),t(Q(G))}),0))})),[i,t]),r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const m=u??i,f=m!=null?`/${a}/invoicing/customers/${encodeURIComponent(m)}`:`/${a}/invoicing/customers`;e(f),t(Se({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerFormPage}),c.jsx(sa,{customerId:i,keepDraftOnLeave:p,location:n,navigate:e,tenantEmailDomain:a})]})}const da=O((function(t){const e=he(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(An({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(kt);function la(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,customerListFetchState:h}=E((D=>{const b=he(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomersListPage,isReady:y}),c.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(ki(D)),t(xe({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Ne=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ua=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],d=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:d==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:d==="Not-Started"||d==="In-Progress",isLoadingMore:d==="In-Progress"&&(u?.items.length??0)>0,session:Ne(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],d=Ne(s,a),p=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.actionStateByKind.rollback?.fetchState==="In-Progress",m=d?.status==="done"&&d.rollback_available_until!=null&&new Date(d.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(Fe({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:d?.status!=="failed"||p?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(ze(a)))},onRollback:m?()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(Dn(a)))}:void 0}}))(Et);function ga(){const t=L(),e=$(),{sessionId:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),[o,s]=r.useState({}),u=E(Qe),d=E(Ce),p=r.useMemo((()=>{const C=te.getSignedInUser();return{userId:C?.userId??"",sessionId:C?.zeniSessionId??"",tenantId:d.tenantId}}),[d.tenantId]),v=Ne(u,n),m=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(Re(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const C=setTimeout((()=>{t(Fe({...o,sessionId:n}))}),300);return()=>clearTimeout(C)}),[a,t,o,n]);const f=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!f)return;const C=setInterval((()=>{t(Re(n)),t(Fe({...o,sessionId:n}))}),3e3);return()=>clearInterval(C)}),[a,t,o,f,n]);const S=r.useMemo((()=>{if(n==null)return"";const C=new URLSearchParams;o.moduleId!=null&&C.set("module_id",o.moduleId),o.level!=null&&C.set("level",o.level),o.outcome!=null&&C.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&C.set("search",o.search.trim());const h=C.toString();return`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=m?.fetch.fetchState??"Not-Started";return N(I)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(ua,{authParams:p,csvDownloadUrl:S,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Zn=t=>`invoicing_active_migration:${t}`,ve=(t,e)=>{if(t!=null&&t!=="")try{const n=Zn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ma=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const s=o??null;t(me(s)),ve(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(ze(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Dn(o))},onViewSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(yt);function va(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),a=E(Qe);r.useEffect((()=>{i&&(t(Ei()),t(jn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ma,{navigate:e,tenantEmailDomain:n,view:a})]})}const pa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:d,sessionDetail:p,sessions:v}=u,m=a.externalConnections?.revenue?.find((S=>S.connectionName==="chargebee")),f=n!=null?p[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(m?.isValid??!1),chargebeeConnectorAvailable:m!=null,chargebeeSite:o?.chargebee_site,connectError:d.connect?.error?.message,connecting:d.connect?.fetchState==="In-Progress",retrying:d.retry?.fetchState==="In-Progress",session:f??v.find((S=>S.id===n)),starting:d.start?.fetchState==="In-Progress",uploading:d.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(l.Event.invoicingChargebeeConnectClicked),t(xi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(ze(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportStarted),n!=null&&t(bi(n))},onUpload:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportFileUploaded),t(yi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(bt);function fa(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),a=E(Cn),o=E(Ce),s=r.useMemo((()=>{const h=te.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,d=o.companyId??te.getSignedInUserTenant(n??"")?.companyId,p=E((h=>Ln(h,d))),v=E(Qe),{activeMigrationSessionId:m}=v,f=m??void 0,S=f!=null?v.sessionDetail[f]??v.sessions.find((h=>h.id===f)):void 0;r.useEffect((()=>{i&&(t(Ke()),t(jn()))}),[i,t]),r.useEffect((()=>{if(m!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Zn(y))}catch{return null}})(n);h!=null&&t(me(h))}),[m,t,n]),r.useEffect((()=>{ve(n,m)}),[m,n]);const I=S?.status,C=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||f==null||!C)return;const h=setInterval((()=>{t(Re(f))}),3e3);return()=>clearInterval(h)}),[i,f,C,t]),r.useEffect((()=>{I==="done"&&(t(me(null)),ve(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportMigratePage}),c.jsx(pa,{activeId:f,authParams:s,integrationsView:p,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(me(null)),ve(n,null),e(`/${n}/invoicing/data_import`)}})]})}const Sa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t($n({action:a,id:i}))},onSaveEdit:a=>{const{coupon:o}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingCouponEdited,{couponId:i,mode:"edit",...B(a,{invoice_name:o?.invoiceName,invoice_notes:o?.invoiceNotes,max_redemptions:o?.maxRedemptions,name:o?.name},["invoice_notes"])}),t(Di({data:a,id:i}))}}}))(xt);function Ia(){const t=L(),e=$(),{coupon_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),o=E((I=>Ai(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,d=u==="Completed",[p,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const m=p===n;r.useEffect((()=>(t(Y({id:n})),()=>{t(Y({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]);const f=r.useCallback((I=>t(we({cacheOverride:!0,id:I}))),[t]),S=se(o.fetchState,o.isFormLoading,n,f);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),c.jsx(Sa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},S)]})}const ha=O((function(t){const e=Pn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t($n({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(Li({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(At);function Ca(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,couponListFetchState:h,runningDiscountActionId:y}=E((b=>{const A=Pn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ae({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>{t(ji(b)),t(Ae({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const ka=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",step:n.step}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,s={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(K({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(K({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(K({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(K({action:"retry",id:i}))}:void 0}}))(jt);function Ea(){const t=L(),e=$(),{case_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),o=E((k=>$i(k,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,p]=r.useState("idle"),[v,m]=r.useState(!1),[f,S]=r.useState(),[I,C]=r.useState(!1),h=r.useCallback((()=>{p("idle"),m(!1),S(void 0),C(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Pi({id:n})),p("idle"),m(!1);const k=o.emailPreview.preview;S(k==null?void 0:{body:k.body,cc:k.cc,subject:k.subject,to:k.to}),C(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((k=>{n!=null&&d!=="pending"&&(m(!1),p("pending"),g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(K({action:"send-email",body:k,id:n})))}),[n,t,d,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(wi({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(ke({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{p("idle"),m(!1),S(void 0),C(!1)}),[n]),r.useEffect((()=>{a||(p("idle"),m(!1),S(void 0),C(!1))}),[a]),r.useEffect((()=>{I&&f==null&&o.emailPreview.preview!=null&&S({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,f,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t(_i({id:n})),h()):v&&o.actionState.fetchState==="Error"&&p("failed"):m(!0))}),[n,h,t,d,v,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(ka,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(Dt,{initialDraft:f,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:d==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:d==="failed"?o.actionState.error?.message:void 0})]})}const ya=O((function(t){const e=wn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,stepById:e.stepById,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((s=>s.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...i(a),action:o}),t(K({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(Fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Lt);function ba(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,dunningCaseListFetchState:h,dunningCases:y}=E((b=>{const A=wn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(De({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(De({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningListPage,isReady:D}),c.jsx(ya,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,dunningCases:y,nextCursor:C,onSearchChange:o,onStatusChange:b=>{t(Ri(b)),t(De({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const xa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(q({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(s,{due_date:a?.dueDate?.format("YYYY-MM-DD")??"",notes:(a?.notes??[]).map((u=>u.note)).filter((u=>u!=null&&u!=="")).join(`
|
|
1
|
+
import{j as c}from"./liveblocks-CzEOPLmF.js";import{a as r}from"./sentry-9QW1WlhM.js";import{u as L,h as $,i as _,j as E,t as oe,l as O,s as z,g as ae,N as H,n as ge,o as x}from"./core-DKqX1MvM.js";import{a6 as st,k as g,ao as F,R as l,cd as rt,ce as dt,cf as lt,cg as ut,ch as gt,ci as mt,cj as vt,ck as pt,cl as ft,cm as St,cn as It,co as ht,p as ce,cp as Ct,cq as kt,z as te,ac as pe,cr as Et,cs as yt,ct as bt,cu as xt,cv as At,cw as Dt,cx as jt,cy as Lt,cz as $t,cA as Pt,V as wt,ag as pn,cB as _t,cC as Rt,cD as Ft,cE as Tt,cF as Ot,cG as Mt,cH as Nt,cI as Ut,cJ as Bt,cK as Vt,cL as Ht,t as en,j as Ue,cM as qt,cN as Qt,cO as zt,cP as Kt,cQ as Gt,cR as Wt,cS as Yt,bt as Jt}from"./index-VO1FF9fC.js";import"./mui-Bhz49yKC.js";import{A as X}from"./AddressScreen-D8ZFS5c0.js";import M from"./NotFoundScreen-C75AzqPX.js";import{_G as Xt,_H as Zt,vw as nn,v as ei,_I as Z,w7 as fe,_J as Be,_K as W,wK as Pe,wR as ni,dY as fn,wV as Sn,_L as Ve,wO as ti,yu as tn,w6 as on,_M as In,_N as Y,x4 as we,x8 as ii,_O as oi,xi as ai,_P as hn,xb as Cn,z2 as ci,_Q as he,_R as an,_S as kn,w2 as si,_T as ri,vW as di,_U as li,yH as ui,_V as En,yQ as be,_W as gi,yN as mi,_X as He,gk as qe,_Y as le,_Z as ue,xq as vi,wc as cn,wh as yn,wf as pi,w9 as fi,xj as Si,wj as Ii,xs as hi,c$ as bn,__ as _e,xB as xn,xz as Q,xx as G,xw as Ci,_$ as Se,yX as xe,$0 as ki,w4 as An,$1 as Qe,fI as Ce,ws as Re,wp as Fe,wC as Dn,wB as ze,wm as Ei,wv as jn,wE as me,Wk as Ln,w8 as Ke,wz as yi,wA as bi,wy as xi,$2 as Ai,x9 as Di,x5 as $n,$3 as Pn,vN as Ae,$4 as ji,vG as Li,$5 as $i,z1 as Pi,z6 as K,z0 as wi,y8 as ke,$6 as _i,$7 as wn,zf as De,$8 as Ri,zc as Fi,$9 as _n,yb as Ti,yc as q,yf as Oi,$a as Rn,yp as je,$b as Mi,xr as Fn,UR as Tn,$c as Ni,yz as Ui,$d as On,$e as sn,$f as Bi,$g as Vi,A2 as Hi,$h as qi,$i as Mn,zm as Nn,$j as Un,A0 as Le,$k as Qi,zZ as zi,$l as Ki,$m as Gi,$n as Wi,$o as Yi,$p as Ji,$q as rn,$r as Xi,ei as Zi,A6 as eo,$s as Ge,xL as no,xG as to,d1 as Te,$t as ee,xP as Bn,xX as Vn,$u as We,xQ as ie,y0 as io,y3 as Hn,$v as oo,$w as Oe,x$ as ao,$x as qn,zR as $e,zM as co,$y as so,zr as ro,$z as lo,zS as uo,zW as go,$A as Ye,wM as Qn,zD as mo,wN as vo,$B as po,$C as zn,ca as fo,mw as So,mx as Io,$D as dn,wL as ne,go as ho,mD as Co,zJ as Kn,Ai as ko,zG as Gn,v2 as Eo,uS as yo,hW as bo,Vi as ln,Vj as xo,GK as Wn,Af as Ao,hO as Do,Ac as jo,$E as Lo,$F as $o,Ao as Po,An as wo,$G as _o,$H as Yn,Al as Ro,$I as Fo,$J as To,yD as Oo,$K as Mo}from"./zeni-epic-state-4S4FDL12.js";import{M as No}from"./MobileAppDrawer-B2nfLEqA.js";import{q as Ie}from"./QBOConnectionScreen-ZmZgKCHJ.js";import"./recharts-zD9lBvAv.js";import"./analytics-BkXKjaSH.js";import"./plaid-Bs1vGF7f.js";import"./dnd-CTBYmQk9.js";import"./stripe-cKAAJElX.js";import"./lottie-ByL7llpj.js";import"./lexical-BBNKXOAq.js";import"./pdf-DKcIxepG.js";import"./utils-Ciaf9ZZY.js";import"./InboxNotificationsProvider-NVGRbeaR.js";import"./useTaskManagerAccess-CZsCSMny.js";import"./empty-Dvx7pCoK.js";import"./pdf-lib-IgS2Okos.js";import"./index-B-oBJcTm.js";import"./url-CKXRQoNl.js";import"./index-Dgy1xiQh.js";import"./decodeURIComponentSafe-BrmecbO9.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]="12d96b94-c222-443f-90e8-dc8d97f1b956",t._sentryDebugIdIdentifier="sentry-dbid-12d96b94-c222-443f-90e8-dc8d97f1b956")}catch{}})();const w=({event:t,isReady:e=!0})=>e?c.jsx(st,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Uo(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),{fetchState:m,hasMore:f,items:S,nextCursor:I,auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h}=E(Xt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((R,U)=>{const T=Zt(D,R,U,C);T!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:R,entityId:U,fromScreen:"audit_log",toScreen:R}),e(T))}),[C,e,D]);r.useEffect((()=>{const R=setTimeout((()=>u(a)),300);return()=>clearTimeout(R)}),[a]),r.useEffect((()=>{i&&t(nn({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&S.length===0,k=m==="In-Progress"&&S.length>0,j=m==="Completed";return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingAuditLogPage,isReady:j}),c.jsx(rt,{auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h,entries:S,hasMore:f,isLoading:A,isLoadingMore:k,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{f&&I!=null&&t(nn({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:p})]})}const Jn=["company","email","firstName","invoiceNotes","lastName","notes","phone","vatNumber"],Me=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:Array.isArray(t)?t.map(Me):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map((([e,n])=>[e,Me(n)]))):null;function B(t,e,n=[]){const i=t,a=e,o=[...new Set([...Object.keys(i),...Object.keys(a??{})])].filter((u=>{if(a==null)return(d=i[u])!=null&&d!==""&&(Array.isArray(d)?d.length>0:typeof d!="object"||Object.keys(d).length>0);var d;return!(i[u]==null&&a[u]==null)&&!ei(i[u],a[u])})).sort(),s=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Me(i[u])])));return{fieldsChanged:o,formValues:s}}function Ee(t,e=!1){const n=L(),i=E((s=>Z(s).productNextCursor!=null)),a=E((s=>Z(s).productNextCursor)),o=E((s=>Z(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(fe({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(fe({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function se(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),d=r.useRef(t);return r.useEffect((()=>{const p=d.current==="In-Progress";d.current=t,t==="Completed"&&p&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((p=>p+1)))}),[s,e]),a}const Bo=new Set(["plan"]),Vo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(l.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ti({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(Ve({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemEdited,{itemId:i,mode:"edit",...B(e.view.localData,fn(e.view.plan))}),t(Sn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(ni({action:o,id:a,parentItemId:i}))}}}))(dt);function Ho(){const t=L(),e=$(),{item_id:n,tenantEmailDomain:i}=_(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=(u=a.get("kind"))!=null&&Bo.has(u)?u:"plan";var u;const d=E((y=>Be(y,n))),{pageFetchState:p}=d,v=p.fetchState;r.useEffect((()=>(t(W({id:n})),()=>{t(W({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(Pe({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t(Pe({cacheOverride:!0,id:y,kind:s}))),[t,s]),f=se(d.fetchState,d.isFormLoading,n,m),S=v==="Completed"&&!d.isFormLoading;Ee(o,!0);const[I,C]=r.useState(S?n:void 0);r.useEffect((()=>{n!=null&&S&&C(n)}),[n,S]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||d.isFormLoading);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemDetailPage,isReady:S}),c.jsx(Vo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:d},f)]})}const qo=new Set(["addon","charge","plan"]),Qo=new Set(["plan"]),zo=O((function(t,e){const n=Be(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedItem:n.plan,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e,a=i!=null?`${n}/catalog/${encodeURIComponent(i)}`:`${n}/catalog`;return{onBack:()=>{t(W({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(W({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ve({id:i,localData:o}))},onSubmit:()=>{t(Sn({id:i}))}}}),(function({savedItem:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemSaved,{itemId:i.itemId,mode:e.mode,...B(e.localData,t!=null?fn(t):void 0)}),n.onSubmit()}}}))(lt);function Ko(){const t=L(),e=$(),{item_id:n,tenantEmailDomain:i}=_(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=n!=null,u=a.get("type"),d=u!=null&&qo.has(u)?u:void 0,p=(v=a.get("kind"))!=null&&Qo.has(v)?v:"plan";var v;const m=E((S=>Be(S,n)));Ee(o,!0);const f=r.useRef();return r.useEffect((()=>(clearTimeout(f.current),()=>{f.current=setTimeout((()=>{t(W({id:n}))}),0)})),[n,t]),r.useEffect((()=>{o&&t(Pe({id:n,kind:p}))}),[o,n,p,t]),r.useEffect((()=>{s||d==null||m.localData.catalogType===d||t(Ve({localData:{...m.localData,catalogType:d}}))}),[s,d,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??n,I=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(I),t(W({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemFormPage}),c.jsx(zo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:s,itemId:n})]})}const Go={addons:"addon",all:"item",charges:"charge",plans:"plan"},Wo=O((function(t,e){const n=Z(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="In-Progress"&&o.length>0,planRows:n.planRows,productRows:n.productRows}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Go[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(on({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(fe({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?on({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):fe({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Yo(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[d,p]=r.useState(""),[v,m]=r.useState(null),f=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),S=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:S,type:"plan"})),[S]),C=r.useMemo((()=>({search:S,type:"addon|charge"})),[S]),h=E((j=>Z(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,k=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>p(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1,planFilters:I,productFilters:C,planSort:f,productSort:f}))}),[i,t,I,C,f]),r.useEffect((()=>{i&&(S!==y||f?.field!==D?.field||f?.dir!==D?.dir)&&t(tn({cacheOverride:!0,planFilters:I,productFilters:C,planSort:f,productSort:f}))}),[y,D,i,t,I,C,S,f]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogPage,isReady:k}),c.jsx(Wo,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:v,planFilters:I,productFilters:C,sort:f,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:m})]})}const Jo=O((function(t,e){const n=In(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCoupon:n.coupon,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>{t(Y({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(Y({id:i})),e.navigate(`${n}/discounts`)},onChange:o=>{t(oi({id:i,localData:o}))},onSubmit:()=>{t(ii({id:i}))}}}),(function({savedCoupon:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponSaved,{couponId:i.couponId,mode:e.mode,...B(e.localData,t!=null?ai(t):void 0)}),n.onSubmit()}}}))(gt);function Xo(){const t=L(),e=$(),{coupon_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),{fetchState:o,savedCouponId:s}=E((d=>In(d,n))),u=r.useRef();return r.useEffect((()=>(clearTimeout(u.current),()=>{u.current=setTimeout((()=>{t(Y({id:n}))}),0)})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=s??n,p=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(p),t(Y({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCouponFormPage}),c.jsx(Jo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Zo=O((function(t){const e=hn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(kn(a))},onSubmit:()=>{const a=ri(t.localData);g.trackInvoicingActionClick(l.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length,mode:"create",...B(t.localData,void 0,["memo"])}),e(di(a))}}}))(vt);function ea(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),[i]=oe(),{areTenantIdsInSync:a}=F(),o=i.get("customerId"),s=E((b=>hn(b))),u=s.fetchState,d=s.localData,p=s.savedInvoiceId,v=E(Cn),m=E((b=>ci(b))),f=E(he),S=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=f.fetchState==="Not-Started"||f.fetchState==="In-Progress"&&f.customers.length===0,C=S||I,h=m.fetchState==="Completed"&&f.fetchState==="Completed";r.useEffect((()=>(t(an()),()=>{t(an())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||d.customerId!==""||(y.current=!0,t(kn({...d,customerId:o})))}),[o,d,t]),r.useEffect((()=>{a&&t(si({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=p!=null?`/${n}/invoicing/invoices/${encodeURIComponent(p)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,p,e,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),C?c.jsx(mt,{}):c.jsx(Zo,{navigate:e,tenantEmailDomain:n})]})}const na=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(pt);function ta(){const t=L(),e=$(),{credit_note_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),o=E((u=>li(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ui({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(na,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const ia=O((function(t){const e=En(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(mi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(ft);function oa(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,creditNoteListFetchState:h}=E((D=>{const b=En(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(be({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditsListPage,isReady:y}),c.jsx(ia,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(gi(D)),t(be({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Xn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},aa=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(_e({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(Q(G)),t(Ci({id:i}))},onOpenAddress:()=>{const a=Xn(e.tenantEmailDomain??"",G,i),o=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerEdited,{customerId:i,mode:"edit",...B(a,e.editView.record.invoicingCustomer!=null?bn(e.editView.record.invoicingCustomer):void 0,Jn)}),t(_e({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(hi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Ii({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function ca(){const t=L(),e=$(),n=ae(),{customer_id:i,tenantEmailDomain:a}=_(),{areTenantIdsInSync:o}=F(),s=E((T=>He(T,i))),u=s.pageFetchState.fetchState,d=u==="Completed"&&!s.isFormLoading,[p,v]=r.useState(!1),[m,f]=r.useState(!1),[S,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const C=S===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,k=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;k.current!=="Error"&&T==="Error"&&t(qe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),k.current=T}),[t,s.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(le()),t(ue()),()=>{t(le()),t(ue())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(f(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(vi({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(cn({customerId:i}))}),[o,i,t,A]);const R=r.useCallback((T=>t(yn({id:T}))),[t]),U=se(s.fetchState,s.isFormLoading,i,R);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),c.jsx(aa,{customerId:i??"",editView:s,hasLoadedRecord:C,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(le()),i!=null&&A&&t(cn({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ue()),f(!0)}},U),c.jsx(St,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:p,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(fi({customerId:i}))},onClose:()=>{v(!1),t(le())},onSavePaymentMethod:T=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(pi({customerId:i,data:T})))}}),c.jsx(It,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:m,submitSucceeded:y.fetchState==="Completed",onClose:()=>{f(!1),t(ue())},onSubmit:({amount:T,description:de})=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(Si({amount:T,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:de})))}})]})}const sa=O((function(t,e){const n=He(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCustomer:n.record.invoicingCustomer}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>{t(Se({id:i})),t(Q(G)),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(Se({id:i})),t(Q(G)),e.navigate(`${n}/customers`)},onChange:o=>{t(_e({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Xn(e.tenantEmailDomain??"",G,i),s=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(o,{state:{pathnameStackToGoBack:s}})},onSubmit:()=>{t(xn({id:i}))}}}),(function({savedCustomer:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerSaved,{customerId:i.customerId,mode:e.mode,...B(e.localData,t!=null?bn(t):void 0,Jn)}),n.onSubmit()}}}))(Ct);function ra(){const t=L(),e=$(),n=ae(),{customer_id:i,tenantEmailDomain:a}=_(),{areTenantIdsInSync:o}=F(),{fetchState:s,savedCustomerId:u}=E((m=>He(m,i))),d=r.useRef(!1),p=r.useCallback((()=>{d.current=!0}),[]),v=r.useRef();return r.useEffect((()=>(clearTimeout(v.current),d.current=!1,()=>{d.current||(v.current=setTimeout((()=>{t(Se({id:i})),t(Q(G))}),0))})),[i,t]),r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const m=u??i,f=m!=null?`/${a}/invoicing/customers/${encodeURIComponent(m)}`:`/${a}/invoicing/customers`;e(f),t(Se({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerFormPage}),c.jsx(sa,{customerId:i,keepDraftOnLeave:p,location:n,navigate:e,tenantEmailDomain:a})]})}const da=O((function(t){const e=he(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(An({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(kt);function la(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,customerListFetchState:h}=E((D=>{const b=he(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomersListPage,isReady:y}),c.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(ki(D)),t(xe({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Ne=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ua=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],d=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:d==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:d==="Not-Started"||d==="In-Progress",isLoadingMore:d==="In-Progress"&&(u?.items.length??0)>0,session:Ne(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],d=Ne(s,a),p=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.actionStateByKind.rollback?.fetchState==="In-Progress",m=d?.status==="done"&&d.rollback_available_until!=null&&new Date(d.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(Fe({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:d?.status!=="failed"||p?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(ze(a)))},onRollback:m?()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(Dn(a)))}:void 0}}))(Et);function ga(){const t=L(),e=$(),{sessionId:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),[o,s]=r.useState({}),u=E(Qe),d=E(Ce),p=r.useMemo((()=>{const C=te.getSignedInUser();return{userId:C?.userId??"",sessionId:C?.zeniSessionId??"",tenantId:d.tenantId}}),[d.tenantId]),v=Ne(u,n),m=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(Re(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const C=setTimeout((()=>{t(Fe({...o,sessionId:n}))}),300);return()=>clearTimeout(C)}),[a,t,o,n]);const f=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!f)return;const C=setInterval((()=>{t(Re(n)),t(Fe({...o,sessionId:n}))}),3e3);return()=>clearInterval(C)}),[a,t,o,f,n]);const S=r.useMemo((()=>{if(n==null)return"";const C=new URLSearchParams;o.moduleId!=null&&C.set("module_id",o.moduleId),o.level!=null&&C.set("level",o.level),o.outcome!=null&&C.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&C.set("search",o.search.trim());const h=C.toString();return`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=m?.fetch.fetchState??"Not-Started";return N(I)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(ua,{authParams:p,csvDownloadUrl:S,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Zn=t=>`invoicing_active_migration:${t}`,ve=(t,e)=>{if(t!=null&&t!=="")try{const n=Zn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ma=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const s=o??null;t(me(s)),ve(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(ze(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Dn(o))},onViewSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(yt);function va(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),a=E(Qe);r.useEffect((()=>{i&&(t(Ei()),t(jn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ma,{navigate:e,tenantEmailDomain:n,view:a})]})}const pa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:d,sessionDetail:p,sessions:v}=u,m=a.externalConnections?.revenue?.find((S=>S.connectionName==="chargebee")),f=n!=null?p[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(m?.isValid??!1),chargebeeConnectorAvailable:m!=null,chargebeeSite:o?.chargebee_site,connectError:d.connect?.error?.message,connecting:d.connect?.fetchState==="In-Progress",retrying:d.retry?.fetchState==="In-Progress",session:f??v.find((S=>S.id===n)),starting:d.start?.fetchState==="In-Progress",uploading:d.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(l.Event.invoicingChargebeeConnectClicked),t(xi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(ze(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportStarted),n!=null&&t(bi(n))},onUpload:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportFileUploaded),t(yi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(bt);function fa(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),a=E(Cn),o=E(Ce),s=r.useMemo((()=>{const h=te.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,d=o.companyId??te.getSignedInUserTenant(n??"")?.companyId,p=E((h=>Ln(h,d))),v=E(Qe),{activeMigrationSessionId:m}=v,f=m??void 0,S=f!=null?v.sessionDetail[f]??v.sessions.find((h=>h.id===f)):void 0;r.useEffect((()=>{i&&(t(Ke()),t(jn()))}),[i,t]),r.useEffect((()=>{if(m!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Zn(y))}catch{return null}})(n);h!=null&&t(me(h))}),[m,t,n]),r.useEffect((()=>{ve(n,m)}),[m,n]);const I=S?.status,C=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||f==null||!C)return;const h=setInterval((()=>{t(Re(f))}),3e3);return()=>clearInterval(h)}),[i,f,C,t]),r.useEffect((()=>{I==="done"&&(t(me(null)),ve(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportMigratePage}),c.jsx(pa,{activeId:f,authParams:s,integrationsView:p,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(me(null)),ve(n,null),e(`/${n}/invoicing/data_import`)}})]})}const Sa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t($n({action:a,id:i}))},onSaveEdit:a=>{const{coupon:o}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingCouponEdited,{couponId:i,mode:"edit",...B(a,{invoice_name:o?.invoiceName,invoice_notes:o?.invoiceNotes,max_redemptions:o?.maxRedemptions,name:o?.name},["invoice_notes"])}),t(Di({data:a,id:i}))}}}))(xt);function Ia(){const t=L(),e=$(),{coupon_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),o=E((I=>Ai(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,d=u==="Completed",[p,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const m=p===n;r.useEffect((()=>(t(Y({id:n})),()=>{t(Y({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]);const f=r.useCallback((I=>t(we({cacheOverride:!0,id:I}))),[t]),S=se(o.fetchState,o.isFormLoading,n,f);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),c.jsx(Sa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},S)]})}const ha=O((function(t){const e=Pn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t($n({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(Li({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(At);function Ca(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,couponListFetchState:h,runningDiscountActionId:y}=E((b=>{const A=Pn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ae({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>{t(ji(b)),t(Ae({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const ka=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",step:n.step}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,s={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(K({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(K({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(K({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(K({action:"retry",id:i}))}:void 0}}))(jt);function Ea(){const t=L(),e=$(),{case_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),o=E((k=>$i(k,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,p]=r.useState("idle"),[v,m]=r.useState(!1),[f,S]=r.useState(),[I,C]=r.useState(!1),h=r.useCallback((()=>{p("idle"),m(!1),S(void 0),C(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Pi({id:n})),p("idle"),m(!1);const k=o.emailPreview.preview;S(k==null?void 0:{body:k.body,cc:k.cc,subject:k.subject,to:k.to}),C(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((k=>{n!=null&&d!=="pending"&&(m(!1),p("pending"),g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(K({action:"send-email",body:k,id:n})))}),[n,t,d,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(wi({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(ke({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{p("idle"),m(!1),S(void 0),C(!1)}),[n]),r.useEffect((()=>{a||(p("idle"),m(!1),S(void 0),C(!1))}),[a]),r.useEffect((()=>{I&&f==null&&o.emailPreview.preview!=null&&S({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,f,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t(_i({id:n})),h()):v&&o.actionState.fetchState==="Error"&&p("failed"):m(!0))}),[n,h,t,d,v,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(ka,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(Dt,{initialDraft:f,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:d==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:d==="failed"?o.actionState.error?.message:void 0})]})}const ya=O((function(t){const e=wn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,stepById:e.stepById,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((s=>s.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...i(a),action:o}),t(K({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(Fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Lt);function ba(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,dunningCaseListFetchState:h,dunningCases:y}=E((b=>{const A=wn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(De({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(De({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningListPage,isReady:D}),c.jsx(ya,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,dunningCases:y,nextCursor:C,onSearchChange:o,onStatusChange:b=>{t(Ri(b)),t(De({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const xa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(q({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(s,{due_date:a?.dueDate?.format("YYYY-MM-DD")??"",notes:(a?.notes??[]).map((u=>u.note)).filter((u=>u!=null&&u!=="")).join(`
|
|
2
2
|
`),po_number:a?.poNumber??""},["notes"])}),t(Oi({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
|
|
3
3
|
`).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:s.po_number!==""?s.po_number:null},invoiceId:i}))},onSendReminder:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(q({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(q({action:"void",invoiceId:i,body:s}))}}}))($t);function Aa(){const t=L(),e=$(),{invoice_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),o=E((S=>_n(S,n??""))),s=o.pageFetchState.fetchState,u=s==="Completed",[d,p]=r.useState(u?n:void 0);r.useEffect((()=>{n!=null&&u&&p(n)}),[n,u]);const v=d===n;r.useEffect((()=>{a&&n!=null&&t(Ti({invoiceId:n}))}),[a,n,t]);const m=r.useCallback((S=>t(ke({invoiceId:S}))),[t]),f=se(o.actionState.fetchState,o.fetchState==="In-Progress",n,m);return N(s)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingInvoiceDetailPage,isReady:u}),c.jsx(xa,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},f)]})}const Da=O((function(t){const e=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`,i=a=>{const o=e.invoices.find((s=>s.id===a));return{amount:o?.total?.amount,customerId:o?.customerID,fromScreen:"invoices_list",invoiceId:a,status:o?.status}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRowClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{switch(o){case"recordPayment":g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/record-payment`);break;case"issueCreditNote":g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/issue-credit-note`);break;case"sendReminder":g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,i(a)),t(q({action:"send-reminder",invoiceId:a}));break;case"regenerate":g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,i(a)),t(q({action:"regenerate",invoiceId:a}));break;case"void":g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a}))}},onVoidInvoice:(a,o)=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"invoices",status:e.activeStatus}),t(Fn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Pt);function ja(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=E((A=>{const k=Rn(A);return{activeStatus:k.activeTab,appliedSearch:k.filters.search,appliedSort:A.invoicingInvoiceListState.sort,nextCursor:k.nextCursor,invoiceListFetchState:k.fetchState,voidingInvoiceId:k.runningActionId,invoices:k.invoices}}),z),b=h==="Completed";return r.useEffect((()=>{const A=setTimeout((()=>u(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(je({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingInvoicesListPage,isReady:b}),c.jsx(Da,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,invoices:D,nextCursor:C,voidingInvoiceId:y,onSearchChange:o,onStatusChange:A=>{t(Mi(A)),t(je({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}function un(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),i=wt(),a=pn(),[o,s]=r.useState(!1),{acceptTermsState:u,status:d}=E(Tn),p=Ni(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,m=f=>{s(f)};return d==="completed"?c.jsx(H,{to:`${v}/overview`,replace:!0}):d==="settings"&&p?c.jsx(H,{to:`${v}/settings`,replace:!0}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPromoPage}),c.jsx(No,{isAppContentDrawerOpen:o,handleDrawerToggle:m}),c.jsx(_t,{analytics:g,isAccepting:u.fetchState==="In-Progress",isReadOnlyUser:!p,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{g.trackInvoicingActionClick(l.Event.invoicingTermsAccepted),t(Ui())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{m(!0)}})]})}const La=O((function(t,e){const n=On(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:s,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:s.fetchState==="Error"?s.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:s.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:u}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:a=>{t(qi({localData:a}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Hi())}}}))(Rt);function $a(){const t=L(),e=$(),{invoice_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),{fetchState:o,invoice:s,isPageReady:u,issuedCreditNoteId:d,submitState:p}=E((S=>On(S,n??""))),v=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>(t(sn()),m.current=null,()=>{t(sn())})),[t,n]),r.useEffect((()=>{a&&n!=null&&t(ke({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{s!=null&&n!=null&&o==="Completed"&&m.current!==n&&(m.current=n,t(Bi({localData:Vi(s)})))}),[t,o,s,n]);const f=r.useRef(p.fetchState);return r.useEffect((()=>{const S=f.current;f.current=p.fetchState,S!=="Completed"&&p.fetchState==="Completed"&&d!=null&&e(`${v}/credits/${encodeURIComponent(d)}`)}),[d,e,p.fetchState,v]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingIssueCreditNotePage,isReady:u}),c.jsx(La,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Pa=O((function(t){return{invoicingOverview:Mn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingOverviewRefreshed),t(Nn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(Ft);function wa(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a]=r.useState((()=>{const s=new Date;return{month:s.getMonth()+1,year:s.getFullYear()}})),o=E((s=>Mn(s).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Nn(a))}),[i,t,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingOverviewPage,isReady:o}),c.jsx(Pa,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const _a=O((function(t){const e=Un(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"payments",tab:e.activeType}),t(zi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Tt);function Ra(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeType:f,appliedSearch:S,appliedSort:I,nextCursor:C,transactionListFetchState:h,transactions:y}=E((j=>{const R=Un(j);return{activeType:R.activeTab,appliedSearch:R.filters.search,appliedSort:R.sort,nextCursor:R.nextCursor,transactionListFetchState:R.fetchState,transactions:R.transactions}}),z),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const R=y.find((T=>T.id===j)),U=R?.linkedInvoices?.[0]?.invoiceID??R?.invoiceID;U!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${b}/invoices/${encodeURIComponent(U)}`))}),[e,b,y]),k=r.useCallback((j=>{const R=y.find((U=>U.id===j))?.customerID;R!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:R,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(R)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(Le({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Le({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPaymentsListPage,isReady:D}),c.jsx(_a,{navigate:e,tenantEmailDomain:n,activeType:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onTypeChange:j=>{t(Qi(j)),t(Le({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p,onViewTransactionCustomer:k,onViewTransactionInvoice:A})]})}const Fa=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function gn(){const t=L(),e=$(),{invoice_id:n,tenantEmailDomain:i}=_(),{areTenantIdsInSync:a}=F(),o=n!=null&&n!=="",s=E(he),u=E((k=>Ki(k))),d=E(Gi),p=E((k=>_n(k,n??""))),v=p.invoice,m=`/${i}/invoicing`,f=r.useRef(null),S=r.useRef("");r.useEffect((()=>{t(Wi()),f.current=null,S.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?ke({invoiceId:n}):An({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&v!=null&&n!=null&&p.fetchState==="Completed"&&f.current!==n&&(f.current=n,t(Yi({contextInvoiceId:n,localData:Ji(v)})))}),[t,v,n,p.fetchState,o]),r.useEffect((()=>{if(o)return;const k=u.localData.customerId;k!==""&&k!==S.current&&(S.current=k,t(Fn({filters:{customerId:k},keepExistingListItems:!1})),u.localData.invoiceToLink!==""&&t(rn({localData:{...u.localData,customerId:k,invoiceToLink:""}})))}),[t,u.localData,o]);const I=r.useRef(d.fetchState);r.useEffect((()=>{const k=I.current;if(I.current=d.fetchState,k!=="Completed"&&d.fetchState==="Completed"){if(d.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(d.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,d.fetchState,d.recordedInvoiceId,m]);const C=r.useMemo((()=>s.customers.map((k=>({id:k.id,name:Fa(k)})))),[s.customers]),h=E((k=>Xi(k,u.localData.customerId))),y=r.useMemo((()=>h.map((k=>{return{amountDue:(j=k.amountDue,R=Zi.currencySymbol,Nt("0,0.00",j,R)),amountDueValue:k.amountDue,id:k.id,label:k.invoiceNumber};var j,R}))),[h]),D=r.useMemo((()=>{if(!o||v==null)return;const k=v.currencyCode??"USD",j=v.amountDue?.amount??0;return{amountDue:Ot("0,0.00",v.amountDue),amountDueValue:j,currencyCode:k,customerName:v.customerName??v.customerID,invoiceId:v.id,invoiceNumber:v.invoiceNumber??v.id}}),[v,o]),b=o?`${m}/invoices/${encodeURIComponent(n??"")}`:`${m}/payments`,A=!o||p.fetchState==="Completed"&&u.localData.invoiceToLink!=="";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingRecordPaymentPage,isReady:A}),c.jsx(Mt,{customers:C,fieldHelp:u.fieldHelp,errorMessage:d.fetchState==="Error"?d.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:u.gatewayOptions,invoiceContext:D,invoiceOptions:y,isSubmitting:d.fetchState==="In-Progress",localData:u.localData,mode:o?"invoice":"customer",paymentMethodOptions:u.paymentMethodOptions,onBack:()=>{e(b)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentCancelled),e(b)},onChange:k=>{t(rn({localData:k}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRecorded,{customerId:u.localData.customerId,invoiceId:o?n:u.localData.invoiceToLink,paymentMethod:u.localData.paymentMethod}),t(eo(o?n??void 0:void 0))}})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Ta=O((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:o,charges:n.charges,coupons:n.coupons,estimate:n.estimate,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(s,u)=>{const{subscription:d}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:s,amount:d?.mrr?.amount,customerId:d?.customerID,fromScreen:"subscription_detail",status:d?.status,subscriptionId:i}),t(Hn({action:s,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:s=>{t(ee({id:i,localData:s}))},onChangeTermEnd:a?s=>{const u=s?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(s)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Q(ie)),t(io({id:i}))},onOpenAddress:()=>{const s=et(e.tenantEmailDomain??"",ie,i),u=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onCloseEstimate:()=>{t(We())},onRequestEstimate:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Vn({id:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEdited,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Bn({id:i}))},onCancelSubscription:a?s=>{o("cancel",{cancel_reason_code:s.cancelReasonCode,end_of_term:!1,...s.cancelReason!=null&&s.cancelReason.trim()!==""?{cancel_reason:s.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(s,u)=>{s!=="pause"?o(s):o(s,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))(Ut);function Oa(){const t=L(),e=$(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=_(),{areTenantIdsInSync:o}=F(),s=E((y=>Ge(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:d,subscriptionMetadataEditAllowedFromStatuses:p}=s,v=s.pageFetchState.fetchState,m=v==="Completed"&&!s.isFormLoading,[f,S]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&S(i)}),[i,m]);const I=f===i;Ee(o),r.useEffect((()=>{o&&i!=null&&t(no({id:i}))}),[o,i,t]);const C=r.useCallback((y=>t(to({id:y}))),[t]),h=se(s.fetchState,s.isFormLoading,i,C);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionDetailPage,isReady:m}),c.jsx(Ta,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:s,lifecycleActionOptions:d,location:n,metadataEditAllowedFromStatuses:p,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},h)]})}const Ma=O((function(t,e){const n=Ge(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,estimate:n.estimate,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,savedSubscription:n.subscription,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e;return{onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionFormCancelled),t(Oe({id:i})),t(Q(ie)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{t(ee({id:i,localData:a}))},onCloseEstimate:()=>{t(We())},onRequestEstimate:()=>{t(Vn({id:i}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const a=et(e.tenantEmailDomain??"",ie,i),o=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(a,{state:{pathnameStackToGoBack:o}})},onSubmit:()=>{t(Bn({id:i}))}}}),(function({savedSubscription:t,...e},n,i){const a=()=>({mode:e.mode,subscriptionId:i.subscriptionId,...B(e.localData,t!=null?Te(t):void 0)});return{...i,...e,...n,onRequestEstimate:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,a()),n.onRequestEstimate()},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionSaved,a()),n.onSubmit()}}}))(Bt);function Na(){const t=L(),e=$(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=_(),[o]=oe(),{areTenantIdsInSync:s}=F(),u=o.get("customerId"),{fetchState:d,savedSubscriptionId:p}=E((C=>oo(C,i))),v=E((C=>Ge(C,i).localData));Ee(s);const m=r.useRef(!1),f=r.useCallback((()=>{m.current=!0}),[]),S=r.useRef();r.useEffect((()=>(clearTimeout(S.current),m.current=!1,()=>{m.current||(S.current=setTimeout((()=>{t(Oe({id:i})),t(Q(ie)),t(We())}),0))})),[i,t]),r.useEffect((()=>{s&&t(ao({subscriptionId:i}))}),[s,i,t]);const I=r.useRef(!1);return r.useEffect((()=>{I.current||i!=null||u==null||u===""||v.customerId!==""||(I.current=!0,t(ee({id:i,localData:{...v,customerId:u}})))}),[u,i,v,t]),r.useEffect((()=>{if(d==="Completed"){const C=p??i,h=C!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(C)}`:`/${a}/invoicing/subscriptions`;e(h),t(Oe({id:i}))}}),[d,p,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionFormPage}),c.jsx(Ma,{keepDraftOnLeave:f,location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Ua=O((function(t){const e=qn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,s)=>{const u=e.subscriptions.find((d=>d.id===a));g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:o,amount:u?.mrr?.amount,customerId:u?.customerID,fromScreen:"subscriptions_list",status:u?.status,subscriptionId:a}),t(Hn({action:o,id:a,body:s}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const s=o?.trim()??"";s!==""&&i(a,"change_term_end",{term_ends_at:s})},onSubscriptionAction:(a,o,s)=>{o!=="pause"?i(a,o):i(a,o,s!=null&&s.trim()!==""?{resume_date:s.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"subscriptions",status:e.activeStatus}),t(ro({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Vt);function Ba(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,subscriptionListFetchState:h,runningActionSubscriptionId:y,subscriptions:D}=E((k=>{const j=qn(k);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,subscriptionListFetchState:j.fetchState,runningActionSubscriptionId:j.runningActionId??null,subscriptions:j.subscriptions}}),z),b=h==="Completed";r.useEffect((()=>{const k=setTimeout((()=>u(a)),300);return()=>clearTimeout(k)}),[a]),r.useEffect((()=>{i&&t($e({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t($e({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]);const A=r.useRef(y);return r.useEffect((()=>{const k=A.current!=null&&y==null;A.current=y,k&&i&&t(co())}),[y,i,t]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionsListPage,isReady:b}),c.jsx(Ua,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:k=>{t(so(k)),t($e({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Va=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{g.trackInvoicingActionClick(l.Event.invoicingTransactionCaptured,{transactionId:i}),t(go({action:"capture",id:i}))}:void 0}}))(Ht);function Ha(){const t=L(),e=$(),{tenantEmailDomain:n,transaction_id:i}=_(),{areTenantIdsInSync:a}=F(),o=E((u=>lo(u,i??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(uo({id:i}))}),[a,i,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingTransactionDetailPage,isReady:s}),c.jsx(Va,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function nt(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=L(),{areTenantIdsInSync:s}=F(),u=E(Ye),d=u.connection?.connected===!0,p=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&s&&(a&&p!=="Not-Started"||o(Qn()),n&&o(mo()))}),[s,o,e,n,a]),r.useEffect((()=>{e&&s&&d&&i&&o(vo())}),[s,o,e,d,i]),{isQboConnected:d,qboView:u}}const qa={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function re(t){const e=L(),{areTenantIdsInSync:n}=F(),{tenantEmailDomain:i}=_(),{fetchState:a,fieldHelp:o,logoFile:s,saveState:u,settings:d,stripeConnectState:p}=E(po),{configError:v,configFetchState:m,dunningScheduleActionOptions:f,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C}=E(zn),h=E(Ye);nt({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=E(Ce),D=t==="dunning"||t==="quickbooks",b=y.companyId??te.getSignedInUserTenant(i??"")?.companyId,A=E((P=>Ln(P,b))),k=fo(y.userRole??[]),j=y.tenantId??"",R=te.getSignedInUser(),U={userId:R?.userId??"",sessionId:R?.zeniSessionId??"",tenantId:j},T=s?.fileId,de=E((P=>T!=null&&T!==""?So(P,T):void 0)),Je=E((P=>T!=null&&T!==""?Io(P,T):void 0)),tt=T!=null&&T!==""&&de!=null?{[T]:de}:{},it=T!=null&&T!==""&&Je!=null?{[T]:Je}:{};r.useEffect((()=>(e(dn()),()=>{e(dn())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Ke()))}),[n,e,a]),r.useEffect((()=>{n&&D&&m==="Not-Started"&&e(ne())}),[n,e,m,D]),r.useEffect((()=>{if(!n)return;const P=R?.userId;P!=null&&P!==""&&j!==""&&en.shouldFetchActiveTenant(j)&&(en.markActiveTenantFetchStarted(j),e(ho(P,j,R?.zeniSessionId)))}),[n,e,R?.userId,R?.zeniSessionId,j]);const ot=f.length>0||S.length>0,at=a==="Not-Started"||a==="In-Progress"&&d==null||D&&!ot&&(m==="Not-Started"||m==="In-Progress"),ct=a==="Completed"&&(!D||m==="Completed"),Xe=A.externalConnections?.revenue?.find((P=>P.connectionName==="chargebee"))?.connectionId,ye=pe?.invoicingMicroServiceBaseUrl,Ze=ye!=null&&ye.length>0?`${ye}/1.0/webhooks/stripe`:"",J={deleteConnectionError:A.externalConnections?.deleteConnectionError?.message,deleteConnectionState:A.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:A,isAdmin:k,isStripeBusy:p.fetchState==="In-Progress",onConnectStripe:P=>{g.trackInvoicingActionClick(l.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(jo(P))},onDisconnect:(P,V)=>{j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingIntegrationDisconnected,{entity:V,entityId:P,fromScreen:t??"hub"}),e(Do(j,P,ln(V))))},onDisconnectStripe:()=>{g.trackInvoicingActionClick(l.Event.invoicingStripeDisconnected,{fromScreen:t??"hub"}),e(Ao())},onReconnectQBO:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:t??"hub"});const P=y.tenantEmailDomain??i??"";Ie.init("/connection/auth",P),Ie.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Wn()))},onSaveChargeBeeCredentials:(P,V)=>{Xe!=null&&j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(bo(j,Xe,ln("revenue"),xo("chargebee"),{api_key:P,site:V})))},saveChargeBeeError:A.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:A.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ze};return{authParams:U,deleteFileStatusById:tt,fieldHelp:o,dunningScheduleActionOptions:f,filesEndPoint:pe?.fileMicroServiceBaseUrl??"",integrationsSectionProps:J,isInvoicingPageReady:ct,isLoading:at,isSaving:u.fetchState==="In-Progress",isStripeBusy:p.fetchState==="In-Progress",logoFile:s,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C,qboView:h,saveErrorMessage:u.fetchState==="Error"?u.error?.message??"Failed to save settings.":D&&m==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ze,updateFileStatusById:it,onConnectStripe:J.onConnectStripe,onDeleteFile:P=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(yo(P,j))},onDisconnectStripe:J.onDisconnectStripe,onEditFileName:(P,V)=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(Eo(P,V.split(".")[0],j))},onReconnectQBO:J.onReconnectQBO,onRefreshQBO:J.onRefreshQBO,onRetryQboSyncTask:P=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:P,fromScreen:t??"hub"}),e(Gn(P))},onSave:P=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys(P).filter((V=>JSON.stringify(P[V])!==JSON.stringify(d?.[V]))),tab:t??"hub"}),e(ko({settings:P,snackbarSection:qa[t??""]}))},onStartQboBackfill:P=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Kn(P))},updateFilesEntity:P=>{g.trackInvoicingActionClick(l.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(Co({files:P}))}}}function mn({appContent:t}){const e=$(),n=ae(),i=L(),{tenantEmailDomain:a}=_(),o=re("branding"),s=E((d=>Lo(d)));r.useEffect((()=>{s.saveState.fetchState==="Completed"&&i($o())}),[s.saveState.fetchState,i]);const u=Ue(s.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&s.saveState.fetchState==="Completed"&&e("..")}),[u,s.saveState.fetchState,e]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(qt,{address:s.address,fieldHelp:s.fieldHelp,addressLabel:s.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:s.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:s.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:d=>{i(_o({localData:d}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"branding",fromScreen:"settings_branding"});const d=`/${a}/invoicing/settings/branding/${wo}/`,p=ce(n.state?.pathnameStackToGoBack,n.pathname);e(d,{state:{pathnameStackToGoBack:p}})},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{tab:"branding"}),i(Po())},updateFilesEntity:o.updateFilesEntity})]})}function Qa(){const t=$(),e=re("dunning");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Qt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function za(){const t=$(),e=re("integrations");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(zt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ka(){const t=$(),e=re("payment-destination");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Kt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Ga=["autoCreateItems","closedPeriodVoidAsCreditMemo","customerMatching","isSyncEnabled","syncStartDate","trackingCategoriesEnabled"],Wa=O((function(t){const e=Yn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,salesTaxPostingAccountName:e.salesTaxPostingAccountName,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(To({localData:e}))},onReset:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsReset,{tab:"quickbooks"}),t(Fo())},onRetryTask:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:e,fromScreen:"settings_qbo"}),t(Gn(e))},onStartBackfill:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:"settings_qbo"}),t(Kn(e))}}}))(Gt);function Ya(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),i=E(Ce),{configFetchState:a,localData:o,savedLocalData:s,saveState:u,settingsFetchState:d}=E(Yn),p=r.useMemo((()=>{return m=o,f=s,[...[...new Set([...Object.keys(m.accountIdByMappingCode),...Object.keys(f.accountIdByMappingCode)])].some((S=>(m.accountIdByMappingCode[S]??"")!==(f.accountIdByMappingCode[S]??"")))?["account_mappings"]:[],...Ga.filter((S=>m[S]!==f[S]))];var m,f}),[o,s]),v=Ue(u.fetchState);return r.useEffect((()=>{v==="In-Progress"&&u.fetchState==="Completed"&&e("..")}),[e,v,u.fetchState]),r.useEffect((()=>{d!=="Not-Started"&&d!=="Error"||t(Ke())}),[t,d]),r.useEffect((()=>{a==="Not-Started"&&t(ne())}),[a,t]),nt({fetchSyncHealth:!0,loadAccountingPickers:!0}),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingQboSettingsPage}),c.jsx(Wa,{onBackClick:()=>e(".."),onReconnect:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:"settings_qbo"}),Ie.init("/connection/auth",i.tenantEmailDomain??n??""),Ie.handleClick()},onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:"settings_qbo"}),t(Wn())},onSave:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:p,tab:"quickbooks"}),t(Ro())}})]})}const Ja={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Xa(){const t=pn(),e=L(),n=$(),[i,a]=oe(),o=re(),{canEnableInvoicing:s,isEnablingInvoicing:u,isInvoicingEnabled:d,isQboConfigured:p,isStripeConnected:v}=E(zn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const f=Ja[m];a({},{replace:!0}),f!=null&&n(f,{replace:!0})}),[m,n,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Wt,{analytics:g,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:u,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:s,isQboConfigured:p,isStripePaymentsReady:v,onEnableInvoicingClick:d?void 0:()=>{g.trackInvoicingActionClick(l.Event.invoicingEnableClicked),e(Oo())}})]})}function vn(){return c.jsxs(ge,{children:[c.jsx(x,{index:!0,element:c.jsx(Xa,{})}),c.jsx(x,{path:"payment-destination",element:c.jsx(Ka,{})}),c.jsx(x,{path:"branding",element:c.jsx(mn,{})}),c.jsx(x,{path:"branding/:addressType",element:c.jsx(mn,{appContent:c.jsx(X,{isSubPage:!0,hideAddressBackButton:!0})})}),c.jsx(x,{path:"integrations",element:c.jsx(za,{})}),c.jsx(x,{path:"dunning",element:c.jsx(Qa,{})}),c.jsx(x,{path:"quickbooks",element:c.jsx(Ya,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:"..",replace:!0})})]})}function Ac(){const t=L(),e=$(),{tenantEmailDomain:n}=_(),{areTenantIdsInSync:i}=F(),{enableState:a,fetchState:o,status:s}=E(Tn),u=Ue(a.fetchState),d=`/${n}/invoicing`,p=r.useRef(!1),v=E((m=>Ye(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||p.current||(p.current=!0,t(ne({cacheOverride:!1}))):t(ne({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&v==="Not-Started"&&t(Qn())}),[i,t,v]),r.useEffect((()=>{u==="In-Progress"&&a.fetchState==="Completed"&&(e(`${d}/catalog`),t(Mo()))}),[u,a.fetchState,d,t,e]),s!=null||o==="Error"&&p.current?s==null?c.jsx(Jt,{onGoHome:()=>e(`/${n??""}`),onReload:()=>t(ne({cacheOverride:!0}))}):s==="not_started"?c.jsxs(ge,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/promo`,replace:!0})})]}):s==="settings"?c.jsxs(ge,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/settings`,replace:!0})})]}):c.jsxs(ge,{children:[c.jsx(x,{path:"/",element:c.jsx(H,{to:"overview",replace:!0})}),c.jsx(x,{path:"overview",element:c.jsx(wa,{})}),c.jsx(x,{path:"promo",element:c.jsx(H,{to:`${d}/overview`,replace:!0})}),c.jsx(x,{path:"customers",element:c.jsx(la,{})}),c.jsx(x,{path:"customers/new",element:c.jsx(ra,{})}),c.jsx(x,{path:"customers/new/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"customers/:customer_id",element:c.jsx(ca,{})}),c.jsx(x,{path:"customers/:customer_id/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"subscriptions",element:c.jsx(Ba,{})}),c.jsx(x,{path:"subscriptions/new",element:c.jsx(Na,{})}),c.jsx(x,{path:"subscriptions/new/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"subscriptions/:subscription_id",element:c.jsx(Oa,{})}),c.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"invoices",element:c.jsx(ja,{})}),c.jsx(x,{path:"invoices/create",element:c.jsx(ea,{})}),c.jsx(x,{path:"invoices/:invoice_id",element:c.jsx(Aa,{})}),c.jsx(x,{path:"invoices/:invoice_id/record-payment",element:c.jsx(gn,{})}),c.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:c.jsx($a,{})}),c.jsx(x,{path:"payments",element:c.jsx(Ra,{})}),c.jsx(x,{path:"payments/record",element:c.jsx(gn,{})}),c.jsx(x,{path:"payments/:transaction_id",element:c.jsx(Ha,{})}),c.jsx(x,{path:"credits",element:c.jsx(oa,{})}),c.jsx(x,{path:"credits/:credit_note_id",element:c.jsx(ta,{})}),c.jsx(x,{path:"discounts",element:c.jsx(Ca,{})}),c.jsx(x,{path:"discounts/new",element:c.jsx(Xo,{})}),c.jsx(x,{path:"discounts/:coupon_id",element:c.jsx(Ia,{})}),c.jsx(x,{path:"dunning",element:c.jsx(ba,{})}),c.jsx(x,{path:"dunning/:case_id",element:c.jsx(Ea,{})}),c.jsx(x,{path:"catalog",element:c.jsx(Yo,{})}),c.jsx(x,{path:"catalog/new",element:c.jsx(Ko,{})}),c.jsx(x,{path:"catalog/:item_id",element:c.jsx(Ho,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"audit_log",element:c.jsx(Uo,{})}),c.jsx(x,{path:"data_import",element:c.jsx(va,{})}),c.jsx(x,{path:"data_import/migrate",element:c.jsx(fa,{})}),c.jsx(x,{path:"data_import/:sessionId",element:c.jsx(ga,{})}),c.jsx(x,{path:"*",element:c.jsx(M,{})})]}):c.jsx(Yt,{fetchState:"In-Progress"})}export{Ac as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as a}from"./liveblocks-
|
|
1
|
+
import{j as a}from"./liveblocks-CzEOPLmF.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-DKqX1MvM.js";import{Vb as k,Vc as v,Vd as V,J$ as D,JN as T,Ve as B,Vf as oe,Vg as ie,JR as se,gl as $,JY as le,JV as re}from"./zeni-epic-state-4S4FDL12.js";import{$ as x,J as r,a0 as de,k as j,X as J,a1 as ce,a2 as me,a3 as pe,p as G,c as ue,F as he,a4 as ge,U as xe,g as fe,a5 as be,a6 as we,Z as Se,a7 as ye,a8 as ke,a9 as ve,aa as je}from"./index-VO1FF9fC.js";import{n as m,u as $e}from"./mui-Bhz49yKC.js";import f from"./NotFoundScreen-C75AzqPX.js";import{a as I}from"./sentry-9QW1WlhM.js";import"./recharts-zD9lBvAv.js";import"./analytics-BkXKjaSH.js";import"./plaid-Bs1vGF7f.js";import"./dnd-CTBYmQk9.js";import"./stripe-cKAAJElX.js";import"./lottie-ByL7llpj.js";import"./lexical-BBNKXOAq.js";import"./pdf-DKcIxepG.js";import"./utils-Ciaf9ZZY.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]="cb365982-b3ea-4a21-bbb0-96e50d62fa2f",e._sentryDebugIdIdentifier="sentry-dbid-cb365982-b3ea-4a21-bbb0-96e50d62fa2f")}catch{}})();const Ie=m.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
height: 100%;
|
|
4
4
|
width: 100%;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as u}from"./liveblocks-
|
|
1
|
+
import{j as u}from"./liveblocks-CzEOPLmF.js";import{a as g}from"./sentry-9QW1WlhM.js";import{u as F,g as _,h as O,t as w,j as l,N as T}from"./core-DKqX1MvM.js";import{z as r,G as M,Q as P,k as A,R as N,Y as G,Z as R,T as Y}from"./index-VO1FF9fC.js";import{fI as Q,UG as W,V7 as Z,U_ as $,gl as q,gn as B,V3 as H,gY as J,dl as K,V8 as X,V9 as ee}from"./zeni-epic-state-4S4FDL12.js";import{u as te,n as ne}from"./mui-Bhz49yKC.js";import{u as se}from"./useDeviceId-DnWM1QX-.js";import{f as ae}from"./analyticsHelper-D5oPBeHb.js";import{t as ie}from"./getLocaleForTenant-DXE0mqRD.js";import"./recharts-zD9lBvAv.js";import"./analytics-BkXKjaSH.js";import"./plaid-Bs1vGF7f.js";import"./dnd-CTBYmQk9.js";import"./stripe-cKAAJElX.js";import"./lottie-ByL7llpj.js";import"./lexical-BBNKXOAq.js";import"./pdf-DKcIxepG.js";import"./utils-Ciaf9ZZY.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="0a8e16eb-22bd-4050-8330-25b60909f54a",t._sentryDebugIdIdentifier="sentry-dbid-0a8e16eb-22bd-4050-8330-25b60909f54a")}catch{}})();const D=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function De(){const t=F(),a=_(),f=O(),[k]=w(),n=k.get("token"),p=k.get("stytch_token_type"),m=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:x,magicLinkEmail:c,verifyDeviceFetchState:z,resendVerifyDeviceOTPFetchState:C}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),y=l((e=>e.tenantState.activeTenantFetchState.fetchState)),I=l((e=>e.tenantState.signInState)),h=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),s=l((e=>e.tenantState.loggedInUser)),o=l((e=>Q(e))),b=l((e=>W(e))),E=r.getSignedInUser(),v=te().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&D(n,p)&&i!=null&&m!=null&&(r.saveMagicLinkTriggered(n),t(Z(n,i,m)))}),[n,p,t,i,m,s?.zeniSessionId]),g.useEffect((()=>{I!=="In-Progress"||S!=="Completed"&&y!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants($(b.tenantsInOrder),s.zeniSessionId),q(s.userId,s.zeniSessionId,o.tenantId),t(B(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(H("Completed")),M.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,b.tenantsInOrder),J().then((()=>{const e=Y();e!=null&&P(e)})),setTimeout((()=>{A.trackLogin(N.Event.loginSuccess,"email",K(o.productSettings))}),2e3))}),[I,S,y,s,o,b,v,a.state,t]);const U=g.useCallback((()=>{f("/signin/auth")}),[f]),V=g.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(X(i,c,d))}),[i,d,t,c]),j=g.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(ee(e,i,c,d))}),[i,n,t,c,d]);if(h==="Completed"&&d!=null)return u.jsx(G,{phoneNumber:x,verifyOtpFetchState:z.fetchState,resendVerifyDeviceOTPFetchState:C,onResendOtp:V,onVerifyOtp:j,onCancelVerifyDevice:U});if(I==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||E!=null){const e=a.state?.origin??"/";return u.jsx(T,{to:e,state:{...a.state,origin:""}})}if(!D(n,p)||m==null||h==="Error"){const e=a.state?.origin??"/",L=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(T,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:L,magicLinkExpired:!L&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(R,{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-
|
|
1
|
+
import{j as D}from"./liveblocks-CzEOPLmF.js";import{a as f}from"./sentry-9QW1WlhM.js";import{u as te,j as t,i as Ue,g as $e,h as Ge,q as F}from"./core-DKqX1MvM.js";import{fI as ne,UH as Me,UI as se,gc as xe,fH as Ne,UR as Re,UK as Pe,UL as Ve,q3 as Le,gp as Oe,UO as b,UT as je,UU as J,gq as He,UV as Ze,ED as qe,h5 as ze,cX as Ke,UW as We,gb as Ye,gr as Xe}from"./zeni-epic-state-4S4FDL12.js";import{w as Je,i as Qe,U as ea,c as aa,d as ta,g as na,u as sa,F as c,h as oa,f as ia,z as ra,e as da,l as ca,n as la,x as ua,o as fa,q as Q,L as ma,H as ha,I as ba,p as S,k as ee,B as pa,K as ae,D as ga,E as Sa}from"./index-VO1FF9fC.js";import{D as Ea}from"./mui-Bhz49yKC.js";import{u as ka}from"./InboxNotificationsProvider-NVGRbeaR.js";import{u as Ca}from"./useTaskManagerAccess-CZsCSMny.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]="aebc5265-5ec4-42f3-8655-4abe81afda54",l._sentryDebugIdIdentifier="sentry-dbid-aebc5265-5ec4-42f3-8655-4abe81afda54")}catch{}})();const Ta=Je((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=Ue(),a=$e(),E=ea(),n=Ge(),B=xe(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:k}=Ca(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,U=t((e=>Ne(e))),{status:ie}=t(Re),$=U.uiState.currentChatSessionId,C=na(),{setLoading:re}=sa(),[w,G]=f.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,M=F("/:tenantEmailDomain/reports")!==null,m=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:x}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,x),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),N=t((e=>Pe(e))),{isFeatureEnabled:T}=d(c.isReferralFeatureEnabled),v=t((e=>Ve(e)));f.useEffect((()=>{C&&T&&!m&&v.fetchState==="Not-Started"&&r(Le(!0))}),[C,T,v.fetchState,m]);const _=t((e=>e.tenantState)),fe=t((e=>_.fetchState==="Completed"?Oe(e):[])),g=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:me}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),R=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Ee=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>b(e).totalUnreadCount)),Ce=t((e=>b(e).reducedFetchCountState)),P=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),V=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),L=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:O,isLoading:j,isFetchingMore:H,hasFetchedAll:Z,fetchMore:Te}=ka();f.useEffect((()=>{const e=setTimeout((()=>Te?.()),0);return()=>clearTimeout(e)})),f.useEffect((()=>{if(j===!1&&H===!1&&Z===!0)if(o?.companyId!=null&&O!=null){const e=`dashboard_${o.companyId}`;G(O.filter((u=>u.roomId===e&&u.readAt==null)).length)}else G(0)}),[j,H,Z]),f.useEffect((()=>{C&&k&&!m&&L.fetchState==="Not-Started"&&B.tenantId!=null&&r(je("task_manager","dashboard"))}),[C,k,m,L.fetchState,B.tenantId,r]),f.useEffect((()=>{m||I.fetchState!=="Not-Started"||r(J({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[m,I.fetchState,r]),f.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(J({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ce,count:ke},q=s!=null?ra.getSignedInUserTenant(s):null,z=t((e=>q?.tenantId!=null?He(e,q.tenantId):void 0)),h=[];me===!1&&h.push("accounts_payable_aging"),he===!1&&h.push("accounts_receivable_aging"),h.push("zeni_accounts_promo_card","treasury_promo_card"),T===!1&&h.push("rewards_card"),R===!1&&h.push("expense_automation_card");const K=t((e=>Ze(e,h).fetchState)),W=t((e=>qe(e).fetchState)),ye=A&&(K==="Completed"||K==="Error")||M&&(W==="Completed"||W==="Error")||!A&&!M?void 0:"disabled",we=f.useMemo((()=>ze(o.userRole)),[o.userRole]),Ae=Ke(we),ve=o?.rewardsLastViewedTime==null,_e=p?.userEmail!=null&&N.fetchState==="Completed"&&We(N.notificationSettings,p.userEmail,x,o,k),Y=da(),Fe=Y&&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"?fe:z!=null?[z]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:Q(a),isInvoicing:fa(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Ee,isNotificationsTabVisible:_e,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:R,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:T,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:Y,onNotificationIconClick:()=>{i(!1);let e=P===0&&V>0?"notifications/comments":"notifications/tasks";Q(a)&&(e=P===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",$??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),X=e.type,De=ae(X)&&X!=="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)?($!=null&&r(Xe()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Be}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})},handleMyProfileClick:()=>{i(!1),n(`/${s}/settings/my_profile`)},handleReferralsClick:()=>{i(!1),n(`/${s}/rewards`)},handleBackClick:()=>{n(`/${s}/dashboard`)},handleTenantSelect:e=>{re(ma.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{E.toggle()},isAiCfo:Fe,aiCfoView:U,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Ye({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)=>{Qe(n)&&Me(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return D.jsx(Ta,{...l,...a})};export{Ba as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./liveblocks-CzEOPLmF.js";import{h as r,l as i}from"./core-DKqX1MvM.js";import{ak as n}from"./index-VO1FF9fC.js";import"./mui-Bhz49yKC.js";import"./sentry-9QW1WlhM.js";import"./zeni-epic-state-4S4FDL12.js";import"./recharts-zD9lBvAv.js";import"./analytics-BkXKjaSH.js";import"./plaid-Bs1vGF7f.js";import"./dnd-CTBYmQk9.js";import"./stripe-cKAAJElX.js";import"./lottie-ByL7llpj.js";import"./lexical-BBNKXOAq.js";import"./pdf-DKcIxepG.js";import"./utils-Ciaf9ZZY.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new o.Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="e1fe4b0b-a509-4443-892f-577d1dfd5036",o._sentryDebugIdIdentifier="sentry-dbid-e1fe4b0b-a509-4443-892f-577d1dfd5036")}catch{}})();const a=i(null,(function(o,t){return{onGoBack:()=>{t.navigate(-1)},onGoHome:()=>{t.navigate("/")}}}))(n);function _(){const o=r();return e.jsx(a,{navigate:o})}export{_ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-
|
|
1
|
+
import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-CzEOPLmF.js";import ut from"./NotFoundScreen-C75AzqPX.js";import{a as k}from"./sentry-9QW1WlhM.js";import{h as ht,g as pt,i as kt,u as gt,j as b,l as bt,n as St,o as K}from"./core-DKqX1MvM.js";import{cC as It,UK as Y,fI as z,h5 as Tt,UO as S,a1S as J,UU as m,UI as y,AO as j,GB as Ct,a1T as At,UH as yt,UW as Et,AT as _t,a1U as F,br as $,gk as w,AX as Q,a1V as Nt,cO as Bt,cH as Ut}from"./zeni-epic-state-4S4FDL12.js";import{ao as wt,d as xt,c as vt,F as Dt,aq as Rt,dL as Gt,p as B,dM as Pt,w as Mt,dN as Ft,i as $t,a2 as jt}from"./index-VO1FF9fC.js";import"./mui-Bhz49yKC.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-CKCM0miP.js";import{u as Lt}from"./useTaskManagerAccess-CZsCSMny.js";import"./recharts-zD9lBvAv.js";import"./analytics-BkXKjaSH.js";import"./plaid-Bs1vGF7f.js";import"./dnd-CTBYmQk9.js";import"./stripe-cKAAJElX.js";import"./lottie-ByL7llpj.js";import"./lexical-BBNKXOAq.js";import"./pdf-DKcIxepG.js";import"./utils-Ciaf9ZZY.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]="9e5cb6c1-006a-41da-96aa-ebf9282bb224",t._sentryDebugIdIdentifier="sentry-dbid-9e5cb6c1-006a-41da-96aa-ebf9282bb224")}catch{}})();const Ot=(t,l)=>new Promise(((n,h)=>{const g=t.map((c=>new Promise((o=>{l(c),o()}))));Promise.all(g).then((()=>{setTimeout((()=>{n()}),2e3)})).catch((c=>{h(c)}))})),qt=bt((function(t,l){const n=Y(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=S(t),f=z(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:(e,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}d==="unread"&&t(Q("task_manager","read",[e],!1))},onCommentNotificationClick:(e,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(I(e),t(F([e],$())));let i=`/${h}/${r[1]}`;const T=B(n.state?.pathnameStackToGoBack,n.pathname);r[1].startsWith("reimbursement")&&!Bt(g)&&(i="not-found"),r[1].startsWith("bill")&&!Ut(g)&&(i="not-found"),f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(e,s)=>{t(y(e,s))},onUpdateNotificationTabState:(e,s)=>{t(m(e,s))},onUpdateNotificationViewCurrentTabAndSubTab:(e,s)=>{t(J(e,s));const d=`../${e}`,r=B(n.state?.pathnameStackToGoBack,n.pathname);f(d,{state:{pathnameStackToGoBack:r}})},onUpdateNotificationViewSubTab:e=>{t(Nt(e))},onFetchMoreNotifications:(e,s)=>{if(e==="tasks"){const d=[];s==="all"?d.push("read","unread"):s!=="mentions"&&d.push(s),t(j("task_manager","dashboard",d))}else v?.()},onUpdateNotificationStatus:(e,s,d,r)=>{e==="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(F([i],$())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(y({unreadCount:c-r.length>0?c-r.length:0},"comments")),t(w({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))}),(i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(w({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})).catch((i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(w({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onMarkAllNotificationsAsRead:e=>{e==="tasks"?t(_t("task_manager","read")):(t(m({markAsAllReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Ot(o,I).then((()=>{t(F(o,$())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(y({unreadCount:0},"comments")),t(w({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))})).catch((s=>{t(m({markAsAllReadState:{fetchState:"Error",error:s}},"comments")),t(w({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onBackClick:()=>{const e=jt(n.state?.pathnameStackToGoBack),s=e.poppedPathname??"../../dashboard";f(s,{state:{pathnameStackToGoBack:e.newStack}})},onSettingsClick:()=>{const e=B(n.state?.pathnameStackToGoBack,n.pathname);f("../../settings/notifications",{state:{pathnameStackToGoBack:e}})}}}))(Mt(Ft)),Wt=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=wt(),c=It(h??""),o=gt(),f=xt(),[I,v]=k.useState(!1),e=b((a=>Y(a))),s=b((a=>z(a))),{useFeatureGate:d}=vt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Rt({isDataReady:!0});const Z=Tt(s.userRole);if(s==null||n==null||s.companyId==null)throw Error("Can't access notifications page without current tenant...");if(f==null)throw Error("Can't access notifications page without signed in...");const V=b((a=>S(a).notificationDetailsByTab.tasks.fetchState)),L=b((a=>S(a).currentTab)),D=b((a=>S(a).currentSubTab)),tt=b((a=>S(a).notificationDetailsByTab.comments.fetchCountState)),R=b((a=>S(a).notificationDetailsByTab.comments.fetchState)),at=b((a=>S(a).notificationDetailsByTab.comments.uiState.unreadCount)),et=b((a=>S(a).allExternalNotifications)).filter((a=>a.inboxNotification.readAt==null)).map((a=>a.inboxNotification.id)),st=Gt().allUsers,{inboxNotifications:U,isLoading:E,hasFetchedAll:C,isFetchingMore:G,fetchMore:ot}=mt(),{threads:O,isLoading:q,fetchMore:W,isFetchingMore:H,hasFetchedAll:X}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(L!==c&&c!=null&&o(J(c)),c==null){const a=`../${L}`,p=B(l.state?.pathnameStackToGoBack,l.pathname);t(a,{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&&U!=null){const a=`dashboard_${s.companyId}`,p=U.filter((A=>A.roomId===a&&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 a=setTimeout((()=>ot?.()),0);return()=>clearTimeout(a)}));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((()=>{e.fetchState!=="In-Progress"&&e.fetchState!=="Completed"&&I===!1&&(v(!0),o(Ct()))}),[e.fetchState]),k.useEffect((()=>{if(E===!1&&q===!1&&U!=null&&O!=null){const a=`dashboard_${s.companyId}`,p=U.filter((u=>u.roomId===a)).filter((u=>Pt(u.kind))),A=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const M=O.find((dt=>{return dt.id===((x=u).kind==="thread"?x.threadId:"subjectId"in x?x.subjectId:void 0);var x}));return M!=null?{inboxNotification:{...u,threadId:M.id},thread:M}:(H||X===!0||W==null||W(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(y({totalCount:_.length,unreadCount:A.length},"comments")),o(At(ct))}}),[E,G,H,C,X,q,U?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(a,p)=>{if($t(p)){const A=yt(p.mode);if(A==="dashboard"&&o(y({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];D==="all"?_.push("read","unread"):D!=="mentions"&&_.push(D),o(j("task_manager",A,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=Lt(f);return N.jsx(qt,{tenantEmailDomain:n,loggedInUserRoleMap:Z,signedInUser:f,externalNotificationsUnreadCount:at,location:l,navigate:t,isDebitCardFeatureEnabled:r,isTaskManagerAccessEnabled:rt,users:st,markInboxNotificationAsRead:it,allUnreadCommentsNotificationIds:et,isAiCfoAccessEnabled:i,onAskAiCfoClick:T,...nt})};function ma(){return N.jsxs(St,{children:[N.jsx(K,{path:"/:selectedTab",element:N.jsx(Wt,{})}),N.jsx(K,{path:"*",element:N.jsx(ut,{})})]})}export{ma as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as m}from"./liveblocks-
|
|
1
|
+
import{j as m}from"./liveblocks-CzEOPLmF.js";import{a as r}from"./sentry-9QW1WlhM.js";import{u as A,g as j,j as o,N as C}from"./core-DKqX1MvM.js";import{Vl as P,fI as V,gp as x,Vm as z,Vn as D,Vo as M,Vp as R,pW as k,U0 as L}from"./zeni-epic-state-4S4FDL12.js";import{z as h,af as I}from"./index-VO1FF9fC.js";import"./mui-Bhz49yKC.js";import"./recharts-zD9lBvAv.js";import"./analytics-BkXKjaSH.js";import"./plaid-Bs1vGF7f.js";import"./dnd-CTBYmQk9.js";import"./stripe-cKAAJElX.js";import"./lottie-ByL7llpj.js";import"./lexical-BBNKXOAq.js";import"./pdf-DKcIxepG.js";import"./utils-Ciaf9ZZY.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new n.Error().stack;s&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[s]="a2186d74-3437-4e2e-b827-ed9e4f4d0446",n._sentryDebugIdIdentifier="sentry-dbid-a2186d74-3437-4e2e-b827-ed9e4f4d0446")}catch{}})();function ee(){const n=A(),s=j(),{params:t,error:i}=r.useMemo((()=>P(s.search)),[s.search]),w=r.useMemo((()=>new URLSearchParams(s.search).get("client_name")??t?.clientId??"Unknown Application"),[s.search,t]),p=h.isSignedIn(),a=h.getSignedInUser(),f=o((e=>V(e))),l=o((e=>x(e))),d=o((e=>e.tenantState.fetchState)),y=o(z),v=o(D),u=o(M),[S,b]=r.useState(null),[E,U]=r.useState(null);r.useEffect((()=>{document.querySelector("#app-shell-loader")?.remove()}),[]),r.useEffect((()=>()=>{n(R())}),[n,s.search]),r.useEffect((()=>{i!=null&&console.warn("[OAuthConsent] invalid params:",i)}),[i]);const g=r.useRef(!1);r.useEffect((()=>{p&&a!=null&&!g.current&&(d!=="Not-Started"&&d!=="Error"||(g.current=!0,n(k(a.userId,a.zeniSessionId??void 0))))}),[p,a,d,n]),r.useEffect((()=>{u!=null&&u!==""&&(window.location.href=u)}),[u]);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]),c=S??_;return i!=null?m.jsx(I,{variant:"invalid_params",paramsError:i}):p?m.jsx(I,{variant:"signed_in",clientName:w,userEmail:a?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:c,onSelectTenant:b,approveError:E??v,isApproving:y==="In-Progress",showAllowButton:c!=null,onApprove:()=>{t!=null&&a!=null&&c!=null&&n(L(a.userId,a.zeniSessionId??void 0,c,t.clientId,t.redirectUri,t.codeChallenge,t.codeChallengeMethod,t.state,t.responseType))},onDeny:()=>{if(t!=null)try{const e=new URL(t.redirectUri);e.searchParams.set("error","access_denied"),e.searchParams.set("error_description","The user denied the request"),e.searchParams.set("state",t.state),window.location.href=e.toString()}catch{U("Unable to deny: redirect_uri is not a valid URL. Close this window or contact support.")}}}):m.jsx(C,{to:"/signin/auth",state:{origin:s.pathname+s.search},replace:!0})}export{ee as default};
|
package/dist/assets/{PandLWithForecastRoutes-BHXDuog4.js → PandLWithForecastRoutes-DZOk2Qlj.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./liveblocks-
|
|
1
|
+
import{j as n}from"./liveblocks-CzEOPLmF.js";import{h as G,u as Y,g as z,i as X,j as d,l as H,n as J,o as S}from"./core-DKqX1MvM.js";import{fI as v,Az as O,vc as K,We as w,v7 as T,bq as Q,c1 as Z,v8 as ee,Wf as ae,VX as C,ek as te,Es as se,Wg as oe,ER as re,e1 as ne,e0 as ce}from"./zeni-epic-state-4S4FDL12.js";import{ag as ie,z as le,ao as de,aq as me,V as fe,a6 as pe,k as M,aB as ue,p as he,c as ge,F as Fe}from"./index-VO1FF9fC.js";import"./mui-Bhz49yKC.js";import Ie from"./NotFoundScreen-C75AzqPX.js";import{F as be}from"./FeaturePreviewScreen-Ctjpdyze.js";import{a as g}from"./sentry-9QW1WlhM.js";import{u as Se}from"./useAskAiCfoHostNavButtonProps-CKCM0miP.js";import{u as Ce}from"./useInitialThreadRequest-BfeP-cDj.js";import{t as Te}from"./routePaths-BDzQ5Jh8.js";import{M as ye}from"./MobileAppDrawer-B2nfLEqA.js";import"./recharts-zD9lBvAv.js";import"./analytics-BkXKjaSH.js";import"./plaid-Bs1vGF7f.js";import"./dnd-CTBYmQk9.js";import"./stripe-cKAAJElX.js";import"./lottie-ByL7llpj.js";import"./lexical-BBNKXOAq.js";import"./pdf-DKcIxepG.js";import"./utils-Ciaf9ZZY.js";import"./InboxNotificationsProvider-NVGRbeaR.js";import"./useTaskManagerAccess-CZsCSMny.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]="6d7f0200-e23c-4859-ac26-39632ee6d669",s._sentryDebugIdIdentifier="sentry-dbid-6d7f0200-e23c-4859-ac26-39632ee6d669")}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})}},Ae=H((function(s){const e=ae(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:M}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(w(a,o)),e.isPandLReportFetched(a)||s(T(a)),y(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(re(a))},onForecastVsActualsCompareToggle:a=>{s(oe(a)),s(C({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(se(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=te(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=Te(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=he(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(C({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(C({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(ue);function U(){const s=ie(),e=G(),a=Y(),o=z(),{forecastId:r,tenantEmailDomain:c}=X(),[p,u]=g.useState(!1),[m,A]=g.useState(!1),F=le.getSignedInUser(),k=d((t=>v(t))),q=k.company?.companyInfo.firstMonthOfFY??1,i=d((t=>O(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),x=d((t=>t.profitAndLossState)),D=d((t=>t.reportUIOptionsState.selectedForecast)),j=t=>x.pandLByForecastID[t]!=null&&ee(t,x).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:I}=de();me({isDataReady:l});const{isAiCfoAccessEnabled:B,onAskAiCfoClick:W}=Se({mobileExploreReferrer:"Forecast"});g.useEffect((()=>{if(!p&&I)u(!0),l||a(K());else if(l&&!m){A(!0);const t=((f,P,R)=>P!=null?f.forecasts.findIndex((b=>b.id===P)):R!=null?f.forecasts.findIndex((b=>b.id===R)):f.forecasts.length>0?0:-1)(i,r,D?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=D?.index?(a(w(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)&&I&&a(T(i.forecasts[t].id))}}),[p,u,a,l,i,m,A,O,T,I]);const E=fe(),_=E?.loggedInUserRole!=null&&Q(E.loggedInUserRole),N=Ce(k?.companyId,{clearParams:l&&m}),[V,$]=g.useState(!1),h=new URL(s("forecast_pandl"));h.searchParams.set("firstname",F?.firstName??""),h.searchParams.set("lastname",F?.lastName??""),h.searchParams.set("email",F?.userEmail??"");const L=t=>{$(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(pe,{analytics:M,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(ye,{isAppContentDrawerOpen:V,handleDrawerToggle:L}),n.jsx(Ae,{firstMonthOfFY:q,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:j,meetingUrl:Z(h.toString()),hasTransactionAccess:_,isAiCfoAccessEnabled:B,onAskAiCfoClick:W,initialOpenThreadRequest:N,onClickMenuIcon:()=>{L(!0)}})]})}function Xe(){const s=d((c=>v(c))),{useFeatureGate:e}=ge(),{isFeatureEnabled:a}=e(Fe.isDebitCardFeatureEnabled),o=ne(a,s),r=ce(s);return o===!0||r===!0?n.jsx(be,{}):n.jsxs(J,{children:[n.jsx(S,{path:"/",element:n.jsx(U,{})}),n.jsx(S,{path:"/:forecastId",element:n.jsx(U,{})}),n.jsx(S,{path:"/:forecastId/*",element:n.jsx(Ie,{})})]})}export{Xe as default};
|