@zeniai/web-app-ui 5.3.51-dev → 5.3.52-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-Z-noj29C.js → AccountMappingScreen-CfjKXYvl.js} +2 -2
- package/dist/assets/{ActualMatchingMatchDetailScreen-DX30h_LR.js → ActualMatchingMatchDetailScreen-Ctlw5YXu.js} +1 -1
- package/dist/assets/AddressRoutes-DakZpUxU.js +1 -0
- package/dist/assets/{AddressScreen-DVZRYb6q.js → AddressScreen-dsCmoEfc.js} +2 -2
- package/dist/assets/{AiCfoScreen-CzHb-C0a.js → AiCfoScreen-1hhGcQPM.js} +1 -1
- package/dist/assets/{AppDrawer-P5Yq4elH.js → AppDrawer-QudxLZqd.js} +1 -1
- package/dist/assets/{BillPayApprovalRoutes-Ckj7qIG3.js → BillPayApprovalRoutes--p2o0UTq.js} +1 -1
- package/dist/assets/BillPayRoutes-BQ5naZy9.js +119 -0
- package/dist/assets/{BusinessVerificationPageScreen-DorF9wJm.js → BusinessVerificationPageScreen-fABxFj6p.js} +2 -2
- package/dist/assets/{CardsAiCfoScreen-DAVWTdRh.js → CardsAiCfoScreen-D7lfbMvU.js} +2 -2
- package/dist/assets/{ChargeCardRoutes-_seq6gak.js → ChargeCardRoutes-8okIr07w.js} +9 -9
- package/dist/assets/{CompanyPassportScreen-heZQuNGW.js → CompanyPassportScreen-DGlmYKZ8.js} +1 -1
- package/dist/assets/{ConnectionAuthScreen-CAbs1jqS.js → ConnectionAuthScreen-BkpK3Q9m.js} +2 -2
- package/dist/assets/CustomerOnboardingAuthScreen-CUL244kC.js +1 -0
- package/dist/assets/{CustomerOnboardingRoutes-B070sYq6.js → CustomerOnboardingRoutes-A9qZQBlL.js} +3 -3
- package/dist/assets/{DashboardRoutes-DIsM75u-.js → DashboardRoutes-monhFGcO.js} +3 -3
- package/dist/assets/{DefaultTenantHome-C2rq74c5.js → DefaultTenantHome-B4aMzjG6.js} +1 -1
- package/dist/assets/{DomesticWireDetailScreen-C66MIDqV.js → DomesticWireDetailScreen-DSnjP_Z5.js} +3 -3
- package/dist/assets/{DrawerScreen-BeG5NZLa.js → DrawerScreen-C728nU-t.js} +1 -1
- package/dist/assets/{EntityDetailRoutes-BH1gTNai.js → EntityDetailRoutes-Bn5UTAGi.js} +1 -1
- package/dist/assets/{ExpenseAutomationRoutes-BuGgZVE5.js → ExpenseAutomationRoutes-lJCxAksc.js} +1 -1
- package/dist/assets/FeaturePreviewScreen-BTcHNbYq.js +1 -0
- package/dist/assets/{HubSpotOAuthCallbackScreen-Cry2n_9T.js → HubSpotOAuthCallbackScreen-DeY4bk0n.js} +1 -1
- package/dist/assets/{InboxNotificationsProvider-DGF7zUT5.js → InboxNotificationsProvider-Bd8tLMl8.js} +1 -1
- package/dist/assets/{InvoicingRoutes-CjVz3D16.js → InvoicingRoutes-BFDQ_AF7.js} +1 -1
- package/dist/assets/{MagicLinkRoutes-FsL_pDsr.js → MagicLinkRoutes-CDa3T_71.js} +19 -19
- package/dist/assets/MagicLinkSignInScreen-DkY-AFQs.js +12 -0
- package/dist/assets/{MobileAppDrawer-3hdMdgHl.js → MobileAppDrawer-CZL1M8HC.js} +1 -1
- package/dist/assets/NotFoundScreen-rNwJ2-Qg.js +1 -0
- package/dist/assets/{NotificationRoutes-Ia_StQxO.js → NotificationRoutes-Dq1wMoB2.js} +1 -1
- package/dist/assets/{OAuthConsentScreen-ENkiOwVE.js → OAuthConsentScreen-QrzCNvCR.js} +1 -1
- package/dist/assets/PandLWithForecastRoutes-CGjGCsop.js +1 -0
- package/dist/assets/{PaymentLinkScreen-CLJWnz9d.js → PaymentLinkScreen-BYkX6g2m.js} +4 -4
- package/dist/assets/PeopleRoutes-BSwZbUJ-.js +22 -0
- package/dist/assets/PerformanceRoutes-Cr1pAdV3.js +1 -0
- package/dist/assets/{Preview-CL5JOwkW.js → Preview-Bt5Z89U4.js} +1 -1
- package/dist/assets/{QBOConnectionScreen-DmjyrlYE.js → QBOConnectionScreen-TrNoYiXG.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRoutes-CtpP2r7b.js → ReimbursementApprovalRoutes-C2OtR60a.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRuleDetailScreen-BBs9NH1t.js → ReimbursementApprovalRuleDetailScreen-BqumfK_F.js} +1 -1
- package/dist/assets/{ReimbursementRoutes-FUlKeO6E.js → ReimbursementRoutes-CPjQ0Aws.js} +1 -1
- package/dist/assets/{ReportsRoutes-BEEImGc5.js → ReportsRoutes-BbjIc2Jw.js} +1 -1
- package/dist/assets/RewardsRoutes-Ca33Xd5P.js +1 -0
- package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen--r68Mash.js → ScheduleDetailsPrepaidExpensesScreen-DETwY7pD.js} +4 -4
- package/dist/assets/ScreenRoutes-CiAckpHg.js +2 -0
- package/dist/assets/{SettingsRoutes-89yhvrtM.js → SettingsRoutes-DwAkdZyX.js} +6 -6
- package/dist/assets/{SetupPagesScreen-CDlcHNSJ.js → SetupPagesScreen-Y9SYCogP.js} +1 -1
- package/dist/assets/SignInScreen-McvwseEQ.js +1 -0
- package/dist/assets/SignOutScreen-lXmArlao.js +9 -0
- package/dist/assets/{TaskListScreen-Ca08z5uM.js → TaskListScreen-CZxRWWOz.js} +2 -2
- package/dist/assets/{TaskRoutes-CystW5mI.js → TaskRoutes-q7JoPp0N.js} +2 -2
- package/dist/assets/TransactionDetailRoutes-ZlWD_PWX.js +1 -0
- package/dist/assets/{TransactionDetailScreen-BJgGk4vk.js → TransactionDetailScreen-0HhiaPRe.js} +2 -2
- package/dist/assets/{TransactionListRoutes-BSWCSgmV.js → TransactionListRoutes-UQ_0OeeD.js} +1 -1
- package/dist/assets/{TreasuryRoutes-BM-7oNnZ.js → TreasuryRoutes-DKuwHbrg.js} +1 -1
- package/dist/assets/{VendorsRoutes-DhpExNly.js → VendorsRoutes-DXw2vvr4.js} +1 -1
- package/dist/assets/{WiseConfirmationScreen-B--eryvX.js → WiseConfirmationScreen-XQZz5N0L.js} +1 -1
- package/dist/assets/{ZeniAccountRoutes-AimNmFB1.js → ZeniAccountRoutes-BU1gb-LE.js} +1 -1
- package/dist/assets/{ZeniAccountStatementScreen-D6V8KkrS.js → ZeniAccountStatementScreen-CrkxN9K8.js} +1 -1
- package/dist/assets/{accountMappingHelper-3Hm_-9n-.js → accountMappingHelper-DQktkWkn.js} +1 -1
- package/dist/assets/{analytics-D_bfwrdA.js → analytics-GZ8dIY_c.js} +1 -1
- package/dist/assets/{analyticsHelper-CddHs7OT.js → analyticsHelper-B9ZU7ow3.js} +1 -1
- package/dist/assets/{core-C5ZG3tJS.js → core-DOBELRta.js} +1 -1
- package/dist/assets/{decodeURIComponentSafe-ukN1WN7f.js → decodeURIComponentSafe-DjVlhgki.js} +1 -1
- package/dist/assets/{dnd-C67Dx0fq.js → dnd-0MaFz9wL.js} +1 -1
- package/dist/assets/{empty-D8AdB3zX.js → empty-C3pt8GU3.js} +1 -1
- package/dist/assets/{empty-CytNejfB.js → empty-DsXUnWhI.js} +1 -1
- package/dist/assets/{emptyVideoElement-DRkRIcLt.js → emptyVideoElement-DObxt-h2.js} +1 -1
- package/dist/assets/{epic-Dij6qtSX.js → epic-BqUfEKD1.js} +1 -1
- package/dist/assets/{expenseAutomationHelper-TRaObTJj.js → expenseAutomationHelper-CRKfrxDD.js} +1 -1
- package/dist/assets/{getLocaleForTenant-CaacUyT4.js → getLocaleForTenant-Dfv4vBw9.js} +1 -1
- package/dist/assets/{index-BQn16-dp.js → index-1mAhqt2L.js} +1 -1
- package/dist/assets/{index-C-mLGw3d.js → index-BmFszw0H.js} +1 -1
- package/dist/assets/{index-DcQYDhNo.js → index-CXbL8CxL.js} +13154 -13154
- package/dist/assets/{index-BJSiEm2J.js → index-C_zqEcVM.js} +1 -1
- package/dist/assets/{index-GiMM0ckT.js → index-F4l7OCjI.js} +2 -2
- package/dist/assets/{index-BkMAt9Jn.js → index-JlXkO7-y.js} +1 -1
- package/dist/assets/{index-B7_eMJP9.js → index-px1SxWJw.js} +1 -1
- package/dist/assets/{index-BUVBGxEt.js → index-rIJ81ix1.js} +1 -1
- package/dist/assets/{lexical-BpFcNSrv.js → lexical-CAgOy6Q-.js} +1 -1
- package/dist/assets/{liveblocks-DsNaXx1Y.js → liveblocks-BPL36a6x.js} +1 -1
- package/dist/assets/{lottie-x1U_1T_X.js → lottie-38LSfraF.js} +1 -1
- package/dist/assets/{mui-BWEZqJM6.js → mui-wO6EIETx.js} +1 -1
- package/dist/assets/{pathToGoBack-Bx2jKiUl.js → pathToGoBack-BTiQNxwp.js} +1 -1
- package/dist/assets/{pdf-Da5t4yqS.js → pdf-B2N0erO1.js} +3 -3
- package/dist/assets/{pdf-lib-BkS3YoMW.js → pdf-lib-Ct6vdrHd.js} +1 -1
- package/dist/assets/{plaid-B_2YsVA4.js → plaid-C-eBmVPr.js} +1 -1
- package/dist/assets/{pusher-BHd7HOLE.js → pusher-Qt-2jBy4.js} +1 -1
- package/dist/assets/{react-CXAUR01O.js → react-9dynYr-j.js} +1 -1
- package/dist/assets/{react-BQz1q-qh.js → react-BogDsHCA.js} +1 -1
- package/dist/assets/{react-aer_dY1C.js → react-ByoUrZyD.js} +1 -1
- package/dist/assets/{react-CLpDx285.js → react-D0sfM7Iy.js} +1 -1
- package/dist/assets/{react-Cl3JZyLA.js → react-DSWUEYTa.js} +1 -1
- package/dist/assets/{react-CluwtJMc.js → react-ofgvrscL.js} +1 -1
- package/dist/assets/{recharts-Cbxp2ciV.js → recharts-Sp9X2zHo.js} +1 -1
- package/dist/assets/{routePaths-CK0hdDvv.js → routePaths-7schl7H2.js} +1 -1
- package/dist/assets/{sentry-D4qoEIco.js → sentry-_x3Yh1Jc.js} +1 -1
- package/dist/assets/{stripSplatSuffix-Ca96gi6n.js → stripSplatSuffix-bz-VGo3l.js} +1 -1
- package/dist/assets/{url-C1Mc-kLe.js → url-DBFa8kl5.js} +1 -1
- package/dist/assets/{url-rUBTkYeh.js → url-DW2CK7rX.js} +1 -1
- package/dist/assets/{useActualMatchingMatchDetail-B2otLn9e.js → useActualMatchingMatchDetail-BFtfLe4Y.js} +1 -1
- package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-DdUF__iY.js → useAiCfoDashboardSuggestedQuestionsChips-BdSnJq4D.js} +1 -1
- package/dist/assets/useAskAiCfoHostNavButtonProps-gnFsttzV.js +1 -0
- package/dist/assets/{useChargeCardPusherEvents-C7Th_zSY.js → useChargeCardPusherEvents-BHookjIG.js} +1 -1
- package/dist/assets/{useDeviceId-D51quroZ.js → useDeviceId-EJu2KjP1.js} +1 -1
- package/dist/assets/{useEmailConnectResultRefresh-DwAwhMvM.js → useEmailConnectResultRefresh-bvDRvnqZ.js} +1 -1
- package/dist/assets/{useInitialThreadRequest-eMzMoXzm.js → useInitialThreadRequest-TFVuVZA_.js} +1 -1
- package/dist/assets/{useTaskManagerAccess-C5N90dEy.js → useTaskManagerAccess-CiaMEBoG.js} +1 -1
- package/dist/assets/{utils-DBZ_QSme.js → utils-BU0XThgM.js} +1 -1
- package/dist/assets/{withTransactionSidePanel-_EtsUxtd.js → withTransactionSidePanel-BR8uip_B.js} +4 -4
- package/dist/assets/{zeni-epic-state-BcPOXb6_.js → zeni-epic-state-DXFYDM66.js} +3 -3
- package/dist/index.html +1 -1
- package/package.json +2 -2
- package/dist/assets/AddressRoutes-Dt1bxWU6.js +0 -1
- package/dist/assets/BillPayRoutes-D99xPk1k.js +0 -119
- package/dist/assets/CustomerOnboardingAuthScreen-eCRYYI-e.js +0 -1
- package/dist/assets/FeaturePreviewScreen-CTfF2kJg.js +0 -1
- package/dist/assets/MagicLinkSignInScreen-dWMA5rvs.js +0 -12
- package/dist/assets/NotFoundScreen-BrZDNi9u.js +0 -1
- package/dist/assets/PandLWithForecastRoutes-Ca9l165b.js +0 -1
- package/dist/assets/PeopleRoutes-BRgSPKLo.js +0 -22
- package/dist/assets/PerformanceRoutes-CSiIWS3d.js +0 -1
- package/dist/assets/RewardsRoutes-BjHgr-LO.js +0 -1
- package/dist/assets/ScreenRoutes-BQzMSFT2.js +0 -2
- package/dist/assets/SignInScreen-DIeWOvHk.js +0 -1
- package/dist/assets/SignOutScreen-wUiFAd90.js +0 -9
- package/dist/assets/TransactionDetailRoutes-DdQ9jI4d.js +0 -1
- package/dist/assets/useAskAiCfoHostNavButtonProps-ChLA2qVa.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as v}from"./liveblocks-
|
|
1
|
+
import{j as v}from"./liveblocks-BPL36a6x.js";import{a as u}from"./sentry-_x3Yh1Jc.js";import{u as y,j as b,l as w,g as A,N}from"./core-DOBELRta.js";import{TM as U,fF as _,gl as k,TN as L,pS as R,TO as z}from"./zeni-epic-state-DXFYDM66.js";import{u as O,z as f,L as C,t as I,G as j,b as $}from"./index-CXbL8CxL.js";import"./mui-wO6EIETx.js";import{t as P}from"./getLocaleForTenant-Dfv4vBw9.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="a8381dc1-57b3-4c40-8c27-a32d9a054992",t._sentryDebugIdIdentifier="sentry-dbid-a8381dc1-57b3-4c40-8c27-a32d9a054992")}catch{}})();const G=w((function(t){return{fetchState:t.tenantState.fetchState,activeTenantFetchState:t.tenantState.activeTenantFetchState.fetchState,currentTenant:_(t),tenantsInOrder:z(t).tenantsInOrder}}))((function({fetchState:t,activeTenantFetchState:s,currentTenant:o,tenantsInOrder:h}){const r=A(),p=new URLSearchParams(r.search);if(o==null||t!=="Completed"&&s!=="Completed")return null;{let m="";const n=h.map((l=>l.tenantEmailDomain)),i=r.state?.origin,a=r.state?.queryParams;let c=`../${o.tenantEmailDomain}`,d=null,e=!1,g=null,S=null;const T=E(r.pathname);if(T!=null)c=`../${o.tenantEmailDomain}/${T}`,m="comingFromV2UrlPath",T==="ai-cfo/explore"&&(d=p.get("question")?.replace(/^["']|["']$/g,"")??null,e=p.get("should_submit")==="true");else if(i!=null)if(n.reduce(((l,x)=>l||i.split("/").find((D=>D===x))!=null),!1))c=i,i.includes("ai-cfo")&&a!=null&&(g=a.aiCfoRef??null,S=a.aiCfoEmailRefId??null);else{const l=E(i);l!=null?(c=`../${o.tenantEmailDomain}/${l}`,m="comingFromV2UrlPath",l==="ai-cfo/explore"&&a!=null&&(a.aiCfoQuestion!=null&&(d=a.aiCfoQuestion),a.aiCfoShouldSubmit==="true"&&(e=!0))):console.warn("Don't have access to previous path tenant!")}const F=$(c,p);return v.jsx(N,{to:F,replace:!0,state:{...r.state,origin:"",message:m,aiCfoInitialQuestion:d,aiCfoShouldSubmit:e,aiCfoRef:g,aiCfoEmailRefId:S}})}}));function oe(){const t=y(),{setLoading:s,clearAllLoading:o}=O(),h=u.useRef(!1),r=u.useRef(!1),p=u.useRef(null),m=b((e=>U(e))),n=b((e=>e.tenantState.fetchState)),i=b((e=>e.tenantState.error)),a=b((e=>e.tenantState.activeTenantFetchState.fetchState)),c=b((e=>_(e))),d=f.getSignedInUser();return u.useLayoutEffect((()=>{const e=f.getActiveTenantForUser()?.tenantId??null;p.current!==e&&(p.current=e,h.current=!1,r.current=!1,s(C.TENANT_FETCHING)),!h.current||a!=="Completed"&&a!=="Error"||(h.current=!1),!r.current||n!=="Completed"&&n!=="Error"||(r.current=!1)}),[a,n]),u.useEffect((()=>{const e=f.getActiveTenantForUser()?.tenantId;h.current===!1&&d!=null&&e!=null&&I.shouldFetchActiveTenant(e)&&(h.current=!0,I.markActiveTenantFetchStarted(e),n==="Completed"||a!=="Not-Started"&&a!=="Error"||(s(C.TENANT_FETCHING),t(k(d.userId,e))))}),[n,a,d,t]),u.useEffect((()=>{const e=f.getSignedInUser(),g=f.getActiveTenantForUser()?.tenantId,S=g==null||a==="Completed"||a==="Error";r.current===!1&&e!=null&&S&&I.shouldFetchAllTenants()&&(r.current=!0,I.markAllTenantsFetchStarted(),(n==="Not-Started"||n==="Error"&&!L(i))&&t(R(e.userId)))}),[n,a,i,d,t]),u.useEffect((()=>{f.isSignedIn()&&n==="Completed"&&m.tenantsCoreDetailsInOrder.length>0&&(f.saveSignedInUserTenants(m.tenantsCoreDetailsInOrder),o())}),[m.tenantsCoreDetailsInOrder,n]),u.useEffect((()=>{!f.isSignedIn()||n!=="Completed"&&a!=="Completed"||c==null||(j.updateAppLocaleID(P(c)),o())}),[n,a,c]),v.jsx(G,{})}const Q=["dashboard/cash-balance","dashboard/card-balance","dashboard/operating-expenses","dashboard/revenue","dashboard/burn-rate","dashboard/cash-position","dashboard/top-expenses","dashboard/cash-in-cash-out","dashboard","reports","forecast","uncategorized-expense","uncategorized-income","missing-receipts","bills","cards/activate","cards","reimbursements","wise","checking","aicfo"],q={"dashboard/cash-balance":"dashboard/cash_balance","dashboard/card-balance":"dashboard/card_balance","dashboard/operating-expenses":"dashboard/operating_expenses","dashboard/revenue":"dashboard/revenue","dashboard/burn-rate":"dashboard/net_burn_or_income","dashboard/cash-position":"dashboard/cash_position","dashboard/top-expenses":"dashboard/top_expenses","dashboard/cash-in-cash-out":"dashboard/cash_in_cash_out",dashboard:"dashboard",reports:"reports",forecast:"forecast","uncategorized-expense":"transactions/uncategorized-expense","uncategorized-income":"transactions/uncategorized-income","missing-receipts":"transactions/missing-receipts",bills:"bills",reimbursements:"reimbursements","cards/activate":"cards/activate",cards:"cards",wise:"bills/wise/callback/link-account",checking:"checking",aicfo:"ai-cfo/explore"};function E(t){for(const s of Q)if(t.toLocaleLowerCase().includes(s))return q[s]}export{oe as default};
|
package/dist/assets/{DomesticWireDetailScreen-C66MIDqV.js → DomesticWireDetailScreen-DSnjP_Z5.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as l}from"./liveblocks-
|
|
1
|
+
import{j as l}from"./liveblocks-BPL36a6x.js";import{h as w,g as C,j as h,l as A,i as V}from"./core-DOBELRta.js";import{YK as k,YR as _,gG as K,gF as L,gE as W,kP as J,WJ as q,uK as M,fF as B,Yh as D,kN as F,YL as S,YU as T,kL as G,l6 as j}from"./zeni-epic-state-DXFYDM66.js";import{bN as Q,a2 as N,c as R,z as U,E as O,a5 as p,A as v,a8 as Y,bO as X,I as Z,bP as ee,p as te}from"./index-CXbL8CxL.js";import{n as z}from"./mui-wO6EIETx.js";import"./sentry-_x3Yh1Jc.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]="12684b64-3a02-4aaf-b98a-df298ca5efc3",e._sentryDebugIdIdentifier="sentry-dbid-12684b64-3a02-4aaf-b98a-df298ca5efc3")}catch{}})();const ae=A(null,(function(e,t){return{onSaveVendor:a=>{e(J(t.vendorId!==void 0?t.vendorId:void 0,t.billId,void 0,t.isExpressPayPage)),e(q("common")),a!=null&&e(M(a))},onGetOtp:a=>{e(W(a,"BillPayVendor"))},onResendOtp:a=>{e(L(a,"BillPayVendor"))},onVerifyOtp:(a,n)=>{e(K(a,n,"BillPayVendor"))},onVerifyOtpSuccess:(a,n,o)=>{e(_(a,n,o))}}}))(Q);function H({vendorId:e,billId:t,isExpressPayPage:a}){const n=w(),o=C(),s=h((r=>k(r,e)));return l.jsx(ae,{location:o,navigate:n,vendorId:e,billId:t,vendorViewDetails:s,isExpressPayPage:a??!1})}const ne=z.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
height: 100vh;
|
|
4
4
|
width: 100%;
|
|
@@ -6,7 +6,7 @@ import{j as l}from"./liveblocks-DsNaXx1Y.js";import{h as w,g as C,j as h,l as A,
|
|
|
6
6
|
flex-direction: column;
|
|
7
7
|
align-items: center;
|
|
8
8
|
background-color: ${e=>e.theme.colors.grey4};
|
|
9
|
-
`,oe=A((function(e,t){const{vendorId:a,billId:n}=t,o=k(e,a),s=D(e,t.isVendorRecommendationEnabled,t.isZeniAccountsFeatureEnabled,n);return{billId:n,isDisabled:o.bankAccountCreationState.fetchState==="In-Progress"?"readonly":void 0,vendorViewDetails:o,file:s.file,bankAccountContext:t.bankAccountContext}}),(function(e,t){const{navigate:a,location:n,vendorId:o}=t;return{onFetchBankName:s=>{e(j(s))},onSaveHandler:s=>{e(G(t.bankAccountContext,s,"standard",o))},onCancel:()=>{(()=>{const s=p(n.state?.pathnameStackToGoBack),r=s.poppedPathname??P();a(r,{state:{pathnameStackToGoBack:s.newStack}})})(),e(S())},onACHDetailsUpdated:s=>{const{bankAccountSection:r}=s;e(T({data:r}))},onBackClick:()=>{if(e(F({fetchState:"Not-Started"})),t.bankAccountContext==="express-pay")a("../",{relative:"path"});else{const s=p(t.location.state?.pathnameStackToGoBack),r=s.poppedPathname??P(0);t.navigate(r,{state:{pathnameStackToGoBack:s.newStack}})}e(S())}}}))(X);function fe({vendorIdParam:e,accountContext:t}){const a=w(),n=C(),o=N(),{vendorId:s,billId:r}=V(),d=e??s,{useFeatureGate:c}=R(),i=U.getSignedInUser(),b=h((u=>B(u))),g=O(),
|
|
9
|
+
`,oe=A((function(e,t){const{vendorId:a,billId:n}=t,o=k(e,a),s=D(e,t.isVendorRecommendationEnabled,t.isZeniAccountsFeatureEnabled,n);return{billId:n,isDisabled:o.bankAccountCreationState.fetchState==="In-Progress"?"readonly":void 0,vendorViewDetails:o,file:s.file,bankAccountContext:t.bankAccountContext}}),(function(e,t){const{navigate:a,location:n,vendorId:o}=t;return{onFetchBankName:s=>{e(j(s))},onSaveHandler:s=>{e(G(t.bankAccountContext,s,"standard",o))},onCancel:()=>{(()=>{const s=p(n.state?.pathnameStackToGoBack),r=s.poppedPathname??P();a(r,{state:{pathnameStackToGoBack:s.newStack}})})(),e(S())},onACHDetailsUpdated:s=>{const{bankAccountSection:r}=s;e(T({data:r}))},onBackClick:()=>{if(e(F({fetchState:"Not-Started"})),t.bankAccountContext==="express-pay")a("../",{relative:"path"});else{const s=p(t.location.state?.pathnameStackToGoBack),r=s.poppedPathname??P(0);t.navigate(r,{state:{pathnameStackToGoBack:s.newStack}})}e(S())}}}))(X);function fe({vendorIdParam:e,accountContext:t}){const a=w(),n=C(),o=N(),{vendorId:s,billId:r}=V(),d=e??s,{useFeatureGate:c}=R(),i=U.getSignedInUser(),b=h((u=>B(u))),g=O(),I=p(n.state?.pathnameStackToGoBack),f=t??(I.poppedPathname?.includes("vendor")===!0?"vendor":"billDetail"),m=h((u=>k(u,d))),{isFeatureEnabled:x}=c(v.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:y}=c(v.isDepositAccountsFeatureEnabled);if(i==null)throw Error("Can't access address page without signing in...");return f==="billDetail"&&m.editVendorState?.saveStatus.fetchState==="In-Progress"?l.jsx(Y,{fetchState:m.editVendorState?.saveStatus.fetchState??"Not-Started",style:{backgroundColor:g.colors.grey5}}):l.jsxs(ne,{windowSize:o,children:[l.jsx(H,{vendorId:d,billId:r}),l.jsx(oe,{location:n,navigate:a,billId:r,vendorId:d,currentTenant:b,bankAccountContext:f,isVendorRecommendationEnabled:x,isZeniAccountsFeatureEnabled:y})]})}const P=(e=2)=>{let t="../";for(let a=0;a<e;a++)t=`${t}../`;return t},me=(e,t,a)=>{let n=`/${e}/bill/${encodeURIComponent(t)}`;return a=="draft"&&(n+="/edit"),n},he=e=>`/${e}/bills`,ke=(e,t)=>{let a=`/${e}/bill`;return a=t!=null?a.concat(`/${t}/edit`):a.concat("/new"),a},E=(e,t,a,n)=>{let o=`/${e}/bill`;return o+=a!=null?`/${a}/edit/vendor`:"/new/vendor",o+=n!=null?`/${n}/edit/${t}`:`/create/${t}`,o};function Se(e,t,a){return E(e,"ach",t,a)}function ve(e,t,a){return E(e,"domestic",t,a)}function ge(e,t,a){return E(e,"international",t,a)}const se=(e,t,a)=>{let n=`/${e}/bill/`;return n=a!=null?n.concat(`${encodeURIComponent(a)}/${t}/`):n.concat(`new/${t}/`),n},ce=z.div`
|
|
10
10
|
display: flex;
|
|
11
11
|
height: 100vh;
|
|
12
12
|
width: 100%;
|
|
@@ -15,4 +15,4 @@ import{j as l}from"./liveblocks-DsNaXx1Y.js";import{h as w,g as C,j as h,l as A,
|
|
|
15
15
|
align-items: center;
|
|
16
16
|
background-color: ${e=>e.theme.colors.grey4};
|
|
17
17
|
box-shadow: ${e=>`0px 2px ${Z.sp1} ${e.theme.colors.dropShadowNormal}`};
|
|
18
|
-
`,re=A((function(e,t){const{vendorId:a,billId:n}=t,o=k(e,a),s=D(e,t.isVendorRecommendationEnabled,t.isZeniAccountsFeatureEnabled,n);return{billId:n,isDisabled:o.bankAccountCreationState.fetchState==="In-Progress"?"readonly":void 0,vendorViewDetails:o,file:s.file,bankAccountContext:t.bankAccountContext}}),(function(e,t){const{billId:a,navigate:n,location:o,vendorId:s,currentTenant:r}=t,{tenantEmailDomain:d}=r;return{onFetchBankName:c=>{e(j(c))},onSaveHandler:c=>{e(G(t.bankAccountContext,c,"us-domestic",s))},onWireDetailsUpdated:c=>{const{bankAccountSection:i}=c;e(T({data:i}))},onCancel:()=>{(()=>{const c=p(o.state?.pathnameStackToGoBack),i=c.poppedPathname??$();n(i,{state:{pathnameStackToGoBack:c.newStack}})})(),e(S())},onAddressClick:c=>{if(t.bankAccountContext==="express-pay")n("./add-address");else{const i=se(d,c,a),b=te(o.state?.pathnameStackToGoBack,o.pathname);n(i,{state:{pathnameStackToGoBack:b}})}},onBackClick:()=>{if(e(F({fetchState:"Not-Started"})),t.bankAccountContext==="express-pay")n("../",{relative:"path"});else{const c=p(t.location.state?.pathnameStackToGoBack),i=c.poppedPathname??$(0);t.navigate(i,{state:{pathnameStackToGoBack:c.newStack}})}e(S())}}}))(ee);function
|
|
18
|
+
`,re=A((function(e,t){const{vendorId:a,billId:n}=t,o=k(e,a),s=D(e,t.isVendorRecommendationEnabled,t.isZeniAccountsFeatureEnabled,n);return{billId:n,isDisabled:o.bankAccountCreationState.fetchState==="In-Progress"?"readonly":void 0,vendorViewDetails:o,file:s.file,bankAccountContext:t.bankAccountContext}}),(function(e,t){const{billId:a,navigate:n,location:o,vendorId:s,currentTenant:r}=t,{tenantEmailDomain:d}=r;return{onFetchBankName:c=>{e(j(c))},onSaveHandler:c=>{e(G(t.bankAccountContext,c,"us-domestic",s))},onWireDetailsUpdated:c=>{const{bankAccountSection:i}=c;e(T({data:i}))},onCancel:()=>{(()=>{const c=p(o.state?.pathnameStackToGoBack),i=c.poppedPathname??$();n(i,{state:{pathnameStackToGoBack:c.newStack}})})(),e(S())},onAddressClick:c=>{if(t.bankAccountContext==="express-pay")n("./add-address");else{const i=se(d,c,a),b=te(o.state?.pathnameStackToGoBack,o.pathname);n(i,{state:{pathnameStackToGoBack:b}})}},onBackClick:()=>{if(e(F({fetchState:"Not-Started"})),t.bankAccountContext==="express-pay")n("../",{relative:"path"});else{const c=p(t.location.state?.pathnameStackToGoBack),i=c.poppedPathname??$(0);t.navigate(i,{state:{pathnameStackToGoBack:c.newStack}})}e(S())}}}))(ee);function Ie({vendorIdParam:e,accountContext:t}){const a=w(),n=C(),o=N(),{vendorId:s,billId:r}=V(),d=e??s,c=U.getSignedInUser(),{useFeatureGate:i}=R(),b=O(),g=h((u=>B(u))),I=p(n.state?.pathnameStackToGoBack),f=t??(I.poppedPathname?.includes("vendor")===!0?"vendor":"billDetail"),m=h((u=>k(u,d))),{isFeatureEnabled:x}=i(v.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:y}=i(v.isDepositAccountsFeatureEnabled);if(c==null)throw Error("Can't access address page without signing in...");return f==="billDetail"&&m.editVendorState?.saveStatus.fetchState==="In-Progress"?l.jsx(Y,{fetchState:m.editVendorState?.saveStatus.fetchState??"Not-Started",style:{backgroundColor:b.colors.grey5,boxShadow:`0px 2px ${Z.sp1} ${b.colors.dropShadowNormal}`}}):l.jsxs(ce,{windowSize:o,children:[l.jsx(H,{vendorId:d,billId:r}),l.jsx(re,{location:n,navigate:a,billId:r,vendorId:d,currentTenant:g,bankAccountContext:f,isVendorRecommendationEnabled:x,isZeniAccountsFeatureEnabled:y})]})}const $=(e=2)=>{let t="../";for(let a=0;a<e;a++)t=`${t}../`;return t};export{fe as A,Ie as D,H as V,me as a,se as b,ke as c,ve as d,he as g,ge as i,Se as v};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as c}from"./liveblocks-
|
|
1
|
+
import{j as c}from"./liveblocks-BPL36a6x.js";import{a2 as d,ac as f,E as l}from"./index-CXbL8CxL.js";import{D as b}from"./mui-wO6EIETx.js";import"./sentry-_x3Yh1Jc.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="c4a1a051-122a-4bbe-9cb2-6f5c19e6b4ff",e._sentryDebugIdIdentifier="sentry-dbid-c4a1a051-122a-4bbe-9cb2-6f5c19e6b4ff")}catch{}})();const p={drawerLeftMargin:new f(0,0,240)};function h(e){const{isOpen:r,drawerLeftMargin:o,children:n,onClose:t}=e,a=d(),s=o?.valuePx(a)??p.drawerLeftMargin.valuePx(a),i=l();return c.jsx(b,{anchor:"right",open:r,PaperProps:{style:{width:`calc(100% - ${s})`}},slotProps:{backdrop:{style:{backgroundColor:i.colors.black,opacity:.8,cursor:"pointer"}}},onClose:t,children:n})}export{h as D};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./liveblocks-
|
|
1
|
+
import{j as s}from"./liveblocks-BPL36a6x.js";import{a as c}from"./sentry-_x3Yh1Jc.js";import{h as B,u as A,g as G,i as F,j as d,N,l as q,n as $,o as O}from"./core-DOBELRta.js";import{WN as _,fF as M,W3 as R,m$ as Y,S4 as k,WS as z,WI as J,l$ as K,S5 as P,W8 as V,W9 as H,WK as L,WJ as Q}from"./zeni-epic-state-DXFYDM66.js";import{b9 as U,k as X,a5 as Z,p as tt}from"./index-CXbL8CxL.js";import"./mui-wO6EIETx.js";import{d as b}from"./decodeURIComponentSafe-DjVlhgki.js";import{w as et}from"./withTransactionSidePanel-BR8uip_B.js";import{f as at,c as nt}from"./routePaths-7schl7H2.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";import"./useAskAiCfoHostNavButtonProps-gnFsttzV.js";import"./TransactionDetailScreen-0HhiaPRe.js";import"./useInitialThreadRequest-TFVuVZA_.js";import"./expenseAutomationHelper-CRKfrxDD.js";import"./stripSplatSuffix-bz-VGo3l.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="e08a97ac-9c8c-472a-9b50-5bd7334867cc",a._sentryDebugIdIdentifier="sentry-dbid-e08a97ac-9c8c-472a-9b50-5bd7334867cc")}catch{}})();const ot=q((function(a,t){const e=t.entity,o=z(a,t.entity,"EntityDetail");return{selectedEntity:e,autoCompleteData:{autoCompleteText:e.name,entityAutoCompleteView:J(a,"common")},trendWithTransactionsReport:o,analytics:X,isAccountingClassesEnabled:K(a)}}),(function(a,t){return{onTransactionItemClick:e=>{if(t.openTransactionPanel)return void t.openTransactionPanel(e.id,e.type);const o=`${nt(e,t.tenantEmailDomain)}`,l=tt(t.location.state?.pathnameStackToGoBack,t.location.pathname);t.navigate(o,{state:{pathnameStackToGoBack:l}})},autoCompleteActions:{onAutoCompleteInputChange:e=>{e.trim().length>=2?a(L({searchString:e,searchOrigin:"common"})):e.trim().length===0&&a(Q("common"))},onAutoCompleteEntity:e=>{const o=at(e,t.tenantEmailDomain);a(V()),a(H()),t.resetTrendIsFetchedStates(),t.navigate(o,{replace:!0,state:{pathnameStackToGoBack:t.location.state?.pathnameStackToGoBack}})},onCancelAutoComplete:()=>{const e=Z(t.location.state?.pathnameStackToGoBack),o=e.poppedPathname??I();t.navigate(o,{state:{pathnameStackToGoBack:e.newStack}})}},onTrendSelectedPeriodChange:e=>{if(t.closeSidePanel?.(),e==null)t.defaultTransactionTimePeriod!=null&&a(P(t.entity,"EntityDetail",{timeframe:"quarter",timePeriod:t.defaultTransactionTimePeriod}));else{const o=e.currentTimePeriod==null?e.addTimePeriod:{startDate:e.addTimePeriod.startDate,endDate:e.currentTimePeriod.endDate};a(k(t.entity,"EntityDetail",{timeframe:e.timeframe,timePeriod:e.addTimePeriod})),a(P(t.entity,"EntityDetail",{timeframe:e.timeframe,timePeriod:o}))}}}}))(U),it=et((function({entityType:a,...t}){const e=B(),o=A(),l=G(),[m,T]=c.useState(!1),[h,D]=c.useState(!1),{tenantEmailDomain:C,entityIdEncoded:W,entityNameEncoded:x}=F(),r=b(W??""),p=b(x??""),u=rt(r,p),j=[r,p].filter((n=>n!=null)),i={name:p,id:r,type:a,zeniId:r,qboId:r},g=d((n=>_(n.customerIncomeState,n.vendorExpenseState,n.trendState,i,"quarter"))),v=d((n=>M(n).company?.companyInfo.firstMonthOfFY??1)),f=d((n=>R(n.trendWithTransactionsState,i,"EntityDetail")));c.useEffect((()=>{m===!1&&u===!0&&(T(!0),o(Y(i)))}),[m,u,i]);const S=d((n=>n.trendState.fetchState)),E=f?.selectedPeriod?.timePeriod??g,w=(function(n,y){return n!=null&&y!=null?{startDate:n.startDate,endDate:y?.endDate}:y})(f?.selectedPeriod?.timePeriod,g);return c.useEffect((()=>{m===!0&&h===!1&&S==="Completed"&&(D(!0),E!=null&&o(k(i,"EntityDetail",{timeframe:f?.selectedPeriod?.timeframe??"quarter",timePeriod:E})))}),[m,h,S]),u?s.jsx(ot,{firstMonthOfFY:v,tenantEmailDomain:C,location:l,navigate:e,entity:i,defaultTransactionTimePeriod:w,resetTrendIsFetchedStates:()=>{T(!1),D(!1)},...t}):s.jsx(N,{to:I(j.length)})})),rt=(a,t)=>t!=null&&t.length>0&&a!=null&&a.length>0,I=(a=2)=>{let t="../";for(let e=0;e<a;e++)t=`${t}../`;return t};function vt({entityType:a}){return s.jsx($,{children:s.jsx(O,{path:"/:entityIdEncoded/:entityNameEncoded/*",element:s.jsx(it,{entityType:a})})})}export{vt as EntityDetailRoutes,vt as default};
|
package/dist/assets/{ExpenseAutomationRoutes-BuGgZVE5.js → ExpenseAutomationRoutes-lJCxAksc.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as b}from"./liveblocks-
|
|
1
|
+
import{j as b}from"./liveblocks-BPL36a6x.js";import{u as he,h as nt,g as be,j as _,i as Ue,t as Yn,l as Hn,n as Kn,o as He,N as Qn}from"./core-DOBELRta.js";import{fF as ke,a0U as Zn,q0 as _e,U3 as Xn,z$ as es,a0V as ts,a0W as as,a0X as ns,a0Y as gt,a0Z as Qe,gh as bt,a0_ as ca,eW as ss,g0 as os,a0$ as ia,a10 as Ze,qT as cs,uN as is,gS as ls,gQ as rs,a11 as ds,r4 as us,rd as ms,qb as ps,qp as wa,gP as re,gR as hs,a12 as Ss,qL as Ra,re as gs,qm as Cs,qh as fs,uT as Is,gO as Me,a13 as tt,C9 as Da,Mp as Fa,a14 as _a,Fs as Ma,a15 as ks,eZ as bs,e$ as Ts,sP as Tt,WO as la,WQ as Ps,m2 as ys,WR as vs,m9 as Es,dl as As,Ds as Pt,a16 as xs,a17 as ws,fm as yt,sD as ra,WI as Rs,a18 as Ds,a19 as Fs,mb as _s,a1a as Ms,R5 as Os,ma as Us,l$ as Bs,qE as Oa,rj as at,tp as Ua,tL as Vs,TV as Ba,ri as da,rl as Va,rn as js,bE as zs,ny as $s,nv as Ls,rm as Xe,rk as pe,a1b as Gs,rE as ua,a1c as Ns,a1d as qs,sH as Js,sI as Ws,WE as Ys,VK as Hs,a0m as Ks,a1e as Qs,WK as ma,WJ as Ke,a1f as pa,mq as Zs,a1g as Xs,a1h as eo,a1i as to,a1j as ao,qz as no,a1k as so,a1l as oo,a1m as co,ru as io,md as lo,m4 as ro,a1n as uo,mc as ha,W$ as mo,a1o as po,a1p as ho,uo as So,t$ as go,t_ as Ct,a1q as Co,a1r as fo,a1s as Io,a1t as ko,nJ as bo,br as To,nE as Sa,nq as Po,a1u as yo,g$ as vo,nB as Eo,sR as Ao,sT as xo,sA as wo,VN as Ro,VO as Do,EW as Fo,EV as _o,Fa as Mo,a1v as ga,sG as Oo,a1w as Uo,rU as Bo,r_ as Vo,s9 as jo,rX as zo,a1x as $o,s8 as Lo,sM as Go,a1y as No,sZ as qo,su as Jo,t2 as Wo,sz as Yo,rF as Ho,a1z as Ko,qX as Qo,qv as Zo,qC as Ca,rp as Xo,a1A as ec,a1B as tc,a1C as ac,a1D as nc,a1E as sc,a1F as oc,t6 as cc,a1G as ic,a1H as lc,a1I as fa,uz as rc,tS as dc,tH as Ia,tF as uc,a1J as mc,tu as pc,t9 as hc,tI as Sc,a1K as gc,a1L as Cc,tf as fc,a1M as Ic,ta as kc,te as bc,tc as Tc,tO as Pc}from"./zeni-epic-state-DXFYDM66.js";import ja from"./NotFoundScreen-rNwJ2-Qg.js";import{a as s,R as za}from"./sentry-_x3Yh1Jc.js";import{n as Te,S as yc}from"./mui-wO6EIETx.js";import{c as Be,A as H,k as Z,p as te,ar as $a,at as La,dP as vc,dQ as Ec,P as Ga,z as st,dR as Ac,dS as xc,dT as wc,af as Oe,dU as Rc,dV as ka,bb as ba,dW as Dc,a8 as Na,dX as Fc,j as et,a as _c,dY as Mc,dZ as Oc,R as Uc,N as Bc,d_ as Vc,d$ as jc,e0 as zc,b5 as $c,bs as Lc,ac as Gc,b6 as Nc,b7 as qc,G as Jc,w as Wc,e1 as Yc,aw as Ta,e2 as Hc}from"./index-CXbL8CxL.js";import{u as qa}from"./useAskAiCfoHostNavButtonProps-gnFsttzV.js";import{g as Pa,b as Kc,c as Qc,h as Zc,a as Xc,i as ei,r as ti,C as ai}from"./TransactionDetailScreen-0HhiaPRe.js";import{u as ni}from"./useActualMatchingMatchDetail-BFtfLe4Y.js";import{d as si}from"./decodeURIComponentSafe-DjVlhgki.js";import{m as Ja,a as Wa}from"./expenseAutomationHelper-CRKfrxDD.js";import{u as Ya,a as Ha,w as oi}from"./withTransactionSidePanel-BR8uip_B.js";import{b as ci,S as ii,a as li,J as ri}from"./ScheduleDetailsPrepaidExpensesScreen-DETwY7pD.js";import{s as ya,i as Ka,h as di,v as ui,c as mi}from"./routePaths-7schl7H2.js";import{a as ft}from"./accountMappingHelper-DQktkWkn.js";import{D as pi}from"./DrawerScreen-C728nU-t.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";import"./useInitialThreadRequest-TFVuVZA_.js";import"./stripSplatSuffix-bz-VGo3l.js";import"./pathToGoBack-BTiQNxwp.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new t.Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="918c0bd2-8b67-4a9e-8934-554bf3acfbdb",t._sentryDebugIdIdentifier="sentry-dbid-918c0bd2-8b67-4a9e-8934-554bf3acfbdb")}catch{}})();const hi=()=>{const t=he(),n=nt(),f=be(),I=_((C=>ke(C))),{useFeatureGate:k}=Be(),{isFeatureEnabled:o}=k(H.isRealtimeInsightsFeatureEnabled),{isFeatureEnabled:r}=k(H.aiAuditScorePercentage),E=_((C=>C.expenseAutomationViewState.selectedPeriodByTenantId)),l=_((C=>Zn(C,I.tenantId))),{isAiCfoAccessEnabled:S,onAskAiCfoClick:R}=qa({mobileExploreReferrer:"Month-End Close Overview"}),x=s.useCallback(((C,h,z=!1)=>{t(_e({tenantId:h,period:{month:C.month,year:C.year},refreshViewInBackground:z}))}),[]),m=s.useCallback((C=>{const h=f.state?.referrer;l.monthEndCloseChecks?.auditSummary!=null&&Z.trackMonthCloseAuditPage(C.month,C.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,h??null),t(Xn(I.tenantId,C))}),[I.tenantId,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),g=E[I.tenantId],u=s.useCallback((()=>{const C=f.state?.referrer;l.monthEndCloseChecks?.auditSummary!=null&&Z.trackMonthCloseAuditPage(g.month,g.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!0,C??null),x(g,I.tenantId,!0)}),[x,g,I.tenantId,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),F=te(f.state?.pathnameStackToGoBack,f.pathname),A=s.useCallback((()=>{if(l.monthEndCloseChecks!=null&&g!=null){const C=l.monthEndCloseChecks.monthEndCloseCheckList.find((h=>h.progress<100));if(C!=null)return void n(`./${C.id}/${g.month}-${g.year}`,{state:{pathnameStackToGoBack:F,message:"comingFromOverview"}});n(`./month_end_insights/${g.month}-${g.year}`,{state:{pathnameStackToGoBack:F,message:"comingFromOverview"}})}}),[l.monthEndCloseChecks,g]),{areTenantIdsInSync:p}=$a();return La({isDataReady:l.fetchState==="Completed"}),s.useEffect((()=>{g!=null&&l.fetchState!=="In-Progress"&&l.fetchState!=="Completed"&&p&&x(g,I.tenantId)}),[x,g,l.fetchState,I.tenantId,p]),s.useEffect((()=>{g!=null&&l.monthClosePerformanceTrendFetchStatus.fetchState!=="In-Progress"&&l.monthClosePerformanceTrendFetchStatus.fetchState!=="Completed"&&p&&t(es(g))}),[g,l.monthClosePerformanceTrendFetchStatus.fetchState,p]),s.useEffect((()=>{const C=setInterval((()=>{l.fetchState!=="In-Progress"&&l.fetchState==="Completed"&&u()}),3e5);return()=>clearInterval(C)}),[l.fetchState]),s.useEffect((()=>{if(l.fetchState==="Completed"&&l.monthEndCloseChecks?.auditSummary!=null){const C=f.state?.referrer;Z.trackMonthCloseAuditPage(l.selectedPeriod.month,l.selectedPeriod.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,C??null)}}),[l.fetchState,l.selectedPeriod,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),b.jsx(Si,{children:b.jsx(vc,{monthEndCloseChecksView:l,isRealtimeInsightsFeatureEnabled:o,onMonthEndCheckClick:C=>{n(`./${C}/${g.month}-${g.year}`,{state:{pathnameStackToGoBack:F,message:"comingFromOverview",referrer:"Expense Automation - Overview"}})},onPeriodChange:m,handleReviewButtonClick:A,onBackClick:()=>{n("../../dashboard")},onReload:u,isAiCfoAccessEnabled:S,onAskAiCfoClick:R,aiAuditScorePercentageEnabled:r})})},Si=Te.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
height: 100vh;
|
|
4
4
|
width: 100%;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as s}from"./liveblocks-BPL36a6x.js";import{a as r}from"./sentry-_x3Yh1Jc.js";import{ax as l,ay as p,Q as d,a5 as m}from"./index-CXbL8CxL.js";import"./mui-wO6EIETx.js";import c from"./NotFoundScreen-rNwJ2-Qg.js";import{h as b,g as u}from"./core-DOBELRta.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="3f3a789f-93b9-43ee-8795-e07bf9f6c81b",e._sentryDebugIdIdentifier="sentry-dbid-3f3a789f-93b9-43ee-8795-e07bf9f6c81b")}catch{}})();const _=()=>{const e=b(),a=u(),t=r.useCallback((()=>{window.open("https://www.zeni.ai/demo/request","_blank")}),[]),f=r.useCallback((()=>{(()=>{const n=m(a.state?.pathnameStackToGoBack),i=n.poppedPathname??k();e(i,{state:{pathnameStackToGoBack:n.newStack}})})()}),[]),o=l(a.pathname);return o!=null?s.jsx(p,{menuItem:d(o),onDemoClick:t,onGoBack:f}):s.jsx(c,{})},k=(e=2)=>{let a="../";for(let t=0;t<e;t++)a=`${a}../`;return a};export{_ as F};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r}from"./sentry-
|
|
1
|
+
import{a as r}from"./sentry-_x3Yh1Jc.js";import{u as l,h as f,g as m}from"./core-DOBELRta.js";import{hY as p,Uq as g,Ur as _}from"./zeni-epic-state-DXFYDM66.js";import{u as b,L as h,z as y}from"./index-CXbL8CxL.js";import"./liveblocks-BPL36a6x.js";import"./recharts-Sp9X2zHo.js";import"./mui-wO6EIETx.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="77204d44-70b9-4fc1-8ae7-6c28d778ce03",e._sentryDebugIdIdentifier="sentry-dbid-77204d44-70b9-4fc1-8ae7-6c28d778ce03")}catch{}})();function j(){const e=l(),n=f(),o=m(),{setLoading:i,clearAllLoading:u}=b(),s=r.useRef(!1);return r.useLayoutEffect((()=>{i(h.CONNECTION_AUTH)}),[i]),r.useEffect((()=>{if(s.current)return;s.current=!0;const a=new URLSearchParams(o.search).get("code"),c=sessionStorage.getItem("hubspot_oauth_pending");if(sessionStorage.removeItem("hubspot_oauth_pending"),a!=null&&c!=null){const t=JSON.parse(c);e(p(t.tenant_id,t.connection_id,g("revenue"),_("hubspot"),{authorization_code:a,client_id:t.client_id,client_secret:t.client_secret,redirect_uri:t.redirect_uri}))}u();const d=y.getActiveTenantForUser();n(d?.tenantEmailDomain!=null?`/${d.tenantEmailDomain}/settings/integrations`:"/",{replace:!0})}),[]),null}export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as s}from"./liveblocks-
|
|
1
|
+
import{n as s}from"./liveblocks-BPL36a6x.js";import{j as d}from"./core-DOBELRta.js";import{fF as a}from"./zeni-epic-state-DXFYDM66.js";import"./sentry-_x3Yh1Jc.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="7ecf9165-dd2c-4040-9e65-c840c8a3aad6",e._sentryDebugIdIdentifier="sentry-dbid-7ecf9165-dd2c-4040-9e65-c840c8a3aad6")}catch{}})();const h=()=>d((e=>a(e))).tenantId==null?{inboxNotifications:[],isLoading:!1,isFetchingMore:!1,hasFetchedAll:!0,fetchMore:()=>null}:(()=>{const{inboxNotifications:e,isLoading:o,isFetchingMore:i,hasFetchedAll:t,fetchMore:n}=s();return{inboxNotifications:e,isLoading:o,isFetchingMore:i,hasFetchedAll:t,fetchMore:n}})();export{h as u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as s}from"./liveblocks-DsNaXx1Y.js";import{a as r}from"./sentry-D4qoEIco.js";import{u as P,h as L,i as R,j as C,t as K,l as O,s as H,g as G,N as B,n as te,o as x}from"./core-C5ZG3tJS.js";import{a9 as st,k as p,ar as T,S as m,cc as ct,cd as rt,ce as lt,cf as dt,cg as ut,ch as gt,ci as mt,cj as vt,ck as pt,cl as ft,cm as St,cn as ht,p as W,co as It,cp as Ct,af as ae,cq as Et,cr as kt,z as ye,cs as yt,ct as xt,cu as bt,cv as jt,cw as Dt,cx as Pt,cy as Lt,cz as At,Q as $t,aj as mn,cA as Ft,cB as wt,cC as Rt,cD as Tt,cE as $e,cF as _t,cG as Ot,cH as Mt,cI as Nt,cJ as Ut,cK as Bt,t as ze,j as vn,cL as Vt,cM as Ht,cN as qt,cO as zt,cP as Zt,cQ as Qt,cR as Kt}from"./index-DcQYDhNo.js";import"./mui-BWEZqJM6.js";import{A as Z}from"./AddressScreen-DVZRYb6q.js";import M from"./NotFoundScreen-BrZDNi9u.js";import{ZE as Gt,ZF as Wt,vl as Ze,ZG as Q,vO as se,ZH as Fe,ZI as ce,wp as xe,ww as Yt,wB as pn,ZJ as we,wt as fn,y3 as Qe,vN as Ke,ZK as Jt,ZL as Sn,wM as be,ZM as re,wQ as Xt,ZN as ei,ZO as hn,wT as In,y_ as ni,ZP as ve,ZQ as Ge,ZR as Cn,vL as ti,ZS as ii,vF as oi,ZT as ai,yg as si,ZU as En,yp as We,ZV as ci,ym as ri,ZW as Re,gh as li,ZX as ee,ZY as ne,x6 as di,vT as Ye,vY as kn,vW as ui,vQ as gi,w$ as mi,v_ as vi,x8 as pi,ZZ as je,xh as yn,xf as Y,xd as le,xc as fi,Z_ as xn,yv as Je,Z$ as Si,vM as bn,_0 as Te,w7 as De,w4 as Pe,wh as jn,wg as _e,w1 as hi,wa as Dn,wj as ie,fF as Oe,Vr as Pn,vP as Me,we as Ii,wf as Ci,wd as Ei,_1 as ki,wR as yi,wN as Ln,_2 as An,vz as Xe,_3 as xi,vv as bi,_4 as ji,yB as Di,yF as q,yA as Pi,xJ as Ne,_5 as Li,_6 as $n,yO as en,_7 as Ai,yL as $i,_8 as Fn,xM as Fi,xN as V,xQ as wi,_9 as wn,x_ as Ie,_a as Ri,x7 as Rn,TZ as Tn,_b as Ti,y8 as _i,_c as _n,_d as Oi,_e as Mi,_f as Ni,zD as Ui,_g as Bi,_h as On,yV as Mn,_i as Nn,zB as Ce,_j as Vi,zy as Hi,_k as qi,_l as zi,_m as Zi,_n as Qi,_o as Ki,_p as nn,_q as Gi,eg as Wi,zH as Yi,_r as Ue,xr as Ji,xm as Xi,_s as de,xC as Un,xu as ue,xt as eo,xx as Bn,_t as no,xs as to,_u as Vn,y$ as Hn,zq as tn,zl as io,_v as oo,z0 as ao,_w as so,zr as co,zv as ro,_x as Be,wr as qn,zc as lo,ws as uo,_y as go,_z as zn,c8 as mo,ms as vo,mt as po,_A as on,wq as ge,gl as fo,mz as So,zi as Zn,zT as ho,zf as Qn,uT as Io,zQ as an,uH as Co,zN as sn,hS as Eo,Uq as cn,Ur as ko,Gb as Kn,hK as yo,_B as xo,Vg as bo,_C as jo,zY as Ee,zZ as Do,_D as Po,_E as Gn,zW as Lo,_F as Ao,_G as $o,yc as Fo,_H as wo}from"./zeni-epic-state-BcPOXb6_.js";import{M as Ro}from"./MobileAppDrawer-3hdMdgHl.js";import{q as me}from"./QBOConnectionScreen-DmjyrlYE.js";import"./recharts-Cbxp2ciV.js";import"./analytics-D_bfwrdA.js";import"./plaid-B_2YsVA4.js";import"./dnd-C67Dx0fq.js";import"./stripe-cKAAJElX.js";import"./lottie-x1U_1T_X.js";import"./lexical-BpFcNSrv.js";import"./pdf-Da5t4yqS.js";import"./utils-DBZ_QSme.js";import"./InboxNotificationsProvider-DGF7zUT5.js";import"./useTaskManagerAccess-C5N90dEy.js";import"./empty-D8AdB3zX.js";import"./pdf-lib-BkS3YoMW.js";import"./index-BJSiEm2J.js";import"./url-C1Mc-kLe.js";import"./index-BUVBGxEt.js";import"./decodeURIComponentSafe-ukN1WN7f.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]="ce373500-0e7d-4b1b-8cb6-a80994028ab1",t._sentryDebugIdIdentifier="sentry-dbid-ce373500-0e7d-4b1b-8cb6-a80994028ab1")}catch{}})();const $=({event:t,isReady:e=!0})=>e?s.jsx(st,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function To(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:g,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:D,auditLogListSortFieldOptions:b}=C(Gt),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${n??""}/invoicing`,I=r.useCallback(((A,U)=>{const _=Wt(y,A,U,D);_!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:A,entityId:U,fromScreen:"audit_log"}),e(_))}),[D,e,y]);r.useEffect((()=>{const A=setTimeout((()=>d(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(Ze({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,t]);const j=g==="Not-Started"||g==="In-Progress"&&f.length===0,E=g==="In-Progress"&&f.length>0,F=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:F}),s.jsx(ct,{auditLogEntityRouteOptions:D,auditLogListSortFieldOptions:b,entries:f,hasMore:S,isLoading:j,isLoadingMore:E,searchValue:a,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&t(Ze({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function pe(t,e=!1){const n=P(),i=C((c=>Q(c).productNextCursor!=null)),a=C((c=>Q(c).productNextCursor)),o=C((c=>Q(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(se({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function fe(t,e,n,i){const[a,o]=r.useState(0),[c,d]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const v=l.current==="In-Progress";l.current=t,t==="Completed"&&v&&n!=null&&(d(!0),i(n))}),[t,n,i]),r.useEffect((()=>{c&&!e&&(d(!1),o((v=>v+1)))}),[c,e]),a}const _o=new Set(["plan"]),Oo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&t(fn({action:a,id:i}))}:void 0,onEditChange:a=>{i!==""&&t(we({id:i,localData:a}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),t(pn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(Yt({action:o,id:a,parentItemId:i}))}}}))(rt);function Mo(){const t=P(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=K(),{areTenantIdsInSync:o}=T(),c=(d=a.get("kind"))!=null&&_o.has(d)?d:"plan";var d;const l=C((k=>Fe(k,n))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(t(ce({id:n})),()=>{t(ce({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(xe({id:n,kind:c}))}),[o,n,c,t]);const g=r.useCallback((k=>t(xe({cacheOverride:!0,id:k,kind:c}))),[t,c]),S=fe(l.fetchState,l.isFormLoading,n,g),f=u==="Completed"&&!l.isFormLoading;pe(o,!0);const[h,D]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&D(n)}),[n,f]);const b=h!==n&&(u==="Not-Started"||u==="In-Progress"||l.isFormLoading);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Oo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:b,view:l},S)]})}const No=new Set(["addon","charge","plan"]),Uo=new Set(["plan"]),Bo=O((function(t,e){const n=Fe(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${n}/catalog/${encodeURIComponent(a)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),t(ce({id:a})),e.navigate(`${n}/catalog`)},onChange:c=>{t(we({id:a,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),t(pn({id:a}))}}}))(lt);function Vo(){const t=P(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=K(),{areTenantIdsInSync:o}=T(),c=n!=null,d=a.get("type"),l=d!=null&&No.has(d)?d:void 0,v=(u=a.get("kind"))!=null&&Uo.has(u)?u:"plan";var u;const g=C((S=>Fe(S,n)));return pe(o,!0),r.useEffect((()=>{o&&t(xe({id:n,kind:v}))}),[o,n,v,t]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||t(we({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const S=g.savedItemId??n,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),t(ce({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),s.jsx(Bo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const Ho={addons:"addon",all:"item",charges:"charge",plans:"plan"},qo=O((function(t,e){const n=Q(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,c=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Ho[e.activeTab];p.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(fn({action:Jt(d),id:c}))},onLoadMore:()=>{if(a)return e.planNextCursor!=null&&t(Ke({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?Ke({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(dt);function zo(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),D=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),b=C((A=>Q(A))),k=b.planFilters.search,y=b.planSort,I=b.planNextCursor,j=b.productNextCursor,E=b.fetchState==="Completed",F=b.runningActionId??null;return r.useEffect((()=>{const A=setTimeout((()=>v(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(Qe({cacheOverride:!1,planFilters:h,productFilters:D,planSort:S,productSort:S}))}),[i,t,h,D,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==y?.field||S?.dir!==y?.dir)&&t(Qe({cacheOverride:!0,planFilters:h,productFilters:D,planSort:S,productSort:S}))}),[k,y,i,t,h,D,f,S]),N(b.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),s.jsx(qo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:a,sortState:u,planFilters:h,productFilters:D,sort:S,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:F,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Zo=O((function(t,e){const n=Sn(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),t(re({id:i})),e.navigate(`${n}/discounts`)},onChange:c=>{t(ei({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:a}),t(Xt({id:i}))}}}))(ut);function Qo(){const t=P(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),{fetchState:o,savedCouponId:c}=C((d=>Sn(d,n)));return r.useEffect((()=>{a&&t(be({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(re({id:n}))}}),[o,c,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCouponFormPage}),s.jsx(Zo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Ko=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:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(Cn(a))},onSubmit:()=>{const a=ii(t.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(oi(a))}}}))(mt);function Go(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),[i]=K(),{areTenantIdsInSync:a}=T(),o=i.get("customerId"),c=C((I=>hn(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(In),g=C((I=>ni(I))),S=C(ve),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,D=f||h,b=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(Ge()),()=>{t(Ge())})),[t]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,t(Cn({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{a&&t(ti({cacheOverride:!1}))}),[a,t]);const y=r.useRef(d);return r.useEffect((()=>{const I=y.current;if(y.current=d,I!=="Completed"&&d==="Completed"){const j=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(j)}}),[d,v,e,n]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),D?s.jsx(gt,{}):s.jsx(Ko,{navigate:e,tenantEmailDomain:n})]})}const Wo=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(vt);function Yo(){const t=P(),e=L(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((d=>ai(d,n??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(si({id:n}))}),[a,n,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Wo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const Jo=O((function(t){const e=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:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(ri({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function Xo(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,creditNoteListFetchState:b}=C((y=>{const I=En(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(We({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(We({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),s.jsx(Jo,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(ci(y)),onSortChange:v})]})}const Wn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},ea=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(je({id:i,localData:a}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onDiscardEdit:()=>{t(Y(le)),t(fi({id:i}))},onOpenAddress:()=>{const a=Wn(e.tenantEmailDomain??"",le,i),o=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),t(je({id:i,localData:a})),t(yn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(pi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>t(vi({body:c,customerId:i,email:a,subject:o})),onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function na(){const t=P(),e=L(),n=G(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),c=C((_=>Re(_,i))),d=c.pageFetchState.fetchState,l=d==="Completed"&&!c.isFormLoading,[v,u]=r.useState(!1),[g,S]=r.useState(!1),[f,h]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&h(i)}),[i,l]);const D=f===i,{plaidTokenFetchState:b,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:y,setupIntentFetchState:I,stripeConnected:j}=c.record,E=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const _=c.record.sendLinkState.fetchState;E.current!=="Error"&&_==="Error"&&t(li({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),E.current=_}),[t,c.record.sendLinkState.fetchState]);const F=I.fetchState==="Error"?I.error?.message??"Failed to start card setup.":y.fetchState==="Error"?y.error?.message??"Failed to save payment method.":b.fetchState==="Error"?b.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(ee()),t(ne()),()=>{t(ee()),t(ne())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(di({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&j&&t(Ye({customerId:i}))}),[o,i,t,j]);const A=r.useCallback((_=>t(kn({id:_}))),[t]),U=fe(c.fetchState,c.isFormLoading,i,A);return N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ea,{customerId:i??"",editView:c,hasLoadedRecord:D,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{t(ee()),i!=null&&j&&t(Ye({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),S(!0)}},U),s.jsx(ft,{errorMessage:F,isCreatingSetupIntent:I.fetchState==="In-Progress",isSaving:y.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:y.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:j,onChooseCard:()=>{i!=null&&t(gi({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:_=>{i!=null&&t(ui({customerId:i,data:_}))}}),s.jsx(St,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:g,submitSucceeded:k.fetchState==="Completed",onClose:()=>{S(!1),t(ne())},onSubmit:({amount:_,description:X})=>{i!=null&&t(mi({amount:_,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:X}))}})]})}const ta=O((function(t,e){const n=Re(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),t(xn({id:i})),t(Y(le)),e.navigate(`${n}/customers`)},onChange:c=>{t(je({id:i,localData:c}))},onOpenAddress:()=>{const c=Wn(e.tenantEmailDomain??"",le,i),d=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:a}),t(yn({id:i}))}}}))(It);function ia(){const t=P(),e=L(),n=G(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),{fetchState:c,savedCustomerId:d}=C((l=>Re(l,i)));return r.useEffect((()=>{o&&i!=null&&t(kn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(v),t(xn({id:i}))}}),[c,d,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerFormPage}),s.jsx(ta,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const oa=O((function(t){const e=ve(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&t(bn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ct);function aa(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,customerListFetchState:b}=C((y=>{const I=ve(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(Je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Je({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),s.jsx(oa,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(Si(y)),onSortChange:v})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),sa=O((function(t,e){const{filters:n,sessionId:i,view:a}=e,o=i==null?void 0:a.diagnosticsBySession[i],c=o?.fetch.fetchState??"Not-Started";return{diagnostics:o?.items??[],errorMessage:c==="Error"?o?.fetch.error?.message:void 0,expired:o?.expired??!1,filters:n,hasMore:o?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(o?.items.length??0)>0,session:Le(a,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:a,sessionId:o,tenantEmailDomain:c,view:d}=e,l=o==null?void 0:d.diagnosticsBySession[o],v=Le(d,o),u=d.actionStateByKind.retry?.fetchState==="In-Progress",g=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>a(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&t(Pe({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&t(_e(o))},onRollback:S?()=>{o!=null&&t(jn(o))}:void 0}}))(Et);function ca(){const t=P(),e=L(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),[o,c]=r.useState({}),d=C(Te),l=Le(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(De(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const f=setTimeout((()=>{t(Pe({...o,sessionId:n}))}),300);return()=>clearTimeout(f)}),[a,t,o,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!a||n==null||!u)return;const f=setInterval((()=>{t(De(n)),t(Pe({...o,sessionId:n}))}),3e3);return()=>clearInterval(f)}),[a,t,o,u,n]);const g=r.useMemo((()=>{if(n==null)return;const f=new URLSearchParams;o.moduleId!=null&&f.set("module_id",o.moduleId),o.level!=null&&f.set("level",o.level),o.outcome!=null&&f.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&f.set("search",o.search.trim());const h=f.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(sa,{downloadUrl:g,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const Yn=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=Yn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ra=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const c=o??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(_e(o)),a(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(jn(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(kt);function la(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),a=C(Te);r.useEffect((()=>{i&&(t(hi()),t(Dn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ra,{navigate:e,tenantEmailDomain:n,view:a})]})}const da=O((function(t,e){const{activeId:n,integrationsView:i,settings:a,view:o}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=o,v=i.externalConnections?.revenue?.find((g=>g.connectionName==="chargebee")),u=n!=null?d[n]:void 0;return{chargebeeConnected:a?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:a?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((g=>g.id===n)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded);const o=ae?.invoicingMicroServiceBaseUrl,c=o!=null&&o.length>0?o:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),t(Ei())},onGoToIntegrations:()=>{i(`/${a}/invoicing/settings`)},onGoToOverview:()=>i(`/${a}/invoicing/overview`),onRetry:()=>{n!=null&&t(_e(n))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),n!=null&&t(Ci(n))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),t(Ii({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(yt);function ua(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),a=C(In),o=C(Oe).companyId??ye.getSignedInUserTenant(n??"")?.companyId,c=C((f=>Pn(f,o))),d=C(Te),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(t(Me()),t(Dn()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(Yn(h))}catch{return null}})(n);f!=null&&t(ie(f))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const g=u?.status,S=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{t(De(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,t]),r.useEffect((()=>{g==="done"&&(t(ie(null)),oe(n,null))}),[t,g,n]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportMigratePage}),s.jsx(da,{activeId:v,integrationsView:c,navigate:e,settings:a,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ga=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{t(Ln({action:a,id:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),t(yi({data:a,id:i}))}}}))(xt);function ma(){const t=P(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((h=>ki(h,n))),c=o.actionState.fetchState==="In-Progress",d=o.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&u(n)}),[n,l]);const g=v===n;r.useEffect((()=>(t(re({id:n})),()=>{t(re({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(be({id:n}))}),[a,n,t]);const S=r.useCallback((h=>t(be({cacheOverride:!0,id:h}))),[t]),f=fe(o.fetchState,o.isFormLoading,n,S);return N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(ga,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},f)]})}const va=O((function(t){const e=An(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{t(Ln({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(bi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function pa(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=An(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,couponListFetchState:j.fetchState,runningDiscountActionId:j.runningActionId??null}}),H),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),s.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>t(xi(I)),onSortChange:v})]})}const fa=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:o=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCancel:a?()=>t(q({action:"cancel",id:i})):void 0,onResolve:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(q({action:"resolve",id:i}))}:void 0,onResume:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(q({action:"resume",id:i}))}:void 0,onRetry:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(q({action:"retry",id:i}))}:void 0}}))(Dt);function Sa(){const t=P(),e=L(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((E=>ji(E,n??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[S,f]=r.useState(),[h,D]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),f(void 0),D(!1)}),[]),k=r.useCallback((()=>{if(n==null)return;t(Di({id:n})),v("idle"),g(!1);const E=o.emailPreview.preview;f(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),D(!0)}),[n,t,o.emailPreview.preview]),y=r.useCallback((E=>{n!=null&&l!=="pending"&&(g(!1),v("pending"),p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(q({action:"send-email",body:E,id:n})))}),[n,t,l]),I=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(Pi({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&d!=null&&t(Ne({invoiceId:d}))}),[a,d,t]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),D(!1)}),[n]),r.useEffect((()=>{a||(v("idle"),g(!1),f(void 0),D(!1))}),[a]),r.useEffect((()=>{h&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(n!=null&&t(Li({id:n})),b()):u&&o.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[n,b,t,l,u,o.actionState.fetchState]);const j=d!=null&&o.linkedInvoice?.id===d?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(fa,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:j,onSendEmail:k}),s.jsx(jt,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:b,onSend:y,open:h,preview:I,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const ha=O((function(t){const e=$n(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{a!=="retry"&&a!=="resume"&&a!=="resolve"&&a!=="cancel"||t(q({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t($i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Pt);function Ia(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,dunningCaseListFetchState:b}=C((y=>{const I=$n(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(en({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(en({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),s.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(Ai(y)),onSortChange:v})]})}const Ca=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),t(wi({data:{due_date:a.due_date!==""?a.due_date:void 0,notes:a.notes.trim()!==""?a.notes.split(`
|
|
1
|
+
import{j as s}from"./liveblocks-BPL36a6x.js";import{a as r}from"./sentry-_x3Yh1Jc.js";import{u as P,h as L,i as R,j as C,t as K,l as O,s as H,g as G,N as B,n as te,o as x}from"./core-DOBELRta.js";import{a9 as st,k as p,ar as T,V as m,cc as ct,cd as rt,ce as lt,cf as dt,cg as ut,ch as gt,ci as mt,cj as vt,ck as pt,cl as ft,cm as St,cn as ht,p as W,co as It,cp as Ct,af as ae,cq as Et,cr as kt,z as ye,cs as yt,ct as xt,cu as bt,cv as jt,cw as Dt,cx as Pt,cy as Lt,cz as At,N as $t,aj as mn,cA as Ft,cB as wt,cC as Rt,cD as Tt,cE as $e,cF as _t,cG as Ot,cH as Mt,cI as Nt,cJ as Ut,cK as Bt,t as ze,j as vn,cL as Vt,cM as Ht,cN as qt,cO as zt,cP as Zt,cQ as Qt,cR as Kt}from"./index-CXbL8CxL.js";import"./mui-wO6EIETx.js";import{A as Z}from"./AddressScreen-dsCmoEfc.js";import M from"./NotFoundScreen-rNwJ2-Qg.js";import{ZE as Gt,ZF as Wt,vl as Ze,ZG as Q,vO as se,ZH as Fe,ZI as ce,wp as xe,ww as Yt,wB as pn,ZJ as we,wt as fn,y3 as Qe,vN as Ke,ZK as Jt,ZL as Sn,wM as be,ZM as re,wQ as Xt,ZN as ei,ZO as hn,wT as In,y_ as ni,ZP as ve,ZQ as Ge,ZR as Cn,vL as ti,ZS as ii,vF as oi,ZT as ai,yg as si,ZU as En,yp as We,ZV as ci,ym as ri,ZW as Re,gh as li,ZX as ee,ZY as ne,x6 as di,vT as Ye,vY as kn,vW as ui,vQ as gi,w$ as mi,v_ as vi,x8 as pi,ZZ as je,xh as yn,xf as Y,xd as le,xc as fi,Z_ as xn,yv as Je,Z$ as Si,vM as bn,_0 as Te,w7 as De,w4 as Pe,wh as jn,wg as _e,w1 as hi,wa as Dn,wj as ie,fF as Oe,Vr as Pn,vP as Me,we as Ii,wf as Ci,wd as Ei,_1 as ki,wR as yi,wN as Ln,_2 as An,vz as Xe,_3 as xi,vv as bi,_4 as ji,yB as Di,yF as q,yA as Pi,xJ as Ne,_5 as Li,_6 as $n,yO as en,_7 as Ai,yL as $i,_8 as Fn,xM as Fi,xN as V,xQ as wi,_9 as wn,x_ as Ie,_a as Ri,x7 as Rn,TZ as Tn,_b as Ti,y8 as _i,_c as _n,_d as Oi,_e as Mi,_f as Ni,zD as Ui,_g as Bi,_h as On,yV as Mn,_i as Nn,zB as Ce,_j as Vi,zy as Hi,_k as qi,_l as zi,_m as Zi,_n as Qi,_o as Ki,_p as nn,_q as Gi,eg as Wi,zH as Yi,_r as Ue,xr as Ji,xm as Xi,_s as de,xC as Un,xu as ue,xt as eo,xx as Bn,_t as no,xs as to,_u as Vn,y$ as Hn,zq as tn,zl as io,_v as oo,z0 as ao,_w as so,zr as co,zv as ro,_x as Be,wr as qn,zc as lo,ws as uo,_y as go,_z as zn,c8 as mo,ms as vo,mt as po,_A as on,wq as ge,gl as fo,mz as So,zi as Zn,zT as ho,zf as Qn,uT as Io,zQ as an,uH as Co,zN as sn,hS as Eo,Uq as cn,Ur as ko,Gb as Kn,hK as yo,_B as xo,Vg as bo,_C as jo,zY as Ee,zZ as Do,_D as Po,_E as Gn,zW as Lo,_F as Ao,_G as $o,yc as Fo,_H as wo}from"./zeni-epic-state-DXFYDM66.js";import{M as Ro}from"./MobileAppDrawer-CZL1M8HC.js";import{q as me}from"./QBOConnectionScreen-TrNoYiXG.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";import"./InboxNotificationsProvider-Bd8tLMl8.js";import"./useTaskManagerAccess-CiaMEBoG.js";import"./empty-C3pt8GU3.js";import"./pdf-lib-Ct6vdrHd.js";import"./index-C_zqEcVM.js";import"./url-DBFa8kl5.js";import"./index-rIJ81ix1.js";import"./decodeURIComponentSafe-DjVlhgki.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]="506177a4-6035-4043-86dd-b9970d505cf8",t._sentryDebugIdIdentifier="sentry-dbid-506177a4-6035-4043-86dd-b9970d505cf8")}catch{}})();const $=({event:t,isReady:e=!0})=>e?s.jsx(st,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function To(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:g,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:D,auditLogListSortFieldOptions:b}=C(Gt),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${n??""}/invoicing`,I=r.useCallback(((A,U)=>{const _=Wt(y,A,U,D);_!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:A,entityId:U,fromScreen:"audit_log"}),e(_))}),[D,e,y]);r.useEffect((()=>{const A=setTimeout((()=>d(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(Ze({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,t]);const j=g==="Not-Started"||g==="In-Progress"&&f.length===0,E=g==="In-Progress"&&f.length>0,F=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:F}),s.jsx(ct,{auditLogEntityRouteOptions:D,auditLogListSortFieldOptions:b,entries:f,hasMore:S,isLoading:j,isLoadingMore:E,searchValue:a,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&t(Ze({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function pe(t,e=!1){const n=P(),i=C((c=>Q(c).productNextCursor!=null)),a=C((c=>Q(c).productNextCursor)),o=C((c=>Q(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(se({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function fe(t,e,n,i){const[a,o]=r.useState(0),[c,d]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const v=l.current==="In-Progress";l.current=t,t==="Completed"&&v&&n!=null&&(d(!0),i(n))}),[t,n,i]),r.useEffect((()=>{c&&!e&&(d(!1),o((v=>v+1)))}),[c,e]),a}const _o=new Set(["plan"]),Oo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&t(fn({action:a,id:i}))}:void 0,onEditChange:a=>{i!==""&&t(we({id:i,localData:a}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),t(pn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(Yt({action:o,id:a,parentItemId:i}))}}}))(rt);function Mo(){const t=P(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=K(),{areTenantIdsInSync:o}=T(),c=(d=a.get("kind"))!=null&&_o.has(d)?d:"plan";var d;const l=C((k=>Fe(k,n))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(t(ce({id:n})),()=>{t(ce({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(xe({id:n,kind:c}))}),[o,n,c,t]);const g=r.useCallback((k=>t(xe({cacheOverride:!0,id:k,kind:c}))),[t,c]),S=fe(l.fetchState,l.isFormLoading,n,g),f=u==="Completed"&&!l.isFormLoading;pe(o,!0);const[h,D]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&D(n)}),[n,f]);const b=h!==n&&(u==="Not-Started"||u==="In-Progress"||l.isFormLoading);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Oo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:b,view:l},S)]})}const No=new Set(["addon","charge","plan"]),Uo=new Set(["plan"]),Bo=O((function(t,e){const n=Fe(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${n}/catalog/${encodeURIComponent(a)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),t(ce({id:a})),e.navigate(`${n}/catalog`)},onChange:c=>{t(we({id:a,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),t(pn({id:a}))}}}))(lt);function Vo(){const t=P(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=K(),{areTenantIdsInSync:o}=T(),c=n!=null,d=a.get("type"),l=d!=null&&No.has(d)?d:void 0,v=(u=a.get("kind"))!=null&&Uo.has(u)?u:"plan";var u;const g=C((S=>Fe(S,n)));return pe(o,!0),r.useEffect((()=>{o&&t(xe({id:n,kind:v}))}),[o,n,v,t]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||t(we({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,t]),r.useEffect((()=>{if(g.fetchState==="Completed"){const S=g.savedItemId??n,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),t(ce({id:n}))}}),[g.fetchState,g.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),s.jsx(Bo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const Ho={addons:"addon",all:"item",charges:"charge",plans:"plan"},qo=O((function(t,e){const n=Q(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,c=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Ho[e.activeTab];p.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(fn({action:Jt(d),id:c}))},onLoadMore:()=>{if(a)return e.planNextCursor!=null&&t(Ke({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?Ke({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(dt);function zo(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),D=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),b=C((A=>Q(A))),k=b.planFilters.search,y=b.planSort,I=b.planNextCursor,j=b.productNextCursor,E=b.fetchState==="Completed",F=b.runningActionId??null;return r.useEffect((()=>{const A=setTimeout((()=>v(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(Qe({cacheOverride:!1,planFilters:h,productFilters:D,planSort:S,productSort:S}))}),[i,t,h,D,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==y?.field||S?.dir!==y?.dir)&&t(Qe({cacheOverride:!0,planFilters:h,productFilters:D,planSort:S,productSort:S}))}),[k,y,i,t,h,D,f,S]),N(b.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),s.jsx(qo,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:a,sortState:u,planFilters:h,productFilters:D,sort:S,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:F,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Zo=O((function(t,e){const n=Sn(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),t(re({id:i})),e.navigate(`${n}/discounts`)},onChange:c=>{t(ei({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:a}),t(Xt({id:i}))}}}))(ut);function Qo(){const t=P(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),{fetchState:o,savedCouponId:c}=C((d=>Sn(d,n)));return r.useEffect((()=>{a&&t(be({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(re({id:n}))}}),[o,c,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCouponFormPage}),s.jsx(Zo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Ko=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:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(Cn(a))},onSubmit:()=>{const a=ii(t.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(oi(a))}}}))(mt);function Go(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),[i]=K(),{areTenantIdsInSync:a}=T(),o=i.get("customerId"),c=C((I=>hn(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(In),g=C((I=>ni(I))),S=C(ve),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,D=f||h,b=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(Ge()),()=>{t(Ge())})),[t]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,t(Cn({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{a&&t(ti({cacheOverride:!1}))}),[a,t]);const y=r.useRef(d);return r.useEffect((()=>{const I=y.current;if(y.current=d,I!=="Completed"&&d==="Completed"){const j=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(j)}}),[d,v,e,n]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),D?s.jsx(gt,{}):s.jsx(Ko,{navigate:e,tenantEmailDomain:n})]})}const Wo=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(vt);function Yo(){const t=P(),e=L(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((d=>ai(d,n??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(si({id:n}))}),[a,n,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Wo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const Jo=O((function(t){const e=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:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(ri({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function Xo(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,creditNoteListFetchState:b}=C((y=>{const I=En(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(We({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(We({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),s.jsx(Jo,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(ci(y)),onSortChange:v})]})}const Wn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},ea=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(je({id:i,localData:a}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onDiscardEdit:()=>{t(Y(le)),t(fi({id:i}))},onOpenAddress:()=>{const a=Wn(e.tenantEmailDomain??"",le,i),o=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),t(je({id:i,localData:a})),t(yn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(pi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>t(vi({body:c,customerId:i,email:a,subject:o})),onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function na(){const t=P(),e=L(),n=G(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),c=C((_=>Re(_,i))),d=c.pageFetchState.fetchState,l=d==="Completed"&&!c.isFormLoading,[v,u]=r.useState(!1),[g,S]=r.useState(!1),[f,h]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&h(i)}),[i,l]);const D=f===i,{plaidTokenFetchState:b,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:y,setupIntentFetchState:I,stripeConnected:j}=c.record,E=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const _=c.record.sendLinkState.fetchState;E.current!=="Error"&&_==="Error"&&t(li({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),E.current=_}),[t,c.record.sendLinkState.fetchState]);const F=I.fetchState==="Error"?I.error?.message??"Failed to start card setup.":y.fetchState==="Error"?y.error?.message??"Failed to save payment method.":b.fetchState==="Error"?b.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(ee()),t(ne()),()=>{t(ee()),t(ne())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(di({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&j&&t(Ye({customerId:i}))}),[o,i,t,j]);const A=r.useCallback((_=>t(kn({id:_}))),[t]),U=fe(c.fetchState,c.isFormLoading,i,A);return N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ea,{customerId:i??"",editView:c,hasLoadedRecord:D,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{t(ee()),i!=null&&j&&t(Ye({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),S(!0)}},U),s.jsx(ft,{errorMessage:F,isCreatingSetupIntent:I.fetchState==="In-Progress",isSaving:y.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:y.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:j,onChooseCard:()=>{i!=null&&t(gi({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:_=>{i!=null&&t(ui({customerId:i,data:_}))}}),s.jsx(St,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:g,submitSucceeded:k.fetchState==="Completed",onClose:()=>{S(!1),t(ne())},onSubmit:({amount:_,description:X})=>{i!=null&&t(mi({amount:_,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:X}))}})]})}const ta=O((function(t,e){const n=Re(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),t(xn({id:i})),t(Y(le)),e.navigate(`${n}/customers`)},onChange:c=>{t(je({id:i,localData:c}))},onOpenAddress:()=>{const c=Wn(e.tenantEmailDomain??"",le,i),d=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:a}),t(yn({id:i}))}}}))(It);function ia(){const t=P(),e=L(),n=G(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),{fetchState:c,savedCustomerId:d}=C((l=>Re(l,i)));return r.useEffect((()=>{o&&i!=null&&t(kn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(v),t(xn({id:i}))}}),[c,d,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerFormPage}),s.jsx(ta,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const oa=O((function(t){const e=ve(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&t(bn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ct);function aa(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,customerListFetchState:b}=C((y=>{const I=ve(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(Je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Je({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),s.jsx(oa,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(Si(y)),onSortChange:v})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),sa=O((function(t,e){const{filters:n,sessionId:i,view:a}=e,o=i==null?void 0:a.diagnosticsBySession[i],c=o?.fetch.fetchState??"Not-Started";return{diagnostics:o?.items??[],errorMessage:c==="Error"?o?.fetch.error?.message:void 0,expired:o?.expired??!1,filters:n,hasMore:o?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(o?.items.length??0)>0,session:Le(a,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:a,sessionId:o,tenantEmailDomain:c,view:d}=e,l=o==null?void 0:d.diagnosticsBySession[o],v=Le(d,o),u=d.actionStateByKind.retry?.fetchState==="In-Progress",g=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>a(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&t(Pe({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&t(_e(o))},onRollback:S?()=>{o!=null&&t(jn(o))}:void 0}}))(Et);function ca(){const t=P(),e=L(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),[o,c]=r.useState({}),d=C(Te),l=Le(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(De(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const f=setTimeout((()=>{t(Pe({...o,sessionId:n}))}),300);return()=>clearTimeout(f)}),[a,t,o,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!a||n==null||!u)return;const f=setInterval((()=>{t(De(n)),t(Pe({...o,sessionId:n}))}),3e3);return()=>clearInterval(f)}),[a,t,o,u,n]);const g=r.useMemo((()=>{if(n==null)return;const f=new URLSearchParams;o.moduleId!=null&&f.set("module_id",o.moduleId),o.level!=null&&f.set("level",o.level),o.outcome!=null&&f.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&f.set("search",o.search.trim());const h=f.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(sa,{downloadUrl:g,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const Yn=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=Yn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ra=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const c=o??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(_e(o)),a(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(jn(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(kt);function la(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),a=C(Te);r.useEffect((()=>{i&&(t(hi()),t(Dn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ra,{navigate:e,tenantEmailDomain:n,view:a})]})}const da=O((function(t,e){const{activeId:n,integrationsView:i,settings:a,view:o}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=o,v=i.externalConnections?.revenue?.find((g=>g.connectionName==="chargebee")),u=n!=null?d[n]:void 0;return{chargebeeConnected:a?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:a?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((g=>g.id===n)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded);const o=ae?.invoicingMicroServiceBaseUrl,c=o!=null&&o.length>0?o:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),t(Ei())},onGoToIntegrations:()=>{i(`/${a}/invoicing/settings`)},onGoToOverview:()=>i(`/${a}/invoicing/overview`),onRetry:()=>{n!=null&&t(_e(n))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),n!=null&&t(Ci(n))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),t(Ii({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(yt);function ua(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),a=C(In),o=C(Oe).companyId??ye.getSignedInUserTenant(n??"")?.companyId,c=C((f=>Pn(f,o))),d=C(Te),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(t(Me()),t(Dn()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(Yn(h))}catch{return null}})(n);f!=null&&t(ie(f))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const g=u?.status,S=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{t(De(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,t]),r.useEffect((()=>{g==="done"&&(t(ie(null)),oe(n,null))}),[t,g,n]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportMigratePage}),s.jsx(da,{activeId:v,integrationsView:c,navigate:e,settings:a,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ga=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{t(Ln({action:a,id:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),t(yi({data:a,id:i}))}}}))(xt);function ma(){const t=P(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((h=>ki(h,n))),c=o.actionState.fetchState==="In-Progress",d=o.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&u(n)}),[n,l]);const g=v===n;r.useEffect((()=>(t(re({id:n})),()=>{t(re({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(be({id:n}))}),[a,n,t]);const S=r.useCallback((h=>t(be({cacheOverride:!0,id:h}))),[t]),f=fe(o.fetchState,o.isFormLoading,n,S);return N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(ga,{hasLoadedRecord:g,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},f)]})}const va=O((function(t){const e=An(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{t(Ln({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(bi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function pa(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=An(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,couponListFetchState:j.fetchState,runningDiscountActionId:j.runningActionId??null}}),H),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),s.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>t(xi(I)),onSortChange:v})]})}const fa=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:o=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCancel:a?()=>t(q({action:"cancel",id:i})):void 0,onResolve:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(q({action:"resolve",id:i}))}:void 0,onResume:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(q({action:"resume",id:i}))}:void 0,onRetry:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(q({action:"retry",id:i}))}:void 0}}))(Dt);function Sa(){const t=P(),e=L(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((E=>ji(E,n??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[S,f]=r.useState(),[h,D]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),f(void 0),D(!1)}),[]),k=r.useCallback((()=>{if(n==null)return;t(Di({id:n})),v("idle"),g(!1);const E=o.emailPreview.preview;f(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),D(!0)}),[n,t,o.emailPreview.preview]),y=r.useCallback((E=>{n!=null&&l!=="pending"&&(g(!1),v("pending"),p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(q({action:"send-email",body:E,id:n})))}),[n,t,l]),I=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(Pi({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&d!=null&&t(Ne({invoiceId:d}))}),[a,d,t]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),D(!1)}),[n]),r.useEffect((()=>{a||(v("idle"),g(!1),f(void 0),D(!1))}),[a]),r.useEffect((()=>{h&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(n!=null&&t(Li({id:n})),b()):u&&o.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[n,b,t,l,u,o.actionState.fetchState]);const j=d!=null&&o.linkedInvoice?.id===d?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(fa,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:j,onSendEmail:k}),s.jsx(jt,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:b,onSend:y,open:h,preview:I,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const ha=O((function(t){const e=$n(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{a!=="retry"&&a!=="resume"&&a!=="resolve"&&a!=="cancel"||t(q({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t($i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Pt);function Ia(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,dunningCaseListFetchState:b}=C((y=>{const I=$n(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&t(en({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(en({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),s.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onStatusChange:y=>t(Ai(y)),onSortChange:v})]})}const Ca=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),t(wi({data:{due_date:a.due_date!==""?a.due_date:void 0,notes:a.notes.trim()!==""?a.notes.split(`
|
|
2
2
|
`).map((o=>o.trim())).filter((o=>o!=="")).map((o=>({note:o}))):void 0,po_number:a.po_number!==""?a.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceReminderSent,{invoiceId:i}),t(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onVoid:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:a}))}}}))(Lt);function Ea(){const t=P(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((g=>Fn(g,n??""))),c=o.pageFetchState.fetchState,d=c==="Completed",[l,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const u=l===n;return r.useEffect((()=>{a&&n!=null&&t(Fi({invoiceId:n}))}),[a,n,t]),N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Ca,{invoiceId:n??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:o})]})}const ka=O((function(t){const e=wn(t),{fetchState:n}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:n==="Not-Started"||n==="In-Progress"&&e.invoices.length===0,isLoadingMore:n==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{switch(a){case"recordPayment":e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":t(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":t(V({action:"regenerate",invoiceId:i}));break;case"void":t(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,a)=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:a}))},onLoadMore:()=>{e.nextCursor!=null&&t(Rn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(At);function ya(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,invoiceListFetchState:b,voidingInvoiceId:k}=C((I=>{const j=wn(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:I.invoicingInvoiceListState.sort,nextCursor:j.nextCursor,invoiceListFetchState:j.fetchState,voidingInvoiceId:j.runningActionId}}),H),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&t(Ie({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ie({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoicesListPage,isReady:y}),s.jsx(ka,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,voidingInvoiceId:k,onSearchChange:o,onStatusChange:I=>{t(Ri(I)),t(Ie({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v})]})}function rn(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),i=$t(),a=mn(),[o,c]=r.useState(!1),{acceptTermsState:d,status:l}=C(Tn),v=Ti(i?.loggedInUserRoleMap),u=`/${n}/invoicing`,g=S=>{c(S)};return l==="completed"?s.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?s.jsx(B,{to:`${u}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(Ro,{isAppContentDrawerOpen:o,handleDrawerToggle:g}),s.jsx(Ft,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{t(_i())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{g(!0)}})]})}const xa=O((function(t,e){const n=_n(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:c,typeOptions:d}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:d}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:a=>{t(Bi({localData:a}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Ui())}}}))(wt);function ba(){const t=P(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),{fetchState:o,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=C((f=>_n(f,n??""))),u=`/${i}/invoicing`,g=r.useRef(null);r.useEffect((()=>{t(Oi()),g.current=null}),[t,n]),r.useEffect((()=>{a&&n!=null&&t(Ne({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{c!=null&&n!=null&&o==="Completed"&&g.current!==n&&(g.current=n,t(Mi({localData:Ni(c)})))}),[t,o,c,n]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(xa,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const ja=O((function(t){return{invoicingOverview:On(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{t(Mn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(Rt);function Da(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),o=C((c=>On(c).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Mn(a))}),[i,t,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingOverviewPage,isReady:o}),s.jsx(ja,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const Pa=O((function(t){const e=Nn(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(Hi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Tt);function La(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:h,nextCursor:D,transactionListFetchState:b,transactions:k}=C((F=>{const A=Nn(F);return{activeType:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,transactionListFetchState:A.fetchState,transactions:A.transactions}}),H),y=b==="Completed",I=`/${n}/invoicing`,j=r.useCallback((F=>{const A=k.find((_=>_.id===F)),U=A?.linkedInvoices?.[0]?.invoiceID??A?.invoiceID;U!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${I}/invoices/${encodeURIComponent(U)}`))}),[e,I,k]),E=r.useCallback((F=>{const A=k.find((U=>U.id===F))?.customerID;A!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:A,fromScreen:"payments_list",toScreen:"customer"}),e(`${I}/customers/${encodeURIComponent(A)}`))}),[e,I,k]);return r.useEffect((()=>{const F=setTimeout((()=>d(a)),300);return()=>clearTimeout(F)}),[a]),r.useEffect((()=>{i&&t(Ce({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Ce({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingPaymentsListPage,isReady:y}),s.jsx(Pa,{navigate:e,tenantEmailDomain:n,activeType:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,onSearchChange:o,onTypeChange:F=>{t(Vi(F)),t(Ce({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v,onViewTransactionCustomer:E,onViewTransactionInvoice:j})]})}const Aa=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 ln(){const t=P(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=n!=null&&n!=="",c=C(ve),d=C((E=>qi(E))),l=C(zi),v=C((E=>Fn(E,n??""))),u=v.invoice,g=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Zi()),S.current=null,f.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?Ne({invoiceId:n}):bn({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&u!=null&&n!=null&&v.fetchState==="Completed"&&S.current!==n&&(S.current=n,t(Qi({contextInvoiceId:n,localData:Ki(u)})))}),[t,u,n,v.fetchState,o]),r.useEffect((()=>{if(o)return;const E=d.localData.customerId;E!==""&&E!==f.current&&(f.current=E,t(Rn({filters:{customerId:E},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&t(nn({localData:{...d.localData,customerId:E,invoiceToLink:""}})))}),[t,d.localData,o]);const h=r.useRef(l.fetchState);r.useEffect((()=>{const E=h.current;if(h.current=l.fetchState,E!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${g}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${g}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,g]);const D=r.useMemo((()=>c.customers.map((E=>({id:E.id,name:Aa(E)})))),[c.customers]),b=C((E=>Gi(E,d.localData.customerId))),k=r.useMemo((()=>b.map((E=>{return{amountDue:(F=E.amountDue,A=Wi.currencySymbol,Ot("0,0.00",F,A)),amountDueValue:E.amountDue,id:E.id,label:E.invoiceNumber};var F,A}))),[b]),y=r.useMemo((()=>{if(!o||u==null)return;const E=u.currencyCode??"USD",F=u.amountDue?.amount??0;return{amountDue:$e("0,0.00",u.amountDue),amountDueValue:F,currencyCode:E,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,o]),I=o?`${g}/invoices/${encodeURIComponent(n??"")}`:`${g}/payments`,j=!o||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingRecordPaymentPage,isReady:j}),s.jsx(_t,{customers:D,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:y,invoiceOptions:k,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:o?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(I)},onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentCancelled),e(I)},onChange:E=>{t(nn({localData:E}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:o?n:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),t(Yi(o?n??void 0:void 0))}})]})}const Jn=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},$a=(t,e)=>{if(t==null)return;const n=$e("0,0",t);return e!=null?`${n}/${e}`:n},Xn=(t,e,n)=>{const i=[t,$a(e,n)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},dn=t=>t.priceCode!=null&&t.priceCode.trim()!=="",Fa=t=>({billingCycles:t.billingCycles,billingPeriod:t.period,billingPeriodUnit:t.periodUnit,label:t.name??t.id,subtitle:Xn(t.productCode,t.price,t.periodUnit),value:t.priceCode}),wa=t=>({label:t.name??t.couponCode??t.id,value:t.couponCode??t.id}),Ra=O((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.products.filter((c=>c.itemType==="addon")).filter(dn).map((c=>({label:c.name??c.id,subtitle:Xn(c.productCode,c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:o,coupons:n.coupons.map(wa),isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans.filter(dn).map(Fa),shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),t(Bn({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:c=>{t(de({id:i,localData:c}))},onChangeTermEnd:a?c=>{const d=c?.trim()??"";d!==""&&o("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Y(ue)),t(eo({id:i}))},onOpenAddress:()=>{const c=Jn(e.tenantEmailDomain??"",ue,i),d=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${n}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionEdited,{subscriptionId:i}),t(de({id:i,localData:c})),t(Un({id:i}))},onCancelSubscription:a?c=>{o("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(c,d)=>{c!=="pause"?o(c):o(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Mt);function Ta(){const t=P(),e=L(),n=G(),{subscription_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),c=C((k=>Ue(k,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,g=u==="Completed"&&!c.isFormLoading,[S,f]=r.useState(g?i:void 0);r.useEffect((()=>{i!=null&&g&&f(i)}),[i,g]);const h=S===i;pe(o),r.useEffect((()=>{o&&i!=null&&t(Ji({id:i}))}),[o,i,t]);const D=r.useCallback((k=>t(Xi({id:k}))),[t]),b=fe(c.fetchState,c.isFormLoading,i,D);return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionDetailPage,isReady:g}),s.jsx(Ra,{hasLoadedRecord:h,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:n,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},b)]})}const _a=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id},Oa=(t,e)=>{if(t==null)return;const n=$e("0,0",t);return e!=null?`${n}/${e}`:n},Ae=(t,e,n)=>{const i=[t,Oa(e,n)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},Ma=t=>({label:_a(t),value:t.id}),ke=t=>t.priceCode!=null&&t.priceCode.trim()!=="",Na=t=>({billingCycles:t.billingCycles,billingPeriod:t.period,billingPeriodUnit:t.periodUnit,label:t.name??t.id,subtitle:Ae(t.productCode,t.price,t.periodUnit),trialPeriod:t.trialPeriod,trialPeriodUnit:t.trialPeriodUnit,value:t.priceCode}),Ua=t=>({label:t.name??t.couponCode??t.id,value:t.couponCode??t.id}),Ba=O((function(t,e){const n=Ue(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.products.filter((i=>i.itemType==="addon")).filter(ke).map((i=>({label:i.name??i.id,subtitle:Ae(i.productCode,i.price,i.periodUnit),value:i.priceCode}))),charges:n.products.filter((i=>i.itemType==="charge")).filter(ke).map((i=>({label:i.name??i.id,subtitle:Ae(i.productCode,i.price,void 0),value:i.priceCode}))),coupons:n.coupons.map(Ua),customers:n.customers.map(Ma),errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans.filter(ke).map(Na),shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionFormCancelled),t(Vn({id:i})),t(Y(ue)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:o=>{t(de({id:i,localData:o}))},onOpenAddress:()=>{const o=Jn(e.tenantEmailDomain??"",ue,i),c=W(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionSaved,{mode:a}),t(Un({id:i}))}}}))(Nt);function Va(){const t=P(),e=L(),n=G(),{subscription_id:i,tenantEmailDomain:a}=R(),[o]=K(),{areTenantIdsInSync:c}=T(),d=o.get("customerId"),{fetchState:l,savedSubscriptionId:v}=C((S=>no(S,i))),u=C((S=>Ue(S,i).localData));pe(c),r.useEffect((()=>{c&&t(to({subscriptionId:i}))}),[c,i,t]);const g=r.useRef(!1);return r.useEffect((()=>{g.current||i!=null||d==null||d===""||u.customerId!==""||(g.current=!0,t(de({id:i,localData:{...u,customerId:d}})))}),[d,i,u,t]),r.useEffect((()=>{if(l==="Completed"){const S=v??i,f=S!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${a}/invoicing/subscriptions`;e(f),t(Vn({id:i}))}}),[l,v,i,t,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionFormPage}),s.jsx(Ba,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Ha=O((function(t){const e=Hn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,c)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:o,subscriptionId:a}),t(Bn({action:o,id:a,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const c=o?.trim()??"";c!==""&&i(a,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(a,o,c)=>{o!=="pause"?i(a,o):i(a,o,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&t(ao({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ut);function qa(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:D,subscriptionListFetchState:b,runningActionSubscriptionId:k}=C((j=>{const E=Hn(j);return{activeStatus:E.activeTab,appliedSearch:E.filters.search,appliedSort:E.sort,nextCursor:E.nextCursor,subscriptionListFetchState:E.fetchState,runningActionSubscriptionId:E.runningActionId??null}}),H),y=b==="Completed";r.useEffect((()=>{const j=setTimeout((()=>d(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(tn({cacheOverride:!0,filters:g,sort:u}))}),[i,t,g,u,f,h]);const I=r.useRef(k);return r.useEffect((()=>{const j=I.current!=null&&k==null;I.current=k,j&&i&&t(io())}),[k,i,t]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionsListPage,isReady:y}),s.jsx(Ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:D,runningActionSubscriptionId:k,onSearchChange:o,onStatusChange:j=>t(oo(j)),onSortChange:v})]})}const za=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(m.Event.invoicingTransactionCaptured,{transactionId:i}),t(ro({action:"capture",id:i}))}:void 0}}))(Bt);function Za(){const t=P(),e=L(),{tenantEmailDomain:n,transaction_id:i}=R(),{areTenantIdsInSync:a}=T(),o=C((d=>so(d,i??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(co({id:i}))}),[a,i,t]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(za,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function et(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=P(),{areTenantIdsInSync:c}=T(),d=C(Be),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(a&&v!=="Not-Started"||o(qn()),n&&o(lo()))}),[c,o,e,n,a]),r.useEffect((()=>{e&&c&&l&&i&&o(uo())}),[c,o,e,l,i]),{isQboConnected:l,qboView:d}}const Qa={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function J(t){const e=P(),{areTenantIdsInSync:n}=T(),{tenantEmailDomain:i}=R(),{fetchState:a,fieldHelp:o,logoFile:c,saveState:d,settings:l,stripeConnectState:v}=C(go),{configError:u,configFetchState:g,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:D}=C(zn),b=C(Be);et({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const k=C(Oe),y=t==="dunning"||t==="quickbooks",I=k.companyId??ye.getSignedInUserTenant(i??"")?.companyId,j=C((w=>Pn(w,I))),E=mo(k.userRole??[]),F=k.tenantId??"",A=ye.getSignedInUser(),U={userId:A?.userId??"",sessionId:A?.zeniSessionId??"",tenantId:F},_=c?.fileId,X=C((w=>_!=null&&_!==""?vo(w,_):void 0)),Ve=C((w=>_!=null&&_!==""?po(w,_):void 0)),nt=_!=null&&_!==""&&X!=null?{[_]:X}:{},tt=_!=null&&_!==""&&Ve!=null?{[_]:Ve}:{};r.useEffect((()=>(e(on()),()=>{e(on())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Me()))}),[n,e,a]),r.useEffect((()=>{n&&y&&g==="Not-Started"&&e(ge())}),[n,e,g,y]),r.useEffect((()=>{if(!n)return;const w=A?.userId;w!=null&&w!==""&&F!==""&&ze.shouldFetchActiveTenant(F)&&(ze.markActiveTenantFetchStarted(F),e(fo(w,F,A?.zeniSessionId)))}),[n,e,A?.userId,A?.zeniSessionId,F]);const it=S.length>0||f.length>0,ot=a==="Not-Started"||a==="In-Progress"&&l==null||y&&!it&&(g==="Not-Started"||g==="In-Progress"),at=a==="Completed"&&(!y||g==="Completed"),He=j.externalConnections?.revenue?.find((w=>w.connectionName==="chargebee"))?.connectionId,Se=ae?.invoicingMicroServiceBaseUrl,qe=Se!=null&&Se.length>0?`${Se}/1.0/webhooks/stripe`:"",he={deleteConnectionError:j.externalConnections?.deleteConnectionError?.message,deleteConnectionState:j.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:j,isAdmin:E,isStripeBusy:v.fetchState==="In-Progress",onConnectStripe:w=>e(sn(w)),onDisconnect:(w,z)=>{F!==""&&e(yo(F,w,cn(z)))},onDisconnectStripe:()=>e(an()),onReconnectQBO:()=>{const w=k.tenantEmailDomain??i??"";me.init("/connection/auth",w),me.handleClick()},onRefreshQBO:()=>{j.integrations.refreshQBO.fetchState!=="In-Progress"&&e(Kn())},onSaveChargeBeeCredentials:(w,z)=>{He!=null&&F!==""&&e(Eo(F,He,cn("revenue"),ko("chargebee"),{api_key:w,site:z}))},saveChargeBeeError:j.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:j.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe};return{authParams:U,deleteFileStatusById:nt,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:ae?.fileMicroServiceBaseUrl??"",integrationsSectionProps:he,isInvoicingPageReady:at,isLoading:ot,isSaving:d.fetchState==="In-Progress",isStripeBusy:v.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:D,qboView:b,saveErrorMessage:d.fetchState==="Error"?d.error?.message??"Failed to save settings.":y&&g==="Error"?u?.message??"Failed to load invoicing configuration.":void 0,settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe,updateFileStatusById:tt,onConnectStripe:w=>e(sn(w)),onDeleteFile:w=>e(Co(w,F)),onDisconnectStripe:()=>e(an()),onEditFileName:(w,z)=>e(Io(w,z,F)),onReconnectQBO:he.onReconnectQBO,onRefreshQBO:he.onRefreshQBO,onRetryQboSyncTask:w=>e(Qn(w)),onSave:w=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:t??"hub"}),e(ho({settings:w,snackbarSection:Qa[t??""]}))},onStartQboBackfill:w=>e(Zn(w)),updateFilesEntity:w=>{p.trackInvoicingActionClick(m.Event.invoicingLogoUploaded),e(So({files:w}))}}}function un({appContent:t}){const e=L(),n=G(),i=P(),{tenantEmailDomain:a}=R(),o=J("branding"),c=C((v=>xo(v))),d=C((v=>bo(Ee,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(jo()),i(Y(Ee)))}),[c.saveState.fetchState,i]);const l=vn(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Vt,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:c.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(Po({localData:v}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{const v=`/${a}/invoicing/settings/branding/${Ee}/`,u=W(n.state?.pathnameStackToGoBack,n.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Do()),updateFilesEntity:o.updateFilesEntity})]})}function Ka(){const t=L(),e=J("dunning");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Ht,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Ga(){const t=L(),e=J("integrations");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(qt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Wa(){const t=L(),e=J("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(zt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Ya=O((function(t){const e=Gn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t($o({localData:e}))},onReset:()=>{t(Ao())},onRetryTask:e=>{t(Qn(e))},onSave:()=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:"quickbooks"}),t(Lo())},onStartBackfill:e=>{t(Zn(e))}}}))(Zt);function Ja(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),i=C(Oe),{configFetchState:a,settingsFetchState:o}=C(Gn);return r.useEffect((()=>{o!=="Not-Started"&&o!=="Error"||t(Me())}),[t,o]),r.useEffect((()=>{a==="Not-Started"&&t(ge())}),[a,t]),et({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage}),s.jsx(Ya,{onBackClick:()=>e(".."),onReconnect:()=>{me.init("/connection/auth",i.tenantEmailDomain??n??""),me.handleClick()},onRefresh:()=>t(Kn())})]})}const Xa={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function es(){const t=mn(),e=P(),n=L(),[i,a]=K(),o=J(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=C(zn),g=i.get("tab");return r.useEffect((()=>{if(g==null)return;const S=Xa[g];a({},{replace:!0}),S!=null&&n(S,{replace:!0})}),[g,n,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Qt,{analytics:p,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:d,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Fo())}})]})}function gn(){return s.jsxs(te,{children:[s.jsx(x,{index:!0,element:s.jsx(es,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(Wa,{})}),s.jsx(x,{path:"branding",element:s.jsx(un,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(un,{appContent:s.jsx(Z,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(Ga,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Ka,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(Ja,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function Ps(){const t=P(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=T(),{enableState:a,fetchState:o,status:c}=C(Tn),d=vn(a.fetchState),l=`/${n}/invoicing`,v=r.useRef(!1),u=C((g=>Be(g).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||v.current||(v.current=!0,t(ge({cacheOverride:!1}))):t(ge({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&u==="Not-Started"&&t(qn())}),[i,t,u]),r.useEffect((()=>{d==="In-Progress"&&a.fetchState==="Completed"&&(e(`${l}/catalog`),t(wo()))}),[d,a.fetchState,l,t,e]),c==null&&o!=="Error"?s.jsx(Kt,{fetchState:"In-Progress"}):c==="not_started"?s.jsxs(te,{children:[s.jsx(x,{path:"promo",element:s.jsx(rn,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(te,{children:[s.jsx(x,{path:"promo",element:s.jsx(rn,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(gn,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(te,{children:[s.jsx(x,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx(Da,{})}),s.jsx(x,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(aa,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(ia,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(Z,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(na,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(Z,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(qa,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(Va,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(Z,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(Ta,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(Z,{})}),s.jsx(x,{path:"invoices",element:s.jsx(ya,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(Go,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(Ea,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(ln,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(ba,{})}),s.jsx(x,{path:"payments",element:s.jsx(La,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(ln,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(Za,{})}),s.jsx(x,{path:"credits",element:s.jsx(Xo,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(Yo,{})}),s.jsx(x,{path:"discounts",element:s.jsx(pa,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(Qo,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(ma,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Ia,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Sa,{})}),s.jsx(x,{path:"catalog",element:s.jsx(zo,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(Vo,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Mo,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(gn,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(To,{})}),s.jsx(x,{path:"data_import",element:s.jsx(la,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(ua,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(ca,{})}),s.jsx(x,{path:"*",element:s.jsx(M,{})})]})}export{Ps as default};
|