@zeniai/web-app-ui 5.3.32-next → 5.3.32-prod

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. package/dist/assets/{AccountMappingScreen-DA6vMX8n.js → AccountMappingScreen-BXftSVn-.js} +1 -1
  2. package/dist/assets/AddressRoutes-Dx1aQN-n.js +1 -0
  3. package/dist/assets/{AddressScreen-2iFQsQhr.js → AddressScreen-TLZdvXNy.js} +1 -1
  4. package/dist/assets/{AiCfoScreen-C9m6odEm.js → AiCfoScreen-DmLnUFml.js} +1 -1
  5. package/dist/assets/{AppDrawer-AR3pdgjI.js → AppDrawer-BnHpD6dG.js} +1 -1
  6. package/dist/assets/{BillPayApprovalRoutes-D6CaIPVl.js → BillPayApprovalRoutes-DPALyyf2.js} +1 -1
  7. package/dist/assets/{BillPayRoutes-BQGUM9hu.js → BillPayRoutes-qAhjjusa.js} +1 -1
  8. package/dist/assets/{BusinessVerificationPageScreen-bzYA6ugA.js → BusinessVerificationPageScreen-BYV8fDWH.js} +1 -1
  9. package/dist/assets/{CardsAiCfoScreen-DzZaAiTB.js → CardsAiCfoScreen-Cd63K_-0.js} +1 -1
  10. package/dist/assets/{ChargeCardRoutes-DUgnqPWj.js → ChargeCardRoutes-BH9evnp_.js} +1 -1
  11. package/dist/assets/{CompanyPassportScreen-DDPsmPkS.js → CompanyPassportScreen-D0g6Nmxq.js} +1 -1
  12. package/dist/assets/{ConnectionAuthScreen-D0DWsoRm.js → ConnectionAuthScreen-CpG3pE-i.js} +1 -1
  13. package/dist/assets/CustomerOnboardingAuthScreen-CXLOaLgp.js +1 -0
  14. package/dist/assets/{CustomerOnboardingRoutes-BZn_LcyK.js → CustomerOnboardingRoutes-CI_z4poM.js} +1 -1
  15. package/dist/assets/{DashboardRoutes-CY1SDvUL.js → DashboardRoutes-C_4oAXQg.js} +1 -1
  16. package/dist/assets/{DefaultTenantHome-C00MLtaA.js → DefaultTenantHome-D3eb-jo9.js} +1 -1
  17. package/dist/assets/{DomesticWireDetailScreen-5wKaAYNZ.js → DomesticWireDetailScreen-i7JC-m7w.js} +1 -1
  18. package/dist/assets/{DrawerScreen-DXivMtkW.js → DrawerScreen-DUO1Z5ow.js} +1 -1
  19. package/dist/assets/{EntityDetailRoutes-D4JppFuK.js → EntityDetailRoutes-B2ai8pR3.js} +1 -1
  20. package/dist/assets/{ExpenseAutomationRoutes-Dmnf2gk3.js → ExpenseAutomationRoutes-DQA6yQ4O.js} +1 -1
  21. package/dist/assets/{FeaturePreviewScreen-C4egsTmn.js → FeaturePreviewScreen-CjFoHQHk.js} +1 -1
  22. package/dist/assets/{HubSpotOAuthCallbackScreen-BPYlggFo.js → HubSpotOAuthCallbackScreen-qemWA0jI.js} +1 -1
  23. package/dist/assets/{InboxNotificationsProvider-DLtCSJ1e.js → InboxNotificationsProvider-7eYmgI1F.js} +1 -1
  24. package/dist/assets/{InvoicingRoutes-C6KEoVXP.js → InvoicingRoutes-DOUUybBE.js} +1 -1
  25. package/dist/assets/{MagicLinkRoutes-BUBt7N4B.js → MagicLinkRoutes-CTs6OYkH.js} +1 -1
  26. package/dist/assets/{MagicLinkSignInScreen-DthxXwoL.js → MagicLinkSignInScreen-CDEl_Ic_.js} +1 -1
  27. package/dist/assets/{MobileAppDrawer-AMYN8Gjf.js → MobileAppDrawer-BMvh-RAa.js} +1 -1
  28. package/dist/assets/NotFoundScreen-Wkt8x0Ja.js +1 -0
  29. package/dist/assets/{NotificationRoutes-C5bjkJ9x.js → NotificationRoutes-BF1aTPUh.js} +1 -1
  30. package/dist/assets/{OAuthConsentScreen-GS4LIEZY.js → OAuthConsentScreen-8oM_ijmg.js} +1 -1
  31. package/dist/assets/{PandLWithForecastRoutes-1JEKWI4D.js → PandLWithForecastRoutes-DvwOSp2G.js} +1 -1
  32. package/dist/assets/{PaymentLinkScreen-klZ4RFzW.js → PaymentLinkScreen-D0VzMTpF.js} +1 -1
  33. package/dist/assets/{PeopleRoutes-D-8614Cf.js → PeopleRoutes-CMx_k0hr.js} +1 -1
  34. package/dist/assets/{PerformanceRoutes-CkfRYNq2.js → PerformanceRoutes-OuxZJbf_.js} +1 -1
  35. package/dist/assets/{Preview-C2GPv-G6.js → Preview-Dkzm36JB.js} +1 -1
  36. package/dist/assets/{QBOConnectionScreen-CgDmO8dD.js → QBOConnectionScreen-Cxvr0UGn.js} +1 -1
  37. package/dist/assets/{ReimbursementApprovalRoutes-DMPKN0xJ.js → ReimbursementApprovalRoutes-ChPdj5ky.js} +1 -1
  38. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-YsjpcW9c.js → ReimbursementApprovalRuleDetailScreen-kIivYyt0.js} +1 -1
  39. package/dist/assets/{ReimbursementRoutes-DXo4NvYM.js → ReimbursementRoutes-DlTMcw_k.js} +1 -1
  40. package/dist/assets/{ReportsRoutes-C5btuAgR.js → ReportsRoutes-DUvTlB32.js} +1 -1
  41. package/dist/assets/{RewardsRoutes-6WcZW5R0.js → RewardsRoutes-CANJzBfw.js} +1 -1
  42. package/dist/assets/{ScreenRoutes-u4rkodoe.js → ScreenRoutes-B2jpCRd2.js} +2 -2
  43. package/dist/assets/{SettingsRoutes-DNaJE00d.js → SettingsRoutes-D405mYiE.js} +1 -1
  44. package/dist/assets/{SetupPagesScreen-BSF8vuHb.js → SetupPagesScreen-o-PhLBXH.js} +1 -1
  45. package/dist/assets/{SignInScreen-C0k1UkVX.js → SignInScreen-CsdAWM0a.js} +1 -1
  46. package/dist/assets/{SignOutScreen-Ciim2wTk.js → SignOutScreen-DjO_hTaY.js} +1 -1
  47. package/dist/assets/{TaskListScreen-t-HxAdY-.js → TaskListScreen-D5rs0HLr.js} +1 -1
  48. package/dist/assets/{TaskRoutes-B3g-TdsM.js → TaskRoutes-IWzYaX-F.js} +1 -1
  49. package/dist/assets/TransactionDetailRoutes-DExFe-03.js +1 -0
  50. package/dist/assets/{TransactionDetailScreen-CfA-Ugfo.js → TransactionDetailScreen-7v-3l9dA.js} +1 -1
  51. package/dist/assets/{TransactionListRoutes-B_3YnN8q.js → TransactionListRoutes-hxVuwPcb.js} +1 -1
  52. package/dist/assets/{TreasuryRoutes-CjNKU5ec.js → TreasuryRoutes-C4GA1Tde.js} +1 -1
  53. package/dist/assets/{VendorsRoutes-DGaauSBm.js → VendorsRoutes-DLC5o9yJ.js} +1 -1
  54. package/dist/assets/{WiseConfirmationScreen-rPMoKWiH.js → WiseConfirmationScreen-BJNaaQrG.js} +1 -1
  55. package/dist/assets/{ZeniAccountRoutes-CEMKZQ-X.js → ZeniAccountRoutes-CPdfqL23.js} +1 -1
  56. package/dist/assets/{ZeniAccountStatementScreen-BhiffvFR.js → ZeniAccountStatementScreen-Butd8DWu.js} +1 -1
  57. package/dist/assets/{accountMappingHelper-ChrGBc2n.js → accountMappingHelper-DsN6SM7a.js} +1 -1
  58. package/dist/assets/{analytics-WNjEvDwJ.js → analytics-NBT5BH2R.js} +1 -1
  59. package/dist/assets/{analyticsHelper-BMvVz4OD.js → analyticsHelper-Bw6Cjeqd.js} +1 -1
  60. package/dist/assets/{core-BaXck2Yj.js → core-Dlma5MIa.js} +1 -1
  61. package/dist/assets/{decodeURIComponentSafe-B0jtUms3.js → decodeURIComponentSafe-MgEJs-XP.js} +1 -1
  62. package/dist/assets/{dnd-Cyb1SC5Y.js → dnd-BgBEAfSC.js} +1 -1
  63. package/dist/assets/{empty-H7TtSYmV.js → empty-BRn9rxGR.js} +1 -1
  64. package/dist/assets/{empty-M_3v5JZA.js → empty-DpC6uPKD.js} +1 -1
  65. package/dist/assets/{emptyVideoElement-BEqLDot8.js → emptyVideoElement-BpruyOrt.js} +1 -1
  66. package/dist/assets/{epic-sIgFMFjP.js → epic-TdjWG3DC.js} +1 -1
  67. package/dist/assets/{expenseAutomationHelper-DlEi6coP.js → expenseAutomationHelper-BpaM_jjL.js} +1 -1
  68. package/dist/assets/{getLocaleForTenant-DEaI00lX.js → getLocaleForTenant-B0nO-Z7L.js} +1 -1
  69. package/dist/assets/{index-BmT_wdak.js → index-Blw4A66-.js} +8 -8
  70. package/dist/assets/{index-VZMRwvc1.js → index-BtQ2P-s4.js} +1 -1
  71. package/dist/assets/{index-DTuBENEN.js → index-CYHgs6V3.js} +1 -1
  72. package/dist/assets/{index-CS4lDeLL.js → index-CexFEAIL.js} +1 -1
  73. package/dist/assets/{index-DGxDcX9G.js → index-Cr8P80rT.js} +1 -1
  74. package/dist/assets/{index-V57vyw7U.js → index-DHUOQOTf.js} +1 -1
  75. package/dist/assets/{index-DtPBjgXd.js → index-YntXYqu4.js} +2 -2
  76. package/dist/assets/{index-Dx3kI9l2.js → index-ui_UfE_7.js} +1 -1
  77. package/dist/assets/{lexical-VH6dL15l.js → lexical-Cc-23sPJ.js} +1 -1
  78. package/dist/assets/{liveblocks-CM7ZQqxd.js → liveblocks-BD1fi6wA.js} +1 -1
  79. package/dist/assets/{lottie-DYRVCvl4.js → lottie-Dd5kLrRz.js} +1 -1
  80. package/dist/assets/{mui-CeNVlxCm.js → mui-DPmPgDDD.js} +1 -1
  81. package/dist/assets/{pathToGoBack-DfpWL1zC.js → pathToGoBack-C5NlBrdk.js} +1 -1
  82. package/dist/assets/{pdf-Dhhhum3V.js → pdf-BCsxh4ki.js} +3 -3
  83. package/dist/assets/{pdf-lib-BXvJUWv4.js → pdf-lib-BSghpPvP.js} +1 -1
  84. package/dist/assets/{plaid-D9ECXCuG.js → plaid-w5kSeMkL.js} +1 -1
  85. package/dist/assets/{pusher-uue_Yphj.js → pusher-D_NnYp1B.js} +1 -1
  86. package/dist/assets/{react-cHKJDlzC.js → react-BRcmo_so.js} +1 -1
  87. package/dist/assets/{react-CW6xsUDz.js → react-BYFmdCmG.js} +1 -1
  88. package/dist/assets/{react-MyBVZkJi.js → react-BiCIC8nJ.js} +1 -1
  89. package/dist/assets/{react-BX9WMcs9.js → react-CKnkKWiv.js} +1 -1
  90. package/dist/assets/{react-BquQQNXI.js → react-Co4WxHXe.js} +1 -1
  91. package/dist/assets/{react-Bsy3W-uL.js → react-wEOgqpw3.js} +1 -1
  92. package/dist/assets/{recharts-BKC_cH7h.js → recharts-WuCIKI4c.js} +1 -1
  93. package/dist/assets/{routePaths-jc2bzNg2.js → routePaths-1GgW-roh.js} +1 -1
  94. package/dist/assets/{sentry-Dh9UB4O6.js → sentry-C6D8WJ15.js} +1 -1
  95. package/dist/assets/{url-Cpedw1H4.js → url-7hMA9KrE.js} +1 -1
  96. package/dist/assets/{url-CV8DVrqd.js → url-BVCS53n5.js} +1 -1
  97. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-Ck3TknRq.js → useAiCfoDashboardSuggestedQuestionsChips-Cox0FTmj.js} +1 -1
  98. package/dist/assets/{useAskAiCfoHostNavButtonProps-fsQB3AjS.js → useAskAiCfoHostNavButtonProps-5qRN6gKs.js} +1 -1
  99. package/dist/assets/{useChargeCardPusherEvents-CioB6dpi.js → useChargeCardPusherEvents-Cu201ke6.js} +1 -1
  100. package/dist/assets/{useDeviceId-CilYhYRW.js → useDeviceId-p2IpPhWq.js} +1 -1
  101. package/dist/assets/{useEmailConnectResultRefresh-DfelAgkd.js → useEmailConnectResultRefresh-pFVkjSX_.js} +1 -1
  102. package/dist/assets/{useInitialThreadRequest-DOTaljn2.js → useInitialThreadRequest-Ddm4sao-.js} +1 -1
  103. package/dist/assets/{useTaskManagerAccess-LntCDDBS.js → useTaskManagerAccess-BKVtGCGL.js} +1 -1
  104. package/dist/assets/{utils-X6jrk5Hl.js → utils-Bv9LDtmr.js} +1 -1
  105. package/dist/assets/{withTransactionSidePanel-CSTE6dRA.js → withTransactionSidePanel-QyMR1bIP.js} +1 -1
  106. package/dist/assets/{zeni-epic-state-Bo1fQFWK.js → zeni-epic-state-2zvjmkUL.js} +3 -3
  107. package/dist/index.html +1 -1
  108. package/package.json +1 -1
  109. package/dist/assets/AddressRoutes-WhSb9kOA.js +0 -1
  110. package/dist/assets/CustomerOnboardingAuthScreen-WKQ_F3V-.js +0 -1
  111. package/dist/assets/NotFoundScreen-CbKfgA9a.js +0 -1
  112. package/dist/assets/TransactionDetailRoutes-ds3JOU2Z.js +0 -1
@@ -1,2 +1,2 @@
1
- import{h0 as S,fE as dP,h1 as A,h2 as y,h3 as v,h4 as De,fD as Kl,h5 as M,h6 as p,h7 as no,h8 as Yl,h9 as f,f_ as lP,ha as uP,hb as Hl,hc as F,hd as Ql,he as Wl,hf as pP,hg as mP,hh as yP,hi as ca,hj as Zl,hk as _P,hl as Xl,hm as W,hn as Ke,ho as le,hp as V,hq as hP,hr as _,hs as ut,ht as SP,hu as eu,hv as gP,hw as _0,hx as fP,hy as tu,hz as oo,hA as rs,hB as au,hC as vP,hD as oe,hE as IP,hF as bP,hG as ie,hH as EP,hI as PP,hJ as ru,hK as TP,hL as ar,hM as T,hN as AP,hO as su,hP as NP,hQ as OP,hR as nu,hS as CP,hT as xP,hU as ou,hV as UP,hW as kP,hX as iu,hY as be,hZ as BP,h_ as cu,h$ as du,i0 as DP,i1 as lu,i2 as uu,i3 as JP,i4 as pu,i5 as mu,i6 as io,i7 as wP,i8 as co,i9 as ss,ia as $P,gd as N,ib as yu,ic as xe,id as z,ie as lo,ig as da,ih as _u,ii as Q,ij as hu,ik as Y,il as RP,im as ot,io as Su,ip as gu,iq as ns,ir as MP,is as VP,it as fu,iu as LP,iv as FP,iw as uo,ix as vu,iy as qP,iz as jP,iA as Iu,iB as GP,iC as zP,iD as KP,iE as bu,iF as YP,iG as HP,iH as Eu,iI as QP,iJ as WP,iK as ZP,iL as XP,iM as Pu,fC as eT,iN as tT,iO as aT,iP as Tu,go as rT,iQ as j,gn as sT,gl as Au,iR as nT,iS as Ha,iT as Ue,iU as oT,iV as Nu,bE as ee,iW as iT,iX as Ou,iY as cT,iZ as dT,i_ as lT,i$ as uT,j0 as pT,j1 as mT,j2 as Cu,j3 as yT,j4 as _T,j5 as hT,j6 as xu,j7 as ST,j8 as gT,j9 as Uu,ja as fT,jb as vT,jc as IT,jd as ku,je as bT,jf as ET,jg as PT,jh as Bu,ji as TT,jj as AT,jk as Du,jl as NT,jm as OT,jn as Ju,jo as wu,jp as CT,jq as $u,gx as po,jr as xT,js as Ru,g7 as UT,jt as kT,ju as Mu,jv as BT,jw as DT,jx as JT,jy as Vu,jz as wT,jA as $T,jB as Lu,jC as RT,jD as os,jE as MT,jF as Fu,jG as VT,jH as qu,jI as ju,jJ as LT,jK as FT,jL as qT,jM as Gu,jN as mo,jO as jT,jP as zu,jQ as GT,jR as zT,jS as Ku,jT as yo,jU as re,jV as Yu,jW as KT,jX as Hu,jY as YT,jZ as Qu,j_ as HT,j$ as Wu,k0 as _o,k1 as QT,k2 as Zu,k3 as WT,k4 as ZT,k5 as Xu,k6 as XT,k7 as eA,k8 as ep,k9 as tA,ka as aA,kb as is,kc as tp,kd as ho,ke as Ot,kf as rA,kg as Ct,kh as he,ki as sA,kj as ap,kk as xt,kl as Ut,km as nA,kn as rp,ko as oA,kp as iA,kq as Je,kr as Ye,ks as sp,kt,ku as So,br as me,kv as cA,kw as la,kx as cs,ky as dA,kz as np,kA as rr,kB as lA,kC as it,kD as uA,kE as pA,kF as op,kG as mA,kH as yA,kI as _A,kJ as hA,kK as SA,kL as ip,kM as gA,kN as fA,kO as vA,kP as cp,kQ as IA,kR as bA,kS as EA,kT as dp,kU as go,kV as ua,kW as lp,kX as up,kY as ae,kZ as PA,k_ as pp,k$ as fo,l0 as TA,l1 as mp,l2 as AA,l3 as ds,l4 as NA,l5 as yp,l6 as OA,l7 as vo,l8 as Io,l9 as CA,la as _p,lb as xA,lc as bo,ld as UA,le as hp,lf as Eo,lg as Po,lh as kA,li as Sp,lj as To,lk as Bt,ll as BA,lm as Dt,ln as Fe,lo as DA,lp as gp,lq as Jt,lr as JA,ls as fp,lt as wA,lu as Ao,lv as vp,lw as $A,lx as RA,ly as Ip,lz as No,lA as bp,lB as MA,lC as Ep,lD as se,lE as Le,lF as pt,lG as Pp,lH as Tp,lI as VA,lJ as Oe,lK as ls,lL as Ze,lM as Qr,lN as Xa,lO as Wr,lP as LA,lQ as pa,lR as At,lS as FA,cD as Oo,lT as qA,lU as Co,lV as Ap,lW as jA,lX as GA,lY as us,lZ as sr,l_ as ps,l$ as Np,m0 as ms,m1 as zA,m2 as He,m3 as ct,m4 as ys,m5 as wt,m6 as KA,m7 as YA,m8 as HA,m9 as QA,ma as h0,mb as dt,mc as mt,md as ve,me as Op,mf as _s,mg as nr,mh as or,mi as xo,mj as Cp,mk as ma,ml as qe,mm as xp,mn as hs,gS as Te,mo as Ne,mp as Up,mq as es,mr as Uo,ms as ya,mt as Ss,mu as WA,mv as lt,bQ as eo,mw as aa,mx as ir,my as kp,mz as ZA,mA as XA,mB as Bp,mC as eN,mD as tN,mE as ko,mF as Bo,mG as Do,mH as gs,mI as Jo,mJ as aN,mK as Dp,mL as Jp,mM as wp,mN as rN,mO as wo,mP as sN,mQ as $o,mR as nN,mS as $p,mT as Ro,mU as Rp,mV as oN,mW as Mp,mX as Vp,mY as iN,mZ as cN,m_ as dN,m$ as lN,n0 as Lp,n1 as uN,n2 as pN,n3 as mN,n4 as Fp,n5 as qp,n6 as yN,n7 as _N,n8 as jp,n9 as Gp,na as hN,nb as zp,nc as Kp,nd as SN,ne as Yp,nf as gN,ng as fN,nh as Hp,ni as vN,c9 as Qp,nj as Wp,nk as IN,nl as Zp,nm as Xp,nn as bN,no as Mo,np as EN,nq as PN,nr as TN,ns as em,nt as AN,nu as tm,nv as fs,nw as Vo,nx as NN,ny as ze,nz as Zr,nA as am,nB as ON,nC as CN,nD as rm,nE as xN,nF as Lo,nG as sm,nH as nm,nI as UN,nJ as om,nK as kN,nL as BN,nM as im,nN as cm,nO as Fo,nP as DN,nQ as dm,nR as JN,nS as cr,nT as lm,g as X,gF as dr,nU as lr,nV as _a,nW as ha,nX as ur,nY as Sa,nZ as um,n_ as vs,n$ as ga,o0 as wN,o1 as pm,o2 as mm,o3 as yt,o4 as $N,o5 as RN,o6 as ym,o7 as MN,o8 as _m,o9 as hm,oa as Sm,ob as VN,oc as LN,od as FN,oe as gm,of as qN,og as jN,oh as GN,oi as fm,oj as zN,ok as vm,ol as KN,om as Im,on as Fl,oo as _t,op as bm,oq as YN,or as HN,os as Em,ot as QN,ou as Pm,ov as WN,ow as fa,ox as je,oy as pr,oz as mr,oA as yr,oB as _r,oC as hr,oD as Tm,oE as qo,oF as ZN,oG as XN,oH as Am,oI as eO,oJ as tO,oK as aO,oL as rO,oM as sO,oN as nO,oO as Nm,oP as oO,oQ as Om,oR as Cm,oS as iO,oT as xm,oU as cO,oV as jo,oW as dO,oX as lO,oY as uO,oZ as pO,o_ as Is,o$ as va,p0 as Be,p1 as bs,p2 as mO,p3 as yO,p4 as _O,p5 as hO,p6 as wl,p7 as $l,p8 as SO,p9 as gO,pa as fO,pb as Um,pc as vO,pd as IO,pe as bO,pf as km,pg as EO,ph as Bm,pi as PO,pj as Dm,pk as TO,pl as Go,pm as AO,pn as NO,po as OO,pp as Jm,pq as CO,pr as xO,ps as UO,pt as wm,pu as kO,fB as H,c7 as BO,bq as DO,pv as JO,pw as Ia,px as Es,py as Ps,pz as Ts,pA as zo,pB as Ko,pC as Yo,pD as Ho,pE as Qo,pF as Wo,pG as et,pH as $m,pI as Rm,pJ as Mm,pK as Ee,pL as As,pM as wO,pN as Vm,pO as $O,pP as RO,pQ as Lm,pR as MO,pS as $t,pT as VO,pU as LO,pV as FO,pW as qO,pX as Fm,pY as jO,pZ as ba,p_ as qm,p$ as jm,q0 as Sr,q1 as GO,q2 as Gm,q3 as Zo,gM as Rt,q4 as zO,q5 as Ea,q6 as Ns,q7 as zm,q8 as KO,q9 as Km,qa as YO,qb as Ym,qc as Xo,qd as ei,qe as gr,qf as Hm,qg as Qm,qh as HO,qi as Os,qj as Re,qk as QO,ql as WO,qm as Wm,qn as ZO,qo as Zm,qp as Xm,qq as XO,qr as eC,qs as ey,gP as tC,qt as Cs,qu as aC,qv as ty,qw as xs,gN as rC,qx as sC,qy as nC,qz as oC,qA as iC,qB as ay,qC as cC,qD as ti,bM as Us,qE as dC,qF as lC,qG as ry,qH as uC,qI as pC,qJ as mC,qK as yC,qL as _C,qM as ht,qN as sy,qO as ny,qP as oy,qQ as iy,qR as hC,qS as SC,qT as ra,qU as gC,qV as fC,qW as ai,qX as vC,qY as IC,qZ as bC,q_ as ge,q$ as fr,r0 as vr,r1 as ks,r2 as Pa,r3 as cy,r4 as EC,r5 as PC,r6 as TC,r7 as AC,r8 as dy,r9 as NC,ra as OC,rb as ly,rc as CC,rd as uy,re as xC,rf as py,rg as my,rh as UC,ri as yy,rj as _y,rk as kC,rl as ri,rm as BC,rn as Qa,ro as Ir,rp as DC,rq as JC,rr as tr,rs as St,rt as hy,ru as br,rv as Ta,rw as wC,rx as Sy,gV as gt,ry as $C,rz as RC,rA as gy,rB as MC,rC as ft,rD as VC,rE as fy,rF as vy,rG as LC,rH as FC,rI as qC,rJ as Iy,rK as jC,rL as by,rM as GC,rN as zC,rO as KC,rP as Ey,rQ as Bs,rR as YC,rS as HC,rT as QC,rU as si,rV as vt,rW as ni,rX as WC,rY as Py,rZ as Ty,r_ as ZC,r$ as oi,s0 as XC,s1 as ex,s2 as tx,s3 as ax,s4 as rx,s5 as sx,s6 as nx,s7 as ox,s8 as ix,s9 as cx,sa as dx,sb as Ay,sc as lx,sd as ux,se as px,sf as Ny,sg as mx,sh as Gn,si as Aa,sj as Ds,sk as Er,sl as Na,sm as yx,sn as ii,f6 as _x,so as hx,sp as Sx,sq as gx,sr as Oy,ss as ci,st as di,su as Cy,sv as zn,sw as Kn,sx as Ce,sy as Yn,sz as Pr,sA as Js,sB as xy,sC as Uy,sD as ky,sE as Tr,sF as fx,sG as li,sH as vx,sI as By,sJ as Ix,sK as Dy,sL as Jy,sM as Ar,sN as bx,sO as S0,sP as Ex,sQ as Px,sR as Tx,sS as Ax,sT as wy,sU as Nx,sV as Ox,sW as Oa,sX as Cx,sY as xx,fw as ui,sZ as Ux,s_ as kx,s$ as $y,t0 as Bx,gK as pi,t1 as Dx,t2 as Ry,t3 as My,t4 as Jx,t5 as wx,t6 as ws,t7 as Vy,t8 as Ly,t9 as mi,ta as $s,tb as Fy,tc as Rs,td as $x,te as Rx,tf as yi,tg as Ms,th as _i,ti as qy,tj as Vs,tk as Mx,tl as Vx,tm as Lx,tn as Fx,to as jy,tp as Gy,tq as Ls,tr as zy,dh as as,ts as g0,tt as Hn,tu as f0,tv as v0,tw as I0,tx as b0,dY as qx,ty as jx,tz as Ky,tA as Yy,tB as hi,cl as E0,tC as P0,tD as T0,tE as A0,di as N0,tF as O0,tG as C0,tH as x0,tI as U0,tJ as Gx,tK as zx,tL as Kx,tM as Yx,tN as Hy,tO as Hx,tP as Qx,tQ as Qy,tR as Wx,tS as Zx,tT as Wy,tU as Xx,tV as eU,tW as Zy,tX as tU,tY as aU,tZ as Xy,t_ as e_,t$ as rU,u0 as t_,u1 as sU,u2 as nU,u3 as a_,u4 as oU,u5 as iU,u6 as Si,u7 as cU,u8 as dU,u9 as lU,ua as Mt,ub as Fs,uc as qs,ud as uU,ue as Nr,uf as ql,ba as ts,ug as pU,uh as Qn,ui as It,uj as mU,uk as yU,ul as r_,um as _U,un as hU,uo as s_,up as SU,uq as gU,ur as n_,us as fU,ut as o_,uu as i_,uv as vU,uw as Pe,ux as IU,uy as bU,uz as c_,uA as tt,uB as at,uC as d_,uD as EU,uE as l_,uF as js,uG as Gs,uH as PU,uI as u_,uJ as TU,uK as AU,uL as NU,uM as zs,uN as OU,uO as p_,uP as CU,uQ as Ca,uR as Or,uS as xU,uT as UU,uU as m_,uV as kU,uW as Ks,uX as Cr,uY as gi,uZ as Vt,u_ as BU,u$ as DU,v0 as y_,v1 as JU,v2 as wU,v3 as __,v4 as $U,v5 as RU,v6 as Ys,v7 as h_,v8 as MU,v9 as VU,va as S_,vb as k0,vc as LU,vd as g_,ve as FU,vf as qU,vg as f_,vh as jU,vi as B0,vj as v_,vk as D0,vl as GU,vm as I_,vn as zU,vo as KU,vp as YU,vq as HU,vr as QU,vs as b_,vt as WU,vu as ZU,vv as E_,vw as xr,vx as P_,vy as T_,vz as XU,vA as Ur,vB as A_,vC as N_,vD as ek,vE as tk,vF as O_,vG as ak,vH as C_,vI as x_,vJ as rk,vK as U_,dP as sk,dO as nk,vL as ok,vM as fi,vN as ik,vO as ck,vP as dk,vQ as lk,vR as uk,dQ as pk,vS as k_,vT as B_,vU as D_,vV as mk,vW as yk,vX as _k,vY as J_,vZ as hk,v_ as w_,v$ as Sk,w0 as gk,w1 as $_,w2 as fk,w3 as vk,w4 as Ik,w5 as bk,w6 as Ek,w7 as R_,w8 as vi,w9 as Ii,wa as bi,wb as M_,wc as Pk,wd as Ei,we as V_,wf as L_,wg as nt,wh as Tk,wi as F_,wj as Ak,wk as Hs,wl as q_,wm as Nk,wn as Ok,wo as Ck,wp as j_,wq as xk,cW as Uk,wr as Pi,ws as xa,wt as Ua,wu as Ti,wv as G_,ww as kk,wx as Bk,wy as Dk,wz as kr,wA as Jk,wB as wk,wC as $k,wD as z_,cX as Ai,wE as Rk,wF as Mk,wG as Vk,wH as Qs,wI as K_,wJ as Y_,wK as Lk,wL as Fk,wM as qk,cY as jk,wN as Br,wO as Gk,wP as H_,wQ as zk,wR as Kk,wS as Q_,wT as Ws,wU as Yk,wV as W_,wW as Hk,wX as Z_,wY as X_,wZ as Qk,w_ as Wk,w$ as eh,x0 as Zk,x1 as th,x2 as Xk,x3 as eB,x4 as ah,x5 as tB,x6 as rh,x7 as aB,x8 as rB,x9 as sh,xa as sB,xb as nh,xc as nB,xd as oB,xe as Ni,xf as oh,xg as iB,xh as cB,xi as ih,xj as ch,xk as dB,xl as lB,xm as dh,xn as lh,xo as uB,xp as uh,xq as ph,xr as pB,xs as mh,xt as mB,xu as yh,xv as yB,xw as _h,xx as _B,xy as hh,xz as hB,xA as Sh,xB as Oi,xC as SB,xD as gh,xE as gB,xF as fh,xG as vh,xH as fB,xI as Ih,xJ as vB,xK as IB,xL as bh,xM as Eh,xN as bB,xO as Ph,xP as Th,xQ as EB,xR as Ah,xS as PB,xT as Nh,xU as TB,xV as Oh,xW as Ch,xX as AB,xY as xh,xZ as NB,x_ as Uh,x$ as kh,y0 as Bh,y1 as Dh,y2 as OB,y3 as CB,y4 as Ci,y5 as xB,y6 as Jh,y7 as UB,y8 as wh,y9 as kB,ya as $h,yb as BB,yc as Rh,yd as Mh,ye as DB,yf as Vh,yg as xi,yh as JB,yi as Lh,yj as wB,yk as $B,yl as Fh,ym as RB,yn as MB,yo as qh,yp as jh,yq as VB,yr as Gh,ys as LB,yt as zh,yu as FB,yv as qB,yw as Zs,yx as jB,yy as Kh,yz as GB,yA as zB,yB as Yh,yC as Hh,yD as KB,yE as Qh,yF as YB,yG as HB,yH as QB,yI as WB,yJ as ZB,yK as Wh,yL as XB,yM as eD,yN as Zh,yO as Xs,yP as tD,yQ as aD,yR as rD,yS as Xh,yT as en,yU as sD,yV as eS,yW as tS,yX as aS,yY as rS,yZ as tn,y_ as nD,y$ as oD,z0 as iD,z1 as an,z2 as cD,z3 as dD,z4 as lD,z5 as uD,z6 as pD,z7 as sS,z8 as mD,z9 as Ui,za as nS,zb as oS,zc as yD,zd as ki,ze as Bi,zf as Dr,zg as ka,zh as Ba,zi as _D,zj as iS,zk as Lt,zl as hD,zm as cS,zn as Ft,zo as SD,zp as dS,zq as lS,zr as gD,zs as uS,zt as fD,zu as vD,zv as ID,zw as pS,zx as mS,zy as bD,zz as ED,zA as yS,zB as _S,zC as PD,zD as TD,zE as hS,zF as Di,zG as Ji,zH as rn,zI as SS,zJ as wi,zK as AD,zL as $i,zM as Ri,zN as gS,zO as ND,zP as fS,zQ as OD,zR as vS,zS as CD,zT as xD,zU as IS,zV as UD,zW as kD,zX as Mi,zY as bS,zZ as BD,fY as bt,z_ as ES,z$ as PS,A0 as TS,A1 as Vi,A2 as DD,dV as JD,de as wD,A3 as $D,dU as RD,A4 as MD,A5 as VD,A6 as LD,A7 as AS,A8 as FD,A9 as qD,Aa as jD,Ab as GD,Ac as zD,Ad as NS,Ae as KD,Af as YD,Ag as OS,Ah as HD,Ai as QD,Aj as CS,Ak as WD,Al as ZD,Am as xS,An as XD,bc as eJ,Ao as tJ,Ap as US,Aq as aJ,Ar as rJ,As as kS,At as sJ,Au as nJ,Av as BS,Aw as oJ,Ax as iJ,Ay as DS,Az as Li,AA as JS,AB as sn,AC as wS,AD as Se,AE as $S,AF as cJ,AG as RS,AH as dJ,AI as lJ,AJ as MS,AK as uJ,AL as pJ,AM as VS,AN as mJ,AO as Da,AP as we,AQ as yJ,AR as _J,AS as LS,v as J0,bw as to,AT as hJ,AU as SJ,AV as Fi,AW as gJ,AX as FS,AY as qS,AZ as jS,A_ as fJ,A$ as vJ,B0 as IJ,B1 as qi,B2 as bJ,B3 as EJ,B4 as PJ,B5 as TJ,B6 as AJ,B7 as NJ,B8 as GS,B9 as OJ,Ba as CJ,Bb as zS,Bc as xJ,Bd as UJ,Be as KS,Bf as kJ,Bg as BJ,Bh as YS,Bi as DJ,Bj as JJ,Bk as HS,Bl as QS,Bm as WS,Bn as wJ,Bo as Ja,Bp as wa,Bq as $J,Br as ZS,Bs as Jr,Bt as ji,Bu as RJ,Bv as XS,Bw as eg,Bx as MJ,By as tg,Bz as VJ,BA as LJ,BB as ag,BC as rg,BD as qt,BE as FJ,BF as sg,BG as jt,BH as qJ,BI as ng,BJ as og,BK as jJ,BL as ig,BM as GJ,BN as w0,BO as zJ,BP as KJ,BQ as YJ,BR as cg,BS as HJ,BT as QJ,BU as dg,BV as WJ,f$ as $e,BW as Gi,BX as ZJ,BY as lg,BZ as XJ,B_ as ew,B$ as zi,C0 as jl,C1 as tw,C2 as aw,C3 as ug,C4 as nn,C5 as rw,C6 as sw,C7 as nw,C8 as ow,C9 as pg,er as iw,Ca as cw,Cb as dw,Cc as mg,Cd as lw,Ce as yg,Cf as Gt,Cg as uw,Ch as _g,Ci as zt,Cj as pw,Ck as hg,Cl as Sg,Cm as gg,Cn as fg,Co as vg,Cp as mw,Cq as Ig,Cr as yw,Cs as bg,Ct as wr,Cu as $r,Cv as Eg,Cw as Pg,Cx as $a,Cy as _w,Cz as hw,CA as Sw,CB as gw,CC as Tg,CD as Ag,CE as fw,CF as vw,CG as Ki,CH as Iw,CI as bw,CJ as Ew,CK as Ng,CL as Pw,CM as Og,CN as Tw,CO as Aw,CP as on,CQ as Nw,CR as Ow,CS as Cw,CT as xw,CU as Uw,CV as Cg,CW as kw,CX as xg,CY as Bw,CZ as Dw,C_ as Jw,C$ as Ug,D0 as kg,D1 as ww,D2 as $w,D3 as Rw,D4 as Mw,D5 as Vw,D6 as Lw,D7 as Fw,D8 as qw,D9 as jw,Da as Gw,Db as Yi,Dc as Bg,Dd as Dg,De as Jg,Df as wg,Dg as $g,Dh as Rg,Di as zw,Dj as Kw,Dk as Yw,Dl as Hw,Dm as Qw,Dn as Ww,Do as Zw,Dp as Xw,Dq as e$,Dr as t$,Ds as a$,Dt as r$,Du as Mg,Dv as Vg,Dw as Lg,Dx as Fg,Dy as s$,eK as n$,ez as o$,Dz as i$,DA as qg,DB as jg,DC as Gg,DD as c$,DE as Ra,DF as Ma,DG as d$,DH as Kt,DI as zg,DJ as l$,DK as Kg,DL as Yt,DM as u$,DN as Yg,DO as p$,DP as Hg,DQ as m$,DR as y$,DS as Qg,DT as sa,DU as $0,DV as R0,DW as _$,DX as Hi,DY as Va,bH as Wa,e3 as Wg,DZ as h$,D_ as S$,D$ as g$,E0 as cn,E1 as f$,E2 as v$,E3 as I$,E4 as Qi,E5 as b$,E6 as Zg,E7 as Wi,E8 as Xg,E9 as Zi,Ea as ef,Eb as E$,Ec as Rr,Ed as Xi,Ee as P$,Ef as T$,Eg as A$,Eh as dn,Ei as ln,Ej as N$,Ek as O$,El as C$,Em as tf,En as x$,Eo as un,Ep as U$,Eq as ec,Er as k$,Es as B$,Et as tc,Eu as af,Ev as Mr,Ew as ac,Ex as D$,Ey as J$,Ez as Vr,EA as rc,EB as w$,EC as $$,ED as R$,EE as M$,EF as V$,EG as sc,EH as L$,EI as F$,EJ as rf,EK as sf,EL as nc,EM as q$,EN as nf,EO as j$,EP as G$,EQ as of,ER as oc,ES as z$,ET as K$,EU as cf,EV as Y$,EW as H$,EX as Q$,EY as ic,EZ as W$,E_ as df,E$ as Z$,F0 as Ge,F1 as ke,F2 as X$,F3 as cc,F4 as lf,F5 as uf,F6 as eR,F7 as tR,F8 as pf,F9 as aR,Fa as mf,Fb as rR,Fc as sR,Fd as nR,Fe as yf,Ff as oR,Fg as _f,Fh as iR,Fi as cR,Fj as dR,Fk as hf,Fl as lR,Fm as uR,Fn as Sf,Fo as pR,Fp as mR,Fq as gf,gE as ff,Fr as vf,Fs as yR,Ft as _R,Fu as If,Fv as hR,Fw as bf,Fx as SR,Fy as gR,Fz as Ef,FA as fR,FB as vR,FC as Pf,FD as IR,FE as bR,FF as Tf,FG as ER,FH as dc,FI as PR,FJ as TR,FK as AR,FL as Af,FM as Nf,FN as NR,FO as OR,FP as Of,FQ as CR,FR as Et,FS as xR,FT as Cf,FU as UR,FV as pn,FW as xf,FX as lc,FY as Uf,FZ as mn,F_ as kR,F$ as uc,G0 as pc,G1 as kf,G2 as Lr,G3 as yn,G4 as mc,G5 as Bf,G6 as Qe,G7 as We,G8 as yc,G9 as _c,Ga as Df,Gb as hc,Gc as BR,Gd as DR,Ge as Jf,Gf as JR,Gg as Me,Gh as La,Gi as wR,Gj as wf,Gk as $R,Gl as Fr,Gm as Sc,Gn as RR,Go as gc,Gp as MR,Gq as $f,Gr as VR,Gs as Rf,Gt as LR,Gu as Mf,Gv as FR,Gw as qR,Gx as Vf,Gy as jR,Gz as fc,GA as Lf,GB as Ff,GC as vc,GD as qf,GE as jf,GF as Gf,GG as GR,GH as zf,GI as Kf,GJ as Yf,bI as Hf,GK as Qf,GL as Wf,GM as zR,GN as KR,GO as Zf,GP as YR,GQ as HR,GR as Xf,GS as QR,GT as ev,GU as rt,GV as Ht,GW as Qt,GX as tv,GY as WR,GZ as av,G_ as _n,G$ as ZR,H0 as XR,H1 as Ic,H2 as bc,H3 as Fa,H4 as e1,H5 as t1,H6 as Rl,H7 as a1,H8 as r1,H9 as rv,Ha as sv,Hb as hn,Hc as Ec,Hd as Pc,He as Tc,Hf as s1,Hg as Ac,Hh as n1,Hi as nv,Hj as o1,Hk as ov,Hl as Nc,Hm as Oc,Hn as Cc,Ho as M0,Hp as i1,Hq as V0,Hr as L0,Hs as c1,Ht as d1,bO as Gl,Hu as iv,Hv as Sn,Hw as xc,Hx as Uc,Hy as l1,Hz as u1,HA as p1,HB as cv,HC as dv,HD as m1,HE as y1,HF as _1,HG as h1,dM as S1,HH as g1,HI as F0,HJ as f1,HK as q0,cK as v1,HL as ao,HM as I1,HN as b1,HO as E1,HP as P1,HQ as T1,HR as A1,HS as kc,HT as N1,HU as O1,HV as C1,dL as lv,HW as x1,HX as U1,HY as Bc,HZ as k1,H_ as B1,H$ as gn,I0 as D1,I1 as J1,I2 as Dc,I3 as uv,I4 as pv,I5 as w1,I6 as mv,I7 as yv,I8 as _v,I9 as $1,Ia as R1,Ib as M1,Ic as hv,Id as Sv,Ie as V1,If as L1,Ig as Jc,Ih as F1,Ii as q1,Ij as j1,Ik as G1,Il as gv,Im as z1,In as K1,Io as Y1,Ip as fv,Iq as H1,dj as Q1,Ir as W1,Is as vv,It as Z1,Iu as X1,Iv,Iw as eM,Ix as wc,Iy as tM,Iz as aM,IA as bv,IB as rM,IC as $c,ID as sM,IE as nM,IF as oM,IG as Rc,IH as iM,II as Mc,IJ as cM,IK as fn,IL as dM,IM as lM,IN as uM,IO as Vc,IP as pM,IQ as mM,IR as yM,IS as _M,IT as hM,IU as Lc,IV as SM,IW as gM,fU as fM,fV as vM,IX as IM,fF as bM,IY as EM,IZ as PM,I_ as vn,I$ as TM,fZ as Ev,J0 as AM,J1 as Pv,J2 as NM,J3 as Tv,gw as Av,J4 as Nv,J5 as OM,J6 as CM,J7 as xM,J8 as UM,J9 as kM,Ja as Fc,Jb as BM,Jc as Ov,Jd as Wt,Je as DM,Jf as Cv,Jg as JM,Jh as qc,Ji as st,Jj as jc,Jk as In,Jl as wM,Jm as $M,Jn as Gc,g1 as Zt,Jo as qr,Jp as RM,Jq as MM,Jr as xv,Js as VM,Jt as LM,Ju as FM,Jv as Uv,Jw as qM,Jx as zc,Jy as jM,Jz as GM,JA as zM,JB as Kc,JC as KM,JD as YM,JE as Yc,JF as kv,JG as HM,JH as Hc,JI as QM,JJ as Qc,JK as WM,JL as Wc,JM as ZM,JN as Zc,JO as XM,JP as Xc,JQ as eV,JR as ed,JS as tV,JT as td,JU as aV,JV as ad,JW as qa,JX as jr,JY as rV,JZ as Bv,J_ as Dv,g0 as sV,J$ as rd,K0 as bn,K1 as Jv,K2 as nV,K3 as wv,K4 as oV,K5 as $v,K6 as iV,K7 as Rv,K8 as cV,K9 as sd,Ka as dV,Kb as lV,Kc as Mv,Kd as uV,Ke as pV,Kf as Vv,Kg as mV,Kh as nd,Ki as yV,Kj as od,Kk as _V,Kl as id,Km as cd,Kn as hV,Ko as SV,Kp as Lv,Kq as gV,Kr as Fv,Ks as fV,Kt as vV,Ku as IV,Kv as bV,Kw as En,Kx as EV,Ky as PV,Kz as TV,KA as Gr,KB as AV,KC as NV,KD as OV,KE as qv,KF as CV,KG as xV,KH as jv,KI as UV,KJ as kV,KK as Gv,KL as zv,KM as Kv,KN as BV,KO as DV,KP as Yv,KQ as JV,KR as Hv,KS as wV,fK as $V,KT as Qv,KU as Wv,KV as RV,KW as Pn,KX as MV,KY as VV,KZ as Zv,g2 as LV,K_ as FV,K$ as dd,L0 as qV,L1 as jV,L2 as GV,L3 as Xv,b_ as zV,L4 as KV,L5 as YV,L6 as HV,L7 as QV,L8 as WV,L9 as ZV,La as XV,Lb as eL,Lc as tL,Ld as ld,Le as aL,Lf as ud,Lg as eI,Lh as rL,Li as tI,Lj as sL,Lk as nL,Ll as aI,Lm as oL,Ln as iL,Lo as rI,Lp as cL,Lq as dL,Lr as sI,Ls as lL,Lt as uL,Lu as nI,Lv as pL,Lw as mL,Lx as oI,Ly as yL,Lz as _L,LA as hL,LB as SL,LC as gL,LD as fL,LE as iI,LF as vL,LG as pd,LH as cI,LI as IL,LJ as md,LK as bL,LL as ja,LM as yd,LN as _d,LO as EL,LP as hd,LQ as Tn,LR as Sd,LS as gd,LT as fd,LU as dI,LV as PL,LW as TL,LX as vd,LY as AL,LZ as lI,L_ as NL,L$ as OL,M0 as CL,M1 as xL,M2 as Id,M3 as UL,M4 as bd,M5 as uI,M6 as kL,M7 as Ed,M8 as pI,M9 as BL,Ma as DL,Mb as mI,Mc as JL,Md as wL,Me as yI,Mf as $L,Mg as An,Mh as _I,Mi as Pd,Mj as RL,Mk as Td,Ml as ML,Mm as hI,Mn as Nn,Mo as VL,Mp as LL,Mq as FL,Mr as qL,Ms as Ad,Mt as jL,Mu as GL,Mv as zL,Mw as SI,Mx as KL,My as YL,Mz as gI,MA as HL,MB as Nd,MC as fI,MD as vI,ME as Od,MF as II,MG as bI,MH as QL,MI as EI,MJ as PI,MK as WL,ML as ZL,MM as TI,MN as XL,MO as eF,MP as AI,MQ as tF,MR as NI,MS as Cd,MT as OI,MU as aF,MV as CI,MW as xI,MX as rF,MY as sF,MZ as nF,M_ as oF,M$ as UI,N0 as On,N1 as iF,N2 as cF,N3 as xd,N4 as Ud,N5 as Ga,N6 as dF,N7 as lF,N8 as uF,N9 as kI,Na as pF,Nb as kd,Nc as Bd,Nd as Dd,Ne as Jd,Nf as wd,Ng as $d,Nh as mF,Ni as BI,Nj as yF,Nk as DI,Nl as _F,Nm as JI,Nn as hF,No as SF,Np as wI,Nq as gF,Nr as $I,Ns as fF,Nt as RI,Nu as vF,Nv as MI,Nw as VI,Nx as IF,Ny as bF,Nz as LI,NA as EF,NB as Rd,NC as PF,ND as Md,NE as TF,NF as AF,NG as Vd,NH as NF,NI as Ld,NJ as OF,NK as Cn,NL as Xt,NM as zr,NN as xn,NO as Fd,NP as CF,NQ as FI,NR as xF,NS as qI,NT as UF,NU as qd,NV as kF,NW as jI,NX as BF,NY as DF,NZ as GI,N_ as JF,N$ as zI,O0 as wF,O1 as jd,O2 as KI,O3 as Un,O4 as YI,O5 as $F,O6 as HI,O7 as RF,O8 as MF,O9 as VF,Oa as QI,Ob as LF,Oc as Gd,Od as FF,Oe as zd,Of as qF,Og as jF,Oh as GF,Oi as WI,Oj as zF,Ok as ZI,Ol as XI,Om as KF,On as eb,Oo as YF,Op as tb,Oq as ab,Or as HF,Os as rb,Ot as sb,Ou as QF,Ov as WF,Ow as nb,Ox as ZF,Oy as ob,Oz as ib,OA as XF,OB as cb,OC as eq,OD as db,OE as lb,OF as tq,OG as aq,OH as ub,OI as rq,OJ as sq,OK as pb,OL as mb,OM as nq,ON as Kd,OO as kn,OP as oq,OQ as iq,OR as Ml,OS as cq,OT as dq,OU as Yd,OV as lq,OW as uq,OX as Hd,OY as pq,OZ as yb,O_ as mq,O$ as yq,P0 as _b,P1 as hb,P2 as _q,P3 as Sb,P4 as hq,P5 as Sq,P6 as gb,P7 as gq,P8 as Vl,P9 as ro,Pa as Nt,Pb as Za,Pc as fq,Pd as vq,Pe as Qd,Pf as fb,bD as so,Pg as Iq,Ph as Wd,Pi as bq,Pj as Eq,Pk as Pq,Pl as vb,Pm as Zd,Pn as Tq,Po as za,Pp as Ib,Pq as Aq,Pr as Xd,Ps as el,Pt as Nq,Pu as Oq,Pv as Cq,Pw as tl,Px as xq,Py as Uq,Pz as er,PA as kq,PB as Bq,PC as Dq,PD as bb,PE as Jq,PF as wq,PG as Eb,PH as Pb,PI as al,PJ as $q,PK as Rq,PL as Tb,PM as Mq,PN as Ab,PO as Vq,PP as rl,PQ as Nb,PR as Lq,PS as Fq,PT as qq,PU as jq,PV as Ob,PW as sl,PX as Gq,PY as Cb,PZ as zq,P_ as nl,P$ as Kq,Q0 as xb,Q1 as Ub,Q2 as Yq,Q3 as Hq,Q4 as Qq,Q5 as kb,Q6 as Wq,Q7 as Zq,Q8 as Xq,Q9 as Bb,Qa as ej,Qb as Db,Qc as tj,Qd as Jb,Qe as aj,Qf as rj,Qg as sj,Qh as wb,Qi as nj,Qj as oj,Qk as ij,Ql as cj,Qm as $b,Qn as dj,Qo as lj,Qp as Rb,Qq as uj,Qr as pj,Qs as mj,Qt as Mb,Qu as Ka,Qv as Vb,Qw as ol,Qx as Lb,Qy as Fb,Qz as Bn,QA as qb,QB as yj,QC as Dn,QD as _j,QE as hj,QF as Sj,QG as gj,QH as fj,QI as vj,QJ as Ij,QK as bj,QL as jb,QM as Gb,QN as zb,QO as Ej,QP as Kb,QQ as Yb,QR as Hb,QS as Pj,QT as Qb,QU as Wb,QV as Zb,QW as Tj,QX as Xb,QY as eE,QZ as tE,Q_ as Aj,Q$ as aE,R0 as Nj,R1 as rE,R2 as Oj,R3 as Cj,R4 as xj,R5 as Uj,R6 as sE,R7 as Jn,R8 as kj,R9 as Bj,Ra as j0,Rb as nE,Rc as Dj,Rd as Jj,Re as wj,Rf as $j,Rg as oE,Rh as Rj,Ri as Mj,Rj as iE,Rk as Vj,Rl as Lj,Rm as Fj,Rn as cE,Ro as qj,Rp as dE,Rq as jj,Rr as il,Rs as Gj,Rt as cl,Ru as lE,Rv as zj,Rw as uE,Rx as Kj,Ry as Yj,Rz as Hj,RA as dl,RB as Qj,RC as Wj,RD as Zj,RE as Xj,RF as eG,RG as tG,RH as pE,RI as aG,RJ as rG,RK as mE,RL as sG,RM as ll,RN as nG,RO as ul,RP as Kr,RQ as pl,RR as oG,RS as Ll,RT as iG,RU as cG,RV as yE,RW as _E,RX as dG,RY as ml,RZ as lG,R_ as uG,R$ as pG,S0 as mG,S1 as yG,S2 as hE,S3 as _G,S4 as hG,S5 as yl,S6 as SG,S7 as gG,S8 as _l,S9 as fG,Sa as vG,Sb as IG,Sc as SE,Sd as bG,Se as gE,Sf as EG,Sg as fE,Sh as PG,Si as hl,Sj as TG,Sk as AG,Sl as NG,Sm as OG,Sn as CG,So as xG,Sp as UG,Sq as kG,Sr as BG,Ss as DG,St as JG,Su as wG,Sv as $G,Sw as RG,Sx as MG,Sy as VG,Sz as LG,SA as FG,SB as qG,SC as jG,SD as GG,SE as zG,SF as KG,SG as YG,SH as HG,SI as QG,SJ as WG,SK as ZG,SL as XG,SM as ez,SN as tz,SO as az,SP as rz,SQ as sz,SR as nz,SS as oz,ST as iz,SU as cz}from"./zeni-epic-state-Bo1fQFWK.js";import"./sentry-Dh9UB4O6.js";import"./core-BaXck2Yj.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new s.Error().stack;i&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[i]="a721ee0c-3376-4414-93d0-62327eebee24",s._sentryDebugIdIdentifier="sentry-dbid-a721ee0c-3376-4414-93d0-62327eebee24")}catch{}})();const Sl=(s,i,r,t)=>{const e=[];return s!=null&&Object.keys(s).forEach((a=>{const n=i[a]?.nestedAccountId;n!=null?e.push({accountsViewParentID:{parentAccountId:_0(n),sectionId:r},accountMetadataPayload:i[a].accountMetadataPayload,accountBalancesPayload:s[a],classesViewParentID:t}):console.warn(`Account ${a} in Section ${r} is missing metadata.`)})),e},dz=(s,i,r,t,e)=>{s!=null&&Object.keys(s).forEach((a=>{const n=i[a];if(n!=null){const o=n.nestedAccountId;e.push({accountsViewParentID:{parentAccountId:_0(o),sectionId:r},accountMetadataPayload:n.accountMetadataPayload,accountBalancesPayload:s[a],projectsViewParentID:t})}else console.warn(`Account ${a} in Section ${r} Project ${t.projectId} is missing metadata.`)}))},lz=s=>{typeof window<"u"&&(window.location.href=s)},uz=s=>s.data?.skipped!=null&&s.data.skipped.length>0?s.data.skipped[0].reason:s.data?.error!=null&&s.data.error.length>0?s.data.error:s.status.message.length>0?s.status.message:"",pz=["private","tenant"],G0=s=>{return{macroId:s.macro_id,name:s.name,displayName:s.display_name,description:s.description,semver:s.semver,hasScripts:s.has_scripts===!0,isMine:s.is_mine===!0,isOwnedByTenant:s.is_owned_by_tenant===!0,updatedAt:s.updated_at??null,visibility:(i=s.visibility,pz.find((r=>r===i))??null)};var i},z0=s=>typeof s?.instructions=="string",gl=s=>z0(s)&&s.skill!=null,fl=s=>({skill:{...G0(s.skill),exampleHints:[]},instructions:s.instructions,instructionsCharCount:s.instructions_char_count??s.instructions.length,artifact:s.artifact??"",artifactTitle:s.artifact_title??""}),mz=s=>({version:s.version,semver:s.semver??null,displayName:s.display_name??null,updatedAt:s.updated_at??null,isActive:s.is_active===!0,isLatest:s.is_latest===!0,instructionsCharCount:s.instructions_char_count??0}),vE=s=>typeof s=="string"&&s.trim()!=="",yz=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return[];const i=Object.values(s).flatMap((r=>vE(r)?[r.trim()]:Array.isArray(r)?r.filter(vE).map((t=>t.trim())):[]));return Array.from(new Set(i))},_z=s=>({...G0(s),exampleHints:yz(s.parameter_hints)}),hz=(s,i)=>({action:s,audit_rule_group_ids:[i]}),Sz=s=>{switch(s){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}},gz=s=>{switch(s){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}},vl=(s,i)=>({bank_account_name:s.bankAccountName,bank_account_number:s.bankAccountNumber,bank_name:s.bankName,bank_routing_number_ach:i==="ach"?s.bankRoutingNumber:"",bank_routing_number_wire_transfer:i==="wire"?s.bankRoutingNumber:"",bank_account_type:s.bankAccountType}),IE=s=>({account_holder_name:s.bankAccountName,bank_swift_code:s.bankSwiftCode,bank_account_iban:s.bankAccountIban,bank_name:s.bankName,pi_type:"swift_code",account_source:""}),fz=s=>({type:s.type,processor_token:s.processor_token,payment_source_type:s.payment_source_type}),vz=s=>({payment_method_types:s}),Iz=s=>{switch(s){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}},bz=s=>{switch(s){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}},bE=s=>({vendorName:s.name,vendorCategory:s.accountId,vendorClass:s.classId,vendorOwner:s.ownerId,vendorId:s.id}),wn=(s,i,r)=>{const{contactState:t}=i,e={},a={},{documentIds:n}=s;n.forEach((d=>{e[d]=KA(i,d)})),n.forEach((d=>{a[d]=YA(i,d)}));const{recommendedAccount:o,recommendedClass:c}=HA(s.recommendations,s.accountId,s.classId);return{vendorName:s.name,bankAccountIds:s.bankAccountIds??[],paymentInstrumentIds:s.paymentInstrumentIds,vendorCategory:s.accountId,vendorClass:s.classId,vendorType:s.vendorType,vendorOwner:s.ownerId,vendorId:s.id,isVendor1099:s.isVendor1099,documentIds:s.documentIds,deleteFileStatusById:e,updateFileStatusById:a,countryCode:s.countryCode,currencyCode:s.vendorCurrencyCode,currencySymbol:s.vendorCurrencySymbol,contacts:r?.contacts!=null?r.contacts.map((d=>QA(d))):h0(t,s.contactIds??[]),recommendations:s.recommendations,fileIdsToBeDeleted:[],recommendedCategory:o,recommendedClass:c,isCategoryUpdateSelected:!1,isClassUpdateSelected:!1,isCategoryRecommendationPrefilled:o?.accountId===s.accountId,isClassRecommendationPrefilled:c?.classId===s.classId}},Il="agent_insights_subject",EE=(s,i,r)=>{const t={...s,...r,subject:i};return Il in t&&r?.[Il]==null&&i!=null&&i!==""&&(t[Il]=i),t},Ez=s=>{switch(s){case"taskName":return"name";case"dueDate":return"due_date";case"createdBy":return"created_by";case"name":return"company_name";default:return s}},Pz=s=>s.categories==null?[]:s.categories.map((i=>({field:i.field??"",operator:i.matchingOperator==="equal"?"is":"is_not",values:i.values.map((r=>String(r))),join:i.valuesCombinationOperator==="ALL"?"and":"or"}))),Tz=s=>{const i={};if(s.statusCode!=null&&(i.status_code=s.statusCode),s.companyGroupId!=null&&(i.company_group_id=s.companyGroupId),s.taxStatusCode!=null&&(i.tax_status_code=s.taxStatusCode),s.lastReportSentDate!=null&&(i.last_report_sent_date=s.lastReportSentDate.format("YYYY-MM-DD")),s.lastReportSentBusinessDay!=null&&(i.last_report_sent_business_day=s.lastReportSentBusinessDay),s.note!=null&&(i.note=s.note),s.users!=null&&(i.users=s.users.map((r=>({is_zeni:r.isZeni,user_id:r.userId,user_email:null,[`is_${r.role}`]:r.isSelected})))),s.customerSatisfaction!=null&&(s.customerSatisfaction.teamRating!=null||s.customerSatisfaction.customerRating!=null)){const r=s.customerSatisfaction;i.customer_satisfaction={},r.customerSatisfactionId!=null&&(i.customer_satisfaction.customer_satisfaction_id=r.customerSatisfactionId),r.customerRating!=null&&(i.customer_satisfaction.customer_rating_code=r.customerRating,i.customer_satisfaction.customer_note=r.customerNote),r.teamRating!=null&&(i.customer_satisfaction.team_rating_code=r.teamRating,i.customer_satisfaction.team_note=r.teamNote)}return i},Az={Employees:"employees",Customers:"customers","Physical office or facility":"physical_office","Banking relationships":"banking_relationships"};function Nz(s){return Az[s]??s}const Oz=s=>{const i={company_inc_type:s.typeOfInc,company_inc_state:s.stateOfInc};return s.incDate!=null&&(i.company_inc_date=s.incDate.format("YYYY-MM-DD")),i},Cz=s=>({tax_id:s.taxIdOrEIN,duns_id:s.dunsNumber,sic_code:s.sicCode,naics_code:s.naicsCode,taxes_filed_years:s.taxesFiledYears}),xz=(s,i)=>{const r=[];return s.fileId!=null&&r.push(s.fileId),i.fileId!=null&&r.push(i.fileId),{file_ids:r}},$n=s=>{const i={};return s.email!=null&&(i.email=s.email),s.firstName!=null&&(i.first_name=s.firstName),s.lastName!=null&&(i.last_name=s.lastName),s.phone!=null&&(i.phone=s.phone),s.isCompanyOfficer!=null&&(i.is_company_officer=s.isCompanyOfficer),s.isPrimaryContact!=null&&(i.is_primary_contact=s.isPrimaryContact),i};function bl(s){const i={};return s.forEach((r=>{const t=r.company_id,e=X(i,t,void 0);i[t]=[...e??[],r.subscription_id]})),i}function El(s){let i;return s.companyAddress!=null&&(i=Object.assign({},i,{company_address:Wn(s.companyAddress)})),s.registeredAddress!=null&&(i=Object.assign({},i,{company_registered_address:Wn(s.registeredAddress)})),s.companyOfficers.slice(0,Fl.length).sort(((r,t)=>r.user.createTime?.isAfter(t.user.createTime)===!0?1:-1)).forEach(((r,t)=>{const e=r.address,a=`officer_${t+1}_address`;e!=null&&(i=Object.assign({},i,{[a]:Wn(e)}))})),i}const Wn=s=>{const{updateTime:i,createTime:r,addressId:t,...e}=s;return e},PE=["company_address","company_registered_address",...Fl.map((s=>`officer_${s}_address`))];function Pl(){return[pO(),N({messageSection:"create_transfer_entry",messageText:"failed",type:"error"})]}function TE(s){return[yO(),_O(s),N({messageSection:"create_transfer_entry",messageText:"success",type:"success"})]}function AE(s){return Ha(0).pipe(y((()=>{const i=[hO()];return s!=null&&i.push(...(function(r){return[wl(Be(r)),$l(r),SO()]})(s)),_(i)})))}const Uz={transferEntryEligible:"transfer_accounts",creditCardOnlyEligible:"credit_card_transfer_accounts"},kz={transferEntryEligible:{is_only_include_transfer_accounts:!0},creditCardOnlyEligible:{is_include_only_credit_card_accounts:!0}};function NE(s){const i=s?.trim();return N(i!=null&&i!==""?{messageSection:"confirm_statement_mapping",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:i}]}:{messageSection:"confirm_statement_mapping",messageText:"failed",type:"error"})}function OE(s){switch(s){case"exclude":return"Excluding Transaction";case"reconcile":return"Reconciling";case"save_reconcile_for_later":return"Saving for Later"}}function CE(s){return s.filter((i=>i.is_checked_transaction===!0)).map((i=>i.transaction_id))}const Bz=s=>s.reduce(((i,r)=>{const t={memo:(e=r,e.recommended_action.recommended_transactions[0]?.transaction_memo??e.transaction_memo??""),categoryId:r.recommended_action.recommended_transactions[0]?.account_id??void 0,classId:r.recommended_action.recommended_transactions[0]?.class_id??void 0,vendor:r.recommended_action.recommended_transactions[0]?.merchant_id!=null&&r.recommended_action.recommended_transactions[0]?.merchant_name!=null?{id:r.recommended_action.recommended_transactions[0].merchant_id,name:r.recommended_action.recommended_transactions[0].merchant_name}:void 0};var e;return{...i,[r.transaction_id]:t}}),{}),Dz=s=>s.reduce(((i,r)=>{const t={memo:(e=r,e.recommendedAction.recommendedTransactions[0]?.memo??e.memo??""),categoryId:r.recommendedAction.recommendedTransactions[0]?.accountId??void 0,classId:r.recommendedAction.recommendedTransactions[0]?.classId??void 0,vendor:r.recommendedAction.recommendedTransactions[0]?.merchantId!=null&&r.recommendedAction.recommendedTransactions[0]?.merchantName!=null?{id:r.recommendedAction.recommendedTransactions[0].merchantId,name:r.recommendedAction.recommendedTransactions[0].merchantName}:void 0};var e;return{...i,[r.transactionId]:t}}),{});function Jz(s,i){return{amount:s.amount.amount,transaction_memo:s.memo,line_description:i.memo,transaction_date:s.transactionDate.format(re),transaction_direction:s.transactionDirection,transaction_id:s.transactionId,vendor_id:i.vendor?.id,vendor_name:i.vendor?.name,account_id:i.categoryId,accounting_class_id:i.classId,currency_code:s.amount.currencyCode}}const wz=(s,i,r,t)=>({account_type:t,amount:s.amount.amount,transaction_memo:r.memo,transaction_date:s.transactionDate.format(re),transaction_direction:s.transactionDirection,transaction_id:s.transactionId,linked_transaction_id:i?.bookTransactionId,linked_transaction_type:"bill",currency_code:s.amount.currencyCode,vendor_id:i?.merchantId,vendor_name:i?.merchantName}),$z=s=>s?.recommendedAction.action==="record_bill_payment"?"recon_transaction_match":"recon_transaction_categorize",xE=(s,i)=>{const{statementMeta:r,statementTransactions:t}=i,e=mC(r,s.statementMeta),a=s.statementTransactions?.deletedIds??[],n=new Set(t.filter((u=>u.statementTransactionId!==""&&!a.includes(u.statementTransactionId))).map((u=>u.statementTransactionId))),o=yC(t,e,n),c=[...new Set([...a,...o])],d=s.statementTransactions?.updated??[];if(c.length===a.length&&c.every((u=>a.includes(u))))return s;const l=new Set(c);return{...s,statementTransactions:{...s.statementTransactions,deletedIds:c,added:s.statementTransactions?.added??[],updated:d.filter((u=>u.statementTransactionId!=null&&!l.has(u.statementTransactionId)))}}};function UE(s,i,r){if(s.length===0)return{count:0,totalAmount:{amount:0,...r}};let t=0,e=ra(0);return s.forEach((a=>{a.transactionDirection===i&&(t+=1,e=e.plus(a.amount.amount))})),{count:t,totalAmount:{amount:parseFloat(e.toFixed(2)),...r}}}const Rz=(s,i)=>({action:CC(s),flux_analysis_entity_ids:i}),Mz="prepaid_expenses",Vz="fixed_assets",Lz="accrued_expenses",Zn="YYYY-MM",Fz=(s,i)=>{const{classListState:r,classState:t}=s,e=tr(t,r).classes.find((n=>n.labels?.includes("balance_sheet")===!0)),a=i.reverseNextMonth?{reverse_next_month:!0,expected_reversal_date:qz(i.serviceMonth).format(re)}:{reverse_next_month:!1};return{vendor_id:i.vendorId,vendor_name:i.vendorName,service_month:i.serviceMonth.format(Zn),amount:i.amount,memo:i.memo,je_debit_account_id:i.debitAccountId,je_credit_account_id:i.creditAccountId,...i.debitAccountName!=null?{je_debit_account_name:i.debitAccountName}:{},...i.creditAccountName!=null?{je_credit_account_name:i.creditAccountName}:{},...i.debitClassId!=null?{je_debit_accounting_class_id:i.debitClassId}:{},...i.debitClassName!=null?{je_debit_accounting_class_name:i.debitClassName}:{},...e!=null?{je_credit_accounting_class_id:e.classId,je_credit_accounting_class_name:e.className}:{},...a}},qz=s=>s.add(1,"month").startOf("month"),jz=(s,i)=>i!=null?i.amount:s.amount.amount,Gz=s=>({scheduled_journal_entry_id:s.scheduledJournalEntryID,je_schedule_id:s.jeScheduleID,...s.updatedVendor?.id!=null&&s.updatedVendor.id!==""?{updated_vendor_id:s.updatedVendor.id}:{},...s.updatedCategoryId!=null?{updated_debit_category_id:s.updatedCategoryId}:{},...s.updatedAccumulatedDepreciationCategoryID!=null?{updated_credit_category_id:s.updatedAccumulatedDepreciationCategoryID}:{},...s.updatedClassId!=null?{updated_debit_class_id:s.updatedClassId}:{}}),zz={missing_third_party_id:"This transaction is missing a QuickBooks reference and cannot be scheduled.",missing_vendor:"This transaction has no vendor and cannot be scheduled. Add a vendor to the transaction first."};function Tl(s){const i=s.expenseAutomationViewState.selectedPeriodByTenantId[H(s).tenantId];if(i==null)return[];const r=Re(i),t=ge(r.start),e=ge(r.end);return t==null||e==null?[]:[Qa({start:t,end:e},!0)]}function ea(s,i,r,t){return[sx({accrualId:i,status:t??f("Unexpected Error",r)}),N({messageSection:s,messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:r}]})]}function Al(s){const i=me().startOf("day"),r=i.subtract(s-1,"day");return{end:i.format(re),start:r.format(re)}}function kE(s,i){return s.length===0?F:_(s).pipe(y((r=>i.getJSON(`${i.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${r}`).pipe(y((t=>{if(!T(t)||t.data==null||!zn(t.data.status))return F;const e=[],a=Kn(t.data.files);return a.length>0&&e.push(Ce(a,(n=>n.transaction_id))),e.push(Gn(Yn(t.data,i.apiEndPoints.fileMicroServiceBaseUrl))),_(e)})),v((t=>(console.error(`Failed to fetch batch details for ${r}:`,f("Unexpected Error","Fetch batch details errored out: "+JSON.stringify(t))),p(S0({batchId:r}))))))),5))}const Ya="review";function Kz(s,i){const r={...s};for(const t of Object.keys(i))r[t]={...s[t],...i[t]};return r}const Yz=(s,i,r,t,e=!1,a,n)=>{const o=b0(r,i??n),c=s[o],d={recommendations:t,entityId:i===n?null:i,...r==="vendor"&&n!=null?{vendorName:n}:{}};s[o]=c==null?{entityType:r,isBulkUpdate:e,updatedEntityId:a,...d}:{...c,...d}},K0=(s,i,r)=>{if(i!=null&&r!=null)return{...i,min:r.min,max:r.max,reason:r.reason,type:r.type};if(i!=null){const{min:t,max:e}=v0(s);return{...i,min:t,max:e,reason:"",type:""}}},Y0=(s,i,r)=>{if(i!=null&&r!=null)return{...i,min:r.min,max:r.max,reason:r.reason,type:r.type};if(i!=null){const{min:t,max:e}=v0(s);return{...i,min:t,max:e,reason:"",type:""}}},Hz=(s,i,r,t)=>s!=null?{entityId:s.qboId??s.id,entityType:s.type,entityName:s.name}:i?.lineEntity!=null?{entityId:i.lineEntity.qboId??i.lineEntity.id,entityType:i.lineEntity.type,entityName:i.lineEntity.name}:t!=null&&t.id&&t.id!=null?{entityId:t.id,entityType:"customer"}:r!=null?{entityId:r.qboId??r.id??r.name,entityType:"vendor",entityName:r.name}:void 0,H0=(s,i)=>{const r=s.lines;if(i===!0&&(as(s)||s.type==="journal_entry"))return!0;let t=!1;return r?.forEach((e=>{if(e.type==="transaction_with_account_and_class_line"||e.type==="transaction_with_product_or_service_line"||e.type==="journal_entry_transaction_line"){const a=e;(a.isCategoryMiscategorized||a.isClassMiscategorized||g0(s.type)&&s.vendor==null||Hn(s.type)&&a.vendor==null&&a.customer==null)&&(t=!0)}})),t},Qz=(s,i,r)=>{const t={updatesByLineId:{}},e={},a={},n=H0(i,!0),o=((u,m)=>{const h=u.lines;let g=!1;return h?.forEach((I=>{I.type!=="transaction_with_account_and_class_line"&&I.type!=="transaction_with_product_or_service_line"&&I.type!=="journal_entry_transaction_line"||f0(m,I.account.qboId)&&(g=!0)})),g})(i,r);t.memo=s.memo;const c=s.selectedEntity;let d,l;return as(i)===!0&&c!=null&&c.type==="vendor"&&(t.vendorId=c.qboId),qx(i)===!0&&c!=null&&c.type==="customer"&&(t.customerId=c.qboId),i.lines?.forEach((u=>{if(u.type!=="transaction_with_account_and_class_line"&&u.type!=="transaction_with_product_or_service_line"&&u.type!=="journal_entry_transaction_line"||!(u.id in s.lineItemById))e[u.id]=u;else{const m=s.lineItemById[u.id].selectedEntityLine,h=Zz(c,s.lineItemById[u.id],s.vendorUpdates,s.customerUpdates,m),g=s.lineItemById[u.id];e[u.id]={lineDescription:g.lineDescription,class:g.class,account:g.account,project:g.project,recommendation:I0(g.recommendationsWithCOT)},u.type!=="journal_entry_transaction_line"&&u.platformLineDetailType!=="deposit_line_detail"||(e[u.id]={...e[u.id],vendor:m!=null&&m.type==="vendor"?g.vendor:void 0,customer:m!=null&&m.type==="customer"?g.customer:void 0});let I=!1,b=!1;const E=u;I=g.account?.qboId!==E.account.qboId&&!!g.account?.qboId,b=(g.class?.qboId!=null||E.class?.qboId!=null)&&g.class?.qboId!==E.class?.qboId;const P=K0(g.amount.amount,g.account),O=Y0(g.amount.amount,g.class);if(h!=null&&(I===!0||b===!0)){d=I===!0?P:void 0,l=b===!0?O:void 0;const C={account:d,class:l};if(C.class!=null||C.account!=null){const U=h.entityId;Wz(a,U,h.entityType,C,!1,void 0,h.entityName)}}}})),t.updatesByLineId=e,{transactionId:i.id,updates:t,entityRelatedUpdates:a,markAsMiscatUpdates:n===!0&&o===!1,anyBulkUpdates:!1}},Wz=(s,i,r,t,e=!1,a,n)=>{const o=b0(r,i),c=s[o],d={recommendations:t,entityId:i===n?null:i,...r==="vendor"&&n!=null?{vendorName:n}:{}};s[o]=c==null?{entityType:r,isBulkUpdate:e,updatedEntityId:a,...d}:{...c,...d}},Zz=(s,i,r,t,e)=>s!=null?{entityId:s.qboId??s.id,entityType:s.type,entityName:s.name}:r!=null?{entityId:r.qboId??r.id??r.name,entityType:"vendor",entityName:r.name}:t!=null&&t.id!=null?{entityId:t.id,entityType:"customer"}:i.lineEntity!=null?{entityId:i.lineEntity.qboId??i.lineEntity.id,entityType:i.vendor!=null?"vendor":"customer",entityName:i.lineEntity.name}:i.customer?.id!=null&&e!=null&&e.type==="customer"?{entityId:e.qboId??i.customer.id,entityType:"customer"}:i.vendor?.id!=null&&e!=null&&e.type==="vendor"?{entityId:e.qboId??i.vendor.id,entityType:"vendor",entityName:e.name??i.vendor.name}:void 0,Xz=(s,i,r,t,e,a,n)=>{const o=Object.assign({},i);o.memo=s.memo??"";const c={};for(const l in s.updatesByLineId){const u=s.updatesByLineId[l],m=o.lines?.map((h=>{if(h.id===l){const g=Object.assign({},h);g.lineDescription=u.lineDescription??"",u.class!=null&&(g.class=u.class),u.project!=null&&(g.project=u.project),u.account!=null&&(g.account=u.account),u.customer!=null?g.customer=u.customer:g.customer=void 0,u.vendor!=null?u.vendor?.id===u.vendor?.name?g.vendor={id:"",name:u.vendor.name}:g.vendor=u.vendor:g.vendor=void 0,u.recommendation!=null&&(c[h.id]=u.recommendation);const I=t[r],b=I?.find((E=>E.lineId===h.id));return b!=null&&(g.cotViewingFlags={vendor:b.vendor,category:b.category,class:b.class,lineId:b.lineId}),g}return h}));o.lines=m}let d;return o.recommendations=c,d=E0(o)?P0(o):as(o)?n!=null&&n.type==="customer"?T0(o,a):A0(o,e):N0(o)?O0(o):C0(o),x0(d,o)},eK=s=>{const i=[];let r;for(r in s){const t=s[r],e={recommendations:U0(t.recommendations),entity_id:t.entityId,entity_type:t.entityType,is_bulk_update:t.isBulkUpdate,updated_entity_id:t.updatedEntityId};t.entityType==="vendor"&&t.vendorName!=null&&(e.vendor_name=t.vendorName),i.push(e)}return i},Q0=s=>({user_id:s.user_id,first_name:s.first_name?.trim(),last_name:s.last_name?.trim(),email:""}),W0=s=>{const i={global_merchant_name:s.globalMerchantName,global_merchant_type:s.globalMerchantType??"vendor",logo:{url:s.logo?.toString(),base64:null},reason:s.reason??null,website_url:s.websiteUrl?.toString()??null,third_party_merchant_id:s.thirdPartyMerchantId??null,update_time:s.updateTime!=null?s.updateTime.format("YYYY-MM-DD"):null,create_time:s.createTime!=null?s.createTime.format("YYYY-MM-DD"):null};return s.isActive!=null&&(i.is_active=s.isActive),i},Xn=(s,i)=>{const r=[];s.map(((e,a)=>{const n=[];e.globalMerchants.forEach(((o,c)=>{const d=ql(o);n[c]={...ts(d,["create_time","update_time"])}})),n.length>0&&(r[a]={global_merchants:n})}));const t=[];return i.map(((e,a)=>{const n=[];e.globalMerchants.forEach(((o,c)=>{const d=W0(o);n[c]={...ts(d,["create_time","update_time"])}})),t[a]={global_merchants:n}})),[{global_merchants:[...r[0]?.global_merchants??[],...t[0]?.global_merchants??[]]}]},Z0=s=>{const i=[];return s[0]?.global_merchants.forEach((r=>{r.global_merchant_id!=null&&i.push(r)})),i},tK=(s,i)=>{const r={global_merchant_name:s.globalMerchantName,global_merchant_type:s.globalMerchantType,is_active:!0,recommendations:i,website_url:s.globalMerchantWebsiteUrl?.toString()};if(i.length>0&&i[0].global_merchants.length>0&&i[0].global_merchants[0].global_merchant_name===s.globalMerchantName){const t=i[0].global_merchants[0];r.logo=t.logo?.url??null,r.third_party_merchant_id=t.third_party_merchant_id??null}return r},aK=new Set(["time","action"]),BE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Ie=s=>{const i=s?.message?.trim()??"";if(i!=="")return[{variableName:"_api-error_",variableValue:i}]},Rn=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Yr=(s,i)=>i.pipe(y((r=>T(r)&&r.data!=null?((t,e)=>[B0(e),WU(e.id),ZU(t),D0(),k0()])(s,r.data):p(b_({kind:s,error:r.status})))),v((r=>p(b_({kind:s,error:f("Unexpected Error",`Data import ${s} REST API call errored out `+JSON.stringify(r))}))))),Nl=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Pt=s=>s.trim()!==""?s.trim():void 0,DE=s=>s.trim()!==""?s.trim():null,Ol=s=>s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),JE=(s,i)=>{const r={};s.sku.trim()!==""&&(r.sku=s.sku.trim());const t=i.accountByQboId(s.accountingCode.trim());t!=null&&(r.account=Qr(t));const e=i.classByQboId(s.accountingCategory.trim());return e!=null&&(r.accounting_class=Wr(e)),Object.keys(r).length>0?r:void 0},rK=(s,i,r)=>{const t=Pt(s.description),e=Pt(s.productCode)??Ol(s.name),a={enabled_for_checkout:!0,enabled_in_portal:!0,is_giftable:!1,is_shippable:!1,item_applicability:s.itemApplicability,metered:!1,name:s.name.trim(),product_code:e,type:s.catalogType};t!=null&&(a.description=t),a.unit=Pt(s.unit)??"USD",s.itemApplicability==="restricted"&&s.applicableItems.length>0&&(a.applicable_items=s.applicableItems);const n=s.subFamilies.length>0?s.subFamilies:[sk()];return a.sub_family_details=i?n.map((o=>((c,d,l,u)=>{const m=c.catalogType==="addon",h=nk(d.pricingModel),g=d.name.trim(),I=Pt(d.priceCode)??Ol(g),b={currency_code:"USD",free_quantity:Number(d.freeQuantity)||0,is_taxable:d.isTaxable,name:g,price:h?0:d.priceDollars?.amount??0,price_code:I,pricing_model:d.pricingModel,show_description_in_invoices:d.showDescriptionInInvoices,show_description_in_quotes:d.showDescriptionInQuotes},E=Pt(d.description);E!=null&&(b.description=E);const P=Pt(d.invoiceNotes);P!=null&&(b.invoice_notes=P),d.period.trim()!==""&&(b.period=Number(d.period),b.period_unit=d.periodUnit||"month"),d.trialPeriod.trim()!==""&&(b.trial_period=Number(d.trialPeriod),b.trial_period_unit=d.trialPeriodUnit,b.trial_end_action=d.trialEndAction),d.billingCycles.trim()!==""&&(b.billing_cycles=Number(d.billingCycles)),m&&d.prorationType&&(b.proration_type=d.prorationType),h&&(b.tiers=d.tiers.map((C=>({ending_unit:C.endingUnit.trim()!==""?Number(C.endingUnit):void 0,package_size:C.packageSize.trim()!==""?Number(C.packageSize):void 0,price:C.price?.amount??0,pricing_type:C.pricingType,starting_unit:Number(C.startingUnit)||1}))));const O=JE(d,u);return O!=null&&(b.accounting_detail=O),b})(s,o,0,r))):n.map((o=>{const c=Pt(o.priceCode)??Ol(o.name),d={description:DE(o.description),invoice_notes:DE(o.invoiceNotes),name:o.name.trim(),price_code:c,show_description_in_invoices:o.showDescriptionInInvoices};d.accounting_detail=JE(o,r)??null;const l=Pt(o.id);return l!=null?{...d,id:l}:d})),a},wE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",sK={archive:"invoicing_discount_archive",delete:"invoicing_discount_delete",unarchive:"invoicing_discount_unarchive"},Cl=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",ta=s=>s.trim()!==""?s.trim():void 0,Mn=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",nK={activate:"invoicing_subscription_activated",cancel:"invoicing_subscription_cancelled",change_term_end:"invoicing_subscription_term_end_changed",pause:"invoicing_subscription_paused",reactivate:"invoicing_subscription_reactivated",remove_scheduled_cancellation:"invoicing_subscription_cancellation_removed",resume:"invoicing_subscription_resumed",set_non_renewing:"invoicing_subscription_non_renewing"},$E=s=>(s??"").trim().toUpperCase(),RE=s=>(s??"").trim().toUpperCase(),ME=(s,i,r,t,e)=>s.postAndGetJSON(`${i}/subscriptions/${encodeURIComponent(r)}/${t}`,{coupon_code:e}).pipe(nt((a=>T(a)?{success:!0,payload:a.data??null}:{success:!1,payload:null,status:a.status})),v((a=>p({success:!1,payload:null,status:f("Unexpected Error",`${t} REST API call errored out `+JSON.stringify(a))})))),VE=s=>s.status??f("Unexpected Error","Coupon sync failed without a status"),LE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",oK={regenerate:"invoicing_invoice_regenerated","send-reminder":"invoicing_invoice_reminder_sent",void:"invoicing_invoice_voided"},xl=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Ul=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",FE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",qE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",iK={cancel:"invoicing_dunning_cancel",resolve:"invoicing_dunning_case_resolved",retry:"invoicing_dunning_retry"},jE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Tt=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress";function GE(s){return{connected:s.connected,companyName:s.company_name??void 0,connectionId:s.connection_id??void 0,realmId:s.realm_id??void 0}}const zE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",cK=(s,i)=>{if(i==null)return[];const r=JD(s,i),t=wD(i),e=$D(i),a=RD(i);if(a&&r)return[];if(r)return[];if(a)return[];if(t)return["bookkeeping","zeni_bill_pay","zeni_reimbursements"];if(e){const n=[];return i.productSettings.isCfoEnabled&&n.push("zeni_cfo"),i.productSettings.isTaxEnabled&&n.push("zeni_tax"),i.productSettings.isPayrollEnabled&&n.push("zeni_payroll"),n}return[]},dK=(s,i,r,t)=>{const{qboRealmId:e,chargebeeId:a,isSubsidiary:n,parentCompanyId:o}=s;e&&e!==t?.qboRealmId?i.qbo_realm_id=e:!e&&t?.qboRealmId!=null&&(i.qbo_realm_id=""),n==null||r!=null&&(r==null||n===r?.company.companyOnboardingInfo.isSubsidiary&&o===r?.company.companyOnboardingInfo.parentCompanyId)||(n===!0?(i.is_subsidiary=!0,i.parent_company_id=o):i.is_subsidiary=!1),a&&a!==t?.chargebeeId&&(i.chargebee_customer_id=a)},KE=(s,i)=>{const r=s?.onboarding_customer_user_ids!=null&&s.onboarding_customer_user_ids.length>0?s.onboarding_customer_user_ids[0]:"";let t="";if(r!=null){const e=i.find((a=>a.user_id===r));if(e!=null){const a=e.first_name?.trim()??"",n=e.last_name?.trim()??"";t=a&&n?`${a} ${n}`:a||n||""}}return t},lK=s=>{return{key:s.key,status:(i=s.status,i==="idle"||i==="starting"||i==="building"||i==="ready"?i:"idle"),startedAt:s.started_at,completedAt:s.completed_at};var i},uK=new Set(["employees","customers","physical_office","banking_relationships"]),pK={Employees:"employees",Customers:"customers","Physical office or facility":"physical_office","Banking relationships":"banking_relationships"};function mK(s){return uK.has(s)?s:pK[s]??s}const YE=(s,i,r,t,e)=>{const{companyDescription:a,companyLegalName:n,companyIndustry:o,companyIndustryType:c,companySubIndustry:d,countriesOfOperations:l,companySourceOfFunds:u,companySourceOfFundsDescription:m,transactionVolume:h,transactionVolumeDescription:g,purposeOfAccount:I,purposeOfAccountDescription:b,regulatedStatus:E,regulatedStatusDescription:P,usNexus:O,usNexusTypes:C,website:U,incDate:B,taxIdOrEIN:x,phone:k,syncToken:J,fileIds:L,typeOfIncorporation:R,stateOfIncorporation:q,sourceOfFunds:$}=s,D={is_ready_for_verification:i,file_ids:L},w=r!=null?xe(r):void 0,K=t!=null?xe(t):void 0;return J0(r!=null?to(r):r,t!=null?to(t):t)?D.is_registered_address_same_as_company_address=!0:D.is_registered_address_same_as_company_address=!1,a!=null&&(D.company_description=a),n!=null&&(D.company_legal_name=n),U!=null&&(D.company_url=U.toString()),x!=null&&(D.tax_id=x),B!=null&&(D.company_inc_date=B.format("YYYY-MM-DD")),k!=null&&(D.phone=k),J!=null&&(D.sync_token=J),w!=null&&(D.address=w),K!=null&&(D.registered_address=K),R!=null&&(D.company_inc_type=R),q!=null&&(D.company_inc_state=q),o!=null&&(D.company_industry=o),Object.assign(D,{...c!=null&&{company_industry_type:c},...d!=null&&{company_industry_sub_type:d},...l!=null&&l.length>0&&{company_countries_of_operations:l},...u!=null&&{company_source_of_funds:u},...m!=null&&{company_source_of_funds_desc:m},...h!=null&&{company_transaction_vol_expectations:h},...g!=null&&{company_transaction_vol_expectations_desc:g},...I!=null&&{company_purpose_of_account:I},...b!=null&&{company_purpose_of_account_desc:b},...E!=null&&{company_regulated_states:E==="yes"},...P!=null&&{company_regulated_states_desc:P},...O!=null&&{company_us_nexus:O==="yes"},...C!=null&&C.length>0&&{company_us_nexus_desc:C.map(mK)}}),e==="zeni_treasury"&&$!=null&&(D.source_of_funds=$),D.is_new_company_industry_verified=!0,D},HE=(s,i)=>{const r={first_name:s.firstName,last_name:s.lastName,email:s.email};return i||s.userId==null||(r.user_id=s.userId),s.syncToken!=null&&(r.sync_token=s.syncToken),r},QE=(s,i,r)=>{const{firstName:t,lastName:e,userId:a,email:n,syncToken:o,ssn:c,birthday:d,nationalityCountryCode:l,phone:u,otpChallenge:m,isPhoneVerified:h,titleAtCompany:g,ownershipInCompany:I,documentTypeSelectedForVerification:b,fileIds:E,additionalSubmittedDocumentsForVerificationFileIds:P}=s,O={first_name:t,last_name:e,file_ids:E},C=r!=null?xe(r):void 0;return a==null?n!=null&&(O.email=n):(a!=null&&(O.user_id=a),o!=null&&(O.sync_token=o)),c!=null&&(O.ssn=c),O.birthday=d?.format("YYYY-MM-DD")??null,u!=null&&(O.phone=u),O.title_at_company=g??"",O.company_ownership=I??null,O.document_type_for_verification=b??"",O.nationality_country_code=l??"",C!=null&&(O.address=C),m!=null&&h===!0&&(O.phone_verification={otp_challenge:m}),i&&(O.are_additional_documents_submitted_for_verification=!0,O.additional_submitted_documents_for_verification_file_ids={social_security_card:P}),O},yK=s=>{switch(s){case"charge_cards":return"charge_cards";case"debit_cards":return"debit_cards";case"charge_cards__debit_cards":return"charge_cards__debit_cards";case"reimbursement":return"reimbursements";case"zeni_accounts":return"deposit_accounts";case"bill_pay":return"bill_pay";case"zeni_treasury":return"treasury_accounts";case"other_connection":return"other_connection";case"billing":return console.warn("Invalid type for setup view"),""}},_K=s=>{const{companyLegalName:i,syncToken:r}=s,t={is_ready_for_verification:!1};return i!=null&&(t.company_legal_name=i),r!=null&&(t.sync_token=r),t},hK=(s,i)=>{const{syncToken:r}=s;return{company:{sync_token:r,subscription_billing_address:xe(i)}}};function WE(s,i,r,t){const{companyInfo:e,incInfo:a,taxInfo:n,questionaire:o,companyBillPayInfo:c}=s,{companyId:d,companyDescription:l,companyLegalName:u,companyUrl:m,phone:h,syncToken:g,sourceOfFunds:I,companySourceOfFunds:b,companySourceOfFundsDescription:E,countriesOfOperations:P,transactionVolume:O,transactionVolumeDescription:C,purposeOfAccount:U,purposeOfAccountDescription:B,regulatedStatus:x,regulatedStatusDescription:k,usNexus:J,usNexusTypes:L}=e,{usersSelectedForVerification:R}=c,{fileIds:q,companyIncDate:$,companyIncType:D,companyIncState:w,companySubIndustry:K,companyIndustryType:G}=a,{companyIndustry:Z}=o,{taxId:de}=n,ue={companyId:d,companyDescription:l,companyIndustry:Z,companyIndustryType:G,companyLegalName:u,companySubIndustry:K,companySourceOfFunds:b,companySourceOfFundsDescription:E,countriesOfOperations:P,taxIdOrEIN:de,incDate:$,phone:h,website:m,fileIds:q,syncToken:g,typeOfIncorporation:D,sourceOfFunds:I,stateOfIncorporation:w,transactionVolume:O,transactionVolumeDescription:C,purposeOfAccount:U,purposeOfAccountDescription:B,regulatedStatus:x,regulatedStatusDescription:k,usNexus:J,usNexusTypes:L};let te;if(t!=null){const{firstName:Ae,lastName:pe,email:fe,userId:na,syncToken:oa}=t;te={userId:na,firstName:Ae,lastName:pe,email:fe,syncToken:oa}}const ye=i.slice(0,Fl.length).sort(((Ae,pe)=>Ae.createTime?.isAfter(pe.createTime)===!0?1:-1));let _e=R?.[0]!=null?ye.findIndex((Ae=>Ae.userId===R[0])):0;_e<0&&(_e=0);const Ve=ye.map(((Ae,pe)=>{const{userId:fe,firstName:na,lastName:oa,birthday:ia,email:aP,nationalityCountryCode:rP,phone:sP,isPhoneVerified:nP,ssn:oP,syncToken:iP}=Ae,Xe=r.find((cP=>cP.userId===fe));return{officerType:`Officer_${pe+1}`,userId:fe,firstName:na,lastName:oa,birthday:ia,email:aP,nationalityCountryCode:rP,phone:sP,isPhoneVerified:nP,ssn:oP,fileIds:Xe?.fileIds??[],syncToken:iP,isSelectedForVerification:_e===pe,documentTypeSelectedForVerification:Xe?.documentTypeSelectedForVerification,titleAtCompany:Xe?.titleAtCompany,ownershipInCompany:Xe?.ownershipInCompany,userVerificationStatus:Xe?.userVerificationStatus,treasuryUserVerificationStatus:Xe?.treasuryUserVerificationStatus,additionalDocumentTypesRequestedForVerification:Xe?.additionalDocumentTypesRequestedForVerification??[],additionalSubmittedDocumentsForVerificationFileIds:Xe?.additionalSubmittedDocumentsForVerificationFileIds??[],areAdditionalDocumentsRequestedForVerification:Xe?.areAdditionalDocumentsRequestedForVerification??!1,areAdditionalDocumentsSubmittedForVerification:Xe?.areAdditionalDocumentsSubmittedForVerification??!1}}));return Ve.length===0&&Ve.push({officerType:"Officer_1",userId:void 0,firstName:"",lastName:"",email:"",nationalityCountryCode:void 0,fileIds:[],isSelectedForVerification:!1,additionalDocumentTypesRequestedForVerification:[],additionalSubmittedDocumentsForVerificationFileIds:[],areAdditionalDocumentsRequestedForVerification:!1,areAdditionalDocumentsSubmittedForVerification:!1}),{companyDetails:ue,officers:Ve,primaryContactDetails:te}}const ZE=(s,i)=>{switch(s){case"update_account":return{is_link_update_mode:!0,is_same_day_microdeposits_enabled:!0,payment_account_id:i};case"link_account_no_microdeposit":return{is_link_update_mode:!1,is_same_day_microdeposits_enabled:!1};default:return{is_link_update_mode:!1,is_same_day_microdeposits_enabled:!0}}},Vn=(s,i,r)=>{const{is_admin:t,is_bookkeeping_admin:e,is_bookkeeping_user:a,user_id:n,is_invite_accepted:o,is_reimbursements_user:c,is_zeni:d,is_zeni_support_user:l}=i;!o||d&&!r||(l||t||e||a||c?s.push(GJ({userType:"manager",id:n})):s.push(w0({userType:"manager",id:n})))},SK=(s,i)=>({invites:s.map((r=>{const t={};return jl(r.role,i).forEach((e=>{t[`is_${e}`]=!0})),r.email.map((e=>({user_email:e,manager_user_id:r.managerId==null||r.managerId==="no_manager"?void 0:r.managerId,accounting_class_ids:r.departmentId!=null?[r.departmentId]:void 0,...t})))})).flat()}),gK=s=>({users:s.map((i=>{const r=i.role[0];return i.email.map((t=>({is_zeni:!0,user_id:null,user_email:t,[`is_${r}`]:!0})))})).flat()}),fK=(s,i,r,t)=>{const e={},{accountingClassIDs:a,managerUserId:n,userRoles:o}=r.userRole;if(s.departmentId!=null&&s.departmentId!==a[0]&&(e.accounting_class_ids=[s.departmentId]),s.managerId!=null&&s.managerId!==n&&(e.manager_user_id=s.managerId!=="no_manager"?s.managerId:null),s.role!=null){const c=jl(s.role,t),d={};o.forEach((l=>{i&&iw(l)||(d[`is_${l}`]=!1)})),c.forEach((l=>{d[`is_${l}`]=!0})),Object.assign(e,d)}return e},Hr=s=>{if(s==null||s.length===0)return;const i=[];return s.map((r=>{i.push(...mw(r))})),i},XE=(s,i)=>{if(s.length===0)return;const r={};return i.length!==s.length?r[i[0]]=vg(s[parseInt(i[0])]):s.forEach(((t,e)=>{r[i[e]]=vg(t)})),r},e0=s=>`${s}s`,vK=(s,i)=>({referrals:s.map((r=>({company:r.companyName,email_ids:r.emailIds,refer_reward_plan_id:i})))}),IK=s=>({vendor_id:s.id,vendor_name:s.name}),bK=({balanceAsOfToday:s,recurringAmount:i})=>s!=null?s.amount:i.amount,EK=(s,i)=>{const{estimatedMonthlyAmount:r,memo:t,selectedAccount:e,selectedClass:a,selectedMonths:n,selectedVendor:o,selectedAccruedExpenseCategory:c,jeScheduleDetails:d,startingBalance:l}=s,u=$0,m=d.length,h=m>0?s.jeScheduleDetails[0].postingDate.format(re):null,g=m>0?s.jeScheduleDetails[m-1].postingDate.format(re):null;return{status:{code:"new",label:"New"},vendor:{vendor_id:o?.id??"",vendor_name:o?.name??""},posting_date:u,currency_code:r?.currencyCode??"USD",currency_symbol:r?.currencySymbol??"$",period:n??0,je_schedule_type:"accrued_expenses",balance:l?.amount??0,other_attributes:{starting_balance:l?.amount??0},start_date:h,end_date:g,je_credit_accounting_class_id:i??"",je_credit_account_id:c??"",je_debit_account_id:e??"",je_debit_accounting_class_id:a??"",memo:t??"",recurring_amount:r?.amount??0,is_deleted:!1}},X0=(s,i,r,t,e)=>{const{vendor:a,currencyCode:n,currencySymbol:o,status:c,startDate:d,recurringAmount:l,endDate:u,balanceAsOfToday:m}=s,{selectedMonths:h,selectedAccount:g,selectedClass:I,memo:b,estimatedMonthlyAmount:E,selectedAccruedExpenseCategory:P,startingBalance:O}=r,C=$0,U=r.jeScheduleDetails.length,B=U>0?r.jeScheduleDetails[0].postingDate.format(re):null,x=U>0?r.jeScheduleDetails[U-1].postingDate.format(re):null,k=a.id,J=i.vendorByID[k],L={status:c,vendor:IK(J),currency_code:n,currency_symbol:o,other_attributes:{starting_balance:O?.amount??0},period:h??null,je_schedule_type:"accrued_expenses",posting_date:C,balance:bK({balanceAsOfToday:m,recurringAmount:l}),start_date:d?.format(re)??B,end_date:u?.format(re)??x,je_credit_accounting_class_id:t??"",je_credit_account_id:P??null,je_debit_account_id:g??null,je_debit_accounting_class_id:I??null,memo:b??"",recurring_amount:E?.amount??0};return e===!0?{...L,is_deleted:!0}:L},zl=(s,i)=>s.find((t=>t.labels?.includes(i)===!0))?.classId??"",PK=(s,i)=>{const r={je_schedules:[],scheduled_journal_entries:[]},{classListState:t,classState:e}=s,a=tr(e,t).classes,n=zl(a,"balance_sheet");return r.je_schedules=[EK(i,n)],r.scheduled_journal_entries=(o=>{const c=o.jeScheduleDetails,d=o.startingBalance?.amount??0;return c.map(((l,u)=>({status:{code:l.postingStatus,label:l.postingStatus},transaction_memo:l.memo,third_party_id:l.jeLink.thirdPartyTransactionId??null,expected_post_date:l.postingDate.format(re),amount:l.amount.amount,balance:u===0&&d!==0?d:l.runningBalance.amount,scheduled_journal_entry_id:null,actual_post_date:null,is_platform_generated:null,je_schedule_id:null,update_time:null,create_time:null})))})(i),r},t0=(s,i,r,t)=>{const e={je_schedules:[],scheduled_journal_entries:[]},{scheduleAccruedDetailState:a}=s,{selectedJEAccruedLinkRowIndex:n,linkBillExpenseView:o}=a;let c;const d=At(s.transactionState,o.linkBillExpenseLocalData.selectedTransaction??"");d!=null&&(c={transaction_id:d.id,transaction_type:d.type});const l=sa(r,s);if(l!=null){const{vendorState:u,classListState:m,classState:h}=s,g=tr(h,m).classes,I=zl(g,"balance_sheet"),b=i.jeScheduleDetails;e.je_schedules=[X0(l,u,i,I,t)],e.scheduled_journal_entries=((E,P,O,C,U)=>{const B=P.scheduledJournalEntry;return E.map(((x,k)=>{const J=B[k],L={status:{code:x.postingStatus,label:AK(x.postingStatus)},transaction_memo:x.memo,third_party_id:x.jeLink.thirdPartyTransactionId??null,expected_post_date:x.postingDate.format(re),amount:x.amount.amount,...O===k&&C!=null?{is_bill_linked:!0}:{},...O===k&&C!=null?{reversal_transaction_details:C}:x.jeLink.reversalTransactionDetails!=null?{reversal_transaction_details:R0(x.jeLink.reversalTransactionDetails)}:{},balance:x.runningBalance.amount,scheduled_journal_entry_id:J?.scheduledJournalEntryID!=null?J.scheduledJournalEntryID:null,actual_post_date:J?.actualPostDate!=null?J.actualPostDate.format(re):null,is_platform_generated:J?.isPlatformGenerated!=null?J.isPlatformGenerated:null,je_schedule_id:J?.jeScheduleId!=null?J.jeScheduleId:null,update_time:J?.syncToken!=null?J.syncToken:null,create_time:J?.createTime!=null?J.createTime.format(re):null};return U===!0?{...L,is_deleted:!0}:L}))})(b,l,n,c,t)}return e},TK=(s,i,r,t)=>{const e={je_schedules:[],scheduled_journal_entries:[]},a=sa(r,s);if(a!=null){const{vendorState:n,classListState:o,classState:c}=s,d=tr(c,o).classes,l=zl(d,"balance_sheet"),u=i.jeScheduleDetails;e.je_schedules=[X0(a,n,i,l,!1)],e.scheduled_journal_entries=((m,h,g)=>{const I=h.scheduledJournalEntry;return m.map(((b,E)=>{const P=I[E];return{status:{code:g==null&&b.postingStatus==="pending"||g!=null&&g===E?"canceled":b.postingStatus,label:g==null&&b.postingStatus==="pending"||g!=null&&g===E?"Canceled":b.postingStatus},transaction_memo:b.memo,third_party_id:b.jeLink.thirdPartyTransactionId??null,...b.jeLink.reversalTransactionDetails!=null&&{reversal_transaction_details:R0(b.jeLink.reversalTransactionDetails)},expected_post_date:b.postingDate.format(re),amount:b.amount.amount,balance:b.runningBalance.amount,scheduled_journal_entry_id:P?.scheduledJournalEntryID!=null?P.scheduledJournalEntryID:null,actual_post_date:P?.actualPostDate!=null?P.actualPostDate.format(re):null,is_platform_generated:P?.isPlatformGenerated!=null?P.isPlatformGenerated:null,je_schedule_id:P?.jeScheduleId!=null?P.jeScheduleId:null,update_time:P?.syncToken!=null?P.syncToken:null,create_time:P?.createTime!=null?P.createTime.format(re):null}}))})(u,a,t)}return e},AK=s=>s.charAt(0).toUpperCase()+s.substring(1),NK=function(s,i,r){let t=Wg(i,s,31);return t.month()!==s&&(t=Wg(i,s).endOf("month")),{postingDate:t,postingStatus:"pending"}},OK=(s,i)=>`${s} - ${i.format(h$)} - Acc_${i.format(S$)}`,CK=(s,i,r,t)=>{const e=s.selectedMonths,a=s.selectedDate;if(a==null)return[];const n=[];if(e==null)return[];for(let o=0;o<e;o++){const c=a.add(o,"month"),{postingDate:d,postingStatus:l}=NK(c.month(),c.year());n.push({postingDate:d,amount:Wa(i.amount,i.currencyCode,i.currencySymbol),runningBalance:Wa(o===0?r.amount??0:0,i.currencyCode,i.currencySymbol),postingStatus:l,memo:OK(t,c),jeLink:{type:"unknown"}})}return n},xK=(s,i)=>{const r=Math.abs(s[i].amount.amount);return s.map(((t,e)=>e===i?{...t,amount:{...t.amount,amount:r}}:t))},UK=(s,i,r,t)=>({type:i!=null?"linked":s==null?r==null?"unknown":"recommended":"qbourl",thirdPartyTransactionId:s,recommendedTransactionID:r,transactionDetailID:i!=null?{id:i,type:"journal_entry"}:void 0,reversalTransactionDetails:t!=null?{id:t.id,type:t.type}:void 0}),kK=s=>s.period!=null&&s.je_debit_account_id!=null&&s.je_debit_accounting_class_id!=null&&s.start_date!=null&&s.posting_date!=null&&s.period!=null&&s.je_credit_account_id!=null,BK=(s,i)=>({company:{sync_token:i,subscription_billing_address:xe(s)}});function Ln(s){return{frequency_type:s.frequency,preferred_mode:s.preferredMode}}const DK=(s,i,r)=>{const{origin:t,phone:e,otpChallenge:a,birthday:n,address:o,firstName:c,lastName:d}=s,l=i.birthday==null,u=r!=null&&o!=null?!J0(to(r),to(o)):r==null&&o!=null;let m={first_name:c??void 0,last_name:d??void 0,birthday:l&&n!=null?n.format(re):void 0,address:u&&o!=null?xe(o):void 0};return a!=null&&e!=null&&(m={...m,phone:e,phone_verification:{otp_challenge:a}}),t==="CardUserOnboarding"?{...m,is_card_issue_fulfilment_request:e!=null&&a!=null&&n!=null,address:r!=null?xe(Wn(r)):void 0}:m},kl=s=>({amount:s.amount,autoTransferRuleId:s.auto_transfer_rule_id,createTime:s.create_time!=null?ee(s.create_time):void 0,currencyCode:s.currency_code,currencySymbol:s.currency_symbol??"$",destinationBankAccountId:s.destination_bank_account_id,destinationBankAccountMetadata:s.destination_bank_account_metadata?.map((i=>({accountId:i.account_id,accountType:i.account_type,percentage:i.percentage})))??void 0,destinationBankAccountType:s.destination_bank_account_type??void 0,frequency:s.frequency,isActive:s.is_active,isDeleted:s.is_deleted,lastRunTime:s.last_run_time,nextTransferDate:s.next_transfer_date!=null?ee(s.next_transfer_date):void 0,ruleType:s.rule_type,sourceBankAccountId:s.source_bank_account_id,sourceBankAccountType:s.source_bank_account_type,updateTime:s.update_time!=null?ee(s.update_time):void 0});function a0(s,i,r){return i===!0?{is_active:!1}:r===!0?{is_active:!0}:{...s.amount!=null&&s.ruleType!=="percentage_of_balance"&&{amount:s.amount.amount,currency_code:s.amount.currencyCode},...s.destinationAccount!=null&&{destination_bank_account_id:s.destinationAccount.id,destination_bank_account_type:Xr(s.destinationAccount.accType)},...s.destinationAccountWithPercentAllocation!=null&&{destination_bank_account_metadata:s.destinationAccountWithPercentAllocation.map((t=>({account_id:t.account.id,account_type:Xr(t.account.accType),percentage:t.percentage})))},frequency:s.frequency,rule_type:s.ruleType,...s.sourceAccount!=null&&{source_bank_account_id:s.sourceAccount.id,source_bank_account_type:Xr(s.sourceAccount.accType)},...s.firstTransferDate!=null&&{first_transfer_date:s.firstTransferDate.format("YYYY-MM-DD")}}}const Xr=s=>{switch(s){case"depositAccount":return"deposit_account";case"paymentAccount":return"payment_account";case"treasuryAccount":return"treasury_account";default:return}};function JK(s){const i=[],r=s.vendor_id;return r&&i.push(aa(r,!1)),i}const r0=s=>{let i;if(s.criteria!=null){const{amount:a,vendor:n,department:o}=s.criteria,c=[];if(a?.min!=null&&c.push({field:"amount",type:"gte",value:a.min.amount}),a?.max!=null&&c.push({field:"amount",type:"lte",value:a.max.amount}),n!=null&&n.vendorIds.length>0&&c.push({field:"vendor_id",type:n.operator==="is_not"?"not_in":"in",value:n.vendorIds}),o!=null&&o.departmentIds.length>0&&c.push({field:"accounting_class_id",type:o.operator==="is_not"?"not_in":"in",value:o.departmentIds}),c.length>0){const d=a?.min??a?.max??null;i={conditions:c,criteria_operator:"and",currency_code:d?.currencyCode??"USD",currency_symbol:d?.currencySymbol??"$"}}}const r=s.steps.map((a=>({action:a.action,operator:a.operator,actors:a.actors.filter((n=>n.subType!=="admin")).map((n=>({type:n.type,id:n.userId??null,sub_type:n.subType??null,id_type:n.idType??null,is_implicit_actor:n.isImplicitActor??!1})))}))),t=s.approvalRuleId!=null,e={steps:r,is_applicable_on_pending_approval_entity:s.isApplicableOnPendingApprovalEntity??!0};return i!=null&&(e.criteria=i),s.name!=null&&(e.name=s.name),s.description!=null&&(e.description=s.description),s.separationOfDuties!=null&&(e.is_separation_of_duty_enabled=s.separationOfDuties),t&&(e.approval_rule_id=s.approvalRuleId),e},s0=s=>{const i=s.criteria?.amount,r=i?.min,t=i?.max,e=r?.currencyCode??t?.currencyCode??"USD",a=r?.currencySymbol??t?.currencySymbol??"$",n=s.steps.map((m=>({action:m.action,operator:m.operator,actors:m.actors.filter((h=>h.subType!=="admin")).map((h=>({type:h.type,id:h.userId??null,sub_type:h.subType??null,id_type:h.idType??null,is_implicit_actor:h.isImplicitActor??!1})))}))),o=s.approvalRuleId!=null,c=r?.amount??null,d=t?.amount??null,l=[];c==null&&d==null?console.warn("[approvalRules][V1] toApprovalChangableInfoPayloadV1: rule has no amount bounds; emitting empty criteria array. The V1 backend will reject this save — caller should ensure at least one bound is set on the form."):l.push({type:"range",range_entity:"currency",min:c,max:d,currency_code:e,currency_symbol:a});const u={steps:n,is_applicable_on_pending_approval_entity:s.isApplicableOnPendingApprovalEntity??!0,criteria:l};return o&&(u.approval_rule_id=s.approvalRuleId),u};function Bl(s,i,r){const t=i.billDetailLocalData.isCancelled,e=i.billDetailLocalData.updatesByLineId,a={...e},n=r?.accountId!=null?Ze(s.accountState,r.accountId,"account_list"):void 0,o=r?.classId!=null?Xa(s.classState,{classId:r.classId,reportId:"class_list"}):void 0,c=r?.vendorCurrencyCode,d=r?.vendorCurrencySymbol,{tenantState:l,companyState:u}=s,{currentTenantId:m}=l,h=m!=null?l.tenantsById?.[m]?.companyId:void 0,g=Te(u,h??""),I=g?.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach,b=I!=null&&me().isSameOrBefore(I);return Object.keys(a).forEach((E=>{const P=e[E];a[E]={...P,account:n,class:o,...es}})),Object.keys(a).length===0&&(a[1]={account:n,class:o,amount:{amount:0,currencyCode:c??"USD",currencySymbol:d??"$"},recipientAmount:{amount:0,currencyCode:c??"USD",currencySymbol:d??"$"},id:"1",lineDescription:"",platformLineDetailType:"account_based_expense_line_detail",type:"transaction_with_account_and_class_line",billable:"not_billable",isCategoryMiscategorized:!1,isClassMiscategorized:!1,...es}),{showVendorGptRecommendationText:!1,vendor:r,isCancelled:t,updatesByLineId:a,whatForSection:{...i.billDetailLocalData.whatForSection,currencyCode:r?.vendorCurrencyCode,recipientCurrencyCode:r?.vendorCurrencyCode},paymentDetailsSection:{...i.billDetailLocalData.paymentDetailsSection,paymentTo:void 0,internationalTransferFeeBearerPaymentMethod:r?.preferredInternationalTransferFeeBearerPaymentMethod,paymentDate:i.billDetailLocalData.paymentDetailsSection?.paymentDate??ee(eo(me().toDate(),[0,6],b?0:1).toISOString())},isCollectToAccountInfoFromVendorContact:!1,isRecurring:!1}}const eP=(s,i,r,t,e,a)=>{const n=i;let o=r?.[s]??[];if(o.length===0&&a?.recommendations!=null&&a?.recommendations.length>0&&(o=a?.recommendations),o.length===0)return{...n,...es};const[c]=o,d=c?.account,l=c?.class;let u,m,h=n?.account,g=n?.class;if(!h?.qboId&&(h=void 0),!g?.classId&&(g=void 0),h==null&&a!=null){const E=t.accounts.find((P=>P.qboId===a.qboId));d!=null?m=d:E!=null?m=E??a.recommendations[0]?.account:a.recommendations[0]?.account!=null&&(m=a.recommendations[0]?.account)}if(g==null&&a!=null){const E=e.classes.find((P=>P.classId===a.classId));l!=null?u=l:E!=null?u=E??a.recommendations[0]?.class:a.recommendations[0]?.class!=null&&(u=a.recommendations[0]?.class)}const I=((E,P)=>P!=null&&!!E.find((O=>O.class?.classId===P.classId)))(o,g),b=((E,P)=>P!=null&&!!E.find((O=>O.account?.qboId===P.qboId)))(o,h);return{...n,recommendedCategory:d,isCategoryFirstTimeAutofilled:!!d?.qboId,isCategoryUpdateSelected:!1,isRetainedCategorySelected:!1,retainedCategory:b?void 0:h,account:h??m,recommendedClass:l,isClassFirstTimeAutofilled:!!l?.classId,isClassUpdateSelected:!1,isRetainedClassSelected:!1,retainedClass:I?void 0:g,class:g??u,isCategoryOrClassUpdated:!1,updateAllCheckbox:!1}},wK=(s,i,r,t,e)=>{const a={currencyCode:r.recipient_currency_code??"",currencySymbol:r.recipient_currency_symbol??""},n={},o=t?.accountId,c=l1(r.lines,r.recommendations),d=r.lines?.[0]?.line_detail;let l=!0,u=!0;r.lines?.forEach((K=>{K.line_detail.account.account_id!==d.account.account_id&&(l=!1),K.line_detail.class.accounting_class_id!==d.class.accounting_class_id&&(u=!1);const G=Ze(s.accountState,o??"","account_list"),Z=Xa(s.classState,{classId:t?.classId??"",reportId:"class_list"}),de=u1(K,a),{accountListState:ue,accountState:te,classListState:ye,classState:_e}=s,Ve=tr(_e,ye),Ae=M0(te,ue,"billPayAccountList"),pe=eP(K.line_id,de,c,Ae,Ve,t);n[K.line_id]={...pe,account:pe.account?.accountId===""&&G!=null?G:pe.account,class:pe.class?.classId===""&&Z!=null?Z:pe.class}})),r.tax!=null&&r.tax>0&&n0(r.tax,a,"Tax",l,u,n),r.discount!=null&&r.discount>0&&n0(-r.discount,a,"Discount",l,u,n);const m=r.bill_pay_info?.bill_payment_method_type.code,h=r.bill_pay_info?.bill_payment_method_type.sub_code,g=r.bill_pay_info?.international_transfer_fee_bearer_payment_method,{internationalCode:I,internationalSubCode:b}=p1(h!=null?dv(h):void 0,g!=null?cv(g):void 0),{tenantState:E,companyState:P}=s,{currentTenantId:O}=E,C=O!=null?E.tenantsById?.[O]?.companyId:void 0,U=Te(P,C??""),B=U?.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach,x=B!=null&&me().isSameOrBefore(B),k=r.bill_pay_info?.from_account.account_type!=null?m1(y1(r.bill_pay_info?.from_account.account_type)):void 0,J=U?.company.companyInfo.bookCloseDate,L=r.transaction_date?Rl("draft",ee(r.transaction_date),J):void 0,R=r.due_date?r.transaction_date?V0("draft",ee(r.due_date),ee(r.transaction_date),J):ee(r.due_date):void 0,q=m!=null&&h!=null?_1(s.billPayConfigState,h1(q0(m),F0(f1(dv(h))),k,I!=null?g1(I):void 0,b!=null?S1(b):void 0)):void 0,$=Gl(m??""),D=r.bill_pay_info?.outside_zeni_transaction_payment_mode,w=$?{paymentMode:D!=null?v1(D):void 0,paymentDate:r.bill_pay_info?.payment_date!=null?ee(r.bill_pay_info?.payment_date):void 0}:void 0;return{recommendedVendorId:e,showVendorGptRecommendationText:i,lastRecommendedVendorName:e!=null?t?.name:void 0,vendor:t,whatForSection:{invoiceNumber:r.invoice_number,billDueDate:R,memo:r.transaction_memo,invoiceDate:L,isInvoiceDateAutoUpdated:!!r.transaction_date&&J!=null&&ee(r.transaction_date).isBefore(J),currencyCode:r.currency_code,recipientCurrencyCode:r.recipient_currency_code},updatesByLineId:n,paymentDetailsSection:{paymentTo:void 0,paymentType:q,paymentDate:r.bill_pay_info?.payment_date!=null?ee(r.bill_pay_info?.payment_date):ee(eo(me().toDate(),[0,6],x?0:1).toISOString()),withdrawFrom:L0(s,r.bill_pay_info?.from_account.account_id??"",r.bill_pay_info?.from_account.account_type??""),internationalTransferFeeBearerPaymentMethod:r.bill_pay_info?.international_transfer_fee_bearer_payment_method!=null?cv(r.bill_pay_info?.international_transfer_fee_bearer_payment_method):void 0},totalAmount:r.amount!=null?ao(r.amount,{currencyCode:r.currency_code??"USD",currencySymbol:r.currency_symbol??"$"}):void 0,recipientTotalAmount:r.recipient_total_amount!=null?ao(r.recipient_total_amount,{currencyCode:r.recipient_currency_code??"USD",currencySymbol:r.recipient_currency_symbol??"$"}):void 0,isCancelled:!1,toAccountVendorEmail:r.bill_pay_info?.to_account_vendor_email??void 0,isCollectToAccountInfoFromVendorContact:r.bill_pay_info?.is_collect_to_account_info_from_vendor_contact??!1,isRecurring:r.is_recurring??!1,outsideZeniPaymentLocalData:w}},$K=(s,i,r,t,e)=>{const a={};return Object.keys(s).forEach((n=>{switch(n){case"vendor":r!=null&&(a.tentativeVendorName=r,a.tentativeVendorName=r+(i===!0?" - "+t:""),a.currencyInInvoice=t,a.vendorCurrency=e),a.isVendorWithNewCurrency=i,s[n]&&(a.vendor="vendor");break;case"whatForSection":if(s.whatForSection!=null){const o=[];Object.keys(s.whatForSection).forEach((c=>{switch(c){case"invoiceNumber":s.whatForSection?.invoiceNumber!=null&&o.push("invoiceNumber");break;case"invoiceDate":s.whatForSection?.invoiceDate!=null&&o.push("invoiceDate");break;case"billDueDate":s.whatForSection?.billDueDate!=null&&o.push("billDueDate");break;case"memo":s.whatForSection?.memo!=null&&s.whatForSection?.memo!=""&&o.push("memo")}})),o.length>0&&o.push("currency"),a.whatForSectionFields=o}break;case"updatesByLineId":if(s.updatesByLineId!=null){const o={};Object.keys(s.updatesByLineId).forEach((c=>{const d=[],l=s.updatesByLineId[c];l.recipientAmount?.amount&&d.push("amount"),l.lineDescription!=null&&d.push("lineDescription"),l.account?.accountName!=null&&l.account?.accountName.length>0&&d.push("account"),l.class?.className!=null&&l.class?.className.length>0&&d.push("class"),l.billable&&d.push("billable"),o[c]=d})),a.linesFields=o}break;case"paymentDetailsSection":if(s.paymentDetailsSection!=null){const o=[];Object.keys(s.paymentDetailsSection).forEach((c=>{switch(c){case"paymentType":s.paymentDetailsSection?.paymentType!=null&&o.push("paymentType");break;case"paymentDate":s.paymentDetailsSection?.paymentDate!=null&&o.push("paymentDate");break;case"withdrawFrom":s.paymentDetailsSection?.withdrawFrom!=null&&o.push("withdrawFrom");break;case"paymentTo":s.paymentDetailsSection?.paymentTo!=null&&o.push("paymentTo")}})),a.paymentDetailsSectionFields=o}}})),a},n0=(s,i,r,t,e,a)=>{const n=Object.keys(a).length,o=e&&n>0?a[0].class:I1({accounting_class_id:"",accounting_class_name:""}),c=t&&n>0?a[0].account:b1({account_id:"",account_name:"",labels:[]});a[n]={class:o,account:c,amount:ao(s,i),recipientAmount:ao(s,i),billable:"not_billable",lineDescription:r,isCategoryMiscategorized:!1,isClassMiscategorized:!1,id:`${n}`,platformLineDetailType:"account_based_expense_line_detail",type:"transaction_with_account_and_class_line",isCategoryUpdateSelected:!1,isCategoryFirstTimeAutofilled:o!=null&&!!o.classId,isRetainedCategorySelected:!1,isClassUpdateSelected:!1,isClassFirstTimeAutofilled:c!=null&&!!c.accountId,isRetainedClassSelected:!1,isCategoryOrClassUpdated:!1,updateAllCheckbox:!1}},o0=(s,i,r,t)=>{if(r!=null){const e=X(t?.transactionById,r);return i||e?.isRecurring===!0?`${s}/${r}/recurring`:`${s}/${r}`}return i?`${s}/recurring`:`${s}`},tP=s=>{const i=s?.method.split("_")[1],r=s?.method.split("_")[2];return{code:i?q0(i):null,name:i==="outside-zeni"?"Outside Zeni":s?.method.replace(/(_depositAccount|_paymentAccount)/g,"")??"",sub_code:r?A1(F0(r)):null}},RK=s=>Gl(s.paymentDetailsSection?.paymentType?.method)?s.outsideZeniPaymentLocalData?.paymentDate?.format("YYYY-MM-DD")??null:s.paymentDetailsSection?.paymentDate?.format("YYYY-MM-DD")??null,i0=(s,i)=>{const r=x1(s.vendorReceiveDate,i);return{instance:s.instance,payment_date:r.format("YYYY-MM-DD"),vendor_receive_date:s.vendorReceiveDate.format("YYYY-MM-DD"),vendor_receive_date_notes:s.vendorReceiveDateNotes}},MK=(s,i)=>s?"bill_pay_marked_as_paid":i==="pending_approval"?"bill_pay_sent_for_approval":"bill_pay_updated",VK=s=>{const i={};return s.supportedAccountTypes!=null&&s.supportedAccountTypes.forEach((r=>{s.supportedDynamicFormByTypes[r.type].forEach((t=>{i[r.type]={...i[r.type],[t.name]:""}}))})),i},LK=s=>({is_applicant_declaration:!0,form_details:s}),FK=s=>{const i=s.cardHolderUser,r=`${i.firstName??""} ${i.lastName??""}`.trim()||i.email||i.userId;return{id:s.id,isChecked:!1,cardName:s.cardName,last4:s.accountLast4,limitAmount:s.limit?.amount??0,limitCadence:s.creditLimitFrequency?.code,owner:{userId:i.userId,displayName:r,roleLabel:s.cardHolderRoles?.titleAtCompany},utilizationAmount:(s.limit?.amount??0)-(s.available?.amount??0)}},c0=s=>s.cardPolicyState.mccCategoriesFetchState==="Completed",d0=(s,i)=>{const r=(e=>CM(e).cards.filter((a=>{return n=a.status?.code,!(n==="closed"||n==="closed_by_customer");var n})).map(FK))(s),t=s.cardPolicyState.mccCategories;return OM({initialData:i,cardsMasterList:r,mccCategories:t,suggestedAllowMerchants:s.cardPolicyState.suggestedAllowMerchants,suggestedBlockMerchants:s.cardPolicyState.suggestedBlockMerchants,suggestedAllowCategories:s.cardPolicyState.suggestedAllowCategories,suggestedBlockCategories:s.cardPolicyState.suggestedBlockCategories})},l0=s=>LV(s.userState,s.userRoleState,s.userListViewState,"cardHolderCandidate").users.map((i=>i.user)).filter((i=>i!=null)),ne=s=>s!=null&&s.value!=null&&s.confidence>=KV,ce=(s,i,r)=>{r!=null&&(typeof r=="string"&&r.trim()===""||(s.values[i]=r,s.autoFilledFieldNames.push(i)))},Dl=s=>{const i=ee(s);if(i.isValid())return i};function qK(s){switch(s){case"bill_pay_setup":return"Bill Pay";case"reimbursement_setup":return"Reimbursements";case"charge_card_setup":return"Cards";case"treasury_setup":return"Treasury";default:return"Checking"}}const jK=s=>{const i=s.realTimeSteps.map((r=>{const t=r.actors.map((e=>({id:e.userId,is_implicit_actor:e.isImplicitActor,type:e.type,sub_type:e.subType,id_type:e.idType})));return{action:r.action,operator:r.operator,step_position:r.stepPosition,step_creator_id:r.stepCreatorId,actors:t}}));return{entity_approval_id:s.entityApprovalId,entity_type:s.entityType,description:s.description,real_time_steps:i}},GK=(s,i,r,t,e)=>({merchant:t!=null?{id:t.id,name:t.name}:void 0,description:r.transaction_memo,lineDetail:{account:Ze(s,t?.accountId??"","account_list"),class:e!=null?Xa(i,{classId:e,reportId:"class_list"}):void 0},transactionDate:ee(r.transaction_date),amount:r.amount,currencyCode:r.currency_code??"USD",currencySymbol:r.currency_symbol??"$",recommendations:[],isCategoryUpdateSelected:!1,isCategoryFirstTimeAutofilled:!1,isRetainedCategorySelected:!1}),zK=s=>{const i=[],r=s.type==="mileage"?s.mileage:s.outOfPocket;return Object.keys(r).forEach((t=>{switch(t){case"merchant":i.push("merchant");break;case"amount":r.amount!==0&&i.push("amount");break;case"transactionDate":i.push("transactionDate");break;case"description":r.description!==""&&i.push("memo");break;case"lineDetail":r.lineDetail?.account?.accountId!=null&&i.push("account")}})),i},KK=(s,i)=>i!=null&&s.type==="out_of_pocket"&&s.merchant!=null?void 0:i,YK={transaction_type:"reimbursement",reimbursement_provider:"zeni"},HK=s=>{const i={from_account:{account_type:"treasury_account"},to_account:{account_type:"treasury_account"},amount:s.amount.amount,currency_code:s.amount.currencyCode,currency_symbol:s.amount.currencySymbol};return s.fromAccount&&s.fromAccount?.accType!=="treasuryAccount"?i.from_account={account_id:s.fromAccount.id,account_type:Me(s.fromAccount.accType)??""}:s.toAccount&&s.toAccount?.accType!=="treasuryAccount"&&(i.to_account={account_id:s.toAccount.id,account_type:Me(s.toAccount.accType)??""}),i},QK=s=>{const i=tP(s.paymentType);return{to_bank_account_id:s.paymentToAccountId,vendor_id:s.vendorId,amount:s.amount.amount,payment_method_type:i.code,payment_method_sub_type:i.sub_code,source_deposit_account_id:s.withdrawFrom?.id,payment_date:s.paymentDate.format("YYYY-MM-DD"),file_id:s.receiptFileId}},u0=(s,i,r=!1)=>{const{subscriptionId:t,subscriptionPlanId:e,subscriptionAddOnIds:a,subscriptionCouponIds:n,shouldProrate:o,applyEndOfTerm:c,invoiceImmediately:d,subscriptionEstmiate:l}=s,u={tenant_id:i,subscription_id:t,subscription_plan_id:e,subscription_coupon_ids:n,subscription_addon_ids:a,invoice_immediately:d,apply_end_of_term:c,should_prorate:o};return r===!1&&(u.estimate_query_hash=l?.estimateQueryHash),u},p0=(s,i,r=!1)=>{const{subscriptionPlanId:t,subscriptionCouponIds:e,subscriptionAddOnIds:a,invoiceImmediately:n,subscriptionEstmiate:o,startDate:c}=s,d={tenant_id:i,subscription_plan_id:t,subscription_coupon_ids:e,subscription_addon_ids:a,invoice_immediately:n};return c!=null&&(d.start_date=c.format("YYYY-MM-DD")),r===!1&&(d.estimate_query_hash=o?.estimateQueryHash),d},WK=(s,i,r)=>{const t={...XK(s)};return i.postAndGetJSON(`${i.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tags`,t).pipe(y((e=>ZK(e,r))),v((e=>p(Ml({fetchState:"Error",error:f("Unexpected Error","Create Tag REST API call errored out "+JSON.stringify(e)),tagsId:[]})))))},ZK=(s,i)=>T(s)&&s.data!=null&&s.data.tags.length>0?_([Zr(s.data.tags),Ml({fetchState:"Completed",tagsId:s.data.tags.map((r=>r.tag_id))}),cq({tagId:s.data.tags[0].tag_id,taskId:i})]):_([Ml({fetchState:"Error",error:s.status,tagsId:[]}),N({messageSection:"create_tag",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:s.status.message}]})]),XK=s=>({name:s});function eY(s){return{cannedResponseId:s.canned_response_id,content:s.content,createTime:ee(s.create_time),createdBy:s.created_by,isDeleted:s.is_deleted,name:s.name,updateTime:ee(s.update_time)}}const tY=(s,i,r)=>{const t=i.value,e={...rY(t,s)};return r.putAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${s}`,e).pipe(y((a=>aY(a,s))),v((a=>p(Vl({fetchState:"Error",taskId:s,error:f("Unexpected Error","Archive Task REST API call errored out"+JSON.stringify(a))})))))},aY=(s,i)=>{if(T(s)&&s.data!=null&&s.data.tasks.length>0){const r=[ze(s.data.tasks),ro(i),Nt(),Vl({fetchState:"Completed",taskId:i})];return _(r)}return _([Vl({fetchState:"Error",taskId:i,error:s.status}),N({messageSection:"archive_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:s.status.message}]})])},rY=(s,i)=>{const{taskState:r}=s;return{sync_token:Za(r,i)?.syncToken??"",is_archived:!0}},sY=(s,i)=>({name:s.name,assignees:s.assignee,description:s.description,priority:s.priority,status:s.status,tags:s.tagIds,time_spent:so(s.timeSpent),group_assignees:s.groupAssignees,parent_task_id:s.parentTaskId,task_group_ids:i,due_date:s.dueDate?.format("YYYY-MM-DD")??null}),nY=(s,i,r)=>{const{taskDetailState:t,taskState:e}=s,a=i!=null?Za(e,i)?.syncToken??"":"",n=(i!=null?t.editTaskStateById[i]:t.newTaskState).taskDetailLocalData;return{name:n.name,assignees:n.assignee,description:n.description,due_date:n.dueDate?.format("YYYY-MM-DD")??null,priority:n.priority,status:n.status,tags:n.tagIds,file_ids:n.fileIds,type:n.type.code,recurring_end_date:n.type.code==="recurring"?n.savedRecurringEndDate?.format(re)??null:null,recurring_frequency:n.type.code==="recurring"?n.recurringFrequency:null,recurring_start_date:n.type.code==="recurring"?n.recurringStartDate?.format(re)??null:null,recurring_days_of_week:n.type.code==="recurring"&&n.recurringFrequency==="semi_weekly"?n.recurringDaysOfWeek??[]:[],sync_token:a,task_group_ids:r,time_spent:so(n.timeSpent),group_assignees:n.groupAssignees,...i==null?{is_private:n.isPrivate??!1}:{}}},oY=s=>ee(s).format(kq),iY=(s,i,r)=>r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${s}/snooze`,{snoozed_until:i}).pipe(y((t=>cY(t,s,i))),v((t=>p(er({fetchState:"Error",taskId:s,error:f("Unexpected Error","Snooze Task REST API call errored out: "+JSON.stringify(t))}))))),cY=(s,i,r)=>{if(T(s)&&s.data!=null&&s.data.tasks.length>0){const t=[ze(s.data.tasks),ro(i),Nt(),er({fetchState:"Completed",taskId:i}),N({messageSection:"snooze_task",messageText:"success",type:"success",variables:[{variableName:"_snoozed_until_",variableValue:oY(r)}]})];return _(t)}return _([er({fetchState:"Error",taskId:i,error:s.status}),N({messageSection:"snooze_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:s.status.message}]})])},dY=(s,i)=>i.deleteAndGetJSON(`${i.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${s}/snooze`).pipe(y((r=>lY(r,s))),v((r=>p(er({fetchState:"Error",taskId:s,error:f("Unexpected Error","Unsnooze Task REST API call errored out: "+JSON.stringify(r))}))))),lY=(s,i)=>{if(T(s)&&s.data!=null&&s.data.tasks.length>0){const r=[ze(s.data.tasks),ro(i),Nt(),er({fetchState:"Completed",taskId:i}),N({messageSection:"unsnooze_task",messageText:"success",type:"success"})];return _(r)}return _([er({fetchState:"Error",taskId:i,error:s.status}),N({messageSection:"unsnooze_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:s.status.message}]})])},uY=s=>{const i={};return s.status!=null&&(i.status=s.status.code),s.priority!=null&&(i.priority=s.priority.code),s.assignees!=null&&(i.assignees=s.assignees),s.groupAssignees!=null&&(i.group_assignees=s.groupAssignees),s.dueDate!=null&&(i.due_date=s.dueDate.format(re)),s.tagIds!=null&&(i.tags=s.tagIds),s.timeSpent!=null&&(i.time_spent=so(s.timeSpent.replace(/\D/g,""))),s.isArchived!=null&&(i.is_archived=s.isArchived),s.isDeleted!=null&&(i.is_deleted=s.isDeleted),"snoozedUntil"in s&&(i.snoozed_until=s.snoozedUntil!=null?s.snoozedUntil.toISOString():null,i.is_snooze_notification_sent=!1,s.snoozedUntil==null&&(i.snoozed_by=null,i.snoozed_at=null)),i},pY=(s,i)=>{const{tagState:r}=s,t=i.tagIds.map((e=>X(r.tagByID,e))).filter((e=>e!=null)).map((e=>e.tagId));return{task_id:i.id,name:i.name,assignees:i.assignees,description:i.description,group_assignees:i.groupAssignees,is_archived:i.isArchived,is_deleted:i.isDeleted,snoozed_until:i.snoozedUntil!=null?i.snoozedUntil.toISOString():null,due_date:i.dueDate!=null?i.dueDate.format(re):null,priority:i.priority.code,status:i.status.code,tags:t,type:i.type.code,file_ids:i.fileIds,recurring_end_date:i.recurringEndDate!=null?i.recurringEndDate.format(re):null,recurring_frequency:i.recurringFrequency??null,recurring_start_date:i.recurringStartDate!=null?i.recurringStartDate.format(re):null,task_group_ids:i.taskGroupIds,time_spent:so(i.timeSpent)}},mY=s=>({transaction_id:s.id}),yY=(s,i,r,t,e,a,n,o,c)=>{const d=Object.assign({},i);if(d.memo=s.memo??"",d.documentId=s.documentId??d.documentId,o!=null&&o.length>0){const m=new Set(o);d.lines=d.lines?.filter((h=>!m.has(h.id)))}const l={};for(const m in s.updatesByLineId){const h=s.updatesByLineId[m],g=d.lines?.map((I=>{if(I.id===m){const b=Object.assign({},I);if(b.lineDescription=h.lineDescription??"",h.amount!=null&&(b.amount=h.amount),h.class!=null&&(b.class=h.class),h.account!=null&&(b.account=h.account),h.project!=null&&(b.project=h.project),h.customer!=null?b.customer=h.customer:b.customer=void 0,h.vendor!=null?b.vendor=h.vendor:b.vendor=void 0,h.postingType!=null){const P=b;P.postingType=h.postingType,h.postingTypeName!=null&&(P.postingTypeName=h.postingTypeName)}h.recommendation!=null&&(l[I.id]=h.recommendation);const E=r?.find((P=>P.lineId===I.id));return E&&(b.cotViewingFlags={vendor:E.vendor,category:E.category,class:E.class,lineId:E.lineId}),b}return I}));d.lines=g}if(c!=null&&c.length>0){const m=c.map(hY);d.lines=[...d.lines??[],...m]}let u;return d.recommendations=l,E0(d)?(u=P0(d),!t||d.type!=="invoice"&&d.type!=="credit_memo"||s.project==null||(u={...u,accounting_project_id:s.project.projectId,...s.project.accountingProviderProjectId!=null?{accounting_project_integration_id:s.project.accountingProviderProjectId}:{},...s.project.projectName?{accounting_project_name:s.project.projectName}:{}})):u=as(d)?n!=null&&n.type==="customer"?T0(d,a):A0(d,e):N0(d)?O0(d):C0(d),x0(u,d)},_Y=(s,i,r,t)=>{if(!t&&(as(s)||Hn(s.type)!=null)){const e=(s.lines??[]).filter((a=>a.type==="transaction_with_account_and_class_line"||a.type==="journal_entry_transaction_line"||a.type==="transaction_with_product_or_service_line"));if(r&&e.some((a=>(a.class?.classId??"")==="")))return[];if(Hn(s.type)!=null&&e.some((a=>{const n=a;return n.vendor==null&&n.customer==null})))return[]}return(s.lines??[]).filter((e=>{if(e.type!=="transaction_with_account_and_class_line"&&e.type!=="journal_entry_transaction_line"&&e.type!=="transaction_with_product_or_service_line")return!1;const a=e,n=!f0(i,a.account?.qboId),o=!r||(a.class?.classId??"")!=="",c=(a.amount?.amount??0)!==0,d=!(e.type==="journal_entry_transaction_line"||Hn(s.type)!=null)||a.vendor!=null||a.customer!=null;return n&&o&&c&&d})).map((e=>e.id)).filter(Boolean)},m0={accountDescription:"",accountId:"",accountName:"",labels:[]},hY=s=>s.type==="journal_entry_transaction_line"?{...s,id:"",type:"journal_entry_transaction_line",platformLineDetailType:s.platformLineDetailType??"journal_entry_line_detail",account:s.account??m0,billable:s.billable??"not_billable",isCategoryMiscategorized:!1,isClassMiscategorized:!1,lineTransactionType:s.lineTransactionType??"journal_entry",postingType:s.postingType??"debit",postingTypeName:s.postingTypeName!=null&&s.postingTypeName!==""?s.postingTypeName:(s.postingType??"debit").charAt(0).toUpperCase()+(s.postingType??"debit").slice(1)}:{...s,id:"",type:"transaction_with_account_and_class_line",platformLineDetailType:s.platformLineDetailType??"account_based_expense_line_detail",account:s.account??m0,billable:s.billable??"not_billable",isCategoryMiscategorized:!1,isClassMiscategorized:!1},SY=s=>{const i=[];let r;for(r in s){const t=s[r],e={recommendations:U0(t.recommendations),entity_id:t.entityId,entity_type:t.entityType,is_bulk_update:t.isBulkUpdate,updated_entity_id:t.updatedEntityId};t.entityType==="vendor"&&t.vendorName!=null&&(e.vendor_name=t.vendorName),i.push(e)}return i};function y0(s){let i=ee(ae(s.start));const r=ee(ae(s.end));i=i.set("date",1);const t=Math.ceil(r.diff(i,"month",!0)),e=[];if(t>0||t==0){let a=i.clone().set("date",1);for(let n=0;n<t-1;++n){const o=a.daysInMonth(),c={day:1,month:a.month()+1,year:a.year()},d={day:o,month:a.month()+1,year:a.year()};e.push({start:c,end:d}),a=a.add(1,"month")}e.push({start:{day:a.date(),month:a.month()+1,year:a.year()},end:{day:r.date(),month:r.month()+1,year:r.year()}})}else console.error(`Invalid time period ${JSON.stringify(s)}`);return e}const gY=(s,i)=>{const r=[],t={startDate:ee(i.data?.report.data_available_start_date),endDate:ee(i.data?.report.data_available_end_date)};return r.push(kj(s.zeniId,i.data?.report.expense)),r.push(Bj({id:s.id,name:s.name},t,i.data?.report.expense,i.data?.report.insights)),r.push(j0(t)),r},fY=(s,i)=>{const r=[],t={startDate:ee(i.data?.report.data_available_start_date),endDate:ee(i.data?.report.data_available_end_date)};return r.push(Dj(s,t,i.data?.report.income,i.data?.report.insights)),r.push(j0(t)),r},vY=s=>[...s].sort(((i,r)=>(i.create_time!=null?ee(i.create_time):me()).isBefore(r.create_time!=null?ee(r.create_time):me())?1:-1))?.[0],IY=(s,i)=>{switch(s){case"manager":return{is_manager_candidate:!0};case"cardHolderCandidate":return{is_card_holder_candidate:!0,is_include_cards_count:!0};case"taskManagerCandidate":return{is_task_manager_candidate:!0};case"cardAdmin":return{is_card_admin_candidate:!0};default:return{is_zeni:i}}},bY=s=>{if(s==="vendorsTab")return"vendor_list"},EY=s=>{switch(s){case"updateTo":return"recommended_global_merchant_name";case"status":return"status";case"ytd":return"year_to_date_spend";default:return"vendor_name"}},Fn=s=>s.map((i=>PY(i))),PY=s=>({vendor_id:s.vendor_id,vendor_name:s.vendor_name,logo:s.logo,qbo_id:s.qbo_id,currency_code:s.currency_code,currency_symbol:s.currency_symbol,transaction_attachments:s.transaction_attachments}),qn=s=>{const i=[];return s.forEach((r=>{r.last_updated_vendor_name_by_user!=null&&i.push(Q0(r.last_updated_vendor_name_by_user))})),i},jn=s=>{const i=[];return s.forEach((r=>{const t=r.recommendations[0]?.global_merchants.filter((e=>e.global_merchant_id!=null));TY(t,i)})),i},TY=(s,i)=>{s.forEach((r=>i.push(r)))},AY=(s,i,r,t,e,a,n)=>{const o=n?.globalMerchantId!=null?ts(ql(n),["create_time","update_time"]):n!=null?ts(W0(n),["create_time","update_time"]):null;return{vendor_name:s,qbo_id:a??null,selected_global_merchant:t===!0?null:o,recommendations:Xn(i,r),is_employee:t,is_local_contractor:e}},NY=(s,i,r)=>{const t=Array({globalMerchants:Qn(i,s.recommendationIds)}),e=Array({globalMerchants:s.recommendedNonExistingGlobalMerchants});let a=Ll(i,s.selectedVendorId);e.length>0&&s.selectedVendorId===e[0].globalMerchants[0]?.globalMerchantName&&(a=e[0].globalMerchants[0]);const n=Oe(r,s.selectedVendorId);let o="";if(s.vendorRenamedText!=null)o=s.vendorRenamedText;else if(n!=null)o=n.name;else{const c=Ll(i,s.selectedVendorId);o=c!=null?c?.globalMerchantName:e[0]?.globalMerchants[0]?.globalMerchantName??""}return{vendorName:o,selectedGlobalMerchant:a,recommendations:t,nonExistingRecommendations:e}},OY=(s,i,r,t,e)=>({tenant_name:s.tenantName,merchant_type:"vendor",tenant_id:s.tenantId,selected_global_merchant:t!=null?ts(ql(t),["create_time","update_time"]):e!=null?lG(e):null,recommendations:i,merchant_name:r}),CY=s=>{const i=[];return s.forEach((r=>{r.last_updated_merchant_name_by_user!=null&&i.push(Q0(r.last_updated_merchant_name_by_user))})),i},xY=s=>{let i=[];return s.forEach((r=>{i=[...new Set([...i,...Z0(r.recommendations)])]})),i},UY=s=>{switch(s){case"originalVendor":return"original_vendor";case"requestedVendor":return"requested_vendor";case"recommended":return"recommended_global_merchant_name";default:return"tenant_name"}},kY=(s,i)=>({tenant_name:s.tenantName,merchant_type:"vendor",tenant_id:s.tenantId,review_status:"review_rejected",recommendations:i,merchant_name:s.tenantMerchantName}),Jl=s=>N({messageSection:"oauth_consent_approve",messageText:"failed",type:"error",variables:[{variableName:"__reason__",variableValue:s}]}),BY=[(s,i,r)=>s.pipe(S(WR.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_bill_pay_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),av()];return _(n)}return p(_n(a.status),N({messageSection:"bill_pay_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(_n(f("Unexpected Error","Accept Bill Pay Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(ZR.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_unit_migration_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),av()];return _(n)}return p(_n(a.status),N({messageSection:"bill_pay_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(_n(f("Unexpected Error","Accept Bill Pay Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(NV.match),y((t=>{const{companyId:e,enableChargeCard:a,chargeCardSetupViewType:n,isEarlyPayEnabled:o,isCompanyInterestedInChargeCard:c}=t.payload;let d;switch(n){case"charge_cards":d={is_charge_cards_tos_accepted:!0,...a&&{is_charge_cards_enabled:!0,...o&&{is_auto_pay_enabled:!0}}};break;case"charge_cards__debit_cards":d={is_charge_cards_tos_accepted:!0,is_debit_cards_tos_accepted:!0,...a&&{is_charge_cards_enabled:!0,is_debit_cards_enabled:!0,...o&&{is_auto_pay_enabled:!0}}};break;case"debit_cards":d={is_debit_cards_tos_accepted:!0,...a&&{is_debit_cards_enabled:!0},...c&&{is_company_interested_in_charge_card:!0}};break;default:d={}}return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,d).pipe(y((l=>{if(M(l)&&l.data!=null){const u=[V({users:l.data.users}),Y(l.data.user_roles),Q({payload:l.data.companies,schema:{}}),OV()];return _(u)}return p(qv(l.status),N({messageSection:"charge_card_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))})),v((l=>p(qv(f("Unexpected Error","Accept Charge Card Terms errored out"+JSON.stringify(l)))))))}))),(s,i,r)=>s.pipe(S(nF.match),y((t=>{const{userRoleId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/${e}`,{is_reimbursement_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[oF(a.data.user_roles[0]),UI()];return _(n)}return p(On(a.status),N({messageSection:"reimbursement_accept_employee_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(On(f("Unexpected Error","Accept Employee Remi Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(nB.match),y((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/config`;return r.putAndGetJSON(t,{is_invoicing_tos_accepted:!0}).pipe(A((e=>T(e)&&e.data!=null?p(Ni(e.data),oB(),Vt()):p(oh(e.status)))),v((e=>p(oh(f("Unexpected Error","Accept invoicing terms REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(eT.match),y((t=>{const{userRoleId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/${e}`,{is_master_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[Y(a.data.user_roles),tT(a.data.user_roles[0]),aT()];return _(n)}return p(Tu(a.status))})),v((a=>p(Tu(f("Unexpected Error","Accept Master TOS errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(iF.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_reimbursement_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),UI()];return _(n)}return p(On(a.status),N({messageSection:"reimbursement_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(On(f("Unexpected Error","Accept Remi Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(hF.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_treasury_accounts_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),SF()];return _(n)}return p(wI(a.status),N({messageSection:"treasury_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(wI(f("Unexpected Error","Accept Treasury Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(jF.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_deposit_accounts_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),GF()];return _(n)}return p(WI(a.status),N({messageSection:"zeni_account_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(WI(f("Unexpected Error","Accept Zeni Account Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(sJ.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_onboarding_ai_activation_viewed:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[Q({payload:a.data.companies,schema:{}}),nJ()];return _(n)}return p(BS(a.status))})),v((a=>p(BS(f("Unexpected Error","Acknowledge - Onboarding AI Activation Viewed errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(oJ.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_onboarding_ai_finance_team_acknowledged:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[Q({payload:a.data.companies,schema:{}}),iJ()];return _(n)}return p(N({messageSection:"onboarding_customer_view_complete",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}),DS(a.status))})),v((a=>p(DS(f("Unexpected Error","Acknowledge - Onboarding AI Finance Team errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(OA.match),y((t=>{const{type:e,paymentSourceType:a,setupIntentId:n}=t.payload,o={...fz({type:e,processor_token:n,payment_source_type:a})};return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/payment-sources`,o).pipe(y((c=>T(c)&&c.data?_([vo({fetchState:"Completed",paymentSources:c.data.payment_sources}),N({messageSection:"add_card_payment_source",messageText:"success",type:"success"}),Io()]):_([vo({fetchState:"Error",error:c.status}),N({messageSection:"add_card_payment_source",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"Card could not be linked!"}]})]))),v((c=>p(vo({fetchState:"Error",error:f("Unexpected Error","Add Card Payment Source API call errored out "+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(bk.match),y((t=>{const{amount:e,currencyCode:a,customerId:n,description:o}=t.payload,c=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(n)}/promotional-credits`,d={amount:e,description:o};return a!=null&&a!==""&&(d.currency_code=a),r.postAndGetJSON(c,d).pipe(y((l=>T(l)&&l.data!=null?[Ek(),Ys({id:n})]:p(R_(l.status)))),v((l=>p(R_(f("Unexpected Error","Add promotional credits REST API call errored out "+JSON.stringify(l)))))))}))),(s,i)=>s.pipe(y((r=>{if(!no.match(r))return F;const t=i.value,e=t.cardPolicyState.policyDocumentExtraction,a=e.extractedRules;if(a==null)return F;const n=(l=>({allowedEntity:{categoryCodes:l.allowedEntity.categoryCodes??[],merchantNames:l.allowedEntity.merchantNames??[]},blockedEntity:{categoryCodes:l.blockedEntity.categoryCodes??[],merchantNames:l.blockedEntity.merchantNames??[]},confidenceScore:l.confidenceScore,policyName:l.policyName,requiredReceiptThreshold:l.requiredReceiptThreshold,transactionLimit:l.transactionLimit}))(a),o=(l=>l.cardPolicyState.vendorSearch.vendors.map((u=>fM(u.name,!1))))(t),c=(l=>l.cardPolicyState.mccCategories.map((u=>vM(IM(u),!1))))(t),d={extracted:n,vendorSearchOptions:o,categorySearchOptions:c};return e.aiCfoAnswerId!=null?p(SM(d)):p(gM(d))}))),(s,i,r)=>s.pipe(S(PG.match),$t((t=>{const{userId:e,zeniSessionId:a,tenantId:n,clientId:o,redirectUri:c,codeChallenge:d,codeChallengeMethod:l,state:u,responseType:m}=t.payload,h={"zeni-user-id":e,"zeni-tenant-id":n};return a!=null&&(h["zeni-session-id"]=a),r.postJSON(`${r.apiEndPoints.authMicroServiceBaseUrl}/oauth/authorize/approve`,{client_id:o,redirect_uri:c,code_challenge:d,code_challenge_method:l,state:u,response_type:m,tenant_id:n},h).pipe(Oa((g=>_(g.json()).pipe(y((I=>{if(!g.ok){const P=I,O=P?.error??P?.message??P?.status?.message??`Authorization failed (${g.status})`;return _([hl(f(O)),Jl(O)])}const b=I,E=b?.redirect_url??b?.data?.redirect_url;if(E==null||E===""){const P="No redirect URL returned from authorization server";return _([hl(f(P)),Jl(P)])}return p(TG({redirectUrl:E}))}))))),v((g=>{const I="OAuth approve request failed: "+(g instanceof Error?g.message:JSON.stringify(g));return _([hl(f(I)),Jl(I)])})))}))),(s,i,r)=>s.pipe(S(CR.match),y((t=>{const{billId:e,approvalType:a,description:n}=t.payload,o={approval_status:a,is_include_entity_approval:!0,description:n};return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}/approval-status`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data.entity_approvals.map((l=>l.entity_approval_id));return _([V({users:c.data.users??[]}),Et(c.data?.entity_approvals),xR(e,d),N({messageSection:a==="approved"?"bill_pay_approved":"bill_pay_rejected",messageText:"success",type:"success"})])}return p(Cf(e,c.status),N({messageSection:"bill_pay_approved",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(Cf(e,f("Unexpected Error","Approve Or Reject Bill errored out"+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(XR.match),y((t=>{const{approvalType:e,description:a}=t.payload,{billsBulkActionViewState:n}=i.value,o=(function(c,d,l){const u=c.map((m=>({entity_id:m,request_data:{approval_status:d,is_include_entity_approval:!0,description:l??""}})));return{operation_type:d==="approved"?"approve":"reject",operations:u}})(n.billsSelectedForBulkAction,e,a);return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/bills/transactions`,o).pipe(y((c=>{if(M(c)){const d=[],l=c.data?.total_operations_processing??0;return d.push(Ic({billsProcessing:l,refreshTime:c.data?.hard_refresh_after_sec??0})),d.push(bc(c.data?.operations??[])),l>0&&d.push(N({messageSection:"bill_pay_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:l.toString()},{variableName:"_bill_",variableValue:l>1?"bills":"bill"},{variableName:"_action_",variableValue:e}]})),_(d)}return p(Fa(c.status),N({messageSection:"bill_pay_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(Fa(f("Unexpected Error","Bill bulk action REST API call errored out "+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(JL.match),y((t=>{const{reimbursementId:e,approvalType:a,description:n}=t.payload,o={approval_status:a,is_include_entity_approval:!0,description:n};return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${e}/approval-status`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data.entity_approvals.map((l=>l.entity_approval_id));return _([V({users:c.data.users??[]}),Et(c.data?.entity_approvals),wL(e,d),N({messageSection:a==="approved"?"reimbursement_approved":"reimbursement_rejected",messageText:"success",type:"success"})])}return p(yI(e,c.status),N({messageSection:a==="approved"?"reimbursement_approved":"reimbursement_rejected",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(yI(e,f("Unexpected Error","Approve Or Reject Reimbursement errored out"+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(cF.match),y((t=>{const{approvalType:e,description:a}=t.payload,{remisBulkActionViewState:n}=i.value,o=(function(c,d,l){const u=c.map((m=>({entity_id:m,request_data:{approval_status:d,is_include_entity_approval:!0,description:l??""}})));return{operation_type:d==="approved"?"approve":"reject",operations:u}})(n.remisSelectedForBulkAction,e,a);return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/reimbursements/transactions`,o).pipe(y((c=>{if(M(c)){const d=[],l=c.data?.total_operations_processing??0;return d.push(xd({remisProcessing:l,refreshTime:c.data?.hard_refresh_after_sec??0})),d.push(Ud(c.data?.operations??[])),l>0&&d.push(N({messageSection:"reimbursement_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:l.toString()},{variableName:"_report_",variableValue:l>1?"reports":"report"},{variableName:"_action_",variableValue:e}]})),_(d)}return p(Ga(c.status),N({messageSection:"reimbursement_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(Ga(f("Unexpected Error","Remi Approve or Reject bulk action REST API call errored out "+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(iG.match),y((t=>{const{merchantId:e}=t.payload,{globalMerchantState:a,vendorGlobalReviewViewState:n}=i.value,{vendorGlobalByMerchantId:o}=n,c=cG(i.value).vendorGlobalReviewData.find((g=>g.merchant.tenantMerchantId===e)),d=o[e].vendorGlobalReviewViewLocalData,l=d!=null&&d.selectedMerchantId!=null?Ll(a,d.selectedMerchantId):void 0;let u,m=l?.globalMerchantName;const h=yE(a,_E(d.tenantId,e));if(m!=null||d.currentSelection!=="recommendedFirst"&&d.currentSelection!=="recommendedSecond"||(d.currentSelection==="recommendedFirst"?(m=c?.recommendations[0].globalMerchantName,u=c?.recommendations[0]):d.currentSelection==="recommendedSecond"&&(m=c?.recommendations[1].globalMerchantName,u=c?.recommendations[1])),d!=null&&m!=null&&h!=null){const g=Array({globalMerchants:Qn(a,d.recommendationIds)}),I=Array({globalMerchants:d.recommendedNonExistingGlobalMerchants}),b=Xn(g,I),E={...OY(h,b,m,l,u)};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/reviews/global-merchant-list/${e}`,E).pipe(y((P=>{const O=h.tenantMerchantName===m;if(M(P)&&m!=null){const C=O?[{variableName:"_merchant_name_",variableValue:m}]:[{variableName:"_original_merchant_name_",variableValue:h.tenantMerchantName},{variableName:"_approved_merchant_name_",variableValue:m}],U=[dG(e),N({messageSection:O?"approve_original_merchant":"approve_global_merchant",messageText:"success",type:"success",variables:C})];return _(U)}return P.status.code===409?p(ml({merchantId:e,status:P.status})):p(ml({merchantId:e,status:P.status}),N({messageSection:O?"approve_original_merchant":"approve_global_merchant",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:P.status.message}]}))})),v((P=>p(ml({merchantId:e,status:f("Unexpected Error","Approve Vendor Global Review REST API call errored out"+JSON.stringify(P))})))))}return p([])}))),(s,i,r)=>s.pipe(S(lM.match),y((t=>{const e=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${e}`).pipe(y((a=>{if(M(a)){const n=[uM(e),Vc({fetchState:"Completed",templateId:e})];return _(n)}return p(Vc({fetchState:"Error",error:a.status,templateId:e}))})),v((a=>p(Vc({fetchState:"Error",error:f("Unexpected Error","Archive card-policy REST API call errored out"+JSON.stringify(a)),templateId:e})))))}))),(s,i,r)=>s.pipe(S(gq.match),y((t=>tY(t.payload.taskId,i,r)))),(s,i,r)=>s.pipe(S(My.match),A((t=>{const{period:e}=t.payload,a=i.value,n=H(a),o=a.expenseAutomationViewState.selectedPeriodByTenantId[n.tenantId],c=a.expenseAutomationTransactionsViewState.transactionCategorizationView.review.uiState,d=c.pageToken,l=u=>{const m={start_date:ae(e.start),end_date:ae(e.end),auto_categorized:!1,sort_by:ui(c.sortKey),sort_order:c.sortOrder==="ascending"?"asc":"desc",page_token:u,page_size:25,search_text:c.searchString,transaction_group:a.expenseAutomationTransactionsViewState.selectedTransactionGroup};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(m))}`)};return l(null).pipe(Jx((u=>{if(!T(u)||u.data==null)return F;const m=u.data.next_page_token??null;return m==null||m===d?F:l(m)})),wx(((u,m)=>{if(!T(m)||m.data==null)return{...u,failureStatus:m.status};const h=m.data.next_page_token??null;return{...u,allTransactions:[...u.allTransactions,...m.data.transactions],finalPageToken:h,finalStatus:m.status,totalCount:m.data.total_count}}),{allTransactions:[],failureStatus:null,finalPageToken:null,finalStatus:null,totalCount:0}),y((u=>{if(u.failureStatus!=null||u.finalStatus==null)return p(ws({selectedPeriod:o,selectedTab:Ya,status:u.failureStatus??f("Unexpected Error","background refetch review tab received error response")}));const m=u.allTransactions.map((g=>g.transaction_id)),h=Vy(u.allTransactions);return _([Ce(u.allTransactions,(g=>g.transaction_id),"merge"),Ly({selectedTab:Ya,uiState:{pageToken:u.finalPageToken}}),mi(Ya,m,o,!1,u.finalPageToken,u.totalCount,h,!0),$s({selectedPeriod:o,selectedTab:Ya,totalCount:u.totalCount}),Fy({refreshViewInBackground:!0,selectedTab:Ya,status:u.finalStatus})])})),v((u=>p(ws({selectedPeriod:o,selectedTab:Ya,status:f("Unexpected Error","background refetch review tab REST API call errored out"+JSON.stringify(u))})))))}))),(s,i,r)=>s.pipe(S(rl.match),A((t=>{const{taskIds:e,updates:a,groupId:n}=t.payload,o=uY(a);n!=null&&(o.task_group_ids=[n]);const c={task_ids:e,updates:o};return r.putAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/bulk-update`,c).pipe(y((d=>{if(T(d)&&d.data!=null){const l=a.isArchived===!0||a.isDeleted===!0||"snoozedUntil"in a;return p(ze(d.data.tasks),xb({taskIds:e,groupId:n,removeFromList:l}),Nt())}return p(Ub({error:d.status}))})),v((d=>p(Ub({error:f("Unexpected Error","Bulk update task list REST API call errored out"+JSON.stringify(d))})))))}))),(s,i)=>s.pipe(S((r=>Er.match(r)||Na.match(r))),y((r=>{const{batchId:t}=r.payload;return Ha(Dx).pipe(y((()=>{const e=i.value.expenseAutomationMissingReceiptsViewState.bulkUpload;return e.phase!=="matching"||e.currentBatchId!==t?F:_([Ry(t),Pr({cacheOverride:!0}),ci()])})),De(vt(s.pipe(S(Ds.match)),s.pipe(S(pi.match),S((e=>e.payload.batchId===t&&e.payload.status==="completed"))),s.pipe(S(Aa.match),S((e=>e.payload.batchId===t))))))}))),s=>s.pipe(S((i=>Er.match(i)||Na.match(i))),A((i=>{const{batchId:r}=i.payload;return vt(s.pipe(S(Aa.match)),s.pipe(S(Gn.match))).pipe(S((t=>t.payload.batchId===r)),Ue(1),y((t=>{const{summary:e}=t.payload;return p(N({messageSection:"receipts_bulk_match",messageText:"success",type:"success",variables:[{variableName:"_matched_",variableValue:String(e.matched)},{variableName:"_total_",variableValue:String(e.total)}]}))})),De(s.pipe(S(Ds.match))))}))),(s,i,r)=>s.pipe(S(yx.match),A((t=>{const{files:e}=t.payload,a=new FormData;for(const n of e)a.append("files",n,n.name);return r.postFormData(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`,a).pipe(y((n=>{if(T(n)&&n.data!=null){const o=String(n.data.batch_id??"").trim();return o===""?p(ii({error:f("Unexpected Error","Bulk upload succeeded but batch_id was missing or empty.")})):j(p(hx(100)),Ha(_x).pipe(y((()=>p(Er({batchId:o}))))))}return p(ii({error:n.status}))})),v((n=>p(ii({error:f("Unexpected Error","Bulk upload receipts API call errored out: "+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(LP.match),y((t=>{const{tenantId:e,companyId:a}=t.payload,n=`${`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`}/ai-accountant/cancel-onboarding`;return r.postAndGetJSON(n,{tenant_id:e,company_id:a}).pipe(y((o=>T(o)?_([FP(e),uo(),N({messageSection:"common",messageText:"success",type:"success"})]):_([vu(e,o.status),N({messageSection:"common",messageText:"failed",type:"error"})]))),v((o=>_([vu(e,f("Unexpected error","AI Accountant cancel onboarding failed: "+JSON.stringify(o))),N({messageSection:"common",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(UR.match),y((t=>{const e={bill_pay_provider:"zeni",is_delete_bill:t.payload.isDeleteBill},{billTransactionState:a}=i.value,n=a.transactionById[t.payload.billId],o=n?.isRecurring??!1,c=n?.recurringBillConfigId;let d=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${t.payload.billId}`;return d=o===!0?`${d}/recurring/cancel-payment`:`${d}/cancel-payment`,r.putAndGetJSON(d,e).pipe(y((l=>{if(t.payload.isDeleteBill===!0&&M(l)){const u=[];return u.push(pn("Completed",t.payload.billId,t.payload.isDeleteBill)),n!=null&&u.push(xf({billId:t.payload.billId,tab:n.billPayInfo.stage.code})),u.push(lc(Ne(t.payload.billId))),o===!0&&c!=null&&u.push(Uf(c)),u.push(N({messageSection:"bill_pay_cancelled_deleted",messageText:"success",type:"success"})),_(u)}return T(l)&&l.data!=null&&l.data.transactions[0]?.transaction_id!=null?p(mn(l.data.transactions[0]),pn("Completed",t.payload.billId,t.payload.isDeleteBill),N({messageSection:"bill_pay_cancelled",messageText:"success",type:"success"})):p(pn("Error",t.payload.billId,t.payload.isDeleteBill,l.status),N({messageSection:"bill_pay_cancelled_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))})),v((l=>p(pn("Error",t.payload.billId,t.payload.isDeleteBill,f("Unexpected Error","Cancel and Delete bill REST API call errored out "+JSON.stringify(l)))))))}))),(s,i,r)=>s.pipe(S($L.match),y((t=>{const e={reimbursement_provider:"zeni",is_delete_reimbursement:t.payload.isDeleteRemi},{reimbursementState:a}=i.value,n=a.reimbursementById[t.payload.reimbursementId];return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${t.payload.reimbursementId}/cancel-payment`,e).pipe(y((o=>{if(t.payload.isDeleteRemi===!0&&M(o)){const c=[An("Completed",t.payload.reimbursementId,t.payload.isDeleteRemi)];return n!=null&&c.push(_I({remiId:t.payload.reimbursementId,tab:n.reimbursementInfo.stage.code})),c.push(Pd(t.payload.reimbursementId)),c.push(N({messageSection:"reimbursement_cancelled_deleted",messageText:"success",type:"success"})),_(c)}return T(o)&&o.data!=null&&o.data?.transaction?.transaction_id!=null?p(bd(o.data.transaction),An("Completed",t.payload.reimbursementId,t.payload.isDeleteRemi),N({messageSection:"reimbursement_cancelled",messageText:"success",type:"success"})):p(An("Error",t.payload.reimbursementId,t.payload.isDeleteRemi,o.status),N({messageSection:"reimbursement_cancelled",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:o.status.message}]}))})),v((o=>p(An("Error",t.payload.reimbursementId,t.payload.isDeleteRemi,f("Unexpected Error","Cancel and Delete reimbursement REST API call errored out "+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(e1.match),y((t=>{const{operationType:e,description:a}=t.payload,{billsBulkActionViewState:n}=i.value,o=(function(d,l,u){const m=d.map((h=>({entity_id:h,request_data:{bill_pay_provider:"zeni",description:u}})));return{operation_type:l,operations:m}})(n.billsSelectedForBulkAction,e,a),c=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/bills/transactions`;return(e==="cancel"?r.putAndGetJSON(c,o):r.deleteAndGetJSON(c,o)).pipe(y((d=>{if(M(d)){const l=[],u=d.data?.total_operations_processing??0;return l.push(Ic({billsProcessing:u,refreshTime:d.data?.hard_refresh_after_sec??0})),l.push(bc(d.data?.operations??[])),u>0&&l.push(N({messageSection:"bill_pay_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:u.toString()},{variableName:"_bill_",variableValue:u>1?"bills":"bill"},{variableName:"_action_",variableValue:e==="cancel"?"canceled":"deleted"}]})),_(l)}return p(Fa(d.status),N({messageSection:"bill_pay_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(Fa(f("Unexpected Error","Bill bulk action REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(dF.match),y((t=>{const{operationType:e,description:a}=t.payload,{remisBulkActionViewState:n}=i.value,o=(function(d,l,u){const m=d.map((h=>({entity_id:h,request_data:{reimbursement_provider:"zeni",description:u}})));return{operation_type:l,operations:m}})(n.remisSelectedForBulkAction,e,a),c=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/reimbursements/transactions`;return(e==="cancel"?r.putAndGetJSON(c,o):r.deleteAndGetJSON(c,o)).pipe(y((d=>{if(M(d)){const l=[],u=d.data?.total_operations_processing??0;return l.push(xd({remisProcessing:u,refreshTime:d.data?.hard_refresh_after_sec??0})),l.push(Ud(d.data?.operations??[])),u>0&&l.push(N({messageSection:"reimbursement_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:u.toString()},{variableName:"_report_",variableValue:u>1?"reports":"report"},{variableName:"_action_",variableValue:e==="cancel"?"canceled":"deleted"}]})),_(l)}return p(Ga(d.status),N({messageSection:"reimbursement_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(Ga(f("Unexpected Error","Remi Cancel or Delete bulk action REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(_$.match),y((t=>{const e=i.value,{scheduleAccruedDetailState:a}=e,{rowId:n,scheduleType:o}=t.payload,c=[],d=a.selectedJEAccruedScheduleKey;if(d==null)return _(c);const l=sa(d,e);if(l==null)return _(c);const u=l.jeScheduleId,m=e.scheduleAccruedDetailState.editScheduleStateByDetailId[u],h=m?.selectedVendor?.name??"",g={...TK(e,m,d,n)},I={je_schedule_type:o};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${u}?query=${encodeURIComponent(JSON.stringify(I))}`,g).pipe(y((b=>{if(T(b)&&b.data!=null){const E=b.data.je_schedules[0].je_schedule_id;return c.push(ca(b.data.je_schedules),br(b.data.je_schedules,b.data.scheduled_journal_entries),Hi("Completed"),Va(o,d,E),N({messageSection:"cancel_journal_entry",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:h}]})),_(c)}return c.push(Hi("Error",b.status)),c.push(N({messageSection:"cancel_journal_entry",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:b.status.message}]})),_(c)})),v((b=>_([N({messageSection:"cancel_journal_entry",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(b)}]}),Hi("Error",f("Unexpected Error",`Cancel Accrual for Schedule Accrued Detail REST API call errored out ${JSON.stringify(b)}`))]))))}))),(s,i,r)=>s.pipe(S(zJ.match),y((t=>{const{localData:e,person:a}=i.value.peopleState.personDetails,{userId:n,userRole:o}=a,c=KJ(e[0].role,o.userRoles,n);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${t.payload.companyId}`,{users:c}).pipe(y((d=>{if(T(d)){const l=[];return d.data?.user_roles&&Vn(l,d.data?.user_roles[0],!0),p(Y(d.data.user_roles),YJ(),N({messageSection:"people_update_person",messageText:"success",type:"success"}),...l)}return p(cg(d.status))})),v((d=>p(cg(f("Unexpected error","Change zeni person roles REST API call errored out"+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(NF.match),A((()=>{const t=i.value,e=t.checkDepositState.localData,a=bm(t.fileState,e.fileIds),n=a.filter((d=>d.documentSide==="front"))[0],o=a.filter((d=>d.documentSide==="back"))[0],c={source_of_deposit:e.source,amount:e.amount.amount,currency_code:e.amount.currencyCode,currency_symbol:e.amount.currencySymbol,check_front_file_id:n?.fileId,check_back_file_id:o?.fileId};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e.depositTo?.id}/check-deposits`,c).pipe(y((d=>T(d)?p(N({messageSection:"deposit_check",messageText:"success",type:"success"}),Ld({fetchState:"Completed"})):p(Ld({fetchState:"Error",error:d.status})))),v((d=>p(Ld({fetchState:"Error",error:f("Unexpected Error","Check deposit REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(JM.match),A((t=>{const{chargeCardId:e,reason:a}=t.payload,n={reason:a},o=i.value.chargeCardState.chargeCardByID[e].accountLast4;return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/close`,n).pipe(y((c=>M(c)&&c.data!=null?p(st(c.data),qc({chargeCardId:e,fetchState:"Completed"}),N({messageSection:"close_charge_card",messageText:"success",type:"success",variables:[{variableName:"_masked_card_number_",variableValue:`•••• ${o}`}]})):p(N({messageSection:"close_charge_card",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}),qc({chargeCardId:e,fetchState:"Error",error:c.status})))),v((c=>p(N({messageSection:"close_charge_card",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(c)}]}),qc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Close card API call errored out"+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(aV.match),A((t=>{const{cardIds:e,reason:a}=t.payload,n={card_ids:e,reason:a};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/bulk/close`,n).pipe(y((o=>M(o)&&o.data!=null?p(qa(o.data),ad({fetchState:"Completed"}),N({messageSection:"close_charge_cards",messageText:"success",type:"success",variables:[{variableName:"_number_of_cards_",variableValue:e.length===1?"1 card":`${e.length} cards`}]})):p(N({messageSection:"close_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:o.status.message}]}),ad({fetchState:"Error",error:o.status})))),v((o=>p(N({messageSection:"close_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(o)}]}),ad({fetchState:"Error",error:f("Unexpected Error","Close cards API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(Lo.match),y((t=>sm(i.value.companyViewState.managementView,t.payload.companyId)!=null?p(nm(t.payload.companyId,{})):_([])))),(s,i,r)=>s.pipe(S(nm.match),y((t=>{const e=t.payload.companyId,a=sm(i.value.companyViewState.managementView,e),n=UN(e,i.value.companyViewState.managementView);if(a!=null&&Object.keys(a.data).length>0&&n==null){const o=Tz(a.data);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[];return i.value.companyViewState.managementView.fetchState==="Completed"&&(d.push(Q({payload:c.data.companies,schema:{},isUpdate:!0})),c.data.customer_satisfactions!=null&&d.push(om({payload:c.data.customer_satisfactions})),d.push(kN(e)),d.push(Lo(e))),i.value.reviewCompanyViewState.fetchState==="Completed"&&d.push(BN({companies:c.data.companies})),_(d)}{const d=[im(e,c.status),Lo(e)];return _(d)}})),v((c=>p(im(e,f("Unexpected error","Company Management save updates errored out"+JSON.stringify(c)))))))}return _([])}))),(s,i,r)=>s.pipe(S(Sx.match),$t((t=>{const{batchId:e,attachmentId:a,transactionId:n,transactionType:o,fileName:c}=t.payload;return r.postAndGetJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`,{attachment_id:a,transaction_id:n,transaction_type:o,file_name:c}).pipe(y((d=>T(d)?_([gx({batchId:e,attachmentId:a,transactionId:n}),N({messageSection:"receipt_match",messageText:"success",type:"success"})]):_([Oy({error:d.status}),N({messageSection:"receipt_match",messageText:"failed",type:"error"})]))),v((d=>_([Oy({error:f("Unexpected Error","Confirm bulk upload match errored out: "+JSON.stringify(d))}),N({messageSection:"receipt_match",messageText:"failed",type:"error"})]))))}))),s=>s.pipe(S(CA.match),y((i=>{const{setupIntentData:r}=i.payload,{setupIntent:t,error:e}=r;if(t!=null&&e==null){const a={id:t.id,status:t.status,clientSecret:t.client_secret};return _([_p({fetchState:"Completed",setupIntentData:a})])}return _([_p({fetchState:"Error",error:e}),N({messageSection:"confirm_card_setup",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.message??"Unknown error"}]})])}))),(s,i,r)=>s.pipe(S(MO.match),$t((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n,accountMappings:o}=t.payload;return r.postAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements/${n}/confirm-mapping`,{account_mappings:o.map((c=>({ledger_identifier:c.ledgerIdentifier,account_id:c.accountId})))}).pipe(y((c=>{if(T(c)===!0&&c.data!=null)return p(VO({accountId:e,selectedPeriod:a,statementUploads:LO(c.data)}));const d=FO(c)?qO(c):null;return p(Fm({accountId:e,selectedPeriod:a,error:c.status,mappingConflict:d}),NE(c.status.message))})),v((c=>p(Fm({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Confirm Statement Mapping REST API call errored out "+(c instanceof Error?c.message:String(c)))}),NE()))))}))),(s,i,r)=>s.pipe(S(rD.match),y((t=>{const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`,{api_key:a,publishable_key:n,webhook_secret:o}=t.payload,c={api_key:a,publishable_key:n,...o!=null&&o!==""?{webhook_secret:o}:{}};return r.postAndGetJSON(e,c).pipe(A((d=>T(d)&&d.data!=null?p(Xh({stripe_connected:d.data.stripe_connected,publishable_key:d.data.publishable_key}),Vt()):p(en(d.status)))),v((d=>p(en(f("Unexpected Error","Stripe connect setup REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(ya.match),y((t=>{const{cacheOverride:e,amount:a,conversionCurrencyCode:n,billId:o}=t.payload,c=i.value;let d=c.editBillDetailViewState.newBillState.billDetailLocalData;if(o!=null){const l=Ne(o);d=c.editBillDetailViewState.editBillStateById[l].billDetailLocalData}if(e===!0){const l={amount:{amount:a.amount,currency_code:a.currencyCode,currency_symbol:a.currencySymbol},home_currency_code:n};return r.postAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/currencies/conversion`,l).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[],h={amount:u.data.home_currency_conversions.amount,currency_code:u.data.home_currency_conversions.currency_code,currency_symbol:u.data.home_currency_conversions.currency_symbol},g=u.data.home_currency_conversions.exchange_rate;return m.push(sv({billId:o,amountPayload:h,conversionRate:g})),m.push(hn({billId:o,fetchState:"Completed",error:void 0})),_(m)}return p(hn({billId:o,fetchState:"Error",error:u.status}))})),v((u=>p(hn({billId:o,fetchState:"Error",error:f("Unexpected Error","Convert Amount To Home Currency REST API call errored out"+JSON.stringify(u))})))))}{const l=[];return l.push(sv({billId:o,amountPayload:{amount:(d.totalAmountAfterConversion?.amount??0)*(d.paymentDetailsSection?.conversionRate??1),currency_code:d.totalAmountAfterConversion?.currencyCode??"",currency_symbol:d.totalAmountAfterConversion?.currencySymbol??""},conversionRate:d.paymentDetailsSection?.conversionRate??0})),l.push(hn({billId:o,fetchState:"Completed",error:void 0})),_(l)}}))),(s,i,r)=>s.pipe(S(yu.match),y((t=>{const{addressType:e}=t.payload,a=i.value.addressViewState.newAddressState?.[e];if(a!=null){const n=xe(a.addressToCreate),o=e.includes("custom_shipping_")?`?query=${encodeURIComponent(JSON.stringify({is_default_namespace_sync_enabled:!0}))}`:"";return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/addresses${o}`,n).pipe(y((c=>{const d=c.data!=null?c.data?.addresses:[];if(T(c)&&d.length>0){const l=[z(d)];return l.push(lo({addressId:d[0].address_id,addressType:e})),_(l)}return p(da({addressType:e,status:c.status}))})),v((c=>p(da({addressType:e,status:f("Unexpected Error","Create Address REST API call errored out"+JSON.stringify(c))})))))}return[]}))),(s,i,r)=>s.pipe(S(SR.match),A((()=>{const t=a0(i.value.autotransferRulesState.ruleUpdateLocalData);return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto`,t).pipe(y((e=>{if(T(e)&&e.data!=null){const a=kl(e.data.auto_transfer_rule),n=[gR({rule:a}),N({messageSection:"auto_transfer_rule_create",messageText:"success",type:"success"})];return _(n)}return _([Ef({fetchState:"Error",error:e.status}),N({messageSection:"auto_transfer_rule_create",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.status.message}]})])})),v((e=>p(Ef({fetchState:"Error",error:f("Unexpected Error","Create auto transfer rule REST API call errored out "+JSON.stringify(e))})))))}))),(s,i,r)=>s.pipe(S(iA.match),A((t=>{const{bankAccountViewState:e,expressPayState:a}=i.value,{paymentMethodType:n,bankAccountContext:o,vendorId:c}=t.payload,d=e.createBankAccountDetails.localData;return d!=null?r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bank-accounts`,vl(d,n)).pipe(y((l=>{const u=[];return T(l)?(u.push(Je(l.data?.bank_accounts??[]),Ye({fetchState:"Completed",isInternationalBankAccount:!1})),o!=="vendor"&&o!=="billDetail"&&o!=="express-pay"||(u.push(sp({bankAccountIds:[l.data?.bank_accounts[0].bank_account_id??""],vendorId:c})),o==="billDetail"&&u.push(kt(c))),o==="express-pay"&&u.push(So({localData:{...a.formLocalData,amount:a.formLocalData?.amount??{amount:0,currencyCode:"USD",currencySymbol:"$"},paymentDate:a.formLocalData?.paymentDate??me(),paymentToAccountId:l.data?.bank_accounts[0].bank_account_id??""}})),l.data?.bank_accounts[0].bank_routing_number_ach!=null&&l.data?.bank_accounts[0].bank_routing_number_ach.length!==0?u.push(N({messageSection:"create_bank_account_ach",messageText:"success",type:"success"})):l.data?.bank_accounts[0].bank_routing_number_wire_transfer!=null&&l.data?.bank_accounts[0].bank_routing_number_wire_transfer.length!==0&&u.push(N({messageSection:"create_bank_account_wire",messageText:"success",type:"success",variables:[{variableName:"_wire-type_",variableValue:"Domestic"}]}))):l.status.code===409?(u.push(Je(l.data?.bank_accounts??[]),Ye({fetchState:"Error",error:l.status,isInternationalBankAccount:!1})),u.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]})),o!=="vendor"&&o!=="billDetail"&&o!=="express-pay"||(u.push(sp({bankAccountIds:[l.data?.bank_accounts[0].bank_account_id??""],vendorId:c})),o==="billDetail"&&u.push(kt(c)),o==="express-pay"&&u.push(So({localData:{...a.formLocalData,amount:a.formLocalData?.amount??{amount:0,currencyCode:"USD",currencySymbol:"$"},paymentDate:a.formLocalData?.paymentDate??me(),paymentToAccountId:l.data?.bank_accounts[0].bank_account_id??""}})))):(u.push(Ye({fetchState:"Error",error:l.status,isInternationalBankAccount:!1})),u.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))),_(u)})),v((l=>p(Ye({fetchState:"Error",error:f("Unexpected Error","Bank Account Creation REST API call errored out"+JSON.stringify(l)),isInternationalBankAccount:!1}))))):_([])}))),(s,i,r)=>s.pipe(S(bM.match),y((t=>{const e=EM(t.payload);return r.postAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`,e).pipe(y((a=>{if(M(a)&&a.data!=null){const{templates_created:n,errors:o}=a.data,c=n.map((m=>m.template)),d=c.map((m=>m.template_id)),l=d.length>0?[PM(d)]:[],u=[...c.map((m=>Rc(m))),...l,vn({fetchState:"Completed",perItemErrors:(o??[]).map(TM),templateIds:d})];return _(u)}return p(vn({fetchState:"Error",error:a.status}))})),v((a=>p(vn({fetchState:"Error",error:f("Unexpected Error","Create card-policy templates REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(xA.match),y((t=>{const{paymentsMethod:e}=t.payload,a={...vz(e)};return r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/stripe/cards/setup_intent`,a).pipe(y((n=>{if(T(n)&&n.data){const{client_secret:o}=n.data;return _([bo({fetchState:"Completed",clientSecret:o})])}return _([bo({fetchState:"Error",error:n.status}),N({messageSection:"create_card_setup",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]})])})),v((n=>p(bo({fetchState:"Error",error:f("Unexpected Error","Create Setup Intent REST API call errored out "+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(FF.match),A((t=>{const e={account_sub_type:"checking",account_name:t.payload.nickname};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts`,e).pipe(y((a=>T(a)?p(Qe(a.data?.deposit_accounts??[]),Qt({data:a.data?.deposit_accounts??[],updateType:"merge"}),N({messageSection:"create_checking_account",messageText:"success",type:"success"}),zd({fetchState:"Completed",accoutnId:a.data?.deposit_accounts[0].deposit_account_id})):p(N({messageSection:"create_checking_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}),zd({fetchState:"Error",accoutnId:void 0,error:a.status})))),v((a=>p(N({messageSection:"create_checking_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(a)}]}),zd({fetchState:"Error",accoutnId:void 0,error:f("Unexpected Error","Create deposit Account REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(_u.match),y((t=>{if(t.payload.addressType==="company_address"&&i.value.addressViewState.newAddressState?.company_address!=null){const e=t.payload.companyId,a=xe(i.value.addressViewState.newAddressState?.company_address.addressToCreate);return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/addresses`,a).pipe(y((n=>{const o=n.data!=null?n.data?.addresses:[];if(T(n)&&o.length>0){const c=n.data,d=[z(o)];return d.push(Q({payload:c?.companies??[],schema:{}})),d.push(lo({addressId:o[0].address_id,addressType:"company_address"})),_(d)}return p(da({addressType:"company_address",status:n.status}))})),v((n=>p(da({addressType:"company_address",status:f("Unexpected Error","Create Company Address REST API call errored out"+JSON.stringify(n))})))))}return[]}))),(s,i,r)=>s.pipe(S(cm.match),y((t=>{const{officers:e}=t.payload,a=e.map((d=>d.officerType)),n=t.payload.companyId,{newAddressState:o}=i.value.addressViewState,c={users:e.map((d=>{const l=Object.assign({},d,{isCompanyOfficer:!0});let u=$n(l);return u=Object.assign({},u,{is_changes_in_response_only:!1}),u}))};return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${n}/users`,c).pipe(y((d=>{const l=d.data?.users??[];if(T(d)&&l.length>0){const u=[V({users:l}),Q({payload:d.data?.companies??[],schema:{}}),Y(d.data?.user_roles??[])],m=e.map((h=>{const g=l.find((I=>I.email===h.email));return{...h,firstName:g?.first_name?.trim()??h.firstName,lastName:g?.last_name?.trim()??h.lastName,phone:g?.phone??"",userId:g?.user_id}}));return u.push(Fo({officers:m})),e.forEach((h=>{const{officerType:g}=h,I=l.find((P=>P.email===h.email)),b=g.toLowerCase().concat("_address");o?.[b]?.addressToCreate!=null&&u.push(ns({addressType:b,companyId:n,userId:I?.user_id}))})),u.push(DN({companyId:n,officerTypes:a})),_(u)}return p(dm({companyId:n,officerTypes:a,status:d.status}))})),v((d=>p(dm({companyId:n,officerTypes:a,status:f("Unexpected error",`Create Company Officers REST API call errored out ${JSON.stringify(d)}`)})))))}))),(s,i,r)=>s.pipe(S(hu.match),y((t=>{const e=t.payload.addressType,{newAddressState:a}=i.value.addressViewState,n=a?.[e]?.addressToCreate;if(e!=="company_address"&&n!=null){const o=t.payload.companyId,c=t.payload.userId,d={...xe(n),is_changes_in_response_only:!1};return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${o}/users/${c}/addresses`,d).pipe(y((l=>{const u=l.data!=null?l.data?.addresses:[];if(T(l)&&u.length>0){const m=l.data,h=[z(u)];return h.push(Q({payload:m?.companies??[],schema:{}}),V({users:m?.users??[]}),Y(m?.user_roles??[])),h.push(lo({addressId:u[0].address_id,addressType:e})),_(h)}return p(da({addressType:e,status:l.status}))})),v((l=>p(da({addressType:e,status:f("Unexpected Error","Create Company User Address REST API call errored out"+JSON.stringify(l))})))))}return[]}))),(s,i,r)=>s.pipe(S(AU.match),y((()=>{const{draft:t}=i.value.invoicingCreateCreditNoteState,e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/credits`,a=NU(t);return r.postAndGetJSON(e,a).pipe(y((n=>T(n)&&n.data!=null?[zs([n.data],"merge"),OU({creditNoteId:n.data.id}),N({messageSection:"invoicing_credit_note_saved",messageText:"success",type:"success"})]:_([p_(n.status),N({messageSection:"invoicing_credit_note_saved",messageText:"failed",type:"error",variables:Ie(n.status)})]))),v((n=>_([p_(f("Unexpected Error","Create credit note REST API call errored out "+JSON.stringify(n))),N({messageSection:"invoicing_credit_note_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(pU.match),y((t=>{const{context:e,merchantId:a}=t.payload,{newGlobalMerchantData:n,recommendationIds:o,recommendedNonExistingGlobalMerchants:c}=i.value.globalMerchantViewState,d=Array({globalMerchants:Qn(i.value.globalMerchantState,o)}),l=Array({globalMerchants:c}),u=Xn(d,l);if(n!=null){const m={...tK(n,u)};return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/global-merchants`,m).pipe(y((h=>{if(h.data!=null&&T(h)){const{global_merchants:g}=h.data,I=[It({globalMerchants:g,updateType:"merge"})],b=g[0].global_merchant_id;return e==="vendor_global_review"&&a!=null&&I.push(mU(a,b)),I.push(yU({merchantId:b}),N({messageSection:"create_global_merchant",messageText:"success",type:"success",variables:[{variableName:"_global_merchant_name_",variableValue:g[0].global_merchant_name}]})),_(I)}return p(r_({status:h.status}),N({messageSection:"create_global_merchant",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:h.status.message}]}))})),v((h=>p(r_({status:f("Unexpected Error","Create Global Merchant REST API call errored out"+JSON.stringify(h))})))))}return[]}))),(s,i,r)=>s.pipe(S(cA.match),A((t=>{const{bankAccountViewState:e,vendorViewState:a}=i.value,{bankAccountContext:n,vendorId:o}=t.payload,c=e.createInternationalBankAccountDetails.localData,d=o!=null?a?.editVendorStateById[o]?.vendorDetailLocalData?.countryCode:a.newVendorState.vendorDetailLocalData?.countryCode;return c!=null?r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-instruments`,((l,u)=>({...IE(l),country_code:u??""}))(c,d)).pipe(y((l=>{const u=[];return T(l)?(u.push(la(l.data?.payment_instruments??[]),Ye({fetchState:"Completed",isInternationalBankAccount:!0})),n!=="vendor"&&n!=="billDetail"&&n!=="express-pay"||(u.push(cs({paymentInstrumentIds:[l.data?.payment_instruments[0].zeni_payment_instrument_id??""],vendorId:o})),n==="billDetail"&&u.push(kt(o))),u.push(N({messageSection:"create_bank_account_international",messageText:"success",type:"success",variables:[{variableName:"_wire-type_",variableValue:"International"}]}))):l.status.code===409?(u.push(Ye({fetchState:"Error",error:l.status,isInternationalBankAccount:!0})),u.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]})),n!=="vendor"&&n!=="billDetail"&&n!=="express-pay"||(u.push(cs({paymentInstrumentIds:[l.data?.payment_instruments[0].zeni_payment_instrument_id??""],vendorId:o})),n==="billDetail"&&u.push(kt(o)))):(u.push(Ye({fetchState:"Error",error:l.status,isInternationalBankAccount:!0})),u.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))),_(u)})),v((l=>p(Ye({fetchState:"Error",error:f("Unexpected Error","Bank Account Creation REST API call errored out"+JSON.stringify(l)),isInternationalBankAccount:!0}))))):_([])}))),(s,i,r)=>s.pipe(S(CU.match),y((t=>{const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices`;return r.postAndGetJSON(e,{...t.payload}).pipe(y((a=>T(a)&&a.data!=null?[Ca([a.data],"merge"),z(Or([a.data])),xU({id:a.data.id,status:a.data.status}),UU({invoiceId:a.data.id}),N({messageSection:"invoicing_invoice_saved",messageText:"success",type:"success"})]:_([m_(a.status),N({messageSection:"invoicing_invoice_saved",messageText:"failed",type:"error",variables:Ie(a.status)})]))),v((a=>_([m_(f("Unexpected Error","Create invoice REST API call errored out "+JSON.stringify(a))),N({messageSection:"invoicing_invoice_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(BU.match),y((t=>{const{customerId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(e)}/payment-methods/setup-intent`;return r.postAndGetJSON(a,{}).pipe(A((n=>T(n)&&n.data!=null?p(DU(n.data)):p(y_(n.status)))),v((n=>p(y_(f("Unexpected Error","Setup intent REST API call errored out "+JSON.stringify(n)))))))}))),(s,i)=>s.pipe(S(g$.match),y((r=>{const t=[],e=r.payload.scheduleType,a=i.value,{scheduleAccruedDetailState:n}=a,o=n.newScheduleState,c=o.selectedVendor,d={scheduleType:e,jeScheduleDetails:CK(o,o?.estimatedMonthlyAmount??{amount:0,currencyCode:"USD",currencySymbol:"$"},o?.startingBalance??{amount:0},c?.name??"")};return t.push(cn({scheduleType:e,selectedJeScheduleDetailId:void 0,localData:d})),_(t)}))),(s,i)=>s.pipe(S(tf.match),y((r=>{const t=[],e=r.payload.scheduleType,a=i.value,{scheduleDetailState:n}=a,o=n.selectedJEScheduleKey;if(o!=null){const c=ft(o,a),d=c.baseTransaction.amount,l=c.vendor.name,u=c.jeScheduleId!=null?n.editScheduleStateByDetailId[e][c.jeScheduleId]:n.newScheduleState[e],m=u.scheduleType==="fixed_assets"?u.assetId:void 0,h={scheduleType:e,jeScheduleDetails:x$(u,d,l,e==="fixed_assets"?{assetId:m}:void 0)};t.push(un({scheduleType:e,selectedJeScheduleDetailId:c.jeScheduleId,localData:h}))}return _(t)}))),(s,i,r)=>s.pipe(S(Mq.match),A((t=>{const{groupName:e,updateSelectedTasks:a}=t.payload,n=i.value,{localData:o}=n.taskListState,c={name:e};return r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/groups`,c).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[Ab(d.data.task_groups[0]),Eb({newTaskGroupId:d.data.task_groups[0].task_group_id}),Vq({newTaskGroup:d.data.task_groups[0]}),N({messageSection:"task_group_creation_success",messageText:"success",type:"success"})];return a===!0&&l.push(rl(o.selectedTaskIds,d.data.task_groups[0].task_group_id,{taskGroupIds:[d.data.task_groups[0].task_group_id]})),_(l)}return p(Nb({fetchState:"Error",error:d.status}))})),v((d=>p(Nb({fetchState:"Error",error:f("Unexpected Error","Create Task Group REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(FC.match),y((t=>{const e=i.value,{localData:a}=t.payload,n=crypto.randomUUID(),o={...Fz(e,a),request_id:n},c=e.expenseAutomationViewState.selectedPeriodByTenantId[H(e).tenantId],d=c!=null?Re(c):void 0,l=d!=null?ge(d.start):void 0,u=d!=null?ge(d.end):void 0;return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`,o).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[Ta([m.data.accrual]),qC(),N({messageSection:"create_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:a.vendorName}]})];return l!=null&&u!=null&&h.push(Qa({start:l,end:u},!0)),_(h)}return _([Iy({status:m.status}),N({messageSection:"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:m.status.message}]})])})),v((m=>_([N({messageSection:"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(m)}]}),Iy({status:f("Unexpected Error",`Create One Time Accrual REST API call errored out ${JSON.stringify(m)}`)})]))),De(s.pipe(S(gt.match))))}))),(s,i,r)=>s.pipe(S(k1.match),A((t=>{const{internationalWireState:e}=i.value,{bankAccountContext:a,vendorId:n}=t.payload,o=e.createInternationalWireDetails.localData;return o!=null?r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-instruments`,B1(o)).pipe(y((c=>{const d=[];return T(c)&&c.data!=null?(d.push(la(c.data.payment_instruments??[]),gn({fetchState:"Completed"})),a!=="vendor"&&a!=="billDetail"&&a!=="express-pay"||(d.push(cs({paymentInstrumentIds:[c.data.payment_instruments[0].zeni_payment_instrument_id??""],vendorId:n})),d.push(D1({countryCode:e.createInternationalWireDetails?.localData?.countryCode,currencyCode:e.createInternationalWireDetails?.localData?.currencyCode,vendorId:n})),a==="billDetail"&&d.push(kt(n))),d.push(N({messageSection:"create_bank_account_international",messageText:"success",type:"success",variables:[{variableName:"_wire-type_",variableValue:"International"}]}))):c.status.code===409?(d.push(gn({fetchState:"Error",error:c.status})),d.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]})),a!=="vendor"&&a!=="billDetail"&&a!=="express-pay"||(d.push(cs({paymentInstrumentIds:[c.data?.payment_instruments[0].zeni_payment_instrument_id??""],vendorId:n})),a==="billDetail"&&d.push(kt(n)))):(d.push(gn({fetchState:"Error",error:c.status})),d.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))),_(d)})),v((c=>p(gn({fetchState:"Error",error:f("Unexpected Error","Payment Instrument Creation REST API call errored out"+JSON.stringify(c))}))))):_([])}))),(s,i,r)=>s.pipe(S(rT.match),A((t=>{const{agentId:e,userId:a,questionAnswerId:n,questionId:o,createdAt:c,question:d,files:l,pageContext:u,macroId:m}=t.payload,h={agent_id:e,...u!=null&&{page_context:u}};return r.postAndGetJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions`,h).pipe(y((g=>{if(T(g)&&g.data!=null){const I=g.data,b=I.chat_session_id;return(function(E,P,O=5e3){return new cT((C=>{if(E==null)return console.warn("[createSessionAndSubmitEpic] ⚠️ Pusher not initialized, proceeding without waiting"),C.next({success:!1,error:"Pusher not initialized"}),void C.complete();const U=`private-${P}`,B=E.channel(U);if(B?.subscribed===!0)return C.next({success:!0}),void C.complete();const x=B??E.subscribe(U),k=()=>{x.unbind("pusher:subscription_succeeded",k),x.unbind("pusher:subscription_error",J),C.next({success:!0}),C.complete()},J=()=>{x.unbind("pusher:subscription_succeeded",k),x.unbind("pusher:subscription_error",J),C.error(new Error(`Failed to subscribe to channel ${U}`))};return x.bind("pusher:subscription_succeeded",k),x.bind("pusher:subscription_error",J),x.subscribed===!0&&k(),()=>{x.unbind("pusher:subscription_succeeded",k),x.unbind("pusher:subscription_error",J)}})).pipe(dT(O),lT(),v((C=>{const U=C instanceof Error?C.message:"Subscription timeout or error";return p({success:!1,error:U})})))})(uT,`chat-${b}`).pipe(y((E=>{const P=[];return E.success||P.push(N({messageSection:"ai_cfo_create_session_and_submit",messageText:"notification",type:"warning"})),j(p(...P,Nu({chatSessionId:b,userId:a,createdAt:ee(I.created_at)}),iT({agentId:e,sessionId:b})),Ha(100).pipe(Ue(1),oT()),p(nT(),Au(b,n,a,o,c,d,l,m),sT({chatSessionId:b,questionAnswerId:n,question:{questionId:o,text:d,createdAt:c},userId:a,attachments:l!=null&&l.length>0?l.map((O=>({filename:O.name,file_size:O.size,mime_type:O.type}))):void 0})))})))}return p(N({messageSection:"ai_cfo_create_session_and_submit",messageText:"failed",type:"error"}),Ou(g.status))})),v((g=>p(Ou(f("Unexpected Error",`Create and Submit Session REST API call errored out: ${JSON.stringify(g)}`))))))}))),(s,i,r)=>s.pipe(S(pT.match),A((t=>{const{agentId:e,contextRefId:a,contextType:n,pageContext:o,userId:c}=t.payload,d={agent_id:e,...a!=null&&{context_ref_id:a},...n!=null&&{context_type:n},...o!=null&&{page_context:o}};return r.postAndGetJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions`,d).pipe(y((l=>T(l)&&l.data!=null?p(Nu({chatSessionId:l.data.chat_session_id,userId:c,createdAt:ee(l.data.created_at)}),mT({agentId:e,contextMessage:l.data.context_message,contextStatus:l.data.context_status,sessionId:l.data.chat_session_id})):p(Cu(l.status)))),v((l=>p(Cu(f("Unexpected Error",`Create Session REST API call errored out: ${JSON.stringify(l)}`))))))}))),(s,i,r)=>s.pipe(S(fq.match),y((t=>{const e=i.value,a=Za(e.taskState,t.payload.parentTaskId),n=a?.taskGroupIds??[],o=n[0],c=e.taskListState.fetchState==="Completed",d=sY(t.payload,n);return r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`,d).pipe(y((l=>{if(T(l)&&l.data!=null&&l.data.tasks.length>0){const u=l.data.tasks[0].task_id,m=[ze(l.data.tasks),vq({parentTaskId:t.payload.parentTaskId,subTaskId:u}),Qd({fetchState:"Completed",newTaskId:u}),N({messageSection:"create_sub_task",messageText:"success",type:"success"})],h=l.data.tasks[0];return h.parent_task_id!=null&&h.parent_task_id!==""||c!==!0||o==null||m.push(fb({taskGroupId:o,task:h})),_(m)}return p(Qd({fetchState:"Error",error:l.status}),N({messageSection:"create_sub_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))})),v((l=>p(Qd({fetchState:"Error",error:f("Unexpected Error","Create Sub Task REST API call errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(iq.match),y((function(t){const{tagName:e,taskId:a}=t.payload;return WK(e,r,a)}))),(s,i,r)=>s.pipe(S(Dq.match),A((t=>{const{taskGroupTemplateId:e,taskIds:a}=t.payload,n=i.value.taskGroupViewState.taskGroupsIds,o={group_name:e,is_create_all_tasks_inside_group:a.length===0,task_names:a};return r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/templates`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[bb(c.data.groups),ze(c.data.tasks),Jq(),wq({tasks:c.data.tasks})];return n.includes(c.data.groups[0].task_group_id)===!1&&d.push(Eb({newTaskGroupId:c.data.groups[0].task_group_id})),_(d)}{const d=[Pb(c.status)];return _(d)}})),v((c=>{const d=[Pb(f("Unexpected error","Create task from templates REST API call errored out"+JSON.stringify(c)))];return _(d)})))}))),(s,i,r)=>s.pipe(S(uO.match),y((t=>{const{transactionId:e,creditAccountIntegrationId:a,debitAccountIntegrationId:n,memo:o,transactionType:c,sourceTransactionType:d}=t.payload,l={id:e,type:d},u={transaction_type:c,transaction_id:e,to_account_integration_id:a,from_account_integration_id:n,transaction_memo:o??""};return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`,u).pipe(y((m=>{if(T(m)&&m.data!=null){const g=m.data?.transaction;return g!=null?(h=g)==null||typeof h.transaction_id!="string"||h.transaction_id===""||typeof h.transaction_type!="string"||h.transaction_type===""?_(Pl()):(function(I,b,E,P){const O=Is(I),C=(B=O,!((U=E).id===B.id&&U.type===B.type));var U,B;const x=[va(Be(O),I),bs({transactionId:O,vendorId:b?.[0]?.vendor_id}),...TE(P)];return C&&x.push(mO(E,O)),j(_(x),AE(C?E:void 0))})(g,m.data?.vendors,l,e):(function(I){return j(_(TE(I)),AE(void 0))})(e)}var h;return _(Pl())})),v((()=>_(Pl()))))}))),(s,i,r)=>s.pipe(S(dA.match),A((t=>{const{userId:e,reimbursementId:a}=t.payload,{bankAccountViewState:n}=i.value,o=n.createBankAccountDetails.localData;return o!=null?r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/users/${e}/bank-accounts`,vl(o,"ach")).pipe(y((c=>{const d=[];if(T(c)){const l=c.data?.bank_accounts??[];d.push(np({bankAccountIds:l.map((u=>u.bank_account_id)),userId:e}),Je(l),rr({bankAccountId:l?.[0].bank_account_id,shouldOverWriteCurrentBankAccountId:!0,reimbursementId:a}),Ye({fetchState:"Completed"}),N({messageSection:"account_added",messageText:"success",type:"success"}))}else c.status.code,d.push(Ye({fetchState:"Error",error:c.status}));return _(d)})),v((c=>p(Ye({fetchState:"Error",error:f("Unexpected Error","Bank Creation REST API call errored out"+JSON.stringify(c))}))))):_([])}))),(s,i,r)=>s.pipe(S(jO.match),A((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements/${n}`).pipe(y((o=>{if(T(o)){const c=[],d=ba(e,a);return o.data!=null&&c.push(qm(d,o.data)),c.push(jm({accountId:e,selectedPeriod:a})),p(...c)}return p(Sr({accountId:e,selectedPeriod:a,error:o.status}))})),v((o=>p(Sr({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Delete Statement File REST API call errored out "+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(fR.match),A((t=>{const{ruleId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto/${e}`).pipe(y((a=>{if(T(a)){const n=[vR({ruleId:e}),N({messageSection:"auto_transfer_rule_delete",messageText:"success",type:"success"})];return _(n)}return _([Pf({ruleId:e,fetchState:"Error",error:a.status}),N({messageSection:"auto_transfer_rule_delete",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]})])})),v((a=>p(Pf({ruleId:e,fetchState:"Error",error:f("Unexpected Error","Delete auto transfer rule REST API call errored out "+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(lA.match),A((t=>r.deleteAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bank-accounts/${t.payload.bankAccountId}`).pipe(y((e=>{if(T(e)){const a=[];return a.push(it({bankAccountId:t.payload.bankAccountId,fetchState:"Completed"})),t.payload.bankAccountContext==="vendor"&&a.push(uA({bankAccountId:t.payload.bankAccountId,vendorId:t.payload.vendorId})),a.push(N({messageSection:"delete_bank_account",messageText:"success",type:"success"})),_(a)}return p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:e.status}),N({messageSection:"delete_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.status.message}]}))})),v((e=>p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:f("Unexpected Error","Bank Deletion REST API call errored out"+JSON.stringify(e))})))))))),(s,i,r)=>s.pipe(S(kR.match),y((t=>{const{billTransactionState:e}=i.value,a=e.transactionById[t.payload.billId],n=a?.isRecurring??!1,o=a?.recurringBillConfigId;let c=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${t.payload.billId}`;return n===!0&&(c=`${c}/recurring`),r.deleteAndGetJSON(`${c}?query=${encodeURIComponent(JSON.stringify({transaction_type:"bill",bill_pay_provider:"zeni"}))}`).pipe(y((d=>{if(M(d)){const l=[];return l.push(uc("Completed",t.payload.billId)),a!=null&&l.push(xf({billId:t.payload.billId,tab:a.billPayInfo.stage.code})),l.push(lc(Ne(t.payload.billId))),n===!0&&o!=null&&l.push(Uf(o)),l.push(N({messageSection:"bill_pay_deleted",messageText:"success",type:"success"})),_(l)}return p(uc("Error",t.payload.billId,d.status),N({messageSection:"bill_pay_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(uc("Error",t.payload.billId,f("Unexpected Error","Delete bill REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(FR.match),A((t=>{const{approvalRuleId:e,useV3:a}=t.payload,n=a===!0?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;return r.deleteAndGetJSON(n,{approval_rule_id:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.approval_rules.map((l=>l.approval_rule_id)),d=[V({users:o.data.users}),We(o.data.approval_rules),N({messageSection:"bill_pay_approval_delete",messageText:"success",type:"success"}),qR(e,c)];return _(d)}return p(N({messageSection:"bill_pay_approval_delete",messageText:"failed",type:"error"}),Vf(e,o.status))})),v((o=>p(Vf(e,f("Unexpected Error","Delete Bill Pay Approval Rule errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(mq.match),y((t=>{const{cannedResponseId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses/${e}`).pipe(y((a=>T(a)?p(yq({cannedResponseId:e})):p(_b({error:a.status})))),v((a=>p(_b({error:f("Unexpected Error","Delete Canned Response errored: "+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(yT.match),y((t=>{const{chatSessionId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions/${e}`).pipe(y((a=>M(a)?_([_T({chatSessionId:e}),hT(e),N({messageSection:"ai_cfo_chat_session_deleted",messageText:"success",type:"success"})]):p(xu({chatSessionId:e,error:a.status}),N({messageSection:"ai_cfo_chat_session_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status?.message??String(a.status)}]})))),v((a=>p(xu({chatSessionId:e,error:f("Unexpected Error","Delete chat session REST API call errored out "+JSON.stringify(a))}),N({messageSection:"ai_cfo_chat_session_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(a)}]})))))}))),(s,i,r)=>s.pipe(S(GO.match),A((t=>{const{accountId:e,selectedPeriod:a,fileId:n}=t.payload;let o=t.payload.combinedStatementGroupId;if(o===""){const d=i.value.expenseAutomationReconciliationViewState.accountReconciliationRecordsBySelectedPeriod[Ee(a)]?.reconciliationByAccountID[e];o=Gm(d)}if(o==="")return p(Sr({accountId:e,selectedPeriod:a,error:f("Missing Data","No combined statement group id found for delete")}));const c=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/combined-statement-groups/${o}`;return r.deleteAndGetJSON(c).pipe(y((d=>{if(T(d)===!0){const l=[];return n!=null&&n!==""&&l.push(Zo([n])),d.data!=null&&l.push(qm(ba(e,a),{statement_upload:d.data.statement_upload})),l.push(jm({accountId:e,selectedPeriod:a}),Rt(a,void 0,!0,!0)),p(...l)}return p(Sr({accountId:e,selectedPeriod:a,error:d.status}))})),v((d=>p(Sr({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Delete Combined Statement REST API call errored out "+(d instanceof Error?d.message:String(d)))})))))}))),(s,i,r)=>s.pipe(S(EP.match),A((t=>r.deleteAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${t.payload.connectionId}`,void 0,Object.assign({"zeni-tenant-id":t.payload.tenantId})).pipe(y((e=>{if(M(e))return _([PP(t.payload.tenantId,t.payload.connectionId,t.payload.connectionType)]);const a=e.status??f("Failed to delete connection. Please try again.");return _([ru(t.payload.tenantId,a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error deleting connection.";return _([ru(t.payload.tenantId,f(a))])})))))),(s,i,r)=>s.pipe(S(Wx.match),y((t=>{const{fileId:e,tenantId:a}=t.payload;return(a!=null?r.deleteAndGetJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}`,void 0,Object.assign({"zeni-tenant-id":a})):r.deleteAndGetJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}`)).pipe(y((n=>T(n)?p(Zo([e]),Zx({fileId:e})):p(Wy({fileId:e,status:n.status})))),v((n=>p(Wy({fileId:e,status:f("Unexpected Error","Delete File REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(Xx.match),y((t=>{const{fileIds:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files?query=${encodeURIComponent(JSON.stringify({file_ids:e}))}`).pipe(y((a=>T(a)?p(Zo(e),eU({fileIds:e})):p(Zy({fileIds:e,status:a.status})))),v((a=>p(Zy({fileIds:e,status:f("Unexpected Error","Delete File List REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(pA.match),A((t=>r.deleteAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/payment-instruments/${t.payload.bankAccountId}`).pipe(y((e=>{if(T(e)){const a=[];return a.push(it({bankAccountId:t.payload.bankAccountId,fetchState:"Completed"})),t.payload.bankAccountContext==="vendor"&&a.push(op({paymentInstrumentId:t.payload.bankAccountId,vendorId:t.payload.vendorId})),a.push(N({messageSection:"delete_bank_account",messageText:"success",type:"success"})),_(a)}return p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:e.status}),N({messageSection:"delete_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.status.message}]}))})),v((e=>p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:f("Unexpected Error","Bank Deletion REST API call errored out"+JSON.stringify(e))})))))))),(s,i,r)=>s.pipe(S(J1.match),A((t=>r.deleteAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-instruments/${t.payload.paymentInstrumentId}`).pipe(y((e=>{if(T(e)){const a=[];return a.push(Dc({paymentInstrumentId:t.payload.paymentInstrumentId,fetchState:"Completed"})),t.payload.bankAccountContext==="vendor"&&a.push(op({paymentInstrumentId:t.payload.paymentInstrumentId,vendorId:t.payload.vendorId})),a.push(N({messageSection:"delete_bank_account",messageText:"success",type:"success"})),_(a)}return p(Dc({paymentInstrumentId:t.payload.paymentInstrumentId,fetchState:"Error",error:e.status}),N({messageSection:"delete_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.status.message}]}))})),v((e=>p(Dc({paymentInstrumentId:t.payload.paymentInstrumentId,fetchState:"Error",error:f("Unexpected Error","Payment Instrument Deletion REST API call errored out"+JSON.stringify(e))})))))))),(s,i,r)=>s.pipe(S(HJ.match),y((t=>r.deleteAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/${t.payload.userRoleId}`).pipe(y((e=>M(e)?p(QJ(t.payload.userId),N({messageSection:"people_delete_person",messageText:"success",type:"success"}),w0({userType:"manager",id:t.payload.userId})):p(dg(t.payload.userId)))),v((()=>p(dg(t.payload.userId)))))))),(s,i,r)=>s.pipe(S(KL.match),A((t=>{const{approvalRuleId:e,useV3:a}=t.payload,n=a===!0?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;return r.deleteAndGetJSON(n,{approval_rule_id:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.approval_rules.map((l=>l.approval_rule_id)),d=[V({users:o.data.users}),We(o.data.approval_rules),N({messageSection:"reimbursement_approval_delete",messageText:"success",type:"success"}),YL(e,c)];return _(d)}return p(N({messageSection:"reimbursement_approval_delete",messageText:"failed",type:"error"}),gI(e,o.status))})),v((o=>p(gI(e,f("Unexpected Error","Delete Reimbursement Approval Rule errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(RL.match),y((t=>{const{reimbursementState:e}=i.value,a=e.reimbursementById[t.payload.reimbursementId];return r.deleteAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${t.payload.reimbursementId}?query=${encodeURIComponent(JSON.stringify(YK))}`).pipe(y((n=>{if(M(n)){const o=[Td("Completed",t.payload.reimbursementId)];return a!=null&&o.push(_I({remiId:t.payload.reimbursementId,tab:a.reimbursementInfo.stage.code})),o.push(Pd(t.payload.reimbursementId)),o.push(N({messageSection:"reimbursement_deleted",messageText:"success",type:"success"})),_(o)}return p(Td("Error",t.payload.reimbursementId,n.status),N({messageSection:"reimbursement_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]}))})),v((n=>p(Td("Error",t.payload.reimbursementId,f("Unexpected Error","Delete reimbursement REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(f$.match),y((t=>{const e=i.value,{scheduleAccruedDetailState:a}=e,{scheduleType:n}=t.payload,o=a.selectedJEAccruedScheduleKey,c=[];if(o==null)return _(c);const d=sa(o,e);if(d==null)return _(c);const l=d.jeScheduleId,u=d.vendor.name,m=e.scheduleAccruedDetailState.editScheduleStateByDetailId[l],h={...t0(e,m,o,!0)},g={je_schedule_type:n};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${l}?query=${encodeURIComponent(JSON.stringify(g))}`,h).pipe(y((I=>T(I)&&I.data!=null?(c.push(v$(o),I$(n,l),Qi("Completed"),N({messageSection:"delete_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:u}]})),_(c)):(c.push(Qi("Error",I.status)),c.push(N({messageSection:"delete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:I.status.message}]})),_(c)))),v((I=>_([N({messageSection:"delete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(I)}]}),Qi("Error",f("Unexpected Error",`Delete Accrued Schedule Detail REST API call errored out ${JSON.stringify(I)}`))]))))}))),(s,i,r)=>s.pipe(S(U$.match),y((t=>{const e=i.value,{scheduleDetailState:a}=e,{selectedJeScheduleDetailId:n,scheduleType:o}=t.payload,c=a.selectedJEScheduleKey,d=[];if(c==null)return _(d);const l=ft(c,e),u=l.vendor.name,m=l.jeScheduleId??n;if(m==null)return _(d);const h=e.scheduleDetailState.editScheduleStateByDetailId[o][m],g={...ec(e,h,c,o,!0)},I={je_schedule_type:o};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${m}?query=${encodeURIComponent(JSON.stringify(I))}`,g).pipe(y((b=>T(b)&&b.data!=null?(d.push(k$(c),B$(o,m),tc("Completed"),N({messageSection:"delete_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:u}]})),_(d)):(d.push(tc("Error",b.status)),d.push(N({messageSection:"delete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:b.status.message}]})),_(d)))),v((b=>_([N({messageSection:"delete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(b)}]}),tc("Error",f("Unexpected Error",`Delete Schedule Detail REST API call errored out ${JSON.stringify(b)}`))]))))}))),(s,i,r)=>s.pipe(S(ST.match),y((t=>{const{macroId:e}=t.payload,a=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}`;return r.deleteAndGetJSON(a).pipe(y((n=>M(n)?p(gT({macroId:e})):p(Uu(n.status)))),v((n=>p(Uu(f("Unexpected Error","Delete skill REST API call failed",n instanceof Error?{message:n.message}:void 0))))))}))),(s,i,r)=>s.pipe(S(dq.match),y((t=>{const{tagId:e,taskId:a}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tags/${e}`).pipe(y((n=>M(n)&&n.data!=null?_([Yd({fetchState:"Completed",tagId:e}),lq(e),uq({tagId:e,taskId:a})]):_([Yd({fetchState:"Error",tagId:e,error:n.status}),N({messageSection:"delete_tag",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]})]))),v((n=>p(Yd({fetchState:"Error",tagId:e,error:f("Unexpected Error","Delete tag REST API call errored out "+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(Iq.match),y((t=>{const{taskId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${e}`).pipe(y((a=>{if(M(a)){const n=[];return e!=null&&n.push(ro(e)),n.push(Nt()),n.push(Wd({fetchState:"Completed",taskId:e})),_(n)}return _([Wd({fetchState:"Error",taskId:e,error:a.status}),N({messageSection:"delete_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]})])})),v((a=>p(Wd({fetchState:"Error",taskId:e,error:f("Unexpected Error","Delete Task REST API call errored out "+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(Lq.match),A((t=>{const{taskGroupId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/groups/${e}`).pipe(y((a=>T(a)&&a.data!=null?p(jq(e),qq({deletedTaskGroupId:e}),Fq({taskGroupId:e}),N({messageSection:"task_group_deletion_success",messageText:"success",type:"success"})):p(Ob({fetchState:"Error",error:a.status})))),v((a=>p(Ob({fetchState:"Error",error:f("Unexpected Error","Delete Task Group REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(nj.match),A((t=>{const{attachmentFileName:e,transactionId:a}=t.payload,n={transaction_type:a.type,attachment_file_names:[e]};return r.deleteAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${a.id}/attachments?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(T(o)){const c=Be(a);return p(cj({thirdPartyTransactionId:a.id,attachmentFileName:e}),ij({id:c,attachmentFileName:e}),oj({transactionId:a,attachmentFileName:e}))}return p($b({transactionId:a,attachmentFileName:e,status:o.status}))})),v((o=>p($b({transactionId:a,attachmentFileName:e,status:f("Unexpected Error","Delete Transaction Attachment REST API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(mA.match),A((t=>{const{userId:e,bankAccountId:a,reimbursementId:n}=t.payload,o=i.value.userFinancialAccountState.financialAccountByUserId[e]?.bankAccountIds??[],c=n!=null?i.value.editRemiDetailViewState.editRemiStateById[n].remiDetailLocalData.paymentTo:i.value.editRemiDetailViewState.newRemiState.remiDetailLocalData.paymentTo;return r.deleteAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/users/${e}/bank-accounts/${a}`).pipe(y((d=>{if(T(d)){const l=[];l.push(it({bankAccountId:t.payload.bankAccountId,fetchState:"Completed"}),yA({userId:e,bankAccountId:a}));const u=o.filter((m=>m!==a));return a===c&&(u.length===1?l.push(rr({bankAccountId:u[0],reimbursementId:n,shouldOverWriteCurrentBankAccountId:!0})):l.push(rr({reimbursementId:n,shouldOverWriteCurrentBankAccountId:!0}))),_(l)}return p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:d.status}))})),v((d=>p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:f("Unexpected Error","Bank Deletion REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(wN.match),A((t=>{const{companyId:e}=t.payload,a=cr(i.value.tenantState,e);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_accounting_projects_enabled:!1}).pipe(y((n=>{const o=n.data?.companies??[];if(T(n)&&o.length>0){const c=[Q({payload:o,schema:{}})];return a!=null&&c.push(pm({enabled:!1,tenantId:a})),c.push(mm()),c.push(N({messageSection:"accounting_projects_enabled_update",messageText:"success",type:"success"})),_(c)}return _([yt({status:n.status}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})])})),v((n=>p(yt({status:f("Unexpected error",`Update Accounting Projects Enabled errored out - ${n instanceof Error?n.message:JSON.stringify(n)}`)}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})))))}))),(s,i,r)=>s.pipe(S(sD.match),y((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;return r.deleteAndGetJSON(t).pipe(A((e=>T(e)?p(Xh({stripe_connected:!1,publishable_key:""}),Vt()):p(en(e.status)))),v((e=>p(en(f("Unexpected Error","Stripe disconnect REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(JN.match),A((t=>{const{companyId:e,accountId:a}=t.payload,n=cr(i.value.tenantState,e),o={capitalization_onboarding_dismissed_accounts:{[a]:!0}};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,o).pipe(y((c=>T(c)&&n!=null?_([lm({tenantId:n,accountId:a})]):_([]))),v((()=>_([]))))}))),NG,OG,CG,(s,i,r)=>s.pipe(S(dj.match),y((t=>{const e=t.payload.attachmentId;return r.getFile(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/transactions/attachments/download/${e}`).pipe(y((a=>p(a!=null?lj({attachmentId:e,data:a}):Rb()))),v((a=>(console.error(`REST API call errored out ${a}`),p(Rb())))))}))),(s,i)=>s.pipe(S(Yq.match),y((r=>{const{taskIds:t,groupId:e}=r.payload,a=i.value,{groupByKey:n}=a.taskListState.uiState,o=Hq(n,e),c=[xb({taskIds:t,groupId:e,removeFromList:!1}),rl(t,e,o)];return _(c)}))),(s,i,r)=>s.pipe(S($N.match),A((t=>{const{companyId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounting_provider_project_authorization_status`).pipe(y((a=>T(a)&&a.data!=null?a.data.is_accounting_provider_project_apis_authorized!==!0?_([RN()]):_([ym(e)]):_([yt({status:a.status}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})]))),v((a=>p(yt({status:f("Unexpected error",`Accounting provider project authorization status errored out - ${a instanceof Error?a.message:JSON.stringify(a)}`)}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})))))}))),(s,i,r)=>s.pipe(S(CV.match),y((t=>{const{isAutoPayEnabled:e,companyId:a}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${a}`,{is_auto_pay_enabled:e}).pipe(y((n=>{if(M(n)&&n.data!=null){const o=[V({users:n.data.users}),Y(n.data.user_roles),Q({payload:n.data.companies,schema:{}}),xV(),N({messageSection:e?"charge_card_auto_pay_enable":"charge_card_auto_pay_disable",messageText:"success",type:"success"})];return _(o)}return p(jv(n.status),N({messageSection:e?"charge_card_auto_pay_enable":"charge_card_auto_pay_disable",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]}))})),v((n=>p(jv(f("Unexpected Error","Enable Charge Card Auto Pay errored out"+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(iB.match),y((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/config`;return r.putAndGetJSON(t,{is_invoicing_enabled:!0}).pipe(A((e=>T(e)&&e.data!=null?p(Ni(e.data),cB()):p(ih(e.status)))),v((e=>p(ih(f("Unexpected Error","Enable invoicing REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(jV.match),y((t=>{const{companyId:e,setupViewType:a}=t.payload;let n;switch(a){case"reimbursement":n={is_reimbursement_enabled:!0};break;case"charge_cards":n={is_charge_cards_enabled:!0};break;case"debit_cards":n={is_debit_cards_enabled:!0};break;case"charge_cards__debit_cards":n={is_charge_cards_enabled:!0,is_debit_cards_enabled:!0};break;case"zeni_accounts":n={is_deposit_accounts_enabled:!0};break;default:n={is_bill_pay_enabled:!0}}return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,n).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[V({users:o.data.users}),Y(o.data.user_roles),Q({payload:o.data.companies,schema:{}}),we({companyId:o.data.companies[0].company_id}),GV()];return _(c)}return p(Xv(o.status))})),v((o=>p(Xv(f("Unexpected Error","Enable Setup errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(xJ.match),y((t=>{const{publicToken:e,linkTokenType:a}=t.payload,n={public_token:e};return a!=="update_account"&&(n.is_primary_for_onboarding=!0,n.is_primary_for_bill_pay=!0,n.is_primary_for_reimbursements=!0,n.is_primary_for_charge_cards=!0,n.is_primary_for_deposit_accounts=!0),r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/public-token`,n).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.payment_accounts.map((l=>l.payment_account_id)),d=[W(o.data.accounts,"onboarding"),Se(o.data.payment_accounts),UJ(c,a)];return _(d)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),KS(o.status,a))})),v((o=>p(KS(f("Unexpected Error","Establish Onboarding Plaid Connection errored out"+JSON.stringify(o)),a)))))}))),(s,i,r)=>s.pipe(S(yL.match),y((t=>{const{publicToken:e,companyId:a,setupViewType:n,linkTokenType:o,plaidAccountKeyType:c,zeniMappedAccountId:d}=t.payload,l={public_token:e},u={},m=i.value.paymentAccountListState,h=i.value.tenantState.loggedInUser?.userId??"";o!=="link_external_account"&&(n==null&&c!=="expense_automation_reconcile"?l.is_user_account=!0:c==="bill_pay_setup"?l.is_primary_for_bill_pay=!0:c==="reimbursement_setup"?l.is_primary_for_reimbursements=!0:c==="charge_card_setup"?l.is_primary_for_charge_cards=!0:c==="account_setup"?l.is_primary_for_deposit_accounts=!0:c==="billing_setup"?l.is_primary_for_onboarding=!0:c==="expense_automation_reconcile"&&(u.zeni_mapped_account_id=d??""));const g=Object.entries(u).length>0?`?query=${JSON.stringify(u)}`:"";return r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/public-token${g}`,l).pipe(y((I=>{if(T(I)&&I.data!=null){const b=I.data.payment_accounts[0],E=[Se(I.data.payment_accounts),Ht({data:I.data.payment_accounts,updateType:"merge"}),_L(o,c)];if(c==="bill_pay_detail"&&E.push(hL(b.payment_account_id)),c==="charge_card_payment"){const P=SL(b),O=gL(P,m.paymentAccountBalanceFetchStatus);E.push(fL(O))}if(n!=null&&(n==="billing"&&E.push(cc(n,c,!1)),b.is_primary_for_bill_pay,b.is_primary_for_bill_pay===!0&&E.push(Gr({companyId:a,primaryFundingAccountId:b.payment_account_id,accountType:"paymentAccount",productType:"bill_pay"})),b.is_primary_for_reimbursements===!0&&E.push(Gr({companyId:a,primaryFundingAccountId:b.payment_account_id,accountType:"paymentAccount",productType:"reimbursement"})),b.is_primary_for_charge_cards===!0&&E.push(Gr({companyId:a,primaryFundingAccountId:b.payment_account_id,accountType:"paymentAccount",productType:"charge_cards"})),b.is_primary_for_deposit_accounts===!0&&E.push(Gr({companyId:a,primaryFundingAccountId:b.payment_account_id,accountType:"paymentAccount",productType:"zeni_accounts"}))),I.data.bank_accounts!=null){const P=I.data.bank_accounts.map((O=>O.bank_account_id));E.push(Je(I.data.bank_accounts),np({bankAccountIds:P,userId:h}))}return n!=null?E.push(W(I.data.accounts,Da(n))):E.push(N({messageSection:"account_added",messageText:"success",type:"success"})),_(E)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),iI(I.status,o,c))})),v((I=>p(iI(f("Unexpected Error","Establish Plaid Connection errored out"+JSON.stringify(I)),o,c)))))}))),(s,i,r)=>s.pipe(S(zO.match),y((t=>{const{accountId:e}=t.payload,a=i.value,n=H(a),o=a.expenseAutomationViewState.selectedPeriodByTenantId[n.tenantId],c=Ea(a,e,o),d={account_id:e,bank_balance:c?.balance?.amount??null,cleared_balance:c?.clearedBalance?.amount??null,variance:c?.variance?.amount??null},l=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/excluded-accounts`;return r.postAndGetJSON(l,d).pipe(y((u=>{if(T(u)){const m=Ns("excluded_account_reconciliation",e),h=Ns("account_reconciliation",e);return p(KO({account:u.data?.excluded_account??void 0,selectedPeriod:o}),zm({oldKey:h,newKey:m}),N({messageSection:"account_excluded_from_reconciliation",messageText:"success",type:"success",variables:[{variableName:"_account-name_",variableValue:c?.account.accountName??""}]}))}return p(Km({error:u.status}),N({messageSection:"account_excluded_from_reconciliation",messageText:"failed",type:"error"}))})),v((u=>p(Km({error:f("Unexpected Error",`Exclude account from reconciliation REST API call errored out ${JSON.stringify(u)}`)}),N({messageSection:"account_excluded_from_reconciliation",messageText:"failed",type:"error"})))))}))),(s,i,r)=>s.pipe(S(UV.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_company_interested_in_charge_card:!0}).pipe(y((a=>{if(M(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),kV()];return _(n)}return p(Gv(a.status),N({messageSection:"charge_card_express_interest",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(Gv(f("Unexpected Error","Express Interest in Charge Card errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(dP.match),A((t=>{const e=(a=>{const n=new FormData;return a.forEach(((o,c)=>{n.append(`attachment_file_${c}`,o);const d=JSON.stringify({file_name:o.name,content_type:o.type,size:o.size});n.append(`attachment_json_${c}`,d)})),n})(t.payload.files);return r.postFormData(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-documents/extract`,e).pipe(y((a=>M(a)&&a.data!=null&&a.data.extracted_rules!=null?p(no(a.data.extracted_rules)):p(Yl(a.status)))),v((a=>p(Yl(f("Unexpected Error","Extract card-policy document REST API call errored out"+JSON.stringify(a)))))),De(s.pipe(S(Kl.match))))}))),(s,i,r)=>s.pipe(S(be.match),y((t=>{const{accountListKey:e,fetchFullResponse:a,excludeAccountPayableAccounts:n,excludeAccountReceivableAccounts:o,isLimitedCategoryEnabled:c,filterAccountTypes:d,isIncludeDeleted:l}=t.payload,u=((h,g)=>g.length>0?g:h===!0?["cogs","expenses","other_expense"]:[])(c,d),m={is_bookkeeping_admin:a,is_exclude_account_payable_accounts:n,is_exclude_account_receivable_accounts:o,account_types:u,...l===!0&&{is_include_deleted:!0}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify(m))}`).pipe(y((h=>{if(T(h)){const g=[W(h.data?.accounts??[],"account_list"),BP({accountListKey:e,accountListResponse:h})];return _(g)}return p(cu({accountListKey:e,status:h.status}))})),v((h=>p(cu({accountListKey:e,status:f("Unexpected Error","Fetch Accounts REST API call errored out"+JSON.stringify(h))})))))}))),(s,i,r)=>s.pipe(S(uu.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify({is_bookkeeping_admin:!1,is_include_tax_1099_config:!0}))}`).pipe(y((t=>{if(T(t)){const e=[],a=[];return t.data?.accounts.forEach((n=>{a.push(n)})),e.push(W([...a],"account_list_by_type")),e.push(JP({accountPayload:a})),_(e)}return p(pu({status:t.status}))})),v((t=>p(pu({status:f("Unexpected Error","Fetch Accounts For Account Type REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(uy.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify({is_bookkeeping_admin:!1,is_include_tax_1099_config:!1}))}`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[],a=[];return t.data.accounts.forEach((n=>{a.push(n)})),e.push(W([...a],"account_list_by_type")),e.push(xC({accountPayload:a})),_(e)}return p(py({status:t.status}))})),v((t=>p(py({status:f("Unexpected Error","Fetch Accounts For Account Type REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(sf.match),y((t=>{const{scheduleType:e}=t.payload,{scheduleListState:a}=i.value,n=nc(a,e),o=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedTimeframe:n.selectedTimeframe,c=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedCategoryId:n.selectedCategoryId,d=ua(o),l=ln(c,o),u=n.jeScheduleAccruedByListKey[l];if(u!=null&&u.fetchState==="Completed"&&t.payload.cacheOverride===!1)return _([]);const m={start_date:ae(d.start),end_date:ae(d.end),je_schedule_type:e,sort_by:"transaction_date",sort_order:"desc",filter:t.payload.statusFilter};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(m))}`).pipe(y((h=>{if(T(h)&&h.data!=null){const g=[];return g.push(ca(h.data.je_schedules),br(h.data.je_schedules,h.data.scheduled_journal_entries),q$(e,o,c,h.data.je_schedules)),_(g)}return p(nf(e,o,c,h.status))})),v((h=>p(nf(e,o,c,f("Unexpected Error","Accrued Schedule List REST API call errored out"+JSON.stringify(h)))))))}))),xG,(s,i,r)=>s.pipe(S(RP.match),A((t=>{const{addressId:e,cacheOverride:a}=t.payload,n=ot(i.value.addressState,e);return a===!0||n==null?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/addresses/${e}`).pipe(y((o=>T(o)?p(z(o.data?.addresses??[]),Su(e)):p(gu({addressId:e,status:o.status})))),v((o=>p(gu({addressId:e,status:f("Unexpected Error","Fetch Address REST API call errored out"+JSON.stringify(o))}))))):p(Su(e))}))),(s,i,r)=>s.pipe(S(QP.match),A((t=>{const{fromMonth:e,toMonth:a,cacheOverride:n}=t.payload,o=i.value.aggregatedReportViewState.aggregatedReport,c=ZP(e,a);if(!(n||o[c]?.fetchState!=="Error"&&o[c]?.fetchState!=="Completed"))return p(WP());const d=`${r.apiEndPoints.agentPerfBaseUrl}/1.0/agent-performance/reports/aggregated?from_month=${e}&to_month=${a}`;return r.getJSON(d).pipe(y((l=>T(l)?p(XP(l.data)):p(Pu(l.status)))),v((l=>p(Pu(f("Unexpected error","REST API call errored out"+JSON.stringify(l)))))))}))),(s,i,r)=>s.pipe(S(uo.match),A((()=>{const t=`${`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`}/ai-accountant/customers`;return r.getJSON(t).pipe(y((e=>{if(T(e)){const a=e.data?.customers??[],n=e.data?.users??[];return _([qP(a),V({users:n}),jP(a)])}return p(Iu(e.status))})),v((e=>p(Iu(f("Unexpected error","AI Accountant customers fetch failed: "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(GP.match),A((t=>{const{tenantId:e,fetchNextPage:a}=t.payload,n=i.value.aiAccountantViewState.customersByTenantId[e],o=a&&n?.jobsPageToken!=null?n.jobsPageToken:null,c=new URLSearchParams({page_size:"50",tenant_id:e});o!=null&&c.set("page_token",o);const d=`${`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`}/ai-accountant/jobs?${c.toString()}`;return r.getJSON(d).pipe(y((l=>{if(T(l)){const u=l.data?.jobs??[],m=l.data?.users??[],h=l.data?.next_page_token??null;return _([V({users:m}),zP(e,u,a),KP(e,h)])}return p(bu({tenantId:e,error:l.status}))})),v((l=>p(bu({tenantId:e,error:f("Unexpected error","AI Accountant jobs fetch failed: "+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(aJ.match),y((()=>{const t=`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-agents-activation/status`;return r.getJSON(t).pipe(y((e=>{if(T(e)&&e.data!=null){const n=(e.data.phases??[]).map(lK);return p(rJ({phases:n,counts:(a=e.data.counts,{customerCount:a?.customer_count??0,glAccountCount:a?.gl_account_count??0,targetTransactionCount:a?.target_transaction_count??0,transactionCount:a?.transaction_count??0,vendorCount:a?.vendor_count??0})}))}var a;return p(kS(e.status))})),v((e=>p(kS(f("Unexpected Error","fetchAiAgentsActivationStatus errored out "+JSON.stringify(e)))))))}))),(s,i)=>s.pipe(S(WN.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([fa(),je(),pr(),mr(),yr(),_r(),hr(),is(),Ro(),Tm(),fs(0,"dueDate","descending",!1),$o()]);{const e=i.value,a=[];return e.companyViewState.managementView.fetchState==="In-Progress"||e.companyViewState.managementView.hasValidState()||a.push(fa()),e.companyViewState.zeniUsers.fetchState==="In-Progress"||e.companyViewState.zeniUsers.hasValidState()||a.push(je()),e.subscriptionViewState.subscriptionListView.fetchState==="In-Progress"||e.subscriptionViewState.subscriptionListView.hasValidState()||a.push(pr()),e.companyViewState.portfolioView.fetchState==="In-Progress"||e.companyViewState.portfolioView.hasValidState()||a.push(mr()),e.onboardingCockpitViewState.fetchState==="In-Progress"||e.onboardingCockpitViewState.hasValidState()||a.push(yr()),e.onboardingCockpitViewState.qboConnectionPool.fetchState==="In-Progress"||e.onboardingCockpitViewState.qboConnectionPool.hasValidState()||a.push(_r()),e.onboardingCockpitViewState.onboardingCompletedCompanies.fetchState==="In-Progress"||e.onboardingCockpitViewState.onboardingCompletedCompanies.hasValidState()||a.push(hr()),e.reviewCompanyViewState.fetchState!=="In-Progress"&&e.reviewCompanyViewState.hasValidState()===!1&&a.push(is()),e.companyHealthMetricViewState.fetchState!=="In-Progress"&&e.companyHealthMetricViewState.hasValidState()===!1&&(a.push(Ro()),a.push($o())),e.companyViewState.metaDataView.fetchState!=="In-Progress"&&e.companyViewState.metaDataView.hasValidState()===!1&&a.push(Tm()),e.companyTaskManagerViewState.fetchState!=="In-Progress"&&e.companyTaskManagerViewState.hasValidState()===!1&&a.push(fs(0,"dueDate","descending",!1)),_(a)}}))),(s,i)=>s.pipe(S(bC.match),A((r=>{const{cacheOverride:t,refreshViewInBackground:e}=r.payload,a=i.value,{monthEndCloseChecksState:n}=a,{monthEndCloseChecksByTenantId:o}=n,c=H(a),d=c.companyId,l=a.expenseAutomationViewState.selectedPeriodByTenantId[c.tenantId],{selectedTransactionCategorizationTab:u}=a.expenseAutomationTransactionsViewState,m=Re(l),h=ge(m.start),g=ge(m.end),I=Ee(l),b=o?.[c.tenantId]?.[I],E=b?.monthEndCloseCheckList.some((P=>P.id==="reconciliation"))??!1;if(h==null||g==null||d==null)throw Error(`Invalid start - ${h} and end - ${g} period from given ${l}`);if(t===!0){const P=[];return P.push(fr(u,{start:h,end:g},t,!1,void 0,void 0,e,!1),vr({start:h,end:g},{amount:75,currencyCode:"USD",currencySymbol:"$"},t,e),ks(l,t,e,null),Pa({start:h,end:g},t)),E&&P.push(Rt(l,void 0,t,e)),_(P)}{const P=[];a.expenseAutomationMissingReceiptsViewState.fetchState==="In-Progress"||a.expenseAutomationMissingReceiptsViewState.hasValidState()&&a.expenseAutomationMissingReceiptsViewState.transactionIdsBySelectedPeriod[I]!=null||P.push(vr({start:h,end:g},{amount:75,currencyCode:"",currencySymbol:""},t,e)),a.expenseAutomationFluxAnalysisViewState.fetchState==="In-Progress"||a.expenseAutomationFluxAnalysisViewState.hasValidState()&&a.expenseAutomationFluxAnalysisViewState.groupsBySelectedPeriod[I]!=null||P.push(ks(l,t,e,null));const O=cy(a.expenseAutomationJESchedulesViewState.uiState.selectedPageTab,I);return a.expenseAutomationJESchedulesViewState.fetchState==="In-Progress"||a.expenseAutomationJESchedulesViewState.hasValidState()&&a.expenseAutomationJESchedulesViewState.jeScheduleTransactionKeysByPeriodAndTab[O]!=null&&a.expenseAutomationJESchedulesViewState.failedJeScheduleTransactionKeysByPeriodAndTab[O]!=null||P.push(Pa({start:h,end:g},t)),a.expenseAutomationReconciliationViewState.fetchState!=="In-Progress"&&a.expenseAutomationReconciliationViewState.accountReconciliationRecordsBySelectedPeriod[I]==null&&E&&P.push(Rt(l,void 0,t,e)),a.expenseAutomationTransactionsViewState.transactionCategorizationView[u].fetchState==="In-Progress"||a.expenseAutomationTransactionsViewState.transactionCategorizationView[u].hasValidState()!==!1&&a.expenseAutomationTransactionsViewState.transactionCategorizationView[u].transactionIdsBySelectedPeriod[I]!=null||P.push(fr(u,{start:h,end:g},t,!1,void 0,void 0,e,!1)),_(P)}}))),(s,i)=>s.pipe(S(WJ.match),A((r=>{const{companyId:t,shouldFetchClassList:e}=r.payload,a=[dr(t),$e("manager",!0)];return e&&a.push(se()),_(a)}))),(s,i,r)=>s.pipe(S(Hd.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tags?query=${encodeURIComponent(JSON.stringify({filter_type:"all"}))}`).pipe(y((t=>T(t)&&t.data!=null?p(Zr(t.data.tags),pq({data:t.data.tags})):p(yb({fetchState:"Error",error:t.status})))),v((t=>p(yb({fetchState:"Error",error:f("Unexpected Error","Fetch Tag List REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(sl.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/groups?query=${encodeURIComponent(JSON.stringify({filter_type:"all"}))}`).pipe(y((t=>T(t)&&t.data!=null?p(bb(t.data.task_groups),Gq({data:t.data.task_groups})):p(Cb({fetchState:"Error",error:t.status})))),v((t=>p(Cb({fetchState:"Error",error:f("Unexpected Error","Fetch all task groups REST API call errored out"+JSON.stringify(t))})))))))),UG,(s,i)=>s.pipe(S(GA.match),y((r=>{const{cacheOverride:t,vendorName:e}=r.payload,a=i.value,n=[];if(t===!0)e!=null&&n.push(sr(e,"vendor")),n.push(us(e));else if(e!=null){const{fetchState:o,recommendations:c=[]}=ps(a,e,"vendor");o==="In-Progress"?n.push(us(e)):o!=="Completed"?(e&&n.push(sr(e,"vendor")),n.push(us(e))):n.push(Np({recommendations:c,vendorId:void 0}))}return _(n)}))),(s,i,r)=>s.pipe(S(GT.match),A((t=>{const{vendorId:e,reportDate:a}=t.payload,n={vendor_id:e,report_date:a.format("YYYY-MM-DD")};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/accounts_payable_aging_detail?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(T(o)&&o.data!=null){const d=[le(o.data.report.vendors),zT(o.data.report,e,a)];return _(d)}const c=[Ku(o.status,e,a)];return _(c)})),v((o=>{const c=[Ku(f("Unexpected error","ApAging Detail Report REST API call errored out"+JSON.stringify(o)),e,a)];return _(c)})))}))),(s,i,r)=>s.pipe(S(yo.match),A((t=>{const{reportDate:e,cacheOverride:a}=t.payload,n={is_reimbursements_user_allowed:!0,report_date:e.format(re)},o=i.value.apAgingState,c=Yu(e);return o.apAgingBalancesByDate[c]!=null&&a===!1?_([]):r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/accounts_payable_aging?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[le(d.data.report.vendors,"merge"),KT(e,d.data.report)];return _(l)}{const l=[Hu(d.status)];return _(l)}})),v((d=>{const l=[Hu(f("Unexpected error","ApAging Report REST API call errored out"+JSON.stringify(d)))];return _(l)})))}))),(s,i,r)=>s.pipe(S(YT.match),A((t=>{const{customerId:e,reportDate:a}=t.payload,n={customer_id:e,report_date:a.format("YYYY-MM-DD")};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/accounts_receivable_aging_detail?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(T(o)&&o.data!=null){const d=[Qu(o.data.report.customers,!0),HT(o.data.report,e,a)];return _(d)}const c=[Wu(o.status,e,a)];return _(c)})),v((o=>{const c=[Wu(f("Unexpected error","ArAging Detail Report REST API call errored out"+JSON.stringify(o)),e,a)];return _(c)})))}))),(s,i,r)=>s.pipe(S(_o.match),A((t=>{const{reportDate:e,cacheOverride:a}=t.payload,n={report_date:e.format("YYYY-MM-DD")},o=i.value.arAgingState,c=Yu(e);return o.arAgingBalancesByDate[c]!=null&&a===!1?_([]):r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/accounts_receivable_aging?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[Qu(d.data.report.customers),QT(e,d.data.report)];return _(l)}{const l=[Zu(d.status)];return _(l)}})),v((d=>{const l=[Zu(f("Unexpected error","ArAging Report REST API call errored out"+JSON.stringify(d)))];return _(l)})))}))),(s,i,r)=>s.pipe(S(WT.match),y((t=>{const{companyId:e,fetchAction:a,reportGroupId:n}=t.payload,o=i.value.companyState.companiesById[e].companyInfo.tenantId;if(o!=null){const c=hz(a,n),{userId:d,sessionId:l}=r,u={"zeni-user-id":d,"zeni-tenant-id":o,"zeni-session-id":l};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/audit?query=${encodeURIComponent(JSON.stringify(c))}`,u).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[ZT(e,n,m.data)];return _(h)}{const h=[Xu(e,n,m.status)];return _(h)}})),v((m=>{const h=[Xu(e,n,f("Unexpected error","Audit Report Group view errored out"+JSON.stringify(m)))];return _(h)})))}return _([])}))),(s,i,r)=>s.pipe(S(XT.match),A((t=>{const{cacheOverride:e}=t.payload,a=i.value,{fetchState:n}=a.auditReportViewState.auditRuleGroupView;return e===!0||n!=="In-Progress"?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/audit-rule-groups`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[eA(o.data.audit_rule_groups)];return _(c)}{const c=[ep(o.status)];return _(c)}})),v((o=>{const c=[ep(f("Unexpected error","Audit rule group view errored out"+JSON.stringify(o)))];return _(c)}))):_([])}))),(s,i,r)=>s.pipe(S(IR.match),A((()=>{const t=i.value.autotransferRulesState.ruleUpdateLocalData,e={...t.sourceAccount!=null&&{from_account:{account_id:t.sourceAccount.id,account_type:Xr(t.sourceAccount.accType)??""}},...t.destinationAccount!=null&&{to_account:{account_id:t.destinationAccount.id,account_type:Xr(t.destinationAccount.accType)??""}},...t.amount!=null&&{amount:t.amount.amount,currency_code:t.amount.currencyCode,currency_symbol:t.amount.currencySymbol}};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/transfers/review`,e).pipe(y((a=>T(a)&&a.data!=null?p(bR(a.data)):p(Tf(a.status)))),v((a=>p(Tf(f("Unexpected Error","Fetch auto transfer review detail REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(ER.match),y((t=>{const{ruleId:e,cacheOverride:a}=t.payload,n=[],o=i.value,c=X(o.autotransferRulesState.historyByRuleId,e,void 0);if(a===!0||c==null||c.fetchState!=="In-Progress"){n.push(dc({ruleId:e,fetchState:"In-Progress"}));const d=r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto/${e}/history`).pipe(y((l=>T(l)&&l.data!=null?p(PR({ruleId:e,historicEventsPayload:l.data.activities})):p(dc({ruleId:e,fetchState:"Error",error:l.status})))),v((l=>p(dc({ruleId:e,fetchState:"Error",error:f("Unexpected Error","Fetch auto transfer rule history REST API call errored out "+JSON.stringify(l))})))));return j(_(n),d)}return _(n)}))),(s,i,r)=>s.pipe(S(TR.match),A((t=>{const e=i.value,{cacheOverride:a}=t.payload,{autotransferRulesState:n,depositAccountListState:o,paymentAccountListState:c}=e;return a===!0||n.hasValidState()===!1&&n.fetchState!=="In-Progress"?r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto/list`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.auto_transfer_rules.map(kl),u=[AR({rules:l})];return o.fetchState!=="In-Progress"&&o.fetchState!=="Completed"&&u.push(ke()),c.fetchState!=="In-Progress"&&c.fetchState!=="Completed"&&u.push(Ge()),u.push(Af(!1,!0)),_(u)}return p(Nf({fetchState:"Error",error:d.status}))})),v((d=>p(Nf({fetchState:"Error",error:f("Unexpected Error","Fetch auto transfer rules REST API call errored out "+JSON.stringify(d))}))))):_([])}))),(s,i)=>s.pipe(S(rA.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Ct("month",!0),Ct("quarter",!0),Ct("year",!0)]);{const e=[],a=i.value.balanceSheetClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Ct("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Ct("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Ct("year")),_(e)}}))),(s,i)=>s.pipe(S(ho.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Ot("month"),Ot("quarter"),Ot("year")]);{const e=[],a=i.value.balanceSheetState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Ot("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Ot("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Ot("year")),_(e)}}))),(s,i,r)=>s.pipe(S(Ct.match),y((t=>{const e={is_full_response:!0,time_series_groups:[Sz(t.payload.timeframe)],is_group_by_class:!0,...t.payload.cacheOverride===!0?{is_hard_refresh:!0}:{}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/balance_sheet?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],{report:o}=a.data,c=o.currency;return n.push(oe(t.payload.timeframe,he("cash_and_equivalents"),"balance_sheet_by_classes",o.assets.current_assets.cash_and_equivalents,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("accounts_receivable"),"balance_sheet_by_classes",o.assets.current_assets.accounts_receivable,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("other_current_assets"),"balance_sheet_by_classes",o.assets.current_assets.other_current_assets,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("fixed_assets"),"balance_sheet_by_classes",o.assets.fixed_assets,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("other_assets"),"balance_sheet_by_classes",o.assets.other_assets,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("accounts_payable"),"balance_sheet_by_classes",o.liabilities.current_liabilities.accounts_payable,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("credit_cards"),"balance_sheet_by_classes",o.liabilities.current_liabilities.credit_cards,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("other_current_liabilities"),"balance_sheet_by_classes",o.liabilities.current_liabilities.other_current_liabilities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("long_term_liabilities"),"balance_sheet_by_classes",o.liabilities.long_term_liabilities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("equity"),"balance_sheet_by_classes",o.equity,o.classes,o.accounts,c)),n.push(sA({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(ap(a.status,t.payload.timeframe))})),v((a=>p(ap(f("Unexpected Error","Balance Sheet by Class REST API call errored out: "+(a instanceof Error?a.message:JSON.stringify(a))),t.payload.timeframe)))))}))),kG,(s,i,r)=>s.pipe(S(xt.match),y((t=>{const e={is_full_response:!0,time_series_groups:[gz(t.payload.timeframe)],is_group_by_project:!0,...t.payload.cacheOverride===!0?{is_hard_refresh:!0}:{}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/balance_sheet?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],{report:o}=a.data,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,he("cash_and_equivalents"),"balance_sheet_by_projects",o.assets.current_assets.cash_and_equivalents,o.accounts,c)),n.push(ie(t.payload.timeframe,he("accounts_receivable"),"balance_sheet_by_projects",o.assets.current_assets.accounts_receivable,o.accounts,c)),n.push(ie(t.payload.timeframe,he("other_current_assets"),"balance_sheet_by_projects",o.assets.current_assets.other_current_assets,o.accounts,c)),n.push(ie(t.payload.timeframe,he("fixed_assets"),"balance_sheet_by_projects",o.assets.fixed_assets,o.accounts,c)),n.push(ie(t.payload.timeframe,he("other_assets"),"balance_sheet_by_projects",o.assets.other_assets,o.accounts,c)),n.push(ie(t.payload.timeframe,he("accounts_payable"),"balance_sheet_by_projects",o.liabilities.current_liabilities.accounts_payable,o.accounts,c)),n.push(ie(t.payload.timeframe,he("credit_cards"),"balance_sheet_by_projects",o.liabilities.current_liabilities.credit_cards,o.accounts,c)),n.push(ie(t.payload.timeframe,he("other_current_liabilities"),"balance_sheet_by_projects",o.liabilities.current_liabilities.other_current_liabilities,o.accounts,c)),n.push(ie(t.payload.timeframe,he("long_term_liabilities"),"balance_sheet_by_projects",o.liabilities.long_term_liabilities,o.accounts,c)),n.push(ie(t.payload.timeframe,he("equity"),"balance_sheet_by_projects",o.equity,o.accounts,c)),n.push(nA({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(rp(a.status,t.payload.timeframe))})),v((a=>p(rp(f("Unexpected Error","Balance Sheet by Project REST API call errored out: "+(a instanceof Error?a.message:JSON.stringify(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(oA.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([xt("month",!0),xt("quarter",!0),xt("year",!0)]);{const e=[],a=i.value.balanceSheetProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(xt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(xt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(xt("year")),_(e)}}))),(s,i,r)=>s.pipe(S(ic.match),A((()=>{const t=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify({is_bookkeeping_admin:!0,is_exclude_account_payable_accounts:!0,is_exclude_account_receivable_accounts:!0,account_types:["bank"]}))}`;return r.getJSON(t).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.accounts.map((o=>o.account_id)),n=[];return n.push(W$({bankAccountIds:a}),W(e.data.accounts,"bill_pay")),p(...n)}return p(df(e.status))})),v((e=>p(df(f("Unexpected error","Fetch Bank Accounts REST API call errored out"+JSON.stringify(e)))))))}))),(s,i)=>s.pipe(S(Z$.match),y((r=>{const{cacheOverride:t}=r.payload,e=[],a=i.value,n=H(a),o=!!n.companyZeniAccountInfo?.info?.isZeniAccountEnabled;if(t===!0)e.push(ic()),e.push(Ge()),o===!0&&e.push(ke());else{const c=a.settingsViewState.bankConnection;c.fetchState!=="Completed"&&c.fetchState!=="In-Progress"&&e.push(ic());const d=a.paymentAccountListState;d.hasValidState()===!1&&d.fetchState!=="In-Progress"&&e.push(Ge());const l=a.depositAccountListState;o===!0&&l.hasValidState()===!1&&l.fetchState!=="In-Progress"&&e.push(ke())}return j(_(e))}))),(s,i,r)=>s.pipe(S(_A.match),A((t=>{const{bankAccountIban:e,cacheOverride:a}=t.payload,n=i.value.bankAccountViewState,o=n.bankCountryNamebyIban[e]?.countryName;if(a===!1&&o)return p(hA(e));{const c={iban:t.payload.bankAccountIban};return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`).pipe(y((d=>T(d)?p(SA({bankAccountIban:t.payload.bankAccountIban,institutions:d.data?.institutions??[]})):p(ip({bankAccountIban:e,status:d.status})))),v((d=>p(ip({bankAccountIban:e,status:f("Unexpected Error","Get Bank Country Name REST API call errored out"+JSON.stringify(d))})))))}}))),(s,i,r)=>s.pipe(S(gA.match),A((t=>{const{routingNumber:e,cacheOverride:a}=t.payload,n=i.value.bankAccountViewState,o=n.bankNameByRouting[e]?.bankName;if(a===!1&&o)return p(fA(e));{const c={routing_numbers:[t.payload.routingNumber]};return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`).pipe(y((d=>T(d)?p(vA({routingNumber:t.payload.routingNumber,institutions:d.data?.institutions??[]})):p(cp({routingNumber:e,status:d.status})))),v((d=>p(cp({routingNumber:e,status:f("Unexpected Error","Get Bank Name By Routing REST API call errored out"+JSON.stringify(d))})))))}}))),(s,i,r)=>s.pipe(S(IA.match),A((t=>{const{swiftCode:e,cacheOverride:a}=t.payload,n=i.value.bankAccountViewState,o=n.bankNameBySwift[e]?.bankName;if(a===!1&&o)return p(bA(e));{const c={swift_code:t.payload.swiftCode};return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`).pipe(y((d=>T(d)?p(EA({swiftCode:t.payload.swiftCode,institutions:d.data?.institutions??[]})):p(dp({swiftCode:e,status:d.status})))),v((d=>p(dp({swiftCode:e,status:f("Unexpected Error","Get Bank Name By Swift REST API call errored out"+JSON.stringify(d))})))))}}))),(s,i)=>s.pipe(S(Ec.match),y((r=>{const{billId:t,cacheOverride:e,isShowDeletedBillsEnabled:a,hasZeniAssistAccess:n}=r.payload,o=i.value,c=[];if(e)c.push(pc(t,a,n,!0)),c.push(Pc(t));else{let d=0;const l=Ne(t),u=X(o.billDetailViewState.billDetailById,l,void 0);(u==null||u?.fetchState!="In-Progress"&&u?.fetchState!="Completed"||u?.vendorId==null)&&(d++,c.push(pc(t,a,!1))),d==0?c.push(Tc(t)):c.push(Pc(t))}return _(c)}))),(s,i,r)=>s.pipe(S(pc.match),y((t=>{const{billId:e,isShowDeletedBillsEnabled:a,cacheOverride:n}=t.payload,o=Ne(e),c=[],d=i.value;if(n===!0){const u=X(d.billDetailViewState.billDetailById,o,void 0);c.push(...(function(m,h){const g=[];return g.push(BR(m)),h!=null&&g.push(lc(Ne(m))),g})(e,u))}const l=X(d.billDetailViewState.billDetailById,o,void 0);if(n==1||l==null||l.fetchState!=="In-Progress"){c.push(Lr(e,"In-Progress")),c.push(yn(e,"bill_pay",n));const u={transaction_type:"bill",bill_pay_provider:"zeni",is_include_payment_accounts_info:!0,is_include_approval_info:!0,is_include_vendor_info:!0,is_include_deleted:a},m=r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}?query=${encodeURIComponent(JSON.stringify(u))}`).pipe(y((h=>{if(T(h)&&h.data?.transaction?.transaction_id!=null){const g=h.data.transaction.transaction_id,I=h.data?.vendors?.[0],b=I?.contacts??[],E=dt(h.data?.vendors??[]),P=I?.bank_accounts??[],O=I?.payment_instruments??[],C=I?.account!=null?[I?.account]:[],U=I?.accounting_class!=null?[I?.accounting_class]:[],B=[...JK(h.data.transaction),mc(h.data.recurring_bill_configs),Bf(h.data.recurring_bills),mn(h.data.transaction),Se(h.data.payment_accounts),Qe(h.data.deposit_accounts),W(h.data.accounts??[],"bill_pay"),V({users:h.data.users??[]}),We(h.data.approval_rules),Et(h.data.entity_approvals),W(C,"account_list"),Ke("class_list",U),mt(b),z(E),Je([...P,...h.data.bank_accounts]),la(O),le(h.data.vendors??[])];if(I==null&&h.data.transaction.candidate_vendor_name!=null&&h.data.transaction.candidate_vendor_name.length>0)B.push(wt({searchString:h.data?.transaction.candidate_vendor_name})),B.push(kf(e,h.data,void 0));else{B.push(yc({billId:e,billDetail:h.data})),B.push(Lr(g,"Completed",void 0,I?.vendor_id));const x=h.data?.transaction;x!=null&&x.total_amount!=null&&I!=null&&B.push(_c(I.vendor_name,I.vendor_id,x.total_amount,x.recipient_total_amount,x.document_id,e)),["failed","cancelled","returned"].includes(x.bill_pay_info.bill_payment_status.code??"")&&t.payload.hasZeniAssistAccess&&B.push(Df(e,!0))}return _(B)}return p(Lr(t.payload.billId,"Error",h.status))})),v((h=>(console.error(`REST API call errored out ${h}`),p(Lr(t.payload.billId,"Error",f("Unexpected Error",`REST API call errored out ${h}`)))))));return j(_(c),m)}return _(c)}))),s=>s.pipe(S(X$.match),A((i=>{const{companyId:r}=i.payload;return _([Io(),cc("billing","billing_setup",!1),lf(r,!1)])}))),(s,i)=>s.pipe(S($R.match),y((r=>{const t=[],e=["draft","pending_approval","scheduled","paid"],a=i.value,{tenantState:n,companyState:o}=a,{currentTenantId:c}=n,d=c!=null?n.tenantsById?.[c]?.companyId:void 0,l=Te(o,d??""),u=l?.company.companyZeniAccountInfo.isZeniAccountEnabled??!1,{period:m,cacheOverride:h,isShowDeletedBillsEnabled:g,isInternationalWireEnabled:I}=r.payload;if(h===!0)t.push(Fr(I)),e.forEach((b=>t.push(Sc(m,b,g))));else{a.billPayConfigState.fetchState!=="Completed"&&a.billPayConfigState.fetchState!=="In-Progress"&&t.push(Fr(I));const b=a.depositAccountListState;u&&b.fetchState!=="In-Progress"&&b.fetchState!=="Completed"&&t.push(ke());const E=a.paymentAccountListState;E.fetchState!=="In-Progress"&&E.fetchState!=="Completed"&&t.push(Ge()),e.forEach((P=>{const O=RR(m,P),C=X(a.billListState.byBillListKey,O,void 0);C!=null&&C.hasValidState()!==!1||t.push(Sc(m,P,g))}))}return _(t)}))),(s,i,r)=>s.pipe(S(Sc.match),y((t=>{const{period:e,tab:a,isShowDeletedBillsEnabled:n}=t.payload,o={start_date:ae(e.start),end_date:ae(e.end),sort_by:"transaction_date",sort_order:"desc",bill_pay_provider:"zeni",transaction_type:"bill",bill_stage_code:a,is_include_pending_approval_transaction_ids_for_user:a==="pending_approval",is_include_approval_info:a==="pending_approval",is_include_deleted:!!n&&a!=="draft"};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[];return d.push(V({users:c.data.users??[]}),mc(c.data.recurring_bill_configs),gc(c.data.transactions),MR({billList:c.data,tab:a}),Et(c.data.entity_approvals??[])),_(d)}return p($f(e,a,c.status))})),v((c=>p($f(t.payload.period,t.payload.tab,f("Unexpected Error","fetch bills REST API call errored out"+JSON.stringify(c)))))))}))),(s,i)=>s.pipe(S(jR.match),y((r=>{const{cacheOverride:t,includeUserRoles:e}=r.payload,{billPaySetupApproverViewState:a,classListState:n}=i.value,{approverListState:o}=a,c=pt(i.value),d=[];return t===!0?(d.push(fc(t,e)),c&&d.push(se())):(a.hasValidState()===!1&&o.fetchStatus.fetchState!=="In-Progress"&&d.push(fc(!0,e)),c&&n.hasValidState()===!1&&n.fetchState!=="In-Progress"&&d.push(se())),j(_(d))}))),(s,i,r)=>s.pipe(S(fc.match),A((t=>{const{cacheOverride:e,includeUserRoles:a}=t.payload,{billPaySetupApproverViewState:n}=i.value,o=n.approverListState.approverIds;if(e===!0||o.length===0)return r.getJSON(`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approvers?query={"is_include_user_roles_info":${a}}`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data.users.map((u=>u.user_id)),l=[V({users:c.data.users})];return a===!0&&l.push(Y(c.data.user_roles)),l.push(Lf(d,c.data.attributes)),_(l)}return p(Ff(c.status))})),v((c=>p(Ff(f("Unexpected Error","Fetch Approvers List errored out"+JSON.stringify(c)))))));{const{approverListState:c}=n,{approverIds:d,attributes:l}=c;return p(Lf(d,l))}}))),(s,i,r)=>s.pipe(S(go.match),y((()=>{const t=ua({startDate:ee(up,"YYYY-MM-DD"),endDate:ee(lp,"YYYY-MM-DD")}),e={start_date:ae(t.start),end_date:ae(t.end),sort_by:"transaction_date",sort_order:"desc",bill_pay_provider:"zeni",transaction_type:"bill",bill_stages:{pending_approval:["awaiting_approval","awaiting_my_approval"],paid:["all"],scheduled:["all"],draft:["all"]},get_count_only:!0,is_include_approval_info:!0,is_include_pending_approval_transaction_ids_for_user:!0,is_exclude_bills_processed_outside_zeni:!0};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bill-pay-card?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>T(a)&&a.data!=null?p(PA({transactionTotals:a.data.transaction_totals,transactionCount:a.data.transaction_count})):p(pp(a.status)))),v((a=>p(pp(f("Unexpected Error","fetch Billpay Dashboard Card REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Fr.match),y((t=>r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bill-pay/config?query=${encodeURIComponent(JSON.stringify({bill_pay_provider:"zeni",transaction_type:"bill",is_include_events:!0,is_include_payment_accounts_info:!0}))}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=[];return a.push(VR({billPayConfigPayload:e.data,isInternationalWireEnabled:t.payload.isInternationalWireEnabled})),_(a)}return p(Rf(e.status))})),v((e=>p(Rf(f("Unexpected Error","fetch bill-pay config REST API call errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(vc.match),A((t=>{const{cacheOverride:e,useV3:a}=t.payload,{billPaySetupApproverViewState:n,approvalRuleState:o,classListState:c}=i.value,d=pt(i.value),l=qf(o,n.approvalRuleIds),u=d&&(e===!0||c.hasValidState()===!1&&c.fetchState!=="In-Progress");if(e===!0||l.length!==n.approvalRuleIds.length||n.hasValidState()===!1&&n.fetchState!=="In-Progress"){const m=a===!0?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;return r.getJSON(m).pipe(y((h=>{if(T(h)&&h.data!=null){const g=h.data.approval_rules.map((b=>b.approval_rule_id)),I=[V({users:h.data.users}),We(h.data.approval_rules),jf(g)];return u&&I.push(se()),_(I)}return p(Gf(h.status))})),v((h=>p(Gf(f("Unexpected Error","Fetch Approval view errored out"+JSON.stringify(h)))))))}{const{approvalRuleIds:m}=n,h=[jf(m)];return u&&h.push(se()),_(h)}}))),(s,i,r)=>s.pipe(S(QR.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{billPaySetupViewState:o,companyState:c,plaidAccountViewState:d}=i.value,l=Te(c,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"bill_pay_setup"}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=u.data.accounts.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses),ve({files:u.data.files}),W(u.data.accounts,"bill_pay"),Se(u.data.payment_accounts),Ht({data:u.data.payment_accounts,updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"replace"}),we({companyId:u.data.companies[0].company_id}),rt(m,"bill_pay_setup"),ev()];return _(h)}return p(N({messageSection:"bill_pay_setup",messageText:"failed",type:"error"}),tv(u.status))})),v((u=>p(tv(f("Unexpected Error","Fetch Bill Pay Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=d.spend_management_setup.accountDetails;return p(we({companyId:e}),rt(u,"bill_pay_setup"),ev())}}))),(s,i,r)=>s.pipe(S(ci.match),y((()=>{const t=i.value.expenseAutomationMissingReceiptsViewState.bulkUpload,{currentBatchId:e}=t;return e==null?p(di({error:f("Unexpected Error","No current batch ID available")})):Cy(t.batchStatusById,t.batchListByPeriod,e)?r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${e}`).pipe(y((a=>{if(!T(a)||a.data==null||!zn(a.data.status))return T(a)&&a.data!=null?F:p(di({error:a.status}));const n=[],o=Kn(a.data.files);return o.length>0&&n.push(Ce(o,(c=>c.transaction_id))),n.push(Aa(Yn(a.data,r.apiEndPoints.fileMicroServiceBaseUrl))),n.push(Pr({cacheOverride:!0})),_(n)})),v((a=>p(di({error:f("Unexpected Error","Fetch batch details errored out: "+JSON.stringify(a))}))))):F}))),(s,i,r)=>s.pipe(S(Pr.match),A((t=>{const{cacheOverride:e}=t.payload,a=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:n},expenseAutomationMissingReceiptsViewState:{bulkUpload:o}}=a,c=n[H(a).tenantId],d=Ee(c),l=o.batchListByPeriod[d]??[];if(e!==!0&&l.length>0)return p(Js({batchList:l,selectedPeriod:c}));const{end:u,start:m}=Al(xy),h={start_date:m,end_date:u,sort_order:"desc"};return r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(h))}`).pipe(y((g=>T(g)&&g.data!=null?p(Js({batchList:g.data.batches.map(Uy),selectedPeriod:c})):p(ky({error:g.status,selectedPeriod:c})))),v((g=>p(ky({error:f("Unexpected Error","Fetch bulk upload batches errored out: "+JSON.stringify(g)),selectedPeriod:c})))))}))),(s,i,r)=>s.pipe(S(hb.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses`).pipe(y((t=>T(t)&&t.data!=null?p(_q({cannedResponses:(t.data.canned_responses??[]).map(eY)})):p(Sb({fetchState:"Error",error:t.status})))),v((t=>p(Sb({fetchState:"Error",error:f("Unexpected Error","Fetch Canned Responses errored: "+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(fo.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/card_balance`).pipe(y((t=>T(t)?p(W(t.data?.report.accounts??[],"card_balance"),TA(t.data)):p(mp(t.status)))),v((t=>p(mp(f("Unexpected error","Card Balance REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(sM.match),$t((t=>{const e=t.payload;return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${e}`).pipe(y((a=>{if(M(a)&&a.data!=null){const{template:n}=a.data,o=nM(oM(n)),c=[Rc(n),iM(o),Mc({fetchState:"Completed"})];return _(c)}return p(Mc({fetchState:"Error",error:a.status}))})),v((a=>p(Mc({fetchState:"Error",error:f("Unexpected Error","Fetch card-policy detail REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(pM.match),$t((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`).pipe(y((t=>{if(M(t)&&t.data!=null){const e=mM(t.data),a=yM(t.data.stats),n=[_M(e),hM(a),Lc({fetchState:"Completed",templateIds:e.map((o=>o.templateId))})];return _(n)}return p(Lc({fetchState:"Error",error:t.status}))})),v((t=>p(Lc({fetchState:"Error",error:f("Unexpected Error","Fetch card-policy list REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(Ev.match),$t((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/mcc-codes`).pipe(y((t=>M(t)&&t.data!=null?_([AM(t.data)]):p(Pv(t.status)))),v((t=>p(Pv(f("Unexpected Error","Fetch card policy MCC categories REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(lP.match),A((t=>{const e={view:"vendor_list",page_token:null,sort_by:"year_to_date_spend",sort_order:"desc",search_text:a=t.payload.searchString,vendor_name:a};var a;const n=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors?query=${encodeURIComponent(JSON.stringify(e))}`;return r.getJSON(n).pipe(A((o=>M(o)&&o.data!=null?p(uP(o.data)):p(Hl(o.status)))),v((o=>p(Hl(f("Unexpected Error","Fetch card policy vendor options REST API call errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(vO.match),A((()=>{const t=`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cockpit/card-tenant-profiles`;return r.getJSON(t).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.rows;return _([IO(a),bO(a)])}return p(km(e.status))})),v((e=>p(km(f("Unexpected error","REST API call errored out: "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Fc.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/cashback?query=${encodeURIComponent('{"is_include_cashback_insights":true}')}`).pipe(y((t=>M(t)&&t.data!=null?p(o_([t.data.insights]),BM(t.data)):p(Ov(t.status)))),v((t=>p(Ov(f("Unexpected Error","Fetch charge card cashback REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Po.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/cash_balance`).pipe(y((t=>T(t)?p(W(t.data?.report.accounts??[],"cash_balance"),kA(t.data)):p(Sp(t.status)))),v((t=>p(Sp(f("Unexpected error","Cash Balance REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(BA.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Dt("month",!0),Dt("quarter",!0),Dt("year",!0)]);{const e=[],a=i.value.cashFlowClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Dt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Dt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Dt("year")),_(e)}}))),(s,i)=>s.pipe(S(To.match),A((r=>{const{fetchFullReport:t,cacheOverride:e}=r.payload;if(e===!0)return _([Bt("month",t),Bt("quarter",t),Bt("year",t)]);{const a=[],n=i.value.cashFlowState.fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(Bt("month",t)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(Bt("quarter",t)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(Bt("year",t)),_(a)}}))),(s,i,r)=>s.pipe(S(Dt.match),y((t=>{const e={is_full_response:!0,time_series_groups:[Iz(t.payload.timeframe)],is_group_by_class:!0,...t.payload.cacheOverride===!0?{is_hard_refresh:!0}:{}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/cash_flow?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],{report:o}=a.data,c=o.currency;return n.push(oe(t.payload.timeframe,Fe("adjustments"),"cash_flow_by_classes",o.operating_activities.adjustments,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("investing_activities"),"cash_flow_by_classes",o.investing_activities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("financing_activities"),"cash_flow_by_classes",o.financing_activities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("net_income"),"cash_flow_by_classes",o.operating_activities.net_income,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("operating_activities"),"cash_flow_by_classes",o.operating_activities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("change_in_cash_and_equivalents"),"cash_flow_by_classes",o.change_in_cash_and_equivalents,o.classes,o.accounts,c)),n.push(DA({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(gp(a.status,t.payload.timeframe))})),v((a=>p(gp(f("Unexpected Error","Cash Flow by Class REST API call errored out: "+(a instanceof Error?a.message:JSON.stringify(a))),t.payload.timeframe)))))}))),BG,(s,i,r)=>s.pipe(S(Jt.match),y((t=>{const e={is_full_response:!0,time_series_groups:[bz(t.payload.timeframe)],is_group_by_project:!0,...t.payload.cacheOverride===!0?{is_hard_refresh:!0}:{}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/cash_flow?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],{report:o}=a.data,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,Fe("adjustments"),"cash_flow_by_projects",o.operating_activities.adjustments,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("investing_activities"),"cash_flow_by_projects",o.investing_activities,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("financing_activities"),"cash_flow_by_projects",o.financing_activities,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("net_income"),"cash_flow_by_projects",o.operating_activities.net_income,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("operating_activities"),"cash_flow_by_projects",o.operating_activities,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("change_in_cash_and_equivalents"),"cash_flow_by_projects",o.change_in_cash_and_equivalents,o.accounts,c)),n.push(JA({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(fp(a.status,t.payload.timeframe))})),v((a=>p(fp(f("Unexpected Error","Cash Flow by Project REST API call errored out: "+(a instanceof Error?a.message:JSON.stringify(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(wA.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Jt("month",!0),Jt("quarter",!0),Jt("year",!0)]);{const e=[],a=i.value.cashFlowProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Jt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Jt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Jt("year")),_(e)}}))),(s,i,r)=>s.pipe(S(Ao.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/cash_in_cash_out`).pipe(y((t=>T(t)?p(W(t.data?.report.accounts??[],"cash_in_cash_out"),RA(t.data?.report.account_groups??[],"cash_in_cash_out"),$A(t.data),vp({thisPeriod:i.value.reportUIOptionsState.thisPeriod})):p(Ip(t.status)))),v((t=>p(Ip(f("Unexpected error","CashInCashOut REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(No.match),A((t=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/cash_position?query=${encodeURIComponent(`{"is_full_response":${t.payload.fetchFullReport}}`)}`).pipe(y((e=>T(e)?p(W(e.data?.report.accounts??[],"cash_position"),MA(e.data),bp({thisPeriod:i.value.reportUIOptionsState.thisPeriod})):p(Ep(e.status)))),v((e=>p(Ep(f("Unexpected error","Cash Position REST API call errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(Wt.match),y((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/config`).pipe(y((t=>{if(M(t)&&t.data!=null){const e=[];return e.push(DM(t.data)),_(e)}return p(Cv(t.status))})),v((t=>p(Cv(f("Unexpected Error","Fetch charge card config REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(jc.match),A((t=>{const{chargeCardId:e,cacheOverride:a}=t.payload,n=[],o=i.value,c=X(o.chargeCardDetailState.detailById,e,void 0);if(a===!0||c==null||c.fetchState!=="In-Progress"){const d=a===!0&&c!=null&&c.fetchState!=="Not-Started";n.push(In({chargeCardId:e,isRefreshingViewInBackground:d,fetchState:d?c.fetchState:"In-Progress",error:d?c.error:void 0}));const l={is_include_card_activation_events:!0,is_include_connected_account_info:!0,is_include_card_pin_change_attempt_history:!0},u=r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}?query=${JSON.stringify(l)}`).pipe(y((m=>M(m)&&m.data!=null?p(st(m.data.card),V({users:m.data.users}),Y(m.data.user_roles),z(m.data.addresses),wM(m.data.connected_account),In({chargeCardId:e,isRefreshingViewInBackground:!1,fetchState:"Completed"})):p(In({chargeCardId:e,fetchState:"Error",isRefreshingViewInBackground:!1,error:m.status})))),v((m=>p(In({chargeCardId:e,fetchState:"Error",isRefreshingViewInBackground:!1,error:f("Unexpected Error","Fetch card detail API call errored out"+JSON.stringify(m))})))));return j(_(n),u)}return _(n)}))),(s,i)=>s.pipe(S($M.match),y((r=>{const{chargeCardId:t,cacheOverride:e,doFetchCreditAccounts:a,isCreditCardEnabled:n}=r.payload,o=[],c=i.value,d=c.chargeCardDetailState.detailById[t],l=d!=null?d.transactionList.uiState.pageToken:null,u=d!=null?d.transactionList.uiState.pageTokenType:null;if(e===!0)o.push(jc(t,e)),o.push(Gc(t,null,null,!0)),o.push(Wt(!0)),a&&n&&o.push(Zt(!0)),a&&n&&o.push(qr(!0));else{const m=c.chargeCardDetailState.detailById[t];(m==null||m.fetchState!=="In-Progress"&&m.hasValidState()===!1)&&o.push(jc(t,e));const h=m?.transactionList;(h==null||h.fetchState!=="Completed"&&h.fetchState!=="In-Progress")&&o.push(Gc(t,l,u));const g=c.chargeCardConfigState;g.fetchState!=="In-Progress"&&g.hasValidState()===!1&&o.push(Wt());const I=c.chargeCardListState;I.creditAccount.fetchState!=="Completed"&&I.creditAccount.fetchState!=="In-Progress"&&a&&n&&o.push(Zt()),I.creditAccountRepayment.fetchState!=="Completed"&&I.creditAccountRepayment.fetchState!=="In-Progress"&&a&&n&&o.push(qr())}return j(_(o))}))),(s,i,r)=>s.pipe(S(jr.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards?query=${encodeURIComponent('{"is_include_total_cash_back":true, "is_include_unassigned_credit": true}')}`).pipe(y((t=>{if(M(t)&&t.data!=null){const e=[];return H(i.value).userRole.includes("charge_card_user")&&e.push(rV({uiState:{sortKey:"cardName"}})),e.push(qa(t.data.cards),V({users:t.data.users}),Y(t.data.user_roles),z(t.data.addresses),Bv({chargeCardListPayload:t.data})),_(e)}return p(Dv(t.status))})),v((t=>p(Dv(f("Unexpected Error","Fetch charge cards list REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(sV.match),y((r=>{const{doFetchCreditAccountsDebitSummaryAndCashback:t,isDebitCardEnabled:e,isCreditCardEnabled:a,cacheOverride:n}=r.payload,o=[],c=i.value,d=c.cashbackDetailState;if(n===!0)t===!0&&(a&&(o.push(Zt(!0)),o.push(qr(!0))),e&&o.push(rd(!0)),o.push(Fc(!0))),o.push(jr(!0)),o.push(Wt(!0)),o.push($e("cardHolderCandidate",!0)),o.push($e("cardAdmin",!0)),o.push(se());else{const l=c.chargeCardListState;t===!0&&a&&l.creditAccount.fetchState!=="Completed"&&l.creditAccount.fetchState!=="In-Progress"&&o.push(Zt()),t===!0&&a&&l.creditAccountRepayment.fetchState!=="Completed"&&l.creditAccountRepayment.fetchState!=="In-Progress"&&o.push(qr()),t&&d.fetchState!=="In-Progress"&&d.hasValidState()===!1&&o.push(Fc()),l.fetchState!=="In-Progress"&&l.hasValidState()===!1&&o.push(jr());const u=c.chargeCardConfigState;u.fetchState!=="In-Progress"&&u.hasValidState()===!1&&o.push(Wt());const m=c.userListViewState.userListByType.cardHolderCandidate;m.fetchState!=="In-Progress"&&m.hasValidState()===!1&&o.push($e("cardHolderCandidate",!1));const h=c.userListViewState.userListByType.cardAdmin;if(h.fetchState!=="In-Progress"&&h.hasValidState()===!1&&o.push($e("cardAdmin",!1)),c.classListState.hasValidState()===!1&&c.classListState.fetchState!=="In-Progress"&&o.push(se()),t&&e&&c.chargeCardListState.debitCardSummaries.fetchState!=="In-Progress"&&c.chargeCardListState.debitCardSummaries.fetchState!=="Completed"&&o.push(rd()),t&&e&&c.issueChargeCardState.depositAccountsFetchState.fetchState!=="In-Progress"&&c.issueChargeCardState.depositAccountsFetchState.fetchState!=="Completed"&&o.push(bn()),t&&c.chargeCardSetupViewState.fetchState!=="In-Progress"&&c.chargeCardSetupViewState.fetchState!=="Completed"){const g=H(c);o.push(Jv(g.companyId,!0))}}return j(_(o))}))),(s,i,r)=>s.pipe(S(cd.match),A((()=>{const t=encodeURIComponent(JSON.stringify({include_history:!0}));return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments?query=${t}`).pipe(y((e=>M(e)&&e.data!=null?p(SV(e.data.repayment_history),V({users:e.data.repayment_history.map((a=>a.paid_by_user)).filter((a=>a!=null))}),hV(e.data)):p(Lv(e.status)))),v((e=>p(Lv(f("Unexpected Error","Fetch charge card payment history REST API call errored out"+JSON.stringify(e)))))))}))),(s,i)=>s.pipe(S(gV.match),y((r=>{const{cacheOverride:t}=r.payload,e=[],a=i.value,n=a.chargeCardPaymentHistoryState;t===!0?e.push(cd(!0)):n.fetchState!=="Completed"&&n.fetchState!=="In-Progress"&&e.push(cd());const o=a.depositAccountListState,c=a.paymentAccountListState;return(o.fetchState!=="Completed"&&o.fetchState!=="In-Progress"||c.fetchState!=="Completed"&&c.fetchState!=="In-Progress")&&e.push(Fv()),j(_(e))}))),(s,i)=>s.pipe(S(Fv.match),y((()=>{const r=[],t=i.value,e=t.depositAccountListState;e.fetchState!=="In-Progress"&&e.fetchState!=="Completed"&&r.push(ke());const a=t.paymentAccountListState;return a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&r.push(Ge()),_(r)}))),(s,i,r)=>s.pipe(S(Jv.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{chargeCardSetupViewState:o,plaidAccountViewState:c,companyState:d}=i.value,l=Te(d,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"charge_cards_setup"}`).pipe(y((u=>{if(M(u)&&u.data!=null){const m=u.data.accounts.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses),ve({files:u.data.files}),W(u.data.accounts,"charge_cards"),Se(u.data.payment_accounts),Ht({data:u.data.payment_accounts,updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"merge"}),we({companyId:u.data.companies[0].company_id}),rt(m,"charge_card_setup"),zv()];return _(h)}return p(N({messageSection:"charge_card_setup",messageText:"failed",type:"error"}),Kv(u.status))})),v((u=>p(Kv(f("Unexpected Error","Fetch Charge Card Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=c.spend_management_setup.accountDetails;return p(we({companyId:e}),rt(u,"charge_card_setup"),zv())}}))),(s,i,r)=>s.pipe(S(GM.match),A((t=>{const{cardIds:e}=t.payload,a={card_ids:e};return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/recurring-expenses?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>{if(T(n)&&n.data!=null){const o={};return n.data.forEach((c=>{o[c.card_id]=c.expenses.map((d=>zM(d)))})),p(KM({recurringExpensesByChargeCardId:o}),Kc({fetchState:"Completed",error:void 0}))}return p(Kc({fetchState:"Error",error:n.status}))})),v((n=>p(Kc({fetchState:"Error",error:f("Unexpected Error","Fetch Charge Cards Recurring Expenses REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(BV.match),y((t=>{const{creditAccountId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/credit-accounts/${e}/statements`).pipe(y((a=>T(a)?p(DV({data:a.data?.statements??[]})):p(Yv({fetchState:"Error",error:a.status})))),v((a=>p(Yv({fetchState:"Error",error:f("Unexpected Error","Fetch Credit Card statement REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(RM.match),A((t=>{const{transactionId:e,cardId:a,attachmentIds:n}=t.payload;let o=`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/transactions/${e}/attachments`;return o+=`?query=${encodeURIComponent(JSON.stringify({attachment_ids:n}))}`,r.getJSON(o).pipe(y((d=>M(d)&&d.data!=null?p(MM({transactionId:e,cardId:a,transactionAttachments:d.data.attachments})):p(xv({cardId:a,transactionId:e,status:d.status})))),v((d=>p(xv({cardId:a,transactionId:e,status:f("Unexpected Error","Fetch charge card transaction attachments API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(Gc.match),A((t=>{const{chargeCardId:e,pageToken:a,pageTokenType:n,cacheOverride:o}=t.payload,{uiState:c}=i.value.chargeCardDetailState.detailById[e]?.transactionList??VM.transactionList,d={page_token:a,page_token_type:n,sort_by:c.sortKey==="paymentDate"?"transaction_date":c.sortKey,sort_order:Vo(c.sortOrder)};return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/transactions?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>M(l)&&l.data!=null?p(FM(l.data.transactions),LM({chargeCardId:e,data:l.data,cacheOverride:o})):p(Uv({chargeCardId:e,error:l.status})))),v((l=>p(Uv({chargeCardId:e,error:f("Unexpected Error","Fetch charge card transactionList API call errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(qM.match),A((t=>{const{chargeCardId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/analytics/transaction-statistics`).pipe(y((a=>T(a)&&a.data?p(jM({chargeCardId:e,statistics:a.data}),zc({chargeCardId:e,fetchState:"Completed",error:void 0})):p(zc({chargeCardId:e,fetchState:"Error",error:a.status})))),v((a=>p(zc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Fetch Charge Card Transaction Statistics REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(fT.match),y((t=>{const{chatSessionId:e,userId:a}=t.payload,n=i.value,o=n.aiCfoViewState.uiState.chatHistoryNextPageToken[e]?.nextPageToken??null,c=new URLSearchParams;return c.append("page_size","20"),c.append("chat_session_id",e),c.append("user_id",a),o!=null&&c.append("page_token",o),r.getJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/history?${c.toString()}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.next_page_token==null;return p(IT({chatSessionId:e,history:d.data.messages,isPaginationComplete:l}),vT({chatSessionId:e,nextPageToken:d.data.next_page_token}))}return p(ku({chatSessionId:e,error:d.status}))})),v((d=>p(ku({chatSessionId:e,error:f("Unexpected Error","Fetch Chat History REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(bT.match),A((()=>{const t=i.value.aiCfoViewState.uiState.chatSessionsNextPageToken.nextPageToken??null,e=new URLSearchParams;return e.append("page_size","50"),t!=null&&e.append("page_token",t),r.getJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions?${e.toString()}`).pipe(y((a=>{if(T(a)&&a.data!=null){const n=a.data.sessions.filter((o=>!!o.chat_session_summary));return p(PT(n),ET({sessions:n,nextPageToken:a.data.next_page_token}))}return p(Bu(a.status))})),v((a=>p(Bu(f("Unexpected Error","Fetch Chat Sessions for User REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(se.match),Le(i),A((([t,e])=>{if(!pt(e))return p(Pp({status:f("Success",""),data:{accounting_classes:[]}}));const{isIncludeDeleted:a}=t.payload,n=a===!0?`?query=${encodeURIComponent(JSON.stringify({is_include_deleted:!0}))}`:"";return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/classes${n}`).pipe(y((o=>T(o)?p(Ke("class_list",o.data?.accounting_classes??[]),Pp(o)):p(Tp(o.status)))),v((o=>p(Tp(f("Unexpected Error","Fetch Classes REST API call errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(TN.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/cockpit-context`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=t.data?.companies??[],a=t.data?.users??[],n=t.data?.user_groups??[],o=e.map((u=>u.company_id)),c=a.map((u=>u.user_id)),d=n.map((u=>u.id)),l=[Q({payload:t.data.companies,schema:{}}),V({users:t.data.users}),em({userGroups:t.data.user_groups}),AN({companyIds:o,userIds:c,userGroupIds:d})];return _(l)}return p(tm(t.status))})),v((t=>p(tm(f("Unexpected error","Cockpit context fetch errored out"+JSON.stringify(t)))))))))),DG,(s,i,r)=>s.pipe(S(lf.match),A((t=>{const{companyId:e,cacheOverride:a}=t.payload,{settingsViewState:n,companyState:o}=i.value,c=Te(o,e)?.company;return a===!0||c==null||n.billingAddress.fetchState!=="In-Progress"?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"subscription_billing_address"}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[Q({payload:d.data.companies,schema:{}}),z(d.data.addresses),uf(),eR("subscription_billing_address")],u=d.data.companies[0].subscription_billing_address_id,m=d.data.addresses.find((h=>h.address_id===u));return m!=null&&l.push(qe({addressType:"subscription_billing_address",addressToCreate:tR(m)})),_(l)}return p(N({messageSection:"billing_address_view",messageText:"failed",type:"error"}),pf(d.status))})),v((d=>p(pf(f("Unexpected Error","Fetch Billing Address View errored out"+JSON.stringify(d))))))):p(uf())}))),JG,(s,i,r)=>s.pipe(S($o.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-health-metrics/config`).pipe(y((t=>T(t)&&t.data!=null?p(nN(t.data.additional_churn_factors)):p($p(t.status)))),v((t=>p($p(f("Unexpected Error","Fetch company health metric config REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Ro.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/health-monitor`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[],a=t.data.companies.map((n=>n.company_id));return e.push(Q({payload:t.data.companies,schema:{}})),e.push(Rp({payload:t.data.company_health_metrics})),e.push(oN({companyIds:a})),_(e)}return p(Mp({error:t.status}))})),v((t=>p(Mp({error:f("Unexpected Error","Fetch Company Health Metric View REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(fa.match),A((t=>{const e={is_full_response:t.payload.fetchFullResponse};return t.payload.companyParentId!=null&&(e.is_include_subsidiaries=!0,e.company_id=t.payload.companyParentId),r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/management?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(T(a)&&a.data!=null){const n=a.data.companies.map((l=>l.company_id)),o=bl(a.data.subscriptions),c=qo(a.data.user_roles,a.data.companies),d=[Y(a.data.user_roles),Q({payload:a.data.companies,schema:a.data.schema.company,subset:t.payload.companyParentId!=null,companyIdTenantIdMapping:c}),lr({payload:a.data.subscriptions,schema:a.data.schema.subscription}),_a({payload:a.data.subscription_plans,schema:a.data.schema.subscription_plan}),ha({payload:a.data.subscription_addons,schema:a.data.schema.subscription_addon}),Sa({payload:a.data.subscription_summaries,schema:a.data.schema.subscription_summary}),om({payload:a.data.customer_satisfactions}),ZN({tasks:a.data.tasks})];return t.payload.companyParentId==null&&d.push(vs("company_management_view",n,o)),t.payload.companyParentId!=null&&(i.value.companyViewState.managementView.fetchState!=="Completed"&&d.push(vs("company_management_view",n,o,!0)),d.push(XN({payload:a.data.companies,parentCompanyId:t.payload.companyParentId}))),t.payload.fetchFullResponse&&a.data.users!=null&&d.push(V({users:a.data.users})),_(d)}{const n=[ga("company_management_view",[],a.status)];return t.payload.companyParentId!=null&&n.push(Am()),_(n)}})),v((a=>{const n=[ga("company_management_view",[],f("Unexpected error","Company Management view errored out"+JSON.stringify(a)))];return t.payload.companyParentId!=null&&n.push(Am()),_(n)})))}))),wG,(s,i,r)=>s.pipe(S(uN.match),A((t=>{const{companyId:e,reportSentDate:a}=t.payload,n=i.value.companyState.companiesById[e].companyInfo.tenantId,o={history:!0,month_year:a.format(pN)};return n!=null?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/emails/month-end?query=${encodeURIComponent(JSON.stringify(o))}`,{"zeni-tenant-id":n}).pipe(y((c=>{if(T(c)&&c.data?.history!=null){const d=[mN({companyId:e,reportSentDate:a,data:c.data})];return c.data.history.length>0&&d.push(Fp({files:c.data.history[0].files})),_(d)}{const d=[qp({companyId:e,reportSentDate:a,error:c.status})];return _(d)}})),v((c=>{const d=[qp({companyId:e,reportSentDate:a,error:f("Unexpected error","Company Month End Report Historic Data errored out"+JSON.stringify(c))})];return _(d)}))):_([])}))),(s,i,r)=>s.pipe(S(yN.match),A((t=>{const{companyId:e}=t.payload,a=i.value.companyState.companiesById[e].companyInfo.tenantId,n={history_dates:!0};return a!=null?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/emails/month-end?query=${encodeURIComponent(JSON.stringify(n))}`,{"zeni-tenant-id":a}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[_N({companyId:e,data:o.data})];return _(c)}{const c=[jp({companyId:e,error:o.status})];return _(c)}})),v((o=>{const c=[jp({companyId:e,error:f("Unexpected error","Company Month End Report Historic Dates errored out"+JSON.stringify(o))})];return _(c)}))):_([])}))),(s,i,r)=>s.pipe(S(Gp.match),A((t=>{const{companyId:e,tenantId:a}=t.payload,n=i.value,o=a??n.companyState.companiesById[e].companyInfo.tenantId,c={email_templates:!0};return o!=null?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/emails/month-end?query=${encodeURIComponent(JSON.stringify(c))}`,{"zeni-tenant-id":o}).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[hN({companyId:e,data:d.data})];return _(l)}{const l=[zp({companyId:e,error:d.status})];return _(l)}})),v((d=>{const l=[zp({companyId:e,error:f("Unexpected error","Company Month End Report Templates errored out"+JSON.stringify(d))})];return _(l)}))):_([])}))),(s,i,r)=>s.pipe(S(Kp.match),A((t=>{const{cacheOverride:e,companyId:a,tenantId:n,refreshInsights:o,insightDate:c}=t.payload,d=i.value,l=d.companyMonthEndReportViewState.monthEndReportDataByCompanyId[a].fetchState,u=n??d.companyState.companiesById[a].companyInfo.tenantId;if(u==null||e!==!0&&l==="Completed")return _([]);{const m={insight_date:c??null,...o===!0&&{refresh_insights:o}},h=`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${a}/emails/month-end?query=${encodeURIComponent(JSON.stringify(m))}`;return r.getJSON(h,{"zeni-tenant-id":u}).pipe(y((g=>{if(T(g)&&g.data!=null){const I=[SN(a,g.data),Fp({files:g.data.files})];return _(I)}{const I=[Yp(a,g.status)];return _(I)}})),v((g=>{const I=[Yp(a,f("Unexpected error","Company Month End Report View errored out"+JSON.stringify(g)))];return _(I)})))}}))),(s,i,r)=>s.pipe(S(yr.match),A((t=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/onboarding?query=${encodeURIComponent(`{"is_full_response":${t.payload.fetchFullResponse}}`)}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.companies.map((c=>c.company_id)),n=Di(e.data.tenants,e.data.companies),o=[Ji(e.data.tenants),rn({payload:e.data.companies,schema:e.data.schema.company,onboardingInviteStatus:e.data.onboarding_invite_status,companyIdTenantIdMapping:n}),z(e.data.addresses??[]),SS({payload:e.data.parent_companies??[],schema:{}}),wi(e.data.tenants),AD(e.data.is_onboarding_allowed_for_user),$i({onboardingCustomersInfo:e.data.whitelist_companies})];return e.data.users!=null&&o.push(V({users:e.data.users})),e.data.user_roles!=null&&o.push(Y(e.data.user_roles)),o.push(Ri(a)),_(o)}return p(gS([],e.status))})),v((e=>p(gS([],f("Unexpected error","Onboarding Company view errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(dr.match),A((t=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${t.payload.companyId}?query={"view":"passport"}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.companies.map((c=>c.company_id)),n=bl(e.data.subscriptions),o=[V({users:e.data.users}),Y(e.data.user_roles),Q({payload:e.data.companies,schema:e.data.schema.company}),ve({files:e.data.files}),z(e.data.addresses),lr({payload:e.data.subscriptions,schema:e.data.schema.subscription}),_a({payload:e.data.subscription_plans,schema:e.data.schema.subscription_plan}),ha({payload:e.data.subscription_addons,schema:e.data.schema.subscription_addon}),ur({payload:e.data.subscription_coupons,schema:e.data.schema.subscription_coupon}),Sa({payload:e.data.subscription_summaries,schema:e.data.schema.subscription_summary}),um({companyId:t.payload.companyId}),vs("company_passport_view",a,n)];return _(o)}return p(ga("company_passport_view",[],e.status))})),v((e=>p(ga("company_passport_view",[],f("Unexpected error","Company Passport view errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(mr.match),A((t=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/portfolio?query=${encodeURIComponent(`{"is_full_response":${t.payload.fetchFullResponse}}`)}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.companies.map((c=>c.company_id)),n=qo(e.data.user_roles,e.data.companies),o=[Y(e.data.user_roles),Q({payload:e.data.companies,schema:e.data.schema.company,subset:!1,companyIdTenantIdMapping:n}),eO(e.data.accounting_summaries),vs("company_portfolio_view",a,{})];return t.payload.fetchFullResponse&&e.data.users!=null&&o.push(V({users:e.data.users})),_(o)}return p(ga("company_portfolio_view",[],e.status))})),v((e=>p(ga("company_portfolio_view",[],f("Unexpected error","Company Portfolio view errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(fs.match),A((t=>{const{from:e,searchString:a,sortKey:n,sortOrder:o,filters:c}=t.payload,d={size:100,from:e,global_search:a??"",sort_by:Ez(n),sort_order:Vo(o),filter_join:c?.categoryCombinationOperator==="AND"?"and":"or",...c?.categories!=null&&c.categories.length>0?{filter_by:Pz(c)}:{},task_group_scopes:c?.taskGroupScopes!=null&&c.taskGroupScopes.length>0?c.taskGroupScopes:["internal"]};return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/tasks-es?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=l.data.aggregations.group_by_company_name.buckets.flatMap((h=>h.tasks)),m=[NN({data:l.data}),ze(u),Zr(u.flatMap((h=>h.tags)))];return _(m)}{const u=[am(l.status)];return _(u)}})),v((l=>{const u=[am(f("Unexpected error","Cockpit Task manager errored out"+JSON.stringify(l)))];return _(u)})))}))),(s,i,r)=>s.pipe(S(Tr.match),A((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a},expenseAutomationMissingReceiptsViewState:{bulkUpload:n}}=e,o=a[H(e).tenantId],c=Ee(o),d=t.payload.pageToken==null,{sortKey:l,sortOrder:u,completedSubTab:m}=n,h=fx(c,l,u,m),g=n.completedTransactionsByPeriod[h];if(d&&t.payload.cacheOverride!==!0&&g!=null&&g.transactionIds.length>0)return _([]);const I=Re(o),b={start_date:I.start,end_date:I.end,page_token:t.payload.pageToken??null,page_size:25};l!=null&&(b.sort_by=l),u!=null&&(b.sort_order=u==="ascending"?"asc":"desc"),m!==li&&(b.match_type=m);const E=encodeURIComponent(JSON.stringify(b));return r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${E}`).pipe(y((P=>{if(T(P)&&P.data!=null){const O=P.data.transactions.map((U=>U.transaction_id)),C=[];return C.push(Ce(P.data.transactions,(U=>U.transaction_id))),C.push(vx({isInitialLoad:d,transactionIds:O,nextPageToken:P.data.next_page_token,totalCount:P.data.total_count,selectedPeriod:o,sortKey:l,sortOrder:u,completedSubTab:m})),_(C)}return p(By({error:P.status,selectedPeriod:o,sortKey:l,sortOrder:u,completedSubTab:m}))})),v((P=>p(By({error:f("Unexpected Error","Fetch completed transactions errored: "+JSON.stringify(P)),selectedPeriod:o,sortKey:l,sortOrder:u,completedSubTab:m})))))}))),(s,i)=>s.pipe(S(kU.match),y((r=>{const{cacheOverride:t}=r.payload,e=i.value,a=e.invoicingCustomerListViewState,n=e.invoicingCatalogListViewState,o=e.invoicingSettingsViewState,c=[];return Rn({fetchState:a.fetchState,error:a.error},t)&&c.push(Ks({filters:{},keepExistingListItems:!1})),Rn({fetchState:n.fetchState,error:n.error},t)&&c.push(Cr({filters:{type:"plan"},keepExistingListItems:!1})),Rn(n.productFetchState,t)&&c.push(gi({filters:{type:"addon|charge"},keepExistingListItems:!1})),Rn({fetchState:o.fetchState,error:o.error},t)&&c.push(Vt()),_(c)}))),(s,i,r)=>s.pipe(S(Zt.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/credit-accounts`).pipe(y((t=>M(t)&&t.data!=null?p(nV(t.data.credit_accounts)):p(wv(t.status)))),v((t=>p(wv(f("Unexpected Error","Fetch creditAccount REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(qr.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments`).pipe(y((t=>M(t)&&t.data!=null?p(oV(t.data)):p($v(t.status)))),v((t=>p($v(f("Unexpected Error","Fetch creditAccountRepayment REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(EO.match),A((()=>{const t=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/macros/credit-agent`;return r.getJSON(t).pipe(y((e=>T(e)&&e.data!=null?_([Bm(e.data),PO()]):p(Dm(e.status)))),v((e=>p(Dm(f("Unexpected error","REST API call errored out: "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(cI.match),y((t=>{const{conversionCurrencyCode:e,reimbursementId:a,lineId:n}=t.payload,o=i.value;let c=o.editRemiDetailViewState.newRemiState.remiDetailLocalData;a!=null&&(c=o.editRemiDetailViewState.editRemiStateById[a].remiDetailLocalData);const d=c.updatesByLineId[n].outOfPocket,l={amount:{amount:d.amount??0,currency_code:d.currencyCode,currency_symbol:d.currencySymbol},home_currency_code:e};return r.postAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/currencies/conversion`,l).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[],h=u.data.home_currency_conversions;return m.push(IL({reimbursementId:a,amountPayload:h,lineId:n})),m.push(md({reimbursementId:a,lineId:n,fetchState:"Completed",error:void 0})),_(m)}return p(md({reimbursementId:a,lineId:n,fetchState:"Error",error:u.status}))})),v((u=>p(md({reimbursementId:a,lineId:n,fetchState:"Error",error:f("Unexpected Error","Fetch Conversion Currency REST API call errored out"+JSON.stringify(u))})))))}))),(s,i)=>s.pipe(S(kO.match),A((r=>{const{userId:t,companyId:e,fetchFullReport:a,cacheOverride:n,excludeResources:o,tenantId:c}=r.payload,d=H(i.value),l=d.company?.featuresActivationInfo.isReimbursementFeatureEnabled,u=!!d?.userRole&&BO(d.userRole),m=DO(d.userRole),h=i.value.arAgingState.uiState.selectedDate,g=i.value.apAgingState.uiState.selectedDate,I=i.value.expenseAutomationViewState.selectedPeriodByTenantId[c]??JO;if(n===!0){const b=[Ia(t),fo(),Po(),Es(a),Ps(a),Ts(a),zo(a),Ko(),No(a),Ao(),Yo(),dr(e),ss(),Ho()];return o.includes("accounts_payable_aging")===!1&&b.push(yo(g)),o.includes("accounts_receivable_aging")===!1&&b.push(_o(h)),m||b.push(go()),l===!0&&u&&b.push(Qo()),o.includes("rewards_card")===!1&&b.push(Wo(!0)),o.includes("expense_automation_card")===!1&&b.push(et({tenantId:c,period:I,refreshViewInBackground:!1})),_(b)}{const b=i.value,E=[],P=$m(b.revenueState.uiState.selectedForecast?.id,b.revenueState),O=Rm(b.opExState.uiState.selectedForecast?.id,b.opExState),C=Mm(b.netBurnOrIncomeState.uiState.selectedForecast?.id,b.netBurnOrIncomeState);b.tenantState.fetchState==="In-Progress"||b.tenantState.hasValidState()||E.push(Ia(t)),b.cardBalanceState.fetchState==="In-Progress"||b.cardBalanceState.hasValidState()||E.push(fo()),b.cashBalanceState.fetchState==="In-Progress"||b.cashBalanceState.hasValidState()||E.push(Po()),O.fetchState!=="In-Progress"&&O.fetchState!=="Completed"&&E.push(Es(a)),P.fetchState!=="In-Progress"&&P.fetchState!=="Completed"&&E.push(Ps(a)),C.fetchState!=="In-Progress"&&C.fetchState!=="Completed"&&E.push(Ts(a)),b.netBurnOrIncomeStoryCardState.fetchState==="In-Progress"||b.netBurnOrIncomeStoryCardState.hasValidState()||E.push(zo(a)),b.topExState.fetchState==="In-Progress"||o.includes("top_expenses")!==!1||b.topExState.hasValidState()||E.push(Ko()),b.cashPositionState.fetchState==="In-Progress"||b.cashPositionState.hasValidState()||E.push(No(a)),b.cashInCashOutState.fetchState==="In-Progress"||b.cashInCashOutState.hasValidState()||E.push(Ao()),b.insightsCardState.fetchState==="In-Progress"||b.insightsCardState.hasValidState()||E.push(Yo()),b.companyViewState.passportView.fetchState==="In-Progress"||b.companyViewState.passportView.hasValidState()||E.push(dr(e)),b.tasksCardState.fetchState==="In-Progress"||o.includes("task_card")!==!1||b.tasksCardState.hasValidState()||E.push(ss()),b.dashboardLayoutState.fetchState!=="In-Progress"&&b.dashboardLayoutState.fetchState!=="Completed"&&E.push(Ho()),b.apAgingState.fetchState!=="In-Progress"&&b.apAgingState.fetchState!=="Completed"&&o.includes("accounts_payable_aging")===!1&&E.push(yo(g)),b.arAgingState.fetchState!=="In-Progress"&&b.arAgingState.fetchState!=="Completed"&&o.includes("accounts_receivable_aging")===!1&&E.push(_o(h)),b.billPayCardState.fetchState==="In-Progress"||b.billPayCardState.hasValidState()||m||E.push(go()),b.reimbursementCardState.fetchState!=="In-Progress"&&!b.reimbursementCardState.hasValidState()&&l===!0&&u&&E.push(Qo()),b.referralViewState.rewardsPlanFetchState.fetchState!=="In-Progress"&&b.referralViewState.rewardsPlanFetchState.fetchState!=="Completed"&&o.includes("rewards_card")===!1&&E.push(Wo(!0));const U=Ee(I);return b.monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[d.tenantId]?.[U]?.fetchState!=="In-Progress"&&b.monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[d.tenantId]?.[U]?.fetchState!=="Completed"&&o.includes("expense_automation_card")===!1&&E.push(et({tenantId:c,period:I,refreshViewInBackground:!1})),_(E)}}))),(s,i,r)=>s.pipe(S(Ho.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/webapp-preferences`).pipe(y((t=>{if(T(t)&&t.data){const e=t.data.preferences.card_order;let a=[...e];const n=a.indexOf("treasury_promo_card"),o=a.indexOf("zeni_promo_card");return n!==-1&&o!==-1&&o>n?(a[n]="zeni_promo_card",a[o]="treasury_promo_card",p(As(a))):n===-1?(a=[...e.slice(0,3),"treasury_promo_card",...e.slice(3)],p(As(a))):p(wO(a))}{const e=t.status.code===404,a=[Vm(t.status)];return e&&a.push(As($O)),p(...a)}})),v((t=>p(Vm(f("Unexpected Error","User preferences REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(rd.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/summaries?query={"card_types": ["debit"]}`).pipe(y((t=>M(t)&&t.data!=null?p(iV(t.data.debit_card_summaries)):p(Rv(t.status)))),v((t=>p(Rv(f("Unexpected Error","Fetch Debit Card Summary REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(OF.match),y((r=>{const{cacheOverride:t,depositAccountId:e}=r.payload,a=[],n=i.value;if(a.push(Cn(e)),t===!0)a.push(ke()),a.push(Ge()),a.push(Xt()),a.push(zr(e)),a.push(xn(e,!0)),a.push(Fd(e));else{const o=n.depositAccountListState;o.hasValidState()===!1&&o.fetchState!=="In-Progress"&&a.push(ke());const c=n.paymentAccountListState;c.hasValidState()===!1&&c.fetchState!=="In-Progress"&&a.push(Ge());const d=n.zeniAccountDetailState.depositAccountDetailById[e];(d==null||d.hasValidState()===!1&&d.fetchState!=="In-Progress")&&a.push(zr(e));const l=n.depositAccountTransactionListState.byDepositId[e];(l==null||l.fetchState!=="Completed"&&l.fetchState!=="In-Progress")&&a.push(xn(e,!1));const u=n.zeniAccountsConfigState;u.hasValidState()===!1&&u.fetchState!=="In-Progress"&&a.push(Xt()),a.push(Fd(e))}return j(_(a))}))),(s,i,r)=>s.pipe(S(zr.match),A((t=>{const{depositAccountId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}?query=${encodeURIComponent('{"is_include_deposit_accounts_summary":true}')}`).pipe(y((a=>T(a)?p(Qe(a.data?.deposit_accounts??[]),CF({data:a,depositAccountId:e,fetchState:"Completed"})):p(FI({depositAccountId:e,error:a.status})))),v((a=>p(FI({depositAccountId:e,error:f("Unexpected Error","Fetch deposit Account REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(Fd.match),A((t=>{const{depositAccountId:e}=t.payload,a={start_date:"2022-01-01",end_date:me().format("YYYY-MM-DD")};return r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}/balances/time-series?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>T(n)?p(xF({depositAccountId:e,data:n})):p(qI({depositAccountId:e,fetchState:"Error",error:n.status})))),v((n=>p(qI({depositAccountId:e,fetchState:"Error",error:f("Unexpected Error","Fetch deposit account history REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(YM.match),A((t=>{const{depositAccountId:e}=t.payload,a={deposit_account_id:e};return r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/limits?query=${JSON.stringify(a)}`).pipe(y((n=>T(n)?p(kv(n.data?.deposit_accounts??[]),Yc({depositAccountId:e,fetchState:"Completed",error:void 0})):p(Yc({depositAccountId:e,fetchState:"Error",error:n.status})))),v((n=>p(Yc({depositAccountId:e,fetchState:"Error",error:f("Unexpected Error","Fetch deposit Accounts Limit For Card Detail REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(ke.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts?query=${encodeURIComponent('{"is_include_deposit_accounts_summary":true}')}`).pipe(y((t=>{if(T(t)){const e=t.data?.deposit_accounts??[];return p(Qe(e),kF({summaryPayload:t.data?.all_deposit_accounts_summary}),Qt({data:e,updateType:"replace"}))}return p(jI({fetchState:"Error",error:t.status}))})),v((t=>p(jI({fetchState:"Error",error:f("Unexpected Error","Fetch deposit Accounts REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(bn.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/limits`).pipe(y((t=>T(t)?p(JV(t.data?.deposit_accounts??[]),kv(t.data?.deposit_accounts??[])):p(Hv({fetchState:"Error",error:t.status})))),v((t=>p(Hv({fetchState:"Error",error:f("Unexpected Error","Fetch deposit Accounts For Cards REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(xn.match),y((t=>{const{depositAccountId:e,cacheOverride:a,count:n}=t.payload,o=i.value,c=X(o.depositAccountTransactionListState.byDepositId,e,void 0);if(a===!0||c==null||c.fetchState!=="Completed"||c.transactions.length<6&&n==null){let d={start_date:"2022-01-01",end_date:"2030-12-31"};return n!=null&&(d={...d,limit:n}),r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}/transactions?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>T(l)?p(DF(l.data?.deposit_account.transactions??[]),BF({transactionList:l.data?.deposit_account.transactions??[],depositName:l.data?.deposit_account.deposit_account_name??"",depositAccountId:e})):p(GI({depositAccountId:e,error:l.status})))),v((l=>p(GI({depositAccountId:e,error:f("Unexpected Error","Fetch deposit Account transactions REST API call errored out"+JSON.stringify(l))})))))}return _([])}))),(s,i,r)=>s.pipe(S(j$.match),y((t=>{const{scheduleType:e,downloadCategories:a,statusFilter:n}=t.payload,o=i.value.scheduleListState;let c;if(e!=="accrued_expenses"&&(c=nc(o,e)),c==null)return _([]);const d=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedTimeframe:c.selectedTimeframe,l=t.payload.timeframeAndCategory.selectedCategoryId,u=ua(d),m=ln(l,d),h=c.jeScheduleKeysByListKey[m];if(h!=null&&h.fetchState==="Completed")return _([]);const g={start_date:ae(u.start),end_date:ae(u.end),je_schedule_type:e,base_txn_account_ids:a,sort_by:"transaction_date",sort_order:"desc",filter:n};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/download?query=${encodeURIComponent(JSON.stringify(g))}`).pipe(y((I=>{if(T(I)&&I.data!=null){const b=[ut(I.data.je_schedules),St(I.data.je_schedules,I.data.scheduled_journal_entries),G$(e,d,l,I.data.je_schedules)];return _(b)}return p(of(e,d,l,I.status))})),v((I=>p(of(e,d,l,f("Unexpected Error","Schedule Download REST API call errored out"+JSON.stringify(I)))))))}))),(s,i,r)=>s.pipe(S(_c.match),A((t=>{const{invoiceId:e,recipientTotalAmount:a,vendorName:n,vendorId:o}=t.payload,c=i.value,d=Oe(c.vendorState,o),l={sort_order:"desc",sort_by:"transaction_date",transaction_type:"bill",bill_pay_provider:"zeni",is_include_attachment:!0,limit:3,entity_type:"vendor",entity_name:n,entity_id:d?.qboId??"",recipient_total_amount:a,...!!e&&{document_id:e}};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions?query=${encodeURIComponent(JSON.stringify(l))}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[];return m.push(gc(u.data.transactions)),m.push(LR({transactions:u.data.transactions,transactionId:t.payload.transactionId})),_(m)}return p(Mf({transactionId:t.payload.transactionId,status:u.status}))})),v((u=>p(Mf({transactionId:t.payload.transactionId,status:f("Unexpected error","Duplicate Bill Pay Rest API errored out"+JSON.stringify(u))})))))}))),(s,i,r)=>s.pipe(S(Id.match),A((t=>{const{reimbursementId:e,signedInUserId:a,isManuallyTriggered:n}=t.payload,{editRemiDetailViewState:o,reimbursementState:c}=i.value;let d=[];const l=e!=null?c.reimbursementById[e]?.createdBy:a;n===!0?d=e!=null?Object.values(o.editRemiStateById[e].remiDetailLocalData.updatesByLineId).filter((m=>m!=null)):Object.values(o.newRemiState.remiDetailLocalData.updatesByLineId).filter((m=>m!=null)):e!=null&&(d=(c.reimbursementById[e]?.lines??[]).map((m=>m.type==="mileage"?(h=>({type:h.type,fileId:h.fileId,lineId:h.lineId,homeCurrencyConversions:h.homeCurrencyConversions,mileage:{description:h.description,lineDetail:h.lineDetail,transactionDate:h.transactionDate,amount:h.amount,currencyCode:h.currencyCode,currencySymbol:h.currencySymbol,distanceMileage:h?.distanceMileage},outOfPocket:{recommendations:[],isCategoryFirstTimeAutofilled:!1,isCategoryUpdateSelected:!1,isRetainedCategorySelected:!1}}))(m):(h=>({type:h.type,fileId:h.fileId,lineId:h.lineId,homeCurrencyConversions:h.homeCurrencyConversions,mileage:{},outOfPocket:{merchant:h?.merchant,description:h.description,lineDetail:h.lineDetail,transactionDate:h.transactionDate,amount:h.amount,currencyCode:h.currencyCode,currencySymbol:h.currencySymbol,recommendations:[],isCategoryFirstTimeAutofilled:!1,isCategoryUpdateSelected:!1,isRetainedCategorySelected:!1}}))(m))));const u={reimbursement_provider:"zeni",transaction_type:"reimbursement",created_by_user_id:l,transaction_id:e??null,lines:d.map(pI)};return r.postAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/duplicates`,u).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[];return h.push(ML({duplicateLinesPayload:m.data.lines})),_(h)}return p(hI({status:m.status}))})),v((m=>p(hI({status:f("Unexpected error","Duplicate Reimbursement Rest API errored out"+JSON.stringify(m))})))))}))),(s,i)=>s.pipe(S(s1.match),y((r=>{const{cacheOverride:t,billId:e,isShowDeletedBillsEnabled:a,hasZeniAssistAccess:n,isInternationalWireEnabled:o}=r.payload,c=[],d=i.value,{tenantState:l,companyState:u}=d,{currentTenantId:m}=l,h=m!=null?l.tenantsById?.[m]?.companyId:void 0,g=Te(u,h??""),I=g?.company.companyZeniAccountInfo.isZeniAccountEnabled??!1;if(t)c.push(be("billPayAccountList",!0,!0,!0)),c.push(se(!0)),c.push(He()),c.push(ct()),c.push(Fr(o)),I&&c.push(ke()),c.push(Ge()),e!=null?c.push(Ec(e,!0,a,n)):c.push(Ac(!0));else{d.ownerListState.fetchState!=="In-Progress"&&d.ownerListState.hasValidState()===!1&&c.push(ct());const b=d.accountListState.byReportId.billPayAccountList;b.hasValidState()===!1&&b.fetchState!=="In-Progress"&&c.push(be("billPayAccountList",!0,!0,!0)),d.classListState.fetchState!=="In-Progress"&&c.push(se(!0)),d.vendorTypeListState.hasValidState()===!1&&d.vendorTypeListState.fetchState!=="In-Progress"&&c.push(He());const E=d.billPayConfigState.fetchState;E!=="Completed"&&E!=="In-Progress"&&c.push(Fr(o));const P=d.depositAccountListState;I&&P.fetchState!=="In-Progress"&&P.fetchState!=="Completed"&&c.push(ke());const O=d.paymentAccountListState;O.fetchState!=="In-Progress"&&O.fetchState!=="Completed"&&c.push(Ge()),e!=null&&c.push(Ec(e,!1,a,n))}return j(_(c))}))),(s,i)=>s.pipe(S(bL.match),y((r=>{const{cacheOverride:t,isLimitedCategoryEnabled:e,reimbursementId:a,isShowDeletedReimbursementEnabled:n}=r.payload,o=[],c=i.value,d=c.tenantState.loggedInUser?.userId??"";if(t)o.push(be("reimbursementAccountList",!0,!0,!0,e,[],!0)),o.push(se(!0)),o.push(ld()),o.push(ja()),o.push(yd(d,a)),a!=null&&o.push(_d(a,!0,n));else{c.accountListState.byReportId.reimbursementAccountList.fetchState!=="In-Progress"&&o.push(be("reimbursementAccountList",!0,!0,!0,e,[],!0)),c.classListState.fetchState!=="In-Progress"&&o.push(se(!0));const l=c.merchantListState;l.hasValidState()===!1&&l.fetchState!=="In-Progress"&&o.push(ld());const u=c.reimbursementConfigState.fetchState;u!=="Completed"&&u!=="In-Progress"&&o.push(ja());const m=c.userFinancialAccountState.financialAccountByUserId[d];if(m==null||m.hasValidState()===!1&&m.fetchState!=="In-Progress")o.push(yd(d,a));else if(a==null){const h=EL(c,d);o.push(rr({bankAccountId:h,shouldOverWriteCurrentBankAccountId:!1}))}a!=null&&o.push(_d(a,!1,n))}return j(_(o))}))),(s,i,r)=>s.pipe(S(Df.match),y((t=>{const{billId:e,cacheOverride:a}=t.payload,n=Ne(e),o=i.value,c=X(o.billDetailViewState.billDetailById,n,void 0);return a==1||c==null||c.zeniAssist.eligibleActionsFetchStatus.fetchState!=="In-Progress"?r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}/eligible-actions`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[DR(e,d.data.is_refund_eligible??void 0,d.data.is_retry_eligible.is_ibt_retry_eligible??void 0,d.data.is_retry_eligible.is_obp_retry_eligible??void 0)];return _(l)}return p(Jf(t.payload.billId,d.status))})),v((d=>(console.error(`Fetch eligible actions REST API call errored out ${d}`),p(Jf(t.payload.billId,f("Unexpected Error",`Fetch eligible actions REST API call errored out ${d}`))))))):_([])}))),$G,(s,i,r)=>s.pipe(S(yn.match),y((t=>{const{entityId:e,entityType:a,cacheOverride:n}=t.payload,o=FV(e,a),c=[],d=i.value,l=X(d.commonHistoryState.historyById,o,void 0);if(n===!0||l==null||l.fetchState!=="In-Progress"){c.push(dd({entityId:e,entityType:a,fetchState:"In-Progress"}));const u=a==="bill_pay"?"bill":a,m=r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/${u}s/transactions/${e}/history`).pipe(y((h=>T(h)&&h.data!=null?p(qV({entityId:e,entityType:a,historicEventsPayload:h.data.activities,keepTimeInUTC:a==="bill_pay"})):p(dd({entityId:e,entityType:a,fetchState:"Error",error:h.status})))),v((h=>(console.error(`REST API call errored out ${h}`),p(dd({entityId:e,entityType:a,fetchState:"Error",error:f("Unexpected Error",`REST API call errored out ${h}`)}))))));return j(_(c),m)}return _(c)}))),(s,i,r)=>s.pipe(S(yw.match),A((t=>{const{entity:e,amount:a,transactionDetails:n,isBulkFetch:o,isTransactionCategorizationFlow:c,isFetchCOT:d}=t.payload,{expenseAutomationTransactionsViewState:{selectedTransactionCategorizationTab:l}}=i.value,u={amount:a,transaction_id:Ig(n.transactionId.id),transaction_type:n.transaction.type,line_ids:n.lineIds};d===!0&&(u.include_cot=!0);const m={entity_name:e.name,entity_type:e.type},h=e.qboId===e.name?`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(m))}`:`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/${e0(e.type)}/${e.qboId}/recommendations?query=${encodeURIComponent(JSON.stringify(u))}`;return r.getJSON(h).pipe(y((g=>{if(T(g)&&g.data!=null){const I=[],{transactionId:b,transaction:E,lineIds:P}=n,O=XE(g.data.recommendations,P),C=Hr(g.data.recommendations),U=d===!0&&O!=null?bg(E,O):Vs(E);if(I.push(wr({entityId:e.id,entityType:e.type,recommendations:C})),o===!0&&I.push($r(b,"Completed")),O!=null){const B=pa(i.value.accountState,i.value.accountListState,"accountList");c===!0?I.push(Eg(l,b,U,P,e,a,O,B,pt(i.value))):I.push(Pg(b,U,P,e,a,O,B))}return _(I)}return p($a({entityId:e.id,entityType:e.type,status:g.status}))})),v((g=>p($a({entityId:e.id,entityType:e.type,status:f("Unexpected Error","Fetch recommendation by Entity QBO Id REST API call errored out"+JSON.stringify(g))})))))}))),(s,i,r)=>s.pipe(S(_w.match),ar((t=>{return e=t.payload.flowType,a=t.payload.transactionDetails.transactionId.id,n=t.payload.transactionDetails.lineIds,`${e}\0${a}\0${[...n].sort(((o,c)=>o.localeCompare(c))).join("\0")}`;var e,a,n}),void 0,(t=>t.pipe(hw((()=>Ha(6e4)))))),y((t=>t.pipe(A((e=>{const a=e.payload,{transactionId:n,transaction:o,lineIds:c}=a.transactionDetails,{entity:d,amount:l,isFetchCOT:u}=a,m=a.flowType==="detail"&&a.isBulkFetch===!0,h=(E,P)=>m&&P!=null?p(E,P):p(E),g=a.flowType==="categorization"?Sw(a.selectedTab,n,c):gw(n,c),I=((E,P,O,C,U)=>{const B={entity_name:P.name,entity_type:P.type};if(P.qboId===P.name)return`${E}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(B))}`;const x={amount:O,transaction_id:Ig(C.transactionId.id),transaction_type:C.transaction.type,line_ids:C.lineIds};return U===!0&&(x.include_cot=!0),`${E}/1.0/${k=P.type,`${k}s`}/${P.qboId}/recommendations?query=${encodeURIComponent(JSON.stringify(x))}`;var k})(r.apiEndPoints.accountMicroServiceBaseUrl,d,l,a.transactionDetails,u===!0),b=r.getJSON(I).pipe(y((E=>{if(!T(E)||E.data==null)return h(a.flowType==="categorization"?Tg(a.selectedTab,n,c,E.status):Ag(n,c,E.status),m?$r(n,"Error",E.status):void 0);const P=XE(E.data.recommendations,c);if(P==null)return h(a.flowType==="categorization"?fw(a.selectedTab,n,c):vw(n,c),m?$r(n,"Completed"):void 0);const O=u===!0?bg(o,P):Vs(o),C=pa(i.value.accountState,i.value.accountListState,"accountList");return a.flowType==="categorization"?p(Eg(a.selectedTab,n,O,c,d,l,P,C,pt(i.value))):h(Pg(n,O,c,d,l,P,C),m?$r(n,"Completed"):void 0)})),v((E=>{const P="fetchEntityRecommendationsForLineUpdate failed: "+(E instanceof Error?E.message:JSON.stringify(E)),O=f("Unexpected Error",P);return h(a.flowType==="categorization"?Tg(a.selectedTab,n,c,O):Ag(n,c,O),m?$r(n,"Error",O):void 0)})));return j(p(g),b)})))))),RG,(s,i,r)=>s.pipe(S(ks.match),y((t=>{const{expenseAutomationFluxAnalysisViewState:{groupsBySelectedPeriod:e,uiState:a}}=i.value,{monthAndYear:n,cacheOverride:o,pageToken:c,fetchReimbursement:d,keepExistingListItems:l}=t.payload,u=e[Ee(n)],m=d===!0?u?.reimbursement:u?.generalExpense,h=m?.operatingExpenseIds??[],g=m?.fetchStatus?.fetchState??"Not-Started";if(o===!0||m==null||h.length===0||g==="Not-Started"){const I={month_and_year:`${n.month<10?`0${n.month}`:n.month}-${n.year}`,sort_by:PC(a.sortKey),sort_order:Vo(a.sortOrder),page_token:c,reimbursement_flag:d};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/month-close/flux-analysis?query=${encodeURIComponent(JSON.stringify(I))}`).pipe(y((b=>{if(T(b)&&b.data!=null){const E=[];return E.push(W(b.data.accounts,"account_list")),E.push(Ke("class_list",b.data.accounting_class)),E.push(le(b.data.vendors,"merge")),E.push(V({users:b.data.users,updateType:"merge"})),E.push(TC({fetchReimbursement:d,pageMetaData:b.data.page_metadata})),b.data.flux_analysis_entities?.operating_expenses!=null&&E.push(AC({expensesPayload:b.data.flux_analysis_entities?.operating_expenses,totalsPayload:b.data.total_operating_expenses,currency:b.data.currency,selectedPeriod:n,fetchReimbursement:d,keepExistingListItems:l,status:b.data?.status})),_(E)}return p(dy({fetchReimbursement:d,status:b.status,selectedPeriod:n}))})),v((b=>p(dy({fetchReimbursement:d,status:f("Unexpected Error",`fetch flux analysis view REST API call errored out: ${JSON.stringify(b)}`),selectedPeriod:n})))))}return _([])}))),(s,i)=>s.pipe(S(mi.match),y((r=>{const{transactionIds:t,selectedPeriod:e,keepExistingListItems:a,selectedTab:n,pageToken:o,totalCount:c,lineItemsByTransactionIds:d,refreshViewInBackground:l}=r.payload,u=[],{transactionState:m,expenseAutomationTransactionsViewState:h}=i.value,{transactionReviewLocalDataById:g}=h.transactionCategorizationView[n],I=a===!0?{...g}:{};return qy(m,t).forEach((b=>{const E=Vs(b),P=Mx(E,n,d[b.id]);I[b.id]==null?I[b.id]={...Vx,transactionId:b.id,transactionReviewLocalData:{...P,sortedLineItems:b.lines?.map((O=>O.id))??[]}}:I[b.id]={transactionId:b.id,transactionReviewLocalData:{...I[b.id].transactionReviewLocalData,...P,lineItemById:{...Kz(I[b.id].transactionReviewLocalData.lineItemById,P.lineItemById)},sortedLineItems:[...new Set(I[b.id].transactionReviewLocalData.sortedLineItems.concat(P.sortedLineItems))],tabSpecificLineItems:Lx(I[b.id].transactionReviewLocalData.tabSpecificLineItems,n,P.tabSpecificLineItems)}}})),u.push(Fx({selectedTab:n,transactionIds:t,selectedPeriod:e,keepExistingListItems:a,transactionLocalData:I,pageToken:o,totalCount:c,refreshViewInBackground:l})),_(u)}))),(s,i,r)=>s.pipe(S(Qa.match),y((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a}}=e,{period:n,refreshViewInBackground:o}=t.payload,c=a[H(e).tenantId],d=t.payload.selectedPageTab??e.expenseAutomationJESchedulesViewState.uiState.selectedPageTab,l=d==="schedules",u=ge(ee(ae(n.start)).subtract(1,"month").endOf("month").format(re)),m=ae(l||u==null?n.end:u),h=ee(m),g=h.subtract(24,"month").startOf("month").format(re),I=h.subtract(12,"month").startOf("month").format(Zn),b={base_transaction_end_date:m,end_date:m,accrued_start_date:g,accrued_end_date:m,include_accrued:!0,...l?{base_transaction_start_date:ae(n.start),close_period_start_date:ae(n.start),one_time_accrual_service_month:ee(ae(n.start)).format(Zn),one_time_accrual_statuses:[],filter_failed_je_postings_by_date:!0}:{one_time_accrual_service_month_start:I,one_time_accrual_service_month_end:h.format(Zn),one_time_accrual_statuses:["posted"],filter_failed_je_postings_by_date:!1}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expenses_automation/je_schedules?query=${encodeURIComponent(JSON.stringify(b))}`).pipe(y((E=>{if(T(E)&&E.data!=null){const P=[],O=E.data.accrued_je_schedules?.je_schedules??[],C=E.data.one_time_accruals??[];return P.push(ut([...E.data.je_schedules,...E.data.failed_je_postings.je_schedules]),St([...E.data.failed_je_postings.je_schedules],E.data.failed_je_postings.scheduled_journal_entries),hy([...E.data.failed_je_postings.je_schedules])),O.length>0&&P.push(ca(O),br(O,E.data.accrued_je_schedules?.scheduled_journal_entries)),C.length>0&&P.push(Ta(C)),P.push(wC({jeSchedules:[...E.data.je_schedules],failedJeSchedules:[...E.data.failed_je_postings.je_schedules],accruedJeSchedules:O,oneTimeAccruals:C,selectedPeriod:c,selectedPageTab:d,refreshViewInBackground:o})),_(P)}return p(Sy({status:E.status,selectedPeriod:c,selectedPageTab:d}))})),v((E=>p(Sy({status:f("Unexpected Error","fetch JE schedules REST API call errored out"+JSON.stringify(E)),selectedPeriod:c,selectedPageTab:d})))),De(s.pipe(S(gt.match))))}))),(s,i)=>s.pipe(S(Pa.match),y((r=>{const t=[],{period:e,refreshViewInBackground:a}=r.payload,n=Ir();return i.value.accountListState.byReportId[n.accountListKey].fetchState==="Not-Started"&&t.push(be(n.accountListKey,!0,!1,!1,!1,n.allowedAccountList)),t.push(Qa(e,a)),i.value.expenseAutomationJESchedulesViewState.accountSettings.hasLoadedAccountSettings||t.push(_y()),j(_(t))}))),(s,i,r)=>s.pipe(S(jy.match),y((t=>{const{expenseAutomationViewState:e,expenseAutomationTransactionsViewState:a}=i.value,{transactionsInReview:n,selectedTab:o}=t.payload,c=n.transactions_update_success,d=n.transactions_update_failed,l=H(i.value),u=e.selectedPeriodByTenantId[l.tenantId],m=o==="review"?"autoCategorized":"review",h=a.transactionCategorizationView[o],g=a.transactionCategorizationView[m],{uiState:I}=h,b=d.map((P=>P.transaction_id)),E=[];return d.length>0&&c.length===0&&E.push(N(Gy(c.length,d.length,0))),c.length>0?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/mark-as-reviewed`,{transactions_reviewed:c}).pipe(y((P=>{if(T(P)&&P.data!=null){const O=P.data.transactions_reviewed_success,C=P.data.transactions_reviewed_failed,U={},B={};O.forEach((w=>{U[w.transaction_id]=w.line_ids})),C.forEach((w=>{B[w.transaction_id]=w.line_ids}));const x=[...new Set([...Object.keys(U),...Object.keys(B)])],k=x.filter((w=>!(w in B))),J=[],L=[],R={};x.forEach((w=>{const K=U[w]??[],G=B[w]??[],Z=h.transactionReviewLocalDataById[w]?.transactionReviewLocalData.tabSpecificLineItems[o]??[],de=(g.transactionReviewLocalDataById[w]?.transactionReviewLocalData.tabSpecificLineItems[m]??[]).length>0,ue=Z.filter((te=>{const ye=K.includes(te),_e=G.includes(te);return o==="review"?!ye||_e:!ye&&!_e}));ue.length>0?R[w]=ue:(R[w]=[],L.push(w),de||J.push(w))}));const q=[...b],$=I.totalCount[Ee(u)],D=L.length===0?$:$-L.length;if(E.push(Ls(o,x,L,u,"Completed",void 0,R)),J.length>0&&E.push(zy({transactionIds:J})),o==="autoCategorized"&&Object.keys(B).length>0){const w=Re(u),K=ge(w.start),G=ge(w.end);K!=null&&G!=null&&E.push(fr("review",{start:K,end:G},!0,!1,void 0,void 0,!0,!1))}return E.push($s({selectedPeriod:u,selectedTab:o,totalCount:D})),E.push(N(Gy(c.length-k.length,q.length,k.length))),l!=null&&E.push(et({tenantId:l.tenantId,period:u,refreshViewInBackground:!0})),_(E)}return p(Ls(t.payload.selectedTab,[],[],u,"Error",P.status))})),v((P=>p(Ls(t.payload.selectedTab,[],[],u,"Error",f("Unexpected Error",`Transaction mark miscategorized as correct REST API call errored out ${JSON.stringify(P)}`)))))):_(E)}))),(s,i,r)=>s.pipe(S(vr.match),A((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a},expenseAutomationMissingReceiptsViewState:{transactionIdsBySelectedPeriod:n,fetchState:o}}=e,{period:c,cacheOverride:d,minimumTransactionAmount:l}=t.payload,u=a[H(e).tenantId],m=n[Ee(u)]??[];if(d===!0||m.length===0||o==="Not-Started"){const h={start_date:ae(c.start),end_date:ae(c.end),total_amount_min:l.amount,is_attachment_missing_only:!0,sort_by:"transaction_date",sort_order:"desc"};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions?query=${encodeURIComponent(JSON.stringify(h))}`).pipe(y((g=>{if(T(g)&&g.data!=null){const I=[];return I.push(Ce(g.data.transactions,(b=>b.transaction_id))),I.push(Ix({transactionsPayload:g.data.transactions,selectedPeriod:u})),_(I)}return p(Dy({status:g.status,selectedPeriod:u}))})),v((g=>p(Dy({status:f("Unexpected Error","fetch missing receipts REST API call errored out"+JSON.stringify(g)),selectedPeriod:u})))))}return _([])}))),(s,i,r)=>s.pipe(S(Rt.match),y((t=>{const{accountId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,o=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:c},expenseAutomationReconciliationViewState:{accountReconciliationRecordsBySelectedPeriod:d}}=o,l=c[H(o).tenantId];let u,m,h;if(e!=null&&(u=Ea(o,e,l),m=u?.reconciliationId),h=e!=null?d[Ee(l)].reconciliationByAccountID[e].transactionFetchState.fetchState:o.expenseAutomationReconciliationViewState.fetchState,a===!0||h!=="Completed"){const{start:g,end:I}=Re(l,!0),b={};m==null&&(b.start_date=g.toString(),b.end_date=I.toString(),e!=null&&(b.account_id=e)),a===!0&&e!=null&&(b.is_force_refresh=!0);const E=m!=null?`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/${m}?query=${encodeURIComponent(JSON.stringify(b))}`:`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation?query=${encodeURIComponent(JSON.stringify(b))}`;return r.getJSON(E).pipe(y((P=>{if(T(P)&&P.data!=null){const O=[],C=Ym(P.data.reconciliation);O.push(W(P.data.accounts,"account_reconciliation"),W(P.data.excluded_accounts??[],"excluded_account_reconciliation"),V({users:P.data.users??[],updateType:"merge"}),ve({files:P.data.files??[]}),Xo(C,"merge"),ei(l,P.data.reconciliation,e==null));const U=Bz(P.data.reconciliation[0]?.transactions?.review??[]);if(e!=null){const B=CE(P.data.reconciliation[0].transactions.reconcile);O.push(gr({selectedTransactionIds:B}),Wm(U))}return O.push(ZO(l,P.data,n,e)),_(O)}return p(Zm({error:P.status,selectedPeriod:l,refreshViewInBackground:n,accountId:e}))})),v((P=>p(Zm({error:f("Unexpected Error",`fetch reconciliation view REST API call errored out ${JSON.stringify(P)}`),refreshViewInBackground:n,selectedPeriod:l,accountId:e})))))}{const g=[];return e!=null&&g.push(Xm()),_(g)}}))),(s,i)=>s.pipe(S(jx.match),y((r=>{const{transactionIds:t,cotTrackingByTransactionId:e,selectedTab:a}=r.payload,n=[],{transactionState:o,expenseAutomationTransactionsViewState:c}=i.value,d=[];return qy(o,t).forEach((l=>{const u=X(c.transactionCategorizationView[a].transactionReviewLocalDataById,l.id,void 0),m=pa(i.value.accountState,i.value.accountListState,"accountList"),h=u?.transactionReviewLocalData;h!=null&&d.push(Qz(h,l,m))})),n.push(Ky(a,t,d,e)),_(n)}))),(s,i,r)=>s.pipe(S(Rs.match),ar((t=>t.payload.selectedTab)),y((t=>t.pipe(A((e=>{const{expenseAutomationViewState:{selectedPeriodByTenantId:a},expenseAutomationTransactionsViewState:n}=i.value,{period:o,keepExistingListItems:c,selectedTab:d,refreshViewInBackground:l}=e.payload,u=n.transactionCategorizationView[d].uiState,{pageToken:m,sortOrder:h,sortKey:g}=u,I=u.searchString,b=a[H(i.value).tenantId],E={start_date:ae(o.start),end_date:ae(o.end),auto_categorized:d==="autoCategorized",sort_by:ui(g),sort_order:h==="ascending"?"asc":"desc",page_token:m,page_size:25,search_text:u.searchString,search_all_statuses:!1,sub_tab:d==="autoCategorized"?n.selectedTransactionCategorizationCompletedSubTab:li,transaction_group:n.selectedTransactionGroup};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(E))}`).pipe(y((P=>{if(i.value.expenseAutomationTransactionsViewState.transactionCategorizationView[d].uiState.searchString!==I)return F;if(T(P)&&P.data!=null){const O=[];O.push(Ce(P.data.transactions,(B=>B.transaction_id),"merge"));const C=P.data.transactions.map((B=>B.transaction_id)),U=Vy(P.data.transactions);return O.push(Ly({selectedTab:d,uiState:{pageToken:P.data.next_page_token??null}})),O.push(mi(d,C,b,c,P.data.next_page_token??null,P.data.total_count,U,l)),O.push($s({selectedPeriod:b,selectedTab:d,totalCount:P.data.total_count})),O.push($x({selectedPeriod:b,selectedTab:d,parentTotalCount:P.data.parent_tab_total_count??P.data.total_count})),O.push(Rx({refreshViewInBackground:l,tabs:yi.filter((B=>d!==B))})),O.push(Fy({refreshViewInBackground:l,selectedTab:d,status:P.status})),_(O)}return p(ws({selectedPeriod:b,selectedTab:d,status:P.status}))})),v((P=>i.value.expenseAutomationTransactionsViewState.transactionCategorizationView[d].uiState.searchString!==I?F:p(ws({selectedPeriod:b,selectedTab:d,status:f("Unexpected Error","fetch Transaction Categorization REST API call errored out"+JSON.stringify(P))})))))})))))),(s,i)=>s.pipe(S(fr.match),y((r=>{const{selectedTab:t,cacheOverride:e,keepExistingListItems:a,pageToken:n,period:o,refreshViewInBackground:c,searchString:d,resetListItems:l}=r.payload,u=[],{expenseAutomationTransactionsViewState:m}=i.value,{fetchState:h,transactionIdsBySelectedPeriod:g,uiState:I}=m.transactionCategorizationView[t],b={month:o.start.month,year:o.start.year},E=g[Ee(b)]??[],P=i.value.accountListState.byReportId.accountList;P.hasValidState()===!1&&P.fetchState==="Not-Started"&&u.push(be("accountList",!0));const O=i.value.classListState;O.hasValidState()===!1&&O.fetchState==="Not-Started"&&u.push(se());const C=i.value.projectListState;Ms(i.value)&&C.hasValidState()===!1&&C.fetchState==="Not-Started"&&u.push(_i());const U=i.value.ownerListState;return U.hasValidState()===!1&&U.fetchState==="Not-Started"&&u.push(ct()),d!==""&&e!==!0&&h!=="Not-Started"&&E.length!==0&&I.searchString===""||u.push(Rs(t,o,e,a,d,n,c,l)),d===void 0&&yi.filter((B=>B!==t)).forEach((B=>{m.transactionCategorizationView[B].fetchState==="Not-Started"&&u.push(Rs(B,o,!1,!1,void 0,void 0,!0,void 0))})),d!==void 0&&yi.filter((B=>B!==t)).forEach((B=>{const x=m.transactionCategorizationView[B].uiState.searchString;d!==x&&u.push(Rs(B,o,!0,a,d,void 0,!0,!0))})),_(u)}))),(s,i,r)=>s.pipe(S(Ky.match),y((t=>{const{selectedTab:e,transactionIds:a,transactionSaveUpdates:n,cotTrackingByTransactionId:o}=t.payload,{transactionState:c,vendorState:d,expenseAutomationTransactionsViewState:l}=i.value,u=(function(m,h,g,I,b,E,P){const O=[];return b.forEach((C=>{const U=E.find((B=>B.transactionId===C));if(U!=null){const B=(function(x,k,J,L,R,q,$){const D=At(k,R),w=X(L.transactionCategorizationView[x].transactionReviewLocalDataById,R,void 0),K=w?.transactionReviewLocalData?.vendorUpdates,G=w?.transactionReviewLocalData?.customerUpdates,Z=w?.transactionReviewLocalData?.selectedEntity;let de;if(K?.qboId!=null&&Z!=null&&Z.type==="vendor"){const te=Oe(J,K.qboId)??K;de={id:te.qboId===te.name?"":te.qboId??"",name:te.name}}let ue;if(Z!=null&&Z.type==="customer"&&(ue=G?.qboId!=null?{id:G.qboId,name:G.name}:{id:Z.id,name:Z.name}),D!=null){const te=Xz(q.updates,D,R,$,de,ue,Z);return{entity_related_updates:eK(q.entityRelatedUpdates),transaction_id:R,transaction:te,transaction_type:Py(D.type)}}})(m,h,g,I,C,U,P);B!=null&&O.push(B)}})),O??[]})(e,c,d,l,a,n,o).filter((m=>m!=null));return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions/categorize`,{transactions:u}).pipe(y((m=>{if(T(m)&&m.data!=null){const h=m.data,g=[];return g.push(jy(e,h),hi(e,"Completed",f("Completed","Transaction categorization updated successfully"))),_(g)}return p(hi(e,"Error",m.status))})),v((m=>p(hi(e,"Error",f("Unexpected Error",`REST API call errored out ${JSON.stringify(m)}`))))))}))),(s,i,r)=>s.pipe(S(sE.match),y((t=>{const{vendorId:e,vendorName:a,vendorZeniId:n}=t.payload,o={entity_id:e,entity_type:"vendor",vendor_id:e,vendor_name:a},c=r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/spend_trend?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((d=>T(d)?_(gY({id:e,name:a,zeniId:n},d)):p(Jn(t.payload.vendorId,d.status)))),v((d=>p(Jn(t.payload.vendorId,f("Unexpected Error","Spend Trend REST API call errored out"+JSON.stringify(d)))))));return j(c)}))),(s,i)=>s.pipe(S(JF.match),y((r=>{const{cacheOverride:t}=r.payload,e=i.value,a=[];if(t===!0)a.push(He()),a.push(Xt()),a.push(ke()),a.push(zI());else{e.vendorTypeListState.hasValidState()===!1&&e.vendorTypeListState.fetchState!=="In-Progress"&&a.push(He());const n=e.zeniAccountsConfigState;n.hasValidState()===!1&&n.fetchState!=="In-Progress"&&a.push(Xt());const o=e.depositAccountListState;o.fetchState!=="In-Progress"&&o.fetchState!=="Completed"&&a.push(ke()),a.push(zI())}return j(_(a))}))),MG,(s,i,r)=>s.pipe(S(tU.match),A((t=>{const{fileId:e,tenantId:a}=t.payload;return(a!=null?r.getJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}?query=${encodeURIComponent(JSON.stringify({is_dummy_response:!1,download_file:!1}))}`,Object.assign({"zeni-tenant-id":a})):r.getJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}?query=${encodeURIComponent(JSON.stringify({is_dummy_response:!1,download_file:!1}))}`)).pipe(y((n=>T(n)?p(ve({files:n.data?.files??[]}),aU({fileId:e})):p(Xy({status:n.status})))),v((n=>p(Xy({status:f("Unexpected Error","Fetch File REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(e_.match),A((t=>{const{fileIds:e,tenantId:a}=t.payload;return(a!=null?r.getJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files?query=${encodeURIComponent(JSON.stringify({file_ids:e}))}`,Object.assign({"zeni-tenant-id":a})):r.getJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files?query=${encodeURIComponent(JSON.stringify({file_ids:e}))}`)).pipe(y((n=>T(n)?p(ve({files:n.data?.files??[]}),rU({fileIds:e})):p(t_({status:n.status})))),v((n=>p(t_({status:f("Unexpected Error","Fetch File List REST API call errored out"+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(iU.match),A((r=>{const{userId:t,fetchSelectedTab:e,fetchFullReport:a,cacheOverride:n}=r.payload,o=i.value;if(n===!0)return p(Ia(t),Si(),ho(),To());{const{tenantState:c,financeStatementState:d}=o,l=[];c.fetchState==="In-Progress"||c.hasValidState()||l.push(Ia(t));const u=cU(void 0,o.profitAndLossState),m=dU(o.balanceSheetState),h=lU(o.cashFlowState);if(e)switch(d.selectedReportId){case"profit_and_loss":case"profit_and_loss_by_classes":u.fetchStateByTimeframe[d.timeframe].fetchState!=="In-Progress"&&u.fetchStateByTimeframe[d.timeframe].fetchState!=="Completed"&&l.push(Mt(d.timeframe));break;case"balance_sheet":m.fetchStateByTimeframe[d.timeframe].fetchState!=="In-Progress"&&m.fetchStateByTimeframe[d.timeframe].fetchState!=="Completed"&&l.push(Ot(d.timeframe));break;case"cash_flow":h.fetchStateByTimeframe[d.timeframe].fetchState!=="In-Progress"&&h.fetchStateByTimeframe[d.timeframe].fetchState!=="Completed"&&l.push(Bt(d.timeframe,a))}else u.reducedAllFetchState.fetchState!=="In-Progress"&&u.reducedAllFetchState.fetchState!=="Completed"&&l.push(Si()),m.reducedAllFetchState.fetchState!=="In-Progress"&&m.reducedAllFetchState.fetchState!=="Completed"&&l.push(ho(a)),h.reducedAllFetchState.fetchState!=="In-Progress"&&h.reducedAllFetchState.fetchState!=="Completed"&&l.push(To(a));return _(l)}}))),(s,i,r)=>s.pipe(S(Fs.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/forecasts`).pipe(y((t=>T(t)?p(uU(t.data?.forecasts??[]),qs(t)):p(Nr(t.status)))),v((t=>p(Nr(f("Unexpected Error","Fetch forecast list call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(SU.match),Oa((t=>{const e=i.value.globalMerchantAutoCompleteState.autoCompleteText??"",{globalMerchantType:a}=t.payload,n={search_text:e,entity_type:a};if(e===t.payload.searchString){const{userId:o,sessionId:c}=r,d={"zeni-user-id":o,"zeni-tenant-id":"","zeni-session-id":c};return r.getJSON(`${r.apiEndPoints.searchMicroServiceBaseUrl}/1.0/autocomplete/global_merchant?query=${encodeURIComponent(JSON.stringify(n))}`,d).pipe(Oa((l=>{if(T(l)&&l.data!=null){const u=[];return u.push(It({globalMerchants:l.data.entities,updateType:"merge"})),u.push(gU(l.data)),_(u)}return p(n_(l.status))})),v((l=>p(n_(f("Unexpected Error","Global Merchant Auto Complete REST API call errored out"+JSON.stringify(l)))))))}return _([])}))),(s,i,r)=>s.pipe(S(_U.match),A((t=>{const{newGlobalMerchantData:e}=i.value.globalMerchantViewState,{source:a,merchantName:n}=t.payload,o=a==="tenant"&&n!=null?n:e?.globalMerchantName;if(o!=null){const c={global_merchant_name:o};return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(c))}`).pipe(A((d=>{if(T(d)&&d.data!=null){const{recommendations:l}=d.data,u=Z0(l),m=[It({globalMerchants:u}),hU(l)];return l[0]?.global_merchants.length===0&&m.push(N({messageSection:"fetch_global_merchant_no_recommendation",messageText:"success",type:"info",variables:[{variableName:"_global_merchant_name_",variableValue:o}]})),m}return p(s_({status:d.status}))})),v((d=>p(s_({status:f("Unexpected Error","Fetch Global Merchant Recommendation REST API call errored out"+JSON.stringify(d))})))))}return _([])}))),(s,i,r)=>s.pipe(S(nE.match),y((t=>{const{customerId:e,customerName:a}=t.payload,n={entity_id:e,entity_type:"customer",customer_id:e,customer_name:a},o=r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/income_trend?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((c=>T(c)?_(fY({id:e,name:a},c)):p(Jn(t.payload.customerId,c.status)))),v((c=>p(Jn(t.payload.customerId,f("Unexpected Error","Income Trend REST API call errored out"+JSON.stringify(c)))))));return j(o)}))),(s,i,r)=>s.pipe(S(Yo.match),A((()=>r.getJSON(`${r.apiEndPoints.insightsMicroServiceBaseUrl}/1.0/insights`).pipe(y((t=>T(t)?p(o_(t.data?.insights??[]),fU(t)):p(i_(t.status)))),v((t=>p(i_(f("Unexpected error","Insights Card REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(uv.match),A((t=>{const{currencyCode:e,amount:a,vendorType:n,cacheOverride:o}=t.payload,c=i.value,d=pv(e,a,n),l=c.internationalWireState.dynamicFormDetailsbyKey[d];return o===!0||l==null||o===!1&&l.hasValidState()===!1?r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/account-requirements?target_currency=${e}&target_amount=${JSON.stringify(a)}&vendor_type=${n}`).pipe(y((u=>T(u)&&u.data!=null?_([w1({internationalWireFormPayload:u.data,currencyCode:e,amount:a,vendorType:n}),mv(a,n)]):p(yv({currencyCode:e,amount:a,vendorType:n,error:u.status})))),v((u=>p(yv({currencyCode:e,amount:a,vendorType:n,error:f("Unexpected Error","Fetch Dynamic form REST API call errored out"+JSON.stringify(u))}))))):_([])}))),(s,i,r)=>s.pipe(S(R1.match),A((t=>r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding-fields?query=${encodeURIComponent(JSON.stringify({region:"US",legal_type:"BUSINESS"}))}`).pipe(y((e=>T(e)&&e.data!=null?_([M1({internationalWireFormPayload:e.data.labels}),hv(t.payload.companyId,e.data.labels)]):p(Sv({error:e.status})))),v((e=>p(Sv({error:f("Unexpected Error","Fetch international verification form REST API call errored out"+JSON.stringify(e))})))))))),(s,i,r)=>s.pipe(S(W_.match),A((()=>{const{filters:t}=i.value.invoicingInvoiceListState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search),t.customerId!=null&&e.set("customer_id",t.customerId),t.subscriptionId!=null&&e.set("subscription_id",t.subscriptionId),t.dateFrom!=null&&e.set("date_from",t.dateFrom),t.dateTo!=null&&e.set("date_to",t.dateTo);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(Hk(n.data)):p(Z_(n.status)))),v((n=>p(Z_(f("Unexpected Error","Fetch invoice counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Br.match),A((t=>{const{invoiceId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[z(Or([n.data])),Ca([n.data],"merge"),Gk({invoiceId:n.data.id})]:p(H_({invoiceId:e,status:n.status})))),v((n=>p(H_({invoiceId:e,status:f("Unexpected Error","Fetch invoice detail REST API call errored out "+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(zk.match),Le(i),y((([r,t])=>{const{cacheOverride:e=!1,invoiceId:a}=r.payload,n=[],o=t.invoicingInvoiceDetailState.detailById[a];LE({error:o?.error,fetchState:o?.fetchState??"Not-Started"},e)&&n.push(Br({invoiceId:a}));const c=t.invoicingConfigViewState;return LE({error:c.error,fetchState:c.fetchState},e)&&n.push(Ur()),n.length>0?_(n):F}))),(s,i,r)=>s.pipe(S(X_.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/kpis`;return r.getJSON(t).pipe(A((e=>T(e)&&e.data!=null?p(Qk(Wk(e.data))):p(eh(e.status)))),v((e=>p(eh(f("Unexpected Error","Fetch invoice KPIs REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Ei.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,{activeTab:c}=i.value.invoicingInvoiceListState,d=c!=="all"?c:void 0,l=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices`,((u,m,h,g)=>{const I=new URLSearchParams;return m!=null&&m.length>0&&I.set("status",m),u.customerId!=null&&I.set("customer_id",u.customerId),u.subscriptionId!=null&&I.set("subscription_id",u.subscriptionId),u.search!=null&&u.search.length>0&&I.set("search",u.search),u.dateFrom!=null&&I.set("date_from",u.dateFrom),u.dateTo!=null&&I.set("date_to",u.dateTo),I.set("limit",String(tt)),h!=null&&I.set("cursor",h),at(I,g),I})(e,d,a,o));return r.getJSON(l).pipe(A((u=>{if(T(u)){const m=u.data?.items??[];return[Ca(m,"merge"),z(Or(m)),Zk({invoices:m,nextCursor:u.data?.next_cursor??null,keepExistingListItems:n})]}return p(th(u.status))})),v((u=>p(th(f("Unexpected Error","Fetch invoice list REST API call errored out "+JSON.stringify(u)))))))}))),(s,i)=>s.pipe(S(Xk.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingInvoiceListState,o=n.invoiceByTab[n.activeTab]??eB(),c=[];return xl({fetchState:o.fetchState,error:o.error},t)&&c.push(Ei({filters:e,sort:a})),xl(n.countsFetchState,t)&&c.push(W_()),xl(n.kpisFetchState,t)&&c.push(X_()),j(_(c))}))),(s,i)=>s.pipe(S(N_.match),Le(i),y((([,r])=>{const t=[],e=r.accountListState.byReportId[Mh];(e.hasValidState()&&e.accountIds.length>0)===!1&&e.fetchState!=="In-Progress"&&t.push(be(Mh,!0));const a=r.classListState;return a.hasValidState()===!1&&a.fetchState!=="In-Progress"&&t.push(se()),t.length>0?_(t):F}))),(s,i,r)=>s.pipe(S(vU.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/audit-log`,((d,l,u)=>{const m=new URLSearchParams,h=(g=>{const I={};return g.search!=null&&g.search.length>0&&(I.search=g.search),g.action!=null&&g.action.length>0&&(I.action=g.action),g.dateFrom!=null&&g.dateFrom.length>0&&(I.date_from=g.dateFrom),g.dateTo!=null&&g.dateTo.length>0&&(I.date_to=g.dateTo),I})(d);return Object.keys(h).length>0&&m.set("filter",JSON.stringify(h)),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),u!=null&&aK.has(u.field)&&at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=(d.data?.items??[]).map(IU);return p(bU({items:l,nextCursor:d.data?.next_cursor??null,keepExistingListItems:n}))}return p(c_(d.status))})),v((d=>p(c_(f("Unexpected Error","Fetch audit log REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(ah.match),A((()=>{const{planFilters:t}=i.value.invoicingCatalogListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(tB(n.data)):p(rh(n.status)))),v((n=>p(rh(f("Unexpected Error","Fetch catalog counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(E_.match),A((t=>{const{id:e,kind:a}=t.payload,n=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/plans/${encodeURIComponent(e)}`;return r.getJSON(n).pipe(A((o=>T(o)&&o.data!=null?[xr([o.data],"merge"),P_({id:o.data.id,kind:a})]:p(T_({error:o.status,id:e})))),v((o=>p(T_({error:f("Unexpected Error","Fetch catalog item detail REST API call errored out "+JSON.stringify(o)),id:e})))))}))),(s,i)=>s.pipe(S(XU.match),Le(i),y((([r,t])=>{const{cacheOverride:e=!1,id:a,kind:n}=r.payload,o=[],c=a!=null?t.editInvoicingCatalogItemDetailViewState.recordStateById[a]:void 0;a!=null&&Nl({error:c?.error,fetchState:c?.fetchState??"Not-Started"},e)&&o.push(E_({id:a,kind:n}));const d=t.invoicingConfigViewState;Nl({fetchState:d.fetchState,error:d.error},e)&&o.push(Ur());const l=t.invoicingQboViewState;return Nl(l.connectionFetchState,e)&&o.push(A_()),o.push(N_()),o.length>0?_(o):F}))),(s,i)=>s.pipe(S(aB.match),y((r=>{const{cacheOverride:t,planFilters:e,productFilters:a,planSort:n,productSort:o}=r.payload,c=i.value.invoicingCatalogListViewState,d=[];return Ul({fetchState:c.fetchState,error:c.error},t)&&d.push(Cr({filters:e,sort:n})),Ul(c.productFetchState,t)&&d.push(gi({filters:a,sort:o})),Ul(c.countsFetchState,t)&&d.push(ah()),j(_(d))}))),(s,i,r)=>s.pipe(S(Cr.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/plans`,((d,l,u)=>{const m=new URLSearchParams;return d.status!=null&&d.status.length>0&&m.set("status",d.status),d.type!=null&&d.type.length>0&&m.set("type",d.type),d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[xr(l,"merge"),rB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(sh(d.status))})),v((d=>p(sh(f("Unexpected Error","Fetch catalog plan list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(gi.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/plans`,((d,l,u)=>{const m=new URLSearchParams;return d.type!=null&&d.type.length>0&&m.set("type",d.type),d.status!=null&&d.status.length>0&&m.set("status",d.status),d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[xr(l,"merge"),sB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(nh(d.status))})),v((d=>p(nh(f("Unexpected Error","Fetch catalog product list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(Ur.match),A((t=>{const{isInvoicingTosAccepted:e}=i.value.invoicingConfigViewState;if(!t.payload.cacheOverride&&e!=null)return F;const a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/config`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(Ni(n.data)):p(ch(n.status)))),v((n=>p(ch(f("Unexpected Error","Fetch invoicing config REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(d_.match),A((()=>{const{filters:t}=i.value.invoicingCouponViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/discounts/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(EU(n.data)):p(l_(n.status)))),v((n=>p(l_(f("Unexpected Error","Fetch discount counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(k_.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/discounts/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[Gs([n.data],"merge"),B_({id:n.data.id})]:p(D_({id:e,status:n.status})))),v((n=>p(D_({id:e,status:f("Unexpected Error","Fetch discount detail REST API call errored out "+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(mk.match),Le(i),y((([r,t])=>{const{cacheOverride:e=!1,id:a}=r.payload,n=[],o=a!=null?t.editInvoicingCouponDetailViewState.recordStateById[a]:void 0;a!=null&&wE({error:o?.error,fetchState:o?.fetchState??"Not-Started"},e)&&n.push(k_({id:a}));const c=t.invoicingConfigViewState;return wE({error:c.error,fetchState:c.fetchState},e)&&n.push(Ur()),n.length>0?_(n):F}))),(s,i,r)=>s.pipe(S(js.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/discounts`,((d,l,u)=>{const m=new URLSearchParams;return d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[Gs(l,"merge"),PU({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(u_(d.status))})),v((d=>p(u_(f("Unexpected Error","Fetch discount list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(TU.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingCouponViewState,o=[];return BE({fetchState:n.fetchState,error:n.error},t)&&o.push(js({filters:e,sort:a})),BE(n.countsFetchState,t)&&o.push(d_()),j(_(o))}))),(s,i,r)=>s.pipe(S(lh.match),A((()=>{const{filters:t}=i.value.invoicingCreditNoteListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search),t.customerId!=null&&e.set("customer_id",t.customerId);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/credits/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(uB(n.data)):p(uh(n.status)))),v((n=>p(uh(f("Unexpected Error","Fetch credit note counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(dB.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/credits/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[zs([n.data],"merge"),lB({id:n.data.id})]:p(dh(n.status)))),v((n=>p(dh(f("Unexpected Error","Fetch credit note detail REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(ph.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/credits`,((d,l,u)=>{const m=new URLSearchParams;return d.customerId!=null&&m.set("customer_id",d.customerId),d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[zs(l,"merge"),pB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(mh(d.status))})),v((d=>p(mh(f("Unexpected Error","Fetch credit note list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(mB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingCreditNoteListViewState,o=[];return FE({fetchState:n.fetchState,error:n.error},t)&&o.push(ph({filters:e,sort:a})),FE(n.countsFetchState,t)&&o.push(lh()),j(_(o))}))),(s,i,r)=>s.pipe(S(yh.match),A((()=>{const{filters:t}=i.value.invoicingCustomerListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(yB(n.data)):p(_h(n.status)))),v((n=>p(_h(f("Unexpected Error","Fetch customer counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Ys.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[z(vi([n.data])),Ii([n.data],"merge"),bi({id:n.data.id})]:p(M_({id:e,status:n.status})))),v((n=>p(M_({id:e,status:f("Unexpected Error","Fetch customer detail REST API call errored out "+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(Pk.match),y((r=>{const{cacheOverride:t,id:e}=r.payload,a=i.value.editInvoicingCustomerDetailViewState.recordStateById[e],n=i.value.invoicingInvoiceListState,o=n.invoiceByTab[n.activeTab],c=i.value.invoicingSettingsViewState,d=[];return Cl({fetchState:a?.fetchState??"Not-Started",error:a?.error},t)&&d.push(Ys({id:e})),n.filters.customerId===e&&!Cl({fetchState:o?.fetchState??"Not-Started",error:o?.error},t)||d.push(Ei({filters:{customerId:e}})),Cl({fetchState:c.fetchState,error:c.error},t)&&d.push(Vt()),d.push(V_({cacheOverride:t,customerId:e})),j(_(d))}))),(s,i,r)=>s.pipe(S(Ks.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers`,((d,l,u)=>{const m=new URLSearchParams;return d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[Ii(l,"merge"),z(vi(l)),_B({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(hh(d.status))})),v((d=>p(hh(f("Unexpected Error","Fetch customer list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(hB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingCustomerListViewState,o=[];return qE({fetchState:n.fetchState,error:n.error},t)&&o.push(Ks({filters:e,sort:a})),qE(n.countsFetchState,t)&&o.push(yh()),j(_(o))}))),(s,i,r)=>s.pipe(S(k0.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import/status`;return r.getJSON(t).pipe(A((e=>T(e)?p(LU(e.data??[])):p(g_(e.status)))),v((e=>p(g_(f("Unexpected Error","Fetch data import status REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Eh.match),A((()=>{const{filters:t}=i.value.invoicingDunningCaseListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(bB(n.data)):p(Ph(n.status)))),v((n=>p(Ph(f("Unexpected Error","Fetch dunning case counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Sh.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[Oi([n.data],"merge"),SB({id:n.data.id})]:p(gh(n.status)))),v((n=>p(gh(f("Unexpected Error","Fetch dunning case detail REST API call errored out "+JSON.stringify(n)))))))}))),(s,i)=>s.pipe(S(gB.match),Le(i),y((([r,t])=>{const{cacheOverride:e,id:a}=r.payload,n=t.invoicingDunningCaseDetailViewState,o=[];return n.id===a&&!((c,d)=>d||c.fetchState!=="Completed"&&c.fetchState!=="In-Progress")({error:n.error,fetchState:n.fetchState},e)||o.push(Sh({id:a})),o.push(fh({id:a,cacheOverride:e})),o.length>0?_(o):F}))),(s,i,r)=>s.pipe(S(Th.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning`,((d,l,u)=>{const m=new URLSearchParams;return d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[Oi(l,"merge"),EB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(Ah(d.status))})),v((d=>p(Ah(f("Unexpected Error","Fetch dunning case list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(PB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingDunningCaseListViewState,o=[];return jE({fetchState:n.fetchState,error:n.error},t)&&o.push(Th({filters:e,sort:a})),jE(n.countsFetchState,t)&&o.push(Eh()),j(_(o))}))),(s,i,r)=>s.pipe(S(vh.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/${encodeURIComponent(e)}/email-preview`;return r.postAndGetJSON(a,{}).pipe(nt((n=>{return T(n)&&n.data!=null?fB({id:e,preview:(o=n.data,{body:o.body,bodyToken:o.body_token,cc:o.cc,renderedHtmlTemplate:o.rendered_html_template,subject:o.subject,subjectToken:o.subject_token,to:o.to})}):Ih({id:e,status:n.status});var o})),v((n=>p(Ih({id:e,status:f("Unexpected Error",`Dunning email preview REST API call errored out: ${n instanceof Error?n.message:String(n)}`)})))))}))),(s,i)=>s.pipe(S(fh.match),y((r=>{const{cacheOverride:t,id:e}=r.payload,a=i.value.invoicingDunningCaseDetailViewState;return a.id!==e?F:((n,o)=>o||n.fetchState!=="Completed"&&n.fetchState!=="In-Progress")(a.emailPreview,t)?p(vh({id:e})):F}))),(s,i,r)=>s.pipe(S(FU.match),A((t=>{const{cursor:e,level:a,moduleId:n,outcome:o,search:c,sessionId:d}=t.payload,l=new URLSearchParams;e!=null&&l.set("cursor",e),n!=null&&l.set("module_id",n),a!=null&&l.set("level",a),o!=null&&l.set("outcome",o),c!=null&&c.trim()!==""&&l.set("search",c.trim());const u=l.toString(),m=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import/${encodeURIComponent(d)}/issues${u===""?"":`?${u}`}`;return r.getJSON(m).pipe(A((h=>T(h)&&h.data!=null?p(qU({append:e!=null,page:h.data,sessionId:d})):p(f_({error:h.status,sessionId:d})))),v((h=>p(f_({error:f("Unexpected Error","Fetch migration diagnostics REST API call errored out "+JSON.stringify(h)),sessionId:d})))))}))),(s,i,r)=>s.pipe(S(jU.match),A((t=>{const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import/${encodeURIComponent(t.payload)}`;return r.getJSON(e).pipe(A((a=>T(a)&&a.data!=null?p(B0(a.data)):p(v_(a.status)))),v((a=>p(v_(f("Unexpected Error","Fetch migration session REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(D0.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import/sessions`;return r.getJSON(t).pipe(A((e=>T(e)?p(GU(e.data??[])):p(I_(e.status)))),v((e=>p(I_(f("Unexpected Error","Fetch migration sessions REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Nh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/churn?months=6&year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(TB(a.data)):p(Oh(a.status)))),v((a=>p(Oh(f("Unexpected Error","Fetch overview churn REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Ch.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/dashboard-summary?year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(AB(a.data)):p(xh(a.status)))),v((a=>p(xh(f("Unexpected Error","Fetch overview dashboard summary REST API call errored out "+JSON.stringify(a)))))))}))),(s,i)=>s.pipe(S(NB.match),y((r=>{const{cacheOverride:t}=r.payload,e=i.value,a=e.invoicingOverviewState,n=[];Tt(a.kpisFetchState,t)&&n.push(Uh()),Tt(a.revenueFetchState,t)&&n.push(kh()),Tt(a.mrrFetchState,t)&&n.push(Bh()),Tt(a.churnFetchState,t)&&n.push(Nh()),Tt(a.planRevenueFetchState,t)&&n.push(Dh()),Tt(a.summaryFetchState,t)&&n.push(Ch()),Tt(OB(e),t)&&n.push(Vt());const o=CB(e);return Tt({fetchState:o.fetchState,error:o.error},t)&&n.push(Ci({})),j(_(n))}))),(s,i,r)=>s.pipe(S(Uh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/kpis?year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(xB(a.data)):p(Jh(a.status)))),v((a=>p(Jh(f("Unexpected Error","Fetch overview KPIs REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Bh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/mrr?months=6&year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(UB(a.data)):p(wh(a.status)))),v((a=>p(wh(f("Unexpected Error","Fetch overview MRR REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Dh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/plan-revenue?year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(kB(a.data)):p($h(a.status)))),v((a=>p($h(f("Unexpected Error","Fetch overview plan revenue REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(kh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/revenue?months=12&year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(BB(a.data)):p(Rh(a.status)))),v((a=>p(Rh(f("Unexpected Error","Fetch overview revenue REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(L_.match),A((t=>{const{customerId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(e)}/payment-link/email-preview`;return r.postAndGetJSON(a,{}).pipe(nt((n=>{return T(n)&&n.data!=null?Tk({customerId:e,preview:(o=n.data,{body:o.body,bodyToken:o.body_token,renderedHtmlTemplate:o.rendered_html_template,subject:o.subject,subjectToken:o.subject_token,to:o.to})}):F_({customerId:e,status:n.status});var o})),v((n=>p(F_({customerId:e,status:f("Unexpected Error",`Payment link email preview REST API call errored out: ${n instanceof Error?n.message:String(n)}`)})))))}))),(s,i)=>s.pipe(S(V_.match),y((r=>{const{cacheOverride:t,customerId:e}=r.payload,{emailPreviewCustomerId:a,emailPreviewFetchState:n}=i.value.editInvoicingCustomerDetailViewState;return a!==e||((o,c)=>c||o.fetchState!=="Completed"&&o.fetchState!=="In-Progress")(n,t)?p(L_({customerId:e})):F}))),(s,i,r)=>s.pipe(S(JU.match),A((t=>{const{customerId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/plaid/link-token?customer_id=${encodeURIComponent(e)}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(wU(n.data.link_token)):p(__(n.status)))),v((n=>p(__(f("Unexpected Error","Plaid link token REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(A_.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/connection`;return r.getJSON(t).pipe(nt((e=>T(e)?DB(GE(e.data??{connected:!1})):Vh(e.status))),v((e=>p(Vh(f("Unexpected Error","Fetch QBO connection REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(xi.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/sync-health`;return r.getJSON(t).pipe(nt((e=>{return T(e)?JB({connection:(a=e.data??{}).connection!=null?GE(a.connection):void 0,countsByStatus:a.counts_by_status??{},failedTasks:(a.failed_tasks??[]).map((n=>({attempts:n.attempts,entityId:n.entity_id,entityType:n.entity_type,taskId:n.task_id,lastError:n.last_error??void 0,updatedAt:n.updated_at??void 0})))}):Lh(e.status);var a})),v((e=>p(Lh(f("Unexpected Error","Fetch QBO sync health REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Vt.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;return r.getJSON(t).pipe(A((e=>{if(T(e)&&e.data!=null){const a=e.data.address;return[...a!=null?[z([a])]:[],eS(e.data)]}return p(tS(e.status))})),v((e=>p(tS(f("Unexpected Error","Fetch settings REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(jh.match),A((()=>{const{filters:t}=i.value.invoicingSubscriptionListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search),t.customerId!=null&&e.set("customer_id",t.customerId);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/subscriptions/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(VB(n.data)):p(Gh(n.status)))),v((n=>p(Gh(f("Unexpected Error","Fetch subscription counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Pi.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/subscriptions/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[z(xa([n.data])),Ua([n.data],"merge"),Ti({id:n.data.id})]:p(G_({error:n.status,id:e})))),v((n=>p(G_({error:f("Unexpected Error","Fetch subscription detail REST API call errored out "+JSON.stringify(n)),id:e})))))}))),(s,i)=>s.pipe(S(kk.match),Le(i),y((([r,t])=>{const{cacheOverride:e=!1,id:a}=r.payload,n=[],o=a!=null?t.editInvoicingSubscriptionDetailViewState.recordStateById[a]:void 0;a!=null&&Mn({error:o?.error,fetchState:o?.fetchState??"Not-Started"},e)&&n.push(Pi({id:a}));const c=t.invoicingConfigViewState;Mn({error:c.error,fetchState:c.fetchState},e)&&n.push(Ur());const d=t.invoicingCatalogListViewState;Mn({error:d.error,fetchState:d.fetchState},e)&&n.push(Cr({filters:{type:"plan"},keepExistingListItems:!1}));const l=t.invoicingCouponViewState;return Mn({error:l.error,fetchState:l.fetchState},e)&&n.push(js({filters:{},keepExistingListItems:!1})),n.length>0?_(n):F}))),s=>s.pipe(S(Bk.match),y((i=>{const{subscriptionId:r}=i.payload,t=[Ks({filters:{},keepExistingListItems:!1}),Cr({filters:{},keepExistingListItems:!1}),js({filters:{},keepExistingListItems:!1})];return r!=null&&t.push(Pi({id:r})),j(_(t))}))),(s,i,r)=>s.pipe(S(Ci.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/subscriptions`,((d,l,u)=>{const m=new URLSearchParams;return d.customerId!=null&&m.set("customer_id",d.customerId),d.search!=null&&d.search.length>0&&m.set("search",d.search),d.startedFrom!=null&&m.set("started_from",d.startedFrom),d.startedTo!=null&&m.set("started_to",d.startedTo),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[Ua(l,"merge"),z(xa(l)),LB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(zh(d.status))})),v((d=>p(zh(f("Unexpected Error","Fetch subscription list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(FB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingSubscriptionListViewState,o=[];return zE({fetchState:n.fetchState,error:n.error},t)&&o.push(Ci({filters:e,sort:a})),zE(n.countsFetchState,t)&&o.push(jh()),j(_(o))}))),(s,i,r)=>s.pipe(S(qB.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/payments/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[Zs([n.data],"merge"),jB({id:n.data.id})]:p(Kh(n.status)))),v((n=>p(Kh(f("Unexpected Error","Fetch payment detail REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Hh.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,{activeTab:c}=i.value.invoicingTransactionListViewState,d=c!=="all"?c:void 0,l=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/payments`,((u,m,h,g)=>{const I=new URLSearchParams;return u.status!=null&&u.status.length>0&&I.set("status",u.status),m!=null&&m.length>0&&I.set("type",m),u.customerId!=null&&I.set("customer_id",u.customerId),u.search!=null&&u.search.length>0&&I.set("search",u.search),I.set("limit",String(tt)),h!=null&&I.set("cursor",h),at(I,g),I})(e,d,a,o));return r.getJSON(l).pipe(A((u=>{if(T(u)){const m=u.data?.items??[];return[Zs(m,"merge"),KB({ids:m.map((h=>h.id)),nextCursor:u.data?.next_cursor??null,keepExistingListItems:n})]}return p(Qh(u.status))})),v((u=>p(Qh(f("Unexpected Error","Fetch payment list REST API call errored out "+JSON.stringify(u)))))))}))),(s,i)=>s.pipe(S(YB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingTransactionListViewState,o=n.byTab[n.activeTab]??HB(),c=[];return((d,l)=>l||d.fetchState!=="Completed"&&d.fetchState!=="In-Progress")({fetchState:o.fetchState,error:o.error},t)&&c.push(Hh({filters:e,sort:a})),j(_(c))}))),(s,i)=>s.pipe(S(wV.match),y((r=>{const{cacheOverride:t,isDebitCardFlagEnabled:e,isCreditCardFlagEnabled:a}=r.payload,n=[],o=i.value;if(t===!0)n.push(Wt()),a&&n.push(Zt()),n.push($e("cardHolderCandidate",!0)),n.push(se()),n.push(jr()),e&&n.push(bn());else{const c=o.chargeCardConfigState;c.fetchState!=="In-Progress"&&c.hasValidState()===!1&&n.push(Wt());const d=o.chargeCardListState;d.creditAccount.fetchState!=="Completed"&&d.creditAccount.fetchState!=="In-Progress"&&a&&n.push(Zt());const l=o.userListViewState.userListByType.cardHolderCandidate;l.fetchState!=="In-Progress"&&l.hasValidState()===!1&&n.push($e("cardHolderCandidate",!1)),o.classListState.hasValidState()===!1&&o.classListState.fetchState!=="In-Progress"&&n.push(se()),d.fetchState!=="Completed"&&d.fetchState!=="In-Progress"&&n.push(jr());const u=o.issueChargeCardState.depositAccountsFetchState;e&&u.fetchState!=="Completed"&&u.fetchState!=="In-Progress"&&n.push(bn())}return j(_(n))}))),(s,i,r)=>s.pipe(S(q1.match),A((t=>{const{routingNumber:e,cacheOverride:a}=t.payload,{bankAccount:n}=i.value.magicLinkViewState,o=n.bankNameByRouting[e]?.bankName;if(a===!1&&o)return p(j1(e));{const c={routing_numbers:[e]},d=`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`;return r.getJSON(d).pipe(y((l=>T(l)?p(G1({routingNumber:e,institutions:l.data?.institutions??[]})):p(gv({routingNumber:e,status:l.status})))),v((l=>p(gv({routingNumber:e,status:f("Unexpected Error","Get Bank Name By Routing REST API call errored out"+JSON.stringify(l))})))))}}))),(s,i,r)=>s.pipe(S(z1.match),A((t=>{const{swiftCode:e,cacheOverride:a}=t.payload,{bankAccount:n}=i.value.magicLinkViewState,o=n.bankNameBySwift[e]?.bankName;if(a===!1&&o)return p(K1(e));{const c={swift_code:e},d=`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`;return r.getJSON(d).pipe(y((l=>T(l)?p(Y1({swiftCode:t.payload.swiftCode,institutions:l.data?.institutions??[]})):p(fv({swiftCode:e,status:l.status})))),v((l=>p(fv({swiftCode:e,status:f("Unexpected Error","Get Bank Name By Swift REST API call errored out"+JSON.stringify(l))})))))}}))),(s,i,r)=>s.pipe(S(H1.match),y((t=>{const{billId:e}=t.payload;let a=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}`;return a+=`?query=${encodeURIComponent(JSON.stringify({transaction_type:"bill",bill_pay_provider:"zeni",view:"vendor"}))}`,r.getJSON(a).pipe(y((n=>{if(T(n)){const o=n.data?.transaction?.attachments?.[0],c=o!=null?Q1(o):void 0;return p(W1({currencySymbol:n.data?.transaction?.currency_symbol??"",amount:n.data?.transaction?.total_amount??0,billAttachment:c}))}return p(vv({status:n.status}))})),v((n=>p(vv({status:f("Unexpected Error","Fetch MagicLink Bill REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(Z1.match),A((t=>{const{vendorId:e,tenantEmailDomain:a,token:n}=t.payload,o=`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/namespaces/${a}/vendors/${e}/session`;return r.getJSON(o,{"auth-token":n}).pipe(A((c=>T(c)?p(X1({tenantId:c.data?.tenants[0].tenant_id??"",companyName:c.data?.companies[0].name??"",userId:c.data?.session_info.user_id??"",sessionId:c.data?.session_info.session_id??""})):p(Iv({status:c.status})))),v((c=>p(Iv({status:f("Unexpected Error","Fetch MagicLink Tenant REST API call errored out"+JSON.stringify(c))})))))}))),(s,i)=>s.pipe(S(tO.match),A((r=>{const{cacheOverride:t,fetchFullResponse:e,companyId:a}=r.payload;if(t===!0)return _([fa(e,a),je()]);const n=i.value,o=[];return n.companyViewState.zeniUsers.fetchState==="In-Progress"||n.companyViewState.zeniUsers.hasValidState()||o.push(je()),n.companyViewState.managementView.fetchState==="In-Progress"||n.companyViewState.managementView.hasValidState()||o.push(fa(e,a)),_(o)}))),(s,i,r)=>s.pipe(S(ld.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/merchants?query=${encodeURIComponent(JSON.stringify({is_include_accounting_classes_info:!0,is_include_accounts_info:!0}))}`).pipe(y((t=>T(t)?p(ud(t.data?.merchants??[]),aL(t),Ke("class_list",t.data?.accounting_classes??[]),W(t.data?.accounts??[],"account_list")):p(eI(t.status)))),v((t=>p(eI(f("Unexpected Error","Fetch Merchants REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(uD.match),A((t=>{const{period:e}=t.payload,a={month_and_year:`${String(e.month).padStart(2,"0")}-${e.year}`};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/month-close/performance-trend?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>{if(n.data!=null){const o=[pD({performanceTrend:n.data.performance_trend,period:e})];return _(o)}{const o=[sS({period:e,fetchState:"Error",error:n.status})];return _(o)}})),v((n=>{const o=[sS({period:e,fetchState:"Error",error:f("Unexpected error",`Fetch Month close performance trend REST API call errored out: ${JSON.stringify(n)}`)})];return _(o)})))}))),(s,i,r)=>s.pipe(S(et.match),A((t=>{const{period:e,tenantId:a,refreshViewInBackground:n}=t.payload,o={month_and_year:`${String(e.month).padStart(2,"0")}-${e.year}`,history_month_and_year_flag:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/month-close/checks?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((c=>{if(c.data!=null){const d=[mD({monthEndCloseChecksPayload:c.data,tenantId:a,period:e}),Ui({tenantId:a,period:e,fetchState:"Completed",refreshViewInBackground:n})];return _(d)}{const d=[Ui({tenantId:a,period:e,fetchState:"Error",error:c.status,refreshViewInBackground:n})];return _(d)}})),v((c=>{const d=[Ui({tenantId:a,period:e,fetchState:"Error",refreshViewInBackground:n,error:f("Unexpected error","Fetch Month end close checks REST API call errored out"+JSON.stringify(c))})];return _(d)})))}))),(s,i,r)=>s.pipe(S(Ex.match),$t((()=>{const t=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:e},expenseAutomationMissingReceiptsViewState:{bulkUpload:a}}=t,n=e[H(t).tenantId];if(n==null)return p(Ar());const o=Ee(n),c=a.batchListByPeriod[o]??[],d=new Set(a.failedBatchDetailIds),l=Jy(c).filter((m=>a.batchDetailsById[m.batchId]==null&&!d.has(m.batchId))).map((m=>m.batchId));if(l.length===0)return p(Ar());const u=l.slice(0,5);return j(kE(u,r),p(Ar())).pipe(v((m=>p(Px({error:f("Unexpected Error","Fetch more batch details errored out: "+JSON.stringify(m))})))))}))),(s,i,r)=>s.pipe(S(Js.match),y((t=>{const e=t.payload.batchList,a=i.value.expenseAutomationMissingReceiptsViewState.bulkUpload,{batchDetailsById:n,batchDetailsRevalidating:o}=a,c=Jy(e),d=(o===!0?c:c.filter((l=>n[l.batchId]==null))).map((l=>l.batchId)).slice(0,5);if(d.length===0){const l=a.currentBatchId;return l!=null&&a.phase==="matching"&&a.batchDetailsById[l]==null&&Cy(a.batchStatusById,a.batchListByPeriod,l)?p(ci()):p(Ar())}return j(p(bx()),kE(d,r),p(Ar()))}))),VG,LG,(s,i)=>s.pipe(S(iS.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Lt("month"),Lt("quarter"),Lt("year")]);{const e=[],a=i.value.netBurnOrIncomeClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Lt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Lt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Lt("year")),_(e)}}))),(s,i)=>s.pipe(S(Ts.match),y((r=>{const{cacheOverride:t,forecastId:e}=r.payload;if(t===!0)return _([Ba("month",e),Ba("quarter",e),Ba("year",e)]);{const a=[],n=_D(i.value.netBurnOrIncomeState,i.value.netBurnOrIncomeState.uiState.isForecastModeOn,e).fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(Ba("month",e)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(Ba("quarter",e)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(Ba("year",e)),_(a)}}))),(s,i,r)=>s.pipe(S(Lt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_class:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/net_burn_or_income?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[];return n.push(oe(t.payload.timeframe,"cogs","net_burn_or_income_by_classes",a.data.report.cogs,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(oe(t.payload.timeframe,"expenses","net_burn_or_income_by_classes",a.data.report.expenses,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(oe(t.payload.timeframe,"income","net_burn_or_income_by_classes",a.data.report.income,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(hD({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(cS(a.status,t.payload.timeframe))})),v((a=>p(cS(f("Unexpected Error","P&L REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),FG,(s,i,r)=>s.pipe(S(Ft.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_project:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/net_burn_or_income?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,"cogs","net_burn_or_income_by_projects",o.cogs,o.accounts,c)),n.push(ie(t.payload.timeframe,"expenses","net_burn_or_income_by_projects",o.expenses,o.accounts,c)),n.push(ie(t.payload.timeframe,"income","net_burn_or_income_by_projects",o.income,o.accounts,c)),n.push(SD({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(dS(a.status,t.payload.timeframe))})),v((a=>p(dS(f("Unexpected Error","Net Burn by Projects REST API call errored out"+(a instanceof Error?a.message:String(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(lS.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Ft("month"),Ft("quarter"),Ft("year")]);{const e=[],a=i.value.netBurnOrIncomeProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Ft("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Ft("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Ft("year")),_(e)}}))),(s,i,r)=>s.pipe(S(zo.match),y((t=>{const{fetchFullReport:e}=t.payload,a={is_full_response:e};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/net_burn_or_income_story_card?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[gD(n.data)];return _(o)}return p(uS(n.status))})),v((n=>p(uS(f("Unexpected Error","NetBurnOrIncome Story Card REST API call errored out"+JSON.stringify(n)))))))}))),(s,i)=>s.pipe(S(nS.match),y((r=>{const{cacheOverride:t,forecastId:e}=r.payload,a=yD(i.value),n=ki(i.value.forecastState,i.value.forecastListState,a.dataAvailable),o=Bi(i.value.forecastState,i.value.forecastListState),c=((d,l)=>d!=null&&((u,m)=>{let h=!1;for(let g=0;g<m.length;++g)if(m[g].id===u){h=!0;break}return h})(d,l)?d:l.length>0?l[0].id:void 0)(e,n.forecasts);if(c!=null){const d=[],l=o.forecasts.map((u=>u.id));return d.push(Dr(a.firstMonthOfFY,!0,void 0,{id:c,index:l.indexOf(c)})),t===!0||((u,m)=>{const h=Mm(u,m);return h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"})(c,i.value.netBurnOrIncomeState)?d.push(Ts(!1,c)):console.log("Required data is already there!! No need to fire any fetch!"),_(d)}if(c==null&&o.fetchState==="Completed"&&o.forecasts.length===0)return _([]);if(c==null&&(o.fetchState==="Completed"||o.fetchState==="Error"||o.forecasts.length>0)){console.warn("Atleast one of the forecast in the list should be valid!");const d=[ka(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"month"),ka(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"year"),ka(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"quarter")];return _([d])}if(c==null&&o.forecasts.length===0)return _([Fs(),oS(t,e)]);{console.warn("Invlid state!!");const d=[ka(f("Unexpected error","Unexpected error"),r.payload.forecastId,"month"),ka(f("Unexpected error","Unexpected error"),r.payload.forecastId,"year"),ka(f("Unexpected error","Unexpected error"),r.payload.forecastId,"quarter")];return _([d])}}))),(s,i,r)=>s.pipe(S(aR.match),A((()=>{const t=i.value,e=t.tenantState.loggedInUser?.userEmail;if(e==null)return _([]);const a=t.notificationPreferencesViewState.saveEpoch,n=t.notificationRegistryState.registryEpoch;return r.getJSON(mf(r)).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[rR(o.data,e)];return c.push(sR({registry:o.data.task_checklist_registry??void 0,registryEpochAtDispatch:n})),o.data.task_checklist_preferences!=null&&c.push(nR({preferences:o.data.task_checklist_preferences,saveEpochAtDispatch:a})),p(...c)}return p(yf(o.status))})),v((o=>p(yf(f("Unexpected error","Fetch Notification Settings REST API call errored out"+JSON.stringify(o)))))))}))),s=>s.pipe(S(oR.match),A((i=>{const{hasMonthEndAccess:r,companyId:t}=i.payload;return _(r?[$e("manager",!0),se()]:[dr(t)])}))),qG,(s,i,r)=>s.pipe(S(fD.match),Oa((t=>{const{notificationGroup:e,mode:a,status:n,isNewNotificationFetch:o}=t.payload,{stateByTab:c}=i.value.notificationViewState,d=c[mS(e)],l={status:n,notification_group:e,is_paginated:!0,limit:10,mode:a,page_token:o?null:d.uiState.pageToken};return r.getJSON(`${r.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/user-notification?query=${encodeURIComponent(JSON.stringify(l))}`).pipe(y((u=>{if(T(u)&&u.data!=null){const{notifications:m,total_count:h,next_page_token:g}=u.data,I=[];m.forEach((E=>{I.push(...E.data.authors)}));const b=[...new Map(I.map((E=>[E.user_id,E]))).values()];return[V({users:b,updateType:"merge"}),vD(m,"replace"),ID(m,h,e,o?null:g)]}return p(pS({status:u.status,notificationGroup:e}))})),v((u=>p(pS({status:f("Unexpected Error","Fetch Notification View API call errored out"+JSON.stringify(u)),notificationGroup:e})))))}))),(s,i,r)=>s.pipe(S(hr.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/whitelist-companies?query=${encodeURIComponent(JSON.stringify({is_onboarding_completed:!0}))}`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=t.data.companies.map((n=>n.company_id)),a=[SS({payload:t.data.companies,schema:{}}),ND(e)];return _(a)}return p(fS(t.status))})),v((t=>p(fS(f("Unexpected error","Onboarding Company view errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Li.match),A((t=>{const{companyId:e,cacheOverride:a,reCalculateCurrentStep:n}=t.payload,{onboardingCustomerViewState:o,companyState:c}=i.value,d=Te(c,e)?.company;if(a===!0||d==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"onboarding_setup"}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=l.data.payment_accounts.map((g=>g.payment_account_id)),m=l.data.subscription_payment_accounts.map((g=>g.subscription_payment_account_id)),h=[V({users:l.data.users}),Y(l.data.user_roles),Q({payload:l.data.companies,schema:{}}),z(l.data.addresses),ve({files:l.data.files}),W(l.data.accounts,"onboarding"),Se(l.data.payment_accounts),hp(l.data.subscription_payment_accounts),wS(u,m),sn({companyId:l.data.companies[0].company_id,reCalculateCurrentStep:n}),JS()];return _(h)}return p(N({messageSection:"onboarding_customer_view",messageText:"failed",type:"error"}),$S(l.status))})),v((l=>p($S(f("Unexpected Error","Fetch Customer Onboarding view errored out"+JSON.stringify(l)))))));{const{subscriptionPaymentAccountIds:l,paymentAccountDetails:u}=o;return p(wS(u.paymentAccountIds,l),sn({companyId:e,reCalculateCurrentStep:n}),JS())}}))),(s,i)=>s.pipe(S(cJ.match),A((r=>{const{companyId:t,cacheOverride:e,reCalculateCurrentStep:a}=r.payload;if(e===!0)return p(Li(t,e,a),RS());{const n=i.value,o=[];return n.onboardingCustomerViewState.fetchState==="In-Progress"||n.onboardingCustomerViewState.hasValidState()||o.push(Li(t,e,a)),n.companyConfigState.fetchState==="In-Progress"||n.companyConfigState.hasValidState()||o.push(RS()),_(o)}}))),(s,i)=>s.pipe(S(aO.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([je(),yr(!0),_r(),hr()]);{const e=i.value,a=[];return e.companyViewState.zeniUsers.fetchState==="In-Progress"||e.companyViewState.zeniUsers.hasValidState()||a.push(je()),e.onboardingCockpitViewState.fetchState==="In-Progress"||e.onboardingCockpitViewState.hasValidState()||a.push(yr(!0)),e.onboardingCockpitViewState.qboConnectionPool.fetchState==="In-Progress"||e.onboardingCockpitViewState.qboConnectionPool.hasValidState()||a.push(_r()),e.onboardingCockpitViewState.onboardingCompletedCompanies.fetchState==="In-Progress"||e.onboardingCockpitViewState.onboardingCompletedCompanies.hasValidState()||a.push(hr()),_(a)}}))),(s,i,r)=>s.pipe(S($C.match),y((t=>{const{accrualId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${e}`).pipe(y((a=>T(a)&&a.data!=null?_([Ta([a.data.accrual]),RC({accrualId:e})]):_([gy({accrualId:e,status:a.status})]))),v((a=>_([gy({accrualId:e,status:f("Unexpected Error",`Fetch one-time accrual REST API call errored out ${JSON.stringify(a)}`)})]))),De(s.pipe(S(gt.match))))}))),(s,i)=>s.pipe(S(ZS.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Jr("month","",null),Jr("quarter","",null),ji(!0)]);{const e=[],a=i.value.opExByVendorState.reportFetchState,n=i.value.opExByVendorState.summaryFetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Jr("month","",null)),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Jr("quarter","",null)),n.fetchState!=="In-Progress"&&n.fetchState!=="Completed"&&e.push(ji()),_(e)}}))),(s,i,r)=>s.pipe(S(Jr.match),y((t=>{const e=i.value.opExByVendorState.uiState,a=e.sortOrder[e.timeframe]==="descending"?"desc":"asc",n=e.pageLimit,o=t.payload.fetchNextPage===!1?null:e.pageToken[t.payload.timeframe],c={sortKey:e.sortKey[e.timeframe],sortOrder:e.sortOrder[e.timeframe],searchString:e.searchString[e.timeframe],fetchNextPage:t.payload.fetchNextPage,pageLimit:n},d={time_series_groups:[(l=>{switch(l){case"month":return"months";case"quarter":return"quarters"}})(t.payload.timeframe)],sort_by:e.sortKey[e.timeframe],sort_order:a,search_text:e.searchString[e.timeframe],page_token:o};return n!=null&&(d.page_limit=n),t.payload.searchText&&(d.search_text=t.payload.searchText,c.searchString=t.payload.searchText),r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses_by_vendor?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(l.data!=null&&T(l)){const u=[],m=l.data.report;if(m.status.is_report_generated==null||m.status.is_report_generated===!0){const h=l.data.report.vendors;h!=null&&u.push(le(h,"merge"));const g=m.accounts;g!=null&&u.push(W(g,"operating_expenses_by_vendor",void 0,"merge"));const I=m.accounting_class;I!=null&&u.push(Ke("operating_expenses_by_vendor",I,void 0,"merge"))}return u.push(RJ(t.payload.timeframe,m,c)),_(u)}return p(XS(l.status,t.payload.timeframe))})),v((l=>p(XS(f("Unexpected Error","Opex By Vendor Report for Timeframe REST API call errored out"+JSON.stringify(l)),t.payload.timeframe)))))}))),(s,i,r)=>s.pipe(S(ji.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses_by_vendor_summary?query=${encodeURIComponent(JSON.stringify({is_full_response:!0,accounting_method:"accrual"}))}`).pipe(y((t=>{if(T(t)){const e=[],a=t.data?.report;return a!=null&&(a?.status.is_report_generated!=null&&a?.status.is_report_generated===!1?eg(!1):(e.push(eg(!0)),a?.vendors!=null&&e.push(le(a.vendors,"merge"))),e.push(MJ(a))),_(e)}return p(tg(t.status))})),v((t=>p(tg(f("Unexpected error","Fetch OpEx by Vendor Summary REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(rg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([qt("month"),qt("quarter"),qt("year")]);{const e=[],a=i.value.opExClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(qt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(qt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(qt("year")),_(e)}}))),(s,i)=>s.pipe(S(Es.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;if(t===!0)return _([wa("month",e),wa("quarter",e),wa("year",e)]);{const a=[],n=$J(i.value.opExState,i.value.opExState.uiState.isForecastModeOn,e).fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(wa("month",e)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(wa("quarter",e)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(wa("year",e)),_(a)}}))),(s,i,r)=>s.pipe(S(qt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_class:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[];return n.push(oe(t.payload.timeframe,"expenses","operating_expenses_by_classes",a.data.report.expenses,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(FJ({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(sg(a.status,t.payload.timeframe))})),v((a=>p(sg(f("Unexpected Error","OpEx REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),(s,i,r)=>s.pipe(S(jt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_project:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,"expenses","operating_expenses_by_projects",o.expenses,o.accounts,c)),n.push(qJ({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(ng(a.status,t.payload.timeframe))})),v((a=>p(ng(f("Unexpected Error","OpEx by Projects REST API call errored out"+(a instanceof Error?a.message:String(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(og.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([jt("month"),jt("quarter"),jt("year")]);{const e=[],a=i.value.opExProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(jt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(jt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(jt("year")),_(e)}}))),jG,(s,i)=>s.pipe(S(QS.match),y((r=>{const{cacheOverride:t,forecastId:e}=r.payload,a=wJ(i.value),n=ki(i.value.forecastState,i.value.forecastListState,a.dataAvailable),o=Bi(i.value.forecastState,i.value.forecastListState),c=((d,l)=>d!=null&&((u,m)=>{let h=!1;for(let g=0;g<m.length;++g)if(m[g].id===u){h=!0;break}return h})(d,l)?d:l.length>0?l[0].id:void 0)(e,n.forecasts);if(c!=null){const d=[],l=o.forecasts.map((u=>u.id));return d.push(Dr(a.firstMonthOfFY,!0,void 0,{id:c,index:l.indexOf(c)})),t===!0||((u,m)=>{const h=Rm(u,m);return h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"})(c,i.value.opExState)?d.push(Es(!1,c)):console.log("Required data is already there!! No need to fire any fetch!"),_(d)}if(c==null&&o.fetchState==="Completed"&&o.forecasts.length===0)return _([]);if(c==null&&(o.fetchState==="Completed"||o.fetchState==="Error"||o.forecasts.length>0)){console.warn("Atleast one of the forecast in the list should be valid!");const d=[Ja(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"month"),Ja(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"year"),Ja(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"quarter")];return _([d])}if(c==null&&o.forecasts.length===0)return _([Fs(),WS(t,e)]);{console.warn("Invlid state!!");const d=[Ja(f("Unexpected error","Unexpected error"),r.payload.forecastId,"month"),Ja(f("Unexpected error","Unexpected error"),r.payload.forecastId,"year"),Ja(f("Unexpected error","Unexpected error"),r.payload.forecastId,"quarter")];return _([d])}}))),(s,i,r)=>s.pipe(S(ct.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/vendor-owners`).pipe(y((t=>{if(T(t)){const e=t.data?.users??[],a=[];return a.push(jJ({users:e})),a.push(V({users:e})),_(a)}return p(ig({fetchState:"Error",error:t.status}))})),v((t=>p(ig({fetchState:"Error",error:f("Unexpected Error","Fetch owner REST API call errored out"+JSON.stringify(t))})))))))),(s,i)=>s.pipe(S(lO.match),A((r=>{const t=i.value,e=[];return t.companyViewState.parentSubsidiaryView.subsidiaryByParentCompanyId[r.payload.companyParentId]==null&&e.push(fa(r.payload.fetchFullResponse,r.payload.companyParentId)),t.companyViewState.zeniUsers.fetchState==="In-Progress"||t.companyViewState.zeniUsers.hasValidState()||e.push(je()),_(e)}))),(s,i,r)=>s.pipe(S(KI.match),y((t=>{const{paymentAccountId:e}=t.payload,a=i.value.paymentAccountState,n=qi(a,e);return n?.providerVerificationStatus?.code==="verified"||n?.providerVerificationStatus?.code==="automatically_verified"?r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts/${e}?query=${encodeURIComponent('{"is_include_realtime_balance":true}')}`).pipe(y((o=>T(o)?p(W(o.data?.accounts??[],"zeni_accounts"),Se(o.data?.payment_accounts??[]),Un({paymentAccountId:e,fetchState:"Completed",error:void 0})):p(Un({paymentAccountId:e,fetchState:"Error",error:o.status})))),v((o=>p(Un({paymentAccountId:e,fetchState:"Error",error:f("Unexpected Error","Fetch payment Accounts Balance REST API call errored out"+JSON.stringify(o))}))))):p(Un({paymentAccountId:e,fetchState:"Completed",error:void 0}))}))),(s,i,r)=>s.pipe(S(Ge.match),A((()=>r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts`).pipe(y((t=>{if(T(t)&&t.data!=null){const{payment_accounts:e,accounts:a}=t.data;let n=[W(a,"zeni_accounts"),Se(e),Ht({data:e,updateType:"replace"})];return n=n.concat(e.map((o=>KI(o.payment_account_id)))),j(_(n))}return p(YI({fetchState:"Error",error:t.status}))})),v((t=>p(YI({fetchState:"Error",error:f("Unexpected Error","Fetch payment Accounts REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(Io.match),y((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/payment-sources?query=${encodeURIComponent(JSON.stringify({is_return_only_valid:!0}))}`).pipe(y((t=>{if(T(t)&&t.data){const e=[];return e.push(UA(t.data.payment_sources.cards),hp(t.data.payment_sources.bank_accounts),Eo({fetchState:"Completed",response:t.data})),_(e)}return _([Eo({fetchState:"Error",error:t.status}),N({messageSection:"fetch_payment_sources",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:t.status.message}]})])})),v((t=>p(Eo({fetchState:"Error",error:f("Unexpected Error","Fetch Payment Sources API call errored out "+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(Gi.match),A((()=>{const t=i.value.peopleState.uiState.mode;let e="";return e=t==="zeni_only"?`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles?query=${encodeURIComponent(JSON.stringify({include:t}))}`:`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles`,r.getJSON(e).pipe(y((a=>T(a)?p(Y(a.data?.user_roles??[]),V({users:a.data?.users??[]}),ZJ(a.data)):p(lg(a.status)))),v((a=>p(lg(f("Unexpected error","User Roles REST API call errored out"+JSON.stringify(a)))))))}))),(s,i)=>s.pipe(S(sw.match),A((r=>{const{userId:t,cacheOverride:e}=r.payload;if(e===!0)return _([Ia(t),Gi()]);{const a=i.value,n=[];return a.tenantState.fetchState==="In-Progress"||a.tenantState.hasValidState()||n.push(Ia(t)),a.peopleState.fetchState=="In-Progress"||a.peopleState.hasValidState()||n.push(Gi()),_(n)}}))),(s,i,r)=>s.pipe(S(Bd.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account`).pipe(y((t=>T(t)&&t.data!=null?p(gF(t.data)):p($I(t.status)))),v((t=>p($I(f("Unexpected Error","Fetch portfolio allocation REST API call errored out: "+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(rO.match),A((r=>{const{cacheOverride:t,fetchFullResponse:e}=r.payload;if(t===!0)return _([mr(e),je()]);const a=i.value,n=[];return a.companyViewState.zeniUsers.fetchState==="In-Progress"||a.companyViewState.zeniUsers.hasValidState()||n.push(je()),a.companyViewState.portfolioView.fetchState==="In-Progress"||a.companyViewState.portfolioView.hasValidState()||n.push(mr(e)),_(n)}))),(s,i,r)=>s.pipe(S(aa.match),y((t=>{const e=i.value,{entityId:a}=t.payload,n=tM(t.payload.entityId),o=X(e.previousBillsState.byEntityKey,n,void 0);if(t.payload.cacheOverride===!0||o==null||o.hasValidState()===!1){const c=Oe(e.vendorState,a)?.name??"",d={transaction_type:"bill",bill_pay_provider:"zeni",sort_by:"transaction_date",sort_order:"desc",entity_type:"vendor",entity_id:a,entity_name:c,is_include_attachment:!0,limit:3};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=[];return u.push(gc(l.data.transactions)),u.push(aM({entityId:a,billTransactions:l.data.transactions})),_(u)}return p(bv({entityId:a,fetchState:"Error",error:l.status}))})),v((l=>p(bv({entityId:a,fetchState:"Error",error:f("Unexpected Error","fetch previous bills REST API call errored out"+JSON.stringify(l))})))))}return _([])}))),(s,i)=>s.pipe(S(yg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Gt("month"),Gt("quarter"),Gt("year")]);{const e=[],a=i.value.profitAndLossClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Gt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Gt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Gt("year")),_(e)}}))),(s,i)=>s.pipe(S(Si.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;if(t===!0)return _([Mt("month",e),Mt("quarter",e),Mt("year",e)]);{const a=[],n=lw(i.value.profitAndLossState,e).fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(Mt("month",e)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(Mt("quarter",e)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(Mt("year",e)),_(a)}}))),(s,i,r)=>s.pipe(S(Gt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_class:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/profit_and_loss?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(oe(t.payload.timeframe,"cogs","profit_and_loss_by_classes",o.cogs,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,"expenses","profit_and_loss_by_classes",o.expenses,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,"income","profit_and_loss_by_classes",o.income,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,"otherExpenses","profit_and_loss_by_classes",o.other_expenses,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,"otherIncome","profit_and_loss_by_classes",o.other_income,o.classes,o.accounts,c)),n.push(uw({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(_g(a.status,t.payload.timeframe))})),v((a=>p(_g(f("Unexpected Error","P&L REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),GG,(s,i,r)=>s.pipe(S(zt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_project:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/profit_and_loss?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,"cogs","profit_and_loss_by_projects",o.cogs,o.accounts,c)),n.push(ie(t.payload.timeframe,"expenses","profit_and_loss_by_projects",o.expenses,o.accounts,c)),n.push(ie(t.payload.timeframe,"income","profit_and_loss_by_projects",o.income,o.accounts,c)),n.push(ie(t.payload.timeframe,"otherExpenses","profit_and_loss_by_projects",o.other_expenses,o.accounts,c)),n.push(ie(t.payload.timeframe,"otherIncome","profit_and_loss_by_projects",o.other_income,o.accounts,c)),n.push(pw({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(hg(a.status,t.payload.timeframe))})),v((a=>p(hg(f("Unexpected Error","P&L by Projects REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(Sg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([zt("month"),zt("quarter"),zt("year")]);{const e=[],a=i.value.profitAndLossProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(zt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(zt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(zt("year")),_(e)}}))),(s,i,r)=>s.pipe(S(_i.match),Le(i),A((([t,e])=>{if(!Ms(e))return p(gg({status:f("Success",""),data:{projects:[]}}));const{isIncludeDeleted:a}=t.payload,n=(o=>`?query=${encodeURIComponent(JSON.stringify({is_deleted:o,sort_by:"accounting_project_name",sort_order:"asc",is_full:!0}))}`)(a);return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/projects${n}`).pipe(y((o=>T(o)?p(Ut(o.data?.projects??[]),gg(o)):p(fg(o.status)))),v((o=>p(fg(f("Unexpected Error","Fetch Projects REST API call errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(_r.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections-pool`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=t.data;return p(OD(e))}return p(vS(t.status))})),v((t=>p(vS(f("Unexpected error","QBO Connection Pool errored Out: "+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Ki.match),y((t=>{const{entityId:e,entityType:a}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/${e0(a)}/${e}/recommendations`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[],c=Hr(n.data.recommendations);return o.push(wr({entityId:e,entityType:a,recommendations:c}),ms(e,a)),_(o)}return p($a({entityId:e,entityType:a,status:n.status}))})),v((n=>p($a({entityId:e,entityType:a,status:f("Unexpected Error","Fetch recommendation by Entity Id REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(sr.match),y((t=>{const{entityName:e,entityType:a}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(`{"entity_type":"${a}", "entity_name": "${e}"}`)}`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[],c=Hr(n.data.recommendations);return o.push(wr({entityId:e,entityType:a,recommendations:c}),ms(e,a)),_(o)}return p($a({entityId:e,entityType:a,status:n.status}))})),v((n=>p($a({entityId:e,entityType:a,status:f("Unexpected Error","Fetch recommendation by Entity Name REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(my.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/account-recommendations`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[];return e.push(UC(t.data)),_(e)}return p(yy({status:t.status}))})),v((t=>p(yy({status:f("Unexpected Error","Fetch account recommendations REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(du.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/account-recommendations`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[];return e.push(DP(t.data)),_(e)}return p(lu({status:t.status}))})),v((t=>p(lu({status:f("Unexpected Error","Fetch account recommendations REST API call errored out"+JSON.stringify(t))})))))))),(s,i)=>s.pipe(S(hd.match),y((r=>{const{cacheOverride:t,lineId:e,reimbursementId:a,merchantId:n,merchantName:o}=r.payload,c=i.value,d=a!=null?c.reimbursementState.reimbursementById[a]:void 0,l=[];if(t)n?l.push(Ki(n,"merchant")):o&&l.push(sr(o,"merchant")),l.push(Tn(e,a,n,o));else if(n||o){const{fetchState:u,recommendations:m=[]}=ps(c,n||o,"merchant");u==="In-Progress"?l.push(Tn(e,a,n,o)):u!="Completed"?(l.push(Sd({reimbursementId:a,lineId:e,recommendations:m,reimbursementStageCode:d?.reimbursementInfo.stage.code,shouldAutofill:!0})),n?l.push(Ki(n,"merchant")):o&&l.push(sr(o,"merchant")),l.push(Tn(e,a,n,o))):l.push(Sd({reimbursementId:a,lineId:e,recommendations:m,reimbursementStageCode:d?.reimbursementInfo.stage.code,shouldAutofill:!0}))}return _(l)}))),(s,i,r)=>s.pipe(S(b$.match),y((t=>{const e=i.value,{selectedJELinkRowIndex:a}=t.payload,{scheduleAccruedDetailState:n,vendorState:o}=e,c=[],{selectedJEAccruedScheduleKey:d}=n;if(d==null||a==null)return _(c);const l=sa(d,e);if(l==null)return _(c);const u=l.scheduledJournalEntry[a],{jeDebit:m}=l,{account:h,accountingClass:g}=m,{amount:I,runningBalance:b,expectedPostDate:E}=u,P=me().endOf("month").format(re),{vendor:O}=l,C=O.id,U=Oe(o,C),B={start_date:E.format(re),end_date:P,amount:I?.amount??0,accrued_balance:b?.amount??0,vendor_id:U?.id??"",account_name:h?.accountName??"",class_name:g?.className??""};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accrued-expenses/transactions/recommendations?query=${encodeURIComponent(JSON.stringify(B))}`).pipe(y((x=>T(x)&&x.data!=null?(c.push(Ce(x.data.transactions,(k=>k.transaction_id)),Zg(x.data.transactions,(k=>k.transaction_id)),Wi({fetchState:"Completed",error:void 0})),_(c)):_([Zg([],(k=>k.transaction_id)),Wi({fetchState:"Error",error:x.status})]))),v((x=>_([Wi({fetchState:"Error",error:f("Unexpected Error",`Fetch Bill Expense Recommendation REST API call errored out ${JSON.stringify(x)}`)})]))))}))),(s,i,r)=>s.pipe(S(bw.match),y((t=>{const{cacheOverride:e}=t.payload,a=i.value.referralViewState.fetchState;return e===!0||a==="Not-Started"?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referrals`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[Ew(n.data)];return _(o)}return p(Ng(n.status))})),v((n=>p(Ng(f("Unexpected Error","Fetch referrals REST API call errored out"+JSON.stringify(n))))))):[]}))),(s,i,r)=>s.pipe(S(zx.match),A((t=>r.getJSON(`${r.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/feature-interests?feature=${encodeURIComponent(t.payload.feature)}`).pipe(y((e=>{if(T(e)&&e.data!=null){const n=e.data.feature_interests.map(Kx);return _([Yx(n)])}const a=e.status??f("Failed to fetch registered interests. Please try again.");return _([Hy(a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error fetching registered interests.";return _([Hy(f(a))])})))))),(s,i,r)=>s.pipe(S(Qo.match),y((()=>{const t=ua({startDate:ee(up,"YYYY-MM-DD"),endDate:ee(lp,"YYYY-MM-DD")}),e={start_date:ae(t.start),end_date:ae(t.end),reimbursement_provider:"zeni",transaction_type:"reimbursement",reimbursement_stages:{pending_approval:["awaiting_approval","awaiting_my_approval"],paid:["all"],scheduled:["all"],draft:["all"]},get_count_only:!0};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursement-card?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>T(a)&&a.data!=null?p(kw({transactionTotals:a.data.transaction_totals,transactionCount:a.data.transaction_count})):p(xg(a.status)))),v((a=>p(xg(f("Unexpected Error","fetch Reimbursement Dashboard Card REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(ja.match),y((()=>r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/config`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[];return e.push(BL(t.data)),e.push(DL(t.data.currency_country_map)),_(e)}return p(mI(t.status))})),v((t=>p(mI(f("Unexpected Error","fetch reimbursement config REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(_d.match),y((r=>{const{reimbursementId:t,cacheOverride:e,isShowDeletedReimbursementEnabled:a}=r.payload,n=i.value,o=[];if(e)o.push(gd(t,!0,a)),o.push(fd(t));else{const c=X(n.remiDetailViewState.remiDetailById,t,void 0);c!=null&&c.fetchState==="In-Progress"?o.push(fd(t)):c==null||c?.fetchState!="In-Progress"&&c?.fetchState!="Completed"?(o.push(gd(t,!1,a)),o.push(fd(t))):o.push(dI(t))}return _(o)}))),(s,i)=>s.pipe(S(HL.match),y((r=>{const{cacheOverride:t,includeUserRoles:e,includeAttributesUserIds:a,lastUpdatedByUserId:n}=r.payload,{remiSetupApproverViewState:o,classListState:c}=i.value,{approverListState:d}=o,l=[];return t===!0?(l.push(Nd(t,e,a,n)),l.push(se())):(o.hasValidState()===!1&&d.fetchStatus.fetchState!=="In-Progress"&&l.push(Nd(!0,e,a,n)),c.hasValidState()===!1&&c.fetchState!=="In-Progress"&&l.push(se())),j(_(l))}))),(s,i,r)=>s.pipe(S(Nd.match),A((t=>{const{cacheOverride:e,includeUserRoles:a,includeAttributesUserIds:n,lastUpdatedByUserId:o}=t.payload,{remiSetupApproverViewState:c}=i.value,d=c.approverListState.approverIds;if(e===!0||d.length===0)return r.getJSON(`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approvers?query={"is_include_user_roles_info":${a},"is_include_attribute_user_ids":${n},"last_updated_by_user_id":"${o}"}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=l.data.users.map((h=>h.user_id)),m=[V({users:l.data.users})];return a===!0&&m.push(Y(l.data.user_roles)),m.push(fI(u,l.data.attributes,l.data.attribute_sub_type_to_user_id_mapping)),_(m)}return p(vI(l.status))})),v((l=>p(vI(f("Unexpected Error","Fetch Approvers List errored out"+JSON.stringify(l)))))));{const{approverListState:l}=c,{approverIds:u,attributes:m}=l;return p(fI(u,m))}}))),(s,i,r)=>s.pipe(S(gd.match),y((t=>{const{reimbursementId:e,cacheOverride:a,isShowDeletedReimbursementEnabled:n}=t.payload,o=[],c=i.value,{remiDetailViewState:d,reimbursementConfigState:l}=c;if(a===!0){const m=X(d.remiDetailById,e,void 0);o.push(...(function(h,g){const I=[];return I.push(FL(h)),g!=null&&I.push(Pd(h)),I})(e,m))}const u=X(d.remiDetailById,e,void 0);if(a==1||u==null||u.fetchState!=="In-Progress"){o.push(Nn(e,"In-Progress")),o.push(yn(e,"reimbursement",a)),l.fetchState!=="In-Progress"&&l.fetchState!=="Completed"&&o.push(ja());const m={transaction_type:"reimbursement",reimbursement_provider:"zeni",is_include_approval_info:!0,is_include_deleted:n},h=r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${e}?query=${encodeURIComponent(JSON.stringify(m))}`).pipe(y((g=>{if(T(g)&&g.data?.transaction?.transaction_id!=null){const I=g.data.transaction.transaction_id,b=g.data.reimbursee_bank_account,E=[bd(g.data.transaction),V({users:g.data.users??[]}),We(g.data.approval_rules),Et(g.data.entity_approvals),VL({reimbursementId:e,remiDetail:g.data}),ud(g.data.merchants),uI(g.data.merchants),Je(b!=null?[b]:[]),Nn(I,"Completed")];return g.data.merchants.forEach((P=>{const O=Hr(P.recommendations??[]);O!=null&&P.merchant_id&&E.push(wr({entityId:P.merchant_id,entityType:"merchant",recommendations:O}))})),E.push(LL()),g.data.transaction?.lines!=null&&g.data.transaction.lines.length>0&&E.push(Id(g.data.transaction.created_by_user_id,!1,g.data.transaction.transaction_id)),_(E)}return p(Nn(t.payload.reimbursementId,"Error",g.status))})),v((g=>(console.error(`REST API call errored out ${g}`),p(Nn(t.payload.reimbursementId,"Error",f("Unexpected Error",`REST API call errored out ${g}`)))))));return j(_(o),h)}return _(o)}))),(s,i)=>s.pipe(S(qL.match),y((r=>{const t=[],e=i.value,{period:a,cacheOverride:n,isShowDeletedReimbursementEnabled:o,isIncludeLineItems:c,isRefreshAccountAndAccountingClass:d}=r.payload,l=["draft","pending_approval","scheduled","paid"];return n===!0?(t.push(ja()),l.forEach((u=>t.push(Ad(a,u,o,c,d))))):(e.reimbursementConfigState.fetchState!=="Completed"&&e.reimbursementConfigState.fetchState!=="In-Progress"&&t.push(ja()),l.forEach((u=>{const m=jL(a,u),h=X(e.remiListState.byRemiListKey,m,void 0);h!=null&&h.hasValidState()!==!1||t.push(Ad(a,u,o,c,d))}))),_(t)}))),(s,i,r)=>s.pipe(S(Ad.match),y((t=>{const{period:e,tab:a,isShowDeletedReimbursementEnabled:n,isIncludeLineItems:o,isRefreshAccountAndAccountingClass:c}=t.payload,d={start_date:ae(e.start),end_date:ae(e.end),sort_by:"reimbursement_date",sort_order:"desc",reimbursement_provider:"zeni",reimbursement_stage_code:a,is_include_reimbursee_users_info:!0,is_include_approval_info:a==="pending_approval",is_include_pending_approval_transaction_ids_for_user:a==="pending_approval",transaction_type:"reimbursement",is_include_deleted:!!n&&a!=="draft",is_include_line_items:!!o&&a!=="draft",is_refresh_account_and_accounting_class:c};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=[V({users:l.data.users}),GL(l.data.transactions),zL({remiList:l.data,tab:a}),Et(l.data.entity_approvals??[])];return _(u)}return p(SI(e,a,l.status))})),v((l=>p(SI(t.payload.period,t.payload.tab,f("Unexpected Error","fetch remi list REST API call errored out"+JSON.stringify(l)))))))}))),(s,i,r)=>s.pipe(S(Od.match),A((t=>{const{cacheOverride:e,resolveAttributeToUser:a,includeImplicitActors:n,useV3:o}=t.payload,{remiSetupApproverViewState:c,approvalRuleState:d,classListState:l}=i.value,u=pt(i.value),m=qf(d,c.approvalRuleIds),h=u&&(e===!0||l.hasValidState()===!1&&l.fetchState!=="In-Progress");if(e===!0||m.length!==c.approvalRuleIds.length||c.hasValidState()===!1&&c.fetchState!=="In-Progress"){const g=o===!0?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;return r.getJSON(`${g}?query={"is_include_implicit_actors": ${n}, "is_resolve_attribute_to_user":${a}}`).pipe(y((I=>{if(T(I)&&I.data!=null){const b=I.data.approval_rules.map((P=>P.approval_rule_id)),E=[V({users:I.data.users}),We(I.data.approval_rules),II(b)];return h&&E.push(se()),_(E)}return p(bI(I.status))})),v((I=>p(bI(f("Unexpected Error","Fetch Approval view errored out"+JSON.stringify(I)))))))}{const{approvalRuleIds:g}=c,I=[II(g)];return h&&I.push(se()),_(I)}}))),(s,i,r)=>s.pipe(S(tF.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{remiSetupViewState:o,plaidAccountViewState:c,companyState:d}=i.value,l=Te(d,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"reimbursement_setup"}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=u.data.accounts.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses),ve({files:u.data.files}),W(u.data.accounts,"reimbursement"),Se(u.data.payment_accounts),Ht({data:u.data.payment_accounts,updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"replace"}),we({companyId:u.data.companies[0].company_id}),Cd({companyId:u.data.companies[0].company_id}),rt(m,"reimbursement_setup"),NI()];return _(h)}return p(N({messageSection:"reimbursement_setup",messageText:"failed",type:"error"}),OI(u.status))})),v((u=>p(OI(f("Unexpected Error","Fetch Remi Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=c.reimbursement_setup.accountDetails;return p(we({companyId:e}),rt(u,"reimbursement_setup"),NI())}}))),(s,i)=>s.pipe(S(Vg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Kt("month"),Kt("quarter"),Kt("year")]);{const e=[],a=i.value.revenueClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Kt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Kt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Kt("year")),_(e)}}))),(s,i)=>s.pipe(S(Ps.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;if(t===!0)return _([Ma("month",e),Ma("quarter",e),Ma("year",e)]);{const a=[],n=d$(i.value.revenueState,i.value.revenueState.uiState.isForecastModeOn,e).fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(Ma("month",e)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(Ma("quarter",e)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(Ma("year",e)),_(a)}}))),(s,i,r)=>s.pipe(S(Kt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[zg(t.payload.timeframe)],is_group_by_class:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/revenue?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[];return n.push(oe(t.payload.timeframe,"cogs","revenue_by_classes",a.data.report.cogs,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(oe(t.payload.timeframe,"income","revenue_by_classes",a.data.report.income,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(l$({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(Kg(a.status,t.payload.timeframe))})),v((a=>p(Kg(f("Unexpected Error","Revenue REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),zG,(s,i,r)=>s.pipe(S(Yt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[zg(t.payload.timeframe)],is_group_by_project:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/revenue?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,"cogs","revenue_by_projects",o.cogs,o.accounts,c)),n.push(ie(t.payload.timeframe,"income","revenue_by_projects",o.income,o.accounts,c)),n.push(u$({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(Yg(a.status,t.payload.timeframe))})),v((a=>p(Yg(f("Unexpected Error","Revenue by Projects REST API call errored out"+(a instanceof Error?a.message:String(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(Fg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Yt("month"),Yt("quarter"),Yt("year")]);{const e=[],a=i.value.revenueProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Yt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Yt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Yt("year")),_(e)}}))),(s,i)=>s.pipe(S(jg.match),y((r=>{const{cacheOverride:t,forecastId:e}=r.payload,a=c$(i.value),n=ki(i.value.forecastState,i.value.forecastListState,a.dataAvailable),o=Bi(i.value.forecastState,i.value.forecastListState),c=((d,l)=>d!=null&&((u,m)=>{let h=!1;for(const g of m)if(g.id===u){h=!0;break}return h})(d,l)?d:l.length>0?l[0].id:void 0)(e,n.forecasts);if(c!=null){const d=[],l=o.forecasts.map((u=>u.id));return d.push(Dr(a.firstMonthOfFY,!0,void 0,{id:c,index:l.indexOf(c)})),t===!0||((u,m)=>{const h=$m(u,m);return h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"})(c,i.value.revenueState)?d.push(Ps(!1,c)):console.log("Required data is already there!! No need to fire any fetch!"),_(d)}if(c==null&&o.fetchState==="Completed"&&o.forecasts.length===0)return _([]);if(c==null&&(o.fetchState==="Completed"||o.fetchState==="Error"||o.forecasts.length>0)){console.warn("Atleast one of the forecast in the list should be valid!");const d=[Ra(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"month"),Ra(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"year"),Ra(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"quarter")];return _([d])}if(c==null&&o.forecasts.length===0)return _([Fs(),Gg(t,e)]);{console.warn("Invlid state!!");const d=[Ra(f("Unexpected error","Unexpected error"),r.payload.forecastId,"month"),Ra(f("Unexpected error","Unexpected error"),r.payload.forecastId,"year"),Ra(f("Unexpected error","Unexpected error"),r.payload.forecastId,"quarter")];return _([d])}}))),(s,i,r)=>s.pipe(S(is.match),A((t=>{const{cacheOverride:e,isFromMonthEnd:a}=t.payload,n=i.value,{fetchState:o}=n.reviewCompanyViewState;return e===!0||o!=="In-Progress"?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/audit`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[p$(c.data.companies)];return a===!0&&d.push(N({messageSection:"audit_score_updated",messageText:"success",type:"success"})),_(d)}{const d=[Hg(c.status)];return _(d)}})),v((c=>{const d=[Hg(f("Unexpected error","Cockpit Review errored out"+JSON.stringify(c)))];return _(d)}))):_([])}))),(s,i,r)=>s.pipe(S(MF.match),A((()=>{const t=i.value.transferDetailState.localData,e={from_account:{account_id:t.transferFrom?.id,account_type:Me(t.transferFrom?.accType)??""},to_account:{account_id:t.transferTo?.id,account_type:Me(t.transferTo?.accType)??""},amount:t.amount.amount,currency_code:t.amount.currencyCode,currency_symbol:t.amount.currencySymbol};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/transfers/review`,e).pipe(y((a=>T(a)&&a.data!=null?p(VF(a.data)):p(QI(a.status)))),v((a=>p(QI(f("Unexpected Error","Review Transfer Detail REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Wo.match),y((t=>{const{cacheOverride:e}=t.payload,a=i.value.referralViewState.rewardsPlanFetchState.fetchState;if(e===!0||a==="Not-Started"){const n={is_primary_refer_reward_plan:!0};return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-refer-reward-plan?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[Pw(o.data)];return _(c)}return p(Og(o.status))})),v((o=>p(Og(f("Unexpected Error","Fetch rewards plan REST API call errored out"+JSON.stringify(o)))))))}return[]}))),(s,i,r)=>s.pipe(S(Xg.match),y((t=>{const e=[],{scheduleType:a,selectedJeScheduleDetailId:n}=t.payload,{scheduleAccruedDetailState:o}=i.value;if(n!=null){if(o.editScheduleStateByDetailId[n]?.jeScheduleDetails.length>0&&o.selectedJEAccruedScheduleKey!=null)return e.push(Va(a,o.selectedJEAccruedScheduleKey,n)),e.push(Zi()),_(e);const c={je_schedule_type:a};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${n}?query=${encodeURIComponent(JSON.stringify(c))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=ef(d.data.je_schedules[0]);return e.push(ca(d.data.je_schedules),E$({selectedJEScheduleKey:l}),br(d.data.je_schedules,d.data.scheduled_journal_entries),Rr("Not-Started"),Va(a,l,n),Zi()),_(e)}return p(Xi({error:d.status}))})),v((d=>p(Xi({error:f("Unexpected Error","Accrued Schedule Detail REST API call errored out"+JSON.stringify(d))})))))}return o.selectedJEAccruedScheduleKey!=null?(e.push(Va(a,o.selectedJEAccruedScheduleKey)),e.push(Zi())):e.push(Xi({error:f("Unexpected Error","Accrued Schedule Detail key is not defined")})),_(e)}))),(s,i)=>s.pipe(S(P$.match),y((r=>{const t=[],e=Ir(),a=i.value.accountListState,n=i.value.classListState;return a.byReportId[e.accountListKey].fetchState==="Not-Started"&&t.push(be(e.accountListKey,!0,!1,!1,!1,e.allowedAccountList)),n.fetchState==="Not-Started"&&t.push(se()),r.payload.selectedJeScheduleDetailId!=null&&t.push(Xg(r.payload.scheduleType,r.payload.selectedJeScheduleDetailId)),j(_(t))}))),(s,i,r)=>s.pipe(S(af.match),y((t=>{const e=[],{scheduleType:a,selectedJeScheduleDetailId:n,cacheOverride:o}=t.payload,{scheduleDetailState:c}=i.value;if(n!=null){if(c.editScheduleStateByDetailId[a][n]?.jeScheduleDetails.length>0&&c.selectedJEScheduleKey!=null&&o!==!0)return e.push(Mr(a,c.selectedJEScheduleKey,n)),e.push(ac()),_(e);const d={je_schedule_type:a};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${n}?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=D$(l.data.je_schedules[0].base_transaction);return e.push(ut(l.data.je_schedules),J$({selectedJEScheduleKey:u}),St(l.data.je_schedules,l.data.scheduled_journal_entries),Vr("Not-Started"),Mr(a,u,n),ac()),l.data.je_schedules[0].status.code==="draft"&&kK(l.data.je_schedules[0])&&e.push(tf({scheduleType:a})),_(e)}return p(rc({error:l.status}))})),v((l=>p(rc({error:f("Unexpected Error","Schedule Detail REST API call errored out"+JSON.stringify(l))})))))}return c.selectedJEScheduleKey!=null?(e.push(Mr(a,c.selectedJEScheduleKey)),e.push(ac())):e.push(rc({error:f("Unexpected Error","Schedule Detail key is not defined")})),_(e)}))),(s,i)=>s.pipe(S(w$.match),y((r=>{const t=[],e=Ir(),a=i.value.accountListState,n=i.value.classListState;return a.byReportId[e.accountListKey].fetchState==="Not-Started"&&t.push(be(e.accountListKey,!0,!1,!1,!1,e.allowedAccountList)),n.fetchState==="Not-Started"&&t.push(se()),r.payload.selectedJeScheduleDetailId!=null&&t.push(af(r.payload.scheduleType,r.payload.selectedJeScheduleDetailId,r.payload.cacheOverride)),j(_(t))}))),(s,i,r)=>s.pipe(S(oc.match),y((t=>{const{scheduleType:e}=t.payload,{scheduleListState:a,accountListState:n}=i.value;let o;if(e!=="accrued_expenses"&&(o=nc(a,e)),o==null)return _([]);const c=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedTimeframe:o.selectedTimeframe,d=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedCategoryId:o.selectedCategoryId,l=ua(c),u=ln(d,c),m=o.jeScheduleKeysByListKey[u];if(m!=null&&m.fetchState==="Completed"&&t.payload.cacheOverride===!1)return _([]);const h=Y$(e),g=H$(e),I=g!=null?z$(n,h.accountListKey,g):[];let b=[d];d==="all"&&(b=I);const E={start_date:ae(l.start),end_date:ae(l.end),je_schedule_type:e,base_txn_account_ids:b,sort_by:"transaction_date",sort_order:"desc",filter:"all"};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(E))}`).pipe(y((P=>{if(T(P)&&P.data!=null){const O=[];return O.push(ut(P.data.je_schedules),St(P.data.je_schedules,P.data.scheduled_journal_entries),K$(e,c,d,P.data.je_schedules)),_(O)}return p(cf(e,c,d,P.status))})),v((P=>p(cf(e,c,d,f("Unexpected Error","Schedule List REST API call errored out"+JSON.stringify(P)))))))}))),s=>s.pipe(S(Q$.match),y((()=>{const i=[],r=Ir();return i.push(be(r.accountListKey,!1,!1,!1,!1,r.allowedAccountList)),_(i)}))),(s,i,r)=>s.pipe(S(TT.match),A((t=>{const{macroId:e}=t.payload,a=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}`;return r.getJSON(a).pipe(y((n=>T(n)&&gl(n.data)?p(AT({detail:fl(n.data),macroId:e})):p(Du({error:n.status,macroId:e})))),v((n=>p(Du({error:f("Unexpected Error","Fetch skill detail REST API call failed",n instanceof Error?{message:n.message}:void 0),macroId:e})))))}))),(s,i,r)=>s.pipe(S(po.match),A((()=>{const t=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills`;return r.getJSON(t).pipe(y((e=>T(e)&&e.data!=null?p(xT({skills:(e.data.skills??[]).map(_z),skillsEnabled:e.data.skills_enabled===!0,canPublish:e.data.can_publish===!0})):p(Ru(e.status)))),v((e=>p(Ru(f("Unexpected Error","Fetch skills REST API call failed",e instanceof Error?{message:e.message}:void 0))))))}))),(s,i,r)=>s.pipe(S(NT.match),A((t=>{const{macroId:e,version:a}=t.payload,n=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}?version=${encodeURIComponent(String(a))}`;return r.getJSON(n).pipe(y((o=>T(o)&&z0(o.data)?p(OT({macroId:e,version:a,instructions:o.data.instructions})):p(Ju({macroId:e,version:a,error:o.status})))),v((o=>p(Ju({macroId:e,version:a,error:f("Unexpected Error","Fetch skill version body REST API call failed",o instanceof Error?{message:o.message}:void 0)})))))}))),(s,i,r)=>s.pipe(S(wu.match),A((t=>{const{macroId:e}=t.payload,a=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}/versions`;return r.getJSON(a).pipe(y((n=>T(n)&&n.data!=null?p(CT({macroId:e,versions:(n.data.versions??[]).map(mz)})):p($u({macroId:e,error:n.status})))),v((n=>p($u({macroId:e,error:f("Unexpected Error","Fetch skill versions REST API call failed",n instanceof Error?{message:n.message}:void 0)})))))}))),(s,i,r)=>s.pipe(S(YF.match),A((t=>{const{cacheOverride:e}=t.payload,{subscriptionViewState:a}=i.value,n=a.addOnListState.addOnIds;return e===!0||n.length===0?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-addons`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.subscription_addons.map((l=>l.subscription_addon_id)),d=[ha({payload:o.data.subscription_addons}),tb({addOnIds:c})];return _(d)}return p(ab({status:o.status}))})),v((o=>p(ab({status:f("Unexpected error","Unable to fetch subscription addOns"+JSON.stringify(o))}))))):p(tb({addOnIds:n}))}))),(s,i,r)=>s.pipe(S(HF.match),A((t=>{const{cacheOverride:e}=t.payload,{subscriptionViewState:a}=i.value,n=a.couponListState.couponIds;return e===!0||n.length===0?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-coupons`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.subscription_coupons.map((l=>l.subscription_coupon_id)),d=[ur({payload:o.data.subscription_coupons}),rb({couponIds:c})];return _(d)}return p(sb({status:o.status}))})),v((o=>p(sb({status:f("Unexpected error","Unable to fetch subscription coupons"+JSON.stringify(o))}))))):p(rb({couponIds:n}))}))),(s,i,r)=>s.pipe(S(QF.match),A((t=>{const{tenantId:e}=t.payload,a=i.value.subscriptionViewState.subscriptionUpdateViewDataByTenantId[e].data;if(a!=null){const{subscriptionPlanId:n,subscriptionAddOnIds:o,subscriptionCouponIds:c,startDate:d,invoiceImmediately:l}=a,u={subscriptionPlanId:n,subscriptionAddOnIds:o,subscriptionCouponIds:c,startDate:d,invoiceImmediately:l};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-create-estimate?query=${encodeURIComponent(JSON.stringify(p0(u,e,!0)))}`).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[WF({tenantId:e,subscriptionEstmiateData:m.data})];return _(h)}return p(nb({tenantId:e,status:m.status}))})),v((m=>p(nb({tenantId:e,status:f("Unexpected error","Unable to fetch subscription create estimate"+JSON.stringify(m))})))))}return _([])}))),(s,i,r)=>s.pipe(S(ZF.match),A((t=>{const{companyId:e,cacheOverride:a}=t.payload,{subscriptionViewState:n}=i.value,o=n.subscriptionDetailsByCompanyId[e],c=o!=null?o.subscriptionIds:[];return a===!0||c.length===0?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions?query=${encodeURIComponent(JSON.stringify({company_id:e}))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.subscriptions.map((m=>m.subscription_id)),u=[lr({payload:d.data.subscriptions,schema:d.data.schema.subscription}),_a({payload:d.data.subscription_plans,schema:d.data.schema.subscription_plan}),ur({payload:d.data.subscription_coupons,schema:d.data.schema.subscription_coupon}),ha({payload:d.data.subscription_addons,schema:d.data.schema.subscription_addon}),Sa({payload:d.data.subscription_summaries,schema:d.data.schema.subscription_summary}),ob({companyId:e,subscriptionIds:l})];return _(u)}return p(ib({companyId:e,status:d.status}))})),v((d=>p(ib({companyId:e,status:f("Unexpected error","fetch Subscription Details errored out"+JSON.stringify(d))}))))):p(ob({companyId:e,subscriptionIds:c}))}))),(s,i,r)=>s.pipe(S(pr.match),A((t=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/subscriptions?query=${encodeURIComponent(`{"is_full_response":${t.payload.fetchFullResponse}}`)}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.companies.map((d=>d.company_id)),n=(function(d,l){const u=bl(d),m={};return l.forEach((h=>{m[h]={subscriptionIds:u[h]??[],fetchStatus:{fetchState:"Completed",error:void 0}}})),m})(e.data.subscriptions,a),o=qo(e.data.user_roles,e.data.companies),c=[Y(e.data.user_roles),Q({payload:e.data.companies,schema:e.data.schema.company,subset:!1,companyIdTenantIdMapping:o}),lr({payload:e.data.subscriptions,schema:e.data.schema.subscription}),_a({payload:e.data.subscription_plans,schema:e.data.schema.subscription_plan}),ha({payload:e.data.subscription_addons,schema:e.data.schema.subscription_addon}),ur({payload:e.data.subscription_coupons,schema:e.data.schema.subscription_coupon}),Sa({payload:e.data.subscription_summaries,schema:e.data.schema.subscription_summary}),XF({companyIds:a,subscriptionDetailsByCompanyId:n})];return t.payload.fetchFullResponse===!0&&e.data.users!=null&&c.push(V({users:e.data.users})),_(c)}return p(cb(e.status))})),v((e=>p(cb(f("Unexpected error","fetch Subscription List errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(eq.match),A((t=>{const{cacheOverride:e}=t.payload,{subscriptionViewState:a}=i.value,n=a.planListState.planIds;return e===!0||n.length===0?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-plans`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.subscription_plans.map((l=>l.subscription_plan_id)),d=[_a({payload:o.data.subscription_plans}),db({planIds:c})];return _(d)}return p(lb({status:o.status}))})),v((o=>p(lb({status:f("Unexpected error","Unable to fetch subscription plans"+JSON.stringify(o))}))))):p(db({planIds:n}))}))),KG,(s,i,r)=>s.pipe(S(tq.match),A((t=>{const{tenantId:e}=t.payload,a=i.value.subscriptionViewState.subscriptionUpdateViewDataByTenantId[e].data;if(a!=null){const{subscriptionId:n,subscriptionEstmiate:o,subscriptionPlanId:c,subscriptionAddOnIds:d,subscriptionCouponIds:l,invoiceImmediately:u,applyEndOfTerm:m,shouldProrate:h}=a,g={subscriptionId:n,subscriptionEstmiate:o,subscriptionPlanId:c,subscriptionAddOnIds:d,subscriptionCouponIds:l,invoiceImmediately:u,applyEndOfTerm:m,shouldProrate:h};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-update-estimate?query=${encodeURIComponent(JSON.stringify(u0(g,e,!0)))}`).pipe(y((I=>{if(T(I)&&I.data!=null){const b=[aq({tenantId:e,subscriptionEstmiateData:I.data})];return _(b)}return p(ub({tenantId:e,status:I.status}))})),v((I=>p(ub({tenantId:e,status:f("Unexpected error","Unable to fetch subscription update estimate"+JSON.stringify(I))})))))}return _([])}))),(s,i)=>s.pipe(S(sO.match),A((r=>{const{cacheOverride:t,fetchFullResponse:e}=r.payload;if(t===!0)return _([pr(e),je()]);const a=i.value,n=[];return a.companyViewState.zeniUsers.fetchState==="In-Progress"||a.companyViewState.zeniUsers.hasValidState()||n.push(je()),a.subscriptionViewState.subscriptionListView.fetchState==="In-Progress"||a.subscriptionViewState.subscriptionListView.hasValidState()||n.push(pr(e)),_(n)}))),(s,i,r)=>s.pipe(S(bq.match),y((t=>{const{parentTaskId:e}=t.payload,a=JSON.stringify({task_type:"subtasks",parent_task_id:e});return r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent(a)}`).pipe(y((n=>{if(T(n)&&n.data!=null){const{tasks:o}=n.data,c=o.filter((d=>d.parent_task_id===e)).map((d=>d.task_id));return p(ze(o),Pq({parentTaskId:e,subTaskIds:c}),Eq({parentTaskId:e}))}return p(vb({parentTaskId:e,fetchState:"Error",error:n.status}))})),v((n=>p(vb({parentTaskId:e,fetchState:"Error",error:f("Unexpected Error","Fetch Sub Tasks REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(UT.match),y((t=>{const{pageContext:e,noCardCreated:a}=t.payload,n=new URLSearchParams({page_context:e});a===!0&&n.set("no_card_created","true");const o=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/suggested-questions?${n.toString()}`;return r.getJSON(o).pipe(y((c=>T(c)&&c.data!=null?p(kT({pageContext:e,generatedAt:c.data.generated_at,suggestedQuestions:c.data.suggested_questions})):p(Mu({pageContext:e,error:c.status})))),v((c=>p(Mu({pageContext:e,error:f("Unexpected Error","Fetch suggested questions REST API call failed",c instanceof Error?{message:c.message}:void 0)})))))}))),(s,i,r)=>s.pipe(S(Zd.match),y((t=>{const{taskId:e,cacheOverride:a}=t.payload,n=[],o=i.value,c=X(o.taskDetailState.editTaskStateById,e,void 0);if(a===!0&&n.push(Tq(e)),a===!0||c==null||c.fetchTaskStatus.fetchState!=="In-Progress"){n.push(za({taskId:e,fetchState:"In-Progress"}));const d=r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${e}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=[ze(l.data.tasks),za({taskId:e,fetchState:"Completed"}),Zr(l.data.tasks.map((h=>h.tags)).flat()),Ib(e)],m=l.data.tasks[0].file_ids;return m.length>0&&u.push(e_(m)),_(u)}{const u=[za({taskId:e,fetchState:"Error",error:l.status})];return l.status.message.includes("delete")?u.push(N({messageSection:"fetch_task_detail",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:"Cannot retrieve deleted task."}]})):u.push(N({messageSection:"fetch_task_detail",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:l.status.message}]})),_(u)}})),v((l=>(console.error(`REST API call errored out ${l}`),p(za({taskId:e,fetchState:"Error",error:f("Unexpected Error","Fetch Task detail REST API call errored out"+JSON.stringify(l))}))))));return j(_(n),d)}return _(n)}))),(s,i)=>s.pipe(S(Aq.match),y((r=>{const{cacheOverride:t,taskId:e}=r.payload,a=[],n=i.value;if(t===!0)a.push($e("taskManagerCandidate",!0)),a.push(se()),e!=null&&(a.push(Zd(e,!0)),a.push(Xd(e,!0)));else{const o=n.userListViewState.userListByType.taskManagerCandidate;o.hasValidState()===!1&&o.fetchState!=="In-Progress"&&a.push($e("taskManagerCandidate",!1)),n.classListState.hasValidState()===!1&&n.classListState.fetchState!=="In-Progress"&&a.push(se()),e!=null&&(a.push(Zd(e,!1)),a.push(Xd(e,!1)))}return j(_(a))}))),(s,i,r)=>s.pipe(S(al.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/templates`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[$q(t.data),Rq(t.data.templates)];return _(e)}{const e=[Tb(t.status)];return _(e)}})),v((t=>{const e=[Tb(f("Unexpected error","fetch task group templates REST API call errored out"+JSON.stringify(t)))];return _(e)})))))),(s,i,r)=>s.pipe(S(Xd.match),y((t=>{const{taskId:e,cacheOverride:a}=t.payload,n=[],o=i.value,c=X(o.taskDetailState.taskHistoryById,e,void 0);if(a===!0||c==null||c.fetchState!=="In-Progress"){n.push(el({taskId:e,fetchState:"In-Progress"}));const d=r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${e}/history`).pipe(y((l=>T(l)&&l.data!=null?p(Nq({taskId:e,historicEventsPayload:l.data.activities})):p(el({taskId:e,fetchState:"Error",error:l.status})))),v((l=>p(el({taskId:e,fetchState:"Error",error:f("Unexpected Error","Fetch Task history REST API call errored out"+JSON.stringify(l))})))));return j(_(n),d)}return _(n)}))),(s,i,r)=>s.pipe(S(Nt.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent('{"task_type": "all"}')}`).pipe(y((t=>{if(T(t)&&t.data!=null){const{tasks:e,deleted:a,archived:n,snoozed:o,completed:c}=t.data,d=[...e,...c??[],...a??[],...n??[],...o??[]];return p(ze(d),Qq({data:e,completed:c??[],deleted:a??[],archived:n??[],snoozed:o??[]}),Zr(d.map((l=>l.tags)).flat()))}return p(kb({fetchState:"Error",error:t.status}))})),v((t=>p(kb({fetchState:"Error",error:f("Unexpected Error","Fetch Task List REST API call errored out"+JSON.stringify(t))})))))))),(s,i)=>s.pipe(S(Wq.match),y((r=>{const{cacheOverride:t,isTaskTemplatesEnabled:e}=r.payload,a=[],n=i.value;if(t===!0)a.push(Nt(),se(),$e("taskManagerCandidate",!0),Hd(),sl()),e===!0&&a.push(al());else{n.taskListState.fetchState!=="In-Progress"&&n.taskListState.hasValidState()===!1&&a.push(Nt()),n.classListState.hasValidState()===!1&&n.classListState.fetchState!=="In-Progress"&&a.push(se());const o=n.userListViewState.userListByType.taskManagerCandidate;o.hasValidState()===!1&&o.fetchState!=="In-Progress"&&a.push($e("taskManagerCandidate",!1)),n.tagViewState.hasValidState()===!1&&n.tagViewState.fetchState!=="In-Progress"&&a.push(Hd()),n.taskGroupViewState.hasValidState()===!1&&n.taskGroupViewState.fetchState!=="In-Progress"&&a.push(sl()),e===!0&&n.taskGroupTemplateViewState.hasValidState()===!1&&n.taskGroupTemplateViewState.fetchState!=="In-Progress"&&a.push(al())}return j(_(a))}))),(s,i,r)=>s.pipe(S(ON.match),A((()=>{const t=JSON.stringify({is_filter_by_logged_in_user:!0,include_subtasks:!0});return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/tasks-es-metrics?query=${encodeURIComponent(t)}`).pipe(y((e=>T(e)&&e.data!=null?p(CN(e.data.summary)):p(rm()))),v((()=>p(rm()))))}))),(s,i,r)=>s.pipe(S(ss.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/task_card`).pipe(y((t=>T(t)?p(ej(t.data)):p(Db(t.status)))),v((t=>p(Db(f("Unexpected Error","Tasks card REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Ko.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/top_expenses`).pipe(y((t=>T(t)?p(W(t.data?.report.accounts??[],"top_expenses"),tj(t.data)):p(Jb(t.status)))),v((t=>p(Jb(f("Unexpected error","TopEx REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(aj.match),A((t=>{const{qboId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${e}/activity`).pipe(y((a=>{if(T(a)&&a.data!=null&&a.data.activity!=null){const n=[];return a.data.users!=null&&a.data.users.length>0&&n.push(V({users:a.data.users,updateType:"merge"})),n.push(rj(a.data.activity)),n.push(sj({data:a.data.activity,qboId:e})),_(n)}return p(wb({fetchState:"Error",error:a.status,qboId:e}))})),v((a=>p(wb({qboId:e,fetchState:"Error",error:f("Unexpected Error","fetch transaction activity log REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(Fb.match),y((t=>{const{transactionId:e,cacheOverride:a}=t.payload,n=Be(e),o=[];if(a===!0){const d=At(i.value.transactionState,n);o.push(...(function(l,u){const m=[];return m.push($l(l)),u!=null&&(m.push(wl(Be(l))),qb(u).forEach((h=>{m.push($l(h)),m.push(wl(Be(h)))}))),m})(e,d))}const c=X(i.value.transactionDetailState.transactionDetailById,n,void 0);if(a===!0||c==null||c.hasValidState()===!1&&c.fetchState!=="In-Progress"){const d=i.value.accountListState.byReportId.accountList;d.hasValidState()===!1&&d.fetchState!=="In-Progress"&&o.push(be("accountList"));const l=i.value.classListState;l.hasValidState()===!1&&l.fetchState!=="In-Progress"&&o.push(se());const u=i.value.projectListState;u.hasValidState()===!1&&u.fetchState!=="In-Progress"&&o.push(_i()),o.push(Bn(e,"In-Progress"));const m={transaction_type:e.type},h=r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${e.id}?query=${encodeURIComponent(JSON.stringify(m))}`).pipe(y((g=>{if(T(g)&&g.data?.transaction?.transaction_id!=null){const I=[],b=Is(g.data.transaction),E={...g.data,vendors:g.data.vendors?.map((O=>({...O,vendor_id:O.qbo_id??O.vendor_id})))??[]};E.vendors.length>0&&I.push(le(E.vendors,"merge"));const P=Be(b);return I.push(va(P,E.transaction)),I.push(bs({transactionId:b,vendorId:E.vendors[0]?.vendor_id})),I.push(Bn(b,"Completed")),I.push(...(function(O,C){const U=[],B=yj(O),x=qb(B).filter((k=>(function(J,L){const R=Be(J),q=L.transactionDetailState.transactionDetailById[R];return q!=null&&(q.hasValidState()===!0||q.fetchState==="In-Progress")})(k,C)===!1));return x.forEach((k=>U.push(Fb(k,!1)))),x.length===0&&console.log("Phew all linked transactions are fetched or there are no linked transactions.."),U})(E.transaction,i.value)),E.vendors.length>0&&I.push(ls({vendorId:E.vendors[0].vendor_id,localData:bE(or(E.vendors[0]))})),g0(E.transaction.transaction_type)!=null&&I.push(ct()),_(I)}return p(Bn(t.payload.transactionId,"Error",g.status))})),v((g=>(console.error(`REST API call errored out ${g}`),p(Bn(t.payload.transactionId,"Error",f("Unexpected Error",`REST API call errored out ${g}`)))))));return j(_(o),h)}return _(o)}))),(s,i,r)=>s.pipe(S(vj.match),y((t=>{const e=i.value,a=Ij(t.payload.accountId,t.payload.accountType,t.payload.period),n=X(e.transactionListState.byAccount.transactionListByAccountKey,a,void 0);if(t.payload.cacheOverride===!0||n==null||n.hasValidState()===!1){const o={start_date:ae(t.payload.period.start),end_date:ae(t.payload.period.end),sort_by:"transaction_date",sort_order:"desc",account_id:t.payload.accountId,account_type:t.payload.accountType,account_name:t.payload.accountName};t.payload.includeSubAccountTransactions===!1&&(o.include_sub_account_transactions=t.payload.includeSubAccountTransactions);const c=ds(t.payload.accountId);return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${c}/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(Ce(d.data.account.transactions,(u=>u.transaction_id))),l.push(bj(d.data)),_(l)}return p(jb(t.payload.accountId,t.payload.accountType,t.payload.period,d.status))})),v((d=>p(jb(t.payload.accountId,t.payload.accountType,t.payload.period,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(d)))))))}return _([])}))),(s,i,r)=>s.pipe(S(Gb.match),y((t=>{const e=i.value,a=zb(t.payload.accountId,t.payload.accountType,t.payload.classId,t.payload.period),n=X(e.transactionListState.byClass.transactionListByClassKey,a,void 0);if(t.payload.cacheOverride===!0||n==null||n.hasValidState()===!1){const o={start_date:ae(t.payload.period.start),end_date:ae(t.payload.period.end),sort_by:"create_time",sort_order:"desc",account_id:t.payload.accountId,account_type:t.payload.accountType,accounting_class_id:t.payload.classId,include_sub_class_transactions:!1},c=ds(t.payload.accountId);return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${c}/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(Ce(d.data.account.transactions,(u=>u.transaction_id))),l.push(Ej(d.data)),_(l)}return p(Kb(t.payload.accountId,t.payload.accountType,t.payload.classId,t.payload.period,d.status))})),v((d=>p(Kb(t.payload.accountId,t.payload.accountType,t.payload.classId,t.payload.period,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(d)))))))}return _([])}))),(s,i,r)=>s.pipe(S(Yb.match),y((t=>{const e=i.value,a=Hb(t.payload.entity,t.payload.period),n=X(e.transactionListState.byEntity.transactionListByEntityKey,a,void 0);if(t.payload.cacheOverride===!0||n==null||n.hasValidState()===!1){const o={start_date:ae(t.payload.period.start),end_date:ae(t.payload.period.end),sort_by:"create_time",sort_order:"desc",entity_id:t.payload.entity.id,entity_name:t.payload.entity.name,entity_type:t.payload.entity.type,is_fetch_all_transactions:t.payload.isFetchAllTransactions===!0?t.payload.isFetchAllTransactions:null};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[];return d.push(Ce(c.data.transactions,(l=>l.transaction_id))),d.push(Pj(c.data)),_(d)}return p(Qb(t.payload.entity,t.payload.period,c.status))})),v((c=>p(Qb(t.payload.entity,t.payload.period,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(c)))))))}return _([])}))),(s,i,r)=>s.pipe(S(Wb.match),y((t=>{const e=i.value,a=Zb(t.payload.accountId,t.payload.accountType,t.payload.projectId,t.payload.period),n=X(e.transactionListState.byProject.transactionListByProjectKey,a,void 0);if(t.payload.cacheOverride===!0||n==null||n.hasValidState()===!1){const o={start_date:ae(t.payload.period.start),end_date:ae(t.payload.period.end),sort_by:"create_time",sort_order:"desc",account_id:t.payload.accountId,account_type:t.payload.accountType,accounting_project_id:t.payload.projectId},c=ds(t.payload.accountId);return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${c}/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(Ce(d.data.account.transactions,(u=>u.transaction_id))),l.push(Tj(d.data)),_(l)}return p(Xb(t.payload.accountId,t.payload.accountType,t.payload.projectId,t.payload.period,d.status))})),v((d=>p(Xb(t.payload.accountId,t.payload.accountType,t.payload.projectId,t.payload.period,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(d)))))))}return _([])}))),(s,i)=>s.pipe(S(Jj.match),y((r=>{const{entity:t,screen:e,selectedPeriod:a,fiscalYearStartMonth:n}=r.payload,o=[];return o.push(rE(t,ua(a.timePeriod),!1,n)),o.push(wj(t,e,a)),_(o)}))),(s,i,r)=>s.pipe(S(eE.match),y((t=>{const e=i.value,{transactionCategoryType:a,period:n,cacheOverride:o,minimumTransactionAmount:c}=t.payload,d=tE(a,n),l=X(e.transactionListState.byType[a].transactionListByCategoryType,d,void 0);if(o===!0||l==null||l.hasValidState()===!1){const u={start_date:ae(n.start),end_date:ae(n.end),sort_by:"transaction_date",sort_order:"desc"};return a==="missingReceipts"&&(u.is_attachment_missing_only=!0),a!=="miscategorizedExpense"&&a!=="miscategorizedIncome"||(u.type="miscategorized",u.account_type=a==="miscategorizedExpense"?"expenses":"income"),a!=="uncategorizedIncome"&&a!=="uncategorizedExpense"||(u.type="uncategorized",u.account_type=a==="uncategorizedExpense"?"expenses":"income"),c!=null&&(u.total_amount_min=c.amount),r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions?query=${encodeURIComponent(JSON.stringify(u))}`).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[];return h.push(Ce(m.data.transactions,(g=>g.transaction_id))),h.push(Aj(a,n,m.data.transactions)),_(h)}return p(aE(a,n,m.status))})),v((m=>p(aE(a,n,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(m)))))))}return _([])}))),(s,i,r)=>s.pipe(S(gO.match),ar((t=>t.payload.kind)),y((t=>t.pipe(A((e=>{const{kind:a}=e.payload,n=kz[a],o=Uz[a],c=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify(n))}`;return r.getJSON(c).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.accounts.map((m=>m.account_id)),u=[W(d.data.accounts,o),fO({accountIds:l,kind:a})];return p(...u)}return p(Um({kind:a}))})),v((()=>p(Um({kind:a})))))})))))),(s,i,r)=>s.pipe(S(Af.match),A((t=>{const{cacheOverride:e,fetchOnlySummary:a}=t.payload,n=i.value,o=[];if(e===!0)o.push(kd()),o.push(Bd()),o.push(Dd(!0)),o.push(Jd(!0)),o.push(wd()),o.push($d(!0));else if(a!==!0){const c=n.treasuryStatementListState;c.hasValidState()===!1&&c.fetchState!=="In-Progress"&&o.push(Dd(!1));const d=n.treasuryTaxLetterListState;d.hasValidState()===!1&&d.fetchState!=="In-Progress"&&o.push(Jd(!1));const l=n.treasuryDetailState;l.hasValidState()===!1&&l.fetchState!=="In-Progress"&&o.push(wd());const u=l.transactionsState;u.fetchState!=="Completed"&&u.fetchState!=="In-Progress"&&o.push($d(!1,5));const m=n.treasurySetupViewState;m.treasuryFundsDetails.fetchStatus.fetchState!=="In-Progress"&&o.push(kd()),m.currentAllocation.fetchStatus.fetchState!=="In-Progress"&&o.push(Bd())}return r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account?query=${encodeURIComponent('{"is_summary":true}')}`).pipe(y((c=>T(c)?j(p(mF({data:c})),_(o)):j(p(BI({error:c.status})),_(o)))),v((c=>j(p(BI({error:f("Unexpected Error","Fetch treasury summary REST API call errored out "+JSON.stringify(c))})),_(o)))))}))),(s,i,r)=>s.pipe(S(kd.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury/funds`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[fF(t.data)];return _(e)}return p(RI({error:t.status}))})),v((t=>p(RI({error:f("Unexpected Error","Fetch treasury funds REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(wd.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/balance/time-series`).pipe(y((t=>T(t)?p(yF({data:t})):p(DI({fetchState:"Error",error:t.status})))),v((t=>p(DI({fetchState:"Error",error:f("Unexpected Error","Fetch treasury account history REST API call errored out "+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(vF.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{treasurySetupViewState:o,plaidAccountViewState:c,companyState:d}=i.value,l=Te(d,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"treasury_accounts_setup"}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=u.data.accounts?.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses??[]),ve({files:u.data.files??[]}),W(u.data.accounts??[],"zeni_treasury"),Se(u.data.payment_accounts??[]),Ht({data:u.data.payment_accounts??[],updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"replace"}),we({companyId:u.data.companies[0].company_id}),rt(m,"treasury_setup"),MI()];return _(h)}return p(N({messageSection:"treasury_setup",messageText:"failed",type:"error"}),VI(u.status))})),v((u=>p(VI(f("Unexpected Error","Fetch Treasury Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=c.spend_management_setup.accountDetails;return p(we({companyId:e}),rt(u,"treasury_setup"),MI())}}))),(s,i,r)=>s.pipe(S(Dd.match),y((t=>{const{cacheOverride:e}=t.payload,a=i.value.treasuryStatementListState.fetchState;if(e===!0||a!=="Completed"){const n={statement_type:"monthly_statement"},o=`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/statements?query=${encodeURIComponent(JSON.stringify(n))}`;return r.getJSON(o).pipe(y((c=>T(c)?p(EF({data:c.data?.statements??[]})):p(Rd({fetchState:"Error",error:c.status})))),v((c=>p(Rd({fetchState:"Error",error:f("Unexpected Error","Fetch treasury Account statement REST API call errored out "+JSON.stringify(c))})))))}return p(Rd({fetchState:"Completed",error:void 0}))}))),(s,i,r)=>s.pipe(S(Jd.match),y((t=>{const{cacheOverride:e}=t.payload,a=i.value.treasuryTaxLetterListState.fetchState;if(e===!0||a!=="Completed"){const n={statement_type:"tax_statement"},o=`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/statements?query=${encodeURIComponent(JSON.stringify(n))}`;return r.getJSON(o).pipe(y((c=>T(c)?p(PF({data:c.data?.statements??[]})):p(Md({fetchState:"Error",error:c.status})))),v((c=>p(Md({fetchState:"Error",error:f("Unexpected Error","Fetch treasury tax letter REST API call errored out "+JSON.stringify(c))})))))}return p(Md({fetchState:"Completed",error:void 0}))}))),(s,i,r)=>s.pipe(S($d.match),A((t=>{const{cacheOverride:e}=t.payload,a={start_date:"2022-01-01",end_date:"2030-12-31"};return e===!0?r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/transactions?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>T(n)?p(_F({transactionList:n.data?.transactions??[]})):p(JI({error:n.status})))),v((n=>p(JI({error:f("Unexpected Error","Fetch treasury transactions REST API call errored out"+JSON.stringify(n))}))))):_([])}))),(s,i)=>s.pipe(S(Bo.match),y((r=>{const{entity:t}=r.payload;return t.type==="customer"?p(nE(t.id,t.name)):t.type==="vendor"?p(sE(t.id,t.name,t.zeniId)):_([])}))),(s,i,r)=>s.pipe(S(kp.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user/self`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[XA()];return t.data.users.length>0&&e.push(V({users:t.data.users})),_(e)}return p(Bp(t.status))})),v((t=>p(Bp(f("Unexpected error","Unable to fetch user details"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(yd.match),A((t=>{const{userId:e,reimbursementId:a}=t.payload;return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/users/${e}/financial-accounts`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[],c=vY(n.data.bank_accounts)?.bank_account_id;return o.push(Je(n.data.bank_accounts),$j({userFinancialAccount:n.data}),Se(n.data.payment_accounts)),a==null&&o.push(rr({bankAccountId:c,shouldOverWriteCurrentBankAccountId:!1})),_(o)}return p(oE({status:n.status,userId:e}))})),v((n=>p(oE({userId:e,status:f("Unexpected Error","Fetch User Financial Account REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S($e.match),y((t=>{const{userType:e,cacheOverride:a}=t.payload,n=i.value,o=n.userListViewState.userListByType[e],c=H(n),d=Rj(c);if(a===!0||a===!1&&o.hasValidState()===!1){let l=`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/users`;const u=IY(e,d);return l+=`?query=${encodeURIComponent(JSON.stringify(u))}`,r.getJSON(l).pipe(y((m=>{if(T(m)){const h=[V({users:m.data?.users??[]}),Y(m.data?.user_roles??[]),If({userType:e,usersPayload:m.data?.users??[]})];return m.data?.user_groups!=null&&(h.push(em({userGroups:m.data.user_groups})),e==="taskManagerCandidate"&&h.push(Mj({userGroupType:e,userGroupsPayload:m.data.user_groups}))),e==="cardHolderCandidate"&&(h.push(Qv(m.data?.cards_count_by_user_id??[])),h.push(Wv(m.data?.debit_cards_count_by_deposit_account_id??{})),h.push(z(m.data?.addresses??[]))),j(_(h))}return p(iE({userType:e,status:m.status}))})),v((m=>p(iE({userType:e,status:f("Unexpected error","User REST API call errored out"+JSON.stringify(m))})))))}return _([])}))),(s,i,r)=>s.pipe(S(Vj.match),A((t=>{const{cacheOverride:e}=t.payload;return e===!0?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/config`).pipe(y((a=>T(a)?_([Lj(a),Fj({countryListKey:"nationalityCountryList",countryListPayload:a.data?.nationality??[]})]):p(cE(a.status)))),v((a=>p(cE(f("Unexpected Error","Fetch user-roles config REST API call errored out"+JSON.stringify(a))))))):[]}))),(s,i,r)=>s.pipe(S(io.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/1099-config`).pipe(y((t=>T(t)?p(qj(t)):p(dE(t.status)))),v((t=>p(dE(f("Unexpected Error","Fetch vendor 1099 types REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(n1.match),y((r=>{const t=[],{vendorId:e,cacheOverride:a}=r.payload,n=i.value;let o=n.editBillDetailViewState.newBillState;if(r.payload.billId!=null){const c=Ne(r.payload.billId);o=n.editBillDetailViewState.editBillStateById[c]}if(e!=null){const c=Oe(n.vendorState,e);c!=null&&a===!1?(c.vendorCurrencyCode==null||Uo(c.vendorCurrencyCode)||t.push(ya(!0,{amount:o.billDetailLocalData.totalAmount?.amount??0,currencyCode:c.vendorCurrencyCode??"USD",currencySymbol:c.vendorCurrencySymbol??"$"},"USD",r.payload.billId)),t.push(lt({billDetailLocalData:Bl(n,o,c),billId:r.payload.billId})),t.push(aa(c.qboId,!1))):t.push(ys(e),nv(e,r.payload.billId))}else t.push(lt({billDetailLocalData:Bl(n,o),billId:r.payload.billId}));return _(t)}))),(s,i)=>s.pipe(S(o1.match),y((r=>{const t=[],{invoiceProcessingPayload:e,isVendorRecommendationFeatureEnabled:a,billId:n}=r.payload,o=e.vendors.length>0?e.vendors[0].vendor_name??"":"",c=Nc(i.value);return c.vendors.map((d=>d.name.toLowerCase())).includes(o.toLowerCase())===!0||o.length===0?t.push(Oc(e,a,n)):c.fetchStateBillsTab.fetchState!=="In-Progress"&&t.push(wt({searchString:o,billId:n}),ov(e,a,n)),_(t)}))),(s,i)=>s.pipe(S(zA.match),A((r=>{const t=[],e=i.value;if(r.payload.cacheOverride===!0)t.push(be("accountList",!0)),t.push(se()),t.push(He()),t.push(ct()),r.payload.vendorId!=null?t.push(ys(r.payload.vendorId,!1,r.payload.signal)):t.push(wt({}));else{const a=i.value.accountListState.byReportId.accountList;a.hasValidState()===!1&&a.fetchState!=="In-Progress"&&t.push(be("accountList",!0));const n=i.value.classListState;if(n.hasValidState()===!1&&n.fetchState!=="In-Progress"&&t.push(se()),e.vendorTypeListState.hasValidState()===!1&&e.vendorTypeListState.fetchState!=="In-Progress"&&t.push(He()),e.ownerListState.fetchState!=="In-Progress"&&e.ownerListState.hasValidState()===!1&&t.push(ct()),r.payload.vendorId!=null){const o=i.value.vendorViewState.editVendorStateById[r.payload.vendorId].fetchStatus;o.fetchState!=="Completed"&&o.fetchState!=="In-Progress"&&t.push(ys(r.payload.vendorId,!1,r.payload.signal))}else{const o=i.value.vendorListState;(o.fetchStateBillsTab.fetchState!=="Completed"&&o.fetchStateBillsTab.fetchState!=="In-Progress"||o.allVendorIdsBillsTab.length===0)&&t.push(wt({}))}}return j(_(t))}))),(s,i,r)=>s.pipe(S(ys.match),A((t=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${t.payload.vendorId}`,{},t.payload.signal).pipe(y((e=>{if(T(e)){const a=e.data?.vendors[0],n=a?.contacts??[],o=dt(e.data?.vendors??[]),c=a?.bank_accounts??[],d=a?.payment_instruments??[],l=a?.account!=null?[a?.account]:[],u=a?.accounting_class!=null?[a?.accounting_class]:[],m=[le(e.data?.vendors??[]),W(l,"account_list"),Ke("class_list",u),mt(n),z(o),Je(c),la(d),ve({files:a?.documents??[]}),Op({vendorId:t.payload.vendorId,isCreatable:t.payload.isCreatable}),_s(t.payload.vendorId)];return a!=null&&m.push(nr({vendorId:t.payload.vendorId,localData:wn(or(a),i.value,a),isCreatable:t.payload.isCreatable})),m.push(xo("Completed",t.payload.vendorId,void 0,t.payload.isCreatable)),m.push(Cp()),_(m)}return p(xo("Error",t.payload.vendorId,e.status,t.payload.isCreatable))})),v((e=>p(xo("Error",t.payload.vendorId,f("Unexpected Error","Fetch vendor REST API call errored out: "+JSON.stringify(e)),t.payload.isCreatable)))))))),(s,i,r)=>s.pipe(S(eG.match),A((t=>{const{attachmentIds:e,vendorId:a}=t.payload;let n=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${a}/attachments`;return n+=`?query=${encodeURIComponent(JSON.stringify({attachment_ids:e}))}`,r.getJSON(n).pipe(A((c=>{if(T(c)&&c.data!=null){const d=[];return d.push(tG({vendorId:a,transactionAttachments:c.data.transaction_attachments})),d}return p(pE({status:c.status}))})),v((c=>p(pE({status:f("Unexpected Error","Fetch Vendor First Review View REST API call errored out"+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(aG.match),A((t=>{let e=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors`;const{searchString:a,keepExistingListItems:n,pageToken:o}=t.payload,{uiState:c}=i.value.vendorFirstReviewViewState,d=c.sortOrder==="ascending"?"asc":c.sortOrder==="descending"?"desc":null,l={view:"merchant_review_list",page_token:o,sort_by:EY(c.sortKey),sort_order:d??null,search_text:a??null};return e+=`?query=${encodeURIComponent(JSON.stringify(l))}`,r.getJSON(e).pipe(A((u=>{if(T(u)&&u.data!=null){const m=[];return m.push(le(Fn(u.data.vendors)),V({users:qn(u.data.vendors),updateType:"merge"}),It({globalMerchants:jn(u.data.vendors)}),rG({response:u.data,keepExistingListItems:n})),m}return p(mE({status:u.status}))})),v((u=>p(mE({status:f("Unexpected Error","Fetch Vendor First Review View REST API call errored out"+JSON.stringify(u))})))))}))),(s,i,r)=>s.pipe(S(uG.match),A((t=>{const{keepExistingListItems:e}=t.payload,{uiState:a}=i.value.vendorGlobalReviewViewState,{searchText:n,sortOrder:o,pageToken:c,limit:d}=a,l=o==="ascending"?"asc":o==="descending"?"desc":null,u={page_token:c,sort_by:UY(a.sortKey),sort_order:l,search_text:n,limit:d??null};return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/reviews/global-merchant-list?query=${encodeURIComponent(JSON.stringify(u))}`).pipe(A((m=>{if(T(m)&&m.data!=null){const h=[];return h.push(V({users:CY(m.data.merchants),updateType:"merge"}),pG({tenantMerchants:m.data.merchants}),It({globalMerchants:xY(m.data.merchants)}),mG({globalMerchantsPayload:m.data.merchants,keepExistingListItems:e}),yG(m.data.query,m.data.total_count)),h}return p(hE({status:m.status}))})),v((m=>p(hE({status:f("Unexpected Error","Fetch Vendor Global Review View REST API call errored out"+JSON.stringify(m))})))))}))),(s,i)=>s.pipe(S(jj.match),A((r=>{const t=i.value,e=[];return r.payload.cacheOverride,t.vendor1099TypeListState.hasValidState()===!1&&t.vendor1099TypeListState.fetchState!=="In-Progress"&&e.push(io()),e.push(mu()),e.push(il()),j(_(e))}))),(s,i,r)=>s.pipe(S(Gj.match),A((t=>{const e={type_1099:t.payload.type1099,report_id:"vendor_1099"},a=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendor-1099/download?query=${encodeURIComponent(JSON.stringify(e))}`;return r.getJSON(a).pipe(A((n=>{if(T(n)&&n.data!=null){const o=[];return o.push(cl({response:n.data,downloadState:{fetchState:"Completed",error:void 0}})),o}return p(cl({response:lE.vendorFiling1099DownloadData,downloadState:{fetchState:"Error"}}))})),v((n=>p(cl({response:lE.vendorFiling1099DownloadData,downloadState:{fetchState:"Error",error:{code:500,message:"Fetch vendors 1099 Download REST API call errored out"+JSON.stringify(n)}}})))))}))),(s,i,r)=>s.pipe(S(il.match),A((()=>{const t=`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/vendor_1099`;return r.getJSON(t).pipe(A((e=>{if(T(e)&&e.data!=null){const a=[];return a.push(...(function(n){const o=[],c=dt(n);return o.push(le(n,"merge"),z(c)),o})(e.data.report.vendors??[]),zj({response:e})),a.push(He()),a}return p(uE({status:e.status}))})),v((e=>p(uE({status:f("Unexpected Error","Fetch vendors 1099 list REST API call errored out"+JSON.stringify(e))})))))}))),(s,i,r)=>s.pipe(S(wt.match),A((t=>{let e=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors`;const{searchString:a,keepExistingListItems:n,view:o,pageToken:c,billId:d}=t.payload,{uiState:l}=i.value.vendorListState,u={view:bY(o),page_token:c,sort_by:l.sortKey,sort_order:l.sortOrder==="ascending"?"asc":l.sortOrder==="descending"?"desc":void 0,search_text:a,vendor_name:a};return e+=`?query=${encodeURIComponent(JSON.stringify(u))}`,r.getJSON(e).pipe(A((m=>{if(T(m)){const h=[];return m.data?.vendors?.[0]?.vendor_id!=null&&o==null&&h.push(Qj({vendorId:m.data?.vendors?.[0].vendor_id,billId:d})),h.push(...(function(g,I){const b=[],E=g.length>0?Wj(g):[],P=dt(g),O=g.length>0?gs(g):[],C=g.length>0?Zj(g):[],U=g.filter((J=>J.account!=null)).map((J=>J.account)),B=g.filter((J=>J.accounting_class!=null)).map((J=>J.accounting_class)),x=g.filter((J=>J.owner!=null)).map((J=>J.owner)),k=g.length>0?Xj(g):[];return b.push(le(g,I==="vendorsTab"?"merge":"replace"),W(U,"account_list"),Ke("class_list",B),mt(E),z(P),Je(O),la(C),ve({files:k}),V({users:x,updateType:"merge"})),b})(m.data?.vendors??[],o),hc({response:m,keepExistingListItems:n,searchString:a??"",view:o})),h}return p(Cc({status:m.status,view:o}))})),v((m=>p(Cc({status:f("Unexpected Error","Fetch vendors list REST API call errored out"+JSON.stringify(m)),view:o})))))}))),(s,i)=>s.pipe(S(tN.match),A((r=>{const{vendorId:t,entity:e,cacheOverride:a}=r.payload,n=[];if(a===!0)n.push(ko(t,!1),Bo(e),He());else{const o=i.value,c=o.vendorViewState.editVendorStateById[t]?.fetchStatus??{fetchState:"Not-Started"};o.vendorTypeListState.hasValidState()===!1&&o.vendorTypeListState.fetchState!=="In-Progress"&&n.push(He()),!(c.fetchState==="Completed"||c.fetchState==="In-Progress")&&n.push(ko(t,!1)),n.push(Bo(e))}return _(n)}))),(s,i)=>s.pipe(S(ko.match),A((r=>{const t=[],e=i.value;if(r.payload.cacheOverride===!0)t.push(be("accountList",!0)),t.push(se()),t.push(He()),t.push(ct()),r.payload.vendorId!=null?t.push(Do(r.payload.vendorId)):t.push(wt({}));else{const a=i.value.accountListState.byReportId.accountList;a.hasValidState()===!1&&a.fetchState!=="In-Progress"&&t.push(be("accountList",!0));const n=i.value.classListState;n.hasValidState()===!1&&n.fetchState!=="In-Progress"&&t.push(se()),e.ownerListState.fetchState!=="In-Progress"&&e.ownerListState.hasValidState()===!1&&t.push(ct());const o=i.value.vendorsTabVendorViewState.vendorStateById[r.payload.vendorId].fetchStatus;o.fetchState!=="Completed"&&o.fetchState!=="In-Progress"&&t.push(Do(r.payload.vendorId))}return j(_(t))}))),(s,i,r)=>s.pipe(S(Do.match),A((t=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${t.payload.vendorId}`).pipe(y((e=>{if(T(e)){const a=e.data?.vendors[0],n=a?.contacts??[],o=dt(e.data?.vendors??[]),c=gs(e.data?.vendors??[]),d=a?.account!=null?[a?.account]:[],l=a?.accounting_class!=null?[a?.accounting_class]:[],u=[le(e.data?.vendors??[]),W(d,"account_list"),Ke("class_list",l),mt(n),z(o),Je(c),ve({files:a?.documents??[]}),Jo("Completed",t.payload.vendorId,void 0),aN({vendorId:t.payload.vendorId}),_s(t.payload.vendorId)];return a!=null&&u.push(Dp({vendorId:t.payload.vendorId,localData:Jp(or(a),i.value,a)})),_(u)}return p(Jo("Error",t.payload.vendorId,e.status))})),v((e=>p(Jo("Error",t.payload.vendorId,f("Unexpected Error","Fetch vendors tab REST API call errored out"+JSON.stringify(e)))))))))),(s,i)=>s.pipe(S(SG.match),A((r=>{const{shouldFetchAccruedExpenses:t,shouldFetchFixedAssets:e,shouldFetchOpexByVendor:a,shouldFetchPrepaidExpenses:n,shouldFetchVendorsList:o,shouldFetchFiling1099Vendor:c}=r.payload,d=i.value,l=[],u=gG(d),m=_l(d,"fixed_assets"),h=_l(d,"prepaid_expenses"),g=_l(d,"accrued_expenses"),I=fG(d).fetchState,b=Nc(d,"vendorsTab").fetchState;t===!0&&u==="Completed"&&g!=="In-Progress"&&g!=="Completed"&&l.push(sf("accrued_expenses",{selectedTimeframe:dn("accrued_expenses"),selectedCategoryId:"all"}));const E=vG(d).fetchState;return e===!0&&u==="Completed"&&m!=="In-Progress"&&m!=="Completed"&&l.push(oc("fixed_assets",{selectedTimeframe:dn("fixed_assets"),selectedCategoryId:"all"})),n===!0&&u==="Completed"&&h!=="In-Progress"&&h!=="Completed"&&l.push(oc("prepaid_expenses",{selectedTimeframe:dn("prepaid_expenses"),selectedCategoryId:"all"})),a&&I!=="In-Progress"&&I!=="Completed"&&l.push(ZS()),o&&b!=="In-Progress"&&b!=="Completed"&&l.push(wt({searchString:"",keepExistingListItems:!1,view:"vendorsTab"})),c&&E!=="In-Progress"&&E!=="Completed"&&l.push(il()),_(l)}))),(s,i,r)=>s.pipe(S(He.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendor/config`).pipe(y((t=>T(t)?p(IG(t)):p(SE(t.status)))),v((t=>p(SE(f("Unexpected Error","Fetch vendor types REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(qF.match),y((r=>{const{cacheOverride:t}=r.payload,e=[],a=i.value;if(t===!0)e.push(ke()),e.push(Ge()),e.push(Xt());else{const n=a.depositAccountListState,o=a.zeniAccountListState;(n.hasValidState()===!1&&n.fetchState!=="In-Progress"||o.summary==null)&&e.push(ke());const c=a.paymentAccountListState;c.hasValidState()===!1&&c.fetchState!=="In-Progress"&&e.push(Ge());const d=a.zeniAccountsConfigState;d.hasValidState()===!1&&d.fetchState!=="In-Progress"&&e.push(Xt())}return j(_(e))}))),(s,i,r)=>s.pipe(S(Xt.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/baas/config`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[z([t.data.mailing_address,t.data.bank_address]),KF(t.data)];return _(e)}return p(eb({error:t.status}))})),v((t=>p(eb({error:f("Unexpected Error","Fetch Zeni Accounts config REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(zF.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{zeniAccountSetupViewState:o,plaidAccountViewState:c,companyState:d}=i.value,l=Te(d,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"deposit_accounts_setup"}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=u.data.accounts?.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses??[]),ve({files:u.data.files??[]}),W(u.data.accounts??[],"zeni_accounts"),Se(u.data.payment_accounts),Ht({data:u.data.payment_accounts,updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"replace"}),we({companyId:u.data.companies[0].company_id}),rt(m,"account_setup"),ZI()];return _(h)}return p(N({messageSection:"zeni_accounts_setup",messageText:"failed",type:"error"}),XI(u.status))})),v((u=>p(XI(f("Unexpected Error","Fetch Zeni Account Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=c.spend_management_setup.accountDetails;return p(we({companyId:e}),rt(u,"account_setup"),ZI())}}))),(s,i,r)=>s.pipe(S(Cn.match),y((t=>{const{depositAccountId:e}=t.payload,a=e==="zeni-clearing-account"?`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/zeni-clearing-account/statements`:`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}/statements`;return r.getJSON(a).pipe(y((n=>T(n)?p(bG({depositAccountId:e,data:n.data?.statements??[]})):p(gE({depositAccountId:e,fetchState:"Error",error:n.status})))),v((n=>p(gE({depositAccountId:e,fetchState:"Error",error:f("Unexpected Error","Fetch deposit Account satement REST API call errored out"+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(EG.match),y((r=>{const{cacheOverride:t,depositAccountId:e}=r.payload,a=[],n=i.value;if(t===!0)a.push(Cn(e)),e!==fE&&a.push(zr(e));else{if(e!==fE){const c=n.zeniAccountDetailState.depositAccountDetailById[e];(c==null||c.hasValidState()===!1&&c.fetchState!=="In-Progress")&&a.push(zr(e))}const o=n.zeniAccStatementListState.byDepositId[e];(o==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")&&a.push(Cn(e))}return j(_(a))}))),(s,i,r)=>s.pipe(S(je.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/users/zeni-users`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=t.data.users.map((n=>n.user_id)),a=[V({users:t.data.users}),nO(e)];return _(a)}return p(Nm(t.status))})),v((t=>p(Nm(f("Unexpected error","Unable to fetch zeni users"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(CD.match),y((t=>{const{companyEmailDomain:e}=t.payload;return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/email-groups?query=${encodeURIComponent(JSON.stringify({company_email_domain:e.toLowerCase()}))}`).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[xD(a.data)];return _(n)}return p(IS(a.status))})),v((a=>p(IS(f("Unexpected error","Email Group REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(DJ.match),A((t=>{const{linkTokenType:e,paymentAccountId:a}=t.payload;return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/link-token?query=${JSON.stringify(ZE(e,a))}`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[JJ(n.data.link_token,n.data.expiration,e)];return _(o)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),HS(n.status,e))})),v((n=>p(HS(f("Unexpected Error","Get Onboarding Plaid Link Token errored out"+JSON.stringify(n)),e)))))}))),(s,i,r)=>s.pipe(S(cc.match),A((t=>{const{setupViewType:e,includeBalances:a,plaidAccountKeyType:n}=t.payload;let o={is_include_balances:a,is_primary_for_onboarding:!1,is_primary_for_bill_pay:!0};return e==="billing"&&n==="billing_setup"&&(o={is_primary_for_onboarding:!0}),r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data.payment_accounts.map((u=>u.payment_account_id)),l=[W(c.data.accounts,Da(e)),Se(c.data.payment_accounts),rL(d,n)];return _(l)}return p(tI(c.status,n))})),v((c=>p(tI(f("Unexpected Error","Get Payment Accounts errored out"+JSON.stringify(c)),n)))))}))),(s,i,r)=>s.pipe(S(kJ.match),y((t=>{const{linkTokenType:e,paymentAccountId:a,plaidAccountKeyType:n}=t.payload;return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/link-token?query=${JSON.stringify(ZE(e,a))}`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[BJ(o.data.link_token,o.data.expiration,e,n)];return _(c)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),YS(o.status,e,n))})),v((o=>p(YS(f("Unexpected Error","Get Plaid Link Token errored out"+JSON.stringify(o)),e,n)))))}))),(s,i,r)=>s.pipe(S(MC.match),y((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a}}=e,{scheduleType:n,jeScheduleTransactionKey:o,reason:c,note:d}=t.payload,l=H(e),u=a[l.tenantId],m=[],h=ft(o,e),g=((E,P,O)=>{const{vendorState:C}=O,{vendor:U,currencyCode:B,currencySymbol:x,baseTransaction:k,status:J,balanceAsOfToday:L,period:R,startDate:q,endDate:$,jeCredit:D,jeDebit:w}=P,K=U.id,G=C.vendorByID[K];return{scheduled_journal_entries:[],je_schedules:[{status:J,vendor:JC(G),currency_code:B,currency_symbol:x,period:R??null,je_schedule_type:E,posting_date:null,balance:jz(k,L),start_date:q?.format(re)??null,end_date:$?.format(re)??null,je_credit_accounting_class_id:D?.accountingClass?.classId??null,je_credit_account_id:D?.account?.accountId??null,je_debit_accounting_class_id:w?.accountingClass?.classId??null,je_debit_account_id:w?.account?.accountId??null,other_attributes:{},base_transaction:DC(k),is_reviewed:!0}]}})(n,h,e),I={...g,je_schedules:g.je_schedules.map(((E,P)=>P===0?{...E,feedback:{reason:c,...d!=null&&d!==""?{note:d}:{}}}:E))},b={je_schedule_type:n};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/ignore/${h.jeScheduleId}?query=${encodeURIComponent(JSON.stringify(b))}`,I).pipe(y((E=>{if(T(E)&&E.data!=null)return m.push(ut(E.data.je_schedules),St(E.data.je_schedules,E.data.scheduled_journal_entries),VC(o),fy(o,u),et({tenantId:l.tenantId,period:u,refreshViewInBackground:!0}),N({messageSection:"ignore_schedule",messageText:"success",type:"success"})),_(m);{const P=[];return P.push(vy({status:E.status,jeScheduleTransactionKey:o})),P.push(N({messageSection:"ignore_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:E.status.message}]})),_(P)}})),v((E=>{const P=[];return P.push(vy({status:f("Unexpected Error","ignore JE schedules REST API call errored out"+JSON.stringify(E)),jeScheduleTransactionKey:o})),P.push(N({messageSection:"ignore_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(E)}]})),_(P)})))}))),(s,i,r)=>s.pipe(S(gN.match),A((t=>{const{companyId:e,tenantId:a}=t.payload,n=i.value.companyState.companiesById[e],o=a??n.companyInfo.tenantId;return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-text-assist/emails/month-end`,{text:t.payload.text},{...!!o&&{"zeni-tenant-id":o}}).pipe(y((c=>{if(c.data?.text!=null){const{text:d}=c.data;return p(fN(d,e))}return p(Hp(f("Unexpected error","Ai-text-assist REST API call errored out"+JSON.stringify(c.status)),e))})),v((c=>p(Hp(f("Unexpected error","Ai-text-assist REST API call errored out"+JSON.stringify(c)),e)))))}))),(s,i,r)=>s.pipe(S(XO.match),y((t=>{const{accountId:e}=t.payload,a=i.value,n=H(a),o=a.expenseAutomationViewState.selectedPeriodByTenantId[n.tenantId],c=Ze(a.accountState,e,"excluded_account_reconciliation"),d=Re(o,!0),l=JSON.stringify({start_date:d.start,end_date:d.end}),u=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/excluded-accounts/${e}?query=${encodeURIComponent(l)}`;return r.deleteAndGetJSON(u).pipe(y((m=>{if(T(m)&&m.data!=null){const h=m.data.reconciliation,g=Ns("excluded_account_reconciliation",h.account_id),I=Ns("account_reconciliation",h.account_id);return p(ei(o,[h]),eC({reconciliation:h,selectedPeriod:o}),zm({oldKey:g,newKey:I}),N({messageSection:"account_included_in_reconciliation",messageText:"success",type:"success",variables:[{variableName:"_account-name_",variableValue:c?.accountName??""}]}))}return p(ey({error:m.status}),N({messageSection:"account_included_in_reconciliation",messageText:"failed",type:"error"}))})),v((m=>p(ey({error:f("Unexpected Error",`Include account in reconciliation REST API call errored out ${JSON.stringify(m)}`)}),N({messageSection:"account_included_in_reconciliation",messageText:"failed",type:"error"})))))}))),(s,i,r,t=lz)=>s.pipe(S(TP.match),ar((e=>e.payload.provider)),y((e=>e.pipe(A((a=>r.postAndGetJSON(`${r.apiEndPoints.authMicroServiceBaseUrl}/1.0/connectors/email/${a.payload.provider}/init`,{redirect_after_url:a.payload.redirectAfterUrl},{"zeni-tenant-id":a.payload.tenantId}).pipe(y((n=>{if(T(n)&&n.data!=null)return t(n.data.authorization_url),_([AP(a.payload.tenantId,a.payload.provider,n.data.authorization_url)]);const o=n.status??f(`Failed to start ${a.payload.provider} connection. Please try again.`);return _([su(a.payload.tenantId,a.payload.provider,o)])})),v((n=>{const o=n instanceof Error?n.message:`Unexpected error starting ${a.payload.provider} connection.`;return _([su(a.payload.tenantId,a.payload.provider,f(o))])}))))))))),(s,i)=>s.pipe(S(Xm.match),y((()=>{const r=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:t},expenseAutomationReconciliationViewState:{selectedAccountId:e}}=r,a=t[H(r).tenantId],n=[];if(e!=null){const o=Ea(r,e,a),c=o?.transactionsToReconcile?.filter((u=>u.isTransactionChecked)),d=c?.map((u=>u.id))??[];n.push(gr({selectedTransactionIds:d}));const l=Dz(o?.transactionsToReview??[]);n.push(Wm(l))}return _(n)}))),s=>s.pipe(S(mu.match),y((()=>{const i=[];return i.push(uu()),i.push(du()),i.push(io()),_(i)}))),s=>s.pipe(S(_y.match),y((()=>{const i=[];return i.push(uy()),i.push(my()),_(i)}))),(s,i)=>s.pipe(S(GR.match),y((r=>{const{approvalRuleId:t}=r.payload,e=[];if(t!=null){const a=zf(i.value.approvalRuleState,t);if(a!=null){const n={approvalRuleId:t,steps:a.steps,criteria:{amount:Hf(a.criteria),vendor:Yf(a.criteria),department:Kf(a.criteria)},name:a.name,description:a.description,separationOfDuties:a.separationOfDuties};e.push(Qf(),Wf(n))}}else{const a={steps:[],criteria:{}};e.push(Qf(),Wf(a))}return _(e)}))),(s,i)=>s.pipe(S(Tc.match),y((r=>{const{billId:t}=r.payload,e=i.value,a=Ne(t),n=X(e.editBillDetailViewState.editBillStateById,a,void 0),o=X(e.billDetailViewState.billDetailById,a,void 0),c=X(e.billTransactionState.transactionById,t,void 0),{accountListState:d,accountState:l,classListState:u,classState:m,recurringBillState:h}=e,g=M0(l,d,"billPayAccountList"),I=tr(m,u),b=c?.recommendations;if(o!=null&&c!=null&&(n?.billDetailLocalData.vendor==null||c.lines!=null&&c.lines.length>0&&Object.keys(n?.billDetailLocalData.updatesByLineId??{}).length===0)){let E=i1(e.vendorState,c.vendor?.id??"");if(E==null){const pe=e.editBillDetailViewState.newBillState.suggestedVendorIdFromParsedInvoice;if(pe!=null){const fe=Oe(e.vendorState,pe);(fe?.matchScore??0)>85&&(E=fe)}}const{tenantState:P,companyState:O}=e,{currentTenantId:C}=P,U=C!=null?P.tenantsById?.[C]?.companyId:void 0,B=Te(O,U??""),x=B?.company.companyInfo.bookCloseDate,k={invoiceNumber:c.documentId,billDueDate:c.dueDate!=null&&c.date!=null?V0(c.billPayInfo.stage.code,c.dueDate,c.date,x):c.dueDate,invoiceDate:Rl(c.billPayInfo.stage.code,c.date,x),memo:c.memo,currencyCode:c.amount.currencyCode,recipientCurrencyCode:c.recipientTotalAmount.currencyCode,isInvoiceDateAutoUpdated:c.billPayInfo.stage.code==="draft"&&c.date!=null&&x!=null&&c.date.isBefore(x)},J={};c.lines?.forEach((pe=>{J[pe.id]={...pe,...eP(pe.id,pe,b,g,I,E)}}));const L=B?.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach,R=L!=null&&me().isSameOrBefore(L),q=c.billPayInfo.paymentDate??ee(eo(me().toDate(),[0,6],R?0:1).toISOString()),$={paymentType:c1(e.billPayConfigState,c.billPayInfo.fromAccount.billAccountType,c.billPayInfo.billPaymentMethodType,c.billPayInfo.internationalTransferFeeBearerPaymentMethod),paymentDate:q,withdrawFrom:L0(e,c.billPayInfo.fromAccount.billAccountId??"",c.billPayInfo.fromAccount.billAccountType??"",U),paymentTo:c.billPayInfo.toAccount.billAccountId!=null&&c.billPayInfo.toAccount.billAccountId.length>0?c.billPayInfo.toAccount.billAccountId:void 0,internationalTransferFeeBearerPaymentMethod:c.billPayInfo.internationalTransferFeeBearerPaymentMethod},D=c.amount,w=c.recipientTotalAmount,K=c.billPayInfo.isCancelled,G=c.attachments?.[0],Z=c.candidateVendorName,de=c.billPayInfo.toAccountVendorEmail,ue=c.billPayInfo.isCollectToAccountInfoFromVendorContact,te=c.isRecurring;let ye,_e;if(te){const{recurringConfigLocalData:pe,recurringBillInstancesLocalData:fe}=d1(h,c);ye=pe,_e=fe}const Ve=Gl(c.billPayInfo.billPaymentMethodType.code)?{paymentMode:c.billPayInfo.outsideZeniTransactionPaymentMode,paymentDate:c.billPayInfo.paymentDate}:void 0,Ae=[lt({billDetailLocalData:{showVendorGptRecommendationText:!1,vendor:E,whatForSection:k,updatesByLineId:J,paymentDetailsSection:$,totalAmount:D,recipientTotalAmount:w,isCancelled:K,file:G,candidateVendorname:Z,toAccountVendorEmail:de,isCollectToAccountInfoFromVendorContact:ue,isRecurring:te,recurringConfig:ye,recurringBillInstances:_e,outsideZeniPaymentLocalData:Ve},billId:t}),iv({billId:t})];return E?.vendorCurrencyCode!=null&&E.vendorCurrencyCode!=="USD"&&Ae.push(ya(!0,{amount:D.amount,currencyCode:E.vendorCurrencyCode,currencySymbol:E.vendorCurrencySymbol},"USD",t)),_(Ae)}return _([iv({billId:t})])}))),(s,i)=>s.pipe(S(xM.match),y((r=>{const{userId:t}=r.payload,e=i.value.userState,a=i.value.userRoleState,n=bt(e,t),o=zi(a,t),c=[];if(n!=null&&o!=null){const d=n.birthday,l=n.phone,u=n?.isPhoneVerified,m=n?.syncToken,h={userId:t,dateOfBirth:d,phone:l,isPhoneVerified:u,syncToken:m};c.push(UM({localData:h}))}return _(c)}))),(s,i)=>s.pipe(S(Vp.match),y((r=>{const t=[],{companyId:e}=r.payload,a=i.value,{companyHealthMetricState:n}=a,o=iN(n,e);if(o!=null){const{netPromoterScore:c,externalProductServiceExposure:d,customerSatisfactionScore:l,additionalChurnFactors:u}=o;t.push(cN({companyId:e,updatedLocalData:{netPromoterScore:c,customerSatisfactionScore:l,externalProductServiceExposure:d?.code,additionalChurnFactors:u}}))}return j(_(t))}))),(s,i)=>s.pipe(S(mv.match),y((r=>{const{amount:t,vendorType:e}=r.payload,a=[],n=i.value,o=n.internationalWireState.createInternationalWireDetails.localData,c=pv(o?.currencyCode??"",t,e),d=n.internationalWireState.dynamicFormDetailsbyKey[c]??{};if(o!=null){const l={countryCode:o.countryCode,currencyCode:o.currencyCode,accountType:o.accountType,dynamicForm:VK(d),source:o.source};a.push(_v(l))}return _(a)}))),(s,i)=>s.pipe(S(XJ.match),y((r=>{const{userId:t}=r.payload,e=[];if(t){const{userState:a,userRoleState:n,peopleState:o}=i.value,c={userId:t,user:bt(a,t),userRole:zi(n,t),update:ew(o,t)},d=c.user?.email,{userRoles:l,managerUserId:u,accountingClassIDs:m}=c.userRole,h=H(i.value),g=jl(l,h.company);e.push(tw({peopleLocalData:[{email:d!=null?[d]:[],role:g,managerId:u,departmentId:m[0]}],person:c}))}return _(e)}))),(s,i)=>s.pipe(S(hy.match),y((r=>{const t=i.value,e=[],{jeScheduleTransactionKeys:a}=r.payload;return a.forEach((n=>{const o=ft(n,t),c={jeScheduleType:o.jeScheduleType,jeScheduleID:o.jeScheduleId,scheduledJournalEntryID:o.scheduledJournalEntry[0].scheduledJournalEntryID,updatedVendor:void 0,updatedCategoryId:void 0,updatedAccumulatedDepreciationCategoryID:void 0,updatedClassId:void 0};e.push(LC({localData:c,scheduledJournalEntryID:o.scheduledJournalEntry[0].scheduledJournalEntryID}))})),_(e)}))),(s,i)=>s.pipe(S($1.match),y((r=>{const{billId:t,vendorId:e}=r.payload,a=[],n=i.value,o=n.internationalWireState.createInternationalWireDetails.localData;let c=0;if(t!=null){const d=Ne(t);c=n.editBillDetailViewState.editBillStateById[d]?.billDetailLocalData?.recipientTotalAmount?.amount??0}else c=n.editBillDetailViewState.newBillState.billDetailLocalData?.recipientTotalAmount?.amount??0;if(o==null){const d={countryCode:e!=null?n.vendorViewState.editVendorStateById[e].vendorDetailLocalData?.countryCode:n.vendorViewState.newVendorState.vendorDetailLocalData?.countryCode,currencyCode:e!=null?n.vendorViewState.editVendorStateById[e].vendorDetailLocalData?.currencyCode:n.vendorViewState.newVendorState.vendorDetailLocalData?.currencyCode,dynamicForm:{}};if(d.currencyCode!=null){const l=e!=null?n.vendorViewState.editVendorStateById[e].vendorDetailLocalData?.vendorType:n.vendorViewState.newVendorState.vendorDetailLocalData?.vendorType;a.push(uv(d.currencyCode,c,l||"international_business",!1))}a.push(_v(d))}return _(a)}))),(s,i)=>s.pipe(S(hv.match),y((r=>{const{companyId:t,internationalWireFormPayload:e}=r.payload,a=[],n=i.value.companyState.companiesById[t].companyBillPayInfo.internationalWireOnboardingDetails,o={};return Object.keys(e).forEach((c=>{const d=n?.[c]?.values;o[c]=d!=null?e[c].type==="enum"?e[c].is_multiple_values_allowed===!1?typeof d[0]=="object"&&"code"in d[0]?d[0].code:"":d.map((l=>typeof l=="object"&&"code"in l?l.code:"")):d[0]:e[c].type==="enum"&&e[c].is_multiple_values_allowed===!0?[]:""})),a.push(V1(o)),_(a)}))),(s,i)=>s.pipe(S(eS.match),y((r=>{const t=i.value,e=t.addressViewState.newAddressState?.[an]?.addressToCreate,a=r.payload.address?.address_id;if(e!=null||a==null)return F;const n=ot(t.addressState,a);return n!=null?p(qe({addressType:an,addressToCreate:n})):F}))),(s,i)=>s.pipe(S((r=>Ak.match(r)||bi.match(r))),y((r=>{const{id:t}=r.payload,e=i.value;if(e.addressViewState.newAddressState?.[Hs]?.addressToCreate!=null||t==null)return F;const n=q_(e.invoicingCustomerState,t),o=n?.billingAddressId!=null?ot(e.addressState,n.billingAddressId):void 0;return o!=null?p(qe({addressType:Hs,addressToCreate:o})):F}))),(s,i)=>s.pipe(S((r=>Dk.match(r)||Ti.match(r))),y((r=>{const{id:t}=r.payload,e=i.value;if(e.addressViewState.newAddressState?.[kr]?.addressToCreate!=null||t==null)return F;const n=Jk(e.invoicingSubscriptionState,t),o=n?.shippingAddressId!=null?ot(e.addressState,n.shippingAddressId):void 0;return o!=null?p(qe({addressType:kr,addressToCreate:o})):F}))),(s,i)=>s.pipe(S(_f.match),y((()=>{const r=i.value.tenantState.loggedInUser?.userId,t=[ma("user_address")];if(r==null)return t;const e=i.value.userState,a=i.value.userRoleState,n=bt(e,r),o=zi(a,r),c=o?.addressId!=null?ot(i.value.addressState,o.addressId):void 0;if(c!=null&&t.push(qe({addressType:"user_address",addressToCreate:c})),n!=null&&o!=null){const d=n.birthday,l=n.phone,u=n?.isPhoneVerified??!1,m=n?.syncToken,h={dateOfBirth:d,phone:l,isPhoneVerified:u,syncToken:m};t.push(iR({localData:h}))}return _(t)}))),(s,i)=>s.pipe(S(jC.match),y((r=>{const t=[],e=Ir(),{accountListState:a,classListState:n}=i.value;return a.byReportId[e.accountListKey]?.fetchState==="Not-Started"&&t.push(be(e.accountListKey,!0,!1,!1,!1,e.allowedAccountList)),n.fetchState==="Not-Started"&&t.push(se()),r.payload.shouldResetEnteredData&&(t.push(by({scheduleType:r.payload.scheduleType})),t.push(GC())),_(t)}))),(s,i)=>s.pipe(S(UD.match),y((r=>{const{isDebitCardFlagEnabled:t,companyId:e}=r.payload,a=[];if(e!=null){const n=kD(i.value.onboardingCustomerState,e),o=Mi(i.value.companyState,e),c=o?.company.companyOnboardingInfo.onboardingInfo?.onboardingCustomerUserIds!=null&&o.company.companyOnboardingInfo.onboardingInfo.onboardingCustomerUserIds.length>0?o.company.companyOnboardingInfo.onboardingInfo.onboardingCustomerUserIds[0]:null;if(n!=null&&o!=null){const d=i.value.onboardingCockpitViewState.onboardingTenantIdByCompanyId[e],l=bS(i.value.tenantState,d),u=l?.isEmailGroupCreated?o.company.companyOnboardingInfo.isSubsidiary:void 0,m={companyEmailDomain:o.company.companyInfo.primaryEmailDomain,isOnboardingTenant:!0,userEmailWithPreOnboardSuccess:n.userEmailWithPreOnboardSuccess,companyId:o.company.companyInfo.companyId,languageCode:o.company.companyLocaleInfo.languageCode,countryCode:o.company.companyLocaleInfo.companyIncCountryCode,currencyCode:o.company.companyLocaleInfo.currencyCode,groupId:n.groupId,groupDescription:n.groupDescription,groupName:n.groupName,name:o.company.companyInfo.name,qboRealmId:l?.qboRealmId,chargebeeId:l?.chargebeeId,hubSpotId:l?.hubSpotId,isCustomerCreated:l?.isCustomerCreated,isEmailGroupCreated:l?.isEmailGroupCreated,isOnboardingCompanyDetailsCompleted:o.company.companyOnboardingInfo.isOnboardingCompanyDetailsCompleted,isSubsidiary:u,parentCompanyId:o.company.companyOnboardingInfo.parentCompanyId,tenantId:d,companyLegalName:o.company.companyInfo.companyLegalName,accountingConnectionCreationMode:o.company.companyOnboardingInfo.onboardingInfo?.accountingConnectionCreationMode!=null?BD(o.company.companyOnboardingInfo.onboardingInfo?.accountingConnectionCreationMode):void 0,selectedProducts:cK(t,l)};if(c!=null){const g=bt(i.value.userState,c);g!=null&&(m.customerName={firstName:g.firstName,lastName:g.lastName},m.email=g.email)}a.push(ES(),PS(m),TS(m),Vi());const h=o?.company.managementInfo.companyAddressId!=null?ot(i.value.addressState,o?.company.managementInfo.companyAddressId):void 0;h!=null&&a.push(qe({addressType:"company_address",addressToCreate:h}))}else a.push(DD())}else{const n={companyEmailDomain:"",isOnboardingTenant:!0,userEmailWithPreOnboardSuccess:"",chargebeeId:"",isSubsidiary:void 0,groupId:"",groupName:"",groupDescription:"",name:"",customerName:{firstName:"",lastName:""},companyLegalName:"",email:"",qboRealmId:"",selectedProducts:[]};a.push(ES(),PS(n),TS(n),Vi())}return _(a)}))),(s,i)=>s.pipe(S(QL.match),y((r=>{const{approvalRuleId:t}=r.payload,e=[];if(t!=null){const a=zf(i.value.approvalRuleState,t);if(a!=null){const n={approvalRuleId:t,steps:a.steps,criteria:{amount:Hf(a.criteria),vendor:Yf(a.criteria),department:Kf(a.criteria)},name:a.name,description:a.description,separationOfDuties:a.separationOfDuties};e.push(EI(),PI(n))}}else{const a={steps:[],criteria:{}};e.push(EI(),PI(a))}return _(e)}))),(s,i)=>s.pipe(S(dI.match),y((r=>{const{reimbursementId:t}=r.payload,e=i.value,a=e.reimbursementState.reimbursementById[t];if(a!=null){const n={reportTitle:a?.reportTitle},o=a.reimbursementInfo.stage.code==="pending_approval",c={};a.lines?.forEach((m=>{if(m.type==="out_of_pocket"){const h=m.merchant?.id,g=h!=null?PL(e.merchantState,h):void 0,{recommendedAccount:I}=TL(g?.recommendations,m.lineDetail.account,m.lineDetail.class);c[m.lineId]={lineId:m.lineId,type:m.type,fileId:m.fileId,homeCurrencyConversions:m.homeCurrencyConversions,outOfPocket:{recommendations:g?.recommendations??[],recommendedAccount:I,isCategoryUpdateSelected:!1,isCategoryFirstTimeAutofilled:!1,isRetainedCategorySelected:!1,merchant:{id:g?.id,name:g?.name??""},amount:m.amount,currencyCode:m.currencyCode,currencySymbol:m.currencySymbol,description:m.description,transactionDate:m.transactionDate,lineDetail:m.lineDetail},mileage:{}},o&&(c[m.lineId]={...c[m.lineId],outOfPocket:{...c[m.lineId].outOfPocket,retainedAccount:I!=null?m.lineDetail.account:void 0,isRetainedCategorySelected:!1}})}else c[m.lineId]={lineId:m.lineId,type:m.type,fileId:m.fileId,homeCurrencyConversions:m.homeCurrencyConversions,mileage:{lineDetail:m.lineDetail,amount:m.amount,currencyCode:m.currencyCode,currencySymbol:m.currencySymbol,description:m.description,transactionDate:m.transactionDate,distanceMileage:m.distanceMileage},outOfPocket:{recommendations:[],isCategoryFirstTimeAutofilled:!1,isRetainedCategorySelected:!1,isCategoryUpdateSelected:!1}}}));const d={};a.lines?.forEach((m=>{d[m.lineId]={fetchState:"Not-Started",error:void 0}}));const l=a.amount,u={whatForSection:n,updatesByLineId:c,totalAmount:l,files:a.attachments,currencyConversionStateByLineId:d,paymentTo:a.reimbursementInfo.toAccount.billAccountId};return p(vd({remiDetailLocalData:u,reimbursementId:t}))}return _([])}))),(s,i)=>s.pipe(S(Va.match),y((r=>{const t=i.value,{scheduleAccruedDetailState:e}=t,a=[],{selectedJeScheduleDetailId:n,selectedJEScheduleKey:o,scheduleType:c}=r.payload;let d;if(o!=null&&(d=sa(o,t)),n!=null&&d!=null){const l=((u,m)=>{const h=m.map((B=>({postingDate:B.expectedPostDate,amount:Wa(B.amount?B.amount.amount:0,B.currencyCode??"USD",B.currencySymbol??"$"),runningBalance:Wa(B.runningBalance?B.runningBalance.amount:0,B.currencyCode??"USD",B.currencySymbol??"$"),postingStatus:B.status.code,memo:B.memo,jeLink:UK(B.thirdPartyID,B.transactionID,B.recommendedTransactionID,B.reversalTransactionDetails)}))),{startDate:g,period:I,jeDebit:b,jeCredit:E,memo:P,recurringAmount:O,vendor:C,otherAttributes:U}=u;return{scheduleType:"accrued_expenses",startingBalance:{amount:U.startingBalance?.amount??0,currencyCode:"USD",currencySymbol:"$"},jeScheduleDetails:h,selectedDate:g,selectedMonths:I,selectedAccount:b.account?.accountId,selectedClass:b.accountingClass?.classId,estimatedMonthlyAmount:O,memo:P,selectedVendor:C,selectedAccruedExpenseCategory:E.account?.accountId??""}})(d,d.scheduledJournalEntry);a.push(cn({scheduleType:c,selectedJeScheduleDetailId:n,localData:{...T$,...l}}))}else a.push(cn({scheduleType:c,localData:{...e.newScheduleState},selectedJeScheduleDetailId:void 0}));return _(a)}))),(s,i)=>s.pipe(S(Mr.match),y((r=>{const t=i.value,{scheduleDetailState:e}=t,a=[],{selectedJeScheduleDetailId:n,selectedJEScheduleKey:o,scheduleType:c}=r.payload,d=ft(o,t);if(n!=null){const l=d.scheduledJournalEntry,u=c!=="fixed_assets"?$$(c,d,l):R$(d,l);a.push(un({scheduleType:c,selectedJeScheduleDetailId:n,localData:{...M$[c],...u}}))}else a.push(un({scheduleType:c,localData:{...e.newScheduleState[c]},selectedJeScheduleDetailId:void 0}));return _(a)}))),(s,i)=>s.pipe(S(rq.match),y((r=>{const{subscriptionId:t,tenantId:e}=r.payload,a=[];if(t!=null){const n=sq(i.value.subscriptionState,t);if(n?.subscription!=null){const{subscriptionPlanId:o,subscriptionAddonIds:c,subscriptionCouponIds:d}=n.subscription;let l=!0,u=!1;const m=!0;n.subscription.status.code==="future"&&(l=!1,u=!0);const h={subscriptionPlanId:o,subscriptionAddOnIds:c,subscriptionCouponIds:d,subscriptionId:t,invoiceImmediately:m,applyEndOfTerm:l,shouldProrate:u};a.push(pb({tenantId:e}),mb({tenantId:e,subscriptionData:h}))}}else{const n={subscriptionAddOnIds:[],subscriptionCouponIds:[],invoiceImmediately:!0};a.push(pb({tenantId:e}),mb({tenantId:e,subscriptionData:n}))}return _(a)}))),(s,i)=>s.pipe(S(Ib.match),y((r=>{const{taskId:t}=r.payload,e=i.value,a=X(e.taskState.taskByID,t,void 0);if(a!=null){const n={name:a.name,description:a.description,status:a.status.code,assignee:a.assignees,groupAssignees:a.groupAssignees,dueDate:a.dueDate,priority:a.priority.code,tagIds:a.tagIds,fileIds:a.fileIds,type:a.type,recurringFrequency:a.recurringFrequency,recurringDaysOfWeek:a.recurringDaysOfWeek,recurringEndDateLocalData:{recurringDatePickerOptionsType:"date",recurringEndDate:a.recurringEndDate},savedRecurringEndDate:a.recurringEndDate,recurringStartDate:a.recurringStartDate,timeSpent:a.timeSpent,isPrivate:a.isPrivate,taskGroupId:a.taskGroupIds[0]},o=[Oq({taskDetailLocalData:n,taskId:t}),za({taskId:t,fetchState:"Completed"})];return _(o)}return _([za({taskId:t,fetchState:"Completed"})])}))),(s,i)=>s.pipe(S(bs.match),y((r=>{const{transactionId:t,vendorId:e}=r.payload,a=[],n=i.value.transactionState,o=Be(t),c=At(n,o);if(c!=null){const d=pa(i.value.accountState,i.value.accountListState,"accountList"),l=uj(c,e,d);a.push(pj({transactionId:t})),a.push(mj({transactionId:t,transactionLocalData:l}))}return _(a)}))),(s,i)=>s.pipe(S(_s.match),y((r=>{const{vendorId:t}=r.payload,e=[ma("vendor_address")];if(t!=null){const a=Oe(i.value.vendorState,t),n=a?.addressId!=null?ot(i.value.addressState,a?.addressId):void 0;n!=null&&e.push(qe({addressType:"vendor_address",addressToCreate:n}))}return _(e)}))),(s,i,r)=>s.pipe(S(fV.match),A((t=>{const e=i.value,{companyId:a}=t.payload,{depositAccountState:n,paymentAccountState:o,paymentAccountListState:c,depositAccountListState:d}=e,l=e.chargeCardRepaymentDetailState.localData,u=vV(n,d),m=IV(o,c),h=bV(u.depositAccounts,m.paymentAccounts,c.paymentAccountBalanceFetchStatus).find((I=>I.id===l.transferFrom?.id)),g={funding_account:{account_id:l.transferFrom?.id,account_type:Me(h?.accType)??""},idempotency_key:l.idempotencyKey,is_auto_pay_enabled:l.isAutoRepayment,amount:l.amount.amount};return h!=null&&l.transferFrom!=null?r.postAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments`,g).pipe(y((I=>{if(T(I)&&I.data!=null){const b=[EV(I.data.card_repayment),PV({cardRepaymentId:I.data.card_repayment.card_repayment_id,zeniCreditAccountId:I.data.card_repayment.zeni_credit_account_id}),TV({amount:Wa(I.data.card_repayment.amount,I.data.card_repayment.currency_code,I.data.card_repayment.currency_symbol),date:ee(I.data.card_repayment.repayment_date)}),En({fetchState:"Completed",error:void 0})];return l.transferFrom!=null&&h?.accType!=null&&b.push(Gr({companyId:a,primaryFundingAccountId:l.transferFrom.id,accountType:h.accType,productType:"charge_cards"}),AV({companyId:a,enableAutoPay:l.isAutoRepayment})),_(b)}return p(En({fetchState:"Error",error:I.status}))})),v((I=>p(En({fetchState:"Error",error:f("Unexpected Error","Initiate Charge Card Repayment REST API call errored out"+JSON.stringify(I))}))))):p(En({fetchState:"Error",error:f("Validation Error","Funding account not selected.")}))}))),(s,i)=>s.pipe(S(Mg.match),A((r=>{const{reportIdToResync:t}=r.payload,e=[];switch(t){case"profit_and_loss_by_classes":e.push(yg(!0));break;case"operating_expenses_by_classes":e.push(rg(!0));break;case"revenue_by_classes":e.push(Vg(!0));break;case"net_burn_or_income_by_classes":e.push(iS(!0))}return _(e)}))),(s,i)=>s.pipe(S(Lg.match),A((r=>{const{reportIdToResync:t}=r.payload,e=[];switch(t){case"profit_and_loss_by_projects":e.push(Sg(!0));break;case"operating_expenses_by_projects":e.push(og(!0));break;case"revenue_by_projects":e.push(Fg(!0));break;case"net_burn_or_income_by_projects":e.push(lS(!0))}return _(e)}))),(s,i,r)=>s.pipe(S(aw.match),A((()=>{const t=i.value.peopleState.personDetails.localData,e=H(i.value),a=SK(t,e.company);return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/invites`,a).pipe(y((n=>{if(T(n)){const o=[];return n.data?.user_roles&&Vn(o,n.data?.user_roles[0],!1),p(Y(n.data?.user_roles??[]),V({users:n.data?.users??[]}),ug(n.data),N({messageSection:a.invites.length>1?"people_invite_multiple_people":"people_invite_people",messageText:"success",type:"success"}),...o)}return p(nn(n.status))})),v((n=>p(nn(f("Unexpected error","User Roles REST API call errored out"+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(rw.match),A((t=>{const e=i.value.peopleState.personDetails.localData,a=gK(e);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${t.payload.companyId}`,a).pipe(y((n=>{if(T(n)){const o=[];return n.data?.user_roles&&Vn(o,n.data?.user_roles[0],!0),p(Y(n.data?.user_roles??[]),V({users:n.data?.users??[]}),ug(n.data),N({messageSection:a.users.length>1?"people_invite_multiple_people":"people_invite_people",messageText:"success",type:"success"}),...o)}return p(nn(n.status))})),v((n=>p(nn(f("Unexpected error","User Roles REST API call errored out"+JSON.stringify(n)))))))}))),(s,i,r)=>{const t=()=>`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import`,e=s.pipe(S(zU.match),y((()=>Yr("connect",r.postAndGetJSON(`${t()}/chargebee/connect`,{}))))),a=s.pipe(S(KU.match),y((d=>{const l=new FormData;return d.payload.files.forEach((u=>l.append("files",u,u.name))),Yr("upload",r.postFormData(`${t()}/uploads`,l))}))),n=s.pipe(S(YU.match),y((d=>Yr("start",r.postAndGetJSON(`${t()}/${encodeURIComponent(d.payload)}/import`,{}))))),o=s.pipe(S(HU.match),y((d=>Yr("retry",r.postAndGetJSON(`${t()}/${encodeURIComponent(d.payload)}/retry`,{}))))),c=s.pipe(S(QU.match),y((d=>Yr("rollback",r.postAndGetJSON(`${t()}/${encodeURIComponent(d.payload)}/rollback`,{})))));return vt(e,a,n,o,c)},(s,i,r)=>s.pipe(S($V.match),A((()=>{const t=i.value,e=i.value.tenantState.loggedInUser?.userId,a=t.issueChargeCardState.localData.map((n=>n.chargeCardType==="credit_card"?n.creditCard.cardType==="business_physical_credit_card"?{card_holder_user_ids:n.creditCard.physicalCard.userId!=null?[n.creditCard.physicalCard.userId]:[],card_name:n.creditCard.physicalCard.cardName,purchase_limit:n.creditCard.physicalCard.amount?.amount??0,currency_code:n.creditCard.physicalCard.amount?.currencyCode??"USD",purchase_limit_frequency:{code:n.creditCard.physicalCard.frequency},card_type:n.creditCard.cardType,shipping_address_type:n.creditCard.physicalCard.addressType,shipping_address_id:n.creditCard.physicalCard.addressId}:{card_holder_user_ids:n.creditCard.virtualCard.userIds,card_name:n.creditCard.virtualCard.cardName,purchase_limit:n.creditCard.virtualCard.amount?.amount??0,currency_code:n.creditCard.virtualCard.amount?.currencyCode??"USD",purchase_limit_frequency:{code:n.creditCard.virtualCard.frequency},card_type:n.creditCard.cardType}:n.debitCard.cardType==="business_physical_debit_card"?{card_holder_user_ids:n.debitCard.physicalCard.userId!=null?[n.debitCard.physicalCard.userId]:[],card_name:n.debitCard.physicalCard.cardName,purchase_limit:n.debitCard.physicalCard.amount?.amount??0,currency_code:n.debitCard.physicalCard.amount?.currencyCode??"USD",purchase_limit_frequency:{code:n.debitCard.physicalCard.frequency},card_type:n.debitCard.cardType,shipping_address_type:n.debitCard.physicalCard.addressType,shipping_address_id:n.debitCard.physicalCard.addressId,connected_account_id:n.debitCard.physicalCard.connectedAccountId,connected_account_type:"deposit_account"}:{card_holder_user_ids:n.debitCard.virtualCard.userIds,card_name:n.debitCard.virtualCard.cardName,purchase_limit:n.debitCard.virtualCard.amount?.amount??0,currency_code:n.debitCard.virtualCard.amount?.currencyCode??"USD",purchase_limit_frequency:{code:n.debitCard.virtualCard.frequency},connected_account_id:n.debitCard.virtualCard.connectedAccountId,card_type:n.debitCard.cardType,connected_account_type:"deposit_account"}));return r.postAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards`,{cards:a}).pipe(y((n=>{if(M(n)&&n.data!=null){const o=[],c=n.data.cards;o.push(qa(c),V({users:n.data.users}),Y(n.data.user_roles),Bv({chargeCardListPayload:n.data,keepExistingListItems:!0}),z(n.data.addresses),Qv(n.data?.cards_count_by_user_id??[]),Wv(n.data?.debit_cards_count_by_deposit_account_id??{}),RV(c.map((u=>u.card_id))),Pn({fetchState:"Completed"})),c.length!==1||c[0].card_type.code!=="business_virtual_debit_card"&&c[0].card_type.code!=="business_physical_debit_card"||e!==c[0].holder_user_id||o.push(MV(c[0].card_id));const d=c.map((u=>u.holder_user_id)),l=n.data.users.filter((u=>d.includes(u.user_id))).map((u=>u.first_name?.trim()??u.last_name?.trim())).filter((u=>u!=null));if(c.length>0&&l.length===1){const u=c.length>1?"cards":"card";o.push(N({messageSection:"issue_charge_card",messageText:"success",type:"success",variables:[{variableName:"_user-name_",variableValue:l[0]??""},{variableName:"_card_",variableValue:u}]}))}else o.push(N({messageSection:"issue_charge_cards",messageText:"success",type:"success"}));return _(o)}return p(Pn({fetchState:"Error",error:n.status}))})),v((n=>p(Pn({fetchState:"Error",error:f("Unexpected Error","Issue Charge Card REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(QB.match),y((()=>{const{draft:t}=i.value.invoicingIssueCreditNoteState,{invoiceId:e}=t,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(e)}/issue-credit-note`,n=WB(t);return r.postAndGetJSON(a,n).pipe(y((o=>T(o)&&o.data!=null?[zs([o.data],"merge"),Br({invoiceId:e}),ZB({creditNoteId:o.data.id}),N({messageSection:"invoicing_credit_note_saved",messageText:"success",type:"success"})]:_([Wh(o.status),N({messageSection:"invoicing_credit_note_saved",messageText:"failed",type:"error",variables:Ie(o.status)})]))),v((o=>_([Wh(f("Unexpected Error","Issue credit note REST API call errored out "+JSON.stringify(o))),N({messageSection:"invoicing_credit_note_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(HM.match),A((t=>{const{chargeCardId:e,reason:a,isChargeCardAdmin:n}=t.payload,o={reason:a},c=i.value.chargeCardState.chargeCardByID[e],d=c?.accountLast4??"";return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/lock`,o).pipe(y((l=>M(l)&&l.data!=null?p(st(l.data),Hc({chargeCardId:e,fetchState:"Completed"}),N({messageSection:n?"lock_charge_card":"lock_charge_card_card_user",messageText:"success",type:"success",variables:[{variableName:"_masked_card_number_",variableValue:`•••• ${d}`}]})):p(N({messageSection:n?"lock_charge_card":"lock_charge_card_card_user",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}),Hc({chargeCardId:e,fetchState:"Error",error:l.status})))),v((l=>p(N({messageSection:n?"lock_charge_card":"lock_charge_card_card_user",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(l)}]}),Hc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Lock card API call errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(cV.match),A((t=>{const{cardIds:e,reason:a}=t.payload,n={card_ids:e,reason:a};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/bulk/lock`,n).pipe(y((o=>M(o)&&o.data!=null?p(qa(o.data),sd({fetchState:"Completed"}),N({messageSection:"lock_charge_cards",messageText:"success",type:"success",variables:[{variableName:"_number_of_cards_",variableValue:e.length===1?"1 card":`${e.length} cards`}]})):p(N({messageSection:"lock_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:o.status.message}]}),sd({fetchState:"Error",error:o.status})))),v((o=>p(N({messageSection:"lock_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(o)}]}),sd({fetchState:"Error",error:f("Unexpected Error","Lock cards API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(V$.match),y((t=>{const e=i.value,{scheduleType:a,jeScheduleKey:n}=t.payload,o=[],c=ft(n,e),d=c.jeScheduleId,l=c.vendor.name,u=d!=null?e.scheduleDetailState.editScheduleStateByDetailId[a][d]:e.scheduleDetailState.newScheduleState[a],m={...ec(e,u,n,a,!1,!0)},h={je_schedule_type:a};return(d!=null?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${d}?query=${encodeURIComponent(JSON.stringify(h))}`,m):r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(h))}`,m)).pipe(y((g=>T(g)&&g.data!=null?(o.push(St(g.data.je_schedules,g.data.scheduled_journal_entries,"replace"),sc("Completed"),N({messageSection:"mark_as_complete_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:l}]})),_(o)):(o.push(sc("Error",g.status)),o.push(N({messageSection:"mark_as_complete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]})),_(o)))),v((g=>_([N({messageSection:"mark_as_complete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(g)}]}),sc("Error",f("Unexpected Error",`Mark As Complete Schedule Detail REST API call errored out ${JSON.stringify(g)}`))]))))}))),(s,i,r)=>s.pipe(S(Mb.match),y((t=>{if(t.payload.isExpenseAutomationEnabled===!0){const e=Be(t.payload.transactionId),a=At(i.value.transactionState,e),n=(t.payload.lineIds?.length??0)>0?t.payload.lineIds:(a?.lines??[]).map((o=>o.id));return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/mark-as-reviewed`,{transactions_reviewed:[{transaction_id:t.payload.transactionId.id,line_ids:n}]}).pipe(y((o=>{if(T(o)){const c=[];c.push(Ka(t.payload.transactionId,"Completed",void 0));const d=t.payload.transactionId.id;if(!(o.data?.transactions_reviewed_failed??[]).some((l=>l.transaction_id===d))){c.push(Vb(e,!1));const{expenseAutomationViewState:l,expenseAutomationTransactionsViewState:u}=i.value,{transactionCategorizationView:m,selectedTransactionCategorizationTab:h}=u,g=H(i.value)?.tenantId,{selectedPeriodByTenantId:I}=l,b=g!=null?I[g]:void 0,E=(m.autoCategorized.transactionReviewLocalDataById[d]?.transactionReviewLocalData.tabSpecificLineItems?.autoCategorized??[]).length>0,{uiState:P}=m[h],O=h==="review"?[d]:E?[]:[d];if(b!=null&&c.push(Ls(h,[d],O,b,"Completed")),E||c.push(zy({transactionIds:[d]})),O.length>0&&b!=null){const C=P.totalCount[Ee(b)]??0,U=Math.max(0,C-1);c.push($s({selectedPeriod:b,selectedTab:h,totalCount:U}))}}return c.push(ol({transactionId:t.payload.transactionId,fetchState:"Completed"})),t.payload.transactionSaveUpdates.anyBulkUpdates===!0?c.push(N({messageSection:"transactionDetails_updatingPastTransactions",messageText:"success",type:"success"})):c.push(N({messageSection:"transactionDetails_transactionUpdated",messageText:"success",type:"success"})),_(c)}return p(Ka(t.payload.transactionId,"Error",o.status))})),v((o=>p(Ka(t.payload.transactionId,"Error",f("Unexpected Error",`Transaction mark as reviewed REST API call errored out ${o}`))))))}return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${t.payload.transactionId.id}/mark-miscategorized-as-correct`,mY(t.payload.transactionId)).pipe(y((e=>{if(M(e)){const a=[];a.push(Ka(t.payload.transactionId,"Completed",void 0));const n=Be(t.payload.transactionId);return a.push(Vb(n,!1)),a.push(ol({transactionId:t.payload.transactionId,fetchState:"Completed"})),t.payload.transactionSaveUpdates.anyBulkUpdates===!0?a.push(N({messageSection:"transactionDetails_updatingPastTransactions",messageText:"success",type:"success"})):a.push(N({messageSection:"transactionDetails_transactionUpdated",messageText:"success",type:"success"})),_(a)}return p(Ka(t.payload.transactionId,"Error",e.status))})),v((e=>p(Ka(t.payload.transactionId,"Error",f("Unexpected Error",`Transaction mark miscategorized as correct REST API call errored out ${e}`))))))}))),(s,i,r)=>s.pipe(S(Hx.match),A((t=>r.postAndGetJSON(`${r.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/feature-interests`,{additional_info:t.payload.additionalInfo,email:t.payload.email,feature:t.payload.feature}).pipe(y((e=>{if(T(e)&&e.data!=null)return _([Qx(e.data)]);const a=e.status??f("Failed to register interest. Please try again.");return _([Qy(a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error registering interest.";return _([Qy(f(a))])})))))),(s,i,r)=>vt(((t,e,a)=>t.pipe(S(ex.match),y((n=>{const o=e.value,{accrualId:c,amount:d}=n.payload,l=tx(ax(c),o.jeSchedulesState),u=o.expenseAutomationJESchedulesViewState.oneTimeAccrualLocalDataById[c],m=u?.jeDebitAccountId??l?.jeDebitAccountId,h=u?.jeCreditAccountId??l?.jeCreditAccountId;if(m==null||h==null)return _(ea("save_schedule",c,"This accrual is missing an expense or liability account."));const g=u?.reverseNextMonth??l?.reversalPolicy==="scheduled_date",I=u?.expectedReversalDate??l?.expectedReversalDate,b=u?.jeDebitAccountingClassId??l?.jeDebitAccountingClassId,E=u?.jeDebitAccountingClassName??l?.jeDebitAccountingClassName,P=u?.jeDebitAccountName??l?.jeDebitAccountName,O=u?.jeCreditAccountName??l?.jeCreditAccountName,C=l?.jeCreditAccountingClassId,U=l?.jeCreditAccountingClassName,B={amount:d,memo:u?.memo??l?.memo??"",je_debit_account_id:m,je_credit_account_id:h,...P!=null?{je_debit_account_name:P}:{},...O!=null?{je_credit_account_name:O}:{},...b!=null?{je_debit_accounting_class_id:b}:{},...E!=null?{je_debit_accounting_class_name:E}:{},...C!=null?{je_credit_accounting_class_id:C}:{},...U!=null?{je_credit_accounting_class_name:U}:{},reverse_next_month:g,...g&&I!=null?{expected_reversal_date:I.format(re)}:{}};return a.putAndGetJSON(`${a.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${c}`,{...B}).pipe(y((x=>T(x)&&x.data!=null?_([Ta([x.data.accrual]),oi({accrualId:c}),rx({accrualId:c}),N({messageSection:"save_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:l?.vendorName??""}]}),...Tl(e.value)]):_(ea("save_schedule",c,x.status.message,x.status)))),v((x=>_(ea("save_schedule",c,`Promote accrual REST API call errored out ${JSON.stringify(x)}`)))),De(t.pipe(S(gt.match))))}))))(s,i,r),((t,e,a)=>t.pipe(S(XC.match),y((n=>{const{accrualId:o,reason:c,note:d}=n.payload,l={reason:c,...d!=null&&d!==""?{note:d}:{}};return a.putAndGetJSON(`${a.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${o}/ignore`,{...l}).pipe(y((u=>T(u)&&u.data!=null?_([Ta([u.data.accrual]),oi({accrualId:o}),N({messageSection:"ignore_accrual",messageText:"success",type:"success"}),...Tl(e.value)]):_(ea("ignore_accrual",o,u.status.message,u.status)))),v((u=>_(ea("ignore_accrual",o,`Ignore accrual REST API call errored out ${JSON.stringify(u)}`)))),De(t.pipe(S(gt.match))))}))))(s,i,r),((t,e,a)=>t.pipe(S(ZC.match),y((n=>{const{accrualId:o,reason:c,note:d}=n.payload,l={reason:c,...d!=null&&d!==""?{note:d}:{}};return a.putAndGetJSON(`${a.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${o}/revert`,{...l}).pipe(y((u=>T(u)&&u.data!=null?_([Ta([u.data.accrual]),oi({accrualId:o}),N({messageSection:"revert_accrual",messageText:"success",type:"success"}),...Tl(e.value)]):_(ea("revert_accrual",o,u.status.message,u.status)))),v((u=>_(ea("revert_accrual",o,`Revert accrual REST API call errored out ${JSON.stringify(u)}`)))),De(t.pipe(S(gt.match))))}))))(s,i,r)),YG,(s,i)=>s.pipe(S(Nj.match),y((r=>{const t=i.value.transactionListState,e=y0(r.payload.period).filter((a=>r.payload.cacheOverride!==!1||(function(n,o,c,d,l){const u=zb(o,c,d,l),m=n.transactionListByClassKey[u];return m!=null&&(m.fetchState==="In-Progress"||m.hasValidState())})(t.byClass,r.payload.accountId,r.payload.accountType,r.payload.classId,a)===!1));if(e.length>12)return console.error("Only maximum 12 parallel fetch are allowed!"),_([]);{const a=e.map((n=>Gb(r.payload.accountId,r.payload.accountType,r.payload.classId,n,!0)));return _(a)}}))),(s,i)=>s.pipe(S(rE.match),y((r=>{const t=i.value.transactionListState,e=(function(n,o=1){let c=ee(ae(n.start));const d=ee(ae(n.end));c=c.set("date",1);const l=Oj(d,o);c.isBefore(l)&&(c=l);const u=Math.ceil(d.diff(c,"month",!0)),m=[];if(u>=0){let h=c.clone().set("date",1);for(let g=0;g<u-1;++g){const I=h.daysInMonth();m.push({start:{day:1,month:h.month()+1,year:h.year()},end:{day:I,month:h.month()+1,year:h.year()}}),h=h.add(1,"month")}m.push({start:{day:h.date(),month:h.month()+1,year:h.year()},end:{day:d.date(),month:d.month()+1,year:d.year()}})}else console.error(`Invalid time period ${JSON.stringify(n)}`);return m})(r.payload.period,r.payload.fiscalYearStartMonth),a=e.filter((n=>r.payload.cacheOverride!==!1||(function(o,c,d){const l=Hb(c,d),u=o.transactionListByEntityKey[l];return u!=null&&(u.fetchState==="In-Progress"||u.hasValidState())})(t.byEntity,r.payload.entity,n)===!1));if(a.length>12)return console.error("Only maximum 12 parallel fetch are allowed!"),_([]);{const n=a.map((o=>Yb(r.payload.entity,o,!0)));return _(n)}}))),(s,i)=>s.pipe(S(Cj.match),y((r=>{const t=i.value.transactionListState,e=y0(r.payload.period).filter((a=>r.payload.cacheOverride!==!1||(function(n,o,c,d,l){const u=Zb(o,c,d,l),m=n.transactionListByProjectKey[u];return m!=null&&(m.fetchState==="In-Progress"||m.hasValidState())})(t.byProject,r.payload.accountId,r.payload.accountType,r.payload.projectId,a)===!1));if(e.length>12)return console.error("Only maximum 12 parallel fetch are allowed!"),_([]);{const a=e.map((n=>Wb(r.payload.accountId,r.payload.accountType,r.payload.projectId,n,!0)));return _(a)}}))),(s,i)=>s.pipe(S(xj.match),y((r=>{const{transactionCategoryType:t,minimumTransactionAmount:e}=r.payload,a=i.value.transactionListState,n=Uj(r.payload.period).filter((o=>r.payload.cacheOverride!==!1||(function(c,d,l){const u=tE(l,d),m=c.transactionListByCategoryType[u];return m!=null&&(m.fetchState==="In-Progress"||m.hasValidState())})(a.byType[t],o,t)===!1));if(n.length>12)return console.error("Only maximum 12 parallel fetch are allowed!"),_([]);{const o=n.map((c=>eE(!0,t,c,e)));return _(o)}}))),(s,i,r)=>s.pipe(S(tC.match),A((t=>{const{accountId:e,selectedPeriod:a,combinedStatementGroupId:n}=t.payload,o=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/combined-statement-groups/${n}`;return r.getJSON(o).pipe(y((c=>T(c)===!0&&c.data!=null?_([Cs({accountId:e,selectedPeriod:a,parsedStatementData:aC(c.data)}),ty({accountId:e,selectedPeriod:a})]):p(xs({accountId:e,selectedPeriod:a,error:c.status})))),v((c=>p(xs({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Parse Combined Statement REST API call errored out "+(c instanceof Error?c.message:String(c)))})))))}))),(s,i)=>s.pipe(S(Oc.match),y((r=>{const{invoiceProcessingPayload:t,isVendorRecommendationFeatureEnabled:e,billId:a}=r.payload,n=i.value,o=a!=null?Ne(a):null,c=o!=null?n.editBillDetailViewState.editBillStateById[o]:null,d=c?.showSkipAutofill??n.editBillDetailViewState.newBillState.showSkipAutofill,l=c?.replaceBillData??n.editBillDetailViewState.newBillState.replaceBillData;if(d||l){let u=Uc.billDetailLocalData.vendor,m=!1;const h=t.vendors.length>0?t.vendors[0].vendor_name??"":void 0,g=t.bills.length>0?t.bills[0].currency_code:"USD";let I="";const b=Nc(n).vendors;let E,P,O=!1;if(h!=null&&h.length>0&&(u=b.filter((x=>x.name.toLowerCase()===h.toLowerCase()))[0],u==null)){const x=c?.suggestedVendorIdFromParsedInvoice??n.editBillDetailViewState.newBillState.suggestedVendorIdFromParsedInvoice;if(x!=null){P=Oe(n.vendorState,x);const k=P?.matchScore??0;I=P?.vendorCurrencyCode??"USD",e?P?.name.toLowerCase()===h.toLowerCase()?I===g?(u=P,O=!0,E=P?.id):m=!0:(E=P?.id,u=P,O=!0):k>85&&(I===g?(u=P,O=!0):m=!0)}}const C=Sn(t.files[0]),U={...wK(n,O,t.bills[0],u,E),file:C},B=$K(U,m,h,g,I);if(u!=null){let x=[];return u.vendorCurrencyCode!=null&&u.vendorCurrencyCode!=="USD"&&x.push(ya(!0,{amount:U.recipientTotalAmount?.amount??0,currencyCode:u.vendorCurrencyCode,currencySymbol:u.vendorCurrencySymbol},"USD")),x=[...x,lt({billDetailLocalData:U,billId:a}),aa(u.qboId,!1),_c(u.name,u.id,U.totalAmount?.amount??0,U.recipientTotalAmount?.amount??0,U.whatForSection?.invoiceNumber),Ac(!1),Ss({addBillAutoFields:B,billId:a}),xc({fetchState:{fetchState:"Completed",error:void 0},billId:a})],_(x)}{const x=[lt({billDetailLocalData:U,billId:a}),Ac(!1),Ss({addBillAutoFields:B,billId:a}),xc({fetchState:{fetchState:"Completed",error:void 0},billId:a})];return E!=null&&P!=null&&x.push(aa(P.qboId,!1)),_(x)}}{const u=Sn(t.files[0]);return p(lt({billDetailLocalData:{...Uc.billDetailLocalData,file:u},billId:a}),Ss({addBillAutoFields:Uc.addBillAutoFields,billId:a}),xc({fetchState:{fetchState:"Completed",error:void 0},billId:a}))}}))),(s,i)=>s.pipe(S(AL.match),y((r=>{const{receiptsProcessingPayload:t,lineId:e,reimbursementId:a,shouldOverwrite:n,signedInUserId:o}=r.payload,c=i.value,d=a!=null?c.editRemiDetailViewState.editRemiStateById[a]:c.editRemiDetailViewState.newRemiState,l=H(c).accountingClassIDs?.[0],u={...d.remiDetailLocalData.updatesByLineId};if(n===!1){let m=e;t.receipts.forEach((g=>{u[m]={...u[m],type:"out_of_pocket",fileId:g.file_id??"",lineId:String(m)},m++}));const h=t.files.map((g=>Sn(g)));return p(vd({remiDetailLocalData:{...d.remiDetailLocalData,files:d.remiDetailLocalData.files!=null?[...d.remiDetailLocalData.files,...h]:h,updatesByLineId:u},reimbursementId:a}),lI({reimbursementId:a,fetchState:"Completed"}))}{const m=[],h=[],g={};t.merchants.forEach((C=>{C.merchant_id&&(g[C.merchant_id]=NL(C))}));const I={},b={};let E=e;const P=OL(c.merchantState,c.merchantListState.merchantIds);t.receipts.forEach((C=>{const U=C.merchant_id,B=g[U],x=B?.name;let k;x!=null&&x.length>0&&(k=P.filter((L=>L.name.toLowerCase()===x.toLowerCase()))[0]),u[E]={lineId:String(E),type:"out_of_pocket",fileId:C.file_id??"",homeCurrencyConversions:{amount:C.amount,currencyCode:C.currency_code??"USD",currencySymbol:C.currency_symbol??"$"},outOfPocket:{...GK(c.accountState,c.classState,C,k,l)},mileage:{}},C.currency_code!=="USD"&&h.push(cI("USD",E.toString(),a)),I[E]=zK(u[E]);const J=KK(u[E],x);J!=null&&J!==""&&(b[E]=J),k!=null?m.push(hd(!1,E.toString(),a,k.id,void 0)):m.push(hd(!1,E.toString(),a,void 0,b[E])),E++}));const O=t.files.map((C=>Sn(C)));return m.push(vd({remiDetailLocalData:{...d.remiDetailLocalData,files:d.remiDetailLocalData.files!=null?[...d.remiDetailLocalData.files,...O]:O,updatesByLineId:u},reimbursementId:a}),CL({reimbursementId:a,addRemiAutoFields:I}),xL({reimbursementId:a,tentativeMerchantNameByLineId:b}),...h,lI({reimbursementId:a,fetchState:"Completed"})),o!=null&&m.push(Id(o,!0,a)),_(m)}}))),(s,i,r)=>s.pipe(S(rC.match),A((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n}=t.payload,o=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/${n}`;return r.getJSON(o).pipe(y((c=>T(c)===!0&&c.data!=null?_([Cs({accountId:e,selectedPeriod:a,parsedStatementData:sC(c.data)}),ty({accountId:e,selectedPeriod:a})]):p(xs({accountId:e,selectedPeriod:a,error:c.status})))),v((c=>p(xs({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Parse Statement REST API call errored out "+(c instanceof Error?c.message:String(c)))})))))}))),(s,i,r)=>s.pipe(S(YV.match),y((t=>{const{target:e,companyId:a,fileId:n,documentType:o}=t.payload,c=`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/documents/process/sync`,d={provided_document_type:o,files:[{file_id:n}],processing_priority:10,metadata:{source:"kyc_kyb_autofill"}},l=HV({target:e,fileId:n});return r.postAndGetJSON(c,d).pipe(y((u=>{if(!T(u)||u.data==null)return p(l);const m=u.data.files?.[0]?.extracted_data;if(m==null)return p(l);let h;switch(o){case"certificate_of_incorporation":h=(I=>{const b={values:{},autoFilledFieldNames:[]};if(ne(I.company_legal_name)&&ce(b,"companyLegalName",I.company_legal_name.value),ne(I.ein)&&ce(b,"taxIdOrEIN",I.ein.value),ne(I.phone_number)&&ce(b,"phone",I.phone_number.value),ne(I.product_description)&&ce(b,"companyDescription",I.product_description.value),ne(I.website))try{ce(b,"website",zV(I.website.value))}catch{}if(ne(I.industry)&&ce(b,"companyIndustryType",I.industry.value),ne(I.sub_industry)&&ce(b,"companySubIndustry",I.sub_industry.value),ne(I.type_of_incorporation)&&ce(b,"typeOfIncorporation",I.type_of_incorporation.value),ne(I.date_of_incorporation)){const E=Dl(I.date_of_incorporation.value);E!=null&&ce(b,"incDate",E)}return ne(I.state_of_incorporation)&&ce(b,"stateOfIncorporation",I.state_of_incorporation.value),ne(I.countries_of_operations)&&ce(b,"countriesOfOperations",I.countries_of_operations.value),ne(I.source_of_funds)&&ce(b,"sourceOfFunds",I.source_of_funds.value),ne(I.transaction_volume_expectations)&&ce(b,"transactionVolume",I.transaction_volume_expectations.value),ne(I.purpose_of_account)&&ce(b,"purposeOfAccount",I.purpose_of_account.value),ne(I.regulated_status)&&ce(b,"regulatedStatus",I.regulated_status.value),ne(I.us_nexus)&&ce(b,"usNexus",I.us_nexus.value),b})(m);break;case"tax_ein":h=(I=>{const b={values:{},autoFilledFieldNames:[]};return ne(I.legal_business_name)&&ce(b,"companyLegalName",I.legal_business_name.value),ne(I.ein)&&ce(b,"taxIdOrEIN",I.ein.value),b})(m)}if(h.autoFilledFieldNames.length===0)return p(l);const g=e==="setup"?QV({companyId:a,fileId:n,values:h.values,autoFilledFieldNames:h.autoFilledFieldNames}):WV({companyId:a,fileId:n,values:h.values,autoFilledFieldNames:h.autoFilledFieldNames});return p(g)})),v((()=>p(l))))}))),(s,i,r)=>s.pipe(S(ZV.match),y((t=>{const{target:e,companyId:a,officerType:n,fileId:o,documentType:c}=t.payload,d=`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/documents/process/sync`,l={provided_document_type:c,files:[{file_id:o}],processing_priority:10,metadata:{source:"kyc_kyb_autofill"}},u=XV({target:e,fileId:o});return r.postAndGetJSON(d,l).pipe(y((m=>{if(!T(m)||m.data==null)return p(u);const h=m.data.files?.[0]?.extracted_data;if(h==null)return p(u);let g;switch(c){case"passport":g=(b=>{const E={values:{},autoFilledFieldNames:[]};if(ne(b.first_name)&&ce(E,"firstName",b.first_name.value),ne(b.last_name)&&ce(E,"lastName",b.last_name.value),ne(b.date_of_birth)){const P=Dl(b.date_of_birth.value);P!=null&&ce(E,"birthday",P)}return ne(b.nationality)&&ce(E,"nationalityCountryCode",b.nationality.value),E})(h);break;case"driving_license":g=(b=>{const E={values:{},autoFilledFieldNames:[]};if(ne(b.first_name)&&ce(E,"firstName",b.first_name.value),ne(b.last_name)&&ce(E,"lastName",b.last_name.value),ne(b.date_of_birth)){const B=Dl(b.date_of_birth.value);B!=null&&ce(E,"birthday",B)}const P=ne(b.address_street)?b.address_street.value.trim():void 0,O=ne(b.address_city)?b.address_city.value.trim():void 0,C=ne(b.address_state)?b.address_state.value.trim():void 0,U=ne(b.address_zip)?b.address_zip.value.trim():void 0;return P==null&&O==null&&C==null&&U==null||(E.address={street:P!=null?[P]:[],city:O??"",state:C??"",postalCode:U??"",country:"USA",countryCode:"US"},E.autoFilledFieldNames.push("officerAddress")),E})(h);break;case"social_security_card":g=(b=>{const E={values:{},autoFilledFieldNames:[]};if(ne(b.full_name)){const{firstName:P,lastName:O}=(C=>{const U=C.trim().split(/\s+/);if(U.length===1)return{firstName:U[0],lastName:""};const B=U[U.length-1];return{firstName:U.slice(0,-1).join(" "),lastName:B}})(b.full_name.value);P!==""&&ce(E,"firstName",P),O!==""&&ce(E,"lastName",O)}return E})(h)}if(g.autoFilledFieldNames.length===0)return p(u);const I=[e==="setup"?eL({companyId:a,officerType:n,fileId:o,values:g.values,autoFilledFieldNames:g.autoFilledFieldNames}):tL({companyId:a,officerType:n,fileId:o,values:g.values,autoFilledFieldNames:g.autoFilledFieldNames})];if(g.address!=null){const b=`${n.toLowerCase()}_address`;I.push(qe({addressType:b,addressToCreate:g.address}))}return _(I)})),v((()=>p(u))))}))),(s,i,r)=>s.pipe(S(nw.match),y((t=>{const{localData:e,person:a}=i.value.peopleState.personDetails,{userRole:n}=a,{isZeniTenant:o}=t.payload,c=H(i.value),d=fK(e[0],o,a,c.company);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/${n.userRoleId}`,d).pipe(y((l=>{if(T(l)&&l.data!=null){const u=[Y(l.data?.user_roles??[]),ow(),N({messageSection:"people_update_person",messageText:"success",type:"success"})];return l.data?.user_roles&&Vn(u,l.data?.user_roles[0]),_(u)}{const u=[pg(l.status)];return _(u)}})),v((l=>p(pg(f("Unexpected error","User Roles save updates errored out"+JSON.stringify(l)))))))}))),(s,i)=>s.pipe(S(no.match),y((r=>{const t=i.value.cardPolicyState.policyDocumentExtraction,e=t.aiCfoAnswerId,a=t.aiCfoChatSessionId,n=t.extractedRules;return e==null||a==null||n==null?F:p(Ql(e,a,n))}))),(s,i,r)=>s.pipe(S(Ql.match),A((t=>{const{answerId:e,chatSessionId:a,extractedRules:n}=t.payload,o={extracted_rules:{allowed_entity:{category_codes:n.allowedEntity.categoryCodes,merchant_names:n.allowedEntity.merchantNames},blocked_entity:{category_codes:n.blockedEntity.categoryCodes,merchant_names:n.blockedEntity.merchantNames},confidence_score:n.confidenceScore,policy_name:n.policyName,required_receipt_threshold:n.requiredReceiptThreshold,transaction_limit:n.transactionLimit}};return r.postAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/ai-cfo/policy-recommendation-from-upload`,o).pipe(y((c=>{if(!M(c)||c.data?.wizard_plan?.step_5_review==null)return p(Wl(c.status));const d=c.data,l=d.wizard_plan.step_5_review,u={step5Review:{draftPolicies:(l.draft_policies??[]).map(((h,g)=>({id:`draft-${g}`,name:h.name,description:h.description??"",mode:h.mode,allowedEntity:{categoryCodes:h.allowed_entity?.category_codes??[],merchantNames:h.allowed_entity?.merchant_names??[]},blockedEntity:{categoryCodes:h.blocked_entity?.category_codes??[],merchantNames:h.blocked_entity?.merchant_names??[]},applyToCards:h.apply_to_cards??[],requiredReceiptThreshold:h.required_receipt_threshold??0,spendLimits:{transaction:h.spend_limits?.transaction??0}}))),groupingSource:l.grouping_source??"none",prompt:l.prompt??""}},m=d.source!=null?{confidenceScore:d.source.confidence_score,fileName:d.source.file_name,lowConfidenceFields:d.source.low_confidence_fields??[]}:void 0;return p(yP(),mP({answerId:e,chatSessionId:a,wizardPlan:u,source:m}),pP(u,m))})),v((c=>p(Wl(f("Unexpected Error","Policy recommendation from upload REST API call errored out"+JSON.stringify(c)))))),De(s.pipe(S(Kl.match))))}))),(s,i,r)=>s.pipe(S((t=>Er.match(t)||Na.match(t))),y((t=>{const{batchId:e}=t.payload;let a=!1;const n=Na.match(t)?5e3:3e4;return Ha(n,1e4).pipe(De(vt(s.pipe(S(Ds.match)),s.pipe(S(pi.match),S((o=>o.payload.batchId===e&&o.payload.status==="completed"))),s.pipe(S(Aa.match),S((o=>o.payload.batchId===e))),s.pipe(S(Ry.match),S((o=>o.payload.batchId===e))))),A((()=>r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${e}`).pipe(y((o=>{if(T(o)&&o.data!=null&&zn(o.data.status)){const c=[],d=Kn(o.data.files);return d.length>0&&c.push(Ce(d,(l=>l.transaction_id))),c.push(Aa(Yn(o.data,r.apiEndPoints.fileMicroServiceBaseUrl))),c.push(Pr({cacheOverride:!0})),_(c)}return F})),v((()=>a?F:(a=!0,p(N({messageSection:"receipts_upload",messageText:"failed",type:"error"})))))))))}))),(s,i)=>s.pipe(S(Pa.match),y((r=>{const t=i.value,{period:e}=r.payload,{selectedPageTab:a}=t.expenseAutomationJESchedulesViewState.uiState,n=nx.find((l=>l!==a));if(n==null)return F;const o=H(t),c=t.expenseAutomationViewState.selectedPeriodByTenantId[o.tenantId];if(c==null)return F;const d=cy(n,Ee(c));return t.expenseAutomationJESchedulesViewState.jeScheduleTransactionKeysByPeriodAndTab[d]!=null?F:p(Qa(e,!0,n))}))),s=>s.pipe(S(pi.match),S((i=>i.payload.status==="completed")),si(300),y((i=>_([Pr({cacheOverride:!0}),wy({batchId:i.payload.batchId})])))),HG,(s,i,r)=>s.pipe(S(XB.match),y((t=>{const e=i.value.invoicingRecordPaymentState.newPaymentDraft,a=t.payload.invoiceId;if(a!=null&&a!==""){const u=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(a)}/record-payment`,m=eD(e);return r.postAndGetJSON(u,m).pipe(y((h=>T(h)&&h.data!=null?[Ca([h.data],"merge"),Br({invoiceId:a}),Zh({invoiceId:a}),N({messageSection:"invoicing_payment_recorded",messageText:"success",type:"success"})]:_([Xs(h.status),N({messageSection:"invoicing_payment_recorded",messageText:"failed",type:"error",variables:Ie(h.status)})]))),v((h=>_([Xs(f("Unexpected Error","Record payment REST API call errored out "+JSON.stringify(h))),N({messageSection:"invoicing_payment_recorded",messageText:"failed",type:"error"})]))))}const n=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/payments`,o=tD(e),c=(d=i.value,(l=d.invoicingRecordPaymentState.newPaymentDraft.invoiceToLink).trim()!==""?l.trim():void 0);var d,l;return r.postAndGetJSON(n,{...o}).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[Zs([u.data],"merge"),aD(u.data.id),Zh({transactionId:u.data.id})];return c!=null&&m.push(Br({invoiceId:c})),m.push(N({messageSection:"invoicing_payment_recorded",messageText:"success",type:"success"})),m}return _([Xs(u.status),N({messageSection:"invoicing_payment_recorded",messageText:"failed",type:"error",variables:Ie(u.status)})])})),v((u=>_([Xs(f("Unexpected Error","Record payment REST API call errored out "+JSON.stringify(u))),N({messageSection:"invoicing_payment_recorded",messageText:"failed",type:"error"})]))))}))),s=>s.pipe(S((i=>Tx.match(i)||Ax.match(i))),y((()=>p(Tr(void 0,!0))))),(s,i,r)=>s.pipe(S(wy.match),y((t=>{const{batchId:e}=t.payload,a=Date.now(),n=i.value.expenseAutomationMissingReceiptsViewState.bulkUpload.lastBatchDetailRefreshAtById[e];if(n!=null&&a-n<5e3)return F;const o=r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${e}`).pipe(y((c=>{if(!T(c)||c.data==null||!zn(c.data.status))return F;const d=[],l=Kn(c.data.files);return l.length>0&&d.push(Ce(l,(u=>u.transaction_id))),d.push(Gn(Yn(c.data,r.apiEndPoints.fileMicroServiceBaseUrl))),_(d)})),v((c=>(console.error(`Failed to refresh batch details for ${e}:`,f("Unexpected Error","Refresh batch details errored out: "+JSON.stringify(c))),p(S0({batchId:e}))))));return j(p(Nx({batchId:e,timestamp:a})),o)}))),(s,i)=>s.pipe(S(EC.match),A((()=>{const r=i.value,t=H(r),e=t.companyId,{selectedTransactionCategorizationTab:a}=r.expenseAutomationTransactionsViewState,{selectedPeriodByTenantId:n,currentSelectedView:o}=r.expenseAutomationViewState,c=n[t.tenantId],{selectedAccountId:d}=r.expenseAutomationReconciliationViewState,l=Re(c),u=ge(l.start),m=ge(l.end);if(u==null||m==null||e==null)throw Error(`Invalid start - ${u} and end - ${m} period from given ${c}`);switch(o){case"missing_receipts":return _([vr({start:u,end:m},{amount:75,currencyCode:"USD",currencySymbol:"$"},!0,!0)]);case"flux_analysis":return _([ks(c,!0,!0,null)]);case"je_schedules":return _([Pa({start:u,end:m},!0)]);case"month_end_insights":return _([Kp(!0,e,t.tenantId,l.end,!0),Gp(e,t.tenantId)]);case"reconciliation":return _(d!=null?[Rt(c,d,!0,!0)]:[Rt(c,void 0,!0,!0)]);default:return _([fr(a,{start:u,end:m},!0,!1,void 0,void 0,!0,void 0)])}}))),(s,i,r)=>s.pipe(S(cR.match),A((()=>{const t=[];return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/settings/refresh-all-entities`).pipe(qu(3e3),y((e=>T(e)&&e.data!=null?(t.push(N({messageSection:"data_refresh_update",messageText:"success",type:"success"}),dR()),_(t)):(t.push(hf()),_(t)))),v((()=>(t.push(hf()),_(t)))))}))),(s,i,r)=>s.pipe(S(VJ.match),A((()=>r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/operating-expenses-by-vendor/refresh`).pipe(y((t=>{if(t.status.code>=200&&t.status.code<300){const e=t.status.last_refresh_success_time!=null?ee(t.status.last_refresh_success_time):void 0;return p(LJ({lastRefreshSuccessTime:e}))}return p(ag(t.status))})),v((t=>p(ag(f("Unexpected error","Refresh OpEx by Vendor REST API call errored out: "+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(_G.match),y((t=>{const{merchantId:e}=t.payload,{globalMerchantState:a,vendorGlobalReviewViewState:n}=i.value,{vendorGlobalByMerchantId:o}=n,c=o[e].vendorGlobalReviewViewLocalData,d=yE(a,_E(c.tenantId,e));if(c!=null&&d!=null){const l=Array({globalMerchants:Qn(a,c.recommendationIds)}),u=Array({globalMerchants:c.recommendedNonExistingGlobalMerchants}),m=Xn(l,u),h={...kY(d,m)};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/reviews/global-merchant-list/${e}`,h).pipe(y((g=>{if(M(g)){const I=[{variableName:"_merchant_name_",variableValue:d.tenantMerchantName}],b=[hG(e),N({messageSection:"reject_global_merchant",messageText:"success",type:"success",variables:I})];return _(b)}return g.status.code===409?p(yl({merchantId:e,status:g.status})):p(yl({merchantId:e,status:g.status}),N({messageSection:"reject_global_merchant",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]}))})),v((g=>p(yl({merchantId:e,status:f("Unexpected Error","Reject Vendor Global Review REST API call errored out"+JSON.stringify(g))})))))}return p([])}))),(s,i,r)=>s.pipe(S(zR.match),A((t=>{const{approvalRuleIds:e,useV3:a}=t.payload,n=`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2/reorder`;return r.putAndGetJSON(n,{rule_ids:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.approval_rules.map((l=>l.approval_rule_id)),d=[We(o.data.approval_rules),KR(c),N({messageSection:"bill_pay_approval_reorder",messageText:"success",type:"success"})];return _(d)}{const c=[Zf(o.status),N({messageSection:"bill_pay_approval_reorder",messageText:"failed",type:"error"}),vc(!0,!0,a)];return _(c)}})),v((o=>_([Zf(f("Unexpected Error","Reorder Bill Pay Approval Rules errored out"+JSON.stringify(o))),N({messageSection:"bill_pay_approval_reorder",messageText:"failed",type:"error"}),vc(!0,!0,a)]))))}))),(s,i,r)=>s.pipe(S(WL.match),A((t=>{const{approvalRuleIds:e,useV3:a}=t.payload,n=`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2/reorder`;return r.putAndGetJSON(n,{rule_ids:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.approval_rules.map((l=>l.approval_rule_id)),d=[We(o.data.approval_rules),ZL(c),N({messageSection:"reimbursement_approval_reorder",messageText:"success",type:"success"})];return _(d)}return _([TI(o.status),N({messageSection:"reimbursement_approval_reorder",messageText:"failed",type:"error"}),Od(!0,!1,!1,a)])})),v((o=>_([TI(f("Unexpected Error","Reorder Reimbursement Approval Rules errored out"+JSON.stringify(o))),N({messageSection:"reimbursement_approval_reorder",messageText:"failed",type:"error"}),Od(!0,!1,!1,a)]))))}))),(s,i,r)=>s.pipe(S(nC.match),A((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n}=t.payload;return r.postAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements/${n}/reparse`).pipe(y((o=>{if(T(o)===!0&&o.data!=null){const c=ba(e,a);return _([oC(c,o.data),iC({accountId:e,selectedPeriod:a})])}return p(ay({accountId:e,selectedPeriod:a,error:o.status}))})),v((o=>p(ay({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Reparse Statement REST API call errored out "+(o instanceof Error?o.message:String(o)))})))))}))),(s,i,r)=>s.pipe(S(s$.match),y((t=>{const{reportIdToResync:e}=t.payload,a=n$(e)||o$(e),n=a?"generate-group-by-project-reports":"generate-group-by-class-reports";return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/tasks/${n}`,{is_hard_refresh:!0}).pipe(A((o=>{if(T(o)){const c=[a?Lg({reportIdToResync:e}):Mg({reportIdToResync:e}),i$({hasNewData:o.status.code===200})];return _(c)}return _([qg({error:o.status}),N({messageSection:"reports_resync",messageText:"failed",type:"error"})])})),v((o=>_([qg({error:f("Unexpected error","Resync API call errored out: "+JSON.stringify(o))}),N({messageSection:"reports_resync",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(dV.match),A((t=>{const{cardId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/resend-reminder`,{card_issuance_request:!0}).pipe(y((a=>M(a)?p(st(a.data),lV({cardId:t.payload.cardId}),N({messageSection:"charge_card_resend_invite",messageText:"success",type:"success"})):p(Mv(a.status)))),v((a=>p(Mv(f("Unexpected Error","Resend Charge Card REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(cw.match),y((t=>r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/invites`,{is_reinvited:!0,user_id:t.payload.userId}).pipe(y((e=>T(e)?p(Y([e.data]),dw(t.payload.userId),N({messageSection:"people_invite_people",messageText:"success",type:"success"})):p(mg(t.payload.userId)))),v((()=>p(mg(t.payload.userId)))))))),QG,(s,i,r)=>s.pipe(S(Tw.match),A((t=>r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referrals`,{reinvite_to:t.payload.emailId}).pipe(y((e=>M(e)&&e.data!=null?[Aw({emailId:t.payload.emailId,timestamp:e.data.last_invite_timestamp}),N({messageSection:"referral_invite_sent",messageText:"success",type:"success"})]:p(on(e.status)))),v((e=>p(on(f("Unexpected error","Resend referral REST API call errored out"+JSON.stringify(e)))))))))),WG,(s,i,r)=>s.pipe(S(VA.match),y((t=>{const e=[];if(t.payload.vendorId!=null){const a=Oe(i.value.vendorState,t.payload.vendorId);a!=null&&e.push(ls({vendorId:t.payload.vendorId,localData:bE(a)}))}else e.push(ls({localData:{},vendorId:void 0}));return _(e)}))),(s,i,r)=>s.pipe(S(xp.match),y((t=>{const e=[];if(t.payload.vendorId!=null){const a=Oe(i.value.vendorState,t.payload.vendorId);a!=null&&e.push(nr({vendorId:t.payload.vendorId,localData:wn(a,i.value)}))}else e.push(nr({localData:void 0,vendorId:void 0}));return _(e)}))),(s,i,r)=>s.pipe(S(wp.match),y((t=>{const e=[],a=Oe(i.value.vendorState,t.payload.vendorId);return a!=null&&e.push(Dp({vendorId:t.payload.vendorId,localData:Jp(a,i.value)})),_(e)}))),(s,i,r)=>s.pipe(S(Ox.match),y((()=>{const t=i.value,{expenseAutomationMissingReceiptsViewState:{bulkUpload:e},expenseAutomationViewState:{selectedPeriodByTenantId:a}}=t;if(e.phase!=="idle")return F;if(e.batchListFetchState.fetchState==="In-Progress")return F;const n=t.tenantState.loggedInUser?.userId;if(n==null)return F;const o=a[H(t).tenantId];if(o==null)return F;const{end:c,start:d}=Al(xy),l={start_date:d,end_date:c,sort_order:"desc"},u=`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(l))}`,m=`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/`,h=Ee(o),g=(e.batchListByPeriod[h]??[]).length>0&&e.batchListFetchState.fetchState==="Completed";return(g?p(null):r.getJSON(u).pipe(v((()=>p(null))))).pipe(y((I=>{const b=g?e.batchListByPeriod[h]??[]:I!=null&&T(I)&&I.data!=null?I.data.batches.map(Uy):null;if(b==null)return F;const E=g?null:Js({batchList:b,selectedPeriod:o}),P=b.filter((C=>{const U=C.status.toLowerCase();return U==="processing"||U==="pending"})),O=_(P).pipe(Oa((C=>r.getJSON(`${m}${C.batchId}`).pipe(y((U=>{if(!T(U)||U.data==null)return F;const B=U.data,x=B.user_id;return x==null||x!==n?F:Cx(B.status)?p(Na({batchId:C.batchId,totalFiles:C.totalFiles})):F})),v((()=>F))))),Ue(1));return E!=null?j(p(E),O):O})))}))),(s,i,r)=>s.pipe(S(ym.match),A((t=>{const{companyId:e}=t.payload,a=cr(i.value.tenantState,e);return a==null?_([yt({status:f("Unexpected error","Tenant not found for company")}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})]):r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounting_provider_project_enablement_status`).pipe(y((n=>T(n)&&n.data!=null?n.data.is_accounting_provider_project_apis_enabled!==!0||n.data.is_accounting_projects_enabled!==!0?_([yt({status:f("Projects not enabled in QBO","Please enable projects in QBO before enabling in the Zeni dashboard!")}),N({messageSection:"accounting_projects_qbo_not_enabled",messageText:"failed",type:"error"})]):_([pm({enabled:!0,tenantId:a}),mm(),N({messageSection:"accounting_projects_enabled_update",messageText:"success",type:"success"})]):_([yt({status:n.status}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})]))),v((n=>p(yt({status:f("Unexpected error",`Accounting provider project enablement status errored out - ${n instanceof Error?n.message:JSON.stringify(n)}`)}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})))))}))),(s,i,r)=>s.pipe(S(m$.match),y((t=>{const{companyId:e}=t.payload,a=i.value,n=Te(a.companyState,e),o=n?.company.companyInfo.tenantId,c={company_id:e,type:"direct_debit",payment_source_type:"processor_token"};return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/payment-sources`,c,Object.assign({"zeni-tenant-id":o})).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(y$({companyId:e,onboardingInfo:d.data.companies[0].onboarding_info})),d.data.companies[0].onboarding_info?.is_zeni_subscriptions_payment_account_linked!==!1?l.push(N({messageSection:"retry_bank_account_connection",messageText:"success",type:"success"})):l.push(N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error"})),_(l)}return p(Qg({companyId:e,error:d.status}),N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(Qg({companyId:e,error:f("Unexpected error","Bank account connection errored out"+JSON.stringify(d))}),N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"Bank account connection errored out"+JSON.stringify(d)}]})))))}))),(s,i,r)=>s.pipe(S(MD.match),y((t=>{const{companyId:e}=t.payload,a=i.value,n=Mi(a.companyState,e),o=n?.company.companyInfo.tenantId,c={company_id:e,type:"direct_debit",payment_source_type:"processor_token"};return o!=null?r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/payment-sources`,c,Object.assign({"zeni-tenant-id":o})).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(VD({companyId:e})),d.data.companies[0].onboarding_info?.is_zeni_subscriptions_payment_account_linked!==!1?l.push(N({messageSection:"retry_bank_account_connection",messageText:"success",type:"success"}),LD({companyId:e,onboardingInfo:d.data.companies[0].onboarding_info})):l.push(N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error"})),_(l)}return p(AS({companyId:e,error:d.status}),N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(AS({companyId:e,error:f("Unexpected error","Bank account connection for onboarding errored out"+JSON.stringify(d))}),N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"Bank account connection for onboarding errored out"+JSON.stringify(d)}]}))))):_([])}))),(s,i,r)=>s.pipe(S(ox.match),A((t=>{const e=i.value,{expenseAutomationJESchedulesViewState:{jeScheduleLocalDataById:a},expenseAutomationViewState:{selectedPeriodByTenantId:n}}=e,o=H(e),c=n[o.tenantId],{scheduledJournalEntryID:d,jeScheduleTransactionKey:l}=t.payload,u=a[d];if(u==null)return _([]);const m={...Gz(u)};return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/retry_sje_posting`,m).pipe(y((h=>{if(M(h)){const g=[];return g.push(ix({scheduledJournalEntryID:d}),cx(l,c),dx({scheduledJournalEntryID:d}),et({tenantId:o.tenantId,period:c,refreshViewInBackground:!0}),N({messageSection:"je_posted",messageText:"success",type:"success"})),_(g)}{const g=[];return g.push(Ay({status:h.status,scheduledJournalEntryID:d})),g.push(N({messageSection:"je_posted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:h.status.message}]})),_(g)}})),v((h=>{const g=[];return g.push(Ay({status:f("Unexpected Error","retry JE schedule posting REST API call errored out"+JSON.stringify(h)),scheduledJournalEntryID:d})),g.push(N({messageSection:"je_posted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(h)}]})),_(g)})))}))),(s,i,r)=>s.pipe(S(wB.match),y((t=>{const{taskId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/sync-tasks/${encodeURIComponent(e)}/retry`;return r.postAndGetJSON(a,{}).pipe(y((n=>T(n)?p($B({status:n.data?.status??"",taskId:n.data?.task_id??e}),xi(),N({messageSection:"invoicing_qbo_sync_health_retry",messageText:"success",type:"success"})):_([Fh({status:n.status,taskId:e}),N({messageSection:"invoicing_qbo_sync_health_retry",messageText:"failed",type:"error",variables:Ie(n.status)})]))),v((n=>_([Fh({status:f("Unexpected Error","Retry QBO sync task REST API call errored out "+JSON.stringify(n)),taskId:e}),N({messageSection:"invoicing_qbo_sync_health_retry",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(JR.match),y((t=>{const{billId:e,actionType:a}=t.payload,{editBillDetailViewState:n}=i.value,o=Ne(e),c=n.editBillStateById[o];let d,l=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}`;if(a==="retry"){const u=c.billDetailLocalData.paymentDetailsSection;l=`${l}/payment/retry`,d=c.billDetailLocalData.isCollectToAccountInfoFromVendorContact?{bill_pay_info:{to_account_vendor_email:c.billDetailLocalData.toAccountVendorEmail??null,is_collect_to_account_info_from_vendor_contact:c.billDetailLocalData.isCollectToAccountInfoFromVendorContact}}:{bill_pay_provider:"zeni",bill_pay_info:{payment_date:u?.paymentDate??null,to_account:u?.paymentType?.method.includes("international")===!0?{payment_instrument_id:u?.paymentTo??null}:{account_id:u?.paymentTo??null},from_account:{account_id:u?.withdrawFrom?.id??null,account_type:u?.withdrawFrom?.accType?Me(La(u?.withdrawFrom?.accType)):null}}}}else l=`${l}/payment/refund`;return r.putAndGetJSON(l,d).pipe(y((u=>{if(T(u)){const m=[];return u.data!=null&&u.data.transactions[0]?.transaction_id!=null&&m.push(mn(u.data.transactions[0])),m.push(wR(t.payload.billId,t.payload.actionType)),m.push(N({messageSection:t.payload.actionType==="refund"?"bill_pay_refund":"bill_pay_retry",messageText:"success",type:"success"})),_(m)}return p(wf(e,t.payload.actionType,u.status),N({messageSection:"bill_pay_cancelled_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:u.status.message}]}))})),v((u=>p(wf(t.payload.billId,t.payload.actionType,f("Unexpected Error","Retry Refund bill REST API call errored out "+JSON.stringify(u)))))))}))),(s,i,r)=>s.pipe(S(lx.match),y((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a}}=e,{jeScheduleId:n,jeScheduleTransactionKey:o,reason:c,note:d,scheduleType:l}=t.payload,u=H(e),m=a[u.tenantId],h={je_schedules:[{je_schedule_id:n,feedback:{reason:c,...d!=null&&d!==""?{note:d}:{}}}]};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${n}/revert`,h).pipe(y((g=>T(g)&&g.data!=null?_([ux({jeScheduleTransactionKey:o}),l==="accrued_expenses"?px(o):fy(o,m),et({tenantId:u.tenantId,period:m,refreshViewInBackground:!0}),N({messageSection:"revert_schedule",messageText:"success",type:"success"})]):_([Ny({jeScheduleTransactionKey:o,status:g.status}),N({messageSection:"revert_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]})]))),v((g=>_([Ny({jeScheduleTransactionKey:o,status:f("Unexpected Error",`Revert schedule REST API call errored out ${JSON.stringify(g)}`)}),N({messageSection:"revert_schedule",messageText:"failed",type:"error"})]))),De(s.pipe(S(gt.match))))}))),(s,i,r)=>s.pipe(S(lF.match),y((()=>{const{remisBulkActionViewState:t}=i.value,e={entity_ids:t.remisSelectedForBulkAction};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/reimbursements/transactions/validate?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(M(a)){const n=[];return n.push(uF(a.data?.validation_results??[])),_(n)}return p(kI(a.status))})),v((a=>p(kI(f("Unexpected Error","Remi bulk review action REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(NC.match),y((t=>{const{actionType:e,operatingExpenseIds:a,selectedPeriod:n}=t.payload,o={...Rz(e,a)},c=H(i.value);return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/month-close/flux-analysis
1
+ import{h0 as S,fE as dP,h1 as A,h2 as y,h3 as v,h4 as De,fD as Kl,h5 as M,h6 as p,h7 as no,h8 as Yl,h9 as f,f_ as lP,ha as uP,hb as Hl,hc as F,hd as Ql,he as Wl,hf as pP,hg as mP,hh as yP,hi as ca,hj as Zl,hk as _P,hl as Xl,hm as W,hn as Ke,ho as le,hp as V,hq as hP,hr as _,hs as ut,ht as SP,hu as eu,hv as gP,hw as _0,hx as fP,hy as tu,hz as oo,hA as rs,hB as au,hC as vP,hD as oe,hE as IP,hF as bP,hG as ie,hH as EP,hI as PP,hJ as ru,hK as TP,hL as ar,hM as T,hN as AP,hO as su,hP as NP,hQ as OP,hR as nu,hS as CP,hT as xP,hU as ou,hV as UP,hW as kP,hX as iu,hY as be,hZ as BP,h_ as cu,h$ as du,i0 as DP,i1 as lu,i2 as uu,i3 as JP,i4 as pu,i5 as mu,i6 as io,i7 as wP,i8 as co,i9 as ss,ia as $P,gd as N,ib as yu,ic as xe,id as z,ie as lo,ig as da,ih as _u,ii as Q,ij as hu,ik as Y,il as RP,im as ot,io as Su,ip as gu,iq as ns,ir as MP,is as VP,it as fu,iu as LP,iv as FP,iw as uo,ix as vu,iy as qP,iz as jP,iA as Iu,iB as GP,iC as zP,iD as KP,iE as bu,iF as YP,iG as HP,iH as Eu,iI as QP,iJ as WP,iK as ZP,iL as XP,iM as Pu,fC as eT,iN as tT,iO as aT,iP as Tu,go as rT,iQ as j,gn as sT,gl as Au,iR as nT,iS as Ha,iT as Ue,iU as oT,iV as Nu,bE as ee,iW as iT,iX as Ou,iY as cT,iZ as dT,i_ as lT,i$ as uT,j0 as pT,j1 as mT,j2 as Cu,j3 as yT,j4 as _T,j5 as hT,j6 as xu,j7 as ST,j8 as gT,j9 as Uu,ja as fT,jb as vT,jc as IT,jd as ku,je as bT,jf as ET,jg as PT,jh as Bu,ji as TT,jj as AT,jk as Du,jl as NT,jm as OT,jn as Ju,jo as wu,jp as CT,jq as $u,gx as po,jr as xT,js as Ru,g7 as UT,jt as kT,ju as Mu,jv as BT,jw as DT,jx as JT,jy as Vu,jz as wT,jA as $T,jB as Lu,jC as RT,jD as os,jE as MT,jF as Fu,jG as VT,jH as qu,jI as ju,jJ as LT,jK as FT,jL as qT,jM as Gu,jN as mo,jO as jT,jP as zu,jQ as GT,jR as zT,jS as Ku,jT as yo,jU as re,jV as Yu,jW as KT,jX as Hu,jY as YT,jZ as Qu,j_ as HT,j$ as Wu,k0 as _o,k1 as QT,k2 as Zu,k3 as WT,k4 as ZT,k5 as Xu,k6 as XT,k7 as eA,k8 as ep,k9 as tA,ka as aA,kb as is,kc as tp,kd as ho,ke as Ot,kf as rA,kg as Ct,kh as he,ki as sA,kj as ap,kk as xt,kl as Ut,km as nA,kn as rp,ko as oA,kp as iA,kq as Je,kr as Ye,ks as sp,kt,ku as So,br as me,kv as cA,kw as la,kx as cs,ky as dA,kz as np,kA as rr,kB as lA,kC as it,kD as uA,kE as pA,kF as op,kG as mA,kH as yA,kI as _A,kJ as hA,kK as SA,kL as ip,kM as gA,kN as fA,kO as vA,kP as cp,kQ as IA,kR as bA,kS as EA,kT as dp,kU as go,kV as ua,kW as lp,kX as up,kY as ae,kZ as PA,k_ as pp,k$ as fo,l0 as TA,l1 as mp,l2 as AA,l3 as ds,l4 as NA,l5 as yp,l6 as OA,l7 as vo,l8 as Io,l9 as CA,la as _p,lb as xA,lc as bo,ld as UA,le as hp,lf as Eo,lg as Po,lh as kA,li as Sp,lj as To,lk as Bt,ll as BA,lm as Dt,ln as Fe,lo as DA,lp as gp,lq as Jt,lr as JA,ls as fp,lt as wA,lu as Ao,lv as vp,lw as $A,lx as RA,ly as Ip,lz as No,lA as bp,lB as MA,lC as Ep,lD as se,lE as Le,lF as pt,lG as Pp,lH as Tp,lI as VA,lJ as Oe,lK as ls,lL as Ze,lM as Qr,lN as Xa,lO as Wr,lP as LA,lQ as pa,lR as At,lS as FA,cD as Oo,lT as qA,lU as Co,lV as Ap,lW as jA,lX as GA,lY as us,lZ as sr,l_ as ps,l$ as Np,m0 as ms,m1 as zA,m2 as He,m3 as ct,m4 as ys,m5 as wt,m6 as KA,m7 as YA,m8 as HA,m9 as QA,ma as h0,mb as dt,mc as mt,md as ve,me as Op,mf as _s,mg as nr,mh as or,mi as xo,mj as Cp,mk as ma,ml as qe,mm as xp,mn as hs,gS as Te,mo as Ne,mp as Up,mq as es,mr as Uo,ms as ya,mt as Ss,mu as WA,mv as lt,bQ as eo,mw as aa,mx as ir,my as kp,mz as ZA,mA as XA,mB as Bp,mC as eN,mD as tN,mE as ko,mF as Bo,mG as Do,mH as gs,mI as Jo,mJ as aN,mK as Dp,mL as Jp,mM as wp,mN as rN,mO as wo,mP as sN,mQ as $o,mR as nN,mS as $p,mT as Ro,mU as Rp,mV as oN,mW as Mp,mX as Vp,mY as iN,mZ as cN,m_ as dN,m$ as lN,n0 as Lp,n1 as uN,n2 as pN,n3 as mN,n4 as Fp,n5 as qp,n6 as yN,n7 as _N,n8 as jp,n9 as Gp,na as hN,nb as zp,nc as Kp,nd as SN,ne as Yp,nf as gN,ng as fN,nh as Hp,ni as vN,c9 as Qp,nj as Wp,nk as IN,nl as Zp,nm as Xp,nn as bN,no as Mo,np as EN,nq as PN,nr as TN,ns as em,nt as AN,nu as tm,nv as fs,nw as Vo,nx as NN,ny as ze,nz as Zr,nA as am,nB as ON,nC as CN,nD as rm,nE as xN,nF as Lo,nG as sm,nH as nm,nI as UN,nJ as om,nK as kN,nL as BN,nM as im,nN as cm,nO as Fo,nP as DN,nQ as dm,nR as JN,nS as cr,nT as lm,g as X,gF as dr,nU as lr,nV as _a,nW as ha,nX as ur,nY as Sa,nZ as um,n_ as vs,n$ as ga,o0 as wN,o1 as pm,o2 as mm,o3 as yt,o4 as $N,o5 as RN,o6 as ym,o7 as MN,o8 as _m,o9 as hm,oa as Sm,ob as VN,oc as LN,od as FN,oe as gm,of as qN,og as jN,oh as GN,oi as fm,oj as zN,ok as vm,ol as KN,om as Im,on as Fl,oo as _t,op as bm,oq as YN,or as HN,os as Em,ot as QN,ou as Pm,ov as WN,ow as fa,ox as je,oy as pr,oz as mr,oA as yr,oB as _r,oC as hr,oD as Tm,oE as qo,oF as ZN,oG as XN,oH as Am,oI as eO,oJ as tO,oK as aO,oL as rO,oM as sO,oN as nO,oO as Nm,oP as oO,oQ as Om,oR as Cm,oS as iO,oT as xm,oU as cO,oV as jo,oW as dO,oX as lO,oY as uO,oZ as pO,o_ as Is,o$ as va,p0 as Be,p1 as bs,p2 as mO,p3 as yO,p4 as _O,p5 as hO,p6 as wl,p7 as $l,p8 as SO,p9 as gO,pa as fO,pb as Um,pc as vO,pd as IO,pe as bO,pf as km,pg as EO,ph as Bm,pi as PO,pj as Dm,pk as TO,pl as Go,pm as AO,pn as NO,po as OO,pp as Jm,pq as CO,pr as xO,ps as UO,pt as wm,pu as kO,fB as H,c7 as BO,bq as DO,pv as JO,pw as Ia,px as Es,py as Ps,pz as Ts,pA as zo,pB as Ko,pC as Yo,pD as Ho,pE as Qo,pF as Wo,pG as et,pH as $m,pI as Rm,pJ as Mm,pK as Ee,pL as As,pM as wO,pN as Vm,pO as $O,pP as RO,pQ as Lm,pR as MO,pS as $t,pT as VO,pU as LO,pV as FO,pW as qO,pX as Fm,pY as jO,pZ as ba,p_ as qm,p$ as jm,q0 as Sr,q1 as GO,q2 as Gm,q3 as Zo,gM as Rt,q4 as zO,q5 as Ea,q6 as Ns,q7 as zm,q8 as KO,q9 as Km,qa as YO,qb as Ym,qc as Xo,qd as ei,qe as gr,qf as Hm,qg as Qm,qh as HO,qi as Os,qj as Re,qk as QO,ql as WO,qm as Wm,qn as ZO,qo as Zm,qp as Xm,qq as XO,qr as eC,qs as ey,gP as tC,qt as Cs,qu as aC,qv as ty,qw as xs,gN as rC,qx as sC,qy as nC,qz as oC,qA as iC,qB as ay,qC as cC,qD as ti,bM as Us,qE as dC,qF as lC,qG as ry,qH as uC,qI as pC,qJ as mC,qK as yC,qL as _C,qM as ht,qN as sy,qO as ny,qP as oy,qQ as iy,qR as hC,qS as SC,qT as ra,qU as gC,qV as fC,qW as ai,qX as vC,qY as IC,qZ as bC,q_ as ge,q$ as fr,r0 as vr,r1 as ks,r2 as Pa,r3 as cy,r4 as EC,r5 as PC,r6 as TC,r7 as AC,r8 as dy,r9 as NC,ra as OC,rb as ly,rc as CC,rd as uy,re as xC,rf as py,rg as my,rh as UC,ri as yy,rj as _y,rk as kC,rl as ri,rm as BC,rn as Qa,ro as Ir,rp as DC,rq as JC,rr as tr,rs as St,rt as hy,ru as br,rv as Ta,rw as wC,rx as Sy,gV as gt,ry as $C,rz as RC,rA as gy,rB as MC,rC as ft,rD as VC,rE as fy,rF as vy,rG as LC,rH as FC,rI as qC,rJ as Iy,rK as jC,rL as by,rM as GC,rN as zC,rO as KC,rP as Ey,rQ as Bs,rR as YC,rS as HC,rT as QC,rU as si,rV as vt,rW as ni,rX as WC,rY as Py,rZ as Ty,r_ as ZC,r$ as oi,s0 as XC,s1 as ex,s2 as tx,s3 as ax,s4 as rx,s5 as sx,s6 as nx,s7 as ox,s8 as ix,s9 as cx,sa as dx,sb as Ay,sc as lx,sd as ux,se as px,sf as Ny,sg as mx,sh as Gn,si as Aa,sj as Ds,sk as Er,sl as Na,sm as yx,sn as ii,f6 as _x,so as hx,sp as Sx,sq as gx,sr as Oy,ss as ci,st as di,su as Cy,sv as zn,sw as Kn,sx as Ce,sy as Yn,sz as Pr,sA as Js,sB as xy,sC as Uy,sD as ky,sE as Tr,sF as fx,sG as li,sH as vx,sI as By,sJ as Ix,sK as Dy,sL as Jy,sM as Ar,sN as bx,sO as S0,sP as Ex,sQ as Px,sR as Tx,sS as Ax,sT as wy,sU as Nx,sV as Ox,sW as Oa,sX as Cx,sY as xx,fw as ui,sZ as Ux,s_ as kx,s$ as $y,t0 as Bx,gK as pi,t1 as Dx,t2 as Ry,t3 as My,t4 as Jx,t5 as wx,t6 as ws,t7 as Vy,t8 as Ly,t9 as mi,ta as $s,tb as Fy,tc as Rs,td as $x,te as Rx,tf as yi,tg as Ms,th as _i,ti as qy,tj as Vs,tk as Mx,tl as Vx,tm as Lx,tn as Fx,to as jy,tp as Gy,tq as Ls,tr as zy,dh as as,ts as g0,tt as Hn,tu as f0,tv as v0,tw as I0,tx as b0,dY as qx,ty as jx,tz as Ky,tA as Yy,tB as hi,cl as E0,tC as P0,tD as T0,tE as A0,di as N0,tF as O0,tG as C0,tH as x0,tI as U0,tJ as Gx,tK as zx,tL as Kx,tM as Yx,tN as Hy,tO as Hx,tP as Qx,tQ as Qy,tR as Wx,tS as Zx,tT as Wy,tU as Xx,tV as eU,tW as Zy,tX as tU,tY as aU,tZ as Xy,t_ as e_,t$ as rU,u0 as t_,u1 as sU,u2 as nU,u3 as a_,u4 as oU,u5 as iU,u6 as Si,u7 as cU,u8 as dU,u9 as lU,ua as Mt,ub as Fs,uc as qs,ud as uU,ue as Nr,uf as ql,ba as ts,ug as pU,uh as Qn,ui as It,uj as mU,uk as yU,ul as r_,um as _U,un as hU,uo as s_,up as SU,uq as gU,ur as n_,us as fU,ut as o_,uu as i_,uv as vU,uw as Pe,ux as IU,uy as bU,uz as c_,uA as tt,uB as at,uC as d_,uD as EU,uE as l_,uF as js,uG as Gs,uH as PU,uI as u_,uJ as TU,uK as AU,uL as NU,uM as zs,uN as OU,uO as p_,uP as CU,uQ as Ca,uR as Or,uS as xU,uT as UU,uU as m_,uV as kU,uW as Ks,uX as Cr,uY as gi,uZ as Vt,u_ as BU,u$ as DU,v0 as y_,v1 as JU,v2 as wU,v3 as __,v4 as $U,v5 as RU,v6 as Ys,v7 as h_,v8 as MU,v9 as VU,va as S_,vb as k0,vc as LU,vd as g_,ve as FU,vf as qU,vg as f_,vh as jU,vi as B0,vj as v_,vk as D0,vl as GU,vm as I_,vn as zU,vo as KU,vp as YU,vq as HU,vr as QU,vs as b_,vt as WU,vu as ZU,vv as E_,vw as xr,vx as P_,vy as T_,vz as XU,vA as Ur,vB as A_,vC as N_,vD as ek,vE as tk,vF as O_,vG as ak,vH as C_,vI as x_,vJ as rk,vK as U_,dP as sk,dO as nk,vL as ok,vM as fi,vN as ik,vO as ck,vP as dk,vQ as lk,vR as uk,dQ as pk,vS as k_,vT as B_,vU as D_,vV as mk,vW as yk,vX as _k,vY as J_,vZ as hk,v_ as w_,v$ as Sk,w0 as gk,w1 as $_,w2 as fk,w3 as vk,w4 as Ik,w5 as bk,w6 as Ek,w7 as R_,w8 as vi,w9 as Ii,wa as bi,wb as M_,wc as Pk,wd as Ei,we as V_,wf as L_,wg as nt,wh as Tk,wi as F_,wj as Ak,wk as Hs,wl as q_,wm as Nk,wn as Ok,wo as Ck,wp as j_,wq as xk,cW as Uk,wr as Pi,ws as xa,wt as Ua,wu as Ti,wv as G_,ww as kk,wx as Bk,wy as Dk,wz as kr,wA as Jk,wB as wk,wC as $k,wD as z_,cX as Ai,wE as Rk,wF as Mk,wG as Vk,wH as Qs,wI as K_,wJ as Y_,wK as Lk,wL as Fk,wM as qk,cY as jk,wN as Br,wO as Gk,wP as H_,wQ as zk,wR as Kk,wS as Q_,wT as Ws,wU as Yk,wV as W_,wW as Hk,wX as Z_,wY as X_,wZ as Qk,w_ as Wk,w$ as eh,x0 as Zk,x1 as th,x2 as Xk,x3 as eB,x4 as ah,x5 as tB,x6 as rh,x7 as aB,x8 as rB,x9 as sh,xa as sB,xb as nh,xc as nB,xd as oB,xe as Ni,xf as oh,xg as iB,xh as cB,xi as ih,xj as ch,xk as dB,xl as lB,xm as dh,xn as lh,xo as uB,xp as uh,xq as ph,xr as pB,xs as mh,xt as mB,xu as yh,xv as yB,xw as _h,xx as _B,xy as hh,xz as hB,xA as Sh,xB as Oi,xC as SB,xD as gh,xE as gB,xF as fh,xG as vh,xH as fB,xI as Ih,xJ as vB,xK as IB,xL as bh,xM as Eh,xN as bB,xO as Ph,xP as Th,xQ as EB,xR as Ah,xS as PB,xT as Nh,xU as TB,xV as Oh,xW as Ch,xX as AB,xY as xh,xZ as NB,x_ as Uh,x$ as kh,y0 as Bh,y1 as Dh,y2 as OB,y3 as CB,y4 as Ci,y5 as xB,y6 as Jh,y7 as UB,y8 as wh,y9 as kB,ya as $h,yb as BB,yc as Rh,yd as Mh,ye as DB,yf as Vh,yg as xi,yh as JB,yi as Lh,yj as wB,yk as $B,yl as Fh,ym as RB,yn as MB,yo as qh,yp as jh,yq as VB,yr as Gh,ys as LB,yt as zh,yu as FB,yv as qB,yw as Zs,yx as jB,yy as Kh,yz as GB,yA as zB,yB as Yh,yC as Hh,yD as KB,yE as Qh,yF as YB,yG as HB,yH as QB,yI as WB,yJ as ZB,yK as Wh,yL as XB,yM as eD,yN as Zh,yO as Xs,yP as tD,yQ as aD,yR as rD,yS as Xh,yT as en,yU as sD,yV as eS,yW as tS,yX as aS,yY as rS,yZ as tn,y_ as nD,y$ as oD,z0 as iD,z1 as an,z2 as cD,z3 as dD,z4 as lD,z5 as uD,z6 as pD,z7 as sS,z8 as mD,z9 as Ui,za as nS,zb as oS,zc as yD,zd as ki,ze as Bi,zf as Dr,zg as ka,zh as Ba,zi as _D,zj as iS,zk as Lt,zl as hD,zm as cS,zn as Ft,zo as SD,zp as dS,zq as lS,zr as gD,zs as uS,zt as fD,zu as vD,zv as ID,zw as pS,zx as mS,zy as bD,zz as ED,zA as yS,zB as _S,zC as PD,zD as TD,zE as hS,zF as Di,zG as Ji,zH as rn,zI as SS,zJ as wi,zK as AD,zL as $i,zM as Ri,zN as gS,zO as ND,zP as fS,zQ as OD,zR as vS,zS as CD,zT as xD,zU as IS,zV as UD,zW as kD,zX as Mi,zY as bS,zZ as BD,fY as bt,z_ as ES,z$ as PS,A0 as TS,A1 as Vi,A2 as DD,dV as JD,de as wD,A3 as $D,dU as RD,A4 as MD,A5 as VD,A6 as LD,A7 as AS,A8 as FD,A9 as qD,Aa as jD,Ab as GD,Ac as zD,Ad as NS,Ae as KD,Af as YD,Ag as OS,Ah as HD,Ai as QD,Aj as CS,Ak as WD,Al as ZD,Am as xS,An as XD,bc as eJ,Ao as tJ,Ap as US,Aq as aJ,Ar as rJ,As as kS,At as sJ,Au as nJ,Av as BS,Aw as oJ,Ax as iJ,Ay as DS,Az as Li,AA as JS,AB as sn,AC as wS,AD as Se,AE as $S,AF as cJ,AG as RS,AH as dJ,AI as lJ,AJ as MS,AK as uJ,AL as pJ,AM as VS,AN as mJ,AO as Da,AP as we,AQ as yJ,AR as _J,AS as LS,v as J0,bw as to,AT as hJ,AU as SJ,AV as Fi,AW as gJ,AX as FS,AY as qS,AZ as jS,A_ as fJ,A$ as vJ,B0 as IJ,B1 as qi,B2 as bJ,B3 as EJ,B4 as PJ,B5 as TJ,B6 as AJ,B7 as NJ,B8 as GS,B9 as OJ,Ba as CJ,Bb as zS,Bc as xJ,Bd as UJ,Be as KS,Bf as kJ,Bg as BJ,Bh as YS,Bi as DJ,Bj as JJ,Bk as HS,Bl as QS,Bm as WS,Bn as wJ,Bo as Ja,Bp as wa,Bq as $J,Br as ZS,Bs as Jr,Bt as ji,Bu as RJ,Bv as XS,Bw as eg,Bx as MJ,By as tg,Bz as VJ,BA as LJ,BB as ag,BC as rg,BD as qt,BE as FJ,BF as sg,BG as jt,BH as qJ,BI as ng,BJ as og,BK as jJ,BL as ig,BM as GJ,BN as w0,BO as zJ,BP as KJ,BQ as YJ,BR as cg,BS as HJ,BT as QJ,BU as dg,BV as WJ,f$ as $e,BW as Gi,BX as ZJ,BY as lg,BZ as XJ,B_ as ew,B$ as zi,C0 as jl,C1 as tw,C2 as aw,C3 as ug,C4 as nn,C5 as rw,C6 as sw,C7 as nw,C8 as ow,C9 as pg,er as iw,Ca as cw,Cb as dw,Cc as mg,Cd as lw,Ce as yg,Cf as Gt,Cg as uw,Ch as _g,Ci as zt,Cj as pw,Ck as hg,Cl as Sg,Cm as gg,Cn as fg,Co as vg,Cp as mw,Cq as Ig,Cr as yw,Cs as bg,Ct as wr,Cu as $r,Cv as Eg,Cw as Pg,Cx as $a,Cy as _w,Cz as hw,CA as Sw,CB as gw,CC as Tg,CD as Ag,CE as fw,CF as vw,CG as Ki,CH as Iw,CI as bw,CJ as Ew,CK as Ng,CL as Pw,CM as Og,CN as Tw,CO as Aw,CP as on,CQ as Nw,CR as Ow,CS as Cw,CT as xw,CU as Uw,CV as Cg,CW as kw,CX as xg,CY as Bw,CZ as Dw,C_ as Jw,C$ as Ug,D0 as kg,D1 as ww,D2 as $w,D3 as Rw,D4 as Mw,D5 as Vw,D6 as Lw,D7 as Fw,D8 as qw,D9 as jw,Da as Gw,Db as Yi,Dc as Bg,Dd as Dg,De as Jg,Df as wg,Dg as $g,Dh as Rg,Di as zw,Dj as Kw,Dk as Yw,Dl as Hw,Dm as Qw,Dn as Ww,Do as Zw,Dp as Xw,Dq as e$,Dr as t$,Ds as a$,Dt as r$,Du as Mg,Dv as Vg,Dw as Lg,Dx as Fg,Dy as s$,eK as n$,ez as o$,Dz as i$,DA as qg,DB as jg,DC as Gg,DD as c$,DE as Ra,DF as Ma,DG as d$,DH as Kt,DI as zg,DJ as l$,DK as Kg,DL as Yt,DM as u$,DN as Yg,DO as p$,DP as Hg,DQ as m$,DR as y$,DS as Qg,DT as sa,DU as $0,DV as R0,DW as _$,DX as Hi,DY as Va,bH as Wa,e3 as Wg,DZ as h$,D_ as S$,D$ as g$,E0 as cn,E1 as f$,E2 as v$,E3 as I$,E4 as Qi,E5 as b$,E6 as Zg,E7 as Wi,E8 as Xg,E9 as Zi,Ea as ef,Eb as E$,Ec as Rr,Ed as Xi,Ee as P$,Ef as T$,Eg as A$,Eh as dn,Ei as ln,Ej as N$,Ek as O$,El as C$,Em as tf,En as x$,Eo as un,Ep as U$,Eq as ec,Er as k$,Es as B$,Et as tc,Eu as af,Ev as Mr,Ew as ac,Ex as D$,Ey as J$,Ez as Vr,EA as rc,EB as w$,EC as $$,ED as R$,EE as M$,EF as V$,EG as sc,EH as L$,EI as F$,EJ as rf,EK as sf,EL as nc,EM as q$,EN as nf,EO as j$,EP as G$,EQ as of,ER as oc,ES as z$,ET as K$,EU as cf,EV as Y$,EW as H$,EX as Q$,EY as ic,EZ as W$,E_ as df,E$ as Z$,F0 as Ge,F1 as ke,F2 as X$,F3 as cc,F4 as lf,F5 as uf,F6 as eR,F7 as tR,F8 as pf,F9 as aR,Fa as mf,Fb as rR,Fc as sR,Fd as nR,Fe as yf,Ff as oR,Fg as _f,Fh as iR,Fi as cR,Fj as dR,Fk as hf,Fl as lR,Fm as uR,Fn as Sf,Fo as pR,Fp as mR,Fq as gf,gE as ff,Fr as vf,Fs as yR,Ft as _R,Fu as If,Fv as hR,Fw as bf,Fx as SR,Fy as gR,Fz as Ef,FA as fR,FB as vR,FC as Pf,FD as IR,FE as bR,FF as Tf,FG as ER,FH as dc,FI as PR,FJ as TR,FK as AR,FL as Af,FM as Nf,FN as NR,FO as OR,FP as Of,FQ as CR,FR as Et,FS as xR,FT as Cf,FU as UR,FV as pn,FW as xf,FX as lc,FY as Uf,FZ as mn,F_ as kR,F$ as uc,G0 as pc,G1 as kf,G2 as Lr,G3 as yn,G4 as mc,G5 as Bf,G6 as Qe,G7 as We,G8 as yc,G9 as _c,Ga as Df,Gb as hc,Gc as BR,Gd as DR,Ge as Jf,Gf as JR,Gg as Me,Gh as La,Gi as wR,Gj as wf,Gk as $R,Gl as Fr,Gm as Sc,Gn as RR,Go as gc,Gp as MR,Gq as $f,Gr as VR,Gs as Rf,Gt as LR,Gu as Mf,Gv as FR,Gw as qR,Gx as Vf,Gy as jR,Gz as fc,GA as Lf,GB as Ff,GC as vc,GD as qf,GE as jf,GF as Gf,GG as GR,GH as zf,GI as Kf,GJ as Yf,bI as Hf,GK as Qf,GL as Wf,GM as zR,GN as KR,GO as Zf,GP as YR,GQ as HR,GR as Xf,GS as QR,GT as ev,GU as rt,GV as Ht,GW as Qt,GX as tv,GY as WR,GZ as av,G_ as _n,G$ as ZR,H0 as XR,H1 as Ic,H2 as bc,H3 as Fa,H4 as e1,H5 as t1,H6 as Rl,H7 as a1,H8 as r1,H9 as rv,Ha as sv,Hb as hn,Hc as Ec,Hd as Pc,He as Tc,Hf as s1,Hg as Ac,Hh as n1,Hi as nv,Hj as o1,Hk as ov,Hl as Nc,Hm as Oc,Hn as Cc,Ho as M0,Hp as i1,Hq as V0,Hr as L0,Hs as c1,Ht as d1,bO as Gl,Hu as iv,Hv as Sn,Hw as xc,Hx as Uc,Hy as l1,Hz as u1,HA as p1,HB as cv,HC as dv,HD as m1,HE as y1,HF as _1,HG as h1,dM as S1,HH as g1,HI as F0,HJ as f1,HK as q0,cK as v1,HL as ao,HM as I1,HN as b1,HO as E1,HP as P1,HQ as T1,HR as A1,HS as kc,HT as N1,HU as O1,HV as C1,dL as lv,HW as x1,HX as U1,HY as Bc,HZ as k1,H_ as B1,H$ as gn,I0 as D1,I1 as J1,I2 as Dc,I3 as uv,I4 as pv,I5 as w1,I6 as mv,I7 as yv,I8 as _v,I9 as $1,Ia as R1,Ib as M1,Ic as hv,Id as Sv,Ie as V1,If as L1,Ig as Jc,Ih as F1,Ii as q1,Ij as j1,Ik as G1,Il as gv,Im as z1,In as K1,Io as Y1,Ip as fv,Iq as H1,dj as Q1,Ir as W1,Is as vv,It as Z1,Iu as X1,Iv,Iw as eM,Ix as wc,Iy as tM,Iz as aM,IA as bv,IB as rM,IC as $c,ID as sM,IE as nM,IF as oM,IG as Rc,IH as iM,II as Mc,IJ as cM,IK as fn,IL as dM,IM as lM,IN as uM,IO as Vc,IP as pM,IQ as mM,IR as yM,IS as _M,IT as hM,IU as Lc,IV as SM,IW as gM,fU as fM,fV as vM,IX as IM,fF as bM,IY as EM,IZ as PM,I_ as vn,I$ as TM,fZ as Ev,J0 as AM,J1 as Pv,J2 as NM,J3 as Tv,gw as Av,J4 as Nv,J5 as OM,J6 as CM,J7 as xM,J8 as UM,J9 as kM,Ja as Fc,Jb as BM,Jc as Ov,Jd as Wt,Je as DM,Jf as Cv,Jg as JM,Jh as qc,Ji as st,Jj as jc,Jk as In,Jl as wM,Jm as $M,Jn as Gc,g1 as Zt,Jo as qr,Jp as RM,Jq as MM,Jr as xv,Js as VM,Jt as LM,Ju as FM,Jv as Uv,Jw as qM,Jx as zc,Jy as jM,Jz as GM,JA as zM,JB as Kc,JC as KM,JD as YM,JE as Yc,JF as kv,JG as HM,JH as Hc,JI as QM,JJ as Qc,JK as WM,JL as Wc,JM as ZM,JN as Zc,JO as XM,JP as Xc,JQ as eV,JR as ed,JS as tV,JT as td,JU as aV,JV as ad,JW as qa,JX as jr,JY as rV,JZ as Bv,J_ as Dv,g0 as sV,J$ as rd,K0 as bn,K1 as Jv,K2 as nV,K3 as wv,K4 as oV,K5 as $v,K6 as iV,K7 as Rv,K8 as cV,K9 as sd,Ka as dV,Kb as lV,Kc as Mv,Kd as uV,Ke as pV,Kf as Vv,Kg as mV,Kh as nd,Ki as yV,Kj as od,Kk as _V,Kl as id,Km as cd,Kn as hV,Ko as SV,Kp as Lv,Kq as gV,Kr as Fv,Ks as fV,Kt as vV,Ku as IV,Kv as bV,Kw as En,Kx as EV,Ky as PV,Kz as TV,KA as Gr,KB as AV,KC as NV,KD as OV,KE as qv,KF as CV,KG as xV,KH as jv,KI as UV,KJ as kV,KK as Gv,KL as zv,KM as Kv,KN as BV,KO as DV,KP as Yv,KQ as JV,KR as Hv,KS as wV,fK as $V,KT as Qv,KU as Wv,KV as RV,KW as Pn,KX as MV,KY as VV,KZ as Zv,g2 as LV,K_ as FV,K$ as dd,L0 as qV,L1 as jV,L2 as GV,L3 as Xv,b_ as zV,L4 as KV,L5 as YV,L6 as HV,L7 as QV,L8 as WV,L9 as ZV,La as XV,Lb as eL,Lc as tL,Ld as ld,Le as aL,Lf as ud,Lg as eI,Lh as rL,Li as tI,Lj as sL,Lk as nL,Ll as aI,Lm as oL,Ln as iL,Lo as rI,Lp as cL,Lq as dL,Lr as sI,Ls as lL,Lt as uL,Lu as nI,Lv as pL,Lw as mL,Lx as oI,Ly as yL,Lz as _L,LA as hL,LB as SL,LC as gL,LD as fL,LE as iI,LF as vL,LG as pd,LH as cI,LI as IL,LJ as md,LK as bL,LL as ja,LM as yd,LN as _d,LO as EL,LP as hd,LQ as Tn,LR as Sd,LS as gd,LT as fd,LU as dI,LV as PL,LW as TL,LX as vd,LY as AL,LZ as lI,L_ as NL,L$ as OL,M0 as CL,M1 as xL,M2 as Id,M3 as UL,M4 as bd,M5 as uI,M6 as kL,M7 as Ed,M8 as pI,M9 as BL,Ma as DL,Mb as mI,Mc as JL,Md as wL,Me as yI,Mf as $L,Mg as An,Mh as _I,Mi as Pd,Mj as RL,Mk as Td,Ml as ML,Mm as hI,Mn as Nn,Mo as VL,Mp as LL,Mq as FL,Mr as qL,Ms as Ad,Mt as jL,Mu as GL,Mv as zL,Mw as SI,Mx as KL,My as YL,Mz as gI,MA as HL,MB as Nd,MC as fI,MD as vI,ME as Od,MF as II,MG as bI,MH as QL,MI as EI,MJ as PI,MK as WL,ML as ZL,MM as TI,MN as XL,MO as eF,MP as AI,MQ as tF,MR as NI,MS as Cd,MT as OI,MU as aF,MV as CI,MW as xI,MX as rF,MY as sF,MZ as nF,M_ as oF,M$ as UI,N0 as On,N1 as iF,N2 as cF,N3 as xd,N4 as Ud,N5 as Ga,N6 as dF,N7 as lF,N8 as uF,N9 as kI,Na as pF,Nb as kd,Nc as Bd,Nd as Dd,Ne as Jd,Nf as wd,Ng as $d,Nh as mF,Ni as BI,Nj as yF,Nk as DI,Nl as _F,Nm as JI,Nn as hF,No as SF,Np as wI,Nq as gF,Nr as $I,Ns as fF,Nt as RI,Nu as vF,Nv as MI,Nw as VI,Nx as IF,Ny as bF,Nz as LI,NA as EF,NB as Rd,NC as PF,ND as Md,NE as TF,NF as AF,NG as Vd,NH as NF,NI as Ld,NJ as OF,NK as Cn,NL as Xt,NM as zr,NN as xn,NO as Fd,NP as CF,NQ as FI,NR as xF,NS as qI,NT as UF,NU as qd,NV as kF,NW as jI,NX as BF,NY as DF,NZ as GI,N_ as JF,N$ as zI,O0 as wF,O1 as jd,O2 as KI,O3 as Un,O4 as YI,O5 as $F,O6 as HI,O7 as RF,O8 as MF,O9 as VF,Oa as QI,Ob as LF,Oc as Gd,Od as FF,Oe as zd,Of as qF,Og as jF,Oh as GF,Oi as WI,Oj as zF,Ok as ZI,Ol as XI,Om as KF,On as eb,Oo as YF,Op as tb,Oq as ab,Or as HF,Os as rb,Ot as sb,Ou as QF,Ov as WF,Ow as nb,Ox as ZF,Oy as ob,Oz as ib,OA as XF,OB as cb,OC as eq,OD as db,OE as lb,OF as tq,OG as aq,OH as ub,OI as rq,OJ as sq,OK as pb,OL as mb,OM as nq,ON as Kd,OO as kn,OP as oq,OQ as iq,OR as Ml,OS as cq,OT as dq,OU as Yd,OV as lq,OW as uq,OX as Hd,OY as pq,OZ as yb,O_ as mq,O$ as yq,P0 as _b,P1 as hb,P2 as _q,P3 as Sb,P4 as hq,P5 as Sq,P6 as gb,P7 as gq,P8 as Vl,P9 as ro,Pa as Nt,Pb as Za,Pc as fq,Pd as vq,Pe as Qd,Pf as fb,bD as so,Pg as Iq,Ph as Wd,Pi as bq,Pj as Eq,Pk as Pq,Pl as vb,Pm as Zd,Pn as Tq,Po as za,Pp as Ib,Pq as Aq,Pr as Xd,Ps as el,Pt as Nq,Pu as Oq,Pv as Cq,Pw as tl,Px as xq,Py as Uq,Pz as er,PA as kq,PB as Bq,PC as Dq,PD as bb,PE as Jq,PF as wq,PG as Eb,PH as Pb,PI as al,PJ as $q,PK as Rq,PL as Tb,PM as Mq,PN as Ab,PO as Vq,PP as rl,PQ as Nb,PR as Lq,PS as Fq,PT as qq,PU as jq,PV as Ob,PW as sl,PX as Gq,PY as Cb,PZ as zq,P_ as nl,P$ as Kq,Q0 as xb,Q1 as Ub,Q2 as Yq,Q3 as Hq,Q4 as Qq,Q5 as kb,Q6 as Wq,Q7 as Zq,Q8 as Xq,Q9 as Bb,Qa as ej,Qb as Db,Qc as tj,Qd as Jb,Qe as aj,Qf as rj,Qg as sj,Qh as wb,Qi as nj,Qj as oj,Qk as ij,Ql as cj,Qm as $b,Qn as dj,Qo as lj,Qp as Rb,Qq as uj,Qr as pj,Qs as mj,Qt as Mb,Qu as Ka,Qv as Vb,Qw as ol,Qx as Lb,Qy as Fb,Qz as Bn,QA as qb,QB as yj,QC as Dn,QD as _j,QE as hj,QF as Sj,QG as gj,QH as fj,QI as vj,QJ as Ij,QK as bj,QL as jb,QM as Gb,QN as zb,QO as Ej,QP as Kb,QQ as Yb,QR as Hb,QS as Pj,QT as Qb,QU as Wb,QV as Zb,QW as Tj,QX as Xb,QY as eE,QZ as tE,Q_ as Aj,Q$ as aE,R0 as Nj,R1 as rE,R2 as Oj,R3 as Cj,R4 as xj,R5 as Uj,R6 as sE,R7 as Jn,R8 as kj,R9 as Bj,Ra as j0,Rb as nE,Rc as Dj,Rd as Jj,Re as wj,Rf as $j,Rg as oE,Rh as Rj,Ri as Mj,Rj as iE,Rk as Vj,Rl as Lj,Rm as Fj,Rn as cE,Ro as qj,Rp as dE,Rq as jj,Rr as il,Rs as Gj,Rt as cl,Ru as lE,Rv as zj,Rw as uE,Rx as Kj,Ry as Yj,Rz as Hj,RA as dl,RB as Qj,RC as Wj,RD as Zj,RE as Xj,RF as eG,RG as tG,RH as pE,RI as aG,RJ as rG,RK as mE,RL as sG,RM as ll,RN as nG,RO as ul,RP as Kr,RQ as pl,RR as oG,RS as Ll,RT as iG,RU as cG,RV as yE,RW as _E,RX as dG,RY as ml,RZ as lG,R_ as uG,R$ as pG,S0 as mG,S1 as yG,S2 as hE,S3 as _G,S4 as hG,S5 as yl,S6 as SG,S7 as gG,S8 as _l,S9 as fG,Sa as vG,Sb as IG,Sc as SE,Sd as bG,Se as gE,Sf as EG,Sg as fE,Sh as PG,Si as hl,Sj as TG,Sk as AG,Sl as NG,Sm as OG,Sn as CG,So as xG,Sp as UG,Sq as kG,Sr as BG,Ss as DG,St as JG,Su as wG,Sv as $G,Sw as RG,Sx as MG,Sy as VG,Sz as LG,SA as FG,SB as qG,SC as jG,SD as GG,SE as zG,SF as KG,SG as YG,SH as HG,SI as QG,SJ as WG,SK as ZG,SL as XG,SM as ez,SN as tz,SO as az,SP as rz,SQ as sz,SR as nz,SS as oz,ST as iz,SU as cz}from"./zeni-epic-state-2zvjmkUL.js";import"./sentry-C6D8WJ15.js";import"./core-Dlma5MIa.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new s.Error().stack;i&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[i]="a721ee0c-3376-4414-93d0-62327eebee24",s._sentryDebugIdIdentifier="sentry-dbid-a721ee0c-3376-4414-93d0-62327eebee24")}catch{}})();const Sl=(s,i,r,t)=>{const e=[];return s!=null&&Object.keys(s).forEach((a=>{const n=i[a]?.nestedAccountId;n!=null?e.push({accountsViewParentID:{parentAccountId:_0(n),sectionId:r},accountMetadataPayload:i[a].accountMetadataPayload,accountBalancesPayload:s[a],classesViewParentID:t}):console.warn(`Account ${a} in Section ${r} is missing metadata.`)})),e},dz=(s,i,r,t,e)=>{s!=null&&Object.keys(s).forEach((a=>{const n=i[a];if(n!=null){const o=n.nestedAccountId;e.push({accountsViewParentID:{parentAccountId:_0(o),sectionId:r},accountMetadataPayload:n.accountMetadataPayload,accountBalancesPayload:s[a],projectsViewParentID:t})}else console.warn(`Account ${a} in Section ${r} Project ${t.projectId} is missing metadata.`)}))},lz=s=>{typeof window<"u"&&(window.location.href=s)},uz=s=>s.data?.skipped!=null&&s.data.skipped.length>0?s.data.skipped[0].reason:s.data?.error!=null&&s.data.error.length>0?s.data.error:s.status.message.length>0?s.status.message:"",pz=["private","tenant"],G0=s=>{return{macroId:s.macro_id,name:s.name,displayName:s.display_name,description:s.description,semver:s.semver,hasScripts:s.has_scripts===!0,isMine:s.is_mine===!0,isOwnedByTenant:s.is_owned_by_tenant===!0,updatedAt:s.updated_at??null,visibility:(i=s.visibility,pz.find((r=>r===i))??null)};var i},z0=s=>typeof s?.instructions=="string",gl=s=>z0(s)&&s.skill!=null,fl=s=>({skill:{...G0(s.skill),exampleHints:[]},instructions:s.instructions,instructionsCharCount:s.instructions_char_count??s.instructions.length,artifact:s.artifact??"",artifactTitle:s.artifact_title??""}),mz=s=>({version:s.version,semver:s.semver??null,displayName:s.display_name??null,updatedAt:s.updated_at??null,isActive:s.is_active===!0,isLatest:s.is_latest===!0,instructionsCharCount:s.instructions_char_count??0}),vE=s=>typeof s=="string"&&s.trim()!=="",yz=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return[];const i=Object.values(s).flatMap((r=>vE(r)?[r.trim()]:Array.isArray(r)?r.filter(vE).map((t=>t.trim())):[]));return Array.from(new Set(i))},_z=s=>({...G0(s),exampleHints:yz(s.parameter_hints)}),hz=(s,i)=>({action:s,audit_rule_group_ids:[i]}),Sz=s=>{switch(s){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}},gz=s=>{switch(s){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}},vl=(s,i)=>({bank_account_name:s.bankAccountName,bank_account_number:s.bankAccountNumber,bank_name:s.bankName,bank_routing_number_ach:i==="ach"?s.bankRoutingNumber:"",bank_routing_number_wire_transfer:i==="wire"?s.bankRoutingNumber:"",bank_account_type:s.bankAccountType}),IE=s=>({account_holder_name:s.bankAccountName,bank_swift_code:s.bankSwiftCode,bank_account_iban:s.bankAccountIban,bank_name:s.bankName,pi_type:"swift_code",account_source:""}),fz=s=>({type:s.type,processor_token:s.processor_token,payment_source_type:s.payment_source_type}),vz=s=>({payment_method_types:s}),Iz=s=>{switch(s){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}},bz=s=>{switch(s){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}},bE=s=>({vendorName:s.name,vendorCategory:s.accountId,vendorClass:s.classId,vendorOwner:s.ownerId,vendorId:s.id}),wn=(s,i,r)=>{const{contactState:t}=i,e={},a={},{documentIds:n}=s;n.forEach((d=>{e[d]=KA(i,d)})),n.forEach((d=>{a[d]=YA(i,d)}));const{recommendedAccount:o,recommendedClass:c}=HA(s.recommendations,s.accountId,s.classId);return{vendorName:s.name,bankAccountIds:s.bankAccountIds??[],paymentInstrumentIds:s.paymentInstrumentIds,vendorCategory:s.accountId,vendorClass:s.classId,vendorType:s.vendorType,vendorOwner:s.ownerId,vendorId:s.id,isVendor1099:s.isVendor1099,documentIds:s.documentIds,deleteFileStatusById:e,updateFileStatusById:a,countryCode:s.countryCode,currencyCode:s.vendorCurrencyCode,currencySymbol:s.vendorCurrencySymbol,contacts:r?.contacts!=null?r.contacts.map((d=>QA(d))):h0(t,s.contactIds??[]),recommendations:s.recommendations,fileIdsToBeDeleted:[],recommendedCategory:o,recommendedClass:c,isCategoryUpdateSelected:!1,isClassUpdateSelected:!1,isCategoryRecommendationPrefilled:o?.accountId===s.accountId,isClassRecommendationPrefilled:c?.classId===s.classId}},Il="agent_insights_subject",EE=(s,i,r)=>{const t={...s,...r,subject:i};return Il in t&&r?.[Il]==null&&i!=null&&i!==""&&(t[Il]=i),t},Ez=s=>{switch(s){case"taskName":return"name";case"dueDate":return"due_date";case"createdBy":return"created_by";case"name":return"company_name";default:return s}},Pz=s=>s.categories==null?[]:s.categories.map((i=>({field:i.field??"",operator:i.matchingOperator==="equal"?"is":"is_not",values:i.values.map((r=>String(r))),join:i.valuesCombinationOperator==="ALL"?"and":"or"}))),Tz=s=>{const i={};if(s.statusCode!=null&&(i.status_code=s.statusCode),s.companyGroupId!=null&&(i.company_group_id=s.companyGroupId),s.taxStatusCode!=null&&(i.tax_status_code=s.taxStatusCode),s.lastReportSentDate!=null&&(i.last_report_sent_date=s.lastReportSentDate.format("YYYY-MM-DD")),s.lastReportSentBusinessDay!=null&&(i.last_report_sent_business_day=s.lastReportSentBusinessDay),s.note!=null&&(i.note=s.note),s.users!=null&&(i.users=s.users.map((r=>({is_zeni:r.isZeni,user_id:r.userId,user_email:null,[`is_${r.role}`]:r.isSelected})))),s.customerSatisfaction!=null&&(s.customerSatisfaction.teamRating!=null||s.customerSatisfaction.customerRating!=null)){const r=s.customerSatisfaction;i.customer_satisfaction={},r.customerSatisfactionId!=null&&(i.customer_satisfaction.customer_satisfaction_id=r.customerSatisfactionId),r.customerRating!=null&&(i.customer_satisfaction.customer_rating_code=r.customerRating,i.customer_satisfaction.customer_note=r.customerNote),r.teamRating!=null&&(i.customer_satisfaction.team_rating_code=r.teamRating,i.customer_satisfaction.team_note=r.teamNote)}return i},Az={Employees:"employees",Customers:"customers","Physical office or facility":"physical_office","Banking relationships":"banking_relationships"};function Nz(s){return Az[s]??s}const Oz=s=>{const i={company_inc_type:s.typeOfInc,company_inc_state:s.stateOfInc};return s.incDate!=null&&(i.company_inc_date=s.incDate.format("YYYY-MM-DD")),i},Cz=s=>({tax_id:s.taxIdOrEIN,duns_id:s.dunsNumber,sic_code:s.sicCode,naics_code:s.naicsCode,taxes_filed_years:s.taxesFiledYears}),xz=(s,i)=>{const r=[];return s.fileId!=null&&r.push(s.fileId),i.fileId!=null&&r.push(i.fileId),{file_ids:r}},$n=s=>{const i={};return s.email!=null&&(i.email=s.email),s.firstName!=null&&(i.first_name=s.firstName),s.lastName!=null&&(i.last_name=s.lastName),s.phone!=null&&(i.phone=s.phone),s.isCompanyOfficer!=null&&(i.is_company_officer=s.isCompanyOfficer),s.isPrimaryContact!=null&&(i.is_primary_contact=s.isPrimaryContact),i};function bl(s){const i={};return s.forEach((r=>{const t=r.company_id,e=X(i,t,void 0);i[t]=[...e??[],r.subscription_id]})),i}function El(s){let i;return s.companyAddress!=null&&(i=Object.assign({},i,{company_address:Wn(s.companyAddress)})),s.registeredAddress!=null&&(i=Object.assign({},i,{company_registered_address:Wn(s.registeredAddress)})),s.companyOfficers.slice(0,Fl.length).sort(((r,t)=>r.user.createTime?.isAfter(t.user.createTime)===!0?1:-1)).forEach(((r,t)=>{const e=r.address,a=`officer_${t+1}_address`;e!=null&&(i=Object.assign({},i,{[a]:Wn(e)}))})),i}const Wn=s=>{const{updateTime:i,createTime:r,addressId:t,...e}=s;return e},PE=["company_address","company_registered_address",...Fl.map((s=>`officer_${s}_address`))];function Pl(){return[pO(),N({messageSection:"create_transfer_entry",messageText:"failed",type:"error"})]}function TE(s){return[yO(),_O(s),N({messageSection:"create_transfer_entry",messageText:"success",type:"success"})]}function AE(s){return Ha(0).pipe(y((()=>{const i=[hO()];return s!=null&&i.push(...(function(r){return[wl(Be(r)),$l(r),SO()]})(s)),_(i)})))}const Uz={transferEntryEligible:"transfer_accounts",creditCardOnlyEligible:"credit_card_transfer_accounts"},kz={transferEntryEligible:{is_only_include_transfer_accounts:!0},creditCardOnlyEligible:{is_include_only_credit_card_accounts:!0}};function NE(s){const i=s?.trim();return N(i!=null&&i!==""?{messageSection:"confirm_statement_mapping",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:i}]}:{messageSection:"confirm_statement_mapping",messageText:"failed",type:"error"})}function OE(s){switch(s){case"exclude":return"Excluding Transaction";case"reconcile":return"Reconciling";case"save_reconcile_for_later":return"Saving for Later"}}function CE(s){return s.filter((i=>i.is_checked_transaction===!0)).map((i=>i.transaction_id))}const Bz=s=>s.reduce(((i,r)=>{const t={memo:(e=r,e.recommended_action.recommended_transactions[0]?.transaction_memo??e.transaction_memo??""),categoryId:r.recommended_action.recommended_transactions[0]?.account_id??void 0,classId:r.recommended_action.recommended_transactions[0]?.class_id??void 0,vendor:r.recommended_action.recommended_transactions[0]?.merchant_id!=null&&r.recommended_action.recommended_transactions[0]?.merchant_name!=null?{id:r.recommended_action.recommended_transactions[0].merchant_id,name:r.recommended_action.recommended_transactions[0].merchant_name}:void 0};var e;return{...i,[r.transaction_id]:t}}),{}),Dz=s=>s.reduce(((i,r)=>{const t={memo:(e=r,e.recommendedAction.recommendedTransactions[0]?.memo??e.memo??""),categoryId:r.recommendedAction.recommendedTransactions[0]?.accountId??void 0,classId:r.recommendedAction.recommendedTransactions[0]?.classId??void 0,vendor:r.recommendedAction.recommendedTransactions[0]?.merchantId!=null&&r.recommendedAction.recommendedTransactions[0]?.merchantName!=null?{id:r.recommendedAction.recommendedTransactions[0].merchantId,name:r.recommendedAction.recommendedTransactions[0].merchantName}:void 0};var e;return{...i,[r.transactionId]:t}}),{});function Jz(s,i){return{amount:s.amount.amount,transaction_memo:s.memo,line_description:i.memo,transaction_date:s.transactionDate.format(re),transaction_direction:s.transactionDirection,transaction_id:s.transactionId,vendor_id:i.vendor?.id,vendor_name:i.vendor?.name,account_id:i.categoryId,accounting_class_id:i.classId,currency_code:s.amount.currencyCode}}const wz=(s,i,r,t)=>({account_type:t,amount:s.amount.amount,transaction_memo:r.memo,transaction_date:s.transactionDate.format(re),transaction_direction:s.transactionDirection,transaction_id:s.transactionId,linked_transaction_id:i?.bookTransactionId,linked_transaction_type:"bill",currency_code:s.amount.currencyCode,vendor_id:i?.merchantId,vendor_name:i?.merchantName}),$z=s=>s?.recommendedAction.action==="record_bill_payment"?"recon_transaction_match":"recon_transaction_categorize",xE=(s,i)=>{const{statementMeta:r,statementTransactions:t}=i,e=mC(r,s.statementMeta),a=s.statementTransactions?.deletedIds??[],n=new Set(t.filter((u=>u.statementTransactionId!==""&&!a.includes(u.statementTransactionId))).map((u=>u.statementTransactionId))),o=yC(t,e,n),c=[...new Set([...a,...o])],d=s.statementTransactions?.updated??[];if(c.length===a.length&&c.every((u=>a.includes(u))))return s;const l=new Set(c);return{...s,statementTransactions:{...s.statementTransactions,deletedIds:c,added:s.statementTransactions?.added??[],updated:d.filter((u=>u.statementTransactionId!=null&&!l.has(u.statementTransactionId)))}}};function UE(s,i,r){if(s.length===0)return{count:0,totalAmount:{amount:0,...r}};let t=0,e=ra(0);return s.forEach((a=>{a.transactionDirection===i&&(t+=1,e=e.plus(a.amount.amount))})),{count:t,totalAmount:{amount:parseFloat(e.toFixed(2)),...r}}}const Rz=(s,i)=>({action:CC(s),flux_analysis_entity_ids:i}),Mz="prepaid_expenses",Vz="fixed_assets",Lz="accrued_expenses",Zn="YYYY-MM",Fz=(s,i)=>{const{classListState:r,classState:t}=s,e=tr(t,r).classes.find((n=>n.labels?.includes("balance_sheet")===!0)),a=i.reverseNextMonth?{reverse_next_month:!0,expected_reversal_date:qz(i.serviceMonth).format(re)}:{reverse_next_month:!1};return{vendor_id:i.vendorId,vendor_name:i.vendorName,service_month:i.serviceMonth.format(Zn),amount:i.amount,memo:i.memo,je_debit_account_id:i.debitAccountId,je_credit_account_id:i.creditAccountId,...i.debitAccountName!=null?{je_debit_account_name:i.debitAccountName}:{},...i.creditAccountName!=null?{je_credit_account_name:i.creditAccountName}:{},...i.debitClassId!=null?{je_debit_accounting_class_id:i.debitClassId}:{},...i.debitClassName!=null?{je_debit_accounting_class_name:i.debitClassName}:{},...e!=null?{je_credit_accounting_class_id:e.classId,je_credit_accounting_class_name:e.className}:{},...a}},qz=s=>s.add(1,"month").startOf("month"),jz=(s,i)=>i!=null?i.amount:s.amount.amount,Gz=s=>({scheduled_journal_entry_id:s.scheduledJournalEntryID,je_schedule_id:s.jeScheduleID,...s.updatedVendor?.id!=null&&s.updatedVendor.id!==""?{updated_vendor_id:s.updatedVendor.id}:{},...s.updatedCategoryId!=null?{updated_debit_category_id:s.updatedCategoryId}:{},...s.updatedAccumulatedDepreciationCategoryID!=null?{updated_credit_category_id:s.updatedAccumulatedDepreciationCategoryID}:{},...s.updatedClassId!=null?{updated_debit_class_id:s.updatedClassId}:{}}),zz={missing_third_party_id:"This transaction is missing a QuickBooks reference and cannot be scheduled.",missing_vendor:"This transaction has no vendor and cannot be scheduled. Add a vendor to the transaction first."};function Tl(s){const i=s.expenseAutomationViewState.selectedPeriodByTenantId[H(s).tenantId];if(i==null)return[];const r=Re(i),t=ge(r.start),e=ge(r.end);return t==null||e==null?[]:[Qa({start:t,end:e},!0)]}function ea(s,i,r,t){return[sx({accrualId:i,status:t??f("Unexpected Error",r)}),N({messageSection:s,messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:r}]})]}function Al(s){const i=me().startOf("day"),r=i.subtract(s-1,"day");return{end:i.format(re),start:r.format(re)}}function kE(s,i){return s.length===0?F:_(s).pipe(y((r=>i.getJSON(`${i.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${r}`).pipe(y((t=>{if(!T(t)||t.data==null||!zn(t.data.status))return F;const e=[],a=Kn(t.data.files);return a.length>0&&e.push(Ce(a,(n=>n.transaction_id))),e.push(Gn(Yn(t.data,i.apiEndPoints.fileMicroServiceBaseUrl))),_(e)})),v((t=>(console.error(`Failed to fetch batch details for ${r}:`,f("Unexpected Error","Fetch batch details errored out: "+JSON.stringify(t))),p(S0({batchId:r}))))))),5))}const Ya="review";function Kz(s,i){const r={...s};for(const t of Object.keys(i))r[t]={...s[t],...i[t]};return r}const Yz=(s,i,r,t,e=!1,a,n)=>{const o=b0(r,i??n),c=s[o],d={recommendations:t,entityId:i===n?null:i,...r==="vendor"&&n!=null?{vendorName:n}:{}};s[o]=c==null?{entityType:r,isBulkUpdate:e,updatedEntityId:a,...d}:{...c,...d}},K0=(s,i,r)=>{if(i!=null&&r!=null)return{...i,min:r.min,max:r.max,reason:r.reason,type:r.type};if(i!=null){const{min:t,max:e}=v0(s);return{...i,min:t,max:e,reason:"",type:""}}},Y0=(s,i,r)=>{if(i!=null&&r!=null)return{...i,min:r.min,max:r.max,reason:r.reason,type:r.type};if(i!=null){const{min:t,max:e}=v0(s);return{...i,min:t,max:e,reason:"",type:""}}},Hz=(s,i,r,t)=>s!=null?{entityId:s.qboId??s.id,entityType:s.type,entityName:s.name}:i?.lineEntity!=null?{entityId:i.lineEntity.qboId??i.lineEntity.id,entityType:i.lineEntity.type,entityName:i.lineEntity.name}:t!=null&&t.id&&t.id!=null?{entityId:t.id,entityType:"customer"}:r!=null?{entityId:r.qboId??r.id??r.name,entityType:"vendor",entityName:r.name}:void 0,H0=(s,i)=>{const r=s.lines;if(i===!0&&(as(s)||s.type==="journal_entry"))return!0;let t=!1;return r?.forEach((e=>{if(e.type==="transaction_with_account_and_class_line"||e.type==="transaction_with_product_or_service_line"||e.type==="journal_entry_transaction_line"){const a=e;(a.isCategoryMiscategorized||a.isClassMiscategorized||g0(s.type)&&s.vendor==null||Hn(s.type)&&a.vendor==null&&a.customer==null)&&(t=!0)}})),t},Qz=(s,i,r)=>{const t={updatesByLineId:{}},e={},a={},n=H0(i,!0),o=((u,m)=>{const h=u.lines;let g=!1;return h?.forEach((I=>{I.type!=="transaction_with_account_and_class_line"&&I.type!=="transaction_with_product_or_service_line"&&I.type!=="journal_entry_transaction_line"||f0(m,I.account.qboId)&&(g=!0)})),g})(i,r);t.memo=s.memo;const c=s.selectedEntity;let d,l;return as(i)===!0&&c!=null&&c.type==="vendor"&&(t.vendorId=c.qboId),qx(i)===!0&&c!=null&&c.type==="customer"&&(t.customerId=c.qboId),i.lines?.forEach((u=>{if(u.type!=="transaction_with_account_and_class_line"&&u.type!=="transaction_with_product_or_service_line"&&u.type!=="journal_entry_transaction_line"||!(u.id in s.lineItemById))e[u.id]=u;else{const m=s.lineItemById[u.id].selectedEntityLine,h=Zz(c,s.lineItemById[u.id],s.vendorUpdates,s.customerUpdates,m),g=s.lineItemById[u.id];e[u.id]={lineDescription:g.lineDescription,class:g.class,account:g.account,project:g.project,recommendation:I0(g.recommendationsWithCOT)},u.type!=="journal_entry_transaction_line"&&u.platformLineDetailType!=="deposit_line_detail"||(e[u.id]={...e[u.id],vendor:m!=null&&m.type==="vendor"?g.vendor:void 0,customer:m!=null&&m.type==="customer"?g.customer:void 0});let I=!1,b=!1;const E=u;I=g.account?.qboId!==E.account.qboId&&!!g.account?.qboId,b=(g.class?.qboId!=null||E.class?.qboId!=null)&&g.class?.qboId!==E.class?.qboId;const P=K0(g.amount.amount,g.account),O=Y0(g.amount.amount,g.class);if(h!=null&&(I===!0||b===!0)){d=I===!0?P:void 0,l=b===!0?O:void 0;const C={account:d,class:l};if(C.class!=null||C.account!=null){const U=h.entityId;Wz(a,U,h.entityType,C,!1,void 0,h.entityName)}}}})),t.updatesByLineId=e,{transactionId:i.id,updates:t,entityRelatedUpdates:a,markAsMiscatUpdates:n===!0&&o===!1,anyBulkUpdates:!1}},Wz=(s,i,r,t,e=!1,a,n)=>{const o=b0(r,i),c=s[o],d={recommendations:t,entityId:i===n?null:i,...r==="vendor"&&n!=null?{vendorName:n}:{}};s[o]=c==null?{entityType:r,isBulkUpdate:e,updatedEntityId:a,...d}:{...c,...d}},Zz=(s,i,r,t,e)=>s!=null?{entityId:s.qboId??s.id,entityType:s.type,entityName:s.name}:r!=null?{entityId:r.qboId??r.id??r.name,entityType:"vendor",entityName:r.name}:t!=null&&t.id!=null?{entityId:t.id,entityType:"customer"}:i.lineEntity!=null?{entityId:i.lineEntity.qboId??i.lineEntity.id,entityType:i.vendor!=null?"vendor":"customer",entityName:i.lineEntity.name}:i.customer?.id!=null&&e!=null&&e.type==="customer"?{entityId:e.qboId??i.customer.id,entityType:"customer"}:i.vendor?.id!=null&&e!=null&&e.type==="vendor"?{entityId:e.qboId??i.vendor.id,entityType:"vendor",entityName:e.name??i.vendor.name}:void 0,Xz=(s,i,r,t,e,a,n)=>{const o=Object.assign({},i);o.memo=s.memo??"";const c={};for(const l in s.updatesByLineId){const u=s.updatesByLineId[l],m=o.lines?.map((h=>{if(h.id===l){const g=Object.assign({},h);g.lineDescription=u.lineDescription??"",u.class!=null&&(g.class=u.class),u.project!=null&&(g.project=u.project),u.account!=null&&(g.account=u.account),u.customer!=null?g.customer=u.customer:g.customer=void 0,u.vendor!=null?u.vendor?.id===u.vendor?.name?g.vendor={id:"",name:u.vendor.name}:g.vendor=u.vendor:g.vendor=void 0,u.recommendation!=null&&(c[h.id]=u.recommendation);const I=t[r],b=I?.find((E=>E.lineId===h.id));return b!=null&&(g.cotViewingFlags={vendor:b.vendor,category:b.category,class:b.class,lineId:b.lineId}),g}return h}));o.lines=m}let d;return o.recommendations=c,d=E0(o)?P0(o):as(o)?n!=null&&n.type==="customer"?T0(o,a):A0(o,e):N0(o)?O0(o):C0(o),x0(d,o)},eK=s=>{const i=[];let r;for(r in s){const t=s[r],e={recommendations:U0(t.recommendations),entity_id:t.entityId,entity_type:t.entityType,is_bulk_update:t.isBulkUpdate,updated_entity_id:t.updatedEntityId};t.entityType==="vendor"&&t.vendorName!=null&&(e.vendor_name=t.vendorName),i.push(e)}return i},Q0=s=>({user_id:s.user_id,first_name:s.first_name?.trim(),last_name:s.last_name?.trim(),email:""}),W0=s=>{const i={global_merchant_name:s.globalMerchantName,global_merchant_type:s.globalMerchantType??"vendor",logo:{url:s.logo?.toString(),base64:null},reason:s.reason??null,website_url:s.websiteUrl?.toString()??null,third_party_merchant_id:s.thirdPartyMerchantId??null,update_time:s.updateTime!=null?s.updateTime.format("YYYY-MM-DD"):null,create_time:s.createTime!=null?s.createTime.format("YYYY-MM-DD"):null};return s.isActive!=null&&(i.is_active=s.isActive),i},Xn=(s,i)=>{const r=[];s.map(((e,a)=>{const n=[];e.globalMerchants.forEach(((o,c)=>{const d=ql(o);n[c]={...ts(d,["create_time","update_time"])}})),n.length>0&&(r[a]={global_merchants:n})}));const t=[];return i.map(((e,a)=>{const n=[];e.globalMerchants.forEach(((o,c)=>{const d=W0(o);n[c]={...ts(d,["create_time","update_time"])}})),t[a]={global_merchants:n}})),[{global_merchants:[...r[0]?.global_merchants??[],...t[0]?.global_merchants??[]]}]},Z0=s=>{const i=[];return s[0]?.global_merchants.forEach((r=>{r.global_merchant_id!=null&&i.push(r)})),i},tK=(s,i)=>{const r={global_merchant_name:s.globalMerchantName,global_merchant_type:s.globalMerchantType,is_active:!0,recommendations:i,website_url:s.globalMerchantWebsiteUrl?.toString()};if(i.length>0&&i[0].global_merchants.length>0&&i[0].global_merchants[0].global_merchant_name===s.globalMerchantName){const t=i[0].global_merchants[0];r.logo=t.logo?.url??null,r.third_party_merchant_id=t.third_party_merchant_id??null}return r},aK=new Set(["time","action"]),BE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Ie=s=>{const i=s?.message?.trim()??"";if(i!=="")return[{variableName:"_api-error_",variableValue:i}]},Rn=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Yr=(s,i)=>i.pipe(y((r=>T(r)&&r.data!=null?((t,e)=>[B0(e),WU(e.id),ZU(t),D0(),k0()])(s,r.data):p(b_({kind:s,error:r.status})))),v((r=>p(b_({kind:s,error:f("Unexpected Error",`Data import ${s} REST API call errored out `+JSON.stringify(r))}))))),Nl=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Pt=s=>s.trim()!==""?s.trim():void 0,DE=s=>s.trim()!==""?s.trim():null,Ol=s=>s.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""),JE=(s,i)=>{const r={};s.sku.trim()!==""&&(r.sku=s.sku.trim());const t=i.accountByQboId(s.accountingCode.trim());t!=null&&(r.account=Qr(t));const e=i.classByQboId(s.accountingCategory.trim());return e!=null&&(r.accounting_class=Wr(e)),Object.keys(r).length>0?r:void 0},rK=(s,i,r)=>{const t=Pt(s.description),e=Pt(s.productCode)??Ol(s.name),a={enabled_for_checkout:!0,enabled_in_portal:!0,is_giftable:!1,is_shippable:!1,item_applicability:s.itemApplicability,metered:!1,name:s.name.trim(),product_code:e,type:s.catalogType};t!=null&&(a.description=t),a.unit=Pt(s.unit)??"USD",s.itemApplicability==="restricted"&&s.applicableItems.length>0&&(a.applicable_items=s.applicableItems);const n=s.subFamilies.length>0?s.subFamilies:[sk()];return a.sub_family_details=i?n.map((o=>((c,d,l,u)=>{const m=c.catalogType==="addon",h=nk(d.pricingModel),g=d.name.trim(),I=Pt(d.priceCode)??Ol(g),b={currency_code:"USD",free_quantity:Number(d.freeQuantity)||0,is_taxable:d.isTaxable,name:g,price:h?0:d.priceDollars?.amount??0,price_code:I,pricing_model:d.pricingModel,show_description_in_invoices:d.showDescriptionInInvoices,show_description_in_quotes:d.showDescriptionInQuotes},E=Pt(d.description);E!=null&&(b.description=E);const P=Pt(d.invoiceNotes);P!=null&&(b.invoice_notes=P),d.period.trim()!==""&&(b.period=Number(d.period),b.period_unit=d.periodUnit||"month"),d.trialPeriod.trim()!==""&&(b.trial_period=Number(d.trialPeriod),b.trial_period_unit=d.trialPeriodUnit,b.trial_end_action=d.trialEndAction),d.billingCycles.trim()!==""&&(b.billing_cycles=Number(d.billingCycles)),m&&d.prorationType&&(b.proration_type=d.prorationType),h&&(b.tiers=d.tiers.map((C=>({ending_unit:C.endingUnit.trim()!==""?Number(C.endingUnit):void 0,package_size:C.packageSize.trim()!==""?Number(C.packageSize):void 0,price:C.price?.amount??0,pricing_type:C.pricingType,starting_unit:Number(C.startingUnit)||1}))));const O=JE(d,u);return O!=null&&(b.accounting_detail=O),b})(s,o,0,r))):n.map((o=>{const c=Pt(o.priceCode)??Ol(o.name),d={description:DE(o.description),invoice_notes:DE(o.invoiceNotes),name:o.name.trim(),price_code:c,show_description_in_invoices:o.showDescriptionInInvoices};d.accounting_detail=JE(o,r)??null;const l=Pt(o.id);return l!=null?{...d,id:l}:d})),a},wE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",sK={archive:"invoicing_discount_archive",delete:"invoicing_discount_delete",unarchive:"invoicing_discount_unarchive"},Cl=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",ta=s=>s.trim()!==""?s.trim():void 0,Mn=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",nK={activate:"invoicing_subscription_activated",cancel:"invoicing_subscription_cancelled",change_term_end:"invoicing_subscription_term_end_changed",pause:"invoicing_subscription_paused",reactivate:"invoicing_subscription_reactivated",remove_scheduled_cancellation:"invoicing_subscription_cancellation_removed",resume:"invoicing_subscription_resumed",set_non_renewing:"invoicing_subscription_non_renewing"},$E=s=>(s??"").trim().toUpperCase(),RE=s=>(s??"").trim().toUpperCase(),ME=(s,i,r,t,e)=>s.postAndGetJSON(`${i}/subscriptions/${encodeURIComponent(r)}/${t}`,{coupon_code:e}).pipe(nt((a=>T(a)?{success:!0,payload:a.data??null}:{success:!1,payload:null,status:a.status})),v((a=>p({success:!1,payload:null,status:f("Unexpected Error",`${t} REST API call errored out `+JSON.stringify(a))})))),VE=s=>s.status??f("Unexpected Error","Coupon sync failed without a status"),LE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",oK={regenerate:"invoicing_invoice_regenerated","send-reminder":"invoicing_invoice_reminder_sent",void:"invoicing_invoice_voided"},xl=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Ul=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",FE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",qE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",iK={cancel:"invoicing_dunning_cancel",resolve:"invoicing_dunning_case_resolved",retry:"invoicing_dunning_retry"},jE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",Tt=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress";function GE(s){return{connected:s.connected,companyName:s.company_name??void 0,connectionId:s.connection_id??void 0,realmId:s.realm_id??void 0}}const zE=(s,i)=>i||s.fetchState!=="Completed"&&s.fetchState!=="In-Progress",cK=(s,i)=>{if(i==null)return[];const r=JD(s,i),t=wD(i),e=$D(i),a=RD(i);if(a&&r)return[];if(r)return[];if(a)return[];if(t)return["bookkeeping","zeni_bill_pay","zeni_reimbursements"];if(e){const n=[];return i.productSettings.isCfoEnabled&&n.push("zeni_cfo"),i.productSettings.isTaxEnabled&&n.push("zeni_tax"),i.productSettings.isPayrollEnabled&&n.push("zeni_payroll"),n}return[]},dK=(s,i,r,t)=>{const{qboRealmId:e,chargebeeId:a,isSubsidiary:n,parentCompanyId:o}=s;e&&e!==t?.qboRealmId?i.qbo_realm_id=e:!e&&t?.qboRealmId!=null&&(i.qbo_realm_id=""),n==null||r!=null&&(r==null||n===r?.company.companyOnboardingInfo.isSubsidiary&&o===r?.company.companyOnboardingInfo.parentCompanyId)||(n===!0?(i.is_subsidiary=!0,i.parent_company_id=o):i.is_subsidiary=!1),a&&a!==t?.chargebeeId&&(i.chargebee_customer_id=a)},KE=(s,i)=>{const r=s?.onboarding_customer_user_ids!=null&&s.onboarding_customer_user_ids.length>0?s.onboarding_customer_user_ids[0]:"";let t="";if(r!=null){const e=i.find((a=>a.user_id===r));if(e!=null){const a=e.first_name?.trim()??"",n=e.last_name?.trim()??"";t=a&&n?`${a} ${n}`:a||n||""}}return t},lK=s=>{return{key:s.key,status:(i=s.status,i==="idle"||i==="starting"||i==="building"||i==="ready"?i:"idle"),startedAt:s.started_at,completedAt:s.completed_at};var i},uK=new Set(["employees","customers","physical_office","banking_relationships"]),pK={Employees:"employees",Customers:"customers","Physical office or facility":"physical_office","Banking relationships":"banking_relationships"};function mK(s){return uK.has(s)?s:pK[s]??s}const YE=(s,i,r,t,e)=>{const{companyDescription:a,companyLegalName:n,companyIndustry:o,companyIndustryType:c,companySubIndustry:d,countriesOfOperations:l,companySourceOfFunds:u,companySourceOfFundsDescription:m,transactionVolume:h,transactionVolumeDescription:g,purposeOfAccount:I,purposeOfAccountDescription:b,regulatedStatus:E,regulatedStatusDescription:P,usNexus:O,usNexusTypes:C,website:U,incDate:B,taxIdOrEIN:x,phone:k,syncToken:J,fileIds:L,typeOfIncorporation:R,stateOfIncorporation:q,sourceOfFunds:$}=s,D={is_ready_for_verification:i,file_ids:L},w=r!=null?xe(r):void 0,K=t!=null?xe(t):void 0;return J0(r!=null?to(r):r,t!=null?to(t):t)?D.is_registered_address_same_as_company_address=!0:D.is_registered_address_same_as_company_address=!1,a!=null&&(D.company_description=a),n!=null&&(D.company_legal_name=n),U!=null&&(D.company_url=U.toString()),x!=null&&(D.tax_id=x),B!=null&&(D.company_inc_date=B.format("YYYY-MM-DD")),k!=null&&(D.phone=k),J!=null&&(D.sync_token=J),w!=null&&(D.address=w),K!=null&&(D.registered_address=K),R!=null&&(D.company_inc_type=R),q!=null&&(D.company_inc_state=q),o!=null&&(D.company_industry=o),Object.assign(D,{...c!=null&&{company_industry_type:c},...d!=null&&{company_industry_sub_type:d},...l!=null&&l.length>0&&{company_countries_of_operations:l},...u!=null&&{company_source_of_funds:u},...m!=null&&{company_source_of_funds_desc:m},...h!=null&&{company_transaction_vol_expectations:h},...g!=null&&{company_transaction_vol_expectations_desc:g},...I!=null&&{company_purpose_of_account:I},...b!=null&&{company_purpose_of_account_desc:b},...E!=null&&{company_regulated_states:E==="yes"},...P!=null&&{company_regulated_states_desc:P},...O!=null&&{company_us_nexus:O==="yes"},...C!=null&&C.length>0&&{company_us_nexus_desc:C.map(mK)}}),e==="zeni_treasury"&&$!=null&&(D.source_of_funds=$),D.is_new_company_industry_verified=!0,D},HE=(s,i)=>{const r={first_name:s.firstName,last_name:s.lastName,email:s.email};return i||s.userId==null||(r.user_id=s.userId),s.syncToken!=null&&(r.sync_token=s.syncToken),r},QE=(s,i,r)=>{const{firstName:t,lastName:e,userId:a,email:n,syncToken:o,ssn:c,birthday:d,nationalityCountryCode:l,phone:u,otpChallenge:m,isPhoneVerified:h,titleAtCompany:g,ownershipInCompany:I,documentTypeSelectedForVerification:b,fileIds:E,additionalSubmittedDocumentsForVerificationFileIds:P}=s,O={first_name:t,last_name:e,file_ids:E},C=r!=null?xe(r):void 0;return a==null?n!=null&&(O.email=n):(a!=null&&(O.user_id=a),o!=null&&(O.sync_token=o)),c!=null&&(O.ssn=c),O.birthday=d?.format("YYYY-MM-DD")??null,u!=null&&(O.phone=u),O.title_at_company=g??"",O.company_ownership=I??null,O.document_type_for_verification=b??"",O.nationality_country_code=l??"",C!=null&&(O.address=C),m!=null&&h===!0&&(O.phone_verification={otp_challenge:m}),i&&(O.are_additional_documents_submitted_for_verification=!0,O.additional_submitted_documents_for_verification_file_ids={social_security_card:P}),O},yK=s=>{switch(s){case"charge_cards":return"charge_cards";case"debit_cards":return"debit_cards";case"charge_cards__debit_cards":return"charge_cards__debit_cards";case"reimbursement":return"reimbursements";case"zeni_accounts":return"deposit_accounts";case"bill_pay":return"bill_pay";case"zeni_treasury":return"treasury_accounts";case"other_connection":return"other_connection";case"billing":return console.warn("Invalid type for setup view"),""}},_K=s=>{const{companyLegalName:i,syncToken:r}=s,t={is_ready_for_verification:!1};return i!=null&&(t.company_legal_name=i),r!=null&&(t.sync_token=r),t},hK=(s,i)=>{const{syncToken:r}=s;return{company:{sync_token:r,subscription_billing_address:xe(i)}}};function WE(s,i,r,t){const{companyInfo:e,incInfo:a,taxInfo:n,questionaire:o,companyBillPayInfo:c}=s,{companyId:d,companyDescription:l,companyLegalName:u,companyUrl:m,phone:h,syncToken:g,sourceOfFunds:I,companySourceOfFunds:b,companySourceOfFundsDescription:E,countriesOfOperations:P,transactionVolume:O,transactionVolumeDescription:C,purposeOfAccount:U,purposeOfAccountDescription:B,regulatedStatus:x,regulatedStatusDescription:k,usNexus:J,usNexusTypes:L}=e,{usersSelectedForVerification:R}=c,{fileIds:q,companyIncDate:$,companyIncType:D,companyIncState:w,companySubIndustry:K,companyIndustryType:G}=a,{companyIndustry:Z}=o,{taxId:de}=n,ue={companyId:d,companyDescription:l,companyIndustry:Z,companyIndustryType:G,companyLegalName:u,companySubIndustry:K,companySourceOfFunds:b,companySourceOfFundsDescription:E,countriesOfOperations:P,taxIdOrEIN:de,incDate:$,phone:h,website:m,fileIds:q,syncToken:g,typeOfIncorporation:D,sourceOfFunds:I,stateOfIncorporation:w,transactionVolume:O,transactionVolumeDescription:C,purposeOfAccount:U,purposeOfAccountDescription:B,regulatedStatus:x,regulatedStatusDescription:k,usNexus:J,usNexusTypes:L};let te;if(t!=null){const{firstName:Ae,lastName:pe,email:fe,userId:na,syncToken:oa}=t;te={userId:na,firstName:Ae,lastName:pe,email:fe,syncToken:oa}}const ye=i.slice(0,Fl.length).sort(((Ae,pe)=>Ae.createTime?.isAfter(pe.createTime)===!0?1:-1));let _e=R?.[0]!=null?ye.findIndex((Ae=>Ae.userId===R[0])):0;_e<0&&(_e=0);const Ve=ye.map(((Ae,pe)=>{const{userId:fe,firstName:na,lastName:oa,birthday:ia,email:aP,nationalityCountryCode:rP,phone:sP,isPhoneVerified:nP,ssn:oP,syncToken:iP}=Ae,Xe=r.find((cP=>cP.userId===fe));return{officerType:`Officer_${pe+1}`,userId:fe,firstName:na,lastName:oa,birthday:ia,email:aP,nationalityCountryCode:rP,phone:sP,isPhoneVerified:nP,ssn:oP,fileIds:Xe?.fileIds??[],syncToken:iP,isSelectedForVerification:_e===pe,documentTypeSelectedForVerification:Xe?.documentTypeSelectedForVerification,titleAtCompany:Xe?.titleAtCompany,ownershipInCompany:Xe?.ownershipInCompany,userVerificationStatus:Xe?.userVerificationStatus,treasuryUserVerificationStatus:Xe?.treasuryUserVerificationStatus,additionalDocumentTypesRequestedForVerification:Xe?.additionalDocumentTypesRequestedForVerification??[],additionalSubmittedDocumentsForVerificationFileIds:Xe?.additionalSubmittedDocumentsForVerificationFileIds??[],areAdditionalDocumentsRequestedForVerification:Xe?.areAdditionalDocumentsRequestedForVerification??!1,areAdditionalDocumentsSubmittedForVerification:Xe?.areAdditionalDocumentsSubmittedForVerification??!1}}));return Ve.length===0&&Ve.push({officerType:"Officer_1",userId:void 0,firstName:"",lastName:"",email:"",nationalityCountryCode:void 0,fileIds:[],isSelectedForVerification:!1,additionalDocumentTypesRequestedForVerification:[],additionalSubmittedDocumentsForVerificationFileIds:[],areAdditionalDocumentsRequestedForVerification:!1,areAdditionalDocumentsSubmittedForVerification:!1}),{companyDetails:ue,officers:Ve,primaryContactDetails:te}}const ZE=(s,i)=>{switch(s){case"update_account":return{is_link_update_mode:!0,is_same_day_microdeposits_enabled:!0,payment_account_id:i};case"link_account_no_microdeposit":return{is_link_update_mode:!1,is_same_day_microdeposits_enabled:!1};default:return{is_link_update_mode:!1,is_same_day_microdeposits_enabled:!0}}},Vn=(s,i,r)=>{const{is_admin:t,is_bookkeeping_admin:e,is_bookkeeping_user:a,user_id:n,is_invite_accepted:o,is_reimbursements_user:c,is_zeni:d,is_zeni_support_user:l}=i;!o||d&&!r||(l||t||e||a||c?s.push(GJ({userType:"manager",id:n})):s.push(w0({userType:"manager",id:n})))},SK=(s,i)=>({invites:s.map((r=>{const t={};return jl(r.role,i).forEach((e=>{t[`is_${e}`]=!0})),r.email.map((e=>({user_email:e,manager_user_id:r.managerId==null||r.managerId==="no_manager"?void 0:r.managerId,accounting_class_ids:r.departmentId!=null?[r.departmentId]:void 0,...t})))})).flat()}),gK=s=>({users:s.map((i=>{const r=i.role[0];return i.email.map((t=>({is_zeni:!0,user_id:null,user_email:t,[`is_${r}`]:!0})))})).flat()}),fK=(s,i,r,t)=>{const e={},{accountingClassIDs:a,managerUserId:n,userRoles:o}=r.userRole;if(s.departmentId!=null&&s.departmentId!==a[0]&&(e.accounting_class_ids=[s.departmentId]),s.managerId!=null&&s.managerId!==n&&(e.manager_user_id=s.managerId!=="no_manager"?s.managerId:null),s.role!=null){const c=jl(s.role,t),d={};o.forEach((l=>{i&&iw(l)||(d[`is_${l}`]=!1)})),c.forEach((l=>{d[`is_${l}`]=!0})),Object.assign(e,d)}return e},Hr=s=>{if(s==null||s.length===0)return;const i=[];return s.map((r=>{i.push(...mw(r))})),i},XE=(s,i)=>{if(s.length===0)return;const r={};return i.length!==s.length?r[i[0]]=vg(s[parseInt(i[0])]):s.forEach(((t,e)=>{r[i[e]]=vg(t)})),r},e0=s=>`${s}s`,vK=(s,i)=>({referrals:s.map((r=>({company:r.companyName,email_ids:r.emailIds,refer_reward_plan_id:i})))}),IK=s=>({vendor_id:s.id,vendor_name:s.name}),bK=({balanceAsOfToday:s,recurringAmount:i})=>s!=null?s.amount:i.amount,EK=(s,i)=>{const{estimatedMonthlyAmount:r,memo:t,selectedAccount:e,selectedClass:a,selectedMonths:n,selectedVendor:o,selectedAccruedExpenseCategory:c,jeScheduleDetails:d,startingBalance:l}=s,u=$0,m=d.length,h=m>0?s.jeScheduleDetails[0].postingDate.format(re):null,g=m>0?s.jeScheduleDetails[m-1].postingDate.format(re):null;return{status:{code:"new",label:"New"},vendor:{vendor_id:o?.id??"",vendor_name:o?.name??""},posting_date:u,currency_code:r?.currencyCode??"USD",currency_symbol:r?.currencySymbol??"$",period:n??0,je_schedule_type:"accrued_expenses",balance:l?.amount??0,other_attributes:{starting_balance:l?.amount??0},start_date:h,end_date:g,je_credit_accounting_class_id:i??"",je_credit_account_id:c??"",je_debit_account_id:e??"",je_debit_accounting_class_id:a??"",memo:t??"",recurring_amount:r?.amount??0,is_deleted:!1}},X0=(s,i,r,t,e)=>{const{vendor:a,currencyCode:n,currencySymbol:o,status:c,startDate:d,recurringAmount:l,endDate:u,balanceAsOfToday:m}=s,{selectedMonths:h,selectedAccount:g,selectedClass:I,memo:b,estimatedMonthlyAmount:E,selectedAccruedExpenseCategory:P,startingBalance:O}=r,C=$0,U=r.jeScheduleDetails.length,B=U>0?r.jeScheduleDetails[0].postingDate.format(re):null,x=U>0?r.jeScheduleDetails[U-1].postingDate.format(re):null,k=a.id,J=i.vendorByID[k],L={status:c,vendor:IK(J),currency_code:n,currency_symbol:o,other_attributes:{starting_balance:O?.amount??0},period:h??null,je_schedule_type:"accrued_expenses",posting_date:C,balance:bK({balanceAsOfToday:m,recurringAmount:l}),start_date:d?.format(re)??B,end_date:u?.format(re)??x,je_credit_accounting_class_id:t??"",je_credit_account_id:P??null,je_debit_account_id:g??null,je_debit_accounting_class_id:I??null,memo:b??"",recurring_amount:E?.amount??0};return e===!0?{...L,is_deleted:!0}:L},zl=(s,i)=>s.find((t=>t.labels?.includes(i)===!0))?.classId??"",PK=(s,i)=>{const r={je_schedules:[],scheduled_journal_entries:[]},{classListState:t,classState:e}=s,a=tr(e,t).classes,n=zl(a,"balance_sheet");return r.je_schedules=[EK(i,n)],r.scheduled_journal_entries=(o=>{const c=o.jeScheduleDetails,d=o.startingBalance?.amount??0;return c.map(((l,u)=>({status:{code:l.postingStatus,label:l.postingStatus},transaction_memo:l.memo,third_party_id:l.jeLink.thirdPartyTransactionId??null,expected_post_date:l.postingDate.format(re),amount:l.amount.amount,balance:u===0&&d!==0?d:l.runningBalance.amount,scheduled_journal_entry_id:null,actual_post_date:null,is_platform_generated:null,je_schedule_id:null,update_time:null,create_time:null})))})(i),r},t0=(s,i,r,t)=>{const e={je_schedules:[],scheduled_journal_entries:[]},{scheduleAccruedDetailState:a}=s,{selectedJEAccruedLinkRowIndex:n,linkBillExpenseView:o}=a;let c;const d=At(s.transactionState,o.linkBillExpenseLocalData.selectedTransaction??"");d!=null&&(c={transaction_id:d.id,transaction_type:d.type});const l=sa(r,s);if(l!=null){const{vendorState:u,classListState:m,classState:h}=s,g=tr(h,m).classes,I=zl(g,"balance_sheet"),b=i.jeScheduleDetails;e.je_schedules=[X0(l,u,i,I,t)],e.scheduled_journal_entries=((E,P,O,C,U)=>{const B=P.scheduledJournalEntry;return E.map(((x,k)=>{const J=B[k],L={status:{code:x.postingStatus,label:AK(x.postingStatus)},transaction_memo:x.memo,third_party_id:x.jeLink.thirdPartyTransactionId??null,expected_post_date:x.postingDate.format(re),amount:x.amount.amount,...O===k&&C!=null?{is_bill_linked:!0}:{},...O===k&&C!=null?{reversal_transaction_details:C}:x.jeLink.reversalTransactionDetails!=null?{reversal_transaction_details:R0(x.jeLink.reversalTransactionDetails)}:{},balance:x.runningBalance.amount,scheduled_journal_entry_id:J?.scheduledJournalEntryID!=null?J.scheduledJournalEntryID:null,actual_post_date:J?.actualPostDate!=null?J.actualPostDate.format(re):null,is_platform_generated:J?.isPlatformGenerated!=null?J.isPlatformGenerated:null,je_schedule_id:J?.jeScheduleId!=null?J.jeScheduleId:null,update_time:J?.syncToken!=null?J.syncToken:null,create_time:J?.createTime!=null?J.createTime.format(re):null};return U===!0?{...L,is_deleted:!0}:L}))})(b,l,n,c,t)}return e},TK=(s,i,r,t)=>{const e={je_schedules:[],scheduled_journal_entries:[]},a=sa(r,s);if(a!=null){const{vendorState:n,classListState:o,classState:c}=s,d=tr(c,o).classes,l=zl(d,"balance_sheet"),u=i.jeScheduleDetails;e.je_schedules=[X0(a,n,i,l,!1)],e.scheduled_journal_entries=((m,h,g)=>{const I=h.scheduledJournalEntry;return m.map(((b,E)=>{const P=I[E];return{status:{code:g==null&&b.postingStatus==="pending"||g!=null&&g===E?"canceled":b.postingStatus,label:g==null&&b.postingStatus==="pending"||g!=null&&g===E?"Canceled":b.postingStatus},transaction_memo:b.memo,third_party_id:b.jeLink.thirdPartyTransactionId??null,...b.jeLink.reversalTransactionDetails!=null&&{reversal_transaction_details:R0(b.jeLink.reversalTransactionDetails)},expected_post_date:b.postingDate.format(re),amount:b.amount.amount,balance:b.runningBalance.amount,scheduled_journal_entry_id:P?.scheduledJournalEntryID!=null?P.scheduledJournalEntryID:null,actual_post_date:P?.actualPostDate!=null?P.actualPostDate.format(re):null,is_platform_generated:P?.isPlatformGenerated!=null?P.isPlatformGenerated:null,je_schedule_id:P?.jeScheduleId!=null?P.jeScheduleId:null,update_time:P?.syncToken!=null?P.syncToken:null,create_time:P?.createTime!=null?P.createTime.format(re):null}}))})(u,a,t)}return e},AK=s=>s.charAt(0).toUpperCase()+s.substring(1),NK=function(s,i,r){let t=Wg(i,s,31);return t.month()!==s&&(t=Wg(i,s).endOf("month")),{postingDate:t,postingStatus:"pending"}},OK=(s,i)=>`${s} - ${i.format(h$)} - Acc_${i.format(S$)}`,CK=(s,i,r,t)=>{const e=s.selectedMonths,a=s.selectedDate;if(a==null)return[];const n=[];if(e==null)return[];for(let o=0;o<e;o++){const c=a.add(o,"month"),{postingDate:d,postingStatus:l}=NK(c.month(),c.year());n.push({postingDate:d,amount:Wa(i.amount,i.currencyCode,i.currencySymbol),runningBalance:Wa(o===0?r.amount??0:0,i.currencyCode,i.currencySymbol),postingStatus:l,memo:OK(t,c),jeLink:{type:"unknown"}})}return n},xK=(s,i)=>{const r=Math.abs(s[i].amount.amount);return s.map(((t,e)=>e===i?{...t,amount:{...t.amount,amount:r}}:t))},UK=(s,i,r,t)=>({type:i!=null?"linked":s==null?r==null?"unknown":"recommended":"qbourl",thirdPartyTransactionId:s,recommendedTransactionID:r,transactionDetailID:i!=null?{id:i,type:"journal_entry"}:void 0,reversalTransactionDetails:t!=null?{id:t.id,type:t.type}:void 0}),kK=s=>s.period!=null&&s.je_debit_account_id!=null&&s.je_debit_accounting_class_id!=null&&s.start_date!=null&&s.posting_date!=null&&s.period!=null&&s.je_credit_account_id!=null,BK=(s,i)=>({company:{sync_token:i,subscription_billing_address:xe(s)}});function Ln(s){return{frequency_type:s.frequency,preferred_mode:s.preferredMode}}const DK=(s,i,r)=>{const{origin:t,phone:e,otpChallenge:a,birthday:n,address:o,firstName:c,lastName:d}=s,l=i.birthday==null,u=r!=null&&o!=null?!J0(to(r),to(o)):r==null&&o!=null;let m={first_name:c??void 0,last_name:d??void 0,birthday:l&&n!=null?n.format(re):void 0,address:u&&o!=null?xe(o):void 0};return a!=null&&e!=null&&(m={...m,phone:e,phone_verification:{otp_challenge:a}}),t==="CardUserOnboarding"?{...m,is_card_issue_fulfilment_request:e!=null&&a!=null&&n!=null,address:r!=null?xe(Wn(r)):void 0}:m},kl=s=>({amount:s.amount,autoTransferRuleId:s.auto_transfer_rule_id,createTime:s.create_time!=null?ee(s.create_time):void 0,currencyCode:s.currency_code,currencySymbol:s.currency_symbol??"$",destinationBankAccountId:s.destination_bank_account_id,destinationBankAccountMetadata:s.destination_bank_account_metadata?.map((i=>({accountId:i.account_id,accountType:i.account_type,percentage:i.percentage})))??void 0,destinationBankAccountType:s.destination_bank_account_type??void 0,frequency:s.frequency,isActive:s.is_active,isDeleted:s.is_deleted,lastRunTime:s.last_run_time,nextTransferDate:s.next_transfer_date!=null?ee(s.next_transfer_date):void 0,ruleType:s.rule_type,sourceBankAccountId:s.source_bank_account_id,sourceBankAccountType:s.source_bank_account_type,updateTime:s.update_time!=null?ee(s.update_time):void 0});function a0(s,i,r){return i===!0?{is_active:!1}:r===!0?{is_active:!0}:{...s.amount!=null&&s.ruleType!=="percentage_of_balance"&&{amount:s.amount.amount,currency_code:s.amount.currencyCode},...s.destinationAccount!=null&&{destination_bank_account_id:s.destinationAccount.id,destination_bank_account_type:Xr(s.destinationAccount.accType)},...s.destinationAccountWithPercentAllocation!=null&&{destination_bank_account_metadata:s.destinationAccountWithPercentAllocation.map((t=>({account_id:t.account.id,account_type:Xr(t.account.accType),percentage:t.percentage})))},frequency:s.frequency,rule_type:s.ruleType,...s.sourceAccount!=null&&{source_bank_account_id:s.sourceAccount.id,source_bank_account_type:Xr(s.sourceAccount.accType)},...s.firstTransferDate!=null&&{first_transfer_date:s.firstTransferDate.format("YYYY-MM-DD")}}}const Xr=s=>{switch(s){case"depositAccount":return"deposit_account";case"paymentAccount":return"payment_account";case"treasuryAccount":return"treasury_account";default:return}};function JK(s){const i=[],r=s.vendor_id;return r&&i.push(aa(r,!1)),i}const r0=s=>{let i;if(s.criteria!=null){const{amount:a,vendor:n,department:o}=s.criteria,c=[];if(a?.min!=null&&c.push({field:"amount",type:"gte",value:a.min.amount}),a?.max!=null&&c.push({field:"amount",type:"lte",value:a.max.amount}),n!=null&&n.vendorIds.length>0&&c.push({field:"vendor_id",type:n.operator==="is_not"?"not_in":"in",value:n.vendorIds}),o!=null&&o.departmentIds.length>0&&c.push({field:"accounting_class_id",type:o.operator==="is_not"?"not_in":"in",value:o.departmentIds}),c.length>0){const d=a?.min??a?.max??null;i={conditions:c,criteria_operator:"and",currency_code:d?.currencyCode??"USD",currency_symbol:d?.currencySymbol??"$"}}}const r=s.steps.map((a=>({action:a.action,operator:a.operator,actors:a.actors.filter((n=>n.subType!=="admin")).map((n=>({type:n.type,id:n.userId??null,sub_type:n.subType??null,id_type:n.idType??null,is_implicit_actor:n.isImplicitActor??!1})))}))),t=s.approvalRuleId!=null,e={steps:r,is_applicable_on_pending_approval_entity:s.isApplicableOnPendingApprovalEntity??!0};return i!=null&&(e.criteria=i),s.name!=null&&(e.name=s.name),s.description!=null&&(e.description=s.description),s.separationOfDuties!=null&&(e.is_separation_of_duty_enabled=s.separationOfDuties),t&&(e.approval_rule_id=s.approvalRuleId),e},s0=s=>{const i=s.criteria?.amount,r=i?.min,t=i?.max,e=r?.currencyCode??t?.currencyCode??"USD",a=r?.currencySymbol??t?.currencySymbol??"$",n=s.steps.map((m=>({action:m.action,operator:m.operator,actors:m.actors.filter((h=>h.subType!=="admin")).map((h=>({type:h.type,id:h.userId??null,sub_type:h.subType??null,id_type:h.idType??null,is_implicit_actor:h.isImplicitActor??!1})))}))),o=s.approvalRuleId!=null,c=r?.amount??null,d=t?.amount??null,l=[];c==null&&d==null?console.warn("[approvalRules][V1] toApprovalChangableInfoPayloadV1: rule has no amount bounds; emitting empty criteria array. The V1 backend will reject this save — caller should ensure at least one bound is set on the form."):l.push({type:"range",range_entity:"currency",min:c,max:d,currency_code:e,currency_symbol:a});const u={steps:n,is_applicable_on_pending_approval_entity:s.isApplicableOnPendingApprovalEntity??!0,criteria:l};return o&&(u.approval_rule_id=s.approvalRuleId),u};function Bl(s,i,r){const t=i.billDetailLocalData.isCancelled,e=i.billDetailLocalData.updatesByLineId,a={...e},n=r?.accountId!=null?Ze(s.accountState,r.accountId,"account_list"):void 0,o=r?.classId!=null?Xa(s.classState,{classId:r.classId,reportId:"class_list"}):void 0,c=r?.vendorCurrencyCode,d=r?.vendorCurrencySymbol,{tenantState:l,companyState:u}=s,{currentTenantId:m}=l,h=m!=null?l.tenantsById?.[m]?.companyId:void 0,g=Te(u,h??""),I=g?.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach,b=I!=null&&me().isSameOrBefore(I);return Object.keys(a).forEach((E=>{const P=e[E];a[E]={...P,account:n,class:o,...es}})),Object.keys(a).length===0&&(a[1]={account:n,class:o,amount:{amount:0,currencyCode:c??"USD",currencySymbol:d??"$"},recipientAmount:{amount:0,currencyCode:c??"USD",currencySymbol:d??"$"},id:"1",lineDescription:"",platformLineDetailType:"account_based_expense_line_detail",type:"transaction_with_account_and_class_line",billable:"not_billable",isCategoryMiscategorized:!1,isClassMiscategorized:!1,...es}),{showVendorGptRecommendationText:!1,vendor:r,isCancelled:t,updatesByLineId:a,whatForSection:{...i.billDetailLocalData.whatForSection,currencyCode:r?.vendorCurrencyCode,recipientCurrencyCode:r?.vendorCurrencyCode},paymentDetailsSection:{...i.billDetailLocalData.paymentDetailsSection,paymentTo:void 0,internationalTransferFeeBearerPaymentMethod:r?.preferredInternationalTransferFeeBearerPaymentMethod,paymentDate:i.billDetailLocalData.paymentDetailsSection?.paymentDate??ee(eo(me().toDate(),[0,6],b?0:1).toISOString())},isCollectToAccountInfoFromVendorContact:!1,isRecurring:!1}}const eP=(s,i,r,t,e,a)=>{const n=i;let o=r?.[s]??[];if(o.length===0&&a?.recommendations!=null&&a?.recommendations.length>0&&(o=a?.recommendations),o.length===0)return{...n,...es};const[c]=o,d=c?.account,l=c?.class;let u,m,h=n?.account,g=n?.class;if(!h?.qboId&&(h=void 0),!g?.classId&&(g=void 0),h==null&&a!=null){const E=t.accounts.find((P=>P.qboId===a.qboId));d!=null?m=d:E!=null?m=E??a.recommendations[0]?.account:a.recommendations[0]?.account!=null&&(m=a.recommendations[0]?.account)}if(g==null&&a!=null){const E=e.classes.find((P=>P.classId===a.classId));l!=null?u=l:E!=null?u=E??a.recommendations[0]?.class:a.recommendations[0]?.class!=null&&(u=a.recommendations[0]?.class)}const I=((E,P)=>P!=null&&!!E.find((O=>O.class?.classId===P.classId)))(o,g),b=((E,P)=>P!=null&&!!E.find((O=>O.account?.qboId===P.qboId)))(o,h);return{...n,recommendedCategory:d,isCategoryFirstTimeAutofilled:!!d?.qboId,isCategoryUpdateSelected:!1,isRetainedCategorySelected:!1,retainedCategory:b?void 0:h,account:h??m,recommendedClass:l,isClassFirstTimeAutofilled:!!l?.classId,isClassUpdateSelected:!1,isRetainedClassSelected:!1,retainedClass:I?void 0:g,class:g??u,isCategoryOrClassUpdated:!1,updateAllCheckbox:!1}},wK=(s,i,r,t,e)=>{const a={currencyCode:r.recipient_currency_code??"",currencySymbol:r.recipient_currency_symbol??""},n={},o=t?.accountId,c=l1(r.lines,r.recommendations),d=r.lines?.[0]?.line_detail;let l=!0,u=!0;r.lines?.forEach((K=>{K.line_detail.account.account_id!==d.account.account_id&&(l=!1),K.line_detail.class.accounting_class_id!==d.class.accounting_class_id&&(u=!1);const G=Ze(s.accountState,o??"","account_list"),Z=Xa(s.classState,{classId:t?.classId??"",reportId:"class_list"}),de=u1(K,a),{accountListState:ue,accountState:te,classListState:ye,classState:_e}=s,Ve=tr(_e,ye),Ae=M0(te,ue,"billPayAccountList"),pe=eP(K.line_id,de,c,Ae,Ve,t);n[K.line_id]={...pe,account:pe.account?.accountId===""&&G!=null?G:pe.account,class:pe.class?.classId===""&&Z!=null?Z:pe.class}})),r.tax!=null&&r.tax>0&&n0(r.tax,a,"Tax",l,u,n),r.discount!=null&&r.discount>0&&n0(-r.discount,a,"Discount",l,u,n);const m=r.bill_pay_info?.bill_payment_method_type.code,h=r.bill_pay_info?.bill_payment_method_type.sub_code,g=r.bill_pay_info?.international_transfer_fee_bearer_payment_method,{internationalCode:I,internationalSubCode:b}=p1(h!=null?dv(h):void 0,g!=null?cv(g):void 0),{tenantState:E,companyState:P}=s,{currentTenantId:O}=E,C=O!=null?E.tenantsById?.[O]?.companyId:void 0,U=Te(P,C??""),B=U?.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach,x=B!=null&&me().isSameOrBefore(B),k=r.bill_pay_info?.from_account.account_type!=null?m1(y1(r.bill_pay_info?.from_account.account_type)):void 0,J=U?.company.companyInfo.bookCloseDate,L=r.transaction_date?Rl("draft",ee(r.transaction_date),J):void 0,R=r.due_date?r.transaction_date?V0("draft",ee(r.due_date),ee(r.transaction_date),J):ee(r.due_date):void 0,q=m!=null&&h!=null?_1(s.billPayConfigState,h1(q0(m),F0(f1(dv(h))),k,I!=null?g1(I):void 0,b!=null?S1(b):void 0)):void 0,$=Gl(m??""),D=r.bill_pay_info?.outside_zeni_transaction_payment_mode,w=$?{paymentMode:D!=null?v1(D):void 0,paymentDate:r.bill_pay_info?.payment_date!=null?ee(r.bill_pay_info?.payment_date):void 0}:void 0;return{recommendedVendorId:e,showVendorGptRecommendationText:i,lastRecommendedVendorName:e!=null?t?.name:void 0,vendor:t,whatForSection:{invoiceNumber:r.invoice_number,billDueDate:R,memo:r.transaction_memo,invoiceDate:L,isInvoiceDateAutoUpdated:!!r.transaction_date&&J!=null&&ee(r.transaction_date).isBefore(J),currencyCode:r.currency_code,recipientCurrencyCode:r.recipient_currency_code},updatesByLineId:n,paymentDetailsSection:{paymentTo:void 0,paymentType:q,paymentDate:r.bill_pay_info?.payment_date!=null?ee(r.bill_pay_info?.payment_date):ee(eo(me().toDate(),[0,6],x?0:1).toISOString()),withdrawFrom:L0(s,r.bill_pay_info?.from_account.account_id??"",r.bill_pay_info?.from_account.account_type??""),internationalTransferFeeBearerPaymentMethod:r.bill_pay_info?.international_transfer_fee_bearer_payment_method!=null?cv(r.bill_pay_info?.international_transfer_fee_bearer_payment_method):void 0},totalAmount:r.amount!=null?ao(r.amount,{currencyCode:r.currency_code??"USD",currencySymbol:r.currency_symbol??"$"}):void 0,recipientTotalAmount:r.recipient_total_amount!=null?ao(r.recipient_total_amount,{currencyCode:r.recipient_currency_code??"USD",currencySymbol:r.recipient_currency_symbol??"$"}):void 0,isCancelled:!1,toAccountVendorEmail:r.bill_pay_info?.to_account_vendor_email??void 0,isCollectToAccountInfoFromVendorContact:r.bill_pay_info?.is_collect_to_account_info_from_vendor_contact??!1,isRecurring:r.is_recurring??!1,outsideZeniPaymentLocalData:w}},$K=(s,i,r,t,e)=>{const a={};return Object.keys(s).forEach((n=>{switch(n){case"vendor":r!=null&&(a.tentativeVendorName=r,a.tentativeVendorName=r+(i===!0?" - "+t:""),a.currencyInInvoice=t,a.vendorCurrency=e),a.isVendorWithNewCurrency=i,s[n]&&(a.vendor="vendor");break;case"whatForSection":if(s.whatForSection!=null){const o=[];Object.keys(s.whatForSection).forEach((c=>{switch(c){case"invoiceNumber":s.whatForSection?.invoiceNumber!=null&&o.push("invoiceNumber");break;case"invoiceDate":s.whatForSection?.invoiceDate!=null&&o.push("invoiceDate");break;case"billDueDate":s.whatForSection?.billDueDate!=null&&o.push("billDueDate");break;case"memo":s.whatForSection?.memo!=null&&s.whatForSection?.memo!=""&&o.push("memo")}})),o.length>0&&o.push("currency"),a.whatForSectionFields=o}break;case"updatesByLineId":if(s.updatesByLineId!=null){const o={};Object.keys(s.updatesByLineId).forEach((c=>{const d=[],l=s.updatesByLineId[c];l.recipientAmount?.amount&&d.push("amount"),l.lineDescription!=null&&d.push("lineDescription"),l.account?.accountName!=null&&l.account?.accountName.length>0&&d.push("account"),l.class?.className!=null&&l.class?.className.length>0&&d.push("class"),l.billable&&d.push("billable"),o[c]=d})),a.linesFields=o}break;case"paymentDetailsSection":if(s.paymentDetailsSection!=null){const o=[];Object.keys(s.paymentDetailsSection).forEach((c=>{switch(c){case"paymentType":s.paymentDetailsSection?.paymentType!=null&&o.push("paymentType");break;case"paymentDate":s.paymentDetailsSection?.paymentDate!=null&&o.push("paymentDate");break;case"withdrawFrom":s.paymentDetailsSection?.withdrawFrom!=null&&o.push("withdrawFrom");break;case"paymentTo":s.paymentDetailsSection?.paymentTo!=null&&o.push("paymentTo")}})),a.paymentDetailsSectionFields=o}}})),a},n0=(s,i,r,t,e,a)=>{const n=Object.keys(a).length,o=e&&n>0?a[0].class:I1({accounting_class_id:"",accounting_class_name:""}),c=t&&n>0?a[0].account:b1({account_id:"",account_name:"",labels:[]});a[n]={class:o,account:c,amount:ao(s,i),recipientAmount:ao(s,i),billable:"not_billable",lineDescription:r,isCategoryMiscategorized:!1,isClassMiscategorized:!1,id:`${n}`,platformLineDetailType:"account_based_expense_line_detail",type:"transaction_with_account_and_class_line",isCategoryUpdateSelected:!1,isCategoryFirstTimeAutofilled:o!=null&&!!o.classId,isRetainedCategorySelected:!1,isClassUpdateSelected:!1,isClassFirstTimeAutofilled:c!=null&&!!c.accountId,isRetainedClassSelected:!1,isCategoryOrClassUpdated:!1,updateAllCheckbox:!1}},o0=(s,i,r,t)=>{if(r!=null){const e=X(t?.transactionById,r);return i||e?.isRecurring===!0?`${s}/${r}/recurring`:`${s}/${r}`}return i?`${s}/recurring`:`${s}`},tP=s=>{const i=s?.method.split("_")[1],r=s?.method.split("_")[2];return{code:i?q0(i):null,name:i==="outside-zeni"?"Outside Zeni":s?.method.replace(/(_depositAccount|_paymentAccount)/g,"")??"",sub_code:r?A1(F0(r)):null}},RK=s=>Gl(s.paymentDetailsSection?.paymentType?.method)?s.outsideZeniPaymentLocalData?.paymentDate?.format("YYYY-MM-DD")??null:s.paymentDetailsSection?.paymentDate?.format("YYYY-MM-DD")??null,i0=(s,i)=>{const r=x1(s.vendorReceiveDate,i);return{instance:s.instance,payment_date:r.format("YYYY-MM-DD"),vendor_receive_date:s.vendorReceiveDate.format("YYYY-MM-DD"),vendor_receive_date_notes:s.vendorReceiveDateNotes}},MK=(s,i)=>s?"bill_pay_marked_as_paid":i==="pending_approval"?"bill_pay_sent_for_approval":"bill_pay_updated",VK=s=>{const i={};return s.supportedAccountTypes!=null&&s.supportedAccountTypes.forEach((r=>{s.supportedDynamicFormByTypes[r.type].forEach((t=>{i[r.type]={...i[r.type],[t.name]:""}}))})),i},LK=s=>({is_applicant_declaration:!0,form_details:s}),FK=s=>{const i=s.cardHolderUser,r=`${i.firstName??""} ${i.lastName??""}`.trim()||i.email||i.userId;return{id:s.id,isChecked:!1,cardName:s.cardName,last4:s.accountLast4,limitAmount:s.limit?.amount??0,limitCadence:s.creditLimitFrequency?.code,owner:{userId:i.userId,displayName:r,roleLabel:s.cardHolderRoles?.titleAtCompany},utilizationAmount:(s.limit?.amount??0)-(s.available?.amount??0)}},c0=s=>s.cardPolicyState.mccCategoriesFetchState==="Completed",d0=(s,i)=>{const r=(e=>CM(e).cards.filter((a=>{return n=a.status?.code,!(n==="closed"||n==="closed_by_customer");var n})).map(FK))(s),t=s.cardPolicyState.mccCategories;return OM({initialData:i,cardsMasterList:r,mccCategories:t,suggestedAllowMerchants:s.cardPolicyState.suggestedAllowMerchants,suggestedBlockMerchants:s.cardPolicyState.suggestedBlockMerchants,suggestedAllowCategories:s.cardPolicyState.suggestedAllowCategories,suggestedBlockCategories:s.cardPolicyState.suggestedBlockCategories})},l0=s=>LV(s.userState,s.userRoleState,s.userListViewState,"cardHolderCandidate").users.map((i=>i.user)).filter((i=>i!=null)),ne=s=>s!=null&&s.value!=null&&s.confidence>=KV,ce=(s,i,r)=>{r!=null&&(typeof r=="string"&&r.trim()===""||(s.values[i]=r,s.autoFilledFieldNames.push(i)))},Dl=s=>{const i=ee(s);if(i.isValid())return i};function qK(s){switch(s){case"bill_pay_setup":return"Bill Pay";case"reimbursement_setup":return"Reimbursements";case"charge_card_setup":return"Cards";case"treasury_setup":return"Treasury";default:return"Checking"}}const jK=s=>{const i=s.realTimeSteps.map((r=>{const t=r.actors.map((e=>({id:e.userId,is_implicit_actor:e.isImplicitActor,type:e.type,sub_type:e.subType,id_type:e.idType})));return{action:r.action,operator:r.operator,step_position:r.stepPosition,step_creator_id:r.stepCreatorId,actors:t}}));return{entity_approval_id:s.entityApprovalId,entity_type:s.entityType,description:s.description,real_time_steps:i}},GK=(s,i,r,t,e)=>({merchant:t!=null?{id:t.id,name:t.name}:void 0,description:r.transaction_memo,lineDetail:{account:Ze(s,t?.accountId??"","account_list"),class:e!=null?Xa(i,{classId:e,reportId:"class_list"}):void 0},transactionDate:ee(r.transaction_date),amount:r.amount,currencyCode:r.currency_code??"USD",currencySymbol:r.currency_symbol??"$",recommendations:[],isCategoryUpdateSelected:!1,isCategoryFirstTimeAutofilled:!1,isRetainedCategorySelected:!1}),zK=s=>{const i=[],r=s.type==="mileage"?s.mileage:s.outOfPocket;return Object.keys(r).forEach((t=>{switch(t){case"merchant":i.push("merchant");break;case"amount":r.amount!==0&&i.push("amount");break;case"transactionDate":i.push("transactionDate");break;case"description":r.description!==""&&i.push("memo");break;case"lineDetail":r.lineDetail?.account?.accountId!=null&&i.push("account")}})),i},KK=(s,i)=>i!=null&&s.type==="out_of_pocket"&&s.merchant!=null?void 0:i,YK={transaction_type:"reimbursement",reimbursement_provider:"zeni"},HK=s=>{const i={from_account:{account_type:"treasury_account"},to_account:{account_type:"treasury_account"},amount:s.amount.amount,currency_code:s.amount.currencyCode,currency_symbol:s.amount.currencySymbol};return s.fromAccount&&s.fromAccount?.accType!=="treasuryAccount"?i.from_account={account_id:s.fromAccount.id,account_type:Me(s.fromAccount.accType)??""}:s.toAccount&&s.toAccount?.accType!=="treasuryAccount"&&(i.to_account={account_id:s.toAccount.id,account_type:Me(s.toAccount.accType)??""}),i},QK=s=>{const i=tP(s.paymentType);return{to_bank_account_id:s.paymentToAccountId,vendor_id:s.vendorId,amount:s.amount.amount,payment_method_type:i.code,payment_method_sub_type:i.sub_code,source_deposit_account_id:s.withdrawFrom?.id,payment_date:s.paymentDate.format("YYYY-MM-DD"),file_id:s.receiptFileId}},u0=(s,i,r=!1)=>{const{subscriptionId:t,subscriptionPlanId:e,subscriptionAddOnIds:a,subscriptionCouponIds:n,shouldProrate:o,applyEndOfTerm:c,invoiceImmediately:d,subscriptionEstmiate:l}=s,u={tenant_id:i,subscription_id:t,subscription_plan_id:e,subscription_coupon_ids:n,subscription_addon_ids:a,invoice_immediately:d,apply_end_of_term:c,should_prorate:o};return r===!1&&(u.estimate_query_hash=l?.estimateQueryHash),u},p0=(s,i,r=!1)=>{const{subscriptionPlanId:t,subscriptionCouponIds:e,subscriptionAddOnIds:a,invoiceImmediately:n,subscriptionEstmiate:o,startDate:c}=s,d={tenant_id:i,subscription_plan_id:t,subscription_coupon_ids:e,subscription_addon_ids:a,invoice_immediately:n};return c!=null&&(d.start_date=c.format("YYYY-MM-DD")),r===!1&&(d.estimate_query_hash=o?.estimateQueryHash),d},WK=(s,i,r)=>{const t={...XK(s)};return i.postAndGetJSON(`${i.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tags`,t).pipe(y((e=>ZK(e,r))),v((e=>p(Ml({fetchState:"Error",error:f("Unexpected Error","Create Tag REST API call errored out "+JSON.stringify(e)),tagsId:[]})))))},ZK=(s,i)=>T(s)&&s.data!=null&&s.data.tags.length>0?_([Zr(s.data.tags),Ml({fetchState:"Completed",tagsId:s.data.tags.map((r=>r.tag_id))}),cq({tagId:s.data.tags[0].tag_id,taskId:i})]):_([Ml({fetchState:"Error",error:s.status,tagsId:[]}),N({messageSection:"create_tag",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:s.status.message}]})]),XK=s=>({name:s});function eY(s){return{cannedResponseId:s.canned_response_id,content:s.content,createTime:ee(s.create_time),createdBy:s.created_by,isDeleted:s.is_deleted,name:s.name,updateTime:ee(s.update_time)}}const tY=(s,i,r)=>{const t=i.value,e={...rY(t,s)};return r.putAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${s}`,e).pipe(y((a=>aY(a,s))),v((a=>p(Vl({fetchState:"Error",taskId:s,error:f("Unexpected Error","Archive Task REST API call errored out"+JSON.stringify(a))})))))},aY=(s,i)=>{if(T(s)&&s.data!=null&&s.data.tasks.length>0){const r=[ze(s.data.tasks),ro(i),Nt(),Vl({fetchState:"Completed",taskId:i})];return _(r)}return _([Vl({fetchState:"Error",taskId:i,error:s.status}),N({messageSection:"archive_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:s.status.message}]})])},rY=(s,i)=>{const{taskState:r}=s;return{sync_token:Za(r,i)?.syncToken??"",is_archived:!0}},sY=(s,i)=>({name:s.name,assignees:s.assignee,description:s.description,priority:s.priority,status:s.status,tags:s.tagIds,time_spent:so(s.timeSpent),group_assignees:s.groupAssignees,parent_task_id:s.parentTaskId,task_group_ids:i,due_date:s.dueDate?.format("YYYY-MM-DD")??null}),nY=(s,i,r)=>{const{taskDetailState:t,taskState:e}=s,a=i!=null?Za(e,i)?.syncToken??"":"",n=(i!=null?t.editTaskStateById[i]:t.newTaskState).taskDetailLocalData;return{name:n.name,assignees:n.assignee,description:n.description,due_date:n.dueDate?.format("YYYY-MM-DD")??null,priority:n.priority,status:n.status,tags:n.tagIds,file_ids:n.fileIds,type:n.type.code,recurring_end_date:n.type.code==="recurring"?n.savedRecurringEndDate?.format(re)??null:null,recurring_frequency:n.type.code==="recurring"?n.recurringFrequency:null,recurring_start_date:n.type.code==="recurring"?n.recurringStartDate?.format(re)??null:null,recurring_days_of_week:n.type.code==="recurring"&&n.recurringFrequency==="semi_weekly"?n.recurringDaysOfWeek??[]:[],sync_token:a,task_group_ids:r,time_spent:so(n.timeSpent),group_assignees:n.groupAssignees,...i==null?{is_private:n.isPrivate??!1}:{}}},oY=s=>ee(s).format(kq),iY=(s,i,r)=>r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${s}/snooze`,{snoozed_until:i}).pipe(y((t=>cY(t,s,i))),v((t=>p(er({fetchState:"Error",taskId:s,error:f("Unexpected Error","Snooze Task REST API call errored out: "+JSON.stringify(t))}))))),cY=(s,i,r)=>{if(T(s)&&s.data!=null&&s.data.tasks.length>0){const t=[ze(s.data.tasks),ro(i),Nt(),er({fetchState:"Completed",taskId:i}),N({messageSection:"snooze_task",messageText:"success",type:"success",variables:[{variableName:"_snoozed_until_",variableValue:oY(r)}]})];return _(t)}return _([er({fetchState:"Error",taskId:i,error:s.status}),N({messageSection:"snooze_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:s.status.message}]})])},dY=(s,i)=>i.deleteAndGetJSON(`${i.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${s}/snooze`).pipe(y((r=>lY(r,s))),v((r=>p(er({fetchState:"Error",taskId:s,error:f("Unexpected Error","Unsnooze Task REST API call errored out: "+JSON.stringify(r))}))))),lY=(s,i)=>{if(T(s)&&s.data!=null&&s.data.tasks.length>0){const r=[ze(s.data.tasks),ro(i),Nt(),er({fetchState:"Completed",taskId:i}),N({messageSection:"unsnooze_task",messageText:"success",type:"success"})];return _(r)}return _([er({fetchState:"Error",taskId:i,error:s.status}),N({messageSection:"unsnooze_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:s.status.message}]})])},uY=s=>{const i={};return s.status!=null&&(i.status=s.status.code),s.priority!=null&&(i.priority=s.priority.code),s.assignees!=null&&(i.assignees=s.assignees),s.groupAssignees!=null&&(i.group_assignees=s.groupAssignees),s.dueDate!=null&&(i.due_date=s.dueDate.format(re)),s.tagIds!=null&&(i.tags=s.tagIds),s.timeSpent!=null&&(i.time_spent=so(s.timeSpent.replace(/\D/g,""))),s.isArchived!=null&&(i.is_archived=s.isArchived),s.isDeleted!=null&&(i.is_deleted=s.isDeleted),"snoozedUntil"in s&&(i.snoozed_until=s.snoozedUntil!=null?s.snoozedUntil.toISOString():null,i.is_snooze_notification_sent=!1,s.snoozedUntil==null&&(i.snoozed_by=null,i.snoozed_at=null)),i},pY=(s,i)=>{const{tagState:r}=s,t=i.tagIds.map((e=>X(r.tagByID,e))).filter((e=>e!=null)).map((e=>e.tagId));return{task_id:i.id,name:i.name,assignees:i.assignees,description:i.description,group_assignees:i.groupAssignees,is_archived:i.isArchived,is_deleted:i.isDeleted,snoozed_until:i.snoozedUntil!=null?i.snoozedUntil.toISOString():null,due_date:i.dueDate!=null?i.dueDate.format(re):null,priority:i.priority.code,status:i.status.code,tags:t,type:i.type.code,file_ids:i.fileIds,recurring_end_date:i.recurringEndDate!=null?i.recurringEndDate.format(re):null,recurring_frequency:i.recurringFrequency??null,recurring_start_date:i.recurringStartDate!=null?i.recurringStartDate.format(re):null,task_group_ids:i.taskGroupIds,time_spent:so(i.timeSpent)}},mY=s=>({transaction_id:s.id}),yY=(s,i,r,t,e,a,n,o,c)=>{const d=Object.assign({},i);if(d.memo=s.memo??"",d.documentId=s.documentId??d.documentId,o!=null&&o.length>0){const m=new Set(o);d.lines=d.lines?.filter((h=>!m.has(h.id)))}const l={};for(const m in s.updatesByLineId){const h=s.updatesByLineId[m],g=d.lines?.map((I=>{if(I.id===m){const b=Object.assign({},I);if(b.lineDescription=h.lineDescription??"",h.amount!=null&&(b.amount=h.amount),h.class!=null&&(b.class=h.class),h.account!=null&&(b.account=h.account),h.project!=null&&(b.project=h.project),h.customer!=null?b.customer=h.customer:b.customer=void 0,h.vendor!=null?b.vendor=h.vendor:b.vendor=void 0,h.postingType!=null){const P=b;P.postingType=h.postingType,h.postingTypeName!=null&&(P.postingTypeName=h.postingTypeName)}h.recommendation!=null&&(l[I.id]=h.recommendation);const E=r?.find((P=>P.lineId===I.id));return E&&(b.cotViewingFlags={vendor:E.vendor,category:E.category,class:E.class,lineId:E.lineId}),b}return I}));d.lines=g}if(c!=null&&c.length>0){const m=c.map(hY);d.lines=[...d.lines??[],...m]}let u;return d.recommendations=l,E0(d)?(u=P0(d),!t||d.type!=="invoice"&&d.type!=="credit_memo"||s.project==null||(u={...u,accounting_project_id:s.project.projectId,...s.project.accountingProviderProjectId!=null?{accounting_project_integration_id:s.project.accountingProviderProjectId}:{},...s.project.projectName?{accounting_project_name:s.project.projectName}:{}})):u=as(d)?n!=null&&n.type==="customer"?T0(d,a):A0(d,e):N0(d)?O0(d):C0(d),x0(u,d)},_Y=(s,i,r,t)=>{if(!t&&(as(s)||Hn(s.type)!=null)){const e=(s.lines??[]).filter((a=>a.type==="transaction_with_account_and_class_line"||a.type==="journal_entry_transaction_line"||a.type==="transaction_with_product_or_service_line"));if(r&&e.some((a=>(a.class?.classId??"")==="")))return[];if(Hn(s.type)!=null&&e.some((a=>{const n=a;return n.vendor==null&&n.customer==null})))return[]}return(s.lines??[]).filter((e=>{if(e.type!=="transaction_with_account_and_class_line"&&e.type!=="journal_entry_transaction_line"&&e.type!=="transaction_with_product_or_service_line")return!1;const a=e,n=!f0(i,a.account?.qboId),o=!r||(a.class?.classId??"")!=="",c=(a.amount?.amount??0)!==0,d=!(e.type==="journal_entry_transaction_line"||Hn(s.type)!=null)||a.vendor!=null||a.customer!=null;return n&&o&&c&&d})).map((e=>e.id)).filter(Boolean)},m0={accountDescription:"",accountId:"",accountName:"",labels:[]},hY=s=>s.type==="journal_entry_transaction_line"?{...s,id:"",type:"journal_entry_transaction_line",platformLineDetailType:s.platformLineDetailType??"journal_entry_line_detail",account:s.account??m0,billable:s.billable??"not_billable",isCategoryMiscategorized:!1,isClassMiscategorized:!1,lineTransactionType:s.lineTransactionType??"journal_entry",postingType:s.postingType??"debit",postingTypeName:s.postingTypeName!=null&&s.postingTypeName!==""?s.postingTypeName:(s.postingType??"debit").charAt(0).toUpperCase()+(s.postingType??"debit").slice(1)}:{...s,id:"",type:"transaction_with_account_and_class_line",platformLineDetailType:s.platformLineDetailType??"account_based_expense_line_detail",account:s.account??m0,billable:s.billable??"not_billable",isCategoryMiscategorized:!1,isClassMiscategorized:!1},SY=s=>{const i=[];let r;for(r in s){const t=s[r],e={recommendations:U0(t.recommendations),entity_id:t.entityId,entity_type:t.entityType,is_bulk_update:t.isBulkUpdate,updated_entity_id:t.updatedEntityId};t.entityType==="vendor"&&t.vendorName!=null&&(e.vendor_name=t.vendorName),i.push(e)}return i};function y0(s){let i=ee(ae(s.start));const r=ee(ae(s.end));i=i.set("date",1);const t=Math.ceil(r.diff(i,"month",!0)),e=[];if(t>0||t==0){let a=i.clone().set("date",1);for(let n=0;n<t-1;++n){const o=a.daysInMonth(),c={day:1,month:a.month()+1,year:a.year()},d={day:o,month:a.month()+1,year:a.year()};e.push({start:c,end:d}),a=a.add(1,"month")}e.push({start:{day:a.date(),month:a.month()+1,year:a.year()},end:{day:r.date(),month:r.month()+1,year:r.year()}})}else console.error(`Invalid time period ${JSON.stringify(s)}`);return e}const gY=(s,i)=>{const r=[],t={startDate:ee(i.data?.report.data_available_start_date),endDate:ee(i.data?.report.data_available_end_date)};return r.push(kj(s.zeniId,i.data?.report.expense)),r.push(Bj({id:s.id,name:s.name},t,i.data?.report.expense,i.data?.report.insights)),r.push(j0(t)),r},fY=(s,i)=>{const r=[],t={startDate:ee(i.data?.report.data_available_start_date),endDate:ee(i.data?.report.data_available_end_date)};return r.push(Dj(s,t,i.data?.report.income,i.data?.report.insights)),r.push(j0(t)),r},vY=s=>[...s].sort(((i,r)=>(i.create_time!=null?ee(i.create_time):me()).isBefore(r.create_time!=null?ee(r.create_time):me())?1:-1))?.[0],IY=(s,i)=>{switch(s){case"manager":return{is_manager_candidate:!0};case"cardHolderCandidate":return{is_card_holder_candidate:!0,is_include_cards_count:!0};case"taskManagerCandidate":return{is_task_manager_candidate:!0};case"cardAdmin":return{is_card_admin_candidate:!0};default:return{is_zeni:i}}},bY=s=>{if(s==="vendorsTab")return"vendor_list"},EY=s=>{switch(s){case"updateTo":return"recommended_global_merchant_name";case"status":return"status";case"ytd":return"year_to_date_spend";default:return"vendor_name"}},Fn=s=>s.map((i=>PY(i))),PY=s=>({vendor_id:s.vendor_id,vendor_name:s.vendor_name,logo:s.logo,qbo_id:s.qbo_id,currency_code:s.currency_code,currency_symbol:s.currency_symbol,transaction_attachments:s.transaction_attachments}),qn=s=>{const i=[];return s.forEach((r=>{r.last_updated_vendor_name_by_user!=null&&i.push(Q0(r.last_updated_vendor_name_by_user))})),i},jn=s=>{const i=[];return s.forEach((r=>{const t=r.recommendations[0]?.global_merchants.filter((e=>e.global_merchant_id!=null));TY(t,i)})),i},TY=(s,i)=>{s.forEach((r=>i.push(r)))},AY=(s,i,r,t,e,a,n)=>{const o=n?.globalMerchantId!=null?ts(ql(n),["create_time","update_time"]):n!=null?ts(W0(n),["create_time","update_time"]):null;return{vendor_name:s,qbo_id:a??null,selected_global_merchant:t===!0?null:o,recommendations:Xn(i,r),is_employee:t,is_local_contractor:e}},NY=(s,i,r)=>{const t=Array({globalMerchants:Qn(i,s.recommendationIds)}),e=Array({globalMerchants:s.recommendedNonExistingGlobalMerchants});let a=Ll(i,s.selectedVendorId);e.length>0&&s.selectedVendorId===e[0].globalMerchants[0]?.globalMerchantName&&(a=e[0].globalMerchants[0]);const n=Oe(r,s.selectedVendorId);let o="";if(s.vendorRenamedText!=null)o=s.vendorRenamedText;else if(n!=null)o=n.name;else{const c=Ll(i,s.selectedVendorId);o=c!=null?c?.globalMerchantName:e[0]?.globalMerchants[0]?.globalMerchantName??""}return{vendorName:o,selectedGlobalMerchant:a,recommendations:t,nonExistingRecommendations:e}},OY=(s,i,r,t,e)=>({tenant_name:s.tenantName,merchant_type:"vendor",tenant_id:s.tenantId,selected_global_merchant:t!=null?ts(ql(t),["create_time","update_time"]):e!=null?lG(e):null,recommendations:i,merchant_name:r}),CY=s=>{const i=[];return s.forEach((r=>{r.last_updated_merchant_name_by_user!=null&&i.push(Q0(r.last_updated_merchant_name_by_user))})),i},xY=s=>{let i=[];return s.forEach((r=>{i=[...new Set([...i,...Z0(r.recommendations)])]})),i},UY=s=>{switch(s){case"originalVendor":return"original_vendor";case"requestedVendor":return"requested_vendor";case"recommended":return"recommended_global_merchant_name";default:return"tenant_name"}},kY=(s,i)=>({tenant_name:s.tenantName,merchant_type:"vendor",tenant_id:s.tenantId,review_status:"review_rejected",recommendations:i,merchant_name:s.tenantMerchantName}),Jl=s=>N({messageSection:"oauth_consent_approve",messageText:"failed",type:"error",variables:[{variableName:"__reason__",variableValue:s}]}),BY=[(s,i,r)=>s.pipe(S(WR.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_bill_pay_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),av()];return _(n)}return p(_n(a.status),N({messageSection:"bill_pay_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(_n(f("Unexpected Error","Accept Bill Pay Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(ZR.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_unit_migration_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),av()];return _(n)}return p(_n(a.status),N({messageSection:"bill_pay_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(_n(f("Unexpected Error","Accept Bill Pay Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(NV.match),y((t=>{const{companyId:e,enableChargeCard:a,chargeCardSetupViewType:n,isEarlyPayEnabled:o,isCompanyInterestedInChargeCard:c}=t.payload;let d;switch(n){case"charge_cards":d={is_charge_cards_tos_accepted:!0,...a&&{is_charge_cards_enabled:!0,...o&&{is_auto_pay_enabled:!0}}};break;case"charge_cards__debit_cards":d={is_charge_cards_tos_accepted:!0,is_debit_cards_tos_accepted:!0,...a&&{is_charge_cards_enabled:!0,is_debit_cards_enabled:!0,...o&&{is_auto_pay_enabled:!0}}};break;case"debit_cards":d={is_debit_cards_tos_accepted:!0,...a&&{is_debit_cards_enabled:!0},...c&&{is_company_interested_in_charge_card:!0}};break;default:d={}}return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,d).pipe(y((l=>{if(M(l)&&l.data!=null){const u=[V({users:l.data.users}),Y(l.data.user_roles),Q({payload:l.data.companies,schema:{}}),OV()];return _(u)}return p(qv(l.status),N({messageSection:"charge_card_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))})),v((l=>p(qv(f("Unexpected Error","Accept Charge Card Terms errored out"+JSON.stringify(l)))))))}))),(s,i,r)=>s.pipe(S(nF.match),y((t=>{const{userRoleId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/${e}`,{is_reimbursement_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[oF(a.data.user_roles[0]),UI()];return _(n)}return p(On(a.status),N({messageSection:"reimbursement_accept_employee_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(On(f("Unexpected Error","Accept Employee Remi Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(nB.match),y((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/config`;return r.putAndGetJSON(t,{is_invoicing_tos_accepted:!0}).pipe(A((e=>T(e)&&e.data!=null?p(Ni(e.data),oB(),Vt()):p(oh(e.status)))),v((e=>p(oh(f("Unexpected Error","Accept invoicing terms REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(eT.match),y((t=>{const{userRoleId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/${e}`,{is_master_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[Y(a.data.user_roles),tT(a.data.user_roles[0]),aT()];return _(n)}return p(Tu(a.status))})),v((a=>p(Tu(f("Unexpected Error","Accept Master TOS errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(iF.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_reimbursement_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),UI()];return _(n)}return p(On(a.status),N({messageSection:"reimbursement_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(On(f("Unexpected Error","Accept Remi Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(hF.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_treasury_accounts_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),SF()];return _(n)}return p(wI(a.status),N({messageSection:"treasury_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(wI(f("Unexpected Error","Accept Treasury Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(jF.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_deposit_accounts_tos_accepted:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),GF()];return _(n)}return p(WI(a.status),N({messageSection:"zeni_account_accept_term",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(WI(f("Unexpected Error","Accept Zeni Account Terms errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(sJ.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_onboarding_ai_activation_viewed:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[Q({payload:a.data.companies,schema:{}}),nJ()];return _(n)}return p(BS(a.status))})),v((a=>p(BS(f("Unexpected Error","Acknowledge - Onboarding AI Activation Viewed errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(oJ.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_onboarding_ai_finance_team_acknowledged:!0}).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[Q({payload:a.data.companies,schema:{}}),iJ()];return _(n)}return p(N({messageSection:"onboarding_customer_view_complete",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}),DS(a.status))})),v((a=>p(DS(f("Unexpected Error","Acknowledge - Onboarding AI Finance Team errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(OA.match),y((t=>{const{type:e,paymentSourceType:a,setupIntentId:n}=t.payload,o={...fz({type:e,processor_token:n,payment_source_type:a})};return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/payment-sources`,o).pipe(y((c=>T(c)&&c.data?_([vo({fetchState:"Completed",paymentSources:c.data.payment_sources}),N({messageSection:"add_card_payment_source",messageText:"success",type:"success"}),Io()]):_([vo({fetchState:"Error",error:c.status}),N({messageSection:"add_card_payment_source",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"Card could not be linked!"}]})]))),v((c=>p(vo({fetchState:"Error",error:f("Unexpected Error","Add Card Payment Source API call errored out "+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(bk.match),y((t=>{const{amount:e,currencyCode:a,customerId:n,description:o}=t.payload,c=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(n)}/promotional-credits`,d={amount:e,description:o};return a!=null&&a!==""&&(d.currency_code=a),r.postAndGetJSON(c,d).pipe(y((l=>T(l)&&l.data!=null?[Ek(),Ys({id:n})]:p(R_(l.status)))),v((l=>p(R_(f("Unexpected Error","Add promotional credits REST API call errored out "+JSON.stringify(l)))))))}))),(s,i)=>s.pipe(y((r=>{if(!no.match(r))return F;const t=i.value,e=t.cardPolicyState.policyDocumentExtraction,a=e.extractedRules;if(a==null)return F;const n=(l=>({allowedEntity:{categoryCodes:l.allowedEntity.categoryCodes??[],merchantNames:l.allowedEntity.merchantNames??[]},blockedEntity:{categoryCodes:l.blockedEntity.categoryCodes??[],merchantNames:l.blockedEntity.merchantNames??[]},confidenceScore:l.confidenceScore,policyName:l.policyName,requiredReceiptThreshold:l.requiredReceiptThreshold,transactionLimit:l.transactionLimit}))(a),o=(l=>l.cardPolicyState.vendorSearch.vendors.map((u=>fM(u.name,!1))))(t),c=(l=>l.cardPolicyState.mccCategories.map((u=>vM(IM(u),!1))))(t),d={extracted:n,vendorSearchOptions:o,categorySearchOptions:c};return e.aiCfoAnswerId!=null?p(SM(d)):p(gM(d))}))),(s,i,r)=>s.pipe(S(PG.match),$t((t=>{const{userId:e,zeniSessionId:a,tenantId:n,clientId:o,redirectUri:c,codeChallenge:d,codeChallengeMethod:l,state:u,responseType:m}=t.payload,h={"zeni-user-id":e,"zeni-tenant-id":n};return a!=null&&(h["zeni-session-id"]=a),r.postJSON(`${r.apiEndPoints.authMicroServiceBaseUrl}/oauth/authorize/approve`,{client_id:o,redirect_uri:c,code_challenge:d,code_challenge_method:l,state:u,response_type:m,tenant_id:n},h).pipe(Oa((g=>_(g.json()).pipe(y((I=>{if(!g.ok){const P=I,O=P?.error??P?.message??P?.status?.message??`Authorization failed (${g.status})`;return _([hl(f(O)),Jl(O)])}const b=I,E=b?.redirect_url??b?.data?.redirect_url;if(E==null||E===""){const P="No redirect URL returned from authorization server";return _([hl(f(P)),Jl(P)])}return p(TG({redirectUrl:E}))}))))),v((g=>{const I="OAuth approve request failed: "+(g instanceof Error?g.message:JSON.stringify(g));return _([hl(f(I)),Jl(I)])})))}))),(s,i,r)=>s.pipe(S(CR.match),y((t=>{const{billId:e,approvalType:a,description:n}=t.payload,o={approval_status:a,is_include_entity_approval:!0,description:n};return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}/approval-status`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data.entity_approvals.map((l=>l.entity_approval_id));return _([V({users:c.data.users??[]}),Et(c.data?.entity_approvals),xR(e,d),N({messageSection:a==="approved"?"bill_pay_approved":"bill_pay_rejected",messageText:"success",type:"success"})])}return p(Cf(e,c.status),N({messageSection:"bill_pay_approved",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(Cf(e,f("Unexpected Error","Approve Or Reject Bill errored out"+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(XR.match),y((t=>{const{approvalType:e,description:a}=t.payload,{billsBulkActionViewState:n}=i.value,o=(function(c,d,l){const u=c.map((m=>({entity_id:m,request_data:{approval_status:d,is_include_entity_approval:!0,description:l??""}})));return{operation_type:d==="approved"?"approve":"reject",operations:u}})(n.billsSelectedForBulkAction,e,a);return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/bills/transactions`,o).pipe(y((c=>{if(M(c)){const d=[],l=c.data?.total_operations_processing??0;return d.push(Ic({billsProcessing:l,refreshTime:c.data?.hard_refresh_after_sec??0})),d.push(bc(c.data?.operations??[])),l>0&&d.push(N({messageSection:"bill_pay_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:l.toString()},{variableName:"_bill_",variableValue:l>1?"bills":"bill"},{variableName:"_action_",variableValue:e}]})),_(d)}return p(Fa(c.status),N({messageSection:"bill_pay_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(Fa(f("Unexpected Error","Bill bulk action REST API call errored out "+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(JL.match),y((t=>{const{reimbursementId:e,approvalType:a,description:n}=t.payload,o={approval_status:a,is_include_entity_approval:!0,description:n};return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${e}/approval-status`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data.entity_approvals.map((l=>l.entity_approval_id));return _([V({users:c.data.users??[]}),Et(c.data?.entity_approvals),wL(e,d),N({messageSection:a==="approved"?"reimbursement_approved":"reimbursement_rejected",messageText:"success",type:"success"})])}return p(yI(e,c.status),N({messageSection:a==="approved"?"reimbursement_approved":"reimbursement_rejected",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(yI(e,f("Unexpected Error","Approve Or Reject Reimbursement errored out"+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(cF.match),y((t=>{const{approvalType:e,description:a}=t.payload,{remisBulkActionViewState:n}=i.value,o=(function(c,d,l){const u=c.map((m=>({entity_id:m,request_data:{approval_status:d,is_include_entity_approval:!0,description:l??""}})));return{operation_type:d==="approved"?"approve":"reject",operations:u}})(n.remisSelectedForBulkAction,e,a);return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/reimbursements/transactions`,o).pipe(y((c=>{if(M(c)){const d=[],l=c.data?.total_operations_processing??0;return d.push(xd({remisProcessing:l,refreshTime:c.data?.hard_refresh_after_sec??0})),d.push(Ud(c.data?.operations??[])),l>0&&d.push(N({messageSection:"reimbursement_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:l.toString()},{variableName:"_report_",variableValue:l>1?"reports":"report"},{variableName:"_action_",variableValue:e}]})),_(d)}return p(Ga(c.status),N({messageSection:"reimbursement_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(Ga(f("Unexpected Error","Remi Approve or Reject bulk action REST API call errored out "+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(iG.match),y((t=>{const{merchantId:e}=t.payload,{globalMerchantState:a,vendorGlobalReviewViewState:n}=i.value,{vendorGlobalByMerchantId:o}=n,c=cG(i.value).vendorGlobalReviewData.find((g=>g.merchant.tenantMerchantId===e)),d=o[e].vendorGlobalReviewViewLocalData,l=d!=null&&d.selectedMerchantId!=null?Ll(a,d.selectedMerchantId):void 0;let u,m=l?.globalMerchantName;const h=yE(a,_E(d.tenantId,e));if(m!=null||d.currentSelection!=="recommendedFirst"&&d.currentSelection!=="recommendedSecond"||(d.currentSelection==="recommendedFirst"?(m=c?.recommendations[0].globalMerchantName,u=c?.recommendations[0]):d.currentSelection==="recommendedSecond"&&(m=c?.recommendations[1].globalMerchantName,u=c?.recommendations[1])),d!=null&&m!=null&&h!=null){const g=Array({globalMerchants:Qn(a,d.recommendationIds)}),I=Array({globalMerchants:d.recommendedNonExistingGlobalMerchants}),b=Xn(g,I),E={...OY(h,b,m,l,u)};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/reviews/global-merchant-list/${e}`,E).pipe(y((P=>{const O=h.tenantMerchantName===m;if(M(P)&&m!=null){const C=O?[{variableName:"_merchant_name_",variableValue:m}]:[{variableName:"_original_merchant_name_",variableValue:h.tenantMerchantName},{variableName:"_approved_merchant_name_",variableValue:m}],U=[dG(e),N({messageSection:O?"approve_original_merchant":"approve_global_merchant",messageText:"success",type:"success",variables:C})];return _(U)}return P.status.code===409?p(ml({merchantId:e,status:P.status})):p(ml({merchantId:e,status:P.status}),N({messageSection:O?"approve_original_merchant":"approve_global_merchant",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:P.status.message}]}))})),v((P=>p(ml({merchantId:e,status:f("Unexpected Error","Approve Vendor Global Review REST API call errored out"+JSON.stringify(P))})))))}return p([])}))),(s,i,r)=>s.pipe(S(lM.match),y((t=>{const e=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${e}`).pipe(y((a=>{if(M(a)){const n=[uM(e),Vc({fetchState:"Completed",templateId:e})];return _(n)}return p(Vc({fetchState:"Error",error:a.status,templateId:e}))})),v((a=>p(Vc({fetchState:"Error",error:f("Unexpected Error","Archive card-policy REST API call errored out"+JSON.stringify(a)),templateId:e})))))}))),(s,i,r)=>s.pipe(S(gq.match),y((t=>tY(t.payload.taskId,i,r)))),(s,i,r)=>s.pipe(S(My.match),A((t=>{const{period:e}=t.payload,a=i.value,n=H(a),o=a.expenseAutomationViewState.selectedPeriodByTenantId[n.tenantId],c=a.expenseAutomationTransactionsViewState.transactionCategorizationView.review.uiState,d=c.pageToken,l=u=>{const m={start_date:ae(e.start),end_date:ae(e.end),auto_categorized:!1,sort_by:ui(c.sortKey),sort_order:c.sortOrder==="ascending"?"asc":"desc",page_token:u,page_size:25,search_text:c.searchString,transaction_group:a.expenseAutomationTransactionsViewState.selectedTransactionGroup};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(m))}`)};return l(null).pipe(Jx((u=>{if(!T(u)||u.data==null)return F;const m=u.data.next_page_token??null;return m==null||m===d?F:l(m)})),wx(((u,m)=>{if(!T(m)||m.data==null)return{...u,failureStatus:m.status};const h=m.data.next_page_token??null;return{...u,allTransactions:[...u.allTransactions,...m.data.transactions],finalPageToken:h,finalStatus:m.status,totalCount:m.data.total_count}}),{allTransactions:[],failureStatus:null,finalPageToken:null,finalStatus:null,totalCount:0}),y((u=>{if(u.failureStatus!=null||u.finalStatus==null)return p(ws({selectedPeriod:o,selectedTab:Ya,status:u.failureStatus??f("Unexpected Error","background refetch review tab received error response")}));const m=u.allTransactions.map((g=>g.transaction_id)),h=Vy(u.allTransactions);return _([Ce(u.allTransactions,(g=>g.transaction_id),"merge"),Ly({selectedTab:Ya,uiState:{pageToken:u.finalPageToken}}),mi(Ya,m,o,!1,u.finalPageToken,u.totalCount,h,!0),$s({selectedPeriod:o,selectedTab:Ya,totalCount:u.totalCount}),Fy({refreshViewInBackground:!0,selectedTab:Ya,status:u.finalStatus})])})),v((u=>p(ws({selectedPeriod:o,selectedTab:Ya,status:f("Unexpected Error","background refetch review tab REST API call errored out"+JSON.stringify(u))})))))}))),(s,i,r)=>s.pipe(S(rl.match),A((t=>{const{taskIds:e,updates:a,groupId:n}=t.payload,o=uY(a);n!=null&&(o.task_group_ids=[n]);const c={task_ids:e,updates:o};return r.putAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/bulk-update`,c).pipe(y((d=>{if(T(d)&&d.data!=null){const l=a.isArchived===!0||a.isDeleted===!0||"snoozedUntil"in a;return p(ze(d.data.tasks),xb({taskIds:e,groupId:n,removeFromList:l}),Nt())}return p(Ub({error:d.status}))})),v((d=>p(Ub({error:f("Unexpected Error","Bulk update task list REST API call errored out"+JSON.stringify(d))})))))}))),(s,i)=>s.pipe(S((r=>Er.match(r)||Na.match(r))),y((r=>{const{batchId:t}=r.payload;return Ha(Dx).pipe(y((()=>{const e=i.value.expenseAutomationMissingReceiptsViewState.bulkUpload;return e.phase!=="matching"||e.currentBatchId!==t?F:_([Ry(t),Pr({cacheOverride:!0}),ci()])})),De(vt(s.pipe(S(Ds.match)),s.pipe(S(pi.match),S((e=>e.payload.batchId===t&&e.payload.status==="completed"))),s.pipe(S(Aa.match),S((e=>e.payload.batchId===t))))))}))),s=>s.pipe(S((i=>Er.match(i)||Na.match(i))),A((i=>{const{batchId:r}=i.payload;return vt(s.pipe(S(Aa.match)),s.pipe(S(Gn.match))).pipe(S((t=>t.payload.batchId===r)),Ue(1),y((t=>{const{summary:e}=t.payload;return p(N({messageSection:"receipts_bulk_match",messageText:"success",type:"success",variables:[{variableName:"_matched_",variableValue:String(e.matched)},{variableName:"_total_",variableValue:String(e.total)}]}))})),De(s.pipe(S(Ds.match))))}))),(s,i,r)=>s.pipe(S(yx.match),A((t=>{const{files:e}=t.payload,a=new FormData;for(const n of e)a.append("files",n,n.name);return r.postFormData(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`,a).pipe(y((n=>{if(T(n)&&n.data!=null){const o=String(n.data.batch_id??"").trim();return o===""?p(ii({error:f("Unexpected Error","Bulk upload succeeded but batch_id was missing or empty.")})):j(p(hx(100)),Ha(_x).pipe(y((()=>p(Er({batchId:o}))))))}return p(ii({error:n.status}))})),v((n=>p(ii({error:f("Unexpected Error","Bulk upload receipts API call errored out: "+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(LP.match),y((t=>{const{tenantId:e,companyId:a}=t.payload,n=`${`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`}/ai-accountant/cancel-onboarding`;return r.postAndGetJSON(n,{tenant_id:e,company_id:a}).pipe(y((o=>T(o)?_([FP(e),uo(),N({messageSection:"common",messageText:"success",type:"success"})]):_([vu(e,o.status),N({messageSection:"common",messageText:"failed",type:"error"})]))),v((o=>_([vu(e,f("Unexpected error","AI Accountant cancel onboarding failed: "+JSON.stringify(o))),N({messageSection:"common",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(UR.match),y((t=>{const e={bill_pay_provider:"zeni",is_delete_bill:t.payload.isDeleteBill},{billTransactionState:a}=i.value,n=a.transactionById[t.payload.billId],o=n?.isRecurring??!1,c=n?.recurringBillConfigId;let d=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${t.payload.billId}`;return d=o===!0?`${d}/recurring/cancel-payment`:`${d}/cancel-payment`,r.putAndGetJSON(d,e).pipe(y((l=>{if(t.payload.isDeleteBill===!0&&M(l)){const u=[];return u.push(pn("Completed",t.payload.billId,t.payload.isDeleteBill)),n!=null&&u.push(xf({billId:t.payload.billId,tab:n.billPayInfo.stage.code})),u.push(lc(Ne(t.payload.billId))),o===!0&&c!=null&&u.push(Uf(c)),u.push(N({messageSection:"bill_pay_cancelled_deleted",messageText:"success",type:"success"})),_(u)}return T(l)&&l.data!=null&&l.data.transactions[0]?.transaction_id!=null?p(mn(l.data.transactions[0]),pn("Completed",t.payload.billId,t.payload.isDeleteBill),N({messageSection:"bill_pay_cancelled",messageText:"success",type:"success"})):p(pn("Error",t.payload.billId,t.payload.isDeleteBill,l.status),N({messageSection:"bill_pay_cancelled_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))})),v((l=>p(pn("Error",t.payload.billId,t.payload.isDeleteBill,f("Unexpected Error","Cancel and Delete bill REST API call errored out "+JSON.stringify(l)))))))}))),(s,i,r)=>s.pipe(S($L.match),y((t=>{const e={reimbursement_provider:"zeni",is_delete_reimbursement:t.payload.isDeleteRemi},{reimbursementState:a}=i.value,n=a.reimbursementById[t.payload.reimbursementId];return r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${t.payload.reimbursementId}/cancel-payment`,e).pipe(y((o=>{if(t.payload.isDeleteRemi===!0&&M(o)){const c=[An("Completed",t.payload.reimbursementId,t.payload.isDeleteRemi)];return n!=null&&c.push(_I({remiId:t.payload.reimbursementId,tab:n.reimbursementInfo.stage.code})),c.push(Pd(t.payload.reimbursementId)),c.push(N({messageSection:"reimbursement_cancelled_deleted",messageText:"success",type:"success"})),_(c)}return T(o)&&o.data!=null&&o.data?.transaction?.transaction_id!=null?p(bd(o.data.transaction),An("Completed",t.payload.reimbursementId,t.payload.isDeleteRemi),N({messageSection:"reimbursement_cancelled",messageText:"success",type:"success"})):p(An("Error",t.payload.reimbursementId,t.payload.isDeleteRemi,o.status),N({messageSection:"reimbursement_cancelled",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:o.status.message}]}))})),v((o=>p(An("Error",t.payload.reimbursementId,t.payload.isDeleteRemi,f("Unexpected Error","Cancel and Delete reimbursement REST API call errored out "+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(e1.match),y((t=>{const{operationType:e,description:a}=t.payload,{billsBulkActionViewState:n}=i.value,o=(function(d,l,u){const m=d.map((h=>({entity_id:h,request_data:{bill_pay_provider:"zeni",description:u}})));return{operation_type:l,operations:m}})(n.billsSelectedForBulkAction,e,a),c=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/bills/transactions`;return(e==="cancel"?r.putAndGetJSON(c,o):r.deleteAndGetJSON(c,o)).pipe(y((d=>{if(M(d)){const l=[],u=d.data?.total_operations_processing??0;return l.push(Ic({billsProcessing:u,refreshTime:d.data?.hard_refresh_after_sec??0})),l.push(bc(d.data?.operations??[])),u>0&&l.push(N({messageSection:"bill_pay_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:u.toString()},{variableName:"_bill_",variableValue:u>1?"bills":"bill"},{variableName:"_action_",variableValue:e==="cancel"?"canceled":"deleted"}]})),_(l)}return p(Fa(d.status),N({messageSection:"bill_pay_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(Fa(f("Unexpected Error","Bill bulk action REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(dF.match),y((t=>{const{operationType:e,description:a}=t.payload,{remisBulkActionViewState:n}=i.value,o=(function(d,l,u){const m=d.map((h=>({entity_id:h,request_data:{reimbursement_provider:"zeni",description:u}})));return{operation_type:l,operations:m}})(n.remisSelectedForBulkAction,e,a),c=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/reimbursements/transactions`;return(e==="cancel"?r.putAndGetJSON(c,o):r.deleteAndGetJSON(c,o)).pipe(y((d=>{if(M(d)){const l=[],u=d.data?.total_operations_processing??0;return l.push(xd({remisProcessing:u,refreshTime:d.data?.hard_refresh_after_sec??0})),l.push(Ud(d.data?.operations??[])),u>0&&l.push(N({messageSection:"reimbursement_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:u.toString()},{variableName:"_report_",variableValue:u>1?"reports":"report"},{variableName:"_action_",variableValue:e==="cancel"?"canceled":"deleted"}]})),_(l)}return p(Ga(d.status),N({messageSection:"reimbursement_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(Ga(f("Unexpected Error","Remi Cancel or Delete bulk action REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(_$.match),y((t=>{const e=i.value,{scheduleAccruedDetailState:a}=e,{rowId:n,scheduleType:o}=t.payload,c=[],d=a.selectedJEAccruedScheduleKey;if(d==null)return _(c);const l=sa(d,e);if(l==null)return _(c);const u=l.jeScheduleId,m=e.scheduleAccruedDetailState.editScheduleStateByDetailId[u],h=m?.selectedVendor?.name??"",g={...TK(e,m,d,n)},I={je_schedule_type:o};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${u}?query=${encodeURIComponent(JSON.stringify(I))}`,g).pipe(y((b=>{if(T(b)&&b.data!=null){const E=b.data.je_schedules[0].je_schedule_id;return c.push(ca(b.data.je_schedules),br(b.data.je_schedules,b.data.scheduled_journal_entries),Hi("Completed"),Va(o,d,E),N({messageSection:"cancel_journal_entry",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:h}]})),_(c)}return c.push(Hi("Error",b.status)),c.push(N({messageSection:"cancel_journal_entry",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:b.status.message}]})),_(c)})),v((b=>_([N({messageSection:"cancel_journal_entry",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(b)}]}),Hi("Error",f("Unexpected Error",`Cancel Accrual for Schedule Accrued Detail REST API call errored out ${JSON.stringify(b)}`))]))))}))),(s,i,r)=>s.pipe(S(zJ.match),y((t=>{const{localData:e,person:a}=i.value.peopleState.personDetails,{userId:n,userRole:o}=a,c=KJ(e[0].role,o.userRoles,n);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${t.payload.companyId}`,{users:c}).pipe(y((d=>{if(T(d)){const l=[];return d.data?.user_roles&&Vn(l,d.data?.user_roles[0],!0),p(Y(d.data.user_roles),YJ(),N({messageSection:"people_update_person",messageText:"success",type:"success"}),...l)}return p(cg(d.status))})),v((d=>p(cg(f("Unexpected error","Change zeni person roles REST API call errored out"+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(NF.match),A((()=>{const t=i.value,e=t.checkDepositState.localData,a=bm(t.fileState,e.fileIds),n=a.filter((d=>d.documentSide==="front"))[0],o=a.filter((d=>d.documentSide==="back"))[0],c={source_of_deposit:e.source,amount:e.amount.amount,currency_code:e.amount.currencyCode,currency_symbol:e.amount.currencySymbol,check_front_file_id:n?.fileId,check_back_file_id:o?.fileId};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e.depositTo?.id}/check-deposits`,c).pipe(y((d=>T(d)?p(N({messageSection:"deposit_check",messageText:"success",type:"success"}),Ld({fetchState:"Completed"})):p(Ld({fetchState:"Error",error:d.status})))),v((d=>p(Ld({fetchState:"Error",error:f("Unexpected Error","Check deposit REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(JM.match),A((t=>{const{chargeCardId:e,reason:a}=t.payload,n={reason:a},o=i.value.chargeCardState.chargeCardByID[e].accountLast4;return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/close`,n).pipe(y((c=>M(c)&&c.data!=null?p(st(c.data),qc({chargeCardId:e,fetchState:"Completed"}),N({messageSection:"close_charge_card",messageText:"success",type:"success",variables:[{variableName:"_masked_card_number_",variableValue:`•••• ${o}`}]})):p(N({messageSection:"close_charge_card",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}),qc({chargeCardId:e,fetchState:"Error",error:c.status})))),v((c=>p(N({messageSection:"close_charge_card",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(c)}]}),qc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Close card API call errored out"+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(aV.match),A((t=>{const{cardIds:e,reason:a}=t.payload,n={card_ids:e,reason:a};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/bulk/close`,n).pipe(y((o=>M(o)&&o.data!=null?p(qa(o.data),ad({fetchState:"Completed"}),N({messageSection:"close_charge_cards",messageText:"success",type:"success",variables:[{variableName:"_number_of_cards_",variableValue:e.length===1?"1 card":`${e.length} cards`}]})):p(N({messageSection:"close_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:o.status.message}]}),ad({fetchState:"Error",error:o.status})))),v((o=>p(N({messageSection:"close_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(o)}]}),ad({fetchState:"Error",error:f("Unexpected Error","Close cards API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(Lo.match),y((t=>sm(i.value.companyViewState.managementView,t.payload.companyId)!=null?p(nm(t.payload.companyId,{})):_([])))),(s,i,r)=>s.pipe(S(nm.match),y((t=>{const e=t.payload.companyId,a=sm(i.value.companyViewState.managementView,e),n=UN(e,i.value.companyViewState.managementView);if(a!=null&&Object.keys(a.data).length>0&&n==null){const o=Tz(a.data);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[];return i.value.companyViewState.managementView.fetchState==="Completed"&&(d.push(Q({payload:c.data.companies,schema:{},isUpdate:!0})),c.data.customer_satisfactions!=null&&d.push(om({payload:c.data.customer_satisfactions})),d.push(kN(e)),d.push(Lo(e))),i.value.reviewCompanyViewState.fetchState==="Completed"&&d.push(BN({companies:c.data.companies})),_(d)}{const d=[im(e,c.status),Lo(e)];return _(d)}})),v((c=>p(im(e,f("Unexpected error","Company Management save updates errored out"+JSON.stringify(c)))))))}return _([])}))),(s,i,r)=>s.pipe(S(Sx.match),$t((t=>{const{batchId:e,attachmentId:a,transactionId:n,transactionType:o,fileName:c}=t.payload;return r.postAndGetJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipts/manual-match`,{attachment_id:a,transaction_id:n,transaction_type:o,file_name:c}).pipe(y((d=>T(d)?_([gx({batchId:e,attachmentId:a,transactionId:n}),N({messageSection:"receipt_match",messageText:"success",type:"success"})]):_([Oy({error:d.status}),N({messageSection:"receipt_match",messageText:"failed",type:"error"})]))),v((d=>_([Oy({error:f("Unexpected Error","Confirm bulk upload match errored out: "+JSON.stringify(d))}),N({messageSection:"receipt_match",messageText:"failed",type:"error"})]))))}))),s=>s.pipe(S(CA.match),y((i=>{const{setupIntentData:r}=i.payload,{setupIntent:t,error:e}=r;if(t!=null&&e==null){const a={id:t.id,status:t.status,clientSecret:t.client_secret};return _([_p({fetchState:"Completed",setupIntentData:a})])}return _([_p({fetchState:"Error",error:e}),N({messageSection:"confirm_card_setup",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.message??"Unknown error"}]})])}))),(s,i,r)=>s.pipe(S(MO.match),$t((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n,accountMappings:o}=t.payload;return r.postAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements/${n}/confirm-mapping`,{account_mappings:o.map((c=>({ledger_identifier:c.ledgerIdentifier,account_id:c.accountId})))}).pipe(y((c=>{if(T(c)===!0&&c.data!=null)return p(VO({accountId:e,selectedPeriod:a,statementUploads:LO(c.data)}));const d=FO(c)?qO(c):null;return p(Fm({accountId:e,selectedPeriod:a,error:c.status,mappingConflict:d}),NE(c.status.message))})),v((c=>p(Fm({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Confirm Statement Mapping REST API call errored out "+(c instanceof Error?c.message:String(c)))}),NE()))))}))),(s,i,r)=>s.pipe(S(rD.match),y((t=>{const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/setup`,{api_key:a,publishable_key:n,webhook_secret:o}=t.payload,c={api_key:a,publishable_key:n,...o!=null&&o!==""?{webhook_secret:o}:{}};return r.postAndGetJSON(e,c).pipe(A((d=>T(d)&&d.data!=null?p(Xh({stripe_connected:d.data.stripe_connected,publishable_key:d.data.publishable_key}),Vt()):p(en(d.status)))),v((d=>p(en(f("Unexpected Error","Stripe connect setup REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(ya.match),y((t=>{const{cacheOverride:e,amount:a,conversionCurrencyCode:n,billId:o}=t.payload,c=i.value;let d=c.editBillDetailViewState.newBillState.billDetailLocalData;if(o!=null){const l=Ne(o);d=c.editBillDetailViewState.editBillStateById[l].billDetailLocalData}if(e===!0){const l={amount:{amount:a.amount,currency_code:a.currencyCode,currency_symbol:a.currencySymbol},home_currency_code:n};return r.postAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/currencies/conversion`,l).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[],h={amount:u.data.home_currency_conversions.amount,currency_code:u.data.home_currency_conversions.currency_code,currency_symbol:u.data.home_currency_conversions.currency_symbol},g=u.data.home_currency_conversions.exchange_rate;return m.push(sv({billId:o,amountPayload:h,conversionRate:g})),m.push(hn({billId:o,fetchState:"Completed",error:void 0})),_(m)}return p(hn({billId:o,fetchState:"Error",error:u.status}))})),v((u=>p(hn({billId:o,fetchState:"Error",error:f("Unexpected Error","Convert Amount To Home Currency REST API call errored out"+JSON.stringify(u))})))))}{const l=[];return l.push(sv({billId:o,amountPayload:{amount:(d.totalAmountAfterConversion?.amount??0)*(d.paymentDetailsSection?.conversionRate??1),currency_code:d.totalAmountAfterConversion?.currencyCode??"",currency_symbol:d.totalAmountAfterConversion?.currencySymbol??""},conversionRate:d.paymentDetailsSection?.conversionRate??0})),l.push(hn({billId:o,fetchState:"Completed",error:void 0})),_(l)}}))),(s,i,r)=>s.pipe(S(yu.match),y((t=>{const{addressType:e}=t.payload,a=i.value.addressViewState.newAddressState?.[e];if(a!=null){const n=xe(a.addressToCreate),o=e.includes("custom_shipping_")?`?query=${encodeURIComponent(JSON.stringify({is_default_namespace_sync_enabled:!0}))}`:"";return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/addresses${o}`,n).pipe(y((c=>{const d=c.data!=null?c.data?.addresses:[];if(T(c)&&d.length>0){const l=[z(d)];return l.push(lo({addressId:d[0].address_id,addressType:e})),_(l)}return p(da({addressType:e,status:c.status}))})),v((c=>p(da({addressType:e,status:f("Unexpected Error","Create Address REST API call errored out"+JSON.stringify(c))})))))}return[]}))),(s,i,r)=>s.pipe(S(SR.match),A((()=>{const t=a0(i.value.autotransferRulesState.ruleUpdateLocalData);return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto`,t).pipe(y((e=>{if(T(e)&&e.data!=null){const a=kl(e.data.auto_transfer_rule),n=[gR({rule:a}),N({messageSection:"auto_transfer_rule_create",messageText:"success",type:"success"})];return _(n)}return _([Ef({fetchState:"Error",error:e.status}),N({messageSection:"auto_transfer_rule_create",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.status.message}]})])})),v((e=>p(Ef({fetchState:"Error",error:f("Unexpected Error","Create auto transfer rule REST API call errored out "+JSON.stringify(e))})))))}))),(s,i,r)=>s.pipe(S(iA.match),A((t=>{const{bankAccountViewState:e,expressPayState:a}=i.value,{paymentMethodType:n,bankAccountContext:o,vendorId:c}=t.payload,d=e.createBankAccountDetails.localData;return d!=null?r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bank-accounts`,vl(d,n)).pipe(y((l=>{const u=[];return T(l)?(u.push(Je(l.data?.bank_accounts??[]),Ye({fetchState:"Completed",isInternationalBankAccount:!1})),o!=="vendor"&&o!=="billDetail"&&o!=="express-pay"||(u.push(sp({bankAccountIds:[l.data?.bank_accounts[0].bank_account_id??""],vendorId:c})),o==="billDetail"&&u.push(kt(c))),o==="express-pay"&&u.push(So({localData:{...a.formLocalData,amount:a.formLocalData?.amount??{amount:0,currencyCode:"USD",currencySymbol:"$"},paymentDate:a.formLocalData?.paymentDate??me(),paymentToAccountId:l.data?.bank_accounts[0].bank_account_id??""}})),l.data?.bank_accounts[0].bank_routing_number_ach!=null&&l.data?.bank_accounts[0].bank_routing_number_ach.length!==0?u.push(N({messageSection:"create_bank_account_ach",messageText:"success",type:"success"})):l.data?.bank_accounts[0].bank_routing_number_wire_transfer!=null&&l.data?.bank_accounts[0].bank_routing_number_wire_transfer.length!==0&&u.push(N({messageSection:"create_bank_account_wire",messageText:"success",type:"success",variables:[{variableName:"_wire-type_",variableValue:"Domestic"}]}))):l.status.code===409?(u.push(Je(l.data?.bank_accounts??[]),Ye({fetchState:"Error",error:l.status,isInternationalBankAccount:!1})),u.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]})),o!=="vendor"&&o!=="billDetail"&&o!=="express-pay"||(u.push(sp({bankAccountIds:[l.data?.bank_accounts[0].bank_account_id??""],vendorId:c})),o==="billDetail"&&u.push(kt(c)),o==="express-pay"&&u.push(So({localData:{...a.formLocalData,amount:a.formLocalData?.amount??{amount:0,currencyCode:"USD",currencySymbol:"$"},paymentDate:a.formLocalData?.paymentDate??me(),paymentToAccountId:l.data?.bank_accounts[0].bank_account_id??""}})))):(u.push(Ye({fetchState:"Error",error:l.status,isInternationalBankAccount:!1})),u.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))),_(u)})),v((l=>p(Ye({fetchState:"Error",error:f("Unexpected Error","Bank Account Creation REST API call errored out"+JSON.stringify(l)),isInternationalBankAccount:!1}))))):_([])}))),(s,i,r)=>s.pipe(S(bM.match),y((t=>{const e=EM(t.payload);return r.postAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`,e).pipe(y((a=>{if(M(a)&&a.data!=null){const{templates_created:n,errors:o}=a.data,c=n.map((m=>m.template)),d=c.map((m=>m.template_id)),l=d.length>0?[PM(d)]:[],u=[...c.map((m=>Rc(m))),...l,vn({fetchState:"Completed",perItemErrors:(o??[]).map(TM),templateIds:d})];return _(u)}return p(vn({fetchState:"Error",error:a.status}))})),v((a=>p(vn({fetchState:"Error",error:f("Unexpected Error","Create card-policy templates REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(xA.match),y((t=>{const{paymentsMethod:e}=t.payload,a={...vz(e)};return r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/stripe/cards/setup_intent`,a).pipe(y((n=>{if(T(n)&&n.data){const{client_secret:o}=n.data;return _([bo({fetchState:"Completed",clientSecret:o})])}return _([bo({fetchState:"Error",error:n.status}),N({messageSection:"create_card_setup",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]})])})),v((n=>p(bo({fetchState:"Error",error:f("Unexpected Error","Create Setup Intent REST API call errored out "+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(FF.match),A((t=>{const e={account_sub_type:"checking",account_name:t.payload.nickname};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts`,e).pipe(y((a=>T(a)?p(Qe(a.data?.deposit_accounts??[]),Qt({data:a.data?.deposit_accounts??[],updateType:"merge"}),N({messageSection:"create_checking_account",messageText:"success",type:"success"}),zd({fetchState:"Completed",accoutnId:a.data?.deposit_accounts[0].deposit_account_id})):p(N({messageSection:"create_checking_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}),zd({fetchState:"Error",accoutnId:void 0,error:a.status})))),v((a=>p(N({messageSection:"create_checking_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(a)}]}),zd({fetchState:"Error",accoutnId:void 0,error:f("Unexpected Error","Create deposit Account REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(_u.match),y((t=>{if(t.payload.addressType==="company_address"&&i.value.addressViewState.newAddressState?.company_address!=null){const e=t.payload.companyId,a=xe(i.value.addressViewState.newAddressState?.company_address.addressToCreate);return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/addresses`,a).pipe(y((n=>{const o=n.data!=null?n.data?.addresses:[];if(T(n)&&o.length>0){const c=n.data,d=[z(o)];return d.push(Q({payload:c?.companies??[],schema:{}})),d.push(lo({addressId:o[0].address_id,addressType:"company_address"})),_(d)}return p(da({addressType:"company_address",status:n.status}))})),v((n=>p(da({addressType:"company_address",status:f("Unexpected Error","Create Company Address REST API call errored out"+JSON.stringify(n))})))))}return[]}))),(s,i,r)=>s.pipe(S(cm.match),y((t=>{const{officers:e}=t.payload,a=e.map((d=>d.officerType)),n=t.payload.companyId,{newAddressState:o}=i.value.addressViewState,c={users:e.map((d=>{const l=Object.assign({},d,{isCompanyOfficer:!0});let u=$n(l);return u=Object.assign({},u,{is_changes_in_response_only:!1}),u}))};return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${n}/users`,c).pipe(y((d=>{const l=d.data?.users??[];if(T(d)&&l.length>0){const u=[V({users:l}),Q({payload:d.data?.companies??[],schema:{}}),Y(d.data?.user_roles??[])],m=e.map((h=>{const g=l.find((I=>I.email===h.email));return{...h,firstName:g?.first_name?.trim()??h.firstName,lastName:g?.last_name?.trim()??h.lastName,phone:g?.phone??"",userId:g?.user_id}}));return u.push(Fo({officers:m})),e.forEach((h=>{const{officerType:g}=h,I=l.find((P=>P.email===h.email)),b=g.toLowerCase().concat("_address");o?.[b]?.addressToCreate!=null&&u.push(ns({addressType:b,companyId:n,userId:I?.user_id}))})),u.push(DN({companyId:n,officerTypes:a})),_(u)}return p(dm({companyId:n,officerTypes:a,status:d.status}))})),v((d=>p(dm({companyId:n,officerTypes:a,status:f("Unexpected error",`Create Company Officers REST API call errored out ${JSON.stringify(d)}`)})))))}))),(s,i,r)=>s.pipe(S(hu.match),y((t=>{const e=t.payload.addressType,{newAddressState:a}=i.value.addressViewState,n=a?.[e]?.addressToCreate;if(e!=="company_address"&&n!=null){const o=t.payload.companyId,c=t.payload.userId,d={...xe(n),is_changes_in_response_only:!1};return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${o}/users/${c}/addresses`,d).pipe(y((l=>{const u=l.data!=null?l.data?.addresses:[];if(T(l)&&u.length>0){const m=l.data,h=[z(u)];return h.push(Q({payload:m?.companies??[],schema:{}}),V({users:m?.users??[]}),Y(m?.user_roles??[])),h.push(lo({addressId:u[0].address_id,addressType:e})),_(h)}return p(da({addressType:e,status:l.status}))})),v((l=>p(da({addressType:e,status:f("Unexpected Error","Create Company User Address REST API call errored out"+JSON.stringify(l))})))))}return[]}))),(s,i,r)=>s.pipe(S(AU.match),y((()=>{const{draft:t}=i.value.invoicingCreateCreditNoteState,e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/credits`,a=NU(t);return r.postAndGetJSON(e,a).pipe(y((n=>T(n)&&n.data!=null?[zs([n.data],"merge"),OU({creditNoteId:n.data.id}),N({messageSection:"invoicing_credit_note_saved",messageText:"success",type:"success"})]:_([p_(n.status),N({messageSection:"invoicing_credit_note_saved",messageText:"failed",type:"error",variables:Ie(n.status)})]))),v((n=>_([p_(f("Unexpected Error","Create credit note REST API call errored out "+JSON.stringify(n))),N({messageSection:"invoicing_credit_note_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(pU.match),y((t=>{const{context:e,merchantId:a}=t.payload,{newGlobalMerchantData:n,recommendationIds:o,recommendedNonExistingGlobalMerchants:c}=i.value.globalMerchantViewState,d=Array({globalMerchants:Qn(i.value.globalMerchantState,o)}),l=Array({globalMerchants:c}),u=Xn(d,l);if(n!=null){const m={...tK(n,u)};return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/global-merchants`,m).pipe(y((h=>{if(h.data!=null&&T(h)){const{global_merchants:g}=h.data,I=[It({globalMerchants:g,updateType:"merge"})],b=g[0].global_merchant_id;return e==="vendor_global_review"&&a!=null&&I.push(mU(a,b)),I.push(yU({merchantId:b}),N({messageSection:"create_global_merchant",messageText:"success",type:"success",variables:[{variableName:"_global_merchant_name_",variableValue:g[0].global_merchant_name}]})),_(I)}return p(r_({status:h.status}),N({messageSection:"create_global_merchant",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:h.status.message}]}))})),v((h=>p(r_({status:f("Unexpected Error","Create Global Merchant REST API call errored out"+JSON.stringify(h))})))))}return[]}))),(s,i,r)=>s.pipe(S(cA.match),A((t=>{const{bankAccountViewState:e,vendorViewState:a}=i.value,{bankAccountContext:n,vendorId:o}=t.payload,c=e.createInternationalBankAccountDetails.localData,d=o!=null?a?.editVendorStateById[o]?.vendorDetailLocalData?.countryCode:a.newVendorState.vendorDetailLocalData?.countryCode;return c!=null?r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-instruments`,((l,u)=>({...IE(l),country_code:u??""}))(c,d)).pipe(y((l=>{const u=[];return T(l)?(u.push(la(l.data?.payment_instruments??[]),Ye({fetchState:"Completed",isInternationalBankAccount:!0})),n!=="vendor"&&n!=="billDetail"&&n!=="express-pay"||(u.push(cs({paymentInstrumentIds:[l.data?.payment_instruments[0].zeni_payment_instrument_id??""],vendorId:o})),n==="billDetail"&&u.push(kt(o))),u.push(N({messageSection:"create_bank_account_international",messageText:"success",type:"success",variables:[{variableName:"_wire-type_",variableValue:"International"}]}))):l.status.code===409?(u.push(Ye({fetchState:"Error",error:l.status,isInternationalBankAccount:!0})),u.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]})),n!=="vendor"&&n!=="billDetail"&&n!=="express-pay"||(u.push(cs({paymentInstrumentIds:[l.data?.payment_instruments[0].zeni_payment_instrument_id??""],vendorId:o})),n==="billDetail"&&u.push(kt(o)))):(u.push(Ye({fetchState:"Error",error:l.status,isInternationalBankAccount:!0})),u.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))),_(u)})),v((l=>p(Ye({fetchState:"Error",error:f("Unexpected Error","Bank Account Creation REST API call errored out"+JSON.stringify(l)),isInternationalBankAccount:!0}))))):_([])}))),(s,i,r)=>s.pipe(S(CU.match),y((t=>{const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices`;return r.postAndGetJSON(e,{...t.payload}).pipe(y((a=>T(a)&&a.data!=null?[Ca([a.data],"merge"),z(Or([a.data])),xU({id:a.data.id,status:a.data.status}),UU({invoiceId:a.data.id}),N({messageSection:"invoicing_invoice_saved",messageText:"success",type:"success"})]:_([m_(a.status),N({messageSection:"invoicing_invoice_saved",messageText:"failed",type:"error",variables:Ie(a.status)})]))),v((a=>_([m_(f("Unexpected Error","Create invoice REST API call errored out "+JSON.stringify(a))),N({messageSection:"invoicing_invoice_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(BU.match),y((t=>{const{customerId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(e)}/payment-methods/setup-intent`;return r.postAndGetJSON(a,{}).pipe(A((n=>T(n)&&n.data!=null?p(DU(n.data)):p(y_(n.status)))),v((n=>p(y_(f("Unexpected Error","Setup intent REST API call errored out "+JSON.stringify(n)))))))}))),(s,i)=>s.pipe(S(g$.match),y((r=>{const t=[],e=r.payload.scheduleType,a=i.value,{scheduleAccruedDetailState:n}=a,o=n.newScheduleState,c=o.selectedVendor,d={scheduleType:e,jeScheduleDetails:CK(o,o?.estimatedMonthlyAmount??{amount:0,currencyCode:"USD",currencySymbol:"$"},o?.startingBalance??{amount:0},c?.name??"")};return t.push(cn({scheduleType:e,selectedJeScheduleDetailId:void 0,localData:d})),_(t)}))),(s,i)=>s.pipe(S(tf.match),y((r=>{const t=[],e=r.payload.scheduleType,a=i.value,{scheduleDetailState:n}=a,o=n.selectedJEScheduleKey;if(o!=null){const c=ft(o,a),d=c.baseTransaction.amount,l=c.vendor.name,u=c.jeScheduleId!=null?n.editScheduleStateByDetailId[e][c.jeScheduleId]:n.newScheduleState[e],m=u.scheduleType==="fixed_assets"?u.assetId:void 0,h={scheduleType:e,jeScheduleDetails:x$(u,d,l,e==="fixed_assets"?{assetId:m}:void 0)};t.push(un({scheduleType:e,selectedJeScheduleDetailId:c.jeScheduleId,localData:h}))}return _(t)}))),(s,i,r)=>s.pipe(S(Mq.match),A((t=>{const{groupName:e,updateSelectedTasks:a}=t.payload,n=i.value,{localData:o}=n.taskListState,c={name:e};return r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/groups`,c).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[Ab(d.data.task_groups[0]),Eb({newTaskGroupId:d.data.task_groups[0].task_group_id}),Vq({newTaskGroup:d.data.task_groups[0]}),N({messageSection:"task_group_creation_success",messageText:"success",type:"success"})];return a===!0&&l.push(rl(o.selectedTaskIds,d.data.task_groups[0].task_group_id,{taskGroupIds:[d.data.task_groups[0].task_group_id]})),_(l)}return p(Nb({fetchState:"Error",error:d.status}))})),v((d=>p(Nb({fetchState:"Error",error:f("Unexpected Error","Create Task Group REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(FC.match),y((t=>{const e=i.value,{localData:a}=t.payload,n=crypto.randomUUID(),o={...Fz(e,a),request_id:n},c=e.expenseAutomationViewState.selectedPeriodByTenantId[H(e).tenantId],d=c!=null?Re(c):void 0,l=d!=null?ge(d.start):void 0,u=d!=null?ge(d.end):void 0;return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals`,o).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[Ta([m.data.accrual]),qC(),N({messageSection:"create_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:a.vendorName}]})];return l!=null&&u!=null&&h.push(Qa({start:l,end:u},!0)),_(h)}return _([Iy({status:m.status}),N({messageSection:"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:m.status.message}]})])})),v((m=>_([N({messageSection:"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(m)}]}),Iy({status:f("Unexpected Error",`Create One Time Accrual REST API call errored out ${JSON.stringify(m)}`)})]))),De(s.pipe(S(gt.match))))}))),(s,i,r)=>s.pipe(S(k1.match),A((t=>{const{internationalWireState:e}=i.value,{bankAccountContext:a,vendorId:n}=t.payload,o=e.createInternationalWireDetails.localData;return o!=null?r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-instruments`,B1(o)).pipe(y((c=>{const d=[];return T(c)&&c.data!=null?(d.push(la(c.data.payment_instruments??[]),gn({fetchState:"Completed"})),a!=="vendor"&&a!=="billDetail"&&a!=="express-pay"||(d.push(cs({paymentInstrumentIds:[c.data.payment_instruments[0].zeni_payment_instrument_id??""],vendorId:n})),d.push(D1({countryCode:e.createInternationalWireDetails?.localData?.countryCode,currencyCode:e.createInternationalWireDetails?.localData?.currencyCode,vendorId:n})),a==="billDetail"&&d.push(kt(n))),d.push(N({messageSection:"create_bank_account_international",messageText:"success",type:"success",variables:[{variableName:"_wire-type_",variableValue:"International"}]}))):c.status.code===409?(d.push(gn({fetchState:"Error",error:c.status})),d.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]})),a!=="vendor"&&a!=="billDetail"&&a!=="express-pay"||(d.push(cs({paymentInstrumentIds:[c.data?.payment_instruments[0].zeni_payment_instrument_id??""],vendorId:n})),a==="billDetail"&&d.push(kt(n)))):(d.push(gn({fetchState:"Error",error:c.status})),d.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))),_(d)})),v((c=>p(gn({fetchState:"Error",error:f("Unexpected Error","Payment Instrument Creation REST API call errored out"+JSON.stringify(c))}))))):_([])}))),(s,i,r)=>s.pipe(S(rT.match),A((t=>{const{agentId:e,userId:a,questionAnswerId:n,questionId:o,createdAt:c,question:d,files:l,pageContext:u,macroId:m}=t.payload,h={agent_id:e,...u!=null&&{page_context:u}};return r.postAndGetJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions`,h).pipe(y((g=>{if(T(g)&&g.data!=null){const I=g.data,b=I.chat_session_id;return(function(E,P,O=5e3){return new cT((C=>{if(E==null)return console.warn("[createSessionAndSubmitEpic] ⚠️ Pusher not initialized, proceeding without waiting"),C.next({success:!1,error:"Pusher not initialized"}),void C.complete();const U=`private-${P}`,B=E.channel(U);if(B?.subscribed===!0)return C.next({success:!0}),void C.complete();const x=B??E.subscribe(U),k=()=>{x.unbind("pusher:subscription_succeeded",k),x.unbind("pusher:subscription_error",J),C.next({success:!0}),C.complete()},J=()=>{x.unbind("pusher:subscription_succeeded",k),x.unbind("pusher:subscription_error",J),C.error(new Error(`Failed to subscribe to channel ${U}`))};return x.bind("pusher:subscription_succeeded",k),x.bind("pusher:subscription_error",J),x.subscribed===!0&&k(),()=>{x.unbind("pusher:subscription_succeeded",k),x.unbind("pusher:subscription_error",J)}})).pipe(dT(O),lT(),v((C=>{const U=C instanceof Error?C.message:"Subscription timeout or error";return p({success:!1,error:U})})))})(uT,`chat-${b}`).pipe(y((E=>{const P=[];return E.success||P.push(N({messageSection:"ai_cfo_create_session_and_submit",messageText:"notification",type:"warning"})),j(p(...P,Nu({chatSessionId:b,userId:a,createdAt:ee(I.created_at)}),iT({agentId:e,sessionId:b})),Ha(100).pipe(Ue(1),oT()),p(nT(),Au(b,n,a,o,c,d,l,m),sT({chatSessionId:b,questionAnswerId:n,question:{questionId:o,text:d,createdAt:c},userId:a,attachments:l!=null&&l.length>0?l.map((O=>({filename:O.name,file_size:O.size,mime_type:O.type}))):void 0})))})))}return p(N({messageSection:"ai_cfo_create_session_and_submit",messageText:"failed",type:"error"}),Ou(g.status))})),v((g=>p(Ou(f("Unexpected Error",`Create and Submit Session REST API call errored out: ${JSON.stringify(g)}`))))))}))),(s,i,r)=>s.pipe(S(pT.match),A((t=>{const{agentId:e,contextRefId:a,contextType:n,pageContext:o,userId:c}=t.payload,d={agent_id:e,...a!=null&&{context_ref_id:a},...n!=null&&{context_type:n},...o!=null&&{page_context:o}};return r.postAndGetJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions`,d).pipe(y((l=>T(l)&&l.data!=null?p(Nu({chatSessionId:l.data.chat_session_id,userId:c,createdAt:ee(l.data.created_at)}),mT({agentId:e,contextMessage:l.data.context_message,contextStatus:l.data.context_status,sessionId:l.data.chat_session_id})):p(Cu(l.status)))),v((l=>p(Cu(f("Unexpected Error",`Create Session REST API call errored out: ${JSON.stringify(l)}`))))))}))),(s,i,r)=>s.pipe(S(fq.match),y((t=>{const e=i.value,a=Za(e.taskState,t.payload.parentTaskId),n=a?.taskGroupIds??[],o=n[0],c=e.taskListState.fetchState==="Completed",d=sY(t.payload,n);return r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`,d).pipe(y((l=>{if(T(l)&&l.data!=null&&l.data.tasks.length>0){const u=l.data.tasks[0].task_id,m=[ze(l.data.tasks),vq({parentTaskId:t.payload.parentTaskId,subTaskId:u}),Qd({fetchState:"Completed",newTaskId:u}),N({messageSection:"create_sub_task",messageText:"success",type:"success"})],h=l.data.tasks[0];return h.parent_task_id!=null&&h.parent_task_id!==""||c!==!0||o==null||m.push(fb({taskGroupId:o,task:h})),_(m)}return p(Qd({fetchState:"Error",error:l.status}),N({messageSection:"create_sub_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))})),v((l=>p(Qd({fetchState:"Error",error:f("Unexpected Error","Create Sub Task REST API call errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(iq.match),y((function(t){const{tagName:e,taskId:a}=t.payload;return WK(e,r,a)}))),(s,i,r)=>s.pipe(S(Dq.match),A((t=>{const{taskGroupTemplateId:e,taskIds:a}=t.payload,n=i.value.taskGroupViewState.taskGroupsIds,o={group_name:e,is_create_all_tasks_inside_group:a.length===0,task_names:a};return r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/templates`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[bb(c.data.groups),ze(c.data.tasks),Jq(),wq({tasks:c.data.tasks})];return n.includes(c.data.groups[0].task_group_id)===!1&&d.push(Eb({newTaskGroupId:c.data.groups[0].task_group_id})),_(d)}{const d=[Pb(c.status)];return _(d)}})),v((c=>{const d=[Pb(f("Unexpected error","Create task from templates REST API call errored out"+JSON.stringify(c)))];return _(d)})))}))),(s,i,r)=>s.pipe(S(uO.match),y((t=>{const{transactionId:e,creditAccountIntegrationId:a,debitAccountIntegrationId:n,memo:o,transactionType:c,sourceTransactionType:d}=t.payload,l={id:e,type:d},u={transaction_type:c,transaction_id:e,to_account_integration_id:a,from_account_integration_id:n,transaction_memo:o??""};return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/transaction-type-update`,u).pipe(y((m=>{if(T(m)&&m.data!=null){const g=m.data?.transaction;return g!=null?(h=g)==null||typeof h.transaction_id!="string"||h.transaction_id===""||typeof h.transaction_type!="string"||h.transaction_type===""?_(Pl()):(function(I,b,E,P){const O=Is(I),C=(B=O,!((U=E).id===B.id&&U.type===B.type));var U,B;const x=[va(Be(O),I),bs({transactionId:O,vendorId:b?.[0]?.vendor_id}),...TE(P)];return C&&x.push(mO(E,O)),j(_(x),AE(C?E:void 0))})(g,m.data?.vendors,l,e):(function(I){return j(_(TE(I)),AE(void 0))})(e)}var h;return _(Pl())})),v((()=>_(Pl()))))}))),(s,i,r)=>s.pipe(S(dA.match),A((t=>{const{userId:e,reimbursementId:a}=t.payload,{bankAccountViewState:n}=i.value,o=n.createBankAccountDetails.localData;return o!=null?r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/users/${e}/bank-accounts`,vl(o,"ach")).pipe(y((c=>{const d=[];if(T(c)){const l=c.data?.bank_accounts??[];d.push(np({bankAccountIds:l.map((u=>u.bank_account_id)),userId:e}),Je(l),rr({bankAccountId:l?.[0].bank_account_id,shouldOverWriteCurrentBankAccountId:!0,reimbursementId:a}),Ye({fetchState:"Completed"}),N({messageSection:"account_added",messageText:"success",type:"success"}))}else c.status.code,d.push(Ye({fetchState:"Error",error:c.status}));return _(d)})),v((c=>p(Ye({fetchState:"Error",error:f("Unexpected Error","Bank Creation REST API call errored out"+JSON.stringify(c))}))))):_([])}))),(s,i,r)=>s.pipe(S(jO.match),A((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements/${n}`).pipe(y((o=>{if(T(o)){const c=[],d=ba(e,a);return o.data!=null&&c.push(qm(d,o.data)),c.push(jm({accountId:e,selectedPeriod:a})),p(...c)}return p(Sr({accountId:e,selectedPeriod:a,error:o.status}))})),v((o=>p(Sr({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Delete Statement File REST API call errored out "+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(fR.match),A((t=>{const{ruleId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto/${e}`).pipe(y((a=>{if(T(a)){const n=[vR({ruleId:e}),N({messageSection:"auto_transfer_rule_delete",messageText:"success",type:"success"})];return _(n)}return _([Pf({ruleId:e,fetchState:"Error",error:a.status}),N({messageSection:"auto_transfer_rule_delete",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]})])})),v((a=>p(Pf({ruleId:e,fetchState:"Error",error:f("Unexpected Error","Delete auto transfer rule REST API call errored out "+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(lA.match),A((t=>r.deleteAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/bank-accounts/${t.payload.bankAccountId}`).pipe(y((e=>{if(T(e)){const a=[];return a.push(it({bankAccountId:t.payload.bankAccountId,fetchState:"Completed"})),t.payload.bankAccountContext==="vendor"&&a.push(uA({bankAccountId:t.payload.bankAccountId,vendorId:t.payload.vendorId})),a.push(N({messageSection:"delete_bank_account",messageText:"success",type:"success"})),_(a)}return p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:e.status}),N({messageSection:"delete_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.status.message}]}))})),v((e=>p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:f("Unexpected Error","Bank Deletion REST API call errored out"+JSON.stringify(e))})))))))),(s,i,r)=>s.pipe(S(kR.match),y((t=>{const{billTransactionState:e}=i.value,a=e.transactionById[t.payload.billId],n=a?.isRecurring??!1,o=a?.recurringBillConfigId;let c=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${t.payload.billId}`;return n===!0&&(c=`${c}/recurring`),r.deleteAndGetJSON(`${c}?query=${encodeURIComponent(JSON.stringify({transaction_type:"bill",bill_pay_provider:"zeni"}))}`).pipe(y((d=>{if(M(d)){const l=[];return l.push(uc("Completed",t.payload.billId)),a!=null&&l.push(xf({billId:t.payload.billId,tab:a.billPayInfo.stage.code})),l.push(lc(Ne(t.payload.billId))),n===!0&&o!=null&&l.push(Uf(o)),l.push(N({messageSection:"bill_pay_deleted",messageText:"success",type:"success"})),_(l)}return p(uc("Error",t.payload.billId,d.status),N({messageSection:"bill_pay_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(uc("Error",t.payload.billId,f("Unexpected Error","Delete bill REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(FR.match),A((t=>{const{approvalRuleId:e,useV3:a}=t.payload,n=a===!0?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;return r.deleteAndGetJSON(n,{approval_rule_id:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.approval_rules.map((l=>l.approval_rule_id)),d=[V({users:o.data.users}),We(o.data.approval_rules),N({messageSection:"bill_pay_approval_delete",messageText:"success",type:"success"}),qR(e,c)];return _(d)}return p(N({messageSection:"bill_pay_approval_delete",messageText:"failed",type:"error"}),Vf(e,o.status))})),v((o=>p(Vf(e,f("Unexpected Error","Delete Bill Pay Approval Rule errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(mq.match),y((t=>{const{cannedResponseId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses/${e}`).pipe(y((a=>T(a)?p(yq({cannedResponseId:e})):p(_b({error:a.status})))),v((a=>p(_b({error:f("Unexpected Error","Delete Canned Response errored: "+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(yT.match),y((t=>{const{chatSessionId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions/${e}`).pipe(y((a=>M(a)?_([_T({chatSessionId:e}),hT(e),N({messageSection:"ai_cfo_chat_session_deleted",messageText:"success",type:"success"})]):p(xu({chatSessionId:e,error:a.status}),N({messageSection:"ai_cfo_chat_session_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status?.message??String(a.status)}]})))),v((a=>p(xu({chatSessionId:e,error:f("Unexpected Error","Delete chat session REST API call errored out "+JSON.stringify(a))}),N({messageSection:"ai_cfo_chat_session_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(a)}]})))))}))),(s,i,r)=>s.pipe(S(GO.match),A((t=>{const{accountId:e,selectedPeriod:a,fileId:n}=t.payload;let o=t.payload.combinedStatementGroupId;if(o===""){const d=i.value.expenseAutomationReconciliationViewState.accountReconciliationRecordsBySelectedPeriod[Ee(a)]?.reconciliationByAccountID[e];o=Gm(d)}if(o==="")return p(Sr({accountId:e,selectedPeriod:a,error:f("Missing Data","No combined statement group id found for delete")}));const c=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/combined-statement-groups/${o}`;return r.deleteAndGetJSON(c).pipe(y((d=>{if(T(d)===!0){const l=[];return n!=null&&n!==""&&l.push(Zo([n])),d.data!=null&&l.push(qm(ba(e,a),{statement_upload:d.data.statement_upload})),l.push(jm({accountId:e,selectedPeriod:a}),Rt(a,void 0,!0,!0)),p(...l)}return p(Sr({accountId:e,selectedPeriod:a,error:d.status}))})),v((d=>p(Sr({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Delete Combined Statement REST API call errored out "+(d instanceof Error?d.message:String(d)))})))))}))),(s,i,r)=>s.pipe(S(EP.match),A((t=>r.deleteAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${t.payload.connectionId}`,void 0,Object.assign({"zeni-tenant-id":t.payload.tenantId})).pipe(y((e=>{if(M(e))return _([PP(t.payload.tenantId,t.payload.connectionId,t.payload.connectionType)]);const a=e.status??f("Failed to delete connection. Please try again.");return _([ru(t.payload.tenantId,a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error deleting connection.";return _([ru(t.payload.tenantId,f(a))])})))))),(s,i,r)=>s.pipe(S(Wx.match),y((t=>{const{fileId:e,tenantId:a}=t.payload;return(a!=null?r.deleteAndGetJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}`,void 0,Object.assign({"zeni-tenant-id":a})):r.deleteAndGetJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}`)).pipe(y((n=>T(n)?p(Zo([e]),Zx({fileId:e})):p(Wy({fileId:e,status:n.status})))),v((n=>p(Wy({fileId:e,status:f("Unexpected Error","Delete File REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(Xx.match),y((t=>{const{fileIds:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files?query=${encodeURIComponent(JSON.stringify({file_ids:e}))}`).pipe(y((a=>T(a)?p(Zo(e),eU({fileIds:e})):p(Zy({fileIds:e,status:a.status})))),v((a=>p(Zy({fileIds:e,status:f("Unexpected Error","Delete File List REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(pA.match),A((t=>r.deleteAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/payment-instruments/${t.payload.bankAccountId}`).pipe(y((e=>{if(T(e)){const a=[];return a.push(it({bankAccountId:t.payload.bankAccountId,fetchState:"Completed"})),t.payload.bankAccountContext==="vendor"&&a.push(op({paymentInstrumentId:t.payload.bankAccountId,vendorId:t.payload.vendorId})),a.push(N({messageSection:"delete_bank_account",messageText:"success",type:"success"})),_(a)}return p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:e.status}),N({messageSection:"delete_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.status.message}]}))})),v((e=>p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:f("Unexpected Error","Bank Deletion REST API call errored out"+JSON.stringify(e))})))))))),(s,i,r)=>s.pipe(S(J1.match),A((t=>r.deleteAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-instruments/${t.payload.paymentInstrumentId}`).pipe(y((e=>{if(T(e)){const a=[];return a.push(Dc({paymentInstrumentId:t.payload.paymentInstrumentId,fetchState:"Completed"})),t.payload.bankAccountContext==="vendor"&&a.push(op({paymentInstrumentId:t.payload.paymentInstrumentId,vendorId:t.payload.vendorId})),a.push(N({messageSection:"delete_bank_account",messageText:"success",type:"success"})),_(a)}return p(Dc({paymentInstrumentId:t.payload.paymentInstrumentId,fetchState:"Error",error:e.status}),N({messageSection:"delete_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:e.status.message}]}))})),v((e=>p(Dc({paymentInstrumentId:t.payload.paymentInstrumentId,fetchState:"Error",error:f("Unexpected Error","Payment Instrument Deletion REST API call errored out"+JSON.stringify(e))})))))))),(s,i,r)=>s.pipe(S(HJ.match),y((t=>r.deleteAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/${t.payload.userRoleId}`).pipe(y((e=>M(e)?p(QJ(t.payload.userId),N({messageSection:"people_delete_person",messageText:"success",type:"success"}),w0({userType:"manager",id:t.payload.userId})):p(dg(t.payload.userId)))),v((()=>p(dg(t.payload.userId)))))))),(s,i,r)=>s.pipe(S(KL.match),A((t=>{const{approvalRuleId:e,useV3:a}=t.payload,n=a===!0?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;return r.deleteAndGetJSON(n,{approval_rule_id:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.approval_rules.map((l=>l.approval_rule_id)),d=[V({users:o.data.users}),We(o.data.approval_rules),N({messageSection:"reimbursement_approval_delete",messageText:"success",type:"success"}),YL(e,c)];return _(d)}return p(N({messageSection:"reimbursement_approval_delete",messageText:"failed",type:"error"}),gI(e,o.status))})),v((o=>p(gI(e,f("Unexpected Error","Delete Reimbursement Approval Rule errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(RL.match),y((t=>{const{reimbursementState:e}=i.value,a=e.reimbursementById[t.payload.reimbursementId];return r.deleteAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${t.payload.reimbursementId}?query=${encodeURIComponent(JSON.stringify(YK))}`).pipe(y((n=>{if(M(n)){const o=[Td("Completed",t.payload.reimbursementId)];return a!=null&&o.push(_I({remiId:t.payload.reimbursementId,tab:a.reimbursementInfo.stage.code})),o.push(Pd(t.payload.reimbursementId)),o.push(N({messageSection:"reimbursement_deleted",messageText:"success",type:"success"})),_(o)}return p(Td("Error",t.payload.reimbursementId,n.status),N({messageSection:"reimbursement_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]}))})),v((n=>p(Td("Error",t.payload.reimbursementId,f("Unexpected Error","Delete reimbursement REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(f$.match),y((t=>{const e=i.value,{scheduleAccruedDetailState:a}=e,{scheduleType:n}=t.payload,o=a.selectedJEAccruedScheduleKey,c=[];if(o==null)return _(c);const d=sa(o,e);if(d==null)return _(c);const l=d.jeScheduleId,u=d.vendor.name,m=e.scheduleAccruedDetailState.editScheduleStateByDetailId[l],h={...t0(e,m,o,!0)},g={je_schedule_type:n};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${l}?query=${encodeURIComponent(JSON.stringify(g))}`,h).pipe(y((I=>T(I)&&I.data!=null?(c.push(v$(o),I$(n,l),Qi("Completed"),N({messageSection:"delete_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:u}]})),_(c)):(c.push(Qi("Error",I.status)),c.push(N({messageSection:"delete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:I.status.message}]})),_(c)))),v((I=>_([N({messageSection:"delete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(I)}]}),Qi("Error",f("Unexpected Error",`Delete Accrued Schedule Detail REST API call errored out ${JSON.stringify(I)}`))]))))}))),(s,i,r)=>s.pipe(S(U$.match),y((t=>{const e=i.value,{scheduleDetailState:a}=e,{selectedJeScheduleDetailId:n,scheduleType:o}=t.payload,c=a.selectedJEScheduleKey,d=[];if(c==null)return _(d);const l=ft(c,e),u=l.vendor.name,m=l.jeScheduleId??n;if(m==null)return _(d);const h=e.scheduleDetailState.editScheduleStateByDetailId[o][m],g={...ec(e,h,c,o,!0)},I={je_schedule_type:o};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${m}?query=${encodeURIComponent(JSON.stringify(I))}`,g).pipe(y((b=>T(b)&&b.data!=null?(d.push(k$(c),B$(o,m),tc("Completed"),N({messageSection:"delete_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:u}]})),_(d)):(d.push(tc("Error",b.status)),d.push(N({messageSection:"delete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:b.status.message}]})),_(d)))),v((b=>_([N({messageSection:"delete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(b)}]}),tc("Error",f("Unexpected Error",`Delete Schedule Detail REST API call errored out ${JSON.stringify(b)}`))]))))}))),(s,i,r)=>s.pipe(S(ST.match),y((t=>{const{macroId:e}=t.payload,a=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}`;return r.deleteAndGetJSON(a).pipe(y((n=>M(n)?p(gT({macroId:e})):p(Uu(n.status)))),v((n=>p(Uu(f("Unexpected Error","Delete skill REST API call failed",n instanceof Error?{message:n.message}:void 0))))))}))),(s,i,r)=>s.pipe(S(dq.match),y((t=>{const{tagId:e,taskId:a}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tags/${e}`).pipe(y((n=>M(n)&&n.data!=null?_([Yd({fetchState:"Completed",tagId:e}),lq(e),uq({tagId:e,taskId:a})]):_([Yd({fetchState:"Error",tagId:e,error:n.status}),N({messageSection:"delete_tag",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]})]))),v((n=>p(Yd({fetchState:"Error",tagId:e,error:f("Unexpected Error","Delete tag REST API call errored out "+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(Iq.match),y((t=>{const{taskId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${e}`).pipe(y((a=>{if(M(a)){const n=[];return e!=null&&n.push(ro(e)),n.push(Nt()),n.push(Wd({fetchState:"Completed",taskId:e})),_(n)}return _([Wd({fetchState:"Error",taskId:e,error:a.status}),N({messageSection:"delete_task",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]})])})),v((a=>p(Wd({fetchState:"Error",taskId:e,error:f("Unexpected Error","Delete Task REST API call errored out "+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(Lq.match),A((t=>{const{taskGroupId:e}=t.payload;return r.deleteAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/groups/${e}`).pipe(y((a=>T(a)&&a.data!=null?p(jq(e),qq({deletedTaskGroupId:e}),Fq({taskGroupId:e}),N({messageSection:"task_group_deletion_success",messageText:"success",type:"success"})):p(Ob({fetchState:"Error",error:a.status})))),v((a=>p(Ob({fetchState:"Error",error:f("Unexpected Error","Delete Task Group REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(nj.match),A((t=>{const{attachmentFileName:e,transactionId:a}=t.payload,n={transaction_type:a.type,attachment_file_names:[e]};return r.deleteAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${a.id}/attachments?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(T(o)){const c=Be(a);return p(cj({thirdPartyTransactionId:a.id,attachmentFileName:e}),ij({id:c,attachmentFileName:e}),oj({transactionId:a,attachmentFileName:e}))}return p($b({transactionId:a,attachmentFileName:e,status:o.status}))})),v((o=>p($b({transactionId:a,attachmentFileName:e,status:f("Unexpected Error","Delete Transaction Attachment REST API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(mA.match),A((t=>{const{userId:e,bankAccountId:a,reimbursementId:n}=t.payload,o=i.value.userFinancialAccountState.financialAccountByUserId[e]?.bankAccountIds??[],c=n!=null?i.value.editRemiDetailViewState.editRemiStateById[n].remiDetailLocalData.paymentTo:i.value.editRemiDetailViewState.newRemiState.remiDetailLocalData.paymentTo;return r.deleteAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/users/${e}/bank-accounts/${a}`).pipe(y((d=>{if(T(d)){const l=[];l.push(it({bankAccountId:t.payload.bankAccountId,fetchState:"Completed"}),yA({userId:e,bankAccountId:a}));const u=o.filter((m=>m!==a));return a===c&&(u.length===1?l.push(rr({bankAccountId:u[0],reimbursementId:n,shouldOverWriteCurrentBankAccountId:!0})):l.push(rr({reimbursementId:n,shouldOverWriteCurrentBankAccountId:!0}))),_(l)}return p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:d.status}))})),v((d=>p(it({bankAccountId:t.payload.bankAccountId,fetchState:"Error",error:f("Unexpected Error","Bank Deletion REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(wN.match),A((t=>{const{companyId:e}=t.payload,a=cr(i.value.tenantState,e);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_accounting_projects_enabled:!1}).pipe(y((n=>{const o=n.data?.companies??[];if(T(n)&&o.length>0){const c=[Q({payload:o,schema:{}})];return a!=null&&c.push(pm({enabled:!1,tenantId:a})),c.push(mm()),c.push(N({messageSection:"accounting_projects_enabled_update",messageText:"success",type:"success"})),_(c)}return _([yt({status:n.status}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})])})),v((n=>p(yt({status:f("Unexpected error",`Update Accounting Projects Enabled errored out - ${n instanceof Error?n.message:JSON.stringify(n)}`)}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})))))}))),(s,i,r)=>s.pipe(S(sD.match),y((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings/stripe-connect/callback`;return r.deleteAndGetJSON(t).pipe(A((e=>T(e)?p(Xh({stripe_connected:!1,publishable_key:""}),Vt()):p(en(e.status)))),v((e=>p(en(f("Unexpected Error","Stripe disconnect REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(JN.match),A((t=>{const{companyId:e,accountId:a}=t.payload,n=cr(i.value.tenantState,e),o={capitalization_onboarding_dismissed_accounts:{[a]:!0}};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,o).pipe(y((c=>T(c)&&n!=null?_([lm({tenantId:n,accountId:a})]):_([]))),v((()=>_([]))))}))),NG,OG,CG,(s,i,r)=>s.pipe(S(dj.match),y((t=>{const e=t.payload.attachmentId;return r.getFile(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/transactions/attachments/download/${e}`).pipe(y((a=>p(a!=null?lj({attachmentId:e,data:a}):Rb()))),v((a=>(console.error(`REST API call errored out ${a}`),p(Rb())))))}))),(s,i)=>s.pipe(S(Yq.match),y((r=>{const{taskIds:t,groupId:e}=r.payload,a=i.value,{groupByKey:n}=a.taskListState.uiState,o=Hq(n,e),c=[xb({taskIds:t,groupId:e,removeFromList:!1}),rl(t,e,o)];return _(c)}))),(s,i,r)=>s.pipe(S($N.match),A((t=>{const{companyId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounting_provider_project_authorization_status`).pipe(y((a=>T(a)&&a.data!=null?a.data.is_accounting_provider_project_apis_authorized!==!0?_([RN()]):_([ym(e)]):_([yt({status:a.status}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})]))),v((a=>p(yt({status:f("Unexpected error",`Accounting provider project authorization status errored out - ${a instanceof Error?a.message:JSON.stringify(a)}`)}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})))))}))),(s,i,r)=>s.pipe(S(CV.match),y((t=>{const{isAutoPayEnabled:e,companyId:a}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${a}`,{is_auto_pay_enabled:e}).pipe(y((n=>{if(M(n)&&n.data!=null){const o=[V({users:n.data.users}),Y(n.data.user_roles),Q({payload:n.data.companies,schema:{}}),xV(),N({messageSection:e?"charge_card_auto_pay_enable":"charge_card_auto_pay_disable",messageText:"success",type:"success"})];return _(o)}return p(jv(n.status),N({messageSection:e?"charge_card_auto_pay_enable":"charge_card_auto_pay_disable",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]}))})),v((n=>p(jv(f("Unexpected Error","Enable Charge Card Auto Pay errored out"+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(iB.match),y((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/config`;return r.putAndGetJSON(t,{is_invoicing_enabled:!0}).pipe(A((e=>T(e)&&e.data!=null?p(Ni(e.data),cB()):p(ih(e.status)))),v((e=>p(ih(f("Unexpected Error","Enable invoicing REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(jV.match),y((t=>{const{companyId:e,setupViewType:a}=t.payload;let n;switch(a){case"reimbursement":n={is_reimbursement_enabled:!0};break;case"charge_cards":n={is_charge_cards_enabled:!0};break;case"debit_cards":n={is_debit_cards_enabled:!0};break;case"charge_cards__debit_cards":n={is_charge_cards_enabled:!0,is_debit_cards_enabled:!0};break;case"zeni_accounts":n={is_deposit_accounts_enabled:!0};break;default:n={is_bill_pay_enabled:!0}}return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,n).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[V({users:o.data.users}),Y(o.data.user_roles),Q({payload:o.data.companies,schema:{}}),we({companyId:o.data.companies[0].company_id}),GV()];return _(c)}return p(Xv(o.status))})),v((o=>p(Xv(f("Unexpected Error","Enable Setup errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(xJ.match),y((t=>{const{publicToken:e,linkTokenType:a}=t.payload,n={public_token:e};return a!=="update_account"&&(n.is_primary_for_onboarding=!0,n.is_primary_for_bill_pay=!0,n.is_primary_for_reimbursements=!0,n.is_primary_for_charge_cards=!0,n.is_primary_for_deposit_accounts=!0),r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/public-token`,n).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.payment_accounts.map((l=>l.payment_account_id)),d=[W(o.data.accounts,"onboarding"),Se(o.data.payment_accounts),UJ(c,a)];return _(d)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),KS(o.status,a))})),v((o=>p(KS(f("Unexpected Error","Establish Onboarding Plaid Connection errored out"+JSON.stringify(o)),a)))))}))),(s,i,r)=>s.pipe(S(yL.match),y((t=>{const{publicToken:e,companyId:a,setupViewType:n,linkTokenType:o,plaidAccountKeyType:c,zeniMappedAccountId:d}=t.payload,l={public_token:e},u={},m=i.value.paymentAccountListState,h=i.value.tenantState.loggedInUser?.userId??"";o!=="link_external_account"&&(n==null&&c!=="expense_automation_reconcile"?l.is_user_account=!0:c==="bill_pay_setup"?l.is_primary_for_bill_pay=!0:c==="reimbursement_setup"?l.is_primary_for_reimbursements=!0:c==="charge_card_setup"?l.is_primary_for_charge_cards=!0:c==="account_setup"?l.is_primary_for_deposit_accounts=!0:c==="billing_setup"?l.is_primary_for_onboarding=!0:c==="expense_automation_reconcile"&&(u.zeni_mapped_account_id=d??""));const g=Object.entries(u).length>0?`?query=${JSON.stringify(u)}`:"";return r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/public-token${g}`,l).pipe(y((I=>{if(T(I)&&I.data!=null){const b=I.data.payment_accounts[0],E=[Se(I.data.payment_accounts),Ht({data:I.data.payment_accounts,updateType:"merge"}),_L(o,c)];if(c==="bill_pay_detail"&&E.push(hL(b.payment_account_id)),c==="charge_card_payment"){const P=SL(b),O=gL(P,m.paymentAccountBalanceFetchStatus);E.push(fL(O))}if(n!=null&&(n==="billing"&&E.push(cc(n,c,!1)),b.is_primary_for_bill_pay,b.is_primary_for_bill_pay===!0&&E.push(Gr({companyId:a,primaryFundingAccountId:b.payment_account_id,accountType:"paymentAccount",productType:"bill_pay"})),b.is_primary_for_reimbursements===!0&&E.push(Gr({companyId:a,primaryFundingAccountId:b.payment_account_id,accountType:"paymentAccount",productType:"reimbursement"})),b.is_primary_for_charge_cards===!0&&E.push(Gr({companyId:a,primaryFundingAccountId:b.payment_account_id,accountType:"paymentAccount",productType:"charge_cards"})),b.is_primary_for_deposit_accounts===!0&&E.push(Gr({companyId:a,primaryFundingAccountId:b.payment_account_id,accountType:"paymentAccount",productType:"zeni_accounts"}))),I.data.bank_accounts!=null){const P=I.data.bank_accounts.map((O=>O.bank_account_id));E.push(Je(I.data.bank_accounts),np({bankAccountIds:P,userId:h}))}return n!=null?E.push(W(I.data.accounts,Da(n))):E.push(N({messageSection:"account_added",messageText:"success",type:"success"})),_(E)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),iI(I.status,o,c))})),v((I=>p(iI(f("Unexpected Error","Establish Plaid Connection errored out"+JSON.stringify(I)),o,c)))))}))),(s,i,r)=>s.pipe(S(zO.match),y((t=>{const{accountId:e}=t.payload,a=i.value,n=H(a),o=a.expenseAutomationViewState.selectedPeriodByTenantId[n.tenantId],c=Ea(a,e,o),d={account_id:e,bank_balance:c?.balance?.amount??null,cleared_balance:c?.clearedBalance?.amount??null,variance:c?.variance?.amount??null},l=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/excluded-accounts`;return r.postAndGetJSON(l,d).pipe(y((u=>{if(T(u)){const m=Ns("excluded_account_reconciliation",e),h=Ns("account_reconciliation",e);return p(KO({account:u.data?.excluded_account??void 0,selectedPeriod:o}),zm({oldKey:h,newKey:m}),N({messageSection:"account_excluded_from_reconciliation",messageText:"success",type:"success",variables:[{variableName:"_account-name_",variableValue:c?.account.accountName??""}]}))}return p(Km({error:u.status}),N({messageSection:"account_excluded_from_reconciliation",messageText:"failed",type:"error"}))})),v((u=>p(Km({error:f("Unexpected Error",`Exclude account from reconciliation REST API call errored out ${JSON.stringify(u)}`)}),N({messageSection:"account_excluded_from_reconciliation",messageText:"failed",type:"error"})))))}))),(s,i,r)=>s.pipe(S(UV.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_company_interested_in_charge_card:!0}).pipe(y((a=>{if(M(a)&&a.data!=null){const n=[V({users:a.data.users}),Y(a.data.user_roles),Q({payload:a.data.companies,schema:{}}),kV()];return _(n)}return p(Gv(a.status),N({messageSection:"charge_card_express_interest",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]}))})),v((a=>p(Gv(f("Unexpected Error","Express Interest in Charge Card errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(dP.match),A((t=>{const e=(a=>{const n=new FormData;return a.forEach(((o,c)=>{n.append(`attachment_file_${c}`,o);const d=JSON.stringify({file_name:o.name,content_type:o.type,size:o.size});n.append(`attachment_json_${c}`,d)})),n})(t.payload.files);return r.postFormData(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-documents/extract`,e).pipe(y((a=>M(a)&&a.data!=null&&a.data.extracted_rules!=null?p(no(a.data.extracted_rules)):p(Yl(a.status)))),v((a=>p(Yl(f("Unexpected Error","Extract card-policy document REST API call errored out"+JSON.stringify(a)))))),De(s.pipe(S(Kl.match))))}))),(s,i,r)=>s.pipe(S(be.match),y((t=>{const{accountListKey:e,fetchFullResponse:a,excludeAccountPayableAccounts:n,excludeAccountReceivableAccounts:o,isLimitedCategoryEnabled:c,filterAccountTypes:d,isIncludeDeleted:l}=t.payload,u=((h,g)=>g.length>0?g:h===!0?["cogs","expenses","other_expense"]:[])(c,d),m={is_bookkeeping_admin:a,is_exclude_account_payable_accounts:n,is_exclude_account_receivable_accounts:o,account_types:u,...l===!0&&{is_include_deleted:!0}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify(m))}`).pipe(y((h=>{if(T(h)){const g=[W(h.data?.accounts??[],"account_list"),BP({accountListKey:e,accountListResponse:h})];return _(g)}return p(cu({accountListKey:e,status:h.status}))})),v((h=>p(cu({accountListKey:e,status:f("Unexpected Error","Fetch Accounts REST API call errored out"+JSON.stringify(h))})))))}))),(s,i,r)=>s.pipe(S(uu.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify({is_bookkeeping_admin:!1,is_include_tax_1099_config:!0}))}`).pipe(y((t=>{if(T(t)){const e=[],a=[];return t.data?.accounts.forEach((n=>{a.push(n)})),e.push(W([...a],"account_list_by_type")),e.push(JP({accountPayload:a})),_(e)}return p(pu({status:t.status}))})),v((t=>p(pu({status:f("Unexpected Error","Fetch Accounts For Account Type REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(uy.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify({is_bookkeeping_admin:!1,is_include_tax_1099_config:!1}))}`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[],a=[];return t.data.accounts.forEach((n=>{a.push(n)})),e.push(W([...a],"account_list_by_type")),e.push(xC({accountPayload:a})),_(e)}return p(py({status:t.status}))})),v((t=>p(py({status:f("Unexpected Error","Fetch Accounts For Account Type REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(sf.match),y((t=>{const{scheduleType:e}=t.payload,{scheduleListState:a}=i.value,n=nc(a,e),o=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedTimeframe:n.selectedTimeframe,c=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedCategoryId:n.selectedCategoryId,d=ua(o),l=ln(c,o),u=n.jeScheduleAccruedByListKey[l];if(u!=null&&u.fetchState==="Completed"&&t.payload.cacheOverride===!1)return _([]);const m={start_date:ae(d.start),end_date:ae(d.end),je_schedule_type:e,sort_by:"transaction_date",sort_order:"desc",filter:t.payload.statusFilter};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(m))}`).pipe(y((h=>{if(T(h)&&h.data!=null){const g=[];return g.push(ca(h.data.je_schedules),br(h.data.je_schedules,h.data.scheduled_journal_entries),q$(e,o,c,h.data.je_schedules)),_(g)}return p(nf(e,o,c,h.status))})),v((h=>p(nf(e,o,c,f("Unexpected Error","Accrued Schedule List REST API call errored out"+JSON.stringify(h)))))))}))),xG,(s,i,r)=>s.pipe(S(RP.match),A((t=>{const{addressId:e,cacheOverride:a}=t.payload,n=ot(i.value.addressState,e);return a===!0||n==null?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/addresses/${e}`).pipe(y((o=>T(o)?p(z(o.data?.addresses??[]),Su(e)):p(gu({addressId:e,status:o.status})))),v((o=>p(gu({addressId:e,status:f("Unexpected Error","Fetch Address REST API call errored out"+JSON.stringify(o))}))))):p(Su(e))}))),(s,i,r)=>s.pipe(S(QP.match),A((t=>{const{fromMonth:e,toMonth:a,cacheOverride:n}=t.payload,o=i.value.aggregatedReportViewState.aggregatedReport,c=ZP(e,a);if(!(n||o[c]?.fetchState!=="Error"&&o[c]?.fetchState!=="Completed"))return p(WP());const d=`${r.apiEndPoints.agentPerfBaseUrl}/1.0/agent-performance/reports/aggregated?from_month=${e}&to_month=${a}`;return r.getJSON(d).pipe(y((l=>T(l)?p(XP(l.data)):p(Pu(l.status)))),v((l=>p(Pu(f("Unexpected error","REST API call errored out"+JSON.stringify(l)))))))}))),(s,i,r)=>s.pipe(S(uo.match),A((()=>{const t=`${`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`}/ai-accountant/customers`;return r.getJSON(t).pipe(y((e=>{if(T(e)){const a=e.data?.customers??[],n=e.data?.users??[];return _([qP(a),V({users:n}),jP(a)])}return p(Iu(e.status))})),v((e=>p(Iu(f("Unexpected error","AI Accountant customers fetch failed: "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(GP.match),A((t=>{const{tenantId:e,fetchNextPage:a}=t.payload,n=i.value.aiAccountantViewState.customersByTenantId[e],o=a&&n?.jobsPageToken!=null?n.jobsPageToken:null,c=new URLSearchParams({page_size:"50",tenant_id:e});o!=null&&c.set("page_token",o);const d=`${`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`}/ai-accountant/jobs?${c.toString()}`;return r.getJSON(d).pipe(y((l=>{if(T(l)){const u=l.data?.jobs??[],m=l.data?.users??[],h=l.data?.next_page_token??null;return _([V({users:m}),zP(e,u,a),KP(e,h)])}return p(bu({tenantId:e,error:l.status}))})),v((l=>p(bu({tenantId:e,error:f("Unexpected error","AI Accountant jobs fetch failed: "+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(aJ.match),y((()=>{const t=`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-agents-activation/status`;return r.getJSON(t).pipe(y((e=>{if(T(e)&&e.data!=null){const n=(e.data.phases??[]).map(lK);return p(rJ({phases:n,counts:(a=e.data.counts,{customerCount:a?.customer_count??0,glAccountCount:a?.gl_account_count??0,targetTransactionCount:a?.target_transaction_count??0,transactionCount:a?.transaction_count??0,vendorCount:a?.vendor_count??0})}))}var a;return p(kS(e.status))})),v((e=>p(kS(f("Unexpected Error","fetchAiAgentsActivationStatus errored out "+JSON.stringify(e)))))))}))),(s,i)=>s.pipe(S(WN.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([fa(),je(),pr(),mr(),yr(),_r(),hr(),is(),Ro(),Tm(),fs(0,"dueDate","descending",!1),$o()]);{const e=i.value,a=[];return e.companyViewState.managementView.fetchState==="In-Progress"||e.companyViewState.managementView.hasValidState()||a.push(fa()),e.companyViewState.zeniUsers.fetchState==="In-Progress"||e.companyViewState.zeniUsers.hasValidState()||a.push(je()),e.subscriptionViewState.subscriptionListView.fetchState==="In-Progress"||e.subscriptionViewState.subscriptionListView.hasValidState()||a.push(pr()),e.companyViewState.portfolioView.fetchState==="In-Progress"||e.companyViewState.portfolioView.hasValidState()||a.push(mr()),e.onboardingCockpitViewState.fetchState==="In-Progress"||e.onboardingCockpitViewState.hasValidState()||a.push(yr()),e.onboardingCockpitViewState.qboConnectionPool.fetchState==="In-Progress"||e.onboardingCockpitViewState.qboConnectionPool.hasValidState()||a.push(_r()),e.onboardingCockpitViewState.onboardingCompletedCompanies.fetchState==="In-Progress"||e.onboardingCockpitViewState.onboardingCompletedCompanies.hasValidState()||a.push(hr()),e.reviewCompanyViewState.fetchState!=="In-Progress"&&e.reviewCompanyViewState.hasValidState()===!1&&a.push(is()),e.companyHealthMetricViewState.fetchState!=="In-Progress"&&e.companyHealthMetricViewState.hasValidState()===!1&&(a.push(Ro()),a.push($o())),e.companyViewState.metaDataView.fetchState!=="In-Progress"&&e.companyViewState.metaDataView.hasValidState()===!1&&a.push(Tm()),e.companyTaskManagerViewState.fetchState!=="In-Progress"&&e.companyTaskManagerViewState.hasValidState()===!1&&a.push(fs(0,"dueDate","descending",!1)),_(a)}}))),(s,i)=>s.pipe(S(bC.match),A((r=>{const{cacheOverride:t,refreshViewInBackground:e}=r.payload,a=i.value,{monthEndCloseChecksState:n}=a,{monthEndCloseChecksByTenantId:o}=n,c=H(a),d=c.companyId,l=a.expenseAutomationViewState.selectedPeriodByTenantId[c.tenantId],{selectedTransactionCategorizationTab:u}=a.expenseAutomationTransactionsViewState,m=Re(l),h=ge(m.start),g=ge(m.end),I=Ee(l),b=o?.[c.tenantId]?.[I],E=b?.monthEndCloseCheckList.some((P=>P.id==="reconciliation"))??!1;if(h==null||g==null||d==null)throw Error(`Invalid start - ${h} and end - ${g} period from given ${l}`);if(t===!0){const P=[];return P.push(fr(u,{start:h,end:g},t,!1,void 0,void 0,e,!1),vr({start:h,end:g},{amount:75,currencyCode:"USD",currencySymbol:"$"},t,e),ks(l,t,e,null),Pa({start:h,end:g},t)),E&&P.push(Rt(l,void 0,t,e)),_(P)}{const P=[];a.expenseAutomationMissingReceiptsViewState.fetchState==="In-Progress"||a.expenseAutomationMissingReceiptsViewState.hasValidState()&&a.expenseAutomationMissingReceiptsViewState.transactionIdsBySelectedPeriod[I]!=null||P.push(vr({start:h,end:g},{amount:75,currencyCode:"",currencySymbol:""},t,e)),a.expenseAutomationFluxAnalysisViewState.fetchState==="In-Progress"||a.expenseAutomationFluxAnalysisViewState.hasValidState()&&a.expenseAutomationFluxAnalysisViewState.groupsBySelectedPeriod[I]!=null||P.push(ks(l,t,e,null));const O=cy(a.expenseAutomationJESchedulesViewState.uiState.selectedPageTab,I);return a.expenseAutomationJESchedulesViewState.fetchState==="In-Progress"||a.expenseAutomationJESchedulesViewState.hasValidState()&&a.expenseAutomationJESchedulesViewState.jeScheduleTransactionKeysByPeriodAndTab[O]!=null&&a.expenseAutomationJESchedulesViewState.failedJeScheduleTransactionKeysByPeriodAndTab[O]!=null||P.push(Pa({start:h,end:g},t)),a.expenseAutomationReconciliationViewState.fetchState!=="In-Progress"&&a.expenseAutomationReconciliationViewState.accountReconciliationRecordsBySelectedPeriod[I]==null&&E&&P.push(Rt(l,void 0,t,e)),a.expenseAutomationTransactionsViewState.transactionCategorizationView[u].fetchState==="In-Progress"||a.expenseAutomationTransactionsViewState.transactionCategorizationView[u].hasValidState()!==!1&&a.expenseAutomationTransactionsViewState.transactionCategorizationView[u].transactionIdsBySelectedPeriod[I]!=null||P.push(fr(u,{start:h,end:g},t,!1,void 0,void 0,e,!1)),_(P)}}))),(s,i)=>s.pipe(S(WJ.match),A((r=>{const{companyId:t,shouldFetchClassList:e}=r.payload,a=[dr(t),$e("manager",!0)];return e&&a.push(se()),_(a)}))),(s,i,r)=>s.pipe(S(Hd.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tags?query=${encodeURIComponent(JSON.stringify({filter_type:"all"}))}`).pipe(y((t=>T(t)&&t.data!=null?p(Zr(t.data.tags),pq({data:t.data.tags})):p(yb({fetchState:"Error",error:t.status})))),v((t=>p(yb({fetchState:"Error",error:f("Unexpected Error","Fetch Tag List REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(sl.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/groups?query=${encodeURIComponent(JSON.stringify({filter_type:"all"}))}`).pipe(y((t=>T(t)&&t.data!=null?p(bb(t.data.task_groups),Gq({data:t.data.task_groups})):p(Cb({fetchState:"Error",error:t.status})))),v((t=>p(Cb({fetchState:"Error",error:f("Unexpected Error","Fetch all task groups REST API call errored out"+JSON.stringify(t))})))))))),UG,(s,i)=>s.pipe(S(GA.match),y((r=>{const{cacheOverride:t,vendorName:e}=r.payload,a=i.value,n=[];if(t===!0)e!=null&&n.push(sr(e,"vendor")),n.push(us(e));else if(e!=null){const{fetchState:o,recommendations:c=[]}=ps(a,e,"vendor");o==="In-Progress"?n.push(us(e)):o!=="Completed"?(e&&n.push(sr(e,"vendor")),n.push(us(e))):n.push(Np({recommendations:c,vendorId:void 0}))}return _(n)}))),(s,i,r)=>s.pipe(S(GT.match),A((t=>{const{vendorId:e,reportDate:a}=t.payload,n={vendor_id:e,report_date:a.format("YYYY-MM-DD")};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/accounts_payable_aging_detail?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(T(o)&&o.data!=null){const d=[le(o.data.report.vendors),zT(o.data.report,e,a)];return _(d)}const c=[Ku(o.status,e,a)];return _(c)})),v((o=>{const c=[Ku(f("Unexpected error","ApAging Detail Report REST API call errored out"+JSON.stringify(o)),e,a)];return _(c)})))}))),(s,i,r)=>s.pipe(S(yo.match),A((t=>{const{reportDate:e,cacheOverride:a}=t.payload,n={is_reimbursements_user_allowed:!0,report_date:e.format(re)},o=i.value.apAgingState,c=Yu(e);return o.apAgingBalancesByDate[c]!=null&&a===!1?_([]):r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/accounts_payable_aging?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[le(d.data.report.vendors,"merge"),KT(e,d.data.report)];return _(l)}{const l=[Hu(d.status)];return _(l)}})),v((d=>{const l=[Hu(f("Unexpected error","ApAging Report REST API call errored out"+JSON.stringify(d)))];return _(l)})))}))),(s,i,r)=>s.pipe(S(YT.match),A((t=>{const{customerId:e,reportDate:a}=t.payload,n={customer_id:e,report_date:a.format("YYYY-MM-DD")};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/accounts_receivable_aging_detail?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(T(o)&&o.data!=null){const d=[Qu(o.data.report.customers,!0),HT(o.data.report,e,a)];return _(d)}const c=[Wu(o.status,e,a)];return _(c)})),v((o=>{const c=[Wu(f("Unexpected error","ArAging Detail Report REST API call errored out"+JSON.stringify(o)),e,a)];return _(c)})))}))),(s,i,r)=>s.pipe(S(_o.match),A((t=>{const{reportDate:e,cacheOverride:a}=t.payload,n={report_date:e.format("YYYY-MM-DD")},o=i.value.arAgingState,c=Yu(e);return o.arAgingBalancesByDate[c]!=null&&a===!1?_([]):r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/accounts_receivable_aging?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[Qu(d.data.report.customers),QT(e,d.data.report)];return _(l)}{const l=[Zu(d.status)];return _(l)}})),v((d=>{const l=[Zu(f("Unexpected error","ArAging Report REST API call errored out"+JSON.stringify(d)))];return _(l)})))}))),(s,i,r)=>s.pipe(S(WT.match),y((t=>{const{companyId:e,fetchAction:a,reportGroupId:n}=t.payload,o=i.value.companyState.companiesById[e].companyInfo.tenantId;if(o!=null){const c=hz(a,n),{userId:d,sessionId:l}=r,u={"zeni-user-id":d,"zeni-tenant-id":o,"zeni-session-id":l};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/audit?query=${encodeURIComponent(JSON.stringify(c))}`,u).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[ZT(e,n,m.data)];return _(h)}{const h=[Xu(e,n,m.status)];return _(h)}})),v((m=>{const h=[Xu(e,n,f("Unexpected error","Audit Report Group view errored out"+JSON.stringify(m)))];return _(h)})))}return _([])}))),(s,i,r)=>s.pipe(S(XT.match),A((t=>{const{cacheOverride:e}=t.payload,a=i.value,{fetchState:n}=a.auditReportViewState.auditRuleGroupView;return e===!0||n!=="In-Progress"?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/audit-rule-groups`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[eA(o.data.audit_rule_groups)];return _(c)}{const c=[ep(o.status)];return _(c)}})),v((o=>{const c=[ep(f("Unexpected error","Audit rule group view errored out"+JSON.stringify(o)))];return _(c)}))):_([])}))),(s,i,r)=>s.pipe(S(IR.match),A((()=>{const t=i.value.autotransferRulesState.ruleUpdateLocalData,e={...t.sourceAccount!=null&&{from_account:{account_id:t.sourceAccount.id,account_type:Xr(t.sourceAccount.accType)??""}},...t.destinationAccount!=null&&{to_account:{account_id:t.destinationAccount.id,account_type:Xr(t.destinationAccount.accType)??""}},...t.amount!=null&&{amount:t.amount.amount,currency_code:t.amount.currencyCode,currency_symbol:t.amount.currencySymbol}};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/transfers/review`,e).pipe(y((a=>T(a)&&a.data!=null?p(bR(a.data)):p(Tf(a.status)))),v((a=>p(Tf(f("Unexpected Error","Fetch auto transfer review detail REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(ER.match),y((t=>{const{ruleId:e,cacheOverride:a}=t.payload,n=[],o=i.value,c=X(o.autotransferRulesState.historyByRuleId,e,void 0);if(a===!0||c==null||c.fetchState!=="In-Progress"){n.push(dc({ruleId:e,fetchState:"In-Progress"}));const d=r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto/${e}/history`).pipe(y((l=>T(l)&&l.data!=null?p(PR({ruleId:e,historicEventsPayload:l.data.activities})):p(dc({ruleId:e,fetchState:"Error",error:l.status})))),v((l=>p(dc({ruleId:e,fetchState:"Error",error:f("Unexpected Error","Fetch auto transfer rule history REST API call errored out "+JSON.stringify(l))})))));return j(_(n),d)}return _(n)}))),(s,i,r)=>s.pipe(S(TR.match),A((t=>{const e=i.value,{cacheOverride:a}=t.payload,{autotransferRulesState:n,depositAccountListState:o,paymentAccountListState:c}=e;return a===!0||n.hasValidState()===!1&&n.fetchState!=="In-Progress"?r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto/list`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.auto_transfer_rules.map(kl),u=[AR({rules:l})];return o.fetchState!=="In-Progress"&&o.fetchState!=="Completed"&&u.push(ke()),c.fetchState!=="In-Progress"&&c.fetchState!=="Completed"&&u.push(Ge()),u.push(Af(!1,!0)),_(u)}return p(Nf({fetchState:"Error",error:d.status}))})),v((d=>p(Nf({fetchState:"Error",error:f("Unexpected Error","Fetch auto transfer rules REST API call errored out "+JSON.stringify(d))}))))):_([])}))),(s,i)=>s.pipe(S(rA.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Ct("month",!0),Ct("quarter",!0),Ct("year",!0)]);{const e=[],a=i.value.balanceSheetClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Ct("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Ct("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Ct("year")),_(e)}}))),(s,i)=>s.pipe(S(ho.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Ot("month"),Ot("quarter"),Ot("year")]);{const e=[],a=i.value.balanceSheetState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Ot("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Ot("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Ot("year")),_(e)}}))),(s,i,r)=>s.pipe(S(Ct.match),y((t=>{const e={is_full_response:!0,time_series_groups:[Sz(t.payload.timeframe)],is_group_by_class:!0,...t.payload.cacheOverride===!0?{is_hard_refresh:!0}:{}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/balance_sheet?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],{report:o}=a.data,c=o.currency;return n.push(oe(t.payload.timeframe,he("cash_and_equivalents"),"balance_sheet_by_classes",o.assets.current_assets.cash_and_equivalents,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("accounts_receivable"),"balance_sheet_by_classes",o.assets.current_assets.accounts_receivable,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("other_current_assets"),"balance_sheet_by_classes",o.assets.current_assets.other_current_assets,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("fixed_assets"),"balance_sheet_by_classes",o.assets.fixed_assets,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("other_assets"),"balance_sheet_by_classes",o.assets.other_assets,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("accounts_payable"),"balance_sheet_by_classes",o.liabilities.current_liabilities.accounts_payable,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("credit_cards"),"balance_sheet_by_classes",o.liabilities.current_liabilities.credit_cards,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("other_current_liabilities"),"balance_sheet_by_classes",o.liabilities.current_liabilities.other_current_liabilities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("long_term_liabilities"),"balance_sheet_by_classes",o.liabilities.long_term_liabilities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,he("equity"),"balance_sheet_by_classes",o.equity,o.classes,o.accounts,c)),n.push(sA({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(ap(a.status,t.payload.timeframe))})),v((a=>p(ap(f("Unexpected Error","Balance Sheet by Class REST API call errored out: "+(a instanceof Error?a.message:JSON.stringify(a))),t.payload.timeframe)))))}))),kG,(s,i,r)=>s.pipe(S(xt.match),y((t=>{const e={is_full_response:!0,time_series_groups:[gz(t.payload.timeframe)],is_group_by_project:!0,...t.payload.cacheOverride===!0?{is_hard_refresh:!0}:{}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/balance_sheet?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],{report:o}=a.data,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,he("cash_and_equivalents"),"balance_sheet_by_projects",o.assets.current_assets.cash_and_equivalents,o.accounts,c)),n.push(ie(t.payload.timeframe,he("accounts_receivable"),"balance_sheet_by_projects",o.assets.current_assets.accounts_receivable,o.accounts,c)),n.push(ie(t.payload.timeframe,he("other_current_assets"),"balance_sheet_by_projects",o.assets.current_assets.other_current_assets,o.accounts,c)),n.push(ie(t.payload.timeframe,he("fixed_assets"),"balance_sheet_by_projects",o.assets.fixed_assets,o.accounts,c)),n.push(ie(t.payload.timeframe,he("other_assets"),"balance_sheet_by_projects",o.assets.other_assets,o.accounts,c)),n.push(ie(t.payload.timeframe,he("accounts_payable"),"balance_sheet_by_projects",o.liabilities.current_liabilities.accounts_payable,o.accounts,c)),n.push(ie(t.payload.timeframe,he("credit_cards"),"balance_sheet_by_projects",o.liabilities.current_liabilities.credit_cards,o.accounts,c)),n.push(ie(t.payload.timeframe,he("other_current_liabilities"),"balance_sheet_by_projects",o.liabilities.current_liabilities.other_current_liabilities,o.accounts,c)),n.push(ie(t.payload.timeframe,he("long_term_liabilities"),"balance_sheet_by_projects",o.liabilities.long_term_liabilities,o.accounts,c)),n.push(ie(t.payload.timeframe,he("equity"),"balance_sheet_by_projects",o.equity,o.accounts,c)),n.push(nA({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(rp(a.status,t.payload.timeframe))})),v((a=>p(rp(f("Unexpected Error","Balance Sheet by Project REST API call errored out: "+(a instanceof Error?a.message:JSON.stringify(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(oA.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([xt("month",!0),xt("quarter",!0),xt("year",!0)]);{const e=[],a=i.value.balanceSheetProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(xt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(xt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(xt("year")),_(e)}}))),(s,i,r)=>s.pipe(S(ic.match),A((()=>{const t=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify({is_bookkeeping_admin:!0,is_exclude_account_payable_accounts:!0,is_exclude_account_receivable_accounts:!0,account_types:["bank"]}))}`;return r.getJSON(t).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.accounts.map((o=>o.account_id)),n=[];return n.push(W$({bankAccountIds:a}),W(e.data.accounts,"bill_pay")),p(...n)}return p(df(e.status))})),v((e=>p(df(f("Unexpected error","Fetch Bank Accounts REST API call errored out"+JSON.stringify(e)))))))}))),(s,i)=>s.pipe(S(Z$.match),y((r=>{const{cacheOverride:t}=r.payload,e=[],a=i.value,n=H(a),o=!!n.companyZeniAccountInfo?.info?.isZeniAccountEnabled;if(t===!0)e.push(ic()),e.push(Ge()),o===!0&&e.push(ke());else{const c=a.settingsViewState.bankConnection;c.fetchState!=="Completed"&&c.fetchState!=="In-Progress"&&e.push(ic());const d=a.paymentAccountListState;d.hasValidState()===!1&&d.fetchState!=="In-Progress"&&e.push(Ge());const l=a.depositAccountListState;o===!0&&l.hasValidState()===!1&&l.fetchState!=="In-Progress"&&e.push(ke())}return j(_(e))}))),(s,i,r)=>s.pipe(S(_A.match),A((t=>{const{bankAccountIban:e,cacheOverride:a}=t.payload,n=i.value.bankAccountViewState,o=n.bankCountryNamebyIban[e]?.countryName;if(a===!1&&o)return p(hA(e));{const c={iban:t.payload.bankAccountIban};return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`).pipe(y((d=>T(d)?p(SA({bankAccountIban:t.payload.bankAccountIban,institutions:d.data?.institutions??[]})):p(ip({bankAccountIban:e,status:d.status})))),v((d=>p(ip({bankAccountIban:e,status:f("Unexpected Error","Get Bank Country Name REST API call errored out"+JSON.stringify(d))})))))}}))),(s,i,r)=>s.pipe(S(gA.match),A((t=>{const{routingNumber:e,cacheOverride:a}=t.payload,n=i.value.bankAccountViewState,o=n.bankNameByRouting[e]?.bankName;if(a===!1&&o)return p(fA(e));{const c={routing_numbers:[t.payload.routingNumber]};return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`).pipe(y((d=>T(d)?p(vA({routingNumber:t.payload.routingNumber,institutions:d.data?.institutions??[]})):p(cp({routingNumber:e,status:d.status})))),v((d=>p(cp({routingNumber:e,status:f("Unexpected Error","Get Bank Name By Routing REST API call errored out"+JSON.stringify(d))})))))}}))),(s,i,r)=>s.pipe(S(IA.match),A((t=>{const{swiftCode:e,cacheOverride:a}=t.payload,n=i.value.bankAccountViewState,o=n.bankNameBySwift[e]?.bankName;if(a===!1&&o)return p(bA(e));{const c={swift_code:t.payload.swiftCode};return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`).pipe(y((d=>T(d)?p(EA({swiftCode:t.payload.swiftCode,institutions:d.data?.institutions??[]})):p(dp({swiftCode:e,status:d.status})))),v((d=>p(dp({swiftCode:e,status:f("Unexpected Error","Get Bank Name By Swift REST API call errored out"+JSON.stringify(d))})))))}}))),(s,i)=>s.pipe(S(Ec.match),y((r=>{const{billId:t,cacheOverride:e,isShowDeletedBillsEnabled:a,hasZeniAssistAccess:n}=r.payload,o=i.value,c=[];if(e)c.push(pc(t,a,n,!0)),c.push(Pc(t));else{let d=0;const l=Ne(t),u=X(o.billDetailViewState.billDetailById,l,void 0);(u==null||u?.fetchState!="In-Progress"&&u?.fetchState!="Completed"||u?.vendorId==null)&&(d++,c.push(pc(t,a,!1))),d==0?c.push(Tc(t)):c.push(Pc(t))}return _(c)}))),(s,i,r)=>s.pipe(S(pc.match),y((t=>{const{billId:e,isShowDeletedBillsEnabled:a,cacheOverride:n}=t.payload,o=Ne(e),c=[],d=i.value;if(n===!0){const u=X(d.billDetailViewState.billDetailById,o,void 0);c.push(...(function(m,h){const g=[];return g.push(BR(m)),h!=null&&g.push(lc(Ne(m))),g})(e,u))}const l=X(d.billDetailViewState.billDetailById,o,void 0);if(n==1||l==null||l.fetchState!=="In-Progress"){c.push(Lr(e,"In-Progress")),c.push(yn(e,"bill_pay",n));const u={transaction_type:"bill",bill_pay_provider:"zeni",is_include_payment_accounts_info:!0,is_include_approval_info:!0,is_include_vendor_info:!0,is_include_deleted:a},m=r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}?query=${encodeURIComponent(JSON.stringify(u))}`).pipe(y((h=>{if(T(h)&&h.data?.transaction?.transaction_id!=null){const g=h.data.transaction.transaction_id,I=h.data?.vendors?.[0],b=I?.contacts??[],E=dt(h.data?.vendors??[]),P=I?.bank_accounts??[],O=I?.payment_instruments??[],C=I?.account!=null?[I?.account]:[],U=I?.accounting_class!=null?[I?.accounting_class]:[],B=[...JK(h.data.transaction),mc(h.data.recurring_bill_configs),Bf(h.data.recurring_bills),mn(h.data.transaction),Se(h.data.payment_accounts),Qe(h.data.deposit_accounts),W(h.data.accounts??[],"bill_pay"),V({users:h.data.users??[]}),We(h.data.approval_rules),Et(h.data.entity_approvals),W(C,"account_list"),Ke("class_list",U),mt(b),z(E),Je([...P,...h.data.bank_accounts]),la(O),le(h.data.vendors??[])];if(I==null&&h.data.transaction.candidate_vendor_name!=null&&h.data.transaction.candidate_vendor_name.length>0)B.push(wt({searchString:h.data?.transaction.candidate_vendor_name})),B.push(kf(e,h.data,void 0));else{B.push(yc({billId:e,billDetail:h.data})),B.push(Lr(g,"Completed",void 0,I?.vendor_id));const x=h.data?.transaction;x!=null&&x.total_amount!=null&&I!=null&&B.push(_c(I.vendor_name,I.vendor_id,x.total_amount,x.recipient_total_amount,x.document_id,e)),["failed","cancelled","returned"].includes(x.bill_pay_info.bill_payment_status.code??"")&&t.payload.hasZeniAssistAccess&&B.push(Df(e,!0))}return _(B)}return p(Lr(t.payload.billId,"Error",h.status))})),v((h=>(console.error(`REST API call errored out ${h}`),p(Lr(t.payload.billId,"Error",f("Unexpected Error",`REST API call errored out ${h}`)))))));return j(_(c),m)}return _(c)}))),s=>s.pipe(S(X$.match),A((i=>{const{companyId:r}=i.payload;return _([Io(),cc("billing","billing_setup",!1),lf(r,!1)])}))),(s,i)=>s.pipe(S($R.match),y((r=>{const t=[],e=["draft","pending_approval","scheduled","paid"],a=i.value,{tenantState:n,companyState:o}=a,{currentTenantId:c}=n,d=c!=null?n.tenantsById?.[c]?.companyId:void 0,l=Te(o,d??""),u=l?.company.companyZeniAccountInfo.isZeniAccountEnabled??!1,{period:m,cacheOverride:h,isShowDeletedBillsEnabled:g,isInternationalWireEnabled:I}=r.payload;if(h===!0)t.push(Fr(I)),e.forEach((b=>t.push(Sc(m,b,g))));else{a.billPayConfigState.fetchState!=="Completed"&&a.billPayConfigState.fetchState!=="In-Progress"&&t.push(Fr(I));const b=a.depositAccountListState;u&&b.fetchState!=="In-Progress"&&b.fetchState!=="Completed"&&t.push(ke());const E=a.paymentAccountListState;E.fetchState!=="In-Progress"&&E.fetchState!=="Completed"&&t.push(Ge()),e.forEach((P=>{const O=RR(m,P),C=X(a.billListState.byBillListKey,O,void 0);C!=null&&C.hasValidState()!==!1||t.push(Sc(m,P,g))}))}return _(t)}))),(s,i,r)=>s.pipe(S(Sc.match),y((t=>{const{period:e,tab:a,isShowDeletedBillsEnabled:n}=t.payload,o={start_date:ae(e.start),end_date:ae(e.end),sort_by:"transaction_date",sort_order:"desc",bill_pay_provider:"zeni",transaction_type:"bill",bill_stage_code:a,is_include_pending_approval_transaction_ids_for_user:a==="pending_approval",is_include_approval_info:a==="pending_approval",is_include_deleted:!!n&&a!=="draft"};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[];return d.push(V({users:c.data.users??[]}),mc(c.data.recurring_bill_configs),gc(c.data.transactions),MR({billList:c.data,tab:a}),Et(c.data.entity_approvals??[])),_(d)}return p($f(e,a,c.status))})),v((c=>p($f(t.payload.period,t.payload.tab,f("Unexpected Error","fetch bills REST API call errored out"+JSON.stringify(c)))))))}))),(s,i)=>s.pipe(S(jR.match),y((r=>{const{cacheOverride:t,includeUserRoles:e}=r.payload,{billPaySetupApproverViewState:a,classListState:n}=i.value,{approverListState:o}=a,c=pt(i.value),d=[];return t===!0?(d.push(fc(t,e)),c&&d.push(se())):(a.hasValidState()===!1&&o.fetchStatus.fetchState!=="In-Progress"&&d.push(fc(!0,e)),c&&n.hasValidState()===!1&&n.fetchState!=="In-Progress"&&d.push(se())),j(_(d))}))),(s,i,r)=>s.pipe(S(fc.match),A((t=>{const{cacheOverride:e,includeUserRoles:a}=t.payload,{billPaySetupApproverViewState:n}=i.value,o=n.approverListState.approverIds;if(e===!0||o.length===0)return r.getJSON(`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approvers?query={"is_include_user_roles_info":${a}}`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data.users.map((u=>u.user_id)),l=[V({users:c.data.users})];return a===!0&&l.push(Y(c.data.user_roles)),l.push(Lf(d,c.data.attributes)),_(l)}return p(Ff(c.status))})),v((c=>p(Ff(f("Unexpected Error","Fetch Approvers List errored out"+JSON.stringify(c)))))));{const{approverListState:c}=n,{approverIds:d,attributes:l}=c;return p(Lf(d,l))}}))),(s,i,r)=>s.pipe(S(go.match),y((()=>{const t=ua({startDate:ee(up,"YYYY-MM-DD"),endDate:ee(lp,"YYYY-MM-DD")}),e={start_date:ae(t.start),end_date:ae(t.end),sort_by:"transaction_date",sort_order:"desc",bill_pay_provider:"zeni",transaction_type:"bill",bill_stages:{pending_approval:["awaiting_approval","awaiting_my_approval"],paid:["all"],scheduled:["all"],draft:["all"]},get_count_only:!0,is_include_approval_info:!0,is_include_pending_approval_transaction_ids_for_user:!0,is_exclude_bills_processed_outside_zeni:!0};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bill-pay-card?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>T(a)&&a.data!=null?p(PA({transactionTotals:a.data.transaction_totals,transactionCount:a.data.transaction_count})):p(pp(a.status)))),v((a=>p(pp(f("Unexpected Error","fetch Billpay Dashboard Card REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Fr.match),y((t=>r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bill-pay/config?query=${encodeURIComponent(JSON.stringify({bill_pay_provider:"zeni",transaction_type:"bill",is_include_events:!0,is_include_payment_accounts_info:!0}))}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=[];return a.push(VR({billPayConfigPayload:e.data,isInternationalWireEnabled:t.payload.isInternationalWireEnabled})),_(a)}return p(Rf(e.status))})),v((e=>p(Rf(f("Unexpected Error","fetch bill-pay config REST API call errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(vc.match),A((t=>{const{cacheOverride:e,useV3:a}=t.payload,{billPaySetupApproverViewState:n,approvalRuleState:o,classListState:c}=i.value,d=pt(i.value),l=qf(o,n.approvalRuleIds),u=d&&(e===!0||c.hasValidState()===!1&&c.fetchState!=="In-Progress");if(e===!0||l.length!==n.approvalRuleIds.length||n.hasValidState()===!1&&n.fetchState!=="In-Progress"){const m=a===!0?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;return r.getJSON(m).pipe(y((h=>{if(T(h)&&h.data!=null){const g=h.data.approval_rules.map((b=>b.approval_rule_id)),I=[V({users:h.data.users}),We(h.data.approval_rules),jf(g)];return u&&I.push(se()),_(I)}return p(Gf(h.status))})),v((h=>p(Gf(f("Unexpected Error","Fetch Approval view errored out"+JSON.stringify(h)))))))}{const{approvalRuleIds:m}=n,h=[jf(m)];return u&&h.push(se()),_(h)}}))),(s,i,r)=>s.pipe(S(QR.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{billPaySetupViewState:o,companyState:c,plaidAccountViewState:d}=i.value,l=Te(c,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"bill_pay_setup"}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=u.data.accounts.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses),ve({files:u.data.files}),W(u.data.accounts,"bill_pay"),Se(u.data.payment_accounts),Ht({data:u.data.payment_accounts,updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"replace"}),we({companyId:u.data.companies[0].company_id}),rt(m,"bill_pay_setup"),ev()];return _(h)}return p(N({messageSection:"bill_pay_setup",messageText:"failed",type:"error"}),tv(u.status))})),v((u=>p(tv(f("Unexpected Error","Fetch Bill Pay Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=d.spend_management_setup.accountDetails;return p(we({companyId:e}),rt(u,"bill_pay_setup"),ev())}}))),(s,i,r)=>s.pipe(S(ci.match),y((()=>{const t=i.value.expenseAutomationMissingReceiptsViewState.bulkUpload,{currentBatchId:e}=t;return e==null?p(di({error:f("Unexpected Error","No current batch ID available")})):Cy(t.batchStatusById,t.batchListByPeriod,e)?r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${e}`).pipe(y((a=>{if(!T(a)||a.data==null||!zn(a.data.status))return T(a)&&a.data!=null?F:p(di({error:a.status}));const n=[],o=Kn(a.data.files);return o.length>0&&n.push(Ce(o,(c=>c.transaction_id))),n.push(Aa(Yn(a.data,r.apiEndPoints.fileMicroServiceBaseUrl))),n.push(Pr({cacheOverride:!0})),_(n)})),v((a=>p(di({error:f("Unexpected Error","Fetch batch details errored out: "+JSON.stringify(a))}))))):F}))),(s,i,r)=>s.pipe(S(Pr.match),A((t=>{const{cacheOverride:e}=t.payload,a=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:n},expenseAutomationMissingReceiptsViewState:{bulkUpload:o}}=a,c=n[H(a).tenantId],d=Ee(c),l=o.batchListByPeriod[d]??[];if(e!==!0&&l.length>0)return p(Js({batchList:l,selectedPeriod:c}));const{end:u,start:m}=Al(xy),h={start_date:m,end_date:u,sort_order:"desc"};return r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(h))}`).pipe(y((g=>T(g)&&g.data!=null?p(Js({batchList:g.data.batches.map(Uy),selectedPeriod:c})):p(ky({error:g.status,selectedPeriod:c})))),v((g=>p(ky({error:f("Unexpected Error","Fetch bulk upload batches errored out: "+JSON.stringify(g)),selectedPeriod:c})))))}))),(s,i,r)=>s.pipe(S(hb.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses`).pipe(y((t=>T(t)&&t.data!=null?p(_q({cannedResponses:(t.data.canned_responses??[]).map(eY)})):p(Sb({fetchState:"Error",error:t.status})))),v((t=>p(Sb({fetchState:"Error",error:f("Unexpected Error","Fetch Canned Responses errored: "+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(fo.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/card_balance`).pipe(y((t=>T(t)?p(W(t.data?.report.accounts??[],"card_balance"),TA(t.data)):p(mp(t.status)))),v((t=>p(mp(f("Unexpected error","Card Balance REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(sM.match),$t((t=>{const e=t.payload;return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${e}`).pipe(y((a=>{if(M(a)&&a.data!=null){const{template:n}=a.data,o=nM(oM(n)),c=[Rc(n),iM(o),Mc({fetchState:"Completed"})];return _(c)}return p(Mc({fetchState:"Error",error:a.status}))})),v((a=>p(Mc({fetchState:"Error",error:f("Unexpected Error","Fetch card-policy detail REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(pM.match),$t((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates`).pipe(y((t=>{if(M(t)&&t.data!=null){const e=mM(t.data),a=yM(t.data.stats),n=[_M(e),hM(a),Lc({fetchState:"Completed",templateIds:e.map((o=>o.templateId))})];return _(n)}return p(Lc({fetchState:"Error",error:t.status}))})),v((t=>p(Lc({fetchState:"Error",error:f("Unexpected Error","Fetch card-policy list REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(Ev.match),$t((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/mcc-codes`).pipe(y((t=>M(t)&&t.data!=null?_([AM(t.data)]):p(Pv(t.status)))),v((t=>p(Pv(f("Unexpected Error","Fetch card policy MCC categories REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(lP.match),A((t=>{const e={view:"vendor_list",page_token:null,sort_by:"year_to_date_spend",sort_order:"desc",search_text:a=t.payload.searchString,vendor_name:a};var a;const n=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors?query=${encodeURIComponent(JSON.stringify(e))}`;return r.getJSON(n).pipe(A((o=>M(o)&&o.data!=null?p(uP(o.data)):p(Hl(o.status)))),v((o=>p(Hl(f("Unexpected Error","Fetch card policy vendor options REST API call errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(vO.match),A((()=>{const t=`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cockpit/card-tenant-profiles`;return r.getJSON(t).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.rows;return _([IO(a),bO(a)])}return p(km(e.status))})),v((e=>p(km(f("Unexpected error","REST API call errored out: "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Fc.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/cashback?query=${encodeURIComponent('{"is_include_cashback_insights":true}')}`).pipe(y((t=>M(t)&&t.data!=null?p(o_([t.data.insights]),BM(t.data)):p(Ov(t.status)))),v((t=>p(Ov(f("Unexpected Error","Fetch charge card cashback REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Po.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/cash_balance`).pipe(y((t=>T(t)?p(W(t.data?.report.accounts??[],"cash_balance"),kA(t.data)):p(Sp(t.status)))),v((t=>p(Sp(f("Unexpected error","Cash Balance REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(BA.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Dt("month",!0),Dt("quarter",!0),Dt("year",!0)]);{const e=[],a=i.value.cashFlowClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Dt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Dt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Dt("year")),_(e)}}))),(s,i)=>s.pipe(S(To.match),A((r=>{const{fetchFullReport:t,cacheOverride:e}=r.payload;if(e===!0)return _([Bt("month",t),Bt("quarter",t),Bt("year",t)]);{const a=[],n=i.value.cashFlowState.fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(Bt("month",t)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(Bt("quarter",t)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(Bt("year",t)),_(a)}}))),(s,i,r)=>s.pipe(S(Dt.match),y((t=>{const e={is_full_response:!0,time_series_groups:[Iz(t.payload.timeframe)],is_group_by_class:!0,...t.payload.cacheOverride===!0?{is_hard_refresh:!0}:{}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/cash_flow?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],{report:o}=a.data,c=o.currency;return n.push(oe(t.payload.timeframe,Fe("adjustments"),"cash_flow_by_classes",o.operating_activities.adjustments,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("investing_activities"),"cash_flow_by_classes",o.investing_activities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("financing_activities"),"cash_flow_by_classes",o.financing_activities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("net_income"),"cash_flow_by_classes",o.operating_activities.net_income,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("operating_activities"),"cash_flow_by_classes",o.operating_activities,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,Fe("change_in_cash_and_equivalents"),"cash_flow_by_classes",o.change_in_cash_and_equivalents,o.classes,o.accounts,c)),n.push(DA({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(gp(a.status,t.payload.timeframe))})),v((a=>p(gp(f("Unexpected Error","Cash Flow by Class REST API call errored out: "+(a instanceof Error?a.message:JSON.stringify(a))),t.payload.timeframe)))))}))),BG,(s,i,r)=>s.pipe(S(Jt.match),y((t=>{const e={is_full_response:!0,time_series_groups:[bz(t.payload.timeframe)],is_group_by_project:!0,...t.payload.cacheOverride===!0?{is_hard_refresh:!0}:{}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/cash_flow?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],{report:o}=a.data,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,Fe("adjustments"),"cash_flow_by_projects",o.operating_activities.adjustments,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("investing_activities"),"cash_flow_by_projects",o.investing_activities,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("financing_activities"),"cash_flow_by_projects",o.financing_activities,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("net_income"),"cash_flow_by_projects",o.operating_activities.net_income,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("operating_activities"),"cash_flow_by_projects",o.operating_activities,o.accounts,c)),n.push(ie(t.payload.timeframe,Fe("change_in_cash_and_equivalents"),"cash_flow_by_projects",o.change_in_cash_and_equivalents,o.accounts,c)),n.push(JA({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(fp(a.status,t.payload.timeframe))})),v((a=>p(fp(f("Unexpected Error","Cash Flow by Project REST API call errored out: "+(a instanceof Error?a.message:JSON.stringify(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(wA.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Jt("month",!0),Jt("quarter",!0),Jt("year",!0)]);{const e=[],a=i.value.cashFlowProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Jt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Jt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Jt("year")),_(e)}}))),(s,i,r)=>s.pipe(S(Ao.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/cash_in_cash_out`).pipe(y((t=>T(t)?p(W(t.data?.report.accounts??[],"cash_in_cash_out"),RA(t.data?.report.account_groups??[],"cash_in_cash_out"),$A(t.data),vp({thisPeriod:i.value.reportUIOptionsState.thisPeriod})):p(Ip(t.status)))),v((t=>p(Ip(f("Unexpected error","CashInCashOut REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(No.match),A((t=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/cash_position?query=${encodeURIComponent(`{"is_full_response":${t.payload.fetchFullReport}}`)}`).pipe(y((e=>T(e)?p(W(e.data?.report.accounts??[],"cash_position"),MA(e.data),bp({thisPeriod:i.value.reportUIOptionsState.thisPeriod})):p(Ep(e.status)))),v((e=>p(Ep(f("Unexpected error","Cash Position REST API call errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(Wt.match),y((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/config`).pipe(y((t=>{if(M(t)&&t.data!=null){const e=[];return e.push(DM(t.data)),_(e)}return p(Cv(t.status))})),v((t=>p(Cv(f("Unexpected Error","Fetch charge card config REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(jc.match),A((t=>{const{chargeCardId:e,cacheOverride:a}=t.payload,n=[],o=i.value,c=X(o.chargeCardDetailState.detailById,e,void 0);if(a===!0||c==null||c.fetchState!=="In-Progress"){const d=a===!0&&c!=null&&c.fetchState!=="Not-Started";n.push(In({chargeCardId:e,isRefreshingViewInBackground:d,fetchState:d?c.fetchState:"In-Progress",error:d?c.error:void 0}));const l={is_include_card_activation_events:!0,is_include_connected_account_info:!0,is_include_card_pin_change_attempt_history:!0},u=r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}?query=${JSON.stringify(l)}`).pipe(y((m=>M(m)&&m.data!=null?p(st(m.data.card),V({users:m.data.users}),Y(m.data.user_roles),z(m.data.addresses),wM(m.data.connected_account),In({chargeCardId:e,isRefreshingViewInBackground:!1,fetchState:"Completed"})):p(In({chargeCardId:e,fetchState:"Error",isRefreshingViewInBackground:!1,error:m.status})))),v((m=>p(In({chargeCardId:e,fetchState:"Error",isRefreshingViewInBackground:!1,error:f("Unexpected Error","Fetch card detail API call errored out"+JSON.stringify(m))})))));return j(_(n),u)}return _(n)}))),(s,i)=>s.pipe(S($M.match),y((r=>{const{chargeCardId:t,cacheOverride:e,doFetchCreditAccounts:a,isCreditCardEnabled:n}=r.payload,o=[],c=i.value,d=c.chargeCardDetailState.detailById[t],l=d!=null?d.transactionList.uiState.pageToken:null,u=d!=null?d.transactionList.uiState.pageTokenType:null;if(e===!0)o.push(jc(t,e)),o.push(Gc(t,null,null,!0)),o.push(Wt(!0)),a&&n&&o.push(Zt(!0)),a&&n&&o.push(qr(!0));else{const m=c.chargeCardDetailState.detailById[t];(m==null||m.fetchState!=="In-Progress"&&m.hasValidState()===!1)&&o.push(jc(t,e));const h=m?.transactionList;(h==null||h.fetchState!=="Completed"&&h.fetchState!=="In-Progress")&&o.push(Gc(t,l,u));const g=c.chargeCardConfigState;g.fetchState!=="In-Progress"&&g.hasValidState()===!1&&o.push(Wt());const I=c.chargeCardListState;I.creditAccount.fetchState!=="Completed"&&I.creditAccount.fetchState!=="In-Progress"&&a&&n&&o.push(Zt()),I.creditAccountRepayment.fetchState!=="Completed"&&I.creditAccountRepayment.fetchState!=="In-Progress"&&a&&n&&o.push(qr())}return j(_(o))}))),(s,i,r)=>s.pipe(S(jr.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards?query=${encodeURIComponent('{"is_include_total_cash_back":true, "is_include_unassigned_credit": true}')}`).pipe(y((t=>{if(M(t)&&t.data!=null){const e=[];return H(i.value).userRole.includes("charge_card_user")&&e.push(rV({uiState:{sortKey:"cardName"}})),e.push(qa(t.data.cards),V({users:t.data.users}),Y(t.data.user_roles),z(t.data.addresses),Bv({chargeCardListPayload:t.data})),_(e)}return p(Dv(t.status))})),v((t=>p(Dv(f("Unexpected Error","Fetch charge cards list REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(sV.match),y((r=>{const{doFetchCreditAccountsDebitSummaryAndCashback:t,isDebitCardEnabled:e,isCreditCardEnabled:a,cacheOverride:n}=r.payload,o=[],c=i.value,d=c.cashbackDetailState;if(n===!0)t===!0&&(a&&(o.push(Zt(!0)),o.push(qr(!0))),e&&o.push(rd(!0)),o.push(Fc(!0))),o.push(jr(!0)),o.push(Wt(!0)),o.push($e("cardHolderCandidate",!0)),o.push($e("cardAdmin",!0)),o.push(se());else{const l=c.chargeCardListState;t===!0&&a&&l.creditAccount.fetchState!=="Completed"&&l.creditAccount.fetchState!=="In-Progress"&&o.push(Zt()),t===!0&&a&&l.creditAccountRepayment.fetchState!=="Completed"&&l.creditAccountRepayment.fetchState!=="In-Progress"&&o.push(qr()),t&&d.fetchState!=="In-Progress"&&d.hasValidState()===!1&&o.push(Fc()),l.fetchState!=="In-Progress"&&l.hasValidState()===!1&&o.push(jr());const u=c.chargeCardConfigState;u.fetchState!=="In-Progress"&&u.hasValidState()===!1&&o.push(Wt());const m=c.userListViewState.userListByType.cardHolderCandidate;m.fetchState!=="In-Progress"&&m.hasValidState()===!1&&o.push($e("cardHolderCandidate",!1));const h=c.userListViewState.userListByType.cardAdmin;if(h.fetchState!=="In-Progress"&&h.hasValidState()===!1&&o.push($e("cardAdmin",!1)),c.classListState.hasValidState()===!1&&c.classListState.fetchState!=="In-Progress"&&o.push(se()),t&&e&&c.chargeCardListState.debitCardSummaries.fetchState!=="In-Progress"&&c.chargeCardListState.debitCardSummaries.fetchState!=="Completed"&&o.push(rd()),t&&e&&c.issueChargeCardState.depositAccountsFetchState.fetchState!=="In-Progress"&&c.issueChargeCardState.depositAccountsFetchState.fetchState!=="Completed"&&o.push(bn()),t&&c.chargeCardSetupViewState.fetchState!=="In-Progress"&&c.chargeCardSetupViewState.fetchState!=="Completed"){const g=H(c);o.push(Jv(g.companyId,!0))}}return j(_(o))}))),(s,i,r)=>s.pipe(S(cd.match),A((()=>{const t=encodeURIComponent(JSON.stringify({include_history:!0}));return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments?query=${t}`).pipe(y((e=>M(e)&&e.data!=null?p(SV(e.data.repayment_history),V({users:e.data.repayment_history.map((a=>a.paid_by_user)).filter((a=>a!=null))}),hV(e.data)):p(Lv(e.status)))),v((e=>p(Lv(f("Unexpected Error","Fetch charge card payment history REST API call errored out"+JSON.stringify(e)))))))}))),(s,i)=>s.pipe(S(gV.match),y((r=>{const{cacheOverride:t}=r.payload,e=[],a=i.value,n=a.chargeCardPaymentHistoryState;t===!0?e.push(cd(!0)):n.fetchState!=="Completed"&&n.fetchState!=="In-Progress"&&e.push(cd());const o=a.depositAccountListState,c=a.paymentAccountListState;return(o.fetchState!=="Completed"&&o.fetchState!=="In-Progress"||c.fetchState!=="Completed"&&c.fetchState!=="In-Progress")&&e.push(Fv()),j(_(e))}))),(s,i)=>s.pipe(S(Fv.match),y((()=>{const r=[],t=i.value,e=t.depositAccountListState;e.fetchState!=="In-Progress"&&e.fetchState!=="Completed"&&r.push(ke());const a=t.paymentAccountListState;return a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&r.push(Ge()),_(r)}))),(s,i,r)=>s.pipe(S(Jv.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{chargeCardSetupViewState:o,plaidAccountViewState:c,companyState:d}=i.value,l=Te(d,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"charge_cards_setup"}`).pipe(y((u=>{if(M(u)&&u.data!=null){const m=u.data.accounts.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses),ve({files:u.data.files}),W(u.data.accounts,"charge_cards"),Se(u.data.payment_accounts),Ht({data:u.data.payment_accounts,updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"merge"}),we({companyId:u.data.companies[0].company_id}),rt(m,"charge_card_setup"),zv()];return _(h)}return p(N({messageSection:"charge_card_setup",messageText:"failed",type:"error"}),Kv(u.status))})),v((u=>p(Kv(f("Unexpected Error","Fetch Charge Card Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=c.spend_management_setup.accountDetails;return p(we({companyId:e}),rt(u,"charge_card_setup"),zv())}}))),(s,i,r)=>s.pipe(S(GM.match),A((t=>{const{cardIds:e}=t.payload,a={card_ids:e};return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/recurring-expenses?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>{if(T(n)&&n.data!=null){const o={};return n.data.forEach((c=>{o[c.card_id]=c.expenses.map((d=>zM(d)))})),p(KM({recurringExpensesByChargeCardId:o}),Kc({fetchState:"Completed",error:void 0}))}return p(Kc({fetchState:"Error",error:n.status}))})),v((n=>p(Kc({fetchState:"Error",error:f("Unexpected Error","Fetch Charge Cards Recurring Expenses REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(BV.match),y((t=>{const{creditAccountId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/credit-accounts/${e}/statements`).pipe(y((a=>T(a)?p(DV({data:a.data?.statements??[]})):p(Yv({fetchState:"Error",error:a.status})))),v((a=>p(Yv({fetchState:"Error",error:f("Unexpected Error","Fetch Credit Card statement REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(RM.match),A((t=>{const{transactionId:e,cardId:a,attachmentIds:n}=t.payload;let o=`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/transactions/${e}/attachments`;return o+=`?query=${encodeURIComponent(JSON.stringify({attachment_ids:n}))}`,r.getJSON(o).pipe(y((d=>M(d)&&d.data!=null?p(MM({transactionId:e,cardId:a,transactionAttachments:d.data.attachments})):p(xv({cardId:a,transactionId:e,status:d.status})))),v((d=>p(xv({cardId:a,transactionId:e,status:f("Unexpected Error","Fetch charge card transaction attachments API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(Gc.match),A((t=>{const{chargeCardId:e,pageToken:a,pageTokenType:n,cacheOverride:o}=t.payload,{uiState:c}=i.value.chargeCardDetailState.detailById[e]?.transactionList??VM.transactionList,d={page_token:a,page_token_type:n,sort_by:c.sortKey==="paymentDate"?"transaction_date":c.sortKey,sort_order:Vo(c.sortOrder)};return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/transactions?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>M(l)&&l.data!=null?p(FM(l.data.transactions),LM({chargeCardId:e,data:l.data,cacheOverride:o})):p(Uv({chargeCardId:e,error:l.status})))),v((l=>p(Uv({chargeCardId:e,error:f("Unexpected Error","Fetch charge card transactionList API call errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(qM.match),A((t=>{const{chargeCardId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/analytics/transaction-statistics`).pipe(y((a=>T(a)&&a.data?p(jM({chargeCardId:e,statistics:a.data}),zc({chargeCardId:e,fetchState:"Completed",error:void 0})):p(zc({chargeCardId:e,fetchState:"Error",error:a.status})))),v((a=>p(zc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Fetch Charge Card Transaction Statistics REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(fT.match),y((t=>{const{chatSessionId:e,userId:a}=t.payload,n=i.value,o=n.aiCfoViewState.uiState.chatHistoryNextPageToken[e]?.nextPageToken??null,c=new URLSearchParams;return c.append("page_size","20"),c.append("chat_session_id",e),c.append("user_id",a),o!=null&&c.append("page_token",o),r.getJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/history?${c.toString()}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.next_page_token==null;return p(IT({chatSessionId:e,history:d.data.messages,isPaginationComplete:l}),vT({chatSessionId:e,nextPageToken:d.data.next_page_token}))}return p(ku({chatSessionId:e,error:d.status}))})),v((d=>p(ku({chatSessionId:e,error:f("Unexpected Error","Fetch Chat History REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(bT.match),A((()=>{const t=i.value.aiCfoViewState.uiState.chatSessionsNextPageToken.nextPageToken??null,e=new URLSearchParams;return e.append("page_size","50"),t!=null&&e.append("page_token",t),r.getJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/sessions?${e.toString()}`).pipe(y((a=>{if(T(a)&&a.data!=null){const n=a.data.sessions.filter((o=>!!o.chat_session_summary));return p(PT(n),ET({sessions:n,nextPageToken:a.data.next_page_token}))}return p(Bu(a.status))})),v((a=>p(Bu(f("Unexpected Error","Fetch Chat Sessions for User REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(se.match),Le(i),A((([t,e])=>{if(!pt(e))return p(Pp({status:f("Success",""),data:{accounting_classes:[]}}));const{isIncludeDeleted:a}=t.payload,n=a===!0?`?query=${encodeURIComponent(JSON.stringify({is_include_deleted:!0}))}`:"";return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/classes${n}`).pipe(y((o=>T(o)?p(Ke("class_list",o.data?.accounting_classes??[]),Pp(o)):p(Tp(o.status)))),v((o=>p(Tp(f("Unexpected Error","Fetch Classes REST API call errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(TN.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/cockpit-context`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=t.data?.companies??[],a=t.data?.users??[],n=t.data?.user_groups??[],o=e.map((u=>u.company_id)),c=a.map((u=>u.user_id)),d=n.map((u=>u.id)),l=[Q({payload:t.data.companies,schema:{}}),V({users:t.data.users}),em({userGroups:t.data.user_groups}),AN({companyIds:o,userIds:c,userGroupIds:d})];return _(l)}return p(tm(t.status))})),v((t=>p(tm(f("Unexpected error","Cockpit context fetch errored out"+JSON.stringify(t)))))))))),DG,(s,i,r)=>s.pipe(S(lf.match),A((t=>{const{companyId:e,cacheOverride:a}=t.payload,{settingsViewState:n,companyState:o}=i.value,c=Te(o,e)?.company;return a===!0||c==null||n.billingAddress.fetchState!=="In-Progress"?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"subscription_billing_address"}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[Q({payload:d.data.companies,schema:{}}),z(d.data.addresses),uf(),eR("subscription_billing_address")],u=d.data.companies[0].subscription_billing_address_id,m=d.data.addresses.find((h=>h.address_id===u));return m!=null&&l.push(qe({addressType:"subscription_billing_address",addressToCreate:tR(m)})),_(l)}return p(N({messageSection:"billing_address_view",messageText:"failed",type:"error"}),pf(d.status))})),v((d=>p(pf(f("Unexpected Error","Fetch Billing Address View errored out"+JSON.stringify(d))))))):p(uf())}))),JG,(s,i,r)=>s.pipe(S($o.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-health-metrics/config`).pipe(y((t=>T(t)&&t.data!=null?p(nN(t.data.additional_churn_factors)):p($p(t.status)))),v((t=>p($p(f("Unexpected Error","Fetch company health metric config REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Ro.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/health-monitor`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[],a=t.data.companies.map((n=>n.company_id));return e.push(Q({payload:t.data.companies,schema:{}})),e.push(Rp({payload:t.data.company_health_metrics})),e.push(oN({companyIds:a})),_(e)}return p(Mp({error:t.status}))})),v((t=>p(Mp({error:f("Unexpected Error","Fetch Company Health Metric View REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(fa.match),A((t=>{const e={is_full_response:t.payload.fetchFullResponse};return t.payload.companyParentId!=null&&(e.is_include_subsidiaries=!0,e.company_id=t.payload.companyParentId),r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/management?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(T(a)&&a.data!=null){const n=a.data.companies.map((l=>l.company_id)),o=bl(a.data.subscriptions),c=qo(a.data.user_roles,a.data.companies),d=[Y(a.data.user_roles),Q({payload:a.data.companies,schema:a.data.schema.company,subset:t.payload.companyParentId!=null,companyIdTenantIdMapping:c}),lr({payload:a.data.subscriptions,schema:a.data.schema.subscription}),_a({payload:a.data.subscription_plans,schema:a.data.schema.subscription_plan}),ha({payload:a.data.subscription_addons,schema:a.data.schema.subscription_addon}),Sa({payload:a.data.subscription_summaries,schema:a.data.schema.subscription_summary}),om({payload:a.data.customer_satisfactions}),ZN({tasks:a.data.tasks})];return t.payload.companyParentId==null&&d.push(vs("company_management_view",n,o)),t.payload.companyParentId!=null&&(i.value.companyViewState.managementView.fetchState!=="Completed"&&d.push(vs("company_management_view",n,o,!0)),d.push(XN({payload:a.data.companies,parentCompanyId:t.payload.companyParentId}))),t.payload.fetchFullResponse&&a.data.users!=null&&d.push(V({users:a.data.users})),_(d)}{const n=[ga("company_management_view",[],a.status)];return t.payload.companyParentId!=null&&n.push(Am()),_(n)}})),v((a=>{const n=[ga("company_management_view",[],f("Unexpected error","Company Management view errored out"+JSON.stringify(a)))];return t.payload.companyParentId!=null&&n.push(Am()),_(n)})))}))),wG,(s,i,r)=>s.pipe(S(uN.match),A((t=>{const{companyId:e,reportSentDate:a}=t.payload,n=i.value.companyState.companiesById[e].companyInfo.tenantId,o={history:!0,month_year:a.format(pN)};return n!=null?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/emails/month-end?query=${encodeURIComponent(JSON.stringify(o))}`,{"zeni-tenant-id":n}).pipe(y((c=>{if(T(c)&&c.data?.history!=null){const d=[mN({companyId:e,reportSentDate:a,data:c.data})];return c.data.history.length>0&&d.push(Fp({files:c.data.history[0].files})),_(d)}{const d=[qp({companyId:e,reportSentDate:a,error:c.status})];return _(d)}})),v((c=>{const d=[qp({companyId:e,reportSentDate:a,error:f("Unexpected error","Company Month End Report Historic Data errored out"+JSON.stringify(c))})];return _(d)}))):_([])}))),(s,i,r)=>s.pipe(S(yN.match),A((t=>{const{companyId:e}=t.payload,a=i.value.companyState.companiesById[e].companyInfo.tenantId,n={history_dates:!0};return a!=null?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/emails/month-end?query=${encodeURIComponent(JSON.stringify(n))}`,{"zeni-tenant-id":a}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[_N({companyId:e,data:o.data})];return _(c)}{const c=[jp({companyId:e,error:o.status})];return _(c)}})),v((o=>{const c=[jp({companyId:e,error:f("Unexpected error","Company Month End Report Historic Dates errored out"+JSON.stringify(o))})];return _(c)}))):_([])}))),(s,i,r)=>s.pipe(S(Gp.match),A((t=>{const{companyId:e,tenantId:a}=t.payload,n=i.value,o=a??n.companyState.companiesById[e].companyInfo.tenantId,c={email_templates:!0};return o!=null?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/emails/month-end?query=${encodeURIComponent(JSON.stringify(c))}`,{"zeni-tenant-id":o}).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[hN({companyId:e,data:d.data})];return _(l)}{const l=[zp({companyId:e,error:d.status})];return _(l)}})),v((d=>{const l=[zp({companyId:e,error:f("Unexpected error","Company Month End Report Templates errored out"+JSON.stringify(d))})];return _(l)}))):_([])}))),(s,i,r)=>s.pipe(S(Kp.match),A((t=>{const{cacheOverride:e,companyId:a,tenantId:n,refreshInsights:o,insightDate:c}=t.payload,d=i.value,l=d.companyMonthEndReportViewState.monthEndReportDataByCompanyId[a].fetchState,u=n??d.companyState.companiesById[a].companyInfo.tenantId;if(u==null||e!==!0&&l==="Completed")return _([]);{const m={insight_date:c??null,...o===!0&&{refresh_insights:o}},h=`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${a}/emails/month-end?query=${encodeURIComponent(JSON.stringify(m))}`;return r.getJSON(h,{"zeni-tenant-id":u}).pipe(y((g=>{if(T(g)&&g.data!=null){const I=[SN(a,g.data),Fp({files:g.data.files})];return _(I)}{const I=[Yp(a,g.status)];return _(I)}})),v((g=>{const I=[Yp(a,f("Unexpected error","Company Month End Report View errored out"+JSON.stringify(g)))];return _(I)})))}}))),(s,i,r)=>s.pipe(S(yr.match),A((t=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/onboarding?query=${encodeURIComponent(`{"is_full_response":${t.payload.fetchFullResponse}}`)}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.companies.map((c=>c.company_id)),n=Di(e.data.tenants,e.data.companies),o=[Ji(e.data.tenants),rn({payload:e.data.companies,schema:e.data.schema.company,onboardingInviteStatus:e.data.onboarding_invite_status,companyIdTenantIdMapping:n}),z(e.data.addresses??[]),SS({payload:e.data.parent_companies??[],schema:{}}),wi(e.data.tenants),AD(e.data.is_onboarding_allowed_for_user),$i({onboardingCustomersInfo:e.data.whitelist_companies})];return e.data.users!=null&&o.push(V({users:e.data.users})),e.data.user_roles!=null&&o.push(Y(e.data.user_roles)),o.push(Ri(a)),_(o)}return p(gS([],e.status))})),v((e=>p(gS([],f("Unexpected error","Onboarding Company view errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(dr.match),A((t=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${t.payload.companyId}?query={"view":"passport"}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.companies.map((c=>c.company_id)),n=bl(e.data.subscriptions),o=[V({users:e.data.users}),Y(e.data.user_roles),Q({payload:e.data.companies,schema:e.data.schema.company}),ve({files:e.data.files}),z(e.data.addresses),lr({payload:e.data.subscriptions,schema:e.data.schema.subscription}),_a({payload:e.data.subscription_plans,schema:e.data.schema.subscription_plan}),ha({payload:e.data.subscription_addons,schema:e.data.schema.subscription_addon}),ur({payload:e.data.subscription_coupons,schema:e.data.schema.subscription_coupon}),Sa({payload:e.data.subscription_summaries,schema:e.data.schema.subscription_summary}),um({companyId:t.payload.companyId}),vs("company_passport_view",a,n)];return _(o)}return p(ga("company_passport_view",[],e.status))})),v((e=>p(ga("company_passport_view",[],f("Unexpected error","Company Passport view errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(mr.match),A((t=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/portfolio?query=${encodeURIComponent(`{"is_full_response":${t.payload.fetchFullResponse}}`)}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.companies.map((c=>c.company_id)),n=qo(e.data.user_roles,e.data.companies),o=[Y(e.data.user_roles),Q({payload:e.data.companies,schema:e.data.schema.company,subset:!1,companyIdTenantIdMapping:n}),eO(e.data.accounting_summaries),vs("company_portfolio_view",a,{})];return t.payload.fetchFullResponse&&e.data.users!=null&&o.push(V({users:e.data.users})),_(o)}return p(ga("company_portfolio_view",[],e.status))})),v((e=>p(ga("company_portfolio_view",[],f("Unexpected error","Company Portfolio view errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(fs.match),A((t=>{const{from:e,searchString:a,sortKey:n,sortOrder:o,filters:c}=t.payload,d={size:100,from:e,global_search:a??"",sort_by:Ez(n),sort_order:Vo(o),filter_join:c?.categoryCombinationOperator==="AND"?"and":"or",...c?.categories!=null&&c.categories.length>0?{filter_by:Pz(c)}:{},task_group_scopes:c?.taskGroupScopes!=null&&c.taskGroupScopes.length>0?c.taskGroupScopes:["internal"]};return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/tasks-es?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=l.data.aggregations.group_by_company_name.buckets.flatMap((h=>h.tasks)),m=[NN({data:l.data}),ze(u),Zr(u.flatMap((h=>h.tags)))];return _(m)}{const u=[am(l.status)];return _(u)}})),v((l=>{const u=[am(f("Unexpected error","Cockpit Task manager errored out"+JSON.stringify(l)))];return _(u)})))}))),(s,i,r)=>s.pipe(S(Tr.match),A((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a},expenseAutomationMissingReceiptsViewState:{bulkUpload:n}}=e,o=a[H(e).tenantId],c=Ee(o),d=t.payload.pageToken==null,{sortKey:l,sortOrder:u,completedSubTab:m}=n,h=fx(c,l,u,m),g=n.completedTransactionsByPeriod[h];if(d&&t.payload.cacheOverride!==!0&&g!=null&&g.transactionIds.length>0)return _([]);const I=Re(o),b={start_date:I.start,end_date:I.end,page_token:t.payload.pageToken??null,page_size:25};l!=null&&(b.sort_by=l),u!=null&&(b.sort_order=u==="ascending"?"asc":"desc"),m!==li&&(b.match_type=m);const E=encodeURIComponent(JSON.stringify(b));return r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/receipt-agent/transactions/completed?query=${E}`).pipe(y((P=>{if(T(P)&&P.data!=null){const O=P.data.transactions.map((U=>U.transaction_id)),C=[];return C.push(Ce(P.data.transactions,(U=>U.transaction_id))),C.push(vx({isInitialLoad:d,transactionIds:O,nextPageToken:P.data.next_page_token,totalCount:P.data.total_count,selectedPeriod:o,sortKey:l,sortOrder:u,completedSubTab:m})),_(C)}return p(By({error:P.status,selectedPeriod:o,sortKey:l,sortOrder:u,completedSubTab:m}))})),v((P=>p(By({error:f("Unexpected Error","Fetch completed transactions errored: "+JSON.stringify(P)),selectedPeriod:o,sortKey:l,sortOrder:u,completedSubTab:m})))))}))),(s,i)=>s.pipe(S(kU.match),y((r=>{const{cacheOverride:t}=r.payload,e=i.value,a=e.invoicingCustomerListViewState,n=e.invoicingCatalogListViewState,o=e.invoicingSettingsViewState,c=[];return Rn({fetchState:a.fetchState,error:a.error},t)&&c.push(Ks({filters:{},keepExistingListItems:!1})),Rn({fetchState:n.fetchState,error:n.error},t)&&c.push(Cr({filters:{type:"plan"},keepExistingListItems:!1})),Rn(n.productFetchState,t)&&c.push(gi({filters:{type:"addon|charge"},keepExistingListItems:!1})),Rn({fetchState:o.fetchState,error:o.error},t)&&c.push(Vt()),_(c)}))),(s,i,r)=>s.pipe(S(Zt.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/credit-accounts`).pipe(y((t=>M(t)&&t.data!=null?p(nV(t.data.credit_accounts)):p(wv(t.status)))),v((t=>p(wv(f("Unexpected Error","Fetch creditAccount REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(qr.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments`).pipe(y((t=>M(t)&&t.data!=null?p(oV(t.data)):p($v(t.status)))),v((t=>p($v(f("Unexpected Error","Fetch creditAccountRepayment REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(EO.match),A((()=>{const t=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/macros/credit-agent`;return r.getJSON(t).pipe(y((e=>T(e)&&e.data!=null?_([Bm(e.data),PO()]):p(Dm(e.status)))),v((e=>p(Dm(f("Unexpected error","REST API call errored out: "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(cI.match),y((t=>{const{conversionCurrencyCode:e,reimbursementId:a,lineId:n}=t.payload,o=i.value;let c=o.editRemiDetailViewState.newRemiState.remiDetailLocalData;a!=null&&(c=o.editRemiDetailViewState.editRemiStateById[a].remiDetailLocalData);const d=c.updatesByLineId[n].outOfPocket,l={amount:{amount:d.amount??0,currency_code:d.currencyCode,currency_symbol:d.currencySymbol},home_currency_code:e};return r.postAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/currencies/conversion`,l).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[],h=u.data.home_currency_conversions;return m.push(IL({reimbursementId:a,amountPayload:h,lineId:n})),m.push(md({reimbursementId:a,lineId:n,fetchState:"Completed",error:void 0})),_(m)}return p(md({reimbursementId:a,lineId:n,fetchState:"Error",error:u.status}))})),v((u=>p(md({reimbursementId:a,lineId:n,fetchState:"Error",error:f("Unexpected Error","Fetch Conversion Currency REST API call errored out"+JSON.stringify(u))})))))}))),(s,i)=>s.pipe(S(kO.match),A((r=>{const{userId:t,companyId:e,fetchFullReport:a,cacheOverride:n,excludeResources:o,tenantId:c}=r.payload,d=H(i.value),l=d.company?.featuresActivationInfo.isReimbursementFeatureEnabled,u=!!d?.userRole&&BO(d.userRole),m=DO(d.userRole),h=i.value.arAgingState.uiState.selectedDate,g=i.value.apAgingState.uiState.selectedDate,I=i.value.expenseAutomationViewState.selectedPeriodByTenantId[c]??JO;if(n===!0){const b=[Ia(t),fo(),Po(),Es(a),Ps(a),Ts(a),zo(a),Ko(),No(a),Ao(),Yo(),dr(e),ss(),Ho()];return o.includes("accounts_payable_aging")===!1&&b.push(yo(g)),o.includes("accounts_receivable_aging")===!1&&b.push(_o(h)),m||b.push(go()),l===!0&&u&&b.push(Qo()),o.includes("rewards_card")===!1&&b.push(Wo(!0)),o.includes("expense_automation_card")===!1&&b.push(et({tenantId:c,period:I,refreshViewInBackground:!1})),_(b)}{const b=i.value,E=[],P=$m(b.revenueState.uiState.selectedForecast?.id,b.revenueState),O=Rm(b.opExState.uiState.selectedForecast?.id,b.opExState),C=Mm(b.netBurnOrIncomeState.uiState.selectedForecast?.id,b.netBurnOrIncomeState);b.tenantState.fetchState==="In-Progress"||b.tenantState.hasValidState()||E.push(Ia(t)),b.cardBalanceState.fetchState==="In-Progress"||b.cardBalanceState.hasValidState()||E.push(fo()),b.cashBalanceState.fetchState==="In-Progress"||b.cashBalanceState.hasValidState()||E.push(Po()),O.fetchState!=="In-Progress"&&O.fetchState!=="Completed"&&E.push(Es(a)),P.fetchState!=="In-Progress"&&P.fetchState!=="Completed"&&E.push(Ps(a)),C.fetchState!=="In-Progress"&&C.fetchState!=="Completed"&&E.push(Ts(a)),b.netBurnOrIncomeStoryCardState.fetchState==="In-Progress"||b.netBurnOrIncomeStoryCardState.hasValidState()||E.push(zo(a)),b.topExState.fetchState==="In-Progress"||o.includes("top_expenses")!==!1||b.topExState.hasValidState()||E.push(Ko()),b.cashPositionState.fetchState==="In-Progress"||b.cashPositionState.hasValidState()||E.push(No(a)),b.cashInCashOutState.fetchState==="In-Progress"||b.cashInCashOutState.hasValidState()||E.push(Ao()),b.insightsCardState.fetchState==="In-Progress"||b.insightsCardState.hasValidState()||E.push(Yo()),b.companyViewState.passportView.fetchState==="In-Progress"||b.companyViewState.passportView.hasValidState()||E.push(dr(e)),b.tasksCardState.fetchState==="In-Progress"||o.includes("task_card")!==!1||b.tasksCardState.hasValidState()||E.push(ss()),b.dashboardLayoutState.fetchState!=="In-Progress"&&b.dashboardLayoutState.fetchState!=="Completed"&&E.push(Ho()),b.apAgingState.fetchState!=="In-Progress"&&b.apAgingState.fetchState!=="Completed"&&o.includes("accounts_payable_aging")===!1&&E.push(yo(g)),b.arAgingState.fetchState!=="In-Progress"&&b.arAgingState.fetchState!=="Completed"&&o.includes("accounts_receivable_aging")===!1&&E.push(_o(h)),b.billPayCardState.fetchState==="In-Progress"||b.billPayCardState.hasValidState()||m||E.push(go()),b.reimbursementCardState.fetchState!=="In-Progress"&&!b.reimbursementCardState.hasValidState()&&l===!0&&u&&E.push(Qo()),b.referralViewState.rewardsPlanFetchState.fetchState!=="In-Progress"&&b.referralViewState.rewardsPlanFetchState.fetchState!=="Completed"&&o.includes("rewards_card")===!1&&E.push(Wo(!0));const U=Ee(I);return b.monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[d.tenantId]?.[U]?.fetchState!=="In-Progress"&&b.monthEndCloseChecksViewState.monthEndCloseChecksViewByTenantId[d.tenantId]?.[U]?.fetchState!=="Completed"&&o.includes("expense_automation_card")===!1&&E.push(et({tenantId:c,period:I,refreshViewInBackground:!1})),_(E)}}))),(s,i,r)=>s.pipe(S(Ho.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/webapp-preferences`).pipe(y((t=>{if(T(t)&&t.data){const e=t.data.preferences.card_order;let a=[...e];const n=a.indexOf("treasury_promo_card"),o=a.indexOf("zeni_promo_card");return n!==-1&&o!==-1&&o>n?(a[n]="zeni_promo_card",a[o]="treasury_promo_card",p(As(a))):n===-1?(a=[...e.slice(0,3),"treasury_promo_card",...e.slice(3)],p(As(a))):p(wO(a))}{const e=t.status.code===404,a=[Vm(t.status)];return e&&a.push(As($O)),p(...a)}})),v((t=>p(Vm(f("Unexpected Error","User preferences REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(rd.match),A((()=>r.getJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/summaries?query={"card_types": ["debit"]}`).pipe(y((t=>M(t)&&t.data!=null?p(iV(t.data.debit_card_summaries)):p(Rv(t.status)))),v((t=>p(Rv(f("Unexpected Error","Fetch Debit Card Summary REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(OF.match),y((r=>{const{cacheOverride:t,depositAccountId:e}=r.payload,a=[],n=i.value;if(a.push(Cn(e)),t===!0)a.push(ke()),a.push(Ge()),a.push(Xt()),a.push(zr(e)),a.push(xn(e,!0)),a.push(Fd(e));else{const o=n.depositAccountListState;o.hasValidState()===!1&&o.fetchState!=="In-Progress"&&a.push(ke());const c=n.paymentAccountListState;c.hasValidState()===!1&&c.fetchState!=="In-Progress"&&a.push(Ge());const d=n.zeniAccountDetailState.depositAccountDetailById[e];(d==null||d.hasValidState()===!1&&d.fetchState!=="In-Progress")&&a.push(zr(e));const l=n.depositAccountTransactionListState.byDepositId[e];(l==null||l.fetchState!=="Completed"&&l.fetchState!=="In-Progress")&&a.push(xn(e,!1));const u=n.zeniAccountsConfigState;u.hasValidState()===!1&&u.fetchState!=="In-Progress"&&a.push(Xt()),a.push(Fd(e))}return j(_(a))}))),(s,i,r)=>s.pipe(S(zr.match),A((t=>{const{depositAccountId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}?query=${encodeURIComponent('{"is_include_deposit_accounts_summary":true}')}`).pipe(y((a=>T(a)?p(Qe(a.data?.deposit_accounts??[]),CF({data:a,depositAccountId:e,fetchState:"Completed"})):p(FI({depositAccountId:e,error:a.status})))),v((a=>p(FI({depositAccountId:e,error:f("Unexpected Error","Fetch deposit Account REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(Fd.match),A((t=>{const{depositAccountId:e}=t.payload,a={start_date:"2022-01-01",end_date:me().format("YYYY-MM-DD")};return r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}/balances/time-series?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>T(n)?p(xF({depositAccountId:e,data:n})):p(qI({depositAccountId:e,fetchState:"Error",error:n.status})))),v((n=>p(qI({depositAccountId:e,fetchState:"Error",error:f("Unexpected Error","Fetch deposit account history REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(YM.match),A((t=>{const{depositAccountId:e}=t.payload,a={deposit_account_id:e};return r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/limits?query=${JSON.stringify(a)}`).pipe(y((n=>T(n)?p(kv(n.data?.deposit_accounts??[]),Yc({depositAccountId:e,fetchState:"Completed",error:void 0})):p(Yc({depositAccountId:e,fetchState:"Error",error:n.status})))),v((n=>p(Yc({depositAccountId:e,fetchState:"Error",error:f("Unexpected Error","Fetch deposit Accounts Limit For Card Detail REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(ke.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts?query=${encodeURIComponent('{"is_include_deposit_accounts_summary":true}')}`).pipe(y((t=>{if(T(t)){const e=t.data?.deposit_accounts??[];return p(Qe(e),kF({summaryPayload:t.data?.all_deposit_accounts_summary}),Qt({data:e,updateType:"replace"}))}return p(jI({fetchState:"Error",error:t.status}))})),v((t=>p(jI({fetchState:"Error",error:f("Unexpected Error","Fetch deposit Accounts REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(bn.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/limits`).pipe(y((t=>T(t)?p(JV(t.data?.deposit_accounts??[]),kv(t.data?.deposit_accounts??[])):p(Hv({fetchState:"Error",error:t.status})))),v((t=>p(Hv({fetchState:"Error",error:f("Unexpected Error","Fetch deposit Accounts For Cards REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(xn.match),y((t=>{const{depositAccountId:e,cacheOverride:a,count:n}=t.payload,o=i.value,c=X(o.depositAccountTransactionListState.byDepositId,e,void 0);if(a===!0||c==null||c.fetchState!=="Completed"||c.transactions.length<6&&n==null){let d={start_date:"2022-01-01",end_date:"2030-12-31"};return n!=null&&(d={...d,limit:n}),r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}/transactions?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>T(l)?p(DF(l.data?.deposit_account.transactions??[]),BF({transactionList:l.data?.deposit_account.transactions??[],depositName:l.data?.deposit_account.deposit_account_name??"",depositAccountId:e})):p(GI({depositAccountId:e,error:l.status})))),v((l=>p(GI({depositAccountId:e,error:f("Unexpected Error","Fetch deposit Account transactions REST API call errored out"+JSON.stringify(l))})))))}return _([])}))),(s,i,r)=>s.pipe(S(j$.match),y((t=>{const{scheduleType:e,downloadCategories:a,statusFilter:n}=t.payload,o=i.value.scheduleListState;let c;if(e!=="accrued_expenses"&&(c=nc(o,e)),c==null)return _([]);const d=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedTimeframe:c.selectedTimeframe,l=t.payload.timeframeAndCategory.selectedCategoryId,u=ua(d),m=ln(l,d),h=c.jeScheduleKeysByListKey[m];if(h!=null&&h.fetchState==="Completed")return _([]);const g={start_date:ae(u.start),end_date:ae(u.end),je_schedule_type:e,base_txn_account_ids:a,sort_by:"transaction_date",sort_order:"desc",filter:n};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/download?query=${encodeURIComponent(JSON.stringify(g))}`).pipe(y((I=>{if(T(I)&&I.data!=null){const b=[ut(I.data.je_schedules),St(I.data.je_schedules,I.data.scheduled_journal_entries),G$(e,d,l,I.data.je_schedules)];return _(b)}return p(of(e,d,l,I.status))})),v((I=>p(of(e,d,l,f("Unexpected Error","Schedule Download REST API call errored out"+JSON.stringify(I)))))))}))),(s,i,r)=>s.pipe(S(_c.match),A((t=>{const{invoiceId:e,recipientTotalAmount:a,vendorName:n,vendorId:o}=t.payload,c=i.value,d=Oe(c.vendorState,o),l={sort_order:"desc",sort_by:"transaction_date",transaction_type:"bill",bill_pay_provider:"zeni",is_include_attachment:!0,limit:3,entity_type:"vendor",entity_name:n,entity_id:d?.qboId??"",recipient_total_amount:a,...!!e&&{document_id:e}};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions?query=${encodeURIComponent(JSON.stringify(l))}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[];return m.push(gc(u.data.transactions)),m.push(LR({transactions:u.data.transactions,transactionId:t.payload.transactionId})),_(m)}return p(Mf({transactionId:t.payload.transactionId,status:u.status}))})),v((u=>p(Mf({transactionId:t.payload.transactionId,status:f("Unexpected error","Duplicate Bill Pay Rest API errored out"+JSON.stringify(u))})))))}))),(s,i,r)=>s.pipe(S(Id.match),A((t=>{const{reimbursementId:e,signedInUserId:a,isManuallyTriggered:n}=t.payload,{editRemiDetailViewState:o,reimbursementState:c}=i.value;let d=[];const l=e!=null?c.reimbursementById[e]?.createdBy:a;n===!0?d=e!=null?Object.values(o.editRemiStateById[e].remiDetailLocalData.updatesByLineId).filter((m=>m!=null)):Object.values(o.newRemiState.remiDetailLocalData.updatesByLineId).filter((m=>m!=null)):e!=null&&(d=(c.reimbursementById[e]?.lines??[]).map((m=>m.type==="mileage"?(h=>({type:h.type,fileId:h.fileId,lineId:h.lineId,homeCurrencyConversions:h.homeCurrencyConversions,mileage:{description:h.description,lineDetail:h.lineDetail,transactionDate:h.transactionDate,amount:h.amount,currencyCode:h.currencyCode,currencySymbol:h.currencySymbol,distanceMileage:h?.distanceMileage},outOfPocket:{recommendations:[],isCategoryFirstTimeAutofilled:!1,isCategoryUpdateSelected:!1,isRetainedCategorySelected:!1}}))(m):(h=>({type:h.type,fileId:h.fileId,lineId:h.lineId,homeCurrencyConversions:h.homeCurrencyConversions,mileage:{},outOfPocket:{merchant:h?.merchant,description:h.description,lineDetail:h.lineDetail,transactionDate:h.transactionDate,amount:h.amount,currencyCode:h.currencyCode,currencySymbol:h.currencySymbol,recommendations:[],isCategoryFirstTimeAutofilled:!1,isCategoryUpdateSelected:!1,isRetainedCategorySelected:!1}}))(m))));const u={reimbursement_provider:"zeni",transaction_type:"reimbursement",created_by_user_id:l,transaction_id:e??null,lines:d.map(pI)};return r.postAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/duplicates`,u).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[];return h.push(ML({duplicateLinesPayload:m.data.lines})),_(h)}return p(hI({status:m.status}))})),v((m=>p(hI({status:f("Unexpected error","Duplicate Reimbursement Rest API errored out"+JSON.stringify(m))})))))}))),(s,i)=>s.pipe(S(s1.match),y((r=>{const{cacheOverride:t,billId:e,isShowDeletedBillsEnabled:a,hasZeniAssistAccess:n,isInternationalWireEnabled:o}=r.payload,c=[],d=i.value,{tenantState:l,companyState:u}=d,{currentTenantId:m}=l,h=m!=null?l.tenantsById?.[m]?.companyId:void 0,g=Te(u,h??""),I=g?.company.companyZeniAccountInfo.isZeniAccountEnabled??!1;if(t)c.push(be("billPayAccountList",!0,!0,!0)),c.push(se(!0)),c.push(He()),c.push(ct()),c.push(Fr(o)),I&&c.push(ke()),c.push(Ge()),e!=null?c.push(Ec(e,!0,a,n)):c.push(Ac(!0));else{d.ownerListState.fetchState!=="In-Progress"&&d.ownerListState.hasValidState()===!1&&c.push(ct());const b=d.accountListState.byReportId.billPayAccountList;b.hasValidState()===!1&&b.fetchState!=="In-Progress"&&c.push(be("billPayAccountList",!0,!0,!0)),d.classListState.fetchState!=="In-Progress"&&c.push(se(!0)),d.vendorTypeListState.hasValidState()===!1&&d.vendorTypeListState.fetchState!=="In-Progress"&&c.push(He());const E=d.billPayConfigState.fetchState;E!=="Completed"&&E!=="In-Progress"&&c.push(Fr(o));const P=d.depositAccountListState;I&&P.fetchState!=="In-Progress"&&P.fetchState!=="Completed"&&c.push(ke());const O=d.paymentAccountListState;O.fetchState!=="In-Progress"&&O.fetchState!=="Completed"&&c.push(Ge()),e!=null&&c.push(Ec(e,!1,a,n))}return j(_(c))}))),(s,i)=>s.pipe(S(bL.match),y((r=>{const{cacheOverride:t,isLimitedCategoryEnabled:e,reimbursementId:a,isShowDeletedReimbursementEnabled:n}=r.payload,o=[],c=i.value,d=c.tenantState.loggedInUser?.userId??"";if(t)o.push(be("reimbursementAccountList",!0,!0,!0,e,[],!0)),o.push(se(!0)),o.push(ld()),o.push(ja()),o.push(yd(d,a)),a!=null&&o.push(_d(a,!0,n));else{c.accountListState.byReportId.reimbursementAccountList.fetchState!=="In-Progress"&&o.push(be("reimbursementAccountList",!0,!0,!0,e,[],!0)),c.classListState.fetchState!=="In-Progress"&&o.push(se(!0));const l=c.merchantListState;l.hasValidState()===!1&&l.fetchState!=="In-Progress"&&o.push(ld());const u=c.reimbursementConfigState.fetchState;u!=="Completed"&&u!=="In-Progress"&&o.push(ja());const m=c.userFinancialAccountState.financialAccountByUserId[d];if(m==null||m.hasValidState()===!1&&m.fetchState!=="In-Progress")o.push(yd(d,a));else if(a==null){const h=EL(c,d);o.push(rr({bankAccountId:h,shouldOverWriteCurrentBankAccountId:!1}))}a!=null&&o.push(_d(a,!1,n))}return j(_(o))}))),(s,i,r)=>s.pipe(S(Df.match),y((t=>{const{billId:e,cacheOverride:a}=t.payload,n=Ne(e),o=i.value,c=X(o.billDetailViewState.billDetailById,n,void 0);return a==1||c==null||c.zeniAssist.eligibleActionsFetchStatus.fetchState!=="In-Progress"?r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}/eligible-actions`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[DR(e,d.data.is_refund_eligible??void 0,d.data.is_retry_eligible.is_ibt_retry_eligible??void 0,d.data.is_retry_eligible.is_obp_retry_eligible??void 0)];return _(l)}return p(Jf(t.payload.billId,d.status))})),v((d=>(console.error(`Fetch eligible actions REST API call errored out ${d}`),p(Jf(t.payload.billId,f("Unexpected Error",`Fetch eligible actions REST API call errored out ${d}`))))))):_([])}))),$G,(s,i,r)=>s.pipe(S(yn.match),y((t=>{const{entityId:e,entityType:a,cacheOverride:n}=t.payload,o=FV(e,a),c=[],d=i.value,l=X(d.commonHistoryState.historyById,o,void 0);if(n===!0||l==null||l.fetchState!=="In-Progress"){c.push(dd({entityId:e,entityType:a,fetchState:"In-Progress"}));const u=a==="bill_pay"?"bill":a,m=r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/${u}s/transactions/${e}/history`).pipe(y((h=>T(h)&&h.data!=null?p(qV({entityId:e,entityType:a,historicEventsPayload:h.data.activities,keepTimeInUTC:a==="bill_pay"})):p(dd({entityId:e,entityType:a,fetchState:"Error",error:h.status})))),v((h=>(console.error(`REST API call errored out ${h}`),p(dd({entityId:e,entityType:a,fetchState:"Error",error:f("Unexpected Error",`REST API call errored out ${h}`)}))))));return j(_(c),m)}return _(c)}))),(s,i,r)=>s.pipe(S(yw.match),A((t=>{const{entity:e,amount:a,transactionDetails:n,isBulkFetch:o,isTransactionCategorizationFlow:c,isFetchCOT:d}=t.payload,{expenseAutomationTransactionsViewState:{selectedTransactionCategorizationTab:l}}=i.value,u={amount:a,transaction_id:Ig(n.transactionId.id),transaction_type:n.transaction.type,line_ids:n.lineIds};d===!0&&(u.include_cot=!0);const m={entity_name:e.name,entity_type:e.type},h=e.qboId===e.name?`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(m))}`:`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/${e0(e.type)}/${e.qboId}/recommendations?query=${encodeURIComponent(JSON.stringify(u))}`;return r.getJSON(h).pipe(y((g=>{if(T(g)&&g.data!=null){const I=[],{transactionId:b,transaction:E,lineIds:P}=n,O=XE(g.data.recommendations,P),C=Hr(g.data.recommendations),U=d===!0&&O!=null?bg(E,O):Vs(E);if(I.push(wr({entityId:e.id,entityType:e.type,recommendations:C})),o===!0&&I.push($r(b,"Completed")),O!=null){const B=pa(i.value.accountState,i.value.accountListState,"accountList");c===!0?I.push(Eg(l,b,U,P,e,a,O,B,pt(i.value))):I.push(Pg(b,U,P,e,a,O,B))}return _(I)}return p($a({entityId:e.id,entityType:e.type,status:g.status}))})),v((g=>p($a({entityId:e.id,entityType:e.type,status:f("Unexpected Error","Fetch recommendation by Entity QBO Id REST API call errored out"+JSON.stringify(g))})))))}))),(s,i,r)=>s.pipe(S(_w.match),ar((t=>{return e=t.payload.flowType,a=t.payload.transactionDetails.transactionId.id,n=t.payload.transactionDetails.lineIds,`${e}\0${a}\0${[...n].sort(((o,c)=>o.localeCompare(c))).join("\0")}`;var e,a,n}),void 0,(t=>t.pipe(hw((()=>Ha(6e4)))))),y((t=>t.pipe(A((e=>{const a=e.payload,{transactionId:n,transaction:o,lineIds:c}=a.transactionDetails,{entity:d,amount:l,isFetchCOT:u}=a,m=a.flowType==="detail"&&a.isBulkFetch===!0,h=(E,P)=>m&&P!=null?p(E,P):p(E),g=a.flowType==="categorization"?Sw(a.selectedTab,n,c):gw(n,c),I=((E,P,O,C,U)=>{const B={entity_name:P.name,entity_type:P.type};if(P.qboId===P.name)return`${E}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(B))}`;const x={amount:O,transaction_id:Ig(C.transactionId.id),transaction_type:C.transaction.type,line_ids:C.lineIds};return U===!0&&(x.include_cot=!0),`${E}/1.0/${k=P.type,`${k}s`}/${P.qboId}/recommendations?query=${encodeURIComponent(JSON.stringify(x))}`;var k})(r.apiEndPoints.accountMicroServiceBaseUrl,d,l,a.transactionDetails,u===!0),b=r.getJSON(I).pipe(y((E=>{if(!T(E)||E.data==null)return h(a.flowType==="categorization"?Tg(a.selectedTab,n,c,E.status):Ag(n,c,E.status),m?$r(n,"Error",E.status):void 0);const P=XE(E.data.recommendations,c);if(P==null)return h(a.flowType==="categorization"?fw(a.selectedTab,n,c):vw(n,c),m?$r(n,"Completed"):void 0);const O=u===!0?bg(o,P):Vs(o),C=pa(i.value.accountState,i.value.accountListState,"accountList");return a.flowType==="categorization"?p(Eg(a.selectedTab,n,O,c,d,l,P,C,pt(i.value))):h(Pg(n,O,c,d,l,P,C),m?$r(n,"Completed"):void 0)})),v((E=>{const P="fetchEntityRecommendationsForLineUpdate failed: "+(E instanceof Error?E.message:JSON.stringify(E)),O=f("Unexpected Error",P);return h(a.flowType==="categorization"?Tg(a.selectedTab,n,c,O):Ag(n,c,O),m?$r(n,"Error",O):void 0)})));return j(p(g),b)})))))),RG,(s,i,r)=>s.pipe(S(ks.match),y((t=>{const{expenseAutomationFluxAnalysisViewState:{groupsBySelectedPeriod:e,uiState:a}}=i.value,{monthAndYear:n,cacheOverride:o,pageToken:c,fetchReimbursement:d,keepExistingListItems:l}=t.payload,u=e[Ee(n)],m=d===!0?u?.reimbursement:u?.generalExpense,h=m?.operatingExpenseIds??[],g=m?.fetchStatus?.fetchState??"Not-Started";if(o===!0||m==null||h.length===0||g==="Not-Started"){const I={month_and_year:`${n.month<10?`0${n.month}`:n.month}-${n.year}`,sort_by:PC(a.sortKey),sort_order:Vo(a.sortOrder),page_token:c,reimbursement_flag:d};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/month-close/flux-analysis?query=${encodeURIComponent(JSON.stringify(I))}`).pipe(y((b=>{if(T(b)&&b.data!=null){const E=[];return E.push(W(b.data.accounts,"account_list")),E.push(Ke("class_list",b.data.accounting_class)),E.push(le(b.data.vendors,"merge")),E.push(V({users:b.data.users,updateType:"merge"})),E.push(TC({fetchReimbursement:d,pageMetaData:b.data.page_metadata})),b.data.flux_analysis_entities?.operating_expenses!=null&&E.push(AC({expensesPayload:b.data.flux_analysis_entities?.operating_expenses,totalsPayload:b.data.total_operating_expenses,currency:b.data.currency,selectedPeriod:n,fetchReimbursement:d,keepExistingListItems:l,status:b.data?.status})),_(E)}return p(dy({fetchReimbursement:d,status:b.status,selectedPeriod:n}))})),v((b=>p(dy({fetchReimbursement:d,status:f("Unexpected Error",`fetch flux analysis view REST API call errored out: ${JSON.stringify(b)}`),selectedPeriod:n})))))}return _([])}))),(s,i)=>s.pipe(S(mi.match),y((r=>{const{transactionIds:t,selectedPeriod:e,keepExistingListItems:a,selectedTab:n,pageToken:o,totalCount:c,lineItemsByTransactionIds:d,refreshViewInBackground:l}=r.payload,u=[],{transactionState:m,expenseAutomationTransactionsViewState:h}=i.value,{transactionReviewLocalDataById:g}=h.transactionCategorizationView[n],I=a===!0?{...g}:{};return qy(m,t).forEach((b=>{const E=Vs(b),P=Mx(E,n,d[b.id]);I[b.id]==null?I[b.id]={...Vx,transactionId:b.id,transactionReviewLocalData:{...P,sortedLineItems:b.lines?.map((O=>O.id))??[]}}:I[b.id]={transactionId:b.id,transactionReviewLocalData:{...I[b.id].transactionReviewLocalData,...P,lineItemById:{...Kz(I[b.id].transactionReviewLocalData.lineItemById,P.lineItemById)},sortedLineItems:[...new Set(I[b.id].transactionReviewLocalData.sortedLineItems.concat(P.sortedLineItems))],tabSpecificLineItems:Lx(I[b.id].transactionReviewLocalData.tabSpecificLineItems,n,P.tabSpecificLineItems)}}})),u.push(Fx({selectedTab:n,transactionIds:t,selectedPeriod:e,keepExistingListItems:a,transactionLocalData:I,pageToken:o,totalCount:c,refreshViewInBackground:l})),_(u)}))),(s,i,r)=>s.pipe(S(Qa.match),y((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a}}=e,{period:n,refreshViewInBackground:o}=t.payload,c=a[H(e).tenantId],d=t.payload.selectedPageTab??e.expenseAutomationJESchedulesViewState.uiState.selectedPageTab,l=d==="schedules",u=ge(ee(ae(n.start)).subtract(1,"month").endOf("month").format(re)),m=ae(l||u==null?n.end:u),h=ee(m),g=h.subtract(24,"month").startOf("month").format(re),I=h.subtract(12,"month").startOf("month").format(Zn),b={base_transaction_end_date:m,end_date:m,accrued_start_date:g,accrued_end_date:m,include_accrued:!0,...l?{base_transaction_start_date:ae(n.start),close_period_start_date:ae(n.start),one_time_accrual_service_month:ee(ae(n.start)).format(Zn),one_time_accrual_statuses:[],filter_failed_je_postings_by_date:!0}:{one_time_accrual_service_month_start:I,one_time_accrual_service_month_end:h.format(Zn),one_time_accrual_statuses:["posted"],filter_failed_je_postings_by_date:!1}};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expenses_automation/je_schedules?query=${encodeURIComponent(JSON.stringify(b))}`).pipe(y((E=>{if(T(E)&&E.data!=null){const P=[],O=E.data.accrued_je_schedules?.je_schedules??[],C=E.data.one_time_accruals??[];return P.push(ut([...E.data.je_schedules,...E.data.failed_je_postings.je_schedules]),St([...E.data.failed_je_postings.je_schedules],E.data.failed_je_postings.scheduled_journal_entries),hy([...E.data.failed_je_postings.je_schedules])),O.length>0&&P.push(ca(O),br(O,E.data.accrued_je_schedules?.scheduled_journal_entries)),C.length>0&&P.push(Ta(C)),P.push(wC({jeSchedules:[...E.data.je_schedules],failedJeSchedules:[...E.data.failed_je_postings.je_schedules],accruedJeSchedules:O,oneTimeAccruals:C,selectedPeriod:c,selectedPageTab:d,refreshViewInBackground:o})),_(P)}return p(Sy({status:E.status,selectedPeriod:c,selectedPageTab:d}))})),v((E=>p(Sy({status:f("Unexpected Error","fetch JE schedules REST API call errored out"+JSON.stringify(E)),selectedPeriod:c,selectedPageTab:d})))),De(s.pipe(S(gt.match))))}))),(s,i)=>s.pipe(S(Pa.match),y((r=>{const t=[],{period:e,refreshViewInBackground:a}=r.payload,n=Ir();return i.value.accountListState.byReportId[n.accountListKey].fetchState==="Not-Started"&&t.push(be(n.accountListKey,!0,!1,!1,!1,n.allowedAccountList)),t.push(Qa(e,a)),i.value.expenseAutomationJESchedulesViewState.accountSettings.hasLoadedAccountSettings||t.push(_y()),j(_(t))}))),(s,i,r)=>s.pipe(S(jy.match),y((t=>{const{expenseAutomationViewState:e,expenseAutomationTransactionsViewState:a}=i.value,{transactionsInReview:n,selectedTab:o}=t.payload,c=n.transactions_update_success,d=n.transactions_update_failed,l=H(i.value),u=e.selectedPeriodByTenantId[l.tenantId],m=o==="review"?"autoCategorized":"review",h=a.transactionCategorizationView[o],g=a.transactionCategorizationView[m],{uiState:I}=h,b=d.map((P=>P.transaction_id)),E=[];return d.length>0&&c.length===0&&E.push(N(Gy(c.length,d.length,0))),c.length>0?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/mark-as-reviewed`,{transactions_reviewed:c}).pipe(y((P=>{if(T(P)&&P.data!=null){const O=P.data.transactions_reviewed_success,C=P.data.transactions_reviewed_failed,U={},B={};O.forEach((w=>{U[w.transaction_id]=w.line_ids})),C.forEach((w=>{B[w.transaction_id]=w.line_ids}));const x=[...new Set([...Object.keys(U),...Object.keys(B)])],k=x.filter((w=>!(w in B))),J=[],L=[],R={};x.forEach((w=>{const K=U[w]??[],G=B[w]??[],Z=h.transactionReviewLocalDataById[w]?.transactionReviewLocalData.tabSpecificLineItems[o]??[],de=(g.transactionReviewLocalDataById[w]?.transactionReviewLocalData.tabSpecificLineItems[m]??[]).length>0,ue=Z.filter((te=>{const ye=K.includes(te),_e=G.includes(te);return o==="review"?!ye||_e:!ye&&!_e}));ue.length>0?R[w]=ue:(R[w]=[],L.push(w),de||J.push(w))}));const q=[...b],$=I.totalCount[Ee(u)],D=L.length===0?$:$-L.length;if(E.push(Ls(o,x,L,u,"Completed",void 0,R)),J.length>0&&E.push(zy({transactionIds:J})),o==="autoCategorized"&&Object.keys(B).length>0){const w=Re(u),K=ge(w.start),G=ge(w.end);K!=null&&G!=null&&E.push(fr("review",{start:K,end:G},!0,!1,void 0,void 0,!0,!1))}return E.push($s({selectedPeriod:u,selectedTab:o,totalCount:D})),E.push(N(Gy(c.length-k.length,q.length,k.length))),l!=null&&E.push(et({tenantId:l.tenantId,period:u,refreshViewInBackground:!0})),_(E)}return p(Ls(t.payload.selectedTab,[],[],u,"Error",P.status))})),v((P=>p(Ls(t.payload.selectedTab,[],[],u,"Error",f("Unexpected Error",`Transaction mark miscategorized as correct REST API call errored out ${JSON.stringify(P)}`)))))):_(E)}))),(s,i,r)=>s.pipe(S(vr.match),A((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a},expenseAutomationMissingReceiptsViewState:{transactionIdsBySelectedPeriod:n,fetchState:o}}=e,{period:c,cacheOverride:d,minimumTransactionAmount:l}=t.payload,u=a[H(e).tenantId],m=n[Ee(u)]??[];if(d===!0||m.length===0||o==="Not-Started"){const h={start_date:ae(c.start),end_date:ae(c.end),total_amount_min:l.amount,is_attachment_missing_only:!0,sort_by:"transaction_date",sort_order:"desc"};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions?query=${encodeURIComponent(JSON.stringify(h))}`).pipe(y((g=>{if(T(g)&&g.data!=null){const I=[];return I.push(Ce(g.data.transactions,(b=>b.transaction_id))),I.push(Ix({transactionsPayload:g.data.transactions,selectedPeriod:u})),_(I)}return p(Dy({status:g.status,selectedPeriod:u}))})),v((g=>p(Dy({status:f("Unexpected Error","fetch missing receipts REST API call errored out"+JSON.stringify(g)),selectedPeriod:u})))))}return _([])}))),(s,i,r)=>s.pipe(S(Rt.match),y((t=>{const{accountId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,o=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:c},expenseAutomationReconciliationViewState:{accountReconciliationRecordsBySelectedPeriod:d}}=o,l=c[H(o).tenantId];let u,m,h;if(e!=null&&(u=Ea(o,e,l),m=u?.reconciliationId),h=e!=null?d[Ee(l)].reconciliationByAccountID[e].transactionFetchState.fetchState:o.expenseAutomationReconciliationViewState.fetchState,a===!0||h!=="Completed"){const{start:g,end:I}=Re(l,!0),b={};m==null&&(b.start_date=g.toString(),b.end_date=I.toString(),e!=null&&(b.account_id=e)),a===!0&&e!=null&&(b.is_force_refresh=!0);const E=m!=null?`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/${m}?query=${encodeURIComponent(JSON.stringify(b))}`:`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation?query=${encodeURIComponent(JSON.stringify(b))}`;return r.getJSON(E).pipe(y((P=>{if(T(P)&&P.data!=null){const O=[],C=Ym(P.data.reconciliation);O.push(W(P.data.accounts,"account_reconciliation"),W(P.data.excluded_accounts??[],"excluded_account_reconciliation"),V({users:P.data.users??[],updateType:"merge"}),ve({files:P.data.files??[]}),Xo(C,"merge"),ei(l,P.data.reconciliation,e==null));const U=Bz(P.data.reconciliation[0]?.transactions?.review??[]);if(e!=null){const B=CE(P.data.reconciliation[0].transactions.reconcile);O.push(gr({selectedTransactionIds:B}),Wm(U))}return O.push(ZO(l,P.data,n,e)),_(O)}return p(Zm({error:P.status,selectedPeriod:l,refreshViewInBackground:n,accountId:e}))})),v((P=>p(Zm({error:f("Unexpected Error",`fetch reconciliation view REST API call errored out ${JSON.stringify(P)}`),refreshViewInBackground:n,selectedPeriod:l,accountId:e})))))}{const g=[];return e!=null&&g.push(Xm()),_(g)}}))),(s,i)=>s.pipe(S(jx.match),y((r=>{const{transactionIds:t,cotTrackingByTransactionId:e,selectedTab:a}=r.payload,n=[],{transactionState:o,expenseAutomationTransactionsViewState:c}=i.value,d=[];return qy(o,t).forEach((l=>{const u=X(c.transactionCategorizationView[a].transactionReviewLocalDataById,l.id,void 0),m=pa(i.value.accountState,i.value.accountListState,"accountList"),h=u?.transactionReviewLocalData;h!=null&&d.push(Qz(h,l,m))})),n.push(Ky(a,t,d,e)),_(n)}))),(s,i,r)=>s.pipe(S(Rs.match),ar((t=>t.payload.selectedTab)),y((t=>t.pipe(A((e=>{const{expenseAutomationViewState:{selectedPeriodByTenantId:a},expenseAutomationTransactionsViewState:n}=i.value,{period:o,keepExistingListItems:c,selectedTab:d,refreshViewInBackground:l}=e.payload,u=n.transactionCategorizationView[d].uiState,{pageToken:m,sortOrder:h,sortKey:g}=u,I=u.searchString,b=a[H(i.value).tenantId],E={start_date:ae(o.start),end_date:ae(o.end),auto_categorized:d==="autoCategorized",sort_by:ui(g),sort_order:h==="ascending"?"asc":"desc",page_token:m,page_size:25,search_text:u.searchString,search_all_statuses:!1,sub_tab:d==="autoCategorized"?n.selectedTransactionCategorizationCompletedSubTab:li,transaction_group:n.selectedTransactionGroup};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(E))}`).pipe(y((P=>{if(i.value.expenseAutomationTransactionsViewState.transactionCategorizationView[d].uiState.searchString!==I)return F;if(T(P)&&P.data!=null){const O=[];O.push(Ce(P.data.transactions,(B=>B.transaction_id),"merge"));const C=P.data.transactions.map((B=>B.transaction_id)),U=Vy(P.data.transactions);return O.push(Ly({selectedTab:d,uiState:{pageToken:P.data.next_page_token??null}})),O.push(mi(d,C,b,c,P.data.next_page_token??null,P.data.total_count,U,l)),O.push($s({selectedPeriod:b,selectedTab:d,totalCount:P.data.total_count})),O.push($x({selectedPeriod:b,selectedTab:d,parentTotalCount:P.data.parent_tab_total_count??P.data.total_count})),O.push(Rx({refreshViewInBackground:l,tabs:yi.filter((B=>d!==B))})),O.push(Fy({refreshViewInBackground:l,selectedTab:d,status:P.status})),_(O)}return p(ws({selectedPeriod:b,selectedTab:d,status:P.status}))})),v((P=>i.value.expenseAutomationTransactionsViewState.transactionCategorizationView[d].uiState.searchString!==I?F:p(ws({selectedPeriod:b,selectedTab:d,status:f("Unexpected Error","fetch Transaction Categorization REST API call errored out"+JSON.stringify(P))})))))})))))),(s,i)=>s.pipe(S(fr.match),y((r=>{const{selectedTab:t,cacheOverride:e,keepExistingListItems:a,pageToken:n,period:o,refreshViewInBackground:c,searchString:d,resetListItems:l}=r.payload,u=[],{expenseAutomationTransactionsViewState:m}=i.value,{fetchState:h,transactionIdsBySelectedPeriod:g,uiState:I}=m.transactionCategorizationView[t],b={month:o.start.month,year:o.start.year},E=g[Ee(b)]??[],P=i.value.accountListState.byReportId.accountList;P.hasValidState()===!1&&P.fetchState==="Not-Started"&&u.push(be("accountList",!0));const O=i.value.classListState;O.hasValidState()===!1&&O.fetchState==="Not-Started"&&u.push(se());const C=i.value.projectListState;Ms(i.value)&&C.hasValidState()===!1&&C.fetchState==="Not-Started"&&u.push(_i());const U=i.value.ownerListState;return U.hasValidState()===!1&&U.fetchState==="Not-Started"&&u.push(ct()),d!==""&&e!==!0&&h!=="Not-Started"&&E.length!==0&&I.searchString===""||u.push(Rs(t,o,e,a,d,n,c,l)),d===void 0&&yi.filter((B=>B!==t)).forEach((B=>{m.transactionCategorizationView[B].fetchState==="Not-Started"&&u.push(Rs(B,o,!1,!1,void 0,void 0,!0,void 0))})),d!==void 0&&yi.filter((B=>B!==t)).forEach((B=>{const x=m.transactionCategorizationView[B].uiState.searchString;d!==x&&u.push(Rs(B,o,!0,a,d,void 0,!0,!0))})),_(u)}))),(s,i,r)=>s.pipe(S(Ky.match),y((t=>{const{selectedTab:e,transactionIds:a,transactionSaveUpdates:n,cotTrackingByTransactionId:o}=t.payload,{transactionState:c,vendorState:d,expenseAutomationTransactionsViewState:l}=i.value,u=(function(m,h,g,I,b,E,P){const O=[];return b.forEach((C=>{const U=E.find((B=>B.transactionId===C));if(U!=null){const B=(function(x,k,J,L,R,q,$){const D=At(k,R),w=X(L.transactionCategorizationView[x].transactionReviewLocalDataById,R,void 0),K=w?.transactionReviewLocalData?.vendorUpdates,G=w?.transactionReviewLocalData?.customerUpdates,Z=w?.transactionReviewLocalData?.selectedEntity;let de;if(K?.qboId!=null&&Z!=null&&Z.type==="vendor"){const te=Oe(J,K.qboId)??K;de={id:te.qboId===te.name?"":te.qboId??"",name:te.name}}let ue;if(Z!=null&&Z.type==="customer"&&(ue=G?.qboId!=null?{id:G.qboId,name:G.name}:{id:Z.id,name:Z.name}),D!=null){const te=Xz(q.updates,D,R,$,de,ue,Z);return{entity_related_updates:eK(q.entityRelatedUpdates),transaction_id:R,transaction:te,transaction_type:Py(D.type)}}})(m,h,g,I,C,U,P);B!=null&&O.push(B)}})),O??[]})(e,c,d,l,a,n,o).filter((m=>m!=null));return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions/categorize`,{transactions:u}).pipe(y((m=>{if(T(m)&&m.data!=null){const h=m.data,g=[];return g.push(jy(e,h),hi(e,"Completed",f("Completed","Transaction categorization updated successfully"))),_(g)}return p(hi(e,"Error",m.status))})),v((m=>p(hi(e,"Error",f("Unexpected Error",`REST API call errored out ${JSON.stringify(m)}`))))))}))),(s,i,r)=>s.pipe(S(sE.match),y((t=>{const{vendorId:e,vendorName:a,vendorZeniId:n}=t.payload,o={entity_id:e,entity_type:"vendor",vendor_id:e,vendor_name:a},c=r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/spend_trend?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((d=>T(d)?_(gY({id:e,name:a,zeniId:n},d)):p(Jn(t.payload.vendorId,d.status)))),v((d=>p(Jn(t.payload.vendorId,f("Unexpected Error","Spend Trend REST API call errored out"+JSON.stringify(d)))))));return j(c)}))),(s,i)=>s.pipe(S(JF.match),y((r=>{const{cacheOverride:t}=r.payload,e=i.value,a=[];if(t===!0)a.push(He()),a.push(Xt()),a.push(ke()),a.push(zI());else{e.vendorTypeListState.hasValidState()===!1&&e.vendorTypeListState.fetchState!=="In-Progress"&&a.push(He());const n=e.zeniAccountsConfigState;n.hasValidState()===!1&&n.fetchState!=="In-Progress"&&a.push(Xt());const o=e.depositAccountListState;o.fetchState!=="In-Progress"&&o.fetchState!=="Completed"&&a.push(ke()),a.push(zI())}return j(_(a))}))),MG,(s,i,r)=>s.pipe(S(tU.match),A((t=>{const{fileId:e,tenantId:a}=t.payload;return(a!=null?r.getJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}?query=${encodeURIComponent(JSON.stringify({is_dummy_response:!1,download_file:!1}))}`,Object.assign({"zeni-tenant-id":a})):r.getJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}?query=${encodeURIComponent(JSON.stringify({is_dummy_response:!1,download_file:!1}))}`)).pipe(y((n=>T(n)?p(ve({files:n.data?.files??[]}),aU({fileId:e})):p(Xy({status:n.status})))),v((n=>p(Xy({status:f("Unexpected Error","Fetch File REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(e_.match),A((t=>{const{fileIds:e,tenantId:a}=t.payload;return(a!=null?r.getJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files?query=${encodeURIComponent(JSON.stringify({file_ids:e}))}`,Object.assign({"zeni-tenant-id":a})):r.getJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files?query=${encodeURIComponent(JSON.stringify({file_ids:e}))}`)).pipe(y((n=>T(n)?p(ve({files:n.data?.files??[]}),rU({fileIds:e})):p(t_({status:n.status})))),v((n=>p(t_({status:f("Unexpected Error","Fetch File List REST API call errored out"+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(iU.match),A((r=>{const{userId:t,fetchSelectedTab:e,fetchFullReport:a,cacheOverride:n}=r.payload,o=i.value;if(n===!0)return p(Ia(t),Si(),ho(),To());{const{tenantState:c,financeStatementState:d}=o,l=[];c.fetchState==="In-Progress"||c.hasValidState()||l.push(Ia(t));const u=cU(void 0,o.profitAndLossState),m=dU(o.balanceSheetState),h=lU(o.cashFlowState);if(e)switch(d.selectedReportId){case"profit_and_loss":case"profit_and_loss_by_classes":u.fetchStateByTimeframe[d.timeframe].fetchState!=="In-Progress"&&u.fetchStateByTimeframe[d.timeframe].fetchState!=="Completed"&&l.push(Mt(d.timeframe));break;case"balance_sheet":m.fetchStateByTimeframe[d.timeframe].fetchState!=="In-Progress"&&m.fetchStateByTimeframe[d.timeframe].fetchState!=="Completed"&&l.push(Ot(d.timeframe));break;case"cash_flow":h.fetchStateByTimeframe[d.timeframe].fetchState!=="In-Progress"&&h.fetchStateByTimeframe[d.timeframe].fetchState!=="Completed"&&l.push(Bt(d.timeframe,a))}else u.reducedAllFetchState.fetchState!=="In-Progress"&&u.reducedAllFetchState.fetchState!=="Completed"&&l.push(Si()),m.reducedAllFetchState.fetchState!=="In-Progress"&&m.reducedAllFetchState.fetchState!=="Completed"&&l.push(ho(a)),h.reducedAllFetchState.fetchState!=="In-Progress"&&h.reducedAllFetchState.fetchState!=="Completed"&&l.push(To(a));return _(l)}}))),(s,i,r)=>s.pipe(S(Fs.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/forecasts`).pipe(y((t=>T(t)?p(uU(t.data?.forecasts??[]),qs(t)):p(Nr(t.status)))),v((t=>p(Nr(f("Unexpected Error","Fetch forecast list call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(SU.match),Oa((t=>{const e=i.value.globalMerchantAutoCompleteState.autoCompleteText??"",{globalMerchantType:a}=t.payload,n={search_text:e,entity_type:a};if(e===t.payload.searchString){const{userId:o,sessionId:c}=r,d={"zeni-user-id":o,"zeni-tenant-id":"","zeni-session-id":c};return r.getJSON(`${r.apiEndPoints.searchMicroServiceBaseUrl}/1.0/autocomplete/global_merchant?query=${encodeURIComponent(JSON.stringify(n))}`,d).pipe(Oa((l=>{if(T(l)&&l.data!=null){const u=[];return u.push(It({globalMerchants:l.data.entities,updateType:"merge"})),u.push(gU(l.data)),_(u)}return p(n_(l.status))})),v((l=>p(n_(f("Unexpected Error","Global Merchant Auto Complete REST API call errored out"+JSON.stringify(l)))))))}return _([])}))),(s,i,r)=>s.pipe(S(_U.match),A((t=>{const{newGlobalMerchantData:e}=i.value.globalMerchantViewState,{source:a,merchantName:n}=t.payload,o=a==="tenant"&&n!=null?n:e?.globalMerchantName;if(o!=null){const c={global_merchant_name:o};return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(JSON.stringify(c))}`).pipe(A((d=>{if(T(d)&&d.data!=null){const{recommendations:l}=d.data,u=Z0(l),m=[It({globalMerchants:u}),hU(l)];return l[0]?.global_merchants.length===0&&m.push(N({messageSection:"fetch_global_merchant_no_recommendation",messageText:"success",type:"info",variables:[{variableName:"_global_merchant_name_",variableValue:o}]})),m}return p(s_({status:d.status}))})),v((d=>p(s_({status:f("Unexpected Error","Fetch Global Merchant Recommendation REST API call errored out"+JSON.stringify(d))})))))}return _([])}))),(s,i,r)=>s.pipe(S(nE.match),y((t=>{const{customerId:e,customerName:a}=t.payload,n={entity_id:e,entity_type:"customer",customer_id:e,customer_name:a},o=r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/income_trend?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((c=>T(c)?_(fY({id:e,name:a},c)):p(Jn(t.payload.customerId,c.status)))),v((c=>p(Jn(t.payload.customerId,f("Unexpected Error","Income Trend REST API call errored out"+JSON.stringify(c)))))));return j(o)}))),(s,i,r)=>s.pipe(S(Yo.match),A((()=>r.getJSON(`${r.apiEndPoints.insightsMicroServiceBaseUrl}/1.0/insights`).pipe(y((t=>T(t)?p(o_(t.data?.insights??[]),fU(t)):p(i_(t.status)))),v((t=>p(i_(f("Unexpected error","Insights Card REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(uv.match),A((t=>{const{currencyCode:e,amount:a,vendorType:n,cacheOverride:o}=t.payload,c=i.value,d=pv(e,a,n),l=c.internationalWireState.dynamicFormDetailsbyKey[d];return o===!0||l==null||o===!1&&l.hasValidState()===!1?r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/account-requirements?target_currency=${e}&target_amount=${JSON.stringify(a)}&vendor_type=${n}`).pipe(y((u=>T(u)&&u.data!=null?_([w1({internationalWireFormPayload:u.data,currencyCode:e,amount:a,vendorType:n}),mv(a,n)]):p(yv({currencyCode:e,amount:a,vendorType:n,error:u.status})))),v((u=>p(yv({currencyCode:e,amount:a,vendorType:n,error:f("Unexpected Error","Fetch Dynamic form REST API call errored out"+JSON.stringify(u))}))))):_([])}))),(s,i,r)=>s.pipe(S(R1.match),A((t=>r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding-fields?query=${encodeURIComponent(JSON.stringify({region:"US",legal_type:"BUSINESS"}))}`).pipe(y((e=>T(e)&&e.data!=null?_([M1({internationalWireFormPayload:e.data.labels}),hv(t.payload.companyId,e.data.labels)]):p(Sv({error:e.status})))),v((e=>p(Sv({error:f("Unexpected Error","Fetch international verification form REST API call errored out"+JSON.stringify(e))})))))))),(s,i,r)=>s.pipe(S(W_.match),A((()=>{const{filters:t}=i.value.invoicingInvoiceListState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search),t.customerId!=null&&e.set("customer_id",t.customerId),t.subscriptionId!=null&&e.set("subscription_id",t.subscriptionId),t.dateFrom!=null&&e.set("date_from",t.dateFrom),t.dateTo!=null&&e.set("date_to",t.dateTo);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(Hk(n.data)):p(Z_(n.status)))),v((n=>p(Z_(f("Unexpected Error","Fetch invoice counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Br.match),A((t=>{const{invoiceId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[z(Or([n.data])),Ca([n.data],"merge"),Gk({invoiceId:n.data.id})]:p(H_({invoiceId:e,status:n.status})))),v((n=>p(H_({invoiceId:e,status:f("Unexpected Error","Fetch invoice detail REST API call errored out "+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(zk.match),Le(i),y((([r,t])=>{const{cacheOverride:e=!1,invoiceId:a}=r.payload,n=[],o=t.invoicingInvoiceDetailState.detailById[a];LE({error:o?.error,fetchState:o?.fetchState??"Not-Started"},e)&&n.push(Br({invoiceId:a}));const c=t.invoicingConfigViewState;return LE({error:c.error,fetchState:c.fetchState},e)&&n.push(Ur()),n.length>0?_(n):F}))),(s,i,r)=>s.pipe(S(X_.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/kpis`;return r.getJSON(t).pipe(A((e=>T(e)&&e.data!=null?p(Qk(Wk(e.data))):p(eh(e.status)))),v((e=>p(eh(f("Unexpected Error","Fetch invoice KPIs REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Ei.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,{activeTab:c}=i.value.invoicingInvoiceListState,d=c!=="all"?c:void 0,l=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices`,((u,m,h,g)=>{const I=new URLSearchParams;return m!=null&&m.length>0&&I.set("status",m),u.customerId!=null&&I.set("customer_id",u.customerId),u.subscriptionId!=null&&I.set("subscription_id",u.subscriptionId),u.search!=null&&u.search.length>0&&I.set("search",u.search),u.dateFrom!=null&&I.set("date_from",u.dateFrom),u.dateTo!=null&&I.set("date_to",u.dateTo),I.set("limit",String(tt)),h!=null&&I.set("cursor",h),at(I,g),I})(e,d,a,o));return r.getJSON(l).pipe(A((u=>{if(T(u)){const m=u.data?.items??[];return[Ca(m,"merge"),z(Or(m)),Zk({invoices:m,nextCursor:u.data?.next_cursor??null,keepExistingListItems:n})]}return p(th(u.status))})),v((u=>p(th(f("Unexpected Error","Fetch invoice list REST API call errored out "+JSON.stringify(u)))))))}))),(s,i)=>s.pipe(S(Xk.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingInvoiceListState,o=n.invoiceByTab[n.activeTab]??eB(),c=[];return xl({fetchState:o.fetchState,error:o.error},t)&&c.push(Ei({filters:e,sort:a})),xl(n.countsFetchState,t)&&c.push(W_()),xl(n.kpisFetchState,t)&&c.push(X_()),j(_(c))}))),(s,i)=>s.pipe(S(N_.match),Le(i),y((([,r])=>{const t=[],e=r.accountListState.byReportId[Mh];(e.hasValidState()&&e.accountIds.length>0)===!1&&e.fetchState!=="In-Progress"&&t.push(be(Mh,!0));const a=r.classListState;return a.hasValidState()===!1&&a.fetchState!=="In-Progress"&&t.push(se()),t.length>0?_(t):F}))),(s,i,r)=>s.pipe(S(vU.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/audit-log`,((d,l,u)=>{const m=new URLSearchParams,h=(g=>{const I={};return g.search!=null&&g.search.length>0&&(I.search=g.search),g.action!=null&&g.action.length>0&&(I.action=g.action),g.dateFrom!=null&&g.dateFrom.length>0&&(I.date_from=g.dateFrom),g.dateTo!=null&&g.dateTo.length>0&&(I.date_to=g.dateTo),I})(d);return Object.keys(h).length>0&&m.set("filter",JSON.stringify(h)),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),u!=null&&aK.has(u.field)&&at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=(d.data?.items??[]).map(IU);return p(bU({items:l,nextCursor:d.data?.next_cursor??null,keepExistingListItems:n}))}return p(c_(d.status))})),v((d=>p(c_(f("Unexpected Error","Fetch audit log REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(ah.match),A((()=>{const{planFilters:t}=i.value.invoicingCatalogListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(tB(n.data)):p(rh(n.status)))),v((n=>p(rh(f("Unexpected Error","Fetch catalog counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(E_.match),A((t=>{const{id:e,kind:a}=t.payload,n=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/plans/${encodeURIComponent(e)}`;return r.getJSON(n).pipe(A((o=>T(o)&&o.data!=null?[xr([o.data],"merge"),P_({id:o.data.id,kind:a})]:p(T_({error:o.status,id:e})))),v((o=>p(T_({error:f("Unexpected Error","Fetch catalog item detail REST API call errored out "+JSON.stringify(o)),id:e})))))}))),(s,i)=>s.pipe(S(XU.match),Le(i),y((([r,t])=>{const{cacheOverride:e=!1,id:a,kind:n}=r.payload,o=[],c=a!=null?t.editInvoicingCatalogItemDetailViewState.recordStateById[a]:void 0;a!=null&&Nl({error:c?.error,fetchState:c?.fetchState??"Not-Started"},e)&&o.push(E_({id:a,kind:n}));const d=t.invoicingConfigViewState;Nl({fetchState:d.fetchState,error:d.error},e)&&o.push(Ur());const l=t.invoicingQboViewState;return Nl(l.connectionFetchState,e)&&o.push(A_()),o.push(N_()),o.length>0?_(o):F}))),(s,i)=>s.pipe(S(aB.match),y((r=>{const{cacheOverride:t,planFilters:e,productFilters:a,planSort:n,productSort:o}=r.payload,c=i.value.invoicingCatalogListViewState,d=[];return Ul({fetchState:c.fetchState,error:c.error},t)&&d.push(Cr({filters:e,sort:n})),Ul(c.productFetchState,t)&&d.push(gi({filters:a,sort:o})),Ul(c.countsFetchState,t)&&d.push(ah()),j(_(d))}))),(s,i,r)=>s.pipe(S(Cr.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/plans`,((d,l,u)=>{const m=new URLSearchParams;return d.status!=null&&d.status.length>0&&m.set("status",d.status),d.type!=null&&d.type.length>0&&m.set("type",d.type),d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[xr(l,"merge"),rB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(sh(d.status))})),v((d=>p(sh(f("Unexpected Error","Fetch catalog plan list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(gi.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/plans`,((d,l,u)=>{const m=new URLSearchParams;return d.type!=null&&d.type.length>0&&m.set("type",d.type),d.status!=null&&d.status.length>0&&m.set("status",d.status),d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[xr(l,"merge"),sB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(nh(d.status))})),v((d=>p(nh(f("Unexpected Error","Fetch catalog product list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(Ur.match),A((t=>{const{isInvoicingTosAccepted:e}=i.value.invoicingConfigViewState;if(!t.payload.cacheOverride&&e!=null)return F;const a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/config`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(Ni(n.data)):p(ch(n.status)))),v((n=>p(ch(f("Unexpected Error","Fetch invoicing config REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(d_.match),A((()=>{const{filters:t}=i.value.invoicingCouponViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/discounts/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(EU(n.data)):p(l_(n.status)))),v((n=>p(l_(f("Unexpected Error","Fetch discount counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(k_.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/discounts/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[Gs([n.data],"merge"),B_({id:n.data.id})]:p(D_({id:e,status:n.status})))),v((n=>p(D_({id:e,status:f("Unexpected Error","Fetch discount detail REST API call errored out "+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(mk.match),Le(i),y((([r,t])=>{const{cacheOverride:e=!1,id:a}=r.payload,n=[],o=a!=null?t.editInvoicingCouponDetailViewState.recordStateById[a]:void 0;a!=null&&wE({error:o?.error,fetchState:o?.fetchState??"Not-Started"},e)&&n.push(k_({id:a}));const c=t.invoicingConfigViewState;return wE({error:c.error,fetchState:c.fetchState},e)&&n.push(Ur()),n.length>0?_(n):F}))),(s,i,r)=>s.pipe(S(js.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/discounts`,((d,l,u)=>{const m=new URLSearchParams;return d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[Gs(l,"merge"),PU({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(u_(d.status))})),v((d=>p(u_(f("Unexpected Error","Fetch discount list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(TU.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingCouponViewState,o=[];return BE({fetchState:n.fetchState,error:n.error},t)&&o.push(js({filters:e,sort:a})),BE(n.countsFetchState,t)&&o.push(d_()),j(_(o))}))),(s,i,r)=>s.pipe(S(lh.match),A((()=>{const{filters:t}=i.value.invoicingCreditNoteListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search),t.customerId!=null&&e.set("customer_id",t.customerId);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/credits/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(uB(n.data)):p(uh(n.status)))),v((n=>p(uh(f("Unexpected Error","Fetch credit note counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(dB.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/credits/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[zs([n.data],"merge"),lB({id:n.data.id})]:p(dh(n.status)))),v((n=>p(dh(f("Unexpected Error","Fetch credit note detail REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(ph.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/credits`,((d,l,u)=>{const m=new URLSearchParams;return d.customerId!=null&&m.set("customer_id",d.customerId),d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[zs(l,"merge"),pB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(mh(d.status))})),v((d=>p(mh(f("Unexpected Error","Fetch credit note list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(mB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingCreditNoteListViewState,o=[];return FE({fetchState:n.fetchState,error:n.error},t)&&o.push(ph({filters:e,sort:a})),FE(n.countsFetchState,t)&&o.push(lh()),j(_(o))}))),(s,i,r)=>s.pipe(S(yh.match),A((()=>{const{filters:t}=i.value.invoicingCustomerListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(yB(n.data)):p(_h(n.status)))),v((n=>p(_h(f("Unexpected Error","Fetch customer counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Ys.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[z(vi([n.data])),Ii([n.data],"merge"),bi({id:n.data.id})]:p(M_({id:e,status:n.status})))),v((n=>p(M_({id:e,status:f("Unexpected Error","Fetch customer detail REST API call errored out "+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(Pk.match),y((r=>{const{cacheOverride:t,id:e}=r.payload,a=i.value.editInvoicingCustomerDetailViewState.recordStateById[e],n=i.value.invoicingInvoiceListState,o=n.invoiceByTab[n.activeTab],c=i.value.invoicingSettingsViewState,d=[];return Cl({fetchState:a?.fetchState??"Not-Started",error:a?.error},t)&&d.push(Ys({id:e})),n.filters.customerId===e&&!Cl({fetchState:o?.fetchState??"Not-Started",error:o?.error},t)||d.push(Ei({filters:{customerId:e}})),Cl({fetchState:c.fetchState,error:c.error},t)&&d.push(Vt()),d.push(V_({cacheOverride:t,customerId:e})),j(_(d))}))),(s,i,r)=>s.pipe(S(Ks.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers`,((d,l,u)=>{const m=new URLSearchParams;return d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[Ii(l,"merge"),z(vi(l)),_B({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(hh(d.status))})),v((d=>p(hh(f("Unexpected Error","Fetch customer list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(hB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingCustomerListViewState,o=[];return qE({fetchState:n.fetchState,error:n.error},t)&&o.push(Ks({filters:e,sort:a})),qE(n.countsFetchState,t)&&o.push(yh()),j(_(o))}))),(s,i,r)=>s.pipe(S(k0.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import/status`;return r.getJSON(t).pipe(A((e=>T(e)?p(LU(e.data??[])):p(g_(e.status)))),v((e=>p(g_(f("Unexpected Error","Fetch data import status REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Eh.match),A((()=>{const{filters:t}=i.value.invoicingDunningCaseListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(bB(n.data)):p(Ph(n.status)))),v((n=>p(Ph(f("Unexpected Error","Fetch dunning case counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Sh.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[Oi([n.data],"merge"),SB({id:n.data.id})]:p(gh(n.status)))),v((n=>p(gh(f("Unexpected Error","Fetch dunning case detail REST API call errored out "+JSON.stringify(n)))))))}))),(s,i)=>s.pipe(S(gB.match),Le(i),y((([r,t])=>{const{cacheOverride:e,id:a}=r.payload,n=t.invoicingDunningCaseDetailViewState,o=[];return n.id===a&&!((c,d)=>d||c.fetchState!=="Completed"&&c.fetchState!=="In-Progress")({error:n.error,fetchState:n.fetchState},e)||o.push(Sh({id:a})),o.push(fh({id:a,cacheOverride:e})),o.length>0?_(o):F}))),(s,i,r)=>s.pipe(S(Th.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning`,((d,l,u)=>{const m=new URLSearchParams;return d.search!=null&&d.search.length>0&&m.set("search",d.search),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[Oi(l,"merge"),EB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(Ah(d.status))})),v((d=>p(Ah(f("Unexpected Error","Fetch dunning case list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(PB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingDunningCaseListViewState,o=[];return jE({fetchState:n.fetchState,error:n.error},t)&&o.push(Th({filters:e,sort:a})),jE(n.countsFetchState,t)&&o.push(Eh()),j(_(o))}))),(s,i,r)=>s.pipe(S(vh.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/${encodeURIComponent(e)}/email-preview`;return r.postAndGetJSON(a,{}).pipe(nt((n=>{return T(n)&&n.data!=null?fB({id:e,preview:(o=n.data,{body:o.body,bodyToken:o.body_token,cc:o.cc,renderedHtmlTemplate:o.rendered_html_template,subject:o.subject,subjectToken:o.subject_token,to:o.to})}):Ih({id:e,status:n.status});var o})),v((n=>p(Ih({id:e,status:f("Unexpected Error",`Dunning email preview REST API call errored out: ${n instanceof Error?n.message:String(n)}`)})))))}))),(s,i)=>s.pipe(S(fh.match),y((r=>{const{cacheOverride:t,id:e}=r.payload,a=i.value.invoicingDunningCaseDetailViewState;return a.id!==e?F:((n,o)=>o||n.fetchState!=="Completed"&&n.fetchState!=="In-Progress")(a.emailPreview,t)?p(vh({id:e})):F}))),(s,i,r)=>s.pipe(S(FU.match),A((t=>{const{cursor:e,level:a,moduleId:n,outcome:o,search:c,sessionId:d}=t.payload,l=new URLSearchParams;e!=null&&l.set("cursor",e),n!=null&&l.set("module_id",n),a!=null&&l.set("level",a),o!=null&&l.set("outcome",o),c!=null&&c.trim()!==""&&l.set("search",c.trim());const u=l.toString(),m=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import/${encodeURIComponent(d)}/issues${u===""?"":`?${u}`}`;return r.getJSON(m).pipe(A((h=>T(h)&&h.data!=null?p(qU({append:e!=null,page:h.data,sessionId:d})):p(f_({error:h.status,sessionId:d})))),v((h=>p(f_({error:f("Unexpected Error","Fetch migration diagnostics REST API call errored out "+JSON.stringify(h)),sessionId:d})))))}))),(s,i,r)=>s.pipe(S(jU.match),A((t=>{const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import/${encodeURIComponent(t.payload)}`;return r.getJSON(e).pipe(A((a=>T(a)&&a.data!=null?p(B0(a.data)):p(v_(a.status)))),v((a=>p(v_(f("Unexpected Error","Fetch migration session REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(D0.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import/sessions`;return r.getJSON(t).pipe(A((e=>T(e)?p(GU(e.data??[])):p(I_(e.status)))),v((e=>p(I_(f("Unexpected Error","Fetch migration sessions REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Nh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/churn?months=6&year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(TB(a.data)):p(Oh(a.status)))),v((a=>p(Oh(f("Unexpected Error","Fetch overview churn REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Ch.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/dashboard-summary?year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(AB(a.data)):p(xh(a.status)))),v((a=>p(xh(f("Unexpected Error","Fetch overview dashboard summary REST API call errored out "+JSON.stringify(a)))))))}))),(s,i)=>s.pipe(S(NB.match),y((r=>{const{cacheOverride:t}=r.payload,e=i.value,a=e.invoicingOverviewState,n=[];Tt(a.kpisFetchState,t)&&n.push(Uh()),Tt(a.revenueFetchState,t)&&n.push(kh()),Tt(a.mrrFetchState,t)&&n.push(Bh()),Tt(a.churnFetchState,t)&&n.push(Nh()),Tt(a.planRevenueFetchState,t)&&n.push(Dh()),Tt(a.summaryFetchState,t)&&n.push(Ch()),Tt(OB(e),t)&&n.push(Vt());const o=CB(e);return Tt({fetchState:o.fetchState,error:o.error},t)&&n.push(Ci({})),j(_(n))}))),(s,i,r)=>s.pipe(S(Uh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/kpis?year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(xB(a.data)):p(Jh(a.status)))),v((a=>p(Jh(f("Unexpected Error","Fetch overview KPIs REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Bh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/mrr?months=6&year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(UB(a.data)):p(wh(a.status)))),v((a=>p(wh(f("Unexpected Error","Fetch overview MRR REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Dh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/plan-revenue?year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(kB(a.data)):p($h(a.status)))),v((a=>p($h(f("Unexpected Error","Fetch overview plan revenue REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(kh.match),A((()=>{const{period:t}=i.value.invoicingOverviewState;if(t==null)return F;const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return r.getJSON(`${e}/analytics/revenue?months=12&year=${t.year}&month=${t.month}`).pipe(A((a=>T(a)&&a.data!=null?p(BB(a.data)):p(Rh(a.status)))),v((a=>p(Rh(f("Unexpected Error","Fetch overview revenue REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(L_.match),A((t=>{const{customerId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(e)}/payment-link/email-preview`;return r.postAndGetJSON(a,{}).pipe(nt((n=>{return T(n)&&n.data!=null?Tk({customerId:e,preview:(o=n.data,{body:o.body,bodyToken:o.body_token,renderedHtmlTemplate:o.rendered_html_template,subject:o.subject,subjectToken:o.subject_token,to:o.to})}):F_({customerId:e,status:n.status});var o})),v((n=>p(F_({customerId:e,status:f("Unexpected Error",`Payment link email preview REST API call errored out: ${n instanceof Error?n.message:String(n)}`)})))))}))),(s,i)=>s.pipe(S(V_.match),y((r=>{const{cacheOverride:t,customerId:e}=r.payload,{emailPreviewCustomerId:a,emailPreviewFetchState:n}=i.value.editInvoicingCustomerDetailViewState;return a!==e||((o,c)=>c||o.fetchState!=="Completed"&&o.fetchState!=="In-Progress")(n,t)?p(L_({customerId:e})):F}))),(s,i,r)=>s.pipe(S(JU.match),A((t=>{const{customerId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/plaid/link-token?customer_id=${encodeURIComponent(e)}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(wU(n.data.link_token)):p(__(n.status)))),v((n=>p(__(f("Unexpected Error","Plaid link token REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(A_.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/connection`;return r.getJSON(t).pipe(nt((e=>T(e)?DB(GE(e.data??{connected:!1})):Vh(e.status))),v((e=>p(Vh(f("Unexpected Error","Fetch QBO connection REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(xi.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/sync-health`;return r.getJSON(t).pipe(nt((e=>{return T(e)?JB({connection:(a=e.data??{}).connection!=null?GE(a.connection):void 0,countsByStatus:a.counts_by_status??{},failedTasks:(a.failed_tasks??[]).map((n=>({attempts:n.attempts,entityId:n.entity_id,entityType:n.entity_type,taskId:n.task_id,lastError:n.last_error??void 0,updatedAt:n.updated_at??void 0})))}):Lh(e.status);var a})),v((e=>p(Lh(f("Unexpected Error","Fetch QBO sync health REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(Vt.match),A((()=>{const t=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;return r.getJSON(t).pipe(A((e=>{if(T(e)&&e.data!=null){const a=e.data.address;return[...a!=null?[z([a])]:[],eS(e.data)]}return p(tS(e.status))})),v((e=>p(tS(f("Unexpected Error","Fetch settings REST API call errored out "+JSON.stringify(e)))))))}))),(s,i,r)=>s.pipe(S(jh.match),A((()=>{const{filters:t}=i.value.invoicingSubscriptionListViewState,e=new URLSearchParams;t.search!=null&&t.search.length>0&&e.set("search",t.search),t.customerId!=null&&e.set("customer_id",t.customerId);const a=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/subscriptions/counts`,e);return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?p(VB(n.data)):p(Gh(n.status)))),v((n=>p(Gh(f("Unexpected Error","Fetch subscription counts REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Pi.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/subscriptions/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[z(xa([n.data])),Ua([n.data],"merge"),Ti({id:n.data.id})]:p(G_({error:n.status,id:e})))),v((n=>p(G_({error:f("Unexpected Error","Fetch subscription detail REST API call errored out "+JSON.stringify(n)),id:e})))))}))),(s,i)=>s.pipe(S(kk.match),Le(i),y((([r,t])=>{const{cacheOverride:e=!1,id:a}=r.payload,n=[],o=a!=null?t.editInvoicingSubscriptionDetailViewState.recordStateById[a]:void 0;a!=null&&Mn({error:o?.error,fetchState:o?.fetchState??"Not-Started"},e)&&n.push(Pi({id:a}));const c=t.invoicingConfigViewState;Mn({error:c.error,fetchState:c.fetchState},e)&&n.push(Ur());const d=t.invoicingCatalogListViewState;Mn({error:d.error,fetchState:d.fetchState},e)&&n.push(Cr({filters:{type:"plan"},keepExistingListItems:!1}));const l=t.invoicingCouponViewState;return Mn({error:l.error,fetchState:l.fetchState},e)&&n.push(js({filters:{},keepExistingListItems:!1})),n.length>0?_(n):F}))),s=>s.pipe(S(Bk.match),y((i=>{const{subscriptionId:r}=i.payload,t=[Ks({filters:{},keepExistingListItems:!1}),Cr({filters:{},keepExistingListItems:!1}),js({filters:{},keepExistingListItems:!1})];return r!=null&&t.push(Pi({id:r})),j(_(t))}))),(s,i,r)=>s.pipe(S(Ci.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,c=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/subscriptions`,((d,l,u)=>{const m=new URLSearchParams;return d.customerId!=null&&m.set("customer_id",d.customerId),d.search!=null&&d.search.length>0&&m.set("search",d.search),d.startedFrom!=null&&m.set("started_from",d.startedFrom),d.startedTo!=null&&m.set("started_to",d.startedTo),m.set("limit",String(tt)),l!=null&&m.set("cursor",l),at(m,u),m})(e,a,o));return r.getJSON(c).pipe(A((d=>{if(T(d)){const l=d.data?.items??[];return[Ua(l,"merge"),z(xa(l)),LB({ids:l.map((u=>u.id)),nextCursor:d.data?.next_cursor??null,keepExistingListItems:n})]}return p(zh(d.status))})),v((d=>p(zh(f("Unexpected Error","Fetch subscription list REST API call errored out "+JSON.stringify(d)))))))}))),(s,i)=>s.pipe(S(FB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingSubscriptionListViewState,o=[];return zE({fetchState:n.fetchState,error:n.error},t)&&o.push(Ci({filters:e,sort:a})),zE(n.countsFetchState,t)&&o.push(jh()),j(_(o))}))),(s,i,r)=>s.pipe(S(qB.match),A((t=>{const{id:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/payments/${e}`;return r.getJSON(a).pipe(A((n=>T(n)&&n.data!=null?[Zs([n.data],"merge"),jB({id:n.data.id})]:p(Kh(n.status)))),v((n=>p(Kh(f("Unexpected Error","Fetch payment detail REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(Hh.match),A((t=>{const{filters:e,cursor:a,keepExistingListItems:n,sort:o}=t.payload,{activeTab:c}=i.value.invoicingTransactionListViewState,d=c!=="all"?c:void 0,l=Pe(`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/payments`,((u,m,h,g)=>{const I=new URLSearchParams;return u.status!=null&&u.status.length>0&&I.set("status",u.status),m!=null&&m.length>0&&I.set("type",m),u.customerId!=null&&I.set("customer_id",u.customerId),u.search!=null&&u.search.length>0&&I.set("search",u.search),I.set("limit",String(tt)),h!=null&&I.set("cursor",h),at(I,g),I})(e,d,a,o));return r.getJSON(l).pipe(A((u=>{if(T(u)){const m=u.data?.items??[];return[Zs(m,"merge"),KB({ids:m.map((h=>h.id)),nextCursor:u.data?.next_cursor??null,keepExistingListItems:n})]}return p(Qh(u.status))})),v((u=>p(Qh(f("Unexpected Error","Fetch payment list REST API call errored out "+JSON.stringify(u)))))))}))),(s,i)=>s.pipe(S(YB.match),y((r=>{const{cacheOverride:t,filters:e,sort:a}=r.payload,n=i.value.invoicingTransactionListViewState,o=n.byTab[n.activeTab]??HB(),c=[];return((d,l)=>l||d.fetchState!=="Completed"&&d.fetchState!=="In-Progress")({fetchState:o.fetchState,error:o.error},t)&&c.push(Hh({filters:e,sort:a})),j(_(c))}))),(s,i)=>s.pipe(S(wV.match),y((r=>{const{cacheOverride:t,isDebitCardFlagEnabled:e,isCreditCardFlagEnabled:a}=r.payload,n=[],o=i.value;if(t===!0)n.push(Wt()),a&&n.push(Zt()),n.push($e("cardHolderCandidate",!0)),n.push(se()),n.push(jr()),e&&n.push(bn());else{const c=o.chargeCardConfigState;c.fetchState!=="In-Progress"&&c.hasValidState()===!1&&n.push(Wt());const d=o.chargeCardListState;d.creditAccount.fetchState!=="Completed"&&d.creditAccount.fetchState!=="In-Progress"&&a&&n.push(Zt());const l=o.userListViewState.userListByType.cardHolderCandidate;l.fetchState!=="In-Progress"&&l.hasValidState()===!1&&n.push($e("cardHolderCandidate",!1)),o.classListState.hasValidState()===!1&&o.classListState.fetchState!=="In-Progress"&&n.push(se()),d.fetchState!=="Completed"&&d.fetchState!=="In-Progress"&&n.push(jr());const u=o.issueChargeCardState.depositAccountsFetchState;e&&u.fetchState!=="Completed"&&u.fetchState!=="In-Progress"&&n.push(bn())}return j(_(n))}))),(s,i,r)=>s.pipe(S(q1.match),A((t=>{const{routingNumber:e,cacheOverride:a}=t.payload,{bankAccount:n}=i.value.magicLinkViewState,o=n.bankNameByRouting[e]?.bankName;if(a===!1&&o)return p(j1(e));{const c={routing_numbers:[e]},d=`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`;return r.getJSON(d).pipe(y((l=>T(l)?p(G1({routingNumber:e,institutions:l.data?.institutions??[]})):p(gv({routingNumber:e,status:l.status})))),v((l=>p(gv({routingNumber:e,status:f("Unexpected Error","Get Bank Name By Routing REST API call errored out"+JSON.stringify(l))})))))}}))),(s,i,r)=>s.pipe(S(z1.match),A((t=>{const{swiftCode:e,cacheOverride:a}=t.payload,{bankAccount:n}=i.value.magicLinkViewState,o=n.bankNameBySwift[e]?.bankName;if(a===!1&&o)return p(K1(e));{const c={swift_code:e},d=`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/institutions?query=${JSON.stringify(c)}`;return r.getJSON(d).pipe(y((l=>T(l)?p(Y1({swiftCode:t.payload.swiftCode,institutions:l.data?.institutions??[]})):p(fv({swiftCode:e,status:l.status})))),v((l=>p(fv({swiftCode:e,status:f("Unexpected Error","Get Bank Name By Swift REST API call errored out"+JSON.stringify(l))})))))}}))),(s,i,r)=>s.pipe(S(H1.match),y((t=>{const{billId:e}=t.payload;let a=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}`;return a+=`?query=${encodeURIComponent(JSON.stringify({transaction_type:"bill",bill_pay_provider:"zeni",view:"vendor"}))}`,r.getJSON(a).pipe(y((n=>{if(T(n)){const o=n.data?.transaction?.attachments?.[0],c=o!=null?Q1(o):void 0;return p(W1({currencySymbol:n.data?.transaction?.currency_symbol??"",amount:n.data?.transaction?.total_amount??0,billAttachment:c}))}return p(vv({status:n.status}))})),v((n=>p(vv({status:f("Unexpected Error","Fetch MagicLink Bill REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(Z1.match),A((t=>{const{vendorId:e,tenantEmailDomain:a,token:n}=t.payload,o=`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/namespaces/${a}/vendors/${e}/session`;return r.getJSON(o,{"auth-token":n}).pipe(A((c=>T(c)?p(X1({tenantId:c.data?.tenants[0].tenant_id??"",companyName:c.data?.companies[0].name??"",userId:c.data?.session_info.user_id??"",sessionId:c.data?.session_info.session_id??""})):p(Iv({status:c.status})))),v((c=>p(Iv({status:f("Unexpected Error","Fetch MagicLink Tenant REST API call errored out"+JSON.stringify(c))})))))}))),(s,i)=>s.pipe(S(tO.match),A((r=>{const{cacheOverride:t,fetchFullResponse:e,companyId:a}=r.payload;if(t===!0)return _([fa(e,a),je()]);const n=i.value,o=[];return n.companyViewState.zeniUsers.fetchState==="In-Progress"||n.companyViewState.zeniUsers.hasValidState()||o.push(je()),n.companyViewState.managementView.fetchState==="In-Progress"||n.companyViewState.managementView.hasValidState()||o.push(fa(e,a)),_(o)}))),(s,i,r)=>s.pipe(S(ld.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/merchants?query=${encodeURIComponent(JSON.stringify({is_include_accounting_classes_info:!0,is_include_accounts_info:!0}))}`).pipe(y((t=>T(t)?p(ud(t.data?.merchants??[]),aL(t),Ke("class_list",t.data?.accounting_classes??[]),W(t.data?.accounts??[],"account_list")):p(eI(t.status)))),v((t=>p(eI(f("Unexpected Error","Fetch Merchants REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(uD.match),A((t=>{const{period:e}=t.payload,a={month_and_year:`${String(e.month).padStart(2,"0")}-${e.year}`};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/month-close/performance-trend?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>{if(n.data!=null){const o=[pD({performanceTrend:n.data.performance_trend,period:e})];return _(o)}{const o=[sS({period:e,fetchState:"Error",error:n.status})];return _(o)}})),v((n=>{const o=[sS({period:e,fetchState:"Error",error:f("Unexpected error",`Fetch Month close performance trend REST API call errored out: ${JSON.stringify(n)}`)})];return _(o)})))}))),(s,i,r)=>s.pipe(S(et.match),A((t=>{const{period:e,tenantId:a,refreshViewInBackground:n}=t.payload,o={month_and_year:`${String(e.month).padStart(2,"0")}-${e.year}`,history_month_and_year_flag:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/month-close/checks?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((c=>{if(c.data!=null){const d=[mD({monthEndCloseChecksPayload:c.data,tenantId:a,period:e}),Ui({tenantId:a,period:e,fetchState:"Completed",refreshViewInBackground:n})];return _(d)}{const d=[Ui({tenantId:a,period:e,fetchState:"Error",error:c.status,refreshViewInBackground:n})];return _(d)}})),v((c=>{const d=[Ui({tenantId:a,period:e,fetchState:"Error",refreshViewInBackground:n,error:f("Unexpected error","Fetch Month end close checks REST API call errored out"+JSON.stringify(c))})];return _(d)})))}))),(s,i,r)=>s.pipe(S(Ex.match),$t((()=>{const t=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:e},expenseAutomationMissingReceiptsViewState:{bulkUpload:a}}=t,n=e[H(t).tenantId];if(n==null)return p(Ar());const o=Ee(n),c=a.batchListByPeriod[o]??[],d=new Set(a.failedBatchDetailIds),l=Jy(c).filter((m=>a.batchDetailsById[m.batchId]==null&&!d.has(m.batchId))).map((m=>m.batchId));if(l.length===0)return p(Ar());const u=l.slice(0,5);return j(kE(u,r),p(Ar())).pipe(v((m=>p(Px({error:f("Unexpected Error","Fetch more batch details errored out: "+JSON.stringify(m))})))))}))),(s,i,r)=>s.pipe(S(Js.match),y((t=>{const e=t.payload.batchList,a=i.value.expenseAutomationMissingReceiptsViewState.bulkUpload,{batchDetailsById:n,batchDetailsRevalidating:o}=a,c=Jy(e),d=(o===!0?c:c.filter((l=>n[l.batchId]==null))).map((l=>l.batchId)).slice(0,5);if(d.length===0){const l=a.currentBatchId;return l!=null&&a.phase==="matching"&&a.batchDetailsById[l]==null&&Cy(a.batchStatusById,a.batchListByPeriod,l)?p(ci()):p(Ar())}return j(p(bx()),kE(d,r),p(Ar()))}))),VG,LG,(s,i)=>s.pipe(S(iS.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Lt("month"),Lt("quarter"),Lt("year")]);{const e=[],a=i.value.netBurnOrIncomeClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Lt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Lt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Lt("year")),_(e)}}))),(s,i)=>s.pipe(S(Ts.match),y((r=>{const{cacheOverride:t,forecastId:e}=r.payload;if(t===!0)return _([Ba("month",e),Ba("quarter",e),Ba("year",e)]);{const a=[],n=_D(i.value.netBurnOrIncomeState,i.value.netBurnOrIncomeState.uiState.isForecastModeOn,e).fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(Ba("month",e)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(Ba("quarter",e)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(Ba("year",e)),_(a)}}))),(s,i,r)=>s.pipe(S(Lt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_class:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/net_burn_or_income?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[];return n.push(oe(t.payload.timeframe,"cogs","net_burn_or_income_by_classes",a.data.report.cogs,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(oe(t.payload.timeframe,"expenses","net_burn_or_income_by_classes",a.data.report.expenses,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(oe(t.payload.timeframe,"income","net_burn_or_income_by_classes",a.data.report.income,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(hD({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(cS(a.status,t.payload.timeframe))})),v((a=>p(cS(f("Unexpected Error","P&L REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),FG,(s,i,r)=>s.pipe(S(Ft.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_project:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/net_burn_or_income?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,"cogs","net_burn_or_income_by_projects",o.cogs,o.accounts,c)),n.push(ie(t.payload.timeframe,"expenses","net_burn_or_income_by_projects",o.expenses,o.accounts,c)),n.push(ie(t.payload.timeframe,"income","net_burn_or_income_by_projects",o.income,o.accounts,c)),n.push(SD({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(dS(a.status,t.payload.timeframe))})),v((a=>p(dS(f("Unexpected Error","Net Burn by Projects REST API call errored out"+(a instanceof Error?a.message:String(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(lS.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Ft("month"),Ft("quarter"),Ft("year")]);{const e=[],a=i.value.netBurnOrIncomeProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Ft("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Ft("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Ft("year")),_(e)}}))),(s,i,r)=>s.pipe(S(zo.match),y((t=>{const{fetchFullReport:e}=t.payload,a={is_full_response:e};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/net_burn_or_income_story_card?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[gD(n.data)];return _(o)}return p(uS(n.status))})),v((n=>p(uS(f("Unexpected Error","NetBurnOrIncome Story Card REST API call errored out"+JSON.stringify(n)))))))}))),(s,i)=>s.pipe(S(nS.match),y((r=>{const{cacheOverride:t,forecastId:e}=r.payload,a=yD(i.value),n=ki(i.value.forecastState,i.value.forecastListState,a.dataAvailable),o=Bi(i.value.forecastState,i.value.forecastListState),c=((d,l)=>d!=null&&((u,m)=>{let h=!1;for(let g=0;g<m.length;++g)if(m[g].id===u){h=!0;break}return h})(d,l)?d:l.length>0?l[0].id:void 0)(e,n.forecasts);if(c!=null){const d=[],l=o.forecasts.map((u=>u.id));return d.push(Dr(a.firstMonthOfFY,!0,void 0,{id:c,index:l.indexOf(c)})),t===!0||((u,m)=>{const h=Mm(u,m);return h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"})(c,i.value.netBurnOrIncomeState)?d.push(Ts(!1,c)):console.log("Required data is already there!! No need to fire any fetch!"),_(d)}if(c==null&&o.fetchState==="Completed"&&o.forecasts.length===0)return _([]);if(c==null&&(o.fetchState==="Completed"||o.fetchState==="Error"||o.forecasts.length>0)){console.warn("Atleast one of the forecast in the list should be valid!");const d=[ka(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"month"),ka(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"year"),ka(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"quarter")];return _([d])}if(c==null&&o.forecasts.length===0)return _([Fs(),oS(t,e)]);{console.warn("Invlid state!!");const d=[ka(f("Unexpected error","Unexpected error"),r.payload.forecastId,"month"),ka(f("Unexpected error","Unexpected error"),r.payload.forecastId,"year"),ka(f("Unexpected error","Unexpected error"),r.payload.forecastId,"quarter")];return _([d])}}))),(s,i,r)=>s.pipe(S(aR.match),A((()=>{const t=i.value,e=t.tenantState.loggedInUser?.userEmail;if(e==null)return _([]);const a=t.notificationPreferencesViewState.saveEpoch,n=t.notificationRegistryState.registryEpoch;return r.getJSON(mf(r)).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[rR(o.data,e)];return c.push(sR({registry:o.data.task_checklist_registry??void 0,registryEpochAtDispatch:n})),o.data.task_checklist_preferences!=null&&c.push(nR({preferences:o.data.task_checklist_preferences,saveEpochAtDispatch:a})),p(...c)}return p(yf(o.status))})),v((o=>p(yf(f("Unexpected error","Fetch Notification Settings REST API call errored out"+JSON.stringify(o)))))))}))),s=>s.pipe(S(oR.match),A((i=>{const{hasMonthEndAccess:r,companyId:t}=i.payload;return _(r?[$e("manager",!0),se()]:[dr(t)])}))),qG,(s,i,r)=>s.pipe(S(fD.match),Oa((t=>{const{notificationGroup:e,mode:a,status:n,isNewNotificationFetch:o}=t.payload,{stateByTab:c}=i.value.notificationViewState,d=c[mS(e)],l={status:n,notification_group:e,is_paginated:!0,limit:10,mode:a,page_token:o?null:d.uiState.pageToken};return r.getJSON(`${r.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/user-notification?query=${encodeURIComponent(JSON.stringify(l))}`).pipe(y((u=>{if(T(u)&&u.data!=null){const{notifications:m,total_count:h,next_page_token:g}=u.data,I=[];m.forEach((E=>{I.push(...E.data.authors)}));const b=[...new Map(I.map((E=>[E.user_id,E]))).values()];return[V({users:b,updateType:"merge"}),vD(m,"replace"),ID(m,h,e,o?null:g)]}return p(pS({status:u.status,notificationGroup:e}))})),v((u=>p(pS({status:f("Unexpected Error","Fetch Notification View API call errored out"+JSON.stringify(u)),notificationGroup:e})))))}))),(s,i,r)=>s.pipe(S(hr.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/whitelist-companies?query=${encodeURIComponent(JSON.stringify({is_onboarding_completed:!0}))}`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=t.data.companies.map((n=>n.company_id)),a=[SS({payload:t.data.companies,schema:{}}),ND(e)];return _(a)}return p(fS(t.status))})),v((t=>p(fS(f("Unexpected error","Onboarding Company view errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Li.match),A((t=>{const{companyId:e,cacheOverride:a,reCalculateCurrentStep:n}=t.payload,{onboardingCustomerViewState:o,companyState:c}=i.value,d=Te(c,e)?.company;if(a===!0||d==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"onboarding_setup"}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=l.data.payment_accounts.map((g=>g.payment_account_id)),m=l.data.subscription_payment_accounts.map((g=>g.subscription_payment_account_id)),h=[V({users:l.data.users}),Y(l.data.user_roles),Q({payload:l.data.companies,schema:{}}),z(l.data.addresses),ve({files:l.data.files}),W(l.data.accounts,"onboarding"),Se(l.data.payment_accounts),hp(l.data.subscription_payment_accounts),wS(u,m),sn({companyId:l.data.companies[0].company_id,reCalculateCurrentStep:n}),JS()];return _(h)}return p(N({messageSection:"onboarding_customer_view",messageText:"failed",type:"error"}),$S(l.status))})),v((l=>p($S(f("Unexpected Error","Fetch Customer Onboarding view errored out"+JSON.stringify(l)))))));{const{subscriptionPaymentAccountIds:l,paymentAccountDetails:u}=o;return p(wS(u.paymentAccountIds,l),sn({companyId:e,reCalculateCurrentStep:n}),JS())}}))),(s,i)=>s.pipe(S(cJ.match),A((r=>{const{companyId:t,cacheOverride:e,reCalculateCurrentStep:a}=r.payload;if(e===!0)return p(Li(t,e,a),RS());{const n=i.value,o=[];return n.onboardingCustomerViewState.fetchState==="In-Progress"||n.onboardingCustomerViewState.hasValidState()||o.push(Li(t,e,a)),n.companyConfigState.fetchState==="In-Progress"||n.companyConfigState.hasValidState()||o.push(RS()),_(o)}}))),(s,i)=>s.pipe(S(aO.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([je(),yr(!0),_r(),hr()]);{const e=i.value,a=[];return e.companyViewState.zeniUsers.fetchState==="In-Progress"||e.companyViewState.zeniUsers.hasValidState()||a.push(je()),e.onboardingCockpitViewState.fetchState==="In-Progress"||e.onboardingCockpitViewState.hasValidState()||a.push(yr(!0)),e.onboardingCockpitViewState.qboConnectionPool.fetchState==="In-Progress"||e.onboardingCockpitViewState.qboConnectionPool.hasValidState()||a.push(_r()),e.onboardingCockpitViewState.onboardingCompletedCompanies.fetchState==="In-Progress"||e.onboardingCockpitViewState.onboardingCompletedCompanies.hasValidState()||a.push(hr()),_(a)}}))),(s,i,r)=>s.pipe(S($C.match),y((t=>{const{accrualId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${e}`).pipe(y((a=>T(a)&&a.data!=null?_([Ta([a.data.accrual]),RC({accrualId:e})]):_([gy({accrualId:e,status:a.status})]))),v((a=>_([gy({accrualId:e,status:f("Unexpected Error",`Fetch one-time accrual REST API call errored out ${JSON.stringify(a)}`)})]))),De(s.pipe(S(gt.match))))}))),(s,i)=>s.pipe(S(ZS.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Jr("month","",null),Jr("quarter","",null),ji(!0)]);{const e=[],a=i.value.opExByVendorState.reportFetchState,n=i.value.opExByVendorState.summaryFetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Jr("month","",null)),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Jr("quarter","",null)),n.fetchState!=="In-Progress"&&n.fetchState!=="Completed"&&e.push(ji()),_(e)}}))),(s,i,r)=>s.pipe(S(Jr.match),y((t=>{const e=i.value.opExByVendorState.uiState,a=e.sortOrder[e.timeframe]==="descending"?"desc":"asc",n=e.pageLimit,o=t.payload.fetchNextPage===!1?null:e.pageToken[t.payload.timeframe],c={sortKey:e.sortKey[e.timeframe],sortOrder:e.sortOrder[e.timeframe],searchString:e.searchString[e.timeframe],fetchNextPage:t.payload.fetchNextPage,pageLimit:n},d={time_series_groups:[(l=>{switch(l){case"month":return"months";case"quarter":return"quarters"}})(t.payload.timeframe)],sort_by:e.sortKey[e.timeframe],sort_order:a,search_text:e.searchString[e.timeframe],page_token:o};return n!=null&&(d.page_limit=n),t.payload.searchText&&(d.search_text=t.payload.searchText,c.searchString=t.payload.searchText),r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses_by_vendor?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(l.data!=null&&T(l)){const u=[],m=l.data.report;if(m.status.is_report_generated==null||m.status.is_report_generated===!0){const h=l.data.report.vendors;h!=null&&u.push(le(h,"merge"));const g=m.accounts;g!=null&&u.push(W(g,"operating_expenses_by_vendor",void 0,"merge"));const I=m.accounting_class;I!=null&&u.push(Ke("operating_expenses_by_vendor",I,void 0,"merge"))}return u.push(RJ(t.payload.timeframe,m,c)),_(u)}return p(XS(l.status,t.payload.timeframe))})),v((l=>p(XS(f("Unexpected Error","Opex By Vendor Report for Timeframe REST API call errored out"+JSON.stringify(l)),t.payload.timeframe)))))}))),(s,i,r)=>s.pipe(S(ji.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses_by_vendor_summary?query=${encodeURIComponent(JSON.stringify({is_full_response:!0,accounting_method:"accrual"}))}`).pipe(y((t=>{if(T(t)){const e=[],a=t.data?.report;return a!=null&&(a?.status.is_report_generated!=null&&a?.status.is_report_generated===!1?eg(!1):(e.push(eg(!0)),a?.vendors!=null&&e.push(le(a.vendors,"merge"))),e.push(MJ(a))),_(e)}return p(tg(t.status))})),v((t=>p(tg(f("Unexpected error","Fetch OpEx by Vendor Summary REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(rg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([qt("month"),qt("quarter"),qt("year")]);{const e=[],a=i.value.opExClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(qt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(qt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(qt("year")),_(e)}}))),(s,i)=>s.pipe(S(Es.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;if(t===!0)return _([wa("month",e),wa("quarter",e),wa("year",e)]);{const a=[],n=$J(i.value.opExState,i.value.opExState.uiState.isForecastModeOn,e).fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(wa("month",e)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(wa("quarter",e)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(wa("year",e)),_(a)}}))),(s,i,r)=>s.pipe(S(qt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_class:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[];return n.push(oe(t.payload.timeframe,"expenses","operating_expenses_by_classes",a.data.report.expenses,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(FJ({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(sg(a.status,t.payload.timeframe))})),v((a=>p(sg(f("Unexpected Error","OpEx REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),(s,i,r)=>s.pipe(S(jt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_project:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/operating_expenses?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,"expenses","operating_expenses_by_projects",o.expenses,o.accounts,c)),n.push(qJ({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(ng(a.status,t.payload.timeframe))})),v((a=>p(ng(f("Unexpected Error","OpEx by Projects REST API call errored out"+(a instanceof Error?a.message:String(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(og.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([jt("month"),jt("quarter"),jt("year")]);{const e=[],a=i.value.opExProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(jt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(jt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(jt("year")),_(e)}}))),jG,(s,i)=>s.pipe(S(QS.match),y((r=>{const{cacheOverride:t,forecastId:e}=r.payload,a=wJ(i.value),n=ki(i.value.forecastState,i.value.forecastListState,a.dataAvailable),o=Bi(i.value.forecastState,i.value.forecastListState),c=((d,l)=>d!=null&&((u,m)=>{let h=!1;for(let g=0;g<m.length;++g)if(m[g].id===u){h=!0;break}return h})(d,l)?d:l.length>0?l[0].id:void 0)(e,n.forecasts);if(c!=null){const d=[],l=o.forecasts.map((u=>u.id));return d.push(Dr(a.firstMonthOfFY,!0,void 0,{id:c,index:l.indexOf(c)})),t===!0||((u,m)=>{const h=Rm(u,m);return h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"})(c,i.value.opExState)?d.push(Es(!1,c)):console.log("Required data is already there!! No need to fire any fetch!"),_(d)}if(c==null&&o.fetchState==="Completed"&&o.forecasts.length===0)return _([]);if(c==null&&(o.fetchState==="Completed"||o.fetchState==="Error"||o.forecasts.length>0)){console.warn("Atleast one of the forecast in the list should be valid!");const d=[Ja(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"month"),Ja(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"year"),Ja(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"quarter")];return _([d])}if(c==null&&o.forecasts.length===0)return _([Fs(),WS(t,e)]);{console.warn("Invlid state!!");const d=[Ja(f("Unexpected error","Unexpected error"),r.payload.forecastId,"month"),Ja(f("Unexpected error","Unexpected error"),r.payload.forecastId,"year"),Ja(f("Unexpected error","Unexpected error"),r.payload.forecastId,"quarter")];return _([d])}}))),(s,i,r)=>s.pipe(S(ct.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/vendor-owners`).pipe(y((t=>{if(T(t)){const e=t.data?.users??[],a=[];return a.push(jJ({users:e})),a.push(V({users:e})),_(a)}return p(ig({fetchState:"Error",error:t.status}))})),v((t=>p(ig({fetchState:"Error",error:f("Unexpected Error","Fetch owner REST API call errored out"+JSON.stringify(t))})))))))),(s,i)=>s.pipe(S(lO.match),A((r=>{const t=i.value,e=[];return t.companyViewState.parentSubsidiaryView.subsidiaryByParentCompanyId[r.payload.companyParentId]==null&&e.push(fa(r.payload.fetchFullResponse,r.payload.companyParentId)),t.companyViewState.zeniUsers.fetchState==="In-Progress"||t.companyViewState.zeniUsers.hasValidState()||e.push(je()),_(e)}))),(s,i,r)=>s.pipe(S(KI.match),y((t=>{const{paymentAccountId:e}=t.payload,a=i.value.paymentAccountState,n=qi(a,e);return n?.providerVerificationStatus?.code==="verified"||n?.providerVerificationStatus?.code==="automatically_verified"?r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts/${e}?query=${encodeURIComponent('{"is_include_realtime_balance":true}')}`).pipe(y((o=>T(o)?p(W(o.data?.accounts??[],"zeni_accounts"),Se(o.data?.payment_accounts??[]),Un({paymentAccountId:e,fetchState:"Completed",error:void 0})):p(Un({paymentAccountId:e,fetchState:"Error",error:o.status})))),v((o=>p(Un({paymentAccountId:e,fetchState:"Error",error:f("Unexpected Error","Fetch payment Accounts Balance REST API call errored out"+JSON.stringify(o))}))))):p(Un({paymentAccountId:e,fetchState:"Completed",error:void 0}))}))),(s,i,r)=>s.pipe(S(Ge.match),A((()=>r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts`).pipe(y((t=>{if(T(t)&&t.data!=null){const{payment_accounts:e,accounts:a}=t.data;let n=[W(a,"zeni_accounts"),Se(e),Ht({data:e,updateType:"replace"})];return n=n.concat(e.map((o=>KI(o.payment_account_id)))),j(_(n))}return p(YI({fetchState:"Error",error:t.status}))})),v((t=>p(YI({fetchState:"Error",error:f("Unexpected Error","Fetch payment Accounts REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(Io.match),y((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/payment-sources?query=${encodeURIComponent(JSON.stringify({is_return_only_valid:!0}))}`).pipe(y((t=>{if(T(t)&&t.data){const e=[];return e.push(UA(t.data.payment_sources.cards),hp(t.data.payment_sources.bank_accounts),Eo({fetchState:"Completed",response:t.data})),_(e)}return _([Eo({fetchState:"Error",error:t.status}),N({messageSection:"fetch_payment_sources",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:t.status.message}]})])})),v((t=>p(Eo({fetchState:"Error",error:f("Unexpected Error","Fetch Payment Sources API call errored out "+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(Gi.match),A((()=>{const t=i.value.peopleState.uiState.mode;let e="";return e=t==="zeni_only"?`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles?query=${encodeURIComponent(JSON.stringify({include:t}))}`:`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles`,r.getJSON(e).pipe(y((a=>T(a)?p(Y(a.data?.user_roles??[]),V({users:a.data?.users??[]}),ZJ(a.data)):p(lg(a.status)))),v((a=>p(lg(f("Unexpected error","User Roles REST API call errored out"+JSON.stringify(a)))))))}))),(s,i)=>s.pipe(S(sw.match),A((r=>{const{userId:t,cacheOverride:e}=r.payload;if(e===!0)return _([Ia(t),Gi()]);{const a=i.value,n=[];return a.tenantState.fetchState==="In-Progress"||a.tenantState.hasValidState()||n.push(Ia(t)),a.peopleState.fetchState=="In-Progress"||a.peopleState.hasValidState()||n.push(Gi()),_(n)}}))),(s,i,r)=>s.pipe(S(Bd.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account`).pipe(y((t=>T(t)&&t.data!=null?p(gF(t.data)):p($I(t.status)))),v((t=>p($I(f("Unexpected Error","Fetch portfolio allocation REST API call errored out: "+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(rO.match),A((r=>{const{cacheOverride:t,fetchFullResponse:e}=r.payload;if(t===!0)return _([mr(e),je()]);const a=i.value,n=[];return a.companyViewState.zeniUsers.fetchState==="In-Progress"||a.companyViewState.zeniUsers.hasValidState()||n.push(je()),a.companyViewState.portfolioView.fetchState==="In-Progress"||a.companyViewState.portfolioView.hasValidState()||n.push(mr(e)),_(n)}))),(s,i,r)=>s.pipe(S(aa.match),y((t=>{const e=i.value,{entityId:a}=t.payload,n=tM(t.payload.entityId),o=X(e.previousBillsState.byEntityKey,n,void 0);if(t.payload.cacheOverride===!0||o==null||o.hasValidState()===!1){const c=Oe(e.vendorState,a)?.name??"",d={transaction_type:"bill",bill_pay_provider:"zeni",sort_by:"transaction_date",sort_order:"desc",entity_type:"vendor",entity_id:a,entity_name:c,is_include_attachment:!0,limit:3};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=[];return u.push(gc(l.data.transactions)),u.push(aM({entityId:a,billTransactions:l.data.transactions})),_(u)}return p(bv({entityId:a,fetchState:"Error",error:l.status}))})),v((l=>p(bv({entityId:a,fetchState:"Error",error:f("Unexpected Error","fetch previous bills REST API call errored out"+JSON.stringify(l))})))))}return _([])}))),(s,i)=>s.pipe(S(yg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Gt("month"),Gt("quarter"),Gt("year")]);{const e=[],a=i.value.profitAndLossClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Gt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Gt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Gt("year")),_(e)}}))),(s,i)=>s.pipe(S(Si.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;if(t===!0)return _([Mt("month",e),Mt("quarter",e),Mt("year",e)]);{const a=[],n=lw(i.value.profitAndLossState,e).fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(Mt("month",e)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(Mt("quarter",e)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(Mt("year",e)),_(a)}}))),(s,i,r)=>s.pipe(S(Gt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_class:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/profit_and_loss?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(oe(t.payload.timeframe,"cogs","profit_and_loss_by_classes",o.cogs,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,"expenses","profit_and_loss_by_classes",o.expenses,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,"income","profit_and_loss_by_classes",o.income,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,"otherExpenses","profit_and_loss_by_classes",o.other_expenses,o.classes,o.accounts,c)),n.push(oe(t.payload.timeframe,"otherIncome","profit_and_loss_by_classes",o.other_income,o.classes,o.accounts,c)),n.push(uw({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(_g(a.status,t.payload.timeframe))})),v((a=>p(_g(f("Unexpected Error","P&L REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),GG,(s,i,r)=>s.pipe(S(zt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[(a=>{switch(a){case"month":return"months";case"quarter":return"quarters";case"year":return"years"}})(t.payload.timeframe)],is_group_by_project:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/profit_and_loss?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,"cogs","profit_and_loss_by_projects",o.cogs,o.accounts,c)),n.push(ie(t.payload.timeframe,"expenses","profit_and_loss_by_projects",o.expenses,o.accounts,c)),n.push(ie(t.payload.timeframe,"income","profit_and_loss_by_projects",o.income,o.accounts,c)),n.push(ie(t.payload.timeframe,"otherExpenses","profit_and_loss_by_projects",o.other_expenses,o.accounts,c)),n.push(ie(t.payload.timeframe,"otherIncome","profit_and_loss_by_projects",o.other_income,o.accounts,c)),n.push(pw({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(hg(a.status,t.payload.timeframe))})),v((a=>p(hg(f("Unexpected Error","P&L by Projects REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(Sg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([zt("month"),zt("quarter"),zt("year")]);{const e=[],a=i.value.profitAndLossProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(zt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(zt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(zt("year")),_(e)}}))),(s,i,r)=>s.pipe(S(_i.match),Le(i),A((([t,e])=>{if(!Ms(e))return p(gg({status:f("Success",""),data:{projects:[]}}));const{isIncludeDeleted:a}=t.payload,n=(o=>`?query=${encodeURIComponent(JSON.stringify({is_deleted:o,sort_by:"accounting_project_name",sort_order:"asc",is_full:!0}))}`)(a);return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/projects${n}`).pipe(y((o=>T(o)?p(Ut(o.data?.projects??[]),gg(o)):p(fg(o.status)))),v((o=>p(fg(f("Unexpected Error","Fetch Projects REST API call errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(_r.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections-pool`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=t.data;return p(OD(e))}return p(vS(t.status))})),v((t=>p(vS(f("Unexpected error","QBO Connection Pool errored Out: "+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Ki.match),y((t=>{const{entityId:e,entityType:a}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/${e0(a)}/${e}/recommendations`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[],c=Hr(n.data.recommendations);return o.push(wr({entityId:e,entityType:a,recommendations:c}),ms(e,a)),_(o)}return p($a({entityId:e,entityType:a,status:n.status}))})),v((n=>p($a({entityId:e,entityType:a,status:f("Unexpected Error","Fetch recommendation by Entity Id REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(sr.match),y((t=>{const{entityName:e,entityType:a}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/recommendations?query=${encodeURIComponent(`{"entity_type":"${a}", "entity_name": "${e}"}`)}`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[],c=Hr(n.data.recommendations);return o.push(wr({entityId:e,entityType:a,recommendations:c}),ms(e,a)),_(o)}return p($a({entityId:e,entityType:a,status:n.status}))})),v((n=>p($a({entityId:e,entityType:a,status:f("Unexpected Error","Fetch recommendation by Entity Name REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(my.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/account-recommendations`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[];return e.push(UC(t.data)),_(e)}return p(yy({status:t.status}))})),v((t=>p(yy({status:f("Unexpected Error","Fetch account recommendations REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(du.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/account-recommendations`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[];return e.push(DP(t.data)),_(e)}return p(lu({status:t.status}))})),v((t=>p(lu({status:f("Unexpected Error","Fetch account recommendations REST API call errored out"+JSON.stringify(t))})))))))),(s,i)=>s.pipe(S(hd.match),y((r=>{const{cacheOverride:t,lineId:e,reimbursementId:a,merchantId:n,merchantName:o}=r.payload,c=i.value,d=a!=null?c.reimbursementState.reimbursementById[a]:void 0,l=[];if(t)n?l.push(Ki(n,"merchant")):o&&l.push(sr(o,"merchant")),l.push(Tn(e,a,n,o));else if(n||o){const{fetchState:u,recommendations:m=[]}=ps(c,n||o,"merchant");u==="In-Progress"?l.push(Tn(e,a,n,o)):u!="Completed"?(l.push(Sd({reimbursementId:a,lineId:e,recommendations:m,reimbursementStageCode:d?.reimbursementInfo.stage.code,shouldAutofill:!0})),n?l.push(Ki(n,"merchant")):o&&l.push(sr(o,"merchant")),l.push(Tn(e,a,n,o))):l.push(Sd({reimbursementId:a,lineId:e,recommendations:m,reimbursementStageCode:d?.reimbursementInfo.stage.code,shouldAutofill:!0}))}return _(l)}))),(s,i,r)=>s.pipe(S(b$.match),y((t=>{const e=i.value,{selectedJELinkRowIndex:a}=t.payload,{scheduleAccruedDetailState:n,vendorState:o}=e,c=[],{selectedJEAccruedScheduleKey:d}=n;if(d==null||a==null)return _(c);const l=sa(d,e);if(l==null)return _(c);const u=l.scheduledJournalEntry[a],{jeDebit:m}=l,{account:h,accountingClass:g}=m,{amount:I,runningBalance:b,expectedPostDate:E}=u,P=me().endOf("month").format(re),{vendor:O}=l,C=O.id,U=Oe(o,C),B={start_date:E.format(re),end_date:P,amount:I?.amount??0,accrued_balance:b?.amount??0,vendor_id:U?.id??"",account_name:h?.accountName??"",class_name:g?.className??""};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accrued-expenses/transactions/recommendations?query=${encodeURIComponent(JSON.stringify(B))}`).pipe(y((x=>T(x)&&x.data!=null?(c.push(Ce(x.data.transactions,(k=>k.transaction_id)),Zg(x.data.transactions,(k=>k.transaction_id)),Wi({fetchState:"Completed",error:void 0})),_(c)):_([Zg([],(k=>k.transaction_id)),Wi({fetchState:"Error",error:x.status})]))),v((x=>_([Wi({fetchState:"Error",error:f("Unexpected Error",`Fetch Bill Expense Recommendation REST API call errored out ${JSON.stringify(x)}`)})]))))}))),(s,i,r)=>s.pipe(S(bw.match),y((t=>{const{cacheOverride:e}=t.payload,a=i.value.referralViewState.fetchState;return e===!0||a==="Not-Started"?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referrals`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[Ew(n.data)];return _(o)}return p(Ng(n.status))})),v((n=>p(Ng(f("Unexpected Error","Fetch referrals REST API call errored out"+JSON.stringify(n))))))):[]}))),(s,i,r)=>s.pipe(S(zx.match),A((t=>r.getJSON(`${r.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/feature-interests?feature=${encodeURIComponent(t.payload.feature)}`).pipe(y((e=>{if(T(e)&&e.data!=null){const n=e.data.feature_interests.map(Kx);return _([Yx(n)])}const a=e.status??f("Failed to fetch registered interests. Please try again.");return _([Hy(a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error fetching registered interests.";return _([Hy(f(a))])})))))),(s,i,r)=>s.pipe(S(Qo.match),y((()=>{const t=ua({startDate:ee(up,"YYYY-MM-DD"),endDate:ee(lp,"YYYY-MM-DD")}),e={start_date:ae(t.start),end_date:ae(t.end),reimbursement_provider:"zeni",transaction_type:"reimbursement",reimbursement_stages:{pending_approval:["awaiting_approval","awaiting_my_approval"],paid:["all"],scheduled:["all"],draft:["all"]},get_count_only:!0};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursement-card?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>T(a)&&a.data!=null?p(kw({transactionTotals:a.data.transaction_totals,transactionCount:a.data.transaction_count})):p(xg(a.status)))),v((a=>p(xg(f("Unexpected Error","fetch Reimbursement Dashboard Card REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(ja.match),y((()=>r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/config`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[];return e.push(BL(t.data)),e.push(DL(t.data.currency_country_map)),_(e)}return p(mI(t.status))})),v((t=>p(mI(f("Unexpected Error","fetch reimbursement config REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(_d.match),y((r=>{const{reimbursementId:t,cacheOverride:e,isShowDeletedReimbursementEnabled:a}=r.payload,n=i.value,o=[];if(e)o.push(gd(t,!0,a)),o.push(fd(t));else{const c=X(n.remiDetailViewState.remiDetailById,t,void 0);c!=null&&c.fetchState==="In-Progress"?o.push(fd(t)):c==null||c?.fetchState!="In-Progress"&&c?.fetchState!="Completed"?(o.push(gd(t,!1,a)),o.push(fd(t))):o.push(dI(t))}return _(o)}))),(s,i)=>s.pipe(S(HL.match),y((r=>{const{cacheOverride:t,includeUserRoles:e,includeAttributesUserIds:a,lastUpdatedByUserId:n}=r.payload,{remiSetupApproverViewState:o,classListState:c}=i.value,{approverListState:d}=o,l=[];return t===!0?(l.push(Nd(t,e,a,n)),l.push(se())):(o.hasValidState()===!1&&d.fetchStatus.fetchState!=="In-Progress"&&l.push(Nd(!0,e,a,n)),c.hasValidState()===!1&&c.fetchState!=="In-Progress"&&l.push(se())),j(_(l))}))),(s,i,r)=>s.pipe(S(Nd.match),A((t=>{const{cacheOverride:e,includeUserRoles:a,includeAttributesUserIds:n,lastUpdatedByUserId:o}=t.payload,{remiSetupApproverViewState:c}=i.value,d=c.approverListState.approverIds;if(e===!0||d.length===0)return r.getJSON(`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approvers?query={"is_include_user_roles_info":${a},"is_include_attribute_user_ids":${n},"last_updated_by_user_id":"${o}"}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=l.data.users.map((h=>h.user_id)),m=[V({users:l.data.users})];return a===!0&&m.push(Y(l.data.user_roles)),m.push(fI(u,l.data.attributes,l.data.attribute_sub_type_to_user_id_mapping)),_(m)}return p(vI(l.status))})),v((l=>p(vI(f("Unexpected Error","Fetch Approvers List errored out"+JSON.stringify(l)))))));{const{approverListState:l}=c,{approverIds:u,attributes:m}=l;return p(fI(u,m))}}))),(s,i,r)=>s.pipe(S(gd.match),y((t=>{const{reimbursementId:e,cacheOverride:a,isShowDeletedReimbursementEnabled:n}=t.payload,o=[],c=i.value,{remiDetailViewState:d,reimbursementConfigState:l}=c;if(a===!0){const m=X(d.remiDetailById,e,void 0);o.push(...(function(h,g){const I=[];return I.push(FL(h)),g!=null&&I.push(Pd(h)),I})(e,m))}const u=X(d.remiDetailById,e,void 0);if(a==1||u==null||u.fetchState!=="In-Progress"){o.push(Nn(e,"In-Progress")),o.push(yn(e,"reimbursement",a)),l.fetchState!=="In-Progress"&&l.fetchState!=="Completed"&&o.push(ja());const m={transaction_type:"reimbursement",reimbursement_provider:"zeni",is_include_approval_info:!0,is_include_deleted:n},h=r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${e}?query=${encodeURIComponent(JSON.stringify(m))}`).pipe(y((g=>{if(T(g)&&g.data?.transaction?.transaction_id!=null){const I=g.data.transaction.transaction_id,b=g.data.reimbursee_bank_account,E=[bd(g.data.transaction),V({users:g.data.users??[]}),We(g.data.approval_rules),Et(g.data.entity_approvals),VL({reimbursementId:e,remiDetail:g.data}),ud(g.data.merchants),uI(g.data.merchants),Je(b!=null?[b]:[]),Nn(I,"Completed")];return g.data.merchants.forEach((P=>{const O=Hr(P.recommendations??[]);O!=null&&P.merchant_id&&E.push(wr({entityId:P.merchant_id,entityType:"merchant",recommendations:O}))})),E.push(LL()),g.data.transaction?.lines!=null&&g.data.transaction.lines.length>0&&E.push(Id(g.data.transaction.created_by_user_id,!1,g.data.transaction.transaction_id)),_(E)}return p(Nn(t.payload.reimbursementId,"Error",g.status))})),v((g=>(console.error(`REST API call errored out ${g}`),p(Nn(t.payload.reimbursementId,"Error",f("Unexpected Error",`REST API call errored out ${g}`)))))));return j(_(o),h)}return _(o)}))),(s,i)=>s.pipe(S(qL.match),y((r=>{const t=[],e=i.value,{period:a,cacheOverride:n,isShowDeletedReimbursementEnabled:o,isIncludeLineItems:c,isRefreshAccountAndAccountingClass:d}=r.payload,l=["draft","pending_approval","scheduled","paid"];return n===!0?(t.push(ja()),l.forEach((u=>t.push(Ad(a,u,o,c,d))))):(e.reimbursementConfigState.fetchState!=="Completed"&&e.reimbursementConfigState.fetchState!=="In-Progress"&&t.push(ja()),l.forEach((u=>{const m=jL(a,u),h=X(e.remiListState.byRemiListKey,m,void 0);h!=null&&h.hasValidState()!==!1||t.push(Ad(a,u,o,c,d))}))),_(t)}))),(s,i,r)=>s.pipe(S(Ad.match),y((t=>{const{period:e,tab:a,isShowDeletedReimbursementEnabled:n,isIncludeLineItems:o,isRefreshAccountAndAccountingClass:c}=t.payload,d={start_date:ae(e.start),end_date:ae(e.end),sort_by:"reimbursement_date",sort_order:"desc",reimbursement_provider:"zeni",reimbursement_stage_code:a,is_include_reimbursee_users_info:!0,is_include_approval_info:a==="pending_approval",is_include_pending_approval_transaction_ids_for_user:a==="pending_approval",transaction_type:"reimbursement",is_include_deleted:!!n&&a!=="draft",is_include_line_items:!!o&&a!=="draft",is_refresh_account_and_accounting_class:c};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=[V({users:l.data.users}),GL(l.data.transactions),zL({remiList:l.data,tab:a}),Et(l.data.entity_approvals??[])];return _(u)}return p(SI(e,a,l.status))})),v((l=>p(SI(t.payload.period,t.payload.tab,f("Unexpected Error","fetch remi list REST API call errored out"+JSON.stringify(l)))))))}))),(s,i,r)=>s.pipe(S(Od.match),A((t=>{const{cacheOverride:e,resolveAttributeToUser:a,includeImplicitActors:n,useV3:o}=t.payload,{remiSetupApproverViewState:c,approvalRuleState:d,classListState:l}=i.value,u=pt(i.value),m=qf(d,c.approvalRuleIds),h=u&&(e===!0||l.hasValidState()===!1&&l.fetchState!=="In-Progress");if(e===!0||m.length!==c.approvalRuleIds.length||c.hasValidState()===!1&&c.fetchState!=="In-Progress"){const g=o===!0?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;return r.getJSON(`${g}?query={"is_include_implicit_actors": ${n}, "is_resolve_attribute_to_user":${a}}`).pipe(y((I=>{if(T(I)&&I.data!=null){const b=I.data.approval_rules.map((P=>P.approval_rule_id)),E=[V({users:I.data.users}),We(I.data.approval_rules),II(b)];return h&&E.push(se()),_(E)}return p(bI(I.status))})),v((I=>p(bI(f("Unexpected Error","Fetch Approval view errored out"+JSON.stringify(I)))))))}{const{approvalRuleIds:g}=c,I=[II(g)];return h&&I.push(se()),_(I)}}))),(s,i,r)=>s.pipe(S(tF.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{remiSetupViewState:o,plaidAccountViewState:c,companyState:d}=i.value,l=Te(d,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"reimbursement_setup"}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=u.data.accounts.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses),ve({files:u.data.files}),W(u.data.accounts,"reimbursement"),Se(u.data.payment_accounts),Ht({data:u.data.payment_accounts,updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"replace"}),we({companyId:u.data.companies[0].company_id}),Cd({companyId:u.data.companies[0].company_id}),rt(m,"reimbursement_setup"),NI()];return _(h)}return p(N({messageSection:"reimbursement_setup",messageText:"failed",type:"error"}),OI(u.status))})),v((u=>p(OI(f("Unexpected Error","Fetch Remi Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=c.reimbursement_setup.accountDetails;return p(we({companyId:e}),rt(u,"reimbursement_setup"),NI())}}))),(s,i)=>s.pipe(S(Vg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Kt("month"),Kt("quarter"),Kt("year")]);{const e=[],a=i.value.revenueClassesViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Kt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Kt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Kt("year")),_(e)}}))),(s,i)=>s.pipe(S(Ps.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;if(t===!0)return _([Ma("month",e),Ma("quarter",e),Ma("year",e)]);{const a=[],n=d$(i.value.revenueState,i.value.revenueState.uiState.isForecastModeOn,e).fetchState;return n.month.fetchState!=="In-Progress"&&n.month.fetchState!=="Completed"&&a.push(Ma("month",e)),n.quarter.fetchState!=="In-Progress"&&n.quarter.fetchState!=="Completed"&&a.push(Ma("quarter",e)),n.year.fetchState!=="In-Progress"&&n.year.fetchState!=="Completed"&&a.push(Ma("year",e)),_(a)}}))),(s,i,r)=>s.pipe(S(Kt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[zg(t.payload.timeframe)],is_group_by_class:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/revenue?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[];return n.push(oe(t.payload.timeframe,"cogs","revenue_by_classes",a.data.report.cogs,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(oe(t.payload.timeframe,"income","revenue_by_classes",a.data.report.income,a.data.report.classes,a.data.report.accounts,a.data.report.currency)),n.push(l$({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(Kg(a.status,t.payload.timeframe))})),v((a=>p(Kg(f("Unexpected Error","Revenue REST API call errored out"+JSON.stringify(a)),t.payload.timeframe)))))}))),zG,(s,i,r)=>s.pipe(S(Yt.match),y((t=>{const e={is_full_response:t.payload.fetchFullReport,time_series_groups:[zg(t.payload.timeframe)],is_group_by_project:!0};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/revenue?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(a.data!=null&&T(a)){const n=[],o=a.data.report,c=o.currency;return n.push(Ut(o.projects)),n.push(ie(t.payload.timeframe,"cogs","revenue_by_projects",o.cogs,o.accounts,c)),n.push(ie(t.payload.timeframe,"income","revenue_by_projects",o.income,o.accounts,c)),n.push(u$({timeframe:t.payload.timeframe,report:a.data})),_(n)}return p(Yg(a.status,t.payload.timeframe))})),v((a=>p(Yg(f("Unexpected Error","Revenue by Projects REST API call errored out"+(a instanceof Error?a.message:String(a))),t.payload.timeframe)))))}))),(s,i)=>s.pipe(S(Fg.match),A((r=>{const{cacheOverride:t}=r.payload;if(t===!0)return _([Yt("month"),Yt("quarter"),Yt("year")]);{const e=[],a=i.value.revenueProjectViewState.fetchState;return a.month.fetchState!=="In-Progress"&&a.month.fetchState!=="Completed"&&e.push(Yt("month")),a.quarter.fetchState!=="In-Progress"&&a.quarter.fetchState!=="Completed"&&e.push(Yt("quarter")),a.year.fetchState!=="In-Progress"&&a.year.fetchState!=="Completed"&&e.push(Yt("year")),_(e)}}))),(s,i)=>s.pipe(S(jg.match),y((r=>{const{cacheOverride:t,forecastId:e}=r.payload,a=c$(i.value),n=ki(i.value.forecastState,i.value.forecastListState,a.dataAvailable),o=Bi(i.value.forecastState,i.value.forecastListState),c=((d,l)=>d!=null&&((u,m)=>{let h=!1;for(const g of m)if(g.id===u){h=!0;break}return h})(d,l)?d:l.length>0?l[0].id:void 0)(e,n.forecasts);if(c!=null){const d=[],l=o.forecasts.map((u=>u.id));return d.push(Dr(a.firstMonthOfFY,!0,void 0,{id:c,index:l.indexOf(c)})),t===!0||((u,m)=>{const h=$m(u,m);return h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"})(c,i.value.revenueState)?d.push(Ps(!1,c)):console.log("Required data is already there!! No need to fire any fetch!"),_(d)}if(c==null&&o.fetchState==="Completed"&&o.forecasts.length===0)return _([]);if(c==null&&(o.fetchState==="Completed"||o.fetchState==="Error"||o.forecasts.length>0)){console.warn("Atleast one of the forecast in the list should be valid!");const d=[Ra(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"month"),Ra(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"year"),Ra(f("Invalid forecastId given or Forecast is deleted","Invalid forecastId given or Forecast is deleted"),r.payload.forecastId,"quarter")];return _([d])}if(c==null&&o.forecasts.length===0)return _([Fs(),Gg(t,e)]);{console.warn("Invlid state!!");const d=[Ra(f("Unexpected error","Unexpected error"),r.payload.forecastId,"month"),Ra(f("Unexpected error","Unexpected error"),r.payload.forecastId,"year"),Ra(f("Unexpected error","Unexpected error"),r.payload.forecastId,"quarter")];return _([d])}}))),(s,i,r)=>s.pipe(S(is.match),A((t=>{const{cacheOverride:e,isFromMonthEnd:a}=t.payload,n=i.value,{fetchState:o}=n.reviewCompanyViewState;return e===!0||o!=="In-Progress"?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/audit`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[p$(c.data.companies)];return a===!0&&d.push(N({messageSection:"audit_score_updated",messageText:"success",type:"success"})),_(d)}{const d=[Hg(c.status)];return _(d)}})),v((c=>{const d=[Hg(f("Unexpected error","Cockpit Review errored out"+JSON.stringify(c)))];return _(d)}))):_([])}))),(s,i,r)=>s.pipe(S(MF.match),A((()=>{const t=i.value.transferDetailState.localData,e={from_account:{account_id:t.transferFrom?.id,account_type:Me(t.transferFrom?.accType)??""},to_account:{account_id:t.transferTo?.id,account_type:Me(t.transferTo?.accType)??""},amount:t.amount.amount,currency_code:t.amount.currencyCode,currency_symbol:t.amount.currencySymbol};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/transfers/review`,e).pipe(y((a=>T(a)&&a.data!=null?p(VF(a.data)):p(QI(a.status)))),v((a=>p(QI(f("Unexpected Error","Review Transfer Detail REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(Wo.match),y((t=>{const{cacheOverride:e}=t.payload,a=i.value.referralViewState.rewardsPlanFetchState.fetchState;if(e===!0||a==="Not-Started"){const n={is_primary_refer_reward_plan:!0};return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-refer-reward-plan?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[Pw(o.data)];return _(c)}return p(Og(o.status))})),v((o=>p(Og(f("Unexpected Error","Fetch rewards plan REST API call errored out"+JSON.stringify(o)))))))}return[]}))),(s,i,r)=>s.pipe(S(Xg.match),y((t=>{const e=[],{scheduleType:a,selectedJeScheduleDetailId:n}=t.payload,{scheduleAccruedDetailState:o}=i.value;if(n!=null){if(o.editScheduleStateByDetailId[n]?.jeScheduleDetails.length>0&&o.selectedJEAccruedScheduleKey!=null)return e.push(Va(a,o.selectedJEAccruedScheduleKey,n)),e.push(Zi()),_(e);const c={je_schedule_type:a};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${n}?query=${encodeURIComponent(JSON.stringify(c))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=ef(d.data.je_schedules[0]);return e.push(ca(d.data.je_schedules),E$({selectedJEScheduleKey:l}),br(d.data.je_schedules,d.data.scheduled_journal_entries),Rr("Not-Started"),Va(a,l,n),Zi()),_(e)}return p(Xi({error:d.status}))})),v((d=>p(Xi({error:f("Unexpected Error","Accrued Schedule Detail REST API call errored out"+JSON.stringify(d))})))))}return o.selectedJEAccruedScheduleKey!=null?(e.push(Va(a,o.selectedJEAccruedScheduleKey)),e.push(Zi())):e.push(Xi({error:f("Unexpected Error","Accrued Schedule Detail key is not defined")})),_(e)}))),(s,i)=>s.pipe(S(P$.match),y((r=>{const t=[],e=Ir(),a=i.value.accountListState,n=i.value.classListState;return a.byReportId[e.accountListKey].fetchState==="Not-Started"&&t.push(be(e.accountListKey,!0,!1,!1,!1,e.allowedAccountList)),n.fetchState==="Not-Started"&&t.push(se()),r.payload.selectedJeScheduleDetailId!=null&&t.push(Xg(r.payload.scheduleType,r.payload.selectedJeScheduleDetailId)),j(_(t))}))),(s,i,r)=>s.pipe(S(af.match),y((t=>{const e=[],{scheduleType:a,selectedJeScheduleDetailId:n,cacheOverride:o}=t.payload,{scheduleDetailState:c}=i.value;if(n!=null){if(c.editScheduleStateByDetailId[a][n]?.jeScheduleDetails.length>0&&c.selectedJEScheduleKey!=null&&o!==!0)return e.push(Mr(a,c.selectedJEScheduleKey,n)),e.push(ac()),_(e);const d={je_schedule_type:a};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${n}?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=D$(l.data.je_schedules[0].base_transaction);return e.push(ut(l.data.je_schedules),J$({selectedJEScheduleKey:u}),St(l.data.je_schedules,l.data.scheduled_journal_entries),Vr("Not-Started"),Mr(a,u,n),ac()),l.data.je_schedules[0].status.code==="draft"&&kK(l.data.je_schedules[0])&&e.push(tf({scheduleType:a})),_(e)}return p(rc({error:l.status}))})),v((l=>p(rc({error:f("Unexpected Error","Schedule Detail REST API call errored out"+JSON.stringify(l))})))))}return c.selectedJEScheduleKey!=null?(e.push(Mr(a,c.selectedJEScheduleKey)),e.push(ac())):e.push(rc({error:f("Unexpected Error","Schedule Detail key is not defined")})),_(e)}))),(s,i)=>s.pipe(S(w$.match),y((r=>{const t=[],e=Ir(),a=i.value.accountListState,n=i.value.classListState;return a.byReportId[e.accountListKey].fetchState==="Not-Started"&&t.push(be(e.accountListKey,!0,!1,!1,!1,e.allowedAccountList)),n.fetchState==="Not-Started"&&t.push(se()),r.payload.selectedJeScheduleDetailId!=null&&t.push(af(r.payload.scheduleType,r.payload.selectedJeScheduleDetailId,r.payload.cacheOverride)),j(_(t))}))),(s,i,r)=>s.pipe(S(oc.match),y((t=>{const{scheduleType:e}=t.payload,{scheduleListState:a,accountListState:n}=i.value;let o;if(e!=="accrued_expenses"&&(o=nc(a,e)),o==null)return _([]);const c=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedTimeframe:o.selectedTimeframe,d=t.payload.timeframeAndCategory!=null?t.payload.timeframeAndCategory.selectedCategoryId:o.selectedCategoryId,l=ua(c),u=ln(d,c),m=o.jeScheduleKeysByListKey[u];if(m!=null&&m.fetchState==="Completed"&&t.payload.cacheOverride===!1)return _([]);const h=Y$(e),g=H$(e),I=g!=null?z$(n,h.accountListKey,g):[];let b=[d];d==="all"&&(b=I);const E={start_date:ae(l.start),end_date:ae(l.end),je_schedule_type:e,base_txn_account_ids:b,sort_by:"transaction_date",sort_order:"desc",filter:"all"};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(E))}`).pipe(y((P=>{if(T(P)&&P.data!=null){const O=[];return O.push(ut(P.data.je_schedules),St(P.data.je_schedules,P.data.scheduled_journal_entries),K$(e,c,d,P.data.je_schedules)),_(O)}return p(cf(e,c,d,P.status))})),v((P=>p(cf(e,c,d,f("Unexpected Error","Schedule List REST API call errored out"+JSON.stringify(P)))))))}))),s=>s.pipe(S(Q$.match),y((()=>{const i=[],r=Ir();return i.push(be(r.accountListKey,!1,!1,!1,!1,r.allowedAccountList)),_(i)}))),(s,i,r)=>s.pipe(S(TT.match),A((t=>{const{macroId:e}=t.payload,a=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}`;return r.getJSON(a).pipe(y((n=>T(n)&&gl(n.data)?p(AT({detail:fl(n.data),macroId:e})):p(Du({error:n.status,macroId:e})))),v((n=>p(Du({error:f("Unexpected Error","Fetch skill detail REST API call failed",n instanceof Error?{message:n.message}:void 0),macroId:e})))))}))),(s,i,r)=>s.pipe(S(po.match),A((()=>{const t=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills`;return r.getJSON(t).pipe(y((e=>T(e)&&e.data!=null?p(xT({skills:(e.data.skills??[]).map(_z),skillsEnabled:e.data.skills_enabled===!0,canPublish:e.data.can_publish===!0})):p(Ru(e.status)))),v((e=>p(Ru(f("Unexpected Error","Fetch skills REST API call failed",e instanceof Error?{message:e.message}:void 0))))))}))),(s,i,r)=>s.pipe(S(NT.match),A((t=>{const{macroId:e,version:a}=t.payload,n=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}?version=${encodeURIComponent(String(a))}`;return r.getJSON(n).pipe(y((o=>T(o)&&z0(o.data)?p(OT({macroId:e,version:a,instructions:o.data.instructions})):p(Ju({macroId:e,version:a,error:o.status})))),v((o=>p(Ju({macroId:e,version:a,error:f("Unexpected Error","Fetch skill version body REST API call failed",o instanceof Error?{message:o.message}:void 0)})))))}))),(s,i,r)=>s.pipe(S(wu.match),A((t=>{const{macroId:e}=t.payload,a=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}/versions`;return r.getJSON(a).pipe(y((n=>T(n)&&n.data!=null?p(CT({macroId:e,versions:(n.data.versions??[]).map(mz)})):p($u({macroId:e,error:n.status})))),v((n=>p($u({macroId:e,error:f("Unexpected Error","Fetch skill versions REST API call failed",n instanceof Error?{message:n.message}:void 0)})))))}))),(s,i,r)=>s.pipe(S(YF.match),A((t=>{const{cacheOverride:e}=t.payload,{subscriptionViewState:a}=i.value,n=a.addOnListState.addOnIds;return e===!0||n.length===0?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-addons`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.subscription_addons.map((l=>l.subscription_addon_id)),d=[ha({payload:o.data.subscription_addons}),tb({addOnIds:c})];return _(d)}return p(ab({status:o.status}))})),v((o=>p(ab({status:f("Unexpected error","Unable to fetch subscription addOns"+JSON.stringify(o))}))))):p(tb({addOnIds:n}))}))),(s,i,r)=>s.pipe(S(HF.match),A((t=>{const{cacheOverride:e}=t.payload,{subscriptionViewState:a}=i.value,n=a.couponListState.couponIds;return e===!0||n.length===0?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-coupons`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.subscription_coupons.map((l=>l.subscription_coupon_id)),d=[ur({payload:o.data.subscription_coupons}),rb({couponIds:c})];return _(d)}return p(sb({status:o.status}))})),v((o=>p(sb({status:f("Unexpected error","Unable to fetch subscription coupons"+JSON.stringify(o))}))))):p(rb({couponIds:n}))}))),(s,i,r)=>s.pipe(S(QF.match),A((t=>{const{tenantId:e}=t.payload,a=i.value.subscriptionViewState.subscriptionUpdateViewDataByTenantId[e].data;if(a!=null){const{subscriptionPlanId:n,subscriptionAddOnIds:o,subscriptionCouponIds:c,startDate:d,invoiceImmediately:l}=a,u={subscriptionPlanId:n,subscriptionAddOnIds:o,subscriptionCouponIds:c,startDate:d,invoiceImmediately:l};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-create-estimate?query=${encodeURIComponent(JSON.stringify(p0(u,e,!0)))}`).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[WF({tenantId:e,subscriptionEstmiateData:m.data})];return _(h)}return p(nb({tenantId:e,status:m.status}))})),v((m=>p(nb({tenantId:e,status:f("Unexpected error","Unable to fetch subscription create estimate"+JSON.stringify(m))})))))}return _([])}))),(s,i,r)=>s.pipe(S(ZF.match),A((t=>{const{companyId:e,cacheOverride:a}=t.payload,{subscriptionViewState:n}=i.value,o=n.subscriptionDetailsByCompanyId[e],c=o!=null?o.subscriptionIds:[];return a===!0||c.length===0?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions?query=${encodeURIComponent(JSON.stringify({company_id:e}))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.subscriptions.map((m=>m.subscription_id)),u=[lr({payload:d.data.subscriptions,schema:d.data.schema.subscription}),_a({payload:d.data.subscription_plans,schema:d.data.schema.subscription_plan}),ur({payload:d.data.subscription_coupons,schema:d.data.schema.subscription_coupon}),ha({payload:d.data.subscription_addons,schema:d.data.schema.subscription_addon}),Sa({payload:d.data.subscription_summaries,schema:d.data.schema.subscription_summary}),ob({companyId:e,subscriptionIds:l})];return _(u)}return p(ib({companyId:e,status:d.status}))})),v((d=>p(ib({companyId:e,status:f("Unexpected error","fetch Subscription Details errored out"+JSON.stringify(d))}))))):p(ob({companyId:e,subscriptionIds:c}))}))),(s,i,r)=>s.pipe(S(pr.match),A((t=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/subscriptions?query=${encodeURIComponent(`{"is_full_response":${t.payload.fetchFullResponse}}`)}`).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data.companies.map((d=>d.company_id)),n=(function(d,l){const u=bl(d),m={};return l.forEach((h=>{m[h]={subscriptionIds:u[h]??[],fetchStatus:{fetchState:"Completed",error:void 0}}})),m})(e.data.subscriptions,a),o=qo(e.data.user_roles,e.data.companies),c=[Y(e.data.user_roles),Q({payload:e.data.companies,schema:e.data.schema.company,subset:!1,companyIdTenantIdMapping:o}),lr({payload:e.data.subscriptions,schema:e.data.schema.subscription}),_a({payload:e.data.subscription_plans,schema:e.data.schema.subscription_plan}),ha({payload:e.data.subscription_addons,schema:e.data.schema.subscription_addon}),ur({payload:e.data.subscription_coupons,schema:e.data.schema.subscription_coupon}),Sa({payload:e.data.subscription_summaries,schema:e.data.schema.subscription_summary}),XF({companyIds:a,subscriptionDetailsByCompanyId:n})];return t.payload.fetchFullResponse===!0&&e.data.users!=null&&c.push(V({users:e.data.users})),_(c)}return p(cb(e.status))})),v((e=>p(cb(f("Unexpected error","fetch Subscription List errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(eq.match),A((t=>{const{cacheOverride:e}=t.payload,{subscriptionViewState:a}=i.value,n=a.planListState.planIds;return e===!0||n.length===0?r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-plans`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.subscription_plans.map((l=>l.subscription_plan_id)),d=[_a({payload:o.data.subscription_plans}),db({planIds:c})];return _(d)}return p(lb({status:o.status}))})),v((o=>p(lb({status:f("Unexpected error","Unable to fetch subscription plans"+JSON.stringify(o))}))))):p(db({planIds:n}))}))),KG,(s,i,r)=>s.pipe(S(tq.match),A((t=>{const{tenantId:e}=t.payload,a=i.value.subscriptionViewState.subscriptionUpdateViewDataByTenantId[e].data;if(a!=null){const{subscriptionId:n,subscriptionEstmiate:o,subscriptionPlanId:c,subscriptionAddOnIds:d,subscriptionCouponIds:l,invoiceImmediately:u,applyEndOfTerm:m,shouldProrate:h}=a,g={subscriptionId:n,subscriptionEstmiate:o,subscriptionPlanId:c,subscriptionAddOnIds:d,subscriptionCouponIds:l,invoiceImmediately:u,applyEndOfTerm:m,shouldProrate:h};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-update-estimate?query=${encodeURIComponent(JSON.stringify(u0(g,e,!0)))}`).pipe(y((I=>{if(T(I)&&I.data!=null){const b=[aq({tenantId:e,subscriptionEstmiateData:I.data})];return _(b)}return p(ub({tenantId:e,status:I.status}))})),v((I=>p(ub({tenantId:e,status:f("Unexpected error","Unable to fetch subscription update estimate"+JSON.stringify(I))})))))}return _([])}))),(s,i)=>s.pipe(S(sO.match),A((r=>{const{cacheOverride:t,fetchFullResponse:e}=r.payload;if(t===!0)return _([pr(e),je()]);const a=i.value,n=[];return a.companyViewState.zeniUsers.fetchState==="In-Progress"||a.companyViewState.zeniUsers.hasValidState()||n.push(je()),a.subscriptionViewState.subscriptionListView.fetchState==="In-Progress"||a.subscriptionViewState.subscriptionListView.hasValidState()||n.push(pr(e)),_(n)}))),(s,i,r)=>s.pipe(S(bq.match),y((t=>{const{parentTaskId:e}=t.payload,a=JSON.stringify({task_type:"subtasks",parent_task_id:e});return r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent(a)}`).pipe(y((n=>{if(T(n)&&n.data!=null){const{tasks:o}=n.data,c=o.filter((d=>d.parent_task_id===e)).map((d=>d.task_id));return p(ze(o),Pq({parentTaskId:e,subTaskIds:c}),Eq({parentTaskId:e}))}return p(vb({parentTaskId:e,fetchState:"Error",error:n.status}))})),v((n=>p(vb({parentTaskId:e,fetchState:"Error",error:f("Unexpected Error","Fetch Sub Tasks REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(UT.match),y((t=>{const{pageContext:e,noCardCreated:a}=t.payload,n=new URLSearchParams({page_context:e});a===!0&&n.set("no_card_created","true");const o=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/suggested-questions?${n.toString()}`;return r.getJSON(o).pipe(y((c=>T(c)&&c.data!=null?p(kT({pageContext:e,generatedAt:c.data.generated_at,suggestedQuestions:c.data.suggested_questions})):p(Mu({pageContext:e,error:c.status})))),v((c=>p(Mu({pageContext:e,error:f("Unexpected Error","Fetch suggested questions REST API call failed",c instanceof Error?{message:c.message}:void 0)})))))}))),(s,i,r)=>s.pipe(S(Zd.match),y((t=>{const{taskId:e,cacheOverride:a}=t.payload,n=[],o=i.value,c=X(o.taskDetailState.editTaskStateById,e,void 0);if(a===!0&&n.push(Tq(e)),a===!0||c==null||c.fetchTaskStatus.fetchState!=="In-Progress"){n.push(za({taskId:e,fetchState:"In-Progress"}));const d=r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${e}`).pipe(y((l=>{if(T(l)&&l.data!=null){const u=[ze(l.data.tasks),za({taskId:e,fetchState:"Completed"}),Zr(l.data.tasks.map((h=>h.tags)).flat()),Ib(e)],m=l.data.tasks[0].file_ids;return m.length>0&&u.push(e_(m)),_(u)}{const u=[za({taskId:e,fetchState:"Error",error:l.status})];return l.status.message.includes("delete")?u.push(N({messageSection:"fetch_task_detail",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:"Cannot retrieve deleted task."}]})):u.push(N({messageSection:"fetch_task_detail",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:l.status.message}]})),_(u)}})),v((l=>(console.error(`REST API call errored out ${l}`),p(za({taskId:e,fetchState:"Error",error:f("Unexpected Error","Fetch Task detail REST API call errored out"+JSON.stringify(l))}))))));return j(_(n),d)}return _(n)}))),(s,i)=>s.pipe(S(Aq.match),y((r=>{const{cacheOverride:t,taskId:e}=r.payload,a=[],n=i.value;if(t===!0)a.push($e("taskManagerCandidate",!0)),a.push(se()),e!=null&&(a.push(Zd(e,!0)),a.push(Xd(e,!0)));else{const o=n.userListViewState.userListByType.taskManagerCandidate;o.hasValidState()===!1&&o.fetchState!=="In-Progress"&&a.push($e("taskManagerCandidate",!1)),n.classListState.hasValidState()===!1&&n.classListState.fetchState!=="In-Progress"&&a.push(se()),e!=null&&(a.push(Zd(e,!1)),a.push(Xd(e,!1)))}return j(_(a))}))),(s,i,r)=>s.pipe(S(al.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/templates`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[$q(t.data),Rq(t.data.templates)];return _(e)}{const e=[Tb(t.status)];return _(e)}})),v((t=>{const e=[Tb(f("Unexpected error","fetch task group templates REST API call errored out"+JSON.stringify(t)))];return _(e)})))))),(s,i,r)=>s.pipe(S(Xd.match),y((t=>{const{taskId:e,cacheOverride:a}=t.payload,n=[],o=i.value,c=X(o.taskDetailState.taskHistoryById,e,void 0);if(a===!0||c==null||c.fetchState!=="In-Progress"){n.push(el({taskId:e,fetchState:"In-Progress"}));const d=r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${e}/history`).pipe(y((l=>T(l)&&l.data!=null?p(Nq({taskId:e,historicEventsPayload:l.data.activities})):p(el({taskId:e,fetchState:"Error",error:l.status})))),v((l=>p(el({taskId:e,fetchState:"Error",error:f("Unexpected Error","Fetch Task history REST API call errored out"+JSON.stringify(l))})))));return j(_(n),d)}return _(n)}))),(s,i,r)=>s.pipe(S(Nt.match),A((()=>r.getJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks?query=${encodeURIComponent('{"task_type": "all"}')}`).pipe(y((t=>{if(T(t)&&t.data!=null){const{tasks:e,deleted:a,archived:n,snoozed:o,completed:c}=t.data,d=[...e,...c??[],...a??[],...n??[],...o??[]];return p(ze(d),Qq({data:e,completed:c??[],deleted:a??[],archived:n??[],snoozed:o??[]}),Zr(d.map((l=>l.tags)).flat()))}return p(kb({fetchState:"Error",error:t.status}))})),v((t=>p(kb({fetchState:"Error",error:f("Unexpected Error","Fetch Task List REST API call errored out"+JSON.stringify(t))})))))))),(s,i)=>s.pipe(S(Wq.match),y((r=>{const{cacheOverride:t,isTaskTemplatesEnabled:e}=r.payload,a=[],n=i.value;if(t===!0)a.push(Nt(),se(),$e("taskManagerCandidate",!0),Hd(),sl()),e===!0&&a.push(al());else{n.taskListState.fetchState!=="In-Progress"&&n.taskListState.hasValidState()===!1&&a.push(Nt()),n.classListState.hasValidState()===!1&&n.classListState.fetchState!=="In-Progress"&&a.push(se());const o=n.userListViewState.userListByType.taskManagerCandidate;o.hasValidState()===!1&&o.fetchState!=="In-Progress"&&a.push($e("taskManagerCandidate",!1)),n.tagViewState.hasValidState()===!1&&n.tagViewState.fetchState!=="In-Progress"&&a.push(Hd()),n.taskGroupViewState.hasValidState()===!1&&n.taskGroupViewState.fetchState!=="In-Progress"&&a.push(sl()),e===!0&&n.taskGroupTemplateViewState.hasValidState()===!1&&n.taskGroupTemplateViewState.fetchState!=="In-Progress"&&a.push(al())}return j(_(a))}))),(s,i,r)=>s.pipe(S(ON.match),A((()=>{const t=JSON.stringify({is_filter_by_logged_in_user:!0,include_subtasks:!0});return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels/tasks-es-metrics?query=${encodeURIComponent(t)}`).pipe(y((e=>T(e)&&e.data!=null?p(CN(e.data.summary)):p(rm()))),v((()=>p(rm()))))}))),(s,i,r)=>s.pipe(S(ss.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/task_card`).pipe(y((t=>T(t)?p(ej(t.data)):p(Db(t.status)))),v((t=>p(Db(f("Unexpected Error","Tasks card REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(Ko.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/top_expenses`).pipe(y((t=>T(t)?p(W(t.data?.report.accounts??[],"top_expenses"),tj(t.data)):p(Jb(t.status)))),v((t=>p(Jb(f("Unexpected error","TopEx REST API call errored out"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(aj.match),A((t=>{const{qboId:e}=t.payload;return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${e}/activity`).pipe(y((a=>{if(T(a)&&a.data!=null&&a.data.activity!=null){const n=[];return a.data.users!=null&&a.data.users.length>0&&n.push(V({users:a.data.users,updateType:"merge"})),n.push(rj(a.data.activity)),n.push(sj({data:a.data.activity,qboId:e})),_(n)}return p(wb({fetchState:"Error",error:a.status,qboId:e}))})),v((a=>p(wb({qboId:e,fetchState:"Error",error:f("Unexpected Error","fetch transaction activity log REST API call errored out"+JSON.stringify(a))})))))}))),(s,i,r)=>s.pipe(S(Fb.match),y((t=>{const{transactionId:e,cacheOverride:a}=t.payload,n=Be(e),o=[];if(a===!0){const d=At(i.value.transactionState,n);o.push(...(function(l,u){const m=[];return m.push($l(l)),u!=null&&(m.push(wl(Be(l))),qb(u).forEach((h=>{m.push($l(h)),m.push(wl(Be(h)))}))),m})(e,d))}const c=X(i.value.transactionDetailState.transactionDetailById,n,void 0);if(a===!0||c==null||c.hasValidState()===!1&&c.fetchState!=="In-Progress"){const d=i.value.accountListState.byReportId.accountList;d.hasValidState()===!1&&d.fetchState!=="In-Progress"&&o.push(be("accountList"));const l=i.value.classListState;l.hasValidState()===!1&&l.fetchState!=="In-Progress"&&o.push(se());const u=i.value.projectListState;u.hasValidState()===!1&&u.fetchState!=="In-Progress"&&o.push(_i()),o.push(Bn(e,"In-Progress"));const m={transaction_type:e.type},h=r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${e.id}?query=${encodeURIComponent(JSON.stringify(m))}`).pipe(y((g=>{if(T(g)&&g.data?.transaction?.transaction_id!=null){const I=[],b=Is(g.data.transaction),E={...g.data,vendors:g.data.vendors?.map((O=>({...O,vendor_id:O.qbo_id??O.vendor_id})))??[]};E.vendors.length>0&&I.push(le(E.vendors,"merge"));const P=Be(b);return I.push(va(P,E.transaction)),I.push(bs({transactionId:b,vendorId:E.vendors[0]?.vendor_id})),I.push(Bn(b,"Completed")),I.push(...(function(O,C){const U=[],B=yj(O),x=qb(B).filter((k=>(function(J,L){const R=Be(J),q=L.transactionDetailState.transactionDetailById[R];return q!=null&&(q.hasValidState()===!0||q.fetchState==="In-Progress")})(k,C)===!1));return x.forEach((k=>U.push(Fb(k,!1)))),x.length===0&&console.log("Phew all linked transactions are fetched or there are no linked transactions.."),U})(E.transaction,i.value)),E.vendors.length>0&&I.push(ls({vendorId:E.vendors[0].vendor_id,localData:bE(or(E.vendors[0]))})),g0(E.transaction.transaction_type)!=null&&I.push(ct()),_(I)}return p(Bn(t.payload.transactionId,"Error",g.status))})),v((g=>(console.error(`REST API call errored out ${g}`),p(Bn(t.payload.transactionId,"Error",f("Unexpected Error",`REST API call errored out ${g}`)))))));return j(_(o),h)}return _(o)}))),(s,i,r)=>s.pipe(S(vj.match),y((t=>{const e=i.value,a=Ij(t.payload.accountId,t.payload.accountType,t.payload.period),n=X(e.transactionListState.byAccount.transactionListByAccountKey,a,void 0);if(t.payload.cacheOverride===!0||n==null||n.hasValidState()===!1){const o={start_date:ae(t.payload.period.start),end_date:ae(t.payload.period.end),sort_by:"transaction_date",sort_order:"desc",account_id:t.payload.accountId,account_type:t.payload.accountType,account_name:t.payload.accountName};t.payload.includeSubAccountTransactions===!1&&(o.include_sub_account_transactions=t.payload.includeSubAccountTransactions);const c=ds(t.payload.accountId);return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${c}/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(Ce(d.data.account.transactions,(u=>u.transaction_id))),l.push(bj(d.data)),_(l)}return p(jb(t.payload.accountId,t.payload.accountType,t.payload.period,d.status))})),v((d=>p(jb(t.payload.accountId,t.payload.accountType,t.payload.period,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(d)))))))}return _([])}))),(s,i,r)=>s.pipe(S(Gb.match),y((t=>{const e=i.value,a=zb(t.payload.accountId,t.payload.accountType,t.payload.classId,t.payload.period),n=X(e.transactionListState.byClass.transactionListByClassKey,a,void 0);if(t.payload.cacheOverride===!0||n==null||n.hasValidState()===!1){const o={start_date:ae(t.payload.period.start),end_date:ae(t.payload.period.end),sort_by:"create_time",sort_order:"desc",account_id:t.payload.accountId,account_type:t.payload.accountType,accounting_class_id:t.payload.classId,include_sub_class_transactions:!1},c=ds(t.payload.accountId);return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${c}/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(Ce(d.data.account.transactions,(u=>u.transaction_id))),l.push(Ej(d.data)),_(l)}return p(Kb(t.payload.accountId,t.payload.accountType,t.payload.classId,t.payload.period,d.status))})),v((d=>p(Kb(t.payload.accountId,t.payload.accountType,t.payload.classId,t.payload.period,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(d)))))))}return _([])}))),(s,i,r)=>s.pipe(S(Yb.match),y((t=>{const e=i.value,a=Hb(t.payload.entity,t.payload.period),n=X(e.transactionListState.byEntity.transactionListByEntityKey,a,void 0);if(t.payload.cacheOverride===!0||n==null||n.hasValidState()===!1){const o={start_date:ae(t.payload.period.start),end_date:ae(t.payload.period.end),sort_by:"create_time",sort_order:"desc",entity_id:t.payload.entity.id,entity_name:t.payload.entity.name,entity_type:t.payload.entity.type,is_fetch_all_transactions:t.payload.isFetchAllTransactions===!0?t.payload.isFetchAllTransactions:null};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[];return d.push(Ce(c.data.transactions,(l=>l.transaction_id))),d.push(Pj(c.data)),_(d)}return p(Qb(t.payload.entity,t.payload.period,c.status))})),v((c=>p(Qb(t.payload.entity,t.payload.period,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(c)))))))}return _([])}))),(s,i,r)=>s.pipe(S(Wb.match),y((t=>{const e=i.value,a=Zb(t.payload.accountId,t.payload.accountType,t.payload.projectId,t.payload.period),n=X(e.transactionListState.byProject.transactionListByProjectKey,a,void 0);if(t.payload.cacheOverride===!0||n==null||n.hasValidState()===!1){const o={start_date:ae(t.payload.period.start),end_date:ae(t.payload.period.end),sort_by:"create_time",sort_order:"desc",account_id:t.payload.accountId,account_type:t.payload.accountType,accounting_project_id:t.payload.projectId},c=ds(t.payload.accountId);return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${c}/transactions?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(Ce(d.data.account.transactions,(u=>u.transaction_id))),l.push(Tj(d.data)),_(l)}return p(Xb(t.payload.accountId,t.payload.accountType,t.payload.projectId,t.payload.period,d.status))})),v((d=>p(Xb(t.payload.accountId,t.payload.accountType,t.payload.projectId,t.payload.period,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(d)))))))}return _([])}))),(s,i)=>s.pipe(S(Jj.match),y((r=>{const{entity:t,screen:e,selectedPeriod:a,fiscalYearStartMonth:n}=r.payload,o=[];return o.push(rE(t,ua(a.timePeriod),!1,n)),o.push(wj(t,e,a)),_(o)}))),(s,i,r)=>s.pipe(S(eE.match),y((t=>{const e=i.value,{transactionCategoryType:a,period:n,cacheOverride:o,minimumTransactionAmount:c}=t.payload,d=tE(a,n),l=X(e.transactionListState.byType[a].transactionListByCategoryType,d,void 0);if(o===!0||l==null||l.hasValidState()===!1){const u={start_date:ae(n.start),end_date:ae(n.end),sort_by:"transaction_date",sort_order:"desc"};return a==="missingReceipts"&&(u.is_attachment_missing_only=!0),a!=="miscategorizedExpense"&&a!=="miscategorizedIncome"||(u.type="miscategorized",u.account_type=a==="miscategorizedExpense"?"expenses":"income"),a!=="uncategorizedIncome"&&a!=="uncategorizedExpense"||(u.type="uncategorized",u.account_type=a==="uncategorizedExpense"?"expenses":"income"),c!=null&&(u.total_amount_min=c.amount),r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions?query=${encodeURIComponent(JSON.stringify(u))}`).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[];return h.push(Ce(m.data.transactions,(g=>g.transaction_id))),h.push(Aj(a,n,m.data.transactions)),_(h)}return p(aE(a,n,m.status))})),v((m=>p(aE(a,n,f("Unexpected Error","fetch transaction list REST API call errored out"+JSON.stringify(m)))))))}return _([])}))),(s,i,r)=>s.pipe(S(gO.match),ar((t=>t.payload.kind)),y((t=>t.pipe(A((e=>{const{kind:a}=e.payload,n=kz[a],o=Uz[a],c=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts?query=${encodeURIComponent(JSON.stringify(n))}`;return r.getJSON(c).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.accounts.map((m=>m.account_id)),u=[W(d.data.accounts,o),fO({accountIds:l,kind:a})];return p(...u)}return p(Um({kind:a}))})),v((()=>p(Um({kind:a})))))})))))),(s,i,r)=>s.pipe(S(Af.match),A((t=>{const{cacheOverride:e,fetchOnlySummary:a}=t.payload,n=i.value,o=[];if(e===!0)o.push(kd()),o.push(Bd()),o.push(Dd(!0)),o.push(Jd(!0)),o.push(wd()),o.push($d(!0));else if(a!==!0){const c=n.treasuryStatementListState;c.hasValidState()===!1&&c.fetchState!=="In-Progress"&&o.push(Dd(!1));const d=n.treasuryTaxLetterListState;d.hasValidState()===!1&&d.fetchState!=="In-Progress"&&o.push(Jd(!1));const l=n.treasuryDetailState;l.hasValidState()===!1&&l.fetchState!=="In-Progress"&&o.push(wd());const u=l.transactionsState;u.fetchState!=="Completed"&&u.fetchState!=="In-Progress"&&o.push($d(!1,5));const m=n.treasurySetupViewState;m.treasuryFundsDetails.fetchStatus.fetchState!=="In-Progress"&&o.push(kd()),m.currentAllocation.fetchStatus.fetchState!=="In-Progress"&&o.push(Bd())}return r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account?query=${encodeURIComponent('{"is_summary":true}')}`).pipe(y((c=>T(c)?j(p(mF({data:c})),_(o)):j(p(BI({error:c.status})),_(o)))),v((c=>j(p(BI({error:f("Unexpected Error","Fetch treasury summary REST API call errored out "+JSON.stringify(c))})),_(o)))))}))),(s,i,r)=>s.pipe(S(kd.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury/funds`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[fF(t.data)];return _(e)}return p(RI({error:t.status}))})),v((t=>p(RI({error:f("Unexpected Error","Fetch treasury funds REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(wd.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/balance/time-series`).pipe(y((t=>T(t)?p(yF({data:t})):p(DI({fetchState:"Error",error:t.status})))),v((t=>p(DI({fetchState:"Error",error:f("Unexpected Error","Fetch treasury account history REST API call errored out "+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(vF.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{treasurySetupViewState:o,plaidAccountViewState:c,companyState:d}=i.value,l=Te(d,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"treasury_accounts_setup"}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=u.data.accounts?.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses??[]),ve({files:u.data.files??[]}),W(u.data.accounts??[],"zeni_treasury"),Se(u.data.payment_accounts??[]),Ht({data:u.data.payment_accounts??[],updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"replace"}),we({companyId:u.data.companies[0].company_id}),rt(m,"treasury_setup"),MI()];return _(h)}return p(N({messageSection:"treasury_setup",messageText:"failed",type:"error"}),VI(u.status))})),v((u=>p(VI(f("Unexpected Error","Fetch Treasury Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=c.spend_management_setup.accountDetails;return p(we({companyId:e}),rt(u,"treasury_setup"),MI())}}))),(s,i,r)=>s.pipe(S(Dd.match),y((t=>{const{cacheOverride:e}=t.payload,a=i.value.treasuryStatementListState.fetchState;if(e===!0||a!=="Completed"){const n={statement_type:"monthly_statement"},o=`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/statements?query=${encodeURIComponent(JSON.stringify(n))}`;return r.getJSON(o).pipe(y((c=>T(c)?p(EF({data:c.data?.statements??[]})):p(Rd({fetchState:"Error",error:c.status})))),v((c=>p(Rd({fetchState:"Error",error:f("Unexpected Error","Fetch treasury Account statement REST API call errored out "+JSON.stringify(c))})))))}return p(Rd({fetchState:"Completed",error:void 0}))}))),(s,i,r)=>s.pipe(S(Jd.match),y((t=>{const{cacheOverride:e}=t.payload,a=i.value.treasuryTaxLetterListState.fetchState;if(e===!0||a!=="Completed"){const n={statement_type:"tax_statement"},o=`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/statements?query=${encodeURIComponent(JSON.stringify(n))}`;return r.getJSON(o).pipe(y((c=>T(c)?p(PF({data:c.data?.statements??[]})):p(Md({fetchState:"Error",error:c.status})))),v((c=>p(Md({fetchState:"Error",error:f("Unexpected Error","Fetch treasury tax letter REST API call errored out "+JSON.stringify(c))})))))}return p(Md({fetchState:"Completed",error:void 0}))}))),(s,i,r)=>s.pipe(S($d.match),A((t=>{const{cacheOverride:e}=t.payload,a={start_date:"2022-01-01",end_date:"2030-12-31"};return e===!0?r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/transactions?query=${encodeURIComponent(JSON.stringify(a))}`).pipe(y((n=>T(n)?p(_F({transactionList:n.data?.transactions??[]})):p(JI({error:n.status})))),v((n=>p(JI({error:f("Unexpected Error","Fetch treasury transactions REST API call errored out"+JSON.stringify(n))}))))):_([])}))),(s,i)=>s.pipe(S(Bo.match),y((r=>{const{entity:t}=r.payload;return t.type==="customer"?p(nE(t.id,t.name)):t.type==="vendor"?p(sE(t.id,t.name,t.zeniId)):_([])}))),(s,i,r)=>s.pipe(S(kp.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user/self`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[XA()];return t.data.users.length>0&&e.push(V({users:t.data.users})),_(e)}return p(Bp(t.status))})),v((t=>p(Bp(f("Unexpected error","Unable to fetch user details"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(yd.match),A((t=>{const{userId:e,reimbursementId:a}=t.payload;return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/users/${e}/financial-accounts`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[],c=vY(n.data.bank_accounts)?.bank_account_id;return o.push(Je(n.data.bank_accounts),$j({userFinancialAccount:n.data}),Se(n.data.payment_accounts)),a==null&&o.push(rr({bankAccountId:c,shouldOverWriteCurrentBankAccountId:!1})),_(o)}return p(oE({status:n.status,userId:e}))})),v((n=>p(oE({userId:e,status:f("Unexpected Error","Fetch User Financial Account REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S($e.match),y((t=>{const{userType:e,cacheOverride:a}=t.payload,n=i.value,o=n.userListViewState.userListByType[e],c=H(n),d=Rj(c);if(a===!0||a===!1&&o.hasValidState()===!1){let l=`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/users`;const u=IY(e,d);return l+=`?query=${encodeURIComponent(JSON.stringify(u))}`,r.getJSON(l).pipe(y((m=>{if(T(m)){const h=[V({users:m.data?.users??[]}),Y(m.data?.user_roles??[]),If({userType:e,usersPayload:m.data?.users??[]})];return m.data?.user_groups!=null&&(h.push(em({userGroups:m.data.user_groups})),e==="taskManagerCandidate"&&h.push(Mj({userGroupType:e,userGroupsPayload:m.data.user_groups}))),e==="cardHolderCandidate"&&(h.push(Qv(m.data?.cards_count_by_user_id??[])),h.push(Wv(m.data?.debit_cards_count_by_deposit_account_id??{})),h.push(z(m.data?.addresses??[]))),j(_(h))}return p(iE({userType:e,status:m.status}))})),v((m=>p(iE({userType:e,status:f("Unexpected error","User REST API call errored out"+JSON.stringify(m))})))))}return _([])}))),(s,i,r)=>s.pipe(S(Vj.match),A((t=>{const{cacheOverride:e}=t.payload;return e===!0?r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/config`).pipe(y((a=>T(a)?_([Lj(a),Fj({countryListKey:"nationalityCountryList",countryListPayload:a.data?.nationality??[]})]):p(cE(a.status)))),v((a=>p(cE(f("Unexpected Error","Fetch user-roles config REST API call errored out"+JSON.stringify(a))))))):[]}))),(s,i,r)=>s.pipe(S(io.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/1099-config`).pipe(y((t=>T(t)?p(qj(t)):p(dE(t.status)))),v((t=>p(dE(f("Unexpected Error","Fetch vendor 1099 types REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(n1.match),y((r=>{const t=[],{vendorId:e,cacheOverride:a}=r.payload,n=i.value;let o=n.editBillDetailViewState.newBillState;if(r.payload.billId!=null){const c=Ne(r.payload.billId);o=n.editBillDetailViewState.editBillStateById[c]}if(e!=null){const c=Oe(n.vendorState,e);c!=null&&a===!1?(c.vendorCurrencyCode==null||Uo(c.vendorCurrencyCode)||t.push(ya(!0,{amount:o.billDetailLocalData.totalAmount?.amount??0,currencyCode:c.vendorCurrencyCode??"USD",currencySymbol:c.vendorCurrencySymbol??"$"},"USD",r.payload.billId)),t.push(lt({billDetailLocalData:Bl(n,o,c),billId:r.payload.billId})),t.push(aa(c.qboId,!1))):t.push(ys(e),nv(e,r.payload.billId))}else t.push(lt({billDetailLocalData:Bl(n,o),billId:r.payload.billId}));return _(t)}))),(s,i)=>s.pipe(S(o1.match),y((r=>{const t=[],{invoiceProcessingPayload:e,isVendorRecommendationFeatureEnabled:a,billId:n}=r.payload,o=e.vendors.length>0?e.vendors[0].vendor_name??"":"",c=Nc(i.value);return c.vendors.map((d=>d.name.toLowerCase())).includes(o.toLowerCase())===!0||o.length===0?t.push(Oc(e,a,n)):c.fetchStateBillsTab.fetchState!=="In-Progress"&&t.push(wt({searchString:o,billId:n}),ov(e,a,n)),_(t)}))),(s,i)=>s.pipe(S(zA.match),A((r=>{const t=[],e=i.value;if(r.payload.cacheOverride===!0)t.push(be("accountList",!0)),t.push(se()),t.push(He()),t.push(ct()),r.payload.vendorId!=null?t.push(ys(r.payload.vendorId,!1,r.payload.signal)):t.push(wt({}));else{const a=i.value.accountListState.byReportId.accountList;a.hasValidState()===!1&&a.fetchState!=="In-Progress"&&t.push(be("accountList",!0));const n=i.value.classListState;if(n.hasValidState()===!1&&n.fetchState!=="In-Progress"&&t.push(se()),e.vendorTypeListState.hasValidState()===!1&&e.vendorTypeListState.fetchState!=="In-Progress"&&t.push(He()),e.ownerListState.fetchState!=="In-Progress"&&e.ownerListState.hasValidState()===!1&&t.push(ct()),r.payload.vendorId!=null){const o=i.value.vendorViewState.editVendorStateById[r.payload.vendorId].fetchStatus;o.fetchState!=="Completed"&&o.fetchState!=="In-Progress"&&t.push(ys(r.payload.vendorId,!1,r.payload.signal))}else{const o=i.value.vendorListState;(o.fetchStateBillsTab.fetchState!=="Completed"&&o.fetchStateBillsTab.fetchState!=="In-Progress"||o.allVendorIdsBillsTab.length===0)&&t.push(wt({}))}}return j(_(t))}))),(s,i,r)=>s.pipe(S(ys.match),A((t=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${t.payload.vendorId}`,{},t.payload.signal).pipe(y((e=>{if(T(e)){const a=e.data?.vendors[0],n=a?.contacts??[],o=dt(e.data?.vendors??[]),c=a?.bank_accounts??[],d=a?.payment_instruments??[],l=a?.account!=null?[a?.account]:[],u=a?.accounting_class!=null?[a?.accounting_class]:[],m=[le(e.data?.vendors??[]),W(l,"account_list"),Ke("class_list",u),mt(n),z(o),Je(c),la(d),ve({files:a?.documents??[]}),Op({vendorId:t.payload.vendorId,isCreatable:t.payload.isCreatable}),_s(t.payload.vendorId)];return a!=null&&m.push(nr({vendorId:t.payload.vendorId,localData:wn(or(a),i.value,a),isCreatable:t.payload.isCreatable})),m.push(xo("Completed",t.payload.vendorId,void 0,t.payload.isCreatable)),m.push(Cp()),_(m)}return p(xo("Error",t.payload.vendorId,e.status,t.payload.isCreatable))})),v((e=>p(xo("Error",t.payload.vendorId,f("Unexpected Error","Fetch vendor REST API call errored out: "+JSON.stringify(e)),t.payload.isCreatable)))))))),(s,i,r)=>s.pipe(S(eG.match),A((t=>{const{attachmentIds:e,vendorId:a}=t.payload;let n=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${a}/attachments`;return n+=`?query=${encodeURIComponent(JSON.stringify({attachment_ids:e}))}`,r.getJSON(n).pipe(A((c=>{if(T(c)&&c.data!=null){const d=[];return d.push(tG({vendorId:a,transactionAttachments:c.data.transaction_attachments})),d}return p(pE({status:c.status}))})),v((c=>p(pE({status:f("Unexpected Error","Fetch Vendor First Review View REST API call errored out"+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(aG.match),A((t=>{let e=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors`;const{searchString:a,keepExistingListItems:n,pageToken:o}=t.payload,{uiState:c}=i.value.vendorFirstReviewViewState,d=c.sortOrder==="ascending"?"asc":c.sortOrder==="descending"?"desc":null,l={view:"merchant_review_list",page_token:o,sort_by:EY(c.sortKey),sort_order:d??null,search_text:a??null};return e+=`?query=${encodeURIComponent(JSON.stringify(l))}`,r.getJSON(e).pipe(A((u=>{if(T(u)&&u.data!=null){const m=[];return m.push(le(Fn(u.data.vendors)),V({users:qn(u.data.vendors),updateType:"merge"}),It({globalMerchants:jn(u.data.vendors)}),rG({response:u.data,keepExistingListItems:n})),m}return p(mE({status:u.status}))})),v((u=>p(mE({status:f("Unexpected Error","Fetch Vendor First Review View REST API call errored out"+JSON.stringify(u))})))))}))),(s,i,r)=>s.pipe(S(uG.match),A((t=>{const{keepExistingListItems:e}=t.payload,{uiState:a}=i.value.vendorGlobalReviewViewState,{searchText:n,sortOrder:o,pageToken:c,limit:d}=a,l=o==="ascending"?"asc":o==="descending"?"desc":null,u={page_token:c,sort_by:UY(a.sortKey),sort_order:l,search_text:n,limit:d??null};return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/reviews/global-merchant-list?query=${encodeURIComponent(JSON.stringify(u))}`).pipe(A((m=>{if(T(m)&&m.data!=null){const h=[];return h.push(V({users:CY(m.data.merchants),updateType:"merge"}),pG({tenantMerchants:m.data.merchants}),It({globalMerchants:xY(m.data.merchants)}),mG({globalMerchantsPayload:m.data.merchants,keepExistingListItems:e}),yG(m.data.query,m.data.total_count)),h}return p(hE({status:m.status}))})),v((m=>p(hE({status:f("Unexpected Error","Fetch Vendor Global Review View REST API call errored out"+JSON.stringify(m))})))))}))),(s,i)=>s.pipe(S(jj.match),A((r=>{const t=i.value,e=[];return r.payload.cacheOverride,t.vendor1099TypeListState.hasValidState()===!1&&t.vendor1099TypeListState.fetchState!=="In-Progress"&&e.push(io()),e.push(mu()),e.push(il()),j(_(e))}))),(s,i,r)=>s.pipe(S(Gj.match),A((t=>{const e={type_1099:t.payload.type1099,report_id:"vendor_1099"},a=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendor-1099/download?query=${encodeURIComponent(JSON.stringify(e))}`;return r.getJSON(a).pipe(A((n=>{if(T(n)&&n.data!=null){const o=[];return o.push(cl({response:n.data,downloadState:{fetchState:"Completed",error:void 0}})),o}return p(cl({response:lE.vendorFiling1099DownloadData,downloadState:{fetchState:"Error"}}))})),v((n=>p(cl({response:lE.vendorFiling1099DownloadData,downloadState:{fetchState:"Error",error:{code:500,message:"Fetch vendors 1099 Download REST API call errored out"+JSON.stringify(n)}}})))))}))),(s,i,r)=>s.pipe(S(il.match),A((()=>{const t=`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/reports/vendor_1099`;return r.getJSON(t).pipe(A((e=>{if(T(e)&&e.data!=null){const a=[];return a.push(...(function(n){const o=[],c=dt(n);return o.push(le(n,"merge"),z(c)),o})(e.data.report.vendors??[]),zj({response:e})),a.push(He()),a}return p(uE({status:e.status}))})),v((e=>p(uE({status:f("Unexpected Error","Fetch vendors 1099 list REST API call errored out"+JSON.stringify(e))})))))}))),(s,i,r)=>s.pipe(S(wt.match),A((t=>{let e=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors`;const{searchString:a,keepExistingListItems:n,view:o,pageToken:c,billId:d}=t.payload,{uiState:l}=i.value.vendorListState,u={view:bY(o),page_token:c,sort_by:l.sortKey,sort_order:l.sortOrder==="ascending"?"asc":l.sortOrder==="descending"?"desc":void 0,search_text:a,vendor_name:a};return e+=`?query=${encodeURIComponent(JSON.stringify(u))}`,r.getJSON(e).pipe(A((m=>{if(T(m)){const h=[];return m.data?.vendors?.[0]?.vendor_id!=null&&o==null&&h.push(Qj({vendorId:m.data?.vendors?.[0].vendor_id,billId:d})),h.push(...(function(g,I){const b=[],E=g.length>0?Wj(g):[],P=dt(g),O=g.length>0?gs(g):[],C=g.length>0?Zj(g):[],U=g.filter((J=>J.account!=null)).map((J=>J.account)),B=g.filter((J=>J.accounting_class!=null)).map((J=>J.accounting_class)),x=g.filter((J=>J.owner!=null)).map((J=>J.owner)),k=g.length>0?Xj(g):[];return b.push(le(g,I==="vendorsTab"?"merge":"replace"),W(U,"account_list"),Ke("class_list",B),mt(E),z(P),Je(O),la(C),ve({files:k}),V({users:x,updateType:"merge"})),b})(m.data?.vendors??[],o),hc({response:m,keepExistingListItems:n,searchString:a??"",view:o})),h}return p(Cc({status:m.status,view:o}))})),v((m=>p(Cc({status:f("Unexpected Error","Fetch vendors list REST API call errored out"+JSON.stringify(m)),view:o})))))}))),(s,i)=>s.pipe(S(tN.match),A((r=>{const{vendorId:t,entity:e,cacheOverride:a}=r.payload,n=[];if(a===!0)n.push(ko(t,!1),Bo(e),He());else{const o=i.value,c=o.vendorViewState.editVendorStateById[t]?.fetchStatus??{fetchState:"Not-Started"};o.vendorTypeListState.hasValidState()===!1&&o.vendorTypeListState.fetchState!=="In-Progress"&&n.push(He()),!(c.fetchState==="Completed"||c.fetchState==="In-Progress")&&n.push(ko(t,!1)),n.push(Bo(e))}return _(n)}))),(s,i)=>s.pipe(S(ko.match),A((r=>{const t=[],e=i.value;if(r.payload.cacheOverride===!0)t.push(be("accountList",!0)),t.push(se()),t.push(He()),t.push(ct()),r.payload.vendorId!=null?t.push(Do(r.payload.vendorId)):t.push(wt({}));else{const a=i.value.accountListState.byReportId.accountList;a.hasValidState()===!1&&a.fetchState!=="In-Progress"&&t.push(be("accountList",!0));const n=i.value.classListState;n.hasValidState()===!1&&n.fetchState!=="In-Progress"&&t.push(se()),e.ownerListState.fetchState!=="In-Progress"&&e.ownerListState.hasValidState()===!1&&t.push(ct());const o=i.value.vendorsTabVendorViewState.vendorStateById[r.payload.vendorId].fetchStatus;o.fetchState!=="Completed"&&o.fetchState!=="In-Progress"&&t.push(Do(r.payload.vendorId))}return j(_(t))}))),(s,i,r)=>s.pipe(S(Do.match),A((t=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${t.payload.vendorId}`).pipe(y((e=>{if(T(e)){const a=e.data?.vendors[0],n=a?.contacts??[],o=dt(e.data?.vendors??[]),c=gs(e.data?.vendors??[]),d=a?.account!=null?[a?.account]:[],l=a?.accounting_class!=null?[a?.accounting_class]:[],u=[le(e.data?.vendors??[]),W(d,"account_list"),Ke("class_list",l),mt(n),z(o),Je(c),ve({files:a?.documents??[]}),Jo("Completed",t.payload.vendorId,void 0),aN({vendorId:t.payload.vendorId}),_s(t.payload.vendorId)];return a!=null&&u.push(Dp({vendorId:t.payload.vendorId,localData:Jp(or(a),i.value,a)})),_(u)}return p(Jo("Error",t.payload.vendorId,e.status))})),v((e=>p(Jo("Error",t.payload.vendorId,f("Unexpected Error","Fetch vendors tab REST API call errored out"+JSON.stringify(e)))))))))),(s,i)=>s.pipe(S(SG.match),A((r=>{const{shouldFetchAccruedExpenses:t,shouldFetchFixedAssets:e,shouldFetchOpexByVendor:a,shouldFetchPrepaidExpenses:n,shouldFetchVendorsList:o,shouldFetchFiling1099Vendor:c}=r.payload,d=i.value,l=[],u=gG(d),m=_l(d,"fixed_assets"),h=_l(d,"prepaid_expenses"),g=_l(d,"accrued_expenses"),I=fG(d).fetchState,b=Nc(d,"vendorsTab").fetchState;t===!0&&u==="Completed"&&g!=="In-Progress"&&g!=="Completed"&&l.push(sf("accrued_expenses",{selectedTimeframe:dn("accrued_expenses"),selectedCategoryId:"all"}));const E=vG(d).fetchState;return e===!0&&u==="Completed"&&m!=="In-Progress"&&m!=="Completed"&&l.push(oc("fixed_assets",{selectedTimeframe:dn("fixed_assets"),selectedCategoryId:"all"})),n===!0&&u==="Completed"&&h!=="In-Progress"&&h!=="Completed"&&l.push(oc("prepaid_expenses",{selectedTimeframe:dn("prepaid_expenses"),selectedCategoryId:"all"})),a&&I!=="In-Progress"&&I!=="Completed"&&l.push(ZS()),o&&b!=="In-Progress"&&b!=="Completed"&&l.push(wt({searchString:"",keepExistingListItems:!1,view:"vendorsTab"})),c&&E!=="In-Progress"&&E!=="Completed"&&l.push(il()),_(l)}))),(s,i,r)=>s.pipe(S(He.match),A((()=>r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendor/config`).pipe(y((t=>T(t)?p(IG(t)):p(SE(t.status)))),v((t=>p(SE(f("Unexpected Error","Fetch vendor types REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(qF.match),y((r=>{const{cacheOverride:t}=r.payload,e=[],a=i.value;if(t===!0)e.push(ke()),e.push(Ge()),e.push(Xt());else{const n=a.depositAccountListState,o=a.zeniAccountListState;(n.hasValidState()===!1&&n.fetchState!=="In-Progress"||o.summary==null)&&e.push(ke());const c=a.paymentAccountListState;c.hasValidState()===!1&&c.fetchState!=="In-Progress"&&e.push(Ge());const d=a.zeniAccountsConfigState;d.hasValidState()===!1&&d.fetchState!=="In-Progress"&&e.push(Xt())}return j(_(e))}))),(s,i,r)=>s.pipe(S(Xt.match),A((()=>r.getJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/baas/config`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=[z([t.data.mailing_address,t.data.bank_address]),KF(t.data)];return _(e)}return p(eb({error:t.status}))})),v((t=>p(eb({error:f("Unexpected Error","Fetch Zeni Accounts config REST API call errored out"+JSON.stringify(t))})))))))),(s,i,r)=>s.pipe(S(zF.match),A((t=>{const{companyId:e,cacheOverride:a,refreshViewInBackground:n}=t.payload,{zeniAccountSetupViewState:o,plaidAccountViewState:c,companyState:d}=i.value,l=Te(d,e)?.company;if(a===!0||n===!0||l==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}?query={"view":"deposit_accounts_setup"}`).pipe(y((u=>{if(T(u)&&u.data!=null){const m=u.data.accounts?.map((g=>g.account_id)),h=[V({users:u.data.users}),Y(u.data.user_roles),Q({payload:u.data.companies,schema:{}}),z(u.data.addresses??[]),ve({files:u.data.files??[]}),W(u.data.accounts??[],"zeni_accounts"),Se(u.data.payment_accounts),Ht({data:u.data.payment_accounts,updateType:"replace"}),Qe(u.data.deposit_accounts??[]),Qt({data:u.data?.deposit_accounts??[],updateType:"replace"}),we({companyId:u.data.companies[0].company_id}),rt(m,"account_setup"),ZI()];return _(h)}return p(N({messageSection:"zeni_accounts_setup",messageText:"failed",type:"error"}),XI(u.status))})),v((u=>p(XI(f("Unexpected Error","Fetch Zeni Account Setup view errored out"+JSON.stringify(u)))))));{const{allBankAccountIds:u}=c.spend_management_setup.accountDetails;return p(we({companyId:e}),rt(u,"account_setup"),ZI())}}))),(s,i,r)=>s.pipe(S(Cn.match),y((t=>{const{depositAccountId:e}=t.payload,a=e==="zeni-clearing-account"?`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/zeni-clearing-account/statements`:`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}/statements`;return r.getJSON(a).pipe(y((n=>T(n)?p(bG({depositAccountId:e,data:n.data?.statements??[]})):p(gE({depositAccountId:e,fetchState:"Error",error:n.status})))),v((n=>p(gE({depositAccountId:e,fetchState:"Error",error:f("Unexpected Error","Fetch deposit Account satement REST API call errored out"+JSON.stringify(n))})))))}))),(s,i)=>s.pipe(S(EG.match),y((r=>{const{cacheOverride:t,depositAccountId:e}=r.payload,a=[],n=i.value;if(t===!0)a.push(Cn(e)),e!==fE&&a.push(zr(e));else{if(e!==fE){const c=n.zeniAccountDetailState.depositAccountDetailById[e];(c==null||c.hasValidState()===!1&&c.fetchState!=="In-Progress")&&a.push(zr(e))}const o=n.zeniAccStatementListState.byDepositId[e];(o==null||o.hasValidState()===!1&&o.fetchState!=="In-Progress")&&a.push(Cn(e))}return j(_(a))}))),(s,i,r)=>s.pipe(S(je.match),A((()=>r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/users/zeni-users`).pipe(y((t=>{if(T(t)&&t.data!=null){const e=t.data.users.map((n=>n.user_id)),a=[V({users:t.data.users}),nO(e)];return _(a)}return p(Nm(t.status))})),v((t=>p(Nm(f("Unexpected error","Unable to fetch zeni users"+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(CD.match),y((t=>{const{companyEmailDomain:e}=t.payload;return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/email-groups?query=${encodeURIComponent(JSON.stringify({company_email_domain:e.toLowerCase()}))}`).pipe(y((a=>{if(T(a)&&a.data!=null){const n=[xD(a.data)];return _(n)}return p(IS(a.status))})),v((a=>p(IS(f("Unexpected error","Email Group REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(DJ.match),A((t=>{const{linkTokenType:e,paymentAccountId:a}=t.payload;return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/link-token?query=${JSON.stringify(ZE(e,a))}`).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[JJ(n.data.link_token,n.data.expiration,e)];return _(o)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),HS(n.status,e))})),v((n=>p(HS(f("Unexpected Error","Get Onboarding Plaid Link Token errored out"+JSON.stringify(n)),e)))))}))),(s,i,r)=>s.pipe(S(cc.match),A((t=>{const{setupViewType:e,includeBalances:a,plaidAccountKeyType:n}=t.payload;let o={is_include_balances:a,is_primary_for_onboarding:!1,is_primary_for_bill_pay:!0};return e==="billing"&&n==="billing_setup"&&(o={is_primary_for_onboarding:!0}),r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts?query=${encodeURIComponent(JSON.stringify(o))}`).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data.payment_accounts.map((u=>u.payment_account_id)),l=[W(c.data.accounts,Da(e)),Se(c.data.payment_accounts),rL(d,n)];return _(l)}return p(tI(c.status,n))})),v((c=>p(tI(f("Unexpected Error","Get Payment Accounts errored out"+JSON.stringify(c)),n)))))}))),(s,i,r)=>s.pipe(S(kJ.match),y((t=>{const{linkTokenType:e,paymentAccountId:a,plaidAccountKeyType:n}=t.payload;return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/plaid/link-token?query=${JSON.stringify(ZE(e,a))}`).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[BJ(o.data.link_token,o.data.expiration,e,n)];return _(c)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),YS(o.status,e,n))})),v((o=>p(YS(f("Unexpected Error","Get Plaid Link Token errored out"+JSON.stringify(o)),e,n)))))}))),(s,i,r)=>s.pipe(S(MC.match),y((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a}}=e,{scheduleType:n,jeScheduleTransactionKey:o,reason:c,note:d}=t.payload,l=H(e),u=a[l.tenantId],m=[],h=ft(o,e),g=((E,P,O)=>{const{vendorState:C}=O,{vendor:U,currencyCode:B,currencySymbol:x,baseTransaction:k,status:J,balanceAsOfToday:L,period:R,startDate:q,endDate:$,jeCredit:D,jeDebit:w}=P,K=U.id,G=C.vendorByID[K];return{scheduled_journal_entries:[],je_schedules:[{status:J,vendor:JC(G),currency_code:B,currency_symbol:x,period:R??null,je_schedule_type:E,posting_date:null,balance:jz(k,L),start_date:q?.format(re)??null,end_date:$?.format(re)??null,je_credit_accounting_class_id:D?.accountingClass?.classId??null,je_credit_account_id:D?.account?.accountId??null,je_debit_accounting_class_id:w?.accountingClass?.classId??null,je_debit_account_id:w?.account?.accountId??null,other_attributes:{},base_transaction:DC(k),is_reviewed:!0}]}})(n,h,e),I={...g,je_schedules:g.je_schedules.map(((E,P)=>P===0?{...E,feedback:{reason:c,...d!=null&&d!==""?{note:d}:{}}}:E))},b={je_schedule_type:n};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/ignore/${h.jeScheduleId}?query=${encodeURIComponent(JSON.stringify(b))}`,I).pipe(y((E=>{if(T(E)&&E.data!=null)return m.push(ut(E.data.je_schedules),St(E.data.je_schedules,E.data.scheduled_journal_entries),VC(o),fy(o,u),et({tenantId:l.tenantId,period:u,refreshViewInBackground:!0}),N({messageSection:"ignore_schedule",messageText:"success",type:"success"})),_(m);{const P=[];return P.push(vy({status:E.status,jeScheduleTransactionKey:o})),P.push(N({messageSection:"ignore_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:E.status.message}]})),_(P)}})),v((E=>{const P=[];return P.push(vy({status:f("Unexpected Error","ignore JE schedules REST API call errored out"+JSON.stringify(E)),jeScheduleTransactionKey:o})),P.push(N({messageSection:"ignore_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(E)}]})),_(P)})))}))),(s,i,r)=>s.pipe(S(gN.match),A((t=>{const{companyId:e,tenantId:a}=t.payload,n=i.value.companyState.companiesById[e],o=a??n.companyInfo.tenantId;return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/ai-text-assist/emails/month-end`,{text:t.payload.text},{...!!o&&{"zeni-tenant-id":o}}).pipe(y((c=>{if(c.data?.text!=null){const{text:d}=c.data;return p(fN(d,e))}return p(Hp(f("Unexpected error","Ai-text-assist REST API call errored out"+JSON.stringify(c.status)),e))})),v((c=>p(Hp(f("Unexpected error","Ai-text-assist REST API call errored out"+JSON.stringify(c)),e)))))}))),(s,i,r)=>s.pipe(S(XO.match),y((t=>{const{accountId:e}=t.payload,a=i.value,n=H(a),o=a.expenseAutomationViewState.selectedPeriodByTenantId[n.tenantId],c=Ze(a.accountState,e,"excluded_account_reconciliation"),d=Re(o,!0),l=JSON.stringify({start_date:d.start,end_date:d.end}),u=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/excluded-accounts/${e}?query=${encodeURIComponent(l)}`;return r.deleteAndGetJSON(u).pipe(y((m=>{if(T(m)&&m.data!=null){const h=m.data.reconciliation,g=Ns("excluded_account_reconciliation",h.account_id),I=Ns("account_reconciliation",h.account_id);return p(ei(o,[h]),eC({reconciliation:h,selectedPeriod:o}),zm({oldKey:g,newKey:I}),N({messageSection:"account_included_in_reconciliation",messageText:"success",type:"success",variables:[{variableName:"_account-name_",variableValue:c?.accountName??""}]}))}return p(ey({error:m.status}),N({messageSection:"account_included_in_reconciliation",messageText:"failed",type:"error"}))})),v((m=>p(ey({error:f("Unexpected Error",`Include account in reconciliation REST API call errored out ${JSON.stringify(m)}`)}),N({messageSection:"account_included_in_reconciliation",messageText:"failed",type:"error"})))))}))),(s,i,r,t=lz)=>s.pipe(S(TP.match),ar((e=>e.payload.provider)),y((e=>e.pipe(A((a=>r.postAndGetJSON(`${r.apiEndPoints.authMicroServiceBaseUrl}/1.0/connectors/email/${a.payload.provider}/init`,{redirect_after_url:a.payload.redirectAfterUrl},{"zeni-tenant-id":a.payload.tenantId}).pipe(y((n=>{if(T(n)&&n.data!=null)return t(n.data.authorization_url),_([AP(a.payload.tenantId,a.payload.provider,n.data.authorization_url)]);const o=n.status??f(`Failed to start ${a.payload.provider} connection. Please try again.`);return _([su(a.payload.tenantId,a.payload.provider,o)])})),v((n=>{const o=n instanceof Error?n.message:`Unexpected error starting ${a.payload.provider} connection.`;return _([su(a.payload.tenantId,a.payload.provider,f(o))])}))))))))),(s,i)=>s.pipe(S(Xm.match),y((()=>{const r=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:t},expenseAutomationReconciliationViewState:{selectedAccountId:e}}=r,a=t[H(r).tenantId],n=[];if(e!=null){const o=Ea(r,e,a),c=o?.transactionsToReconcile?.filter((u=>u.isTransactionChecked)),d=c?.map((u=>u.id))??[];n.push(gr({selectedTransactionIds:d}));const l=Dz(o?.transactionsToReview??[]);n.push(Wm(l))}return _(n)}))),s=>s.pipe(S(mu.match),y((()=>{const i=[];return i.push(uu()),i.push(du()),i.push(io()),_(i)}))),s=>s.pipe(S(_y.match),y((()=>{const i=[];return i.push(uy()),i.push(my()),_(i)}))),(s,i)=>s.pipe(S(GR.match),y((r=>{const{approvalRuleId:t}=r.payload,e=[];if(t!=null){const a=zf(i.value.approvalRuleState,t);if(a!=null){const n={approvalRuleId:t,steps:a.steps,criteria:{amount:Hf(a.criteria),vendor:Yf(a.criteria),department:Kf(a.criteria)},name:a.name,description:a.description,separationOfDuties:a.separationOfDuties};e.push(Qf(),Wf(n))}}else{const a={steps:[],criteria:{}};e.push(Qf(),Wf(a))}return _(e)}))),(s,i)=>s.pipe(S(Tc.match),y((r=>{const{billId:t}=r.payload,e=i.value,a=Ne(t),n=X(e.editBillDetailViewState.editBillStateById,a,void 0),o=X(e.billDetailViewState.billDetailById,a,void 0),c=X(e.billTransactionState.transactionById,t,void 0),{accountListState:d,accountState:l,classListState:u,classState:m,recurringBillState:h}=e,g=M0(l,d,"billPayAccountList"),I=tr(m,u),b=c?.recommendations;if(o!=null&&c!=null&&(n?.billDetailLocalData.vendor==null||c.lines!=null&&c.lines.length>0&&Object.keys(n?.billDetailLocalData.updatesByLineId??{}).length===0)){let E=i1(e.vendorState,c.vendor?.id??"");if(E==null){const pe=e.editBillDetailViewState.newBillState.suggestedVendorIdFromParsedInvoice;if(pe!=null){const fe=Oe(e.vendorState,pe);(fe?.matchScore??0)>85&&(E=fe)}}const{tenantState:P,companyState:O}=e,{currentTenantId:C}=P,U=C!=null?P.tenantsById?.[C]?.companyId:void 0,B=Te(O,U??""),x=B?.company.companyInfo.bookCloseDate,k={invoiceNumber:c.documentId,billDueDate:c.dueDate!=null&&c.date!=null?V0(c.billPayInfo.stage.code,c.dueDate,c.date,x):c.dueDate,invoiceDate:Rl(c.billPayInfo.stage.code,c.date,x),memo:c.memo,currencyCode:c.amount.currencyCode,recipientCurrencyCode:c.recipientTotalAmount.currencyCode,isInvoiceDateAutoUpdated:c.billPayInfo.stage.code==="draft"&&c.date!=null&&x!=null&&c.date.isBefore(x)},J={};c.lines?.forEach((pe=>{J[pe.id]={...pe,...eP(pe.id,pe,b,g,I,E)}}));const L=B?.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach,R=L!=null&&me().isSameOrBefore(L),q=c.billPayInfo.paymentDate??ee(eo(me().toDate(),[0,6],R?0:1).toISOString()),$={paymentType:c1(e.billPayConfigState,c.billPayInfo.fromAccount.billAccountType,c.billPayInfo.billPaymentMethodType,c.billPayInfo.internationalTransferFeeBearerPaymentMethod),paymentDate:q,withdrawFrom:L0(e,c.billPayInfo.fromAccount.billAccountId??"",c.billPayInfo.fromAccount.billAccountType??"",U),paymentTo:c.billPayInfo.toAccount.billAccountId!=null&&c.billPayInfo.toAccount.billAccountId.length>0?c.billPayInfo.toAccount.billAccountId:void 0,internationalTransferFeeBearerPaymentMethod:c.billPayInfo.internationalTransferFeeBearerPaymentMethod},D=c.amount,w=c.recipientTotalAmount,K=c.billPayInfo.isCancelled,G=c.attachments?.[0],Z=c.candidateVendorName,de=c.billPayInfo.toAccountVendorEmail,ue=c.billPayInfo.isCollectToAccountInfoFromVendorContact,te=c.isRecurring;let ye,_e;if(te){const{recurringConfigLocalData:pe,recurringBillInstancesLocalData:fe}=d1(h,c);ye=pe,_e=fe}const Ve=Gl(c.billPayInfo.billPaymentMethodType.code)?{paymentMode:c.billPayInfo.outsideZeniTransactionPaymentMode,paymentDate:c.billPayInfo.paymentDate}:void 0,Ae=[lt({billDetailLocalData:{showVendorGptRecommendationText:!1,vendor:E,whatForSection:k,updatesByLineId:J,paymentDetailsSection:$,totalAmount:D,recipientTotalAmount:w,isCancelled:K,file:G,candidateVendorname:Z,toAccountVendorEmail:de,isCollectToAccountInfoFromVendorContact:ue,isRecurring:te,recurringConfig:ye,recurringBillInstances:_e,outsideZeniPaymentLocalData:Ve},billId:t}),iv({billId:t})];return E?.vendorCurrencyCode!=null&&E.vendorCurrencyCode!=="USD"&&Ae.push(ya(!0,{amount:D.amount,currencyCode:E.vendorCurrencyCode,currencySymbol:E.vendorCurrencySymbol},"USD",t)),_(Ae)}return _([iv({billId:t})])}))),(s,i)=>s.pipe(S(xM.match),y((r=>{const{userId:t}=r.payload,e=i.value.userState,a=i.value.userRoleState,n=bt(e,t),o=zi(a,t),c=[];if(n!=null&&o!=null){const d=n.birthday,l=n.phone,u=n?.isPhoneVerified,m=n?.syncToken,h={userId:t,dateOfBirth:d,phone:l,isPhoneVerified:u,syncToken:m};c.push(UM({localData:h}))}return _(c)}))),(s,i)=>s.pipe(S(Vp.match),y((r=>{const t=[],{companyId:e}=r.payload,a=i.value,{companyHealthMetricState:n}=a,o=iN(n,e);if(o!=null){const{netPromoterScore:c,externalProductServiceExposure:d,customerSatisfactionScore:l,additionalChurnFactors:u}=o;t.push(cN({companyId:e,updatedLocalData:{netPromoterScore:c,customerSatisfactionScore:l,externalProductServiceExposure:d?.code,additionalChurnFactors:u}}))}return j(_(t))}))),(s,i)=>s.pipe(S(mv.match),y((r=>{const{amount:t,vendorType:e}=r.payload,a=[],n=i.value,o=n.internationalWireState.createInternationalWireDetails.localData,c=pv(o?.currencyCode??"",t,e),d=n.internationalWireState.dynamicFormDetailsbyKey[c]??{};if(o!=null){const l={countryCode:o.countryCode,currencyCode:o.currencyCode,accountType:o.accountType,dynamicForm:VK(d),source:o.source};a.push(_v(l))}return _(a)}))),(s,i)=>s.pipe(S(XJ.match),y((r=>{const{userId:t}=r.payload,e=[];if(t){const{userState:a,userRoleState:n,peopleState:o}=i.value,c={userId:t,user:bt(a,t),userRole:zi(n,t),update:ew(o,t)},d=c.user?.email,{userRoles:l,managerUserId:u,accountingClassIDs:m}=c.userRole,h=H(i.value),g=jl(l,h.company);e.push(tw({peopleLocalData:[{email:d!=null?[d]:[],role:g,managerId:u,departmentId:m[0]}],person:c}))}return _(e)}))),(s,i)=>s.pipe(S(hy.match),y((r=>{const t=i.value,e=[],{jeScheduleTransactionKeys:a}=r.payload;return a.forEach((n=>{const o=ft(n,t),c={jeScheduleType:o.jeScheduleType,jeScheduleID:o.jeScheduleId,scheduledJournalEntryID:o.scheduledJournalEntry[0].scheduledJournalEntryID,updatedVendor:void 0,updatedCategoryId:void 0,updatedAccumulatedDepreciationCategoryID:void 0,updatedClassId:void 0};e.push(LC({localData:c,scheduledJournalEntryID:o.scheduledJournalEntry[0].scheduledJournalEntryID}))})),_(e)}))),(s,i)=>s.pipe(S($1.match),y((r=>{const{billId:t,vendorId:e}=r.payload,a=[],n=i.value,o=n.internationalWireState.createInternationalWireDetails.localData;let c=0;if(t!=null){const d=Ne(t);c=n.editBillDetailViewState.editBillStateById[d]?.billDetailLocalData?.recipientTotalAmount?.amount??0}else c=n.editBillDetailViewState.newBillState.billDetailLocalData?.recipientTotalAmount?.amount??0;if(o==null){const d={countryCode:e!=null?n.vendorViewState.editVendorStateById[e].vendorDetailLocalData?.countryCode:n.vendorViewState.newVendorState.vendorDetailLocalData?.countryCode,currencyCode:e!=null?n.vendorViewState.editVendorStateById[e].vendorDetailLocalData?.currencyCode:n.vendorViewState.newVendorState.vendorDetailLocalData?.currencyCode,dynamicForm:{}};if(d.currencyCode!=null){const l=e!=null?n.vendorViewState.editVendorStateById[e].vendorDetailLocalData?.vendorType:n.vendorViewState.newVendorState.vendorDetailLocalData?.vendorType;a.push(uv(d.currencyCode,c,l||"international_business",!1))}a.push(_v(d))}return _(a)}))),(s,i)=>s.pipe(S(hv.match),y((r=>{const{companyId:t,internationalWireFormPayload:e}=r.payload,a=[],n=i.value.companyState.companiesById[t].companyBillPayInfo.internationalWireOnboardingDetails,o={};return Object.keys(e).forEach((c=>{const d=n?.[c]?.values;o[c]=d!=null?e[c].type==="enum"?e[c].is_multiple_values_allowed===!1?typeof d[0]=="object"&&"code"in d[0]?d[0].code:"":d.map((l=>typeof l=="object"&&"code"in l?l.code:"")):d[0]:e[c].type==="enum"&&e[c].is_multiple_values_allowed===!0?[]:""})),a.push(V1(o)),_(a)}))),(s,i)=>s.pipe(S(eS.match),y((r=>{const t=i.value,e=t.addressViewState.newAddressState?.[an]?.addressToCreate,a=r.payload.address?.address_id;if(e!=null||a==null)return F;const n=ot(t.addressState,a);return n!=null?p(qe({addressType:an,addressToCreate:n})):F}))),(s,i)=>s.pipe(S((r=>Ak.match(r)||bi.match(r))),y((r=>{const{id:t}=r.payload,e=i.value;if(e.addressViewState.newAddressState?.[Hs]?.addressToCreate!=null||t==null)return F;const n=q_(e.invoicingCustomerState,t),o=n?.billingAddressId!=null?ot(e.addressState,n.billingAddressId):void 0;return o!=null?p(qe({addressType:Hs,addressToCreate:o})):F}))),(s,i)=>s.pipe(S((r=>Dk.match(r)||Ti.match(r))),y((r=>{const{id:t}=r.payload,e=i.value;if(e.addressViewState.newAddressState?.[kr]?.addressToCreate!=null||t==null)return F;const n=Jk(e.invoicingSubscriptionState,t),o=n?.shippingAddressId!=null?ot(e.addressState,n.shippingAddressId):void 0;return o!=null?p(qe({addressType:kr,addressToCreate:o})):F}))),(s,i)=>s.pipe(S(_f.match),y((()=>{const r=i.value.tenantState.loggedInUser?.userId,t=[ma("user_address")];if(r==null)return t;const e=i.value.userState,a=i.value.userRoleState,n=bt(e,r),o=zi(a,r),c=o?.addressId!=null?ot(i.value.addressState,o.addressId):void 0;if(c!=null&&t.push(qe({addressType:"user_address",addressToCreate:c})),n!=null&&o!=null){const d=n.birthday,l=n.phone,u=n?.isPhoneVerified??!1,m=n?.syncToken,h={dateOfBirth:d,phone:l,isPhoneVerified:u,syncToken:m};t.push(iR({localData:h}))}return _(t)}))),(s,i)=>s.pipe(S(jC.match),y((r=>{const t=[],e=Ir(),{accountListState:a,classListState:n}=i.value;return a.byReportId[e.accountListKey]?.fetchState==="Not-Started"&&t.push(be(e.accountListKey,!0,!1,!1,!1,e.allowedAccountList)),n.fetchState==="Not-Started"&&t.push(se()),r.payload.shouldResetEnteredData&&(t.push(by({scheduleType:r.payload.scheduleType})),t.push(GC())),_(t)}))),(s,i)=>s.pipe(S(UD.match),y((r=>{const{isDebitCardFlagEnabled:t,companyId:e}=r.payload,a=[];if(e!=null){const n=kD(i.value.onboardingCustomerState,e),o=Mi(i.value.companyState,e),c=o?.company.companyOnboardingInfo.onboardingInfo?.onboardingCustomerUserIds!=null&&o.company.companyOnboardingInfo.onboardingInfo.onboardingCustomerUserIds.length>0?o.company.companyOnboardingInfo.onboardingInfo.onboardingCustomerUserIds[0]:null;if(n!=null&&o!=null){const d=i.value.onboardingCockpitViewState.onboardingTenantIdByCompanyId[e],l=bS(i.value.tenantState,d),u=l?.isEmailGroupCreated?o.company.companyOnboardingInfo.isSubsidiary:void 0,m={companyEmailDomain:o.company.companyInfo.primaryEmailDomain,isOnboardingTenant:!0,userEmailWithPreOnboardSuccess:n.userEmailWithPreOnboardSuccess,companyId:o.company.companyInfo.companyId,languageCode:o.company.companyLocaleInfo.languageCode,countryCode:o.company.companyLocaleInfo.companyIncCountryCode,currencyCode:o.company.companyLocaleInfo.currencyCode,groupId:n.groupId,groupDescription:n.groupDescription,groupName:n.groupName,name:o.company.companyInfo.name,qboRealmId:l?.qboRealmId,chargebeeId:l?.chargebeeId,hubSpotId:l?.hubSpotId,isCustomerCreated:l?.isCustomerCreated,isEmailGroupCreated:l?.isEmailGroupCreated,isOnboardingCompanyDetailsCompleted:o.company.companyOnboardingInfo.isOnboardingCompanyDetailsCompleted,isSubsidiary:u,parentCompanyId:o.company.companyOnboardingInfo.parentCompanyId,tenantId:d,companyLegalName:o.company.companyInfo.companyLegalName,accountingConnectionCreationMode:o.company.companyOnboardingInfo.onboardingInfo?.accountingConnectionCreationMode!=null?BD(o.company.companyOnboardingInfo.onboardingInfo?.accountingConnectionCreationMode):void 0,selectedProducts:cK(t,l)};if(c!=null){const g=bt(i.value.userState,c);g!=null&&(m.customerName={firstName:g.firstName,lastName:g.lastName},m.email=g.email)}a.push(ES(),PS(m),TS(m),Vi());const h=o?.company.managementInfo.companyAddressId!=null?ot(i.value.addressState,o?.company.managementInfo.companyAddressId):void 0;h!=null&&a.push(qe({addressType:"company_address",addressToCreate:h}))}else a.push(DD())}else{const n={companyEmailDomain:"",isOnboardingTenant:!0,userEmailWithPreOnboardSuccess:"",chargebeeId:"",isSubsidiary:void 0,groupId:"",groupName:"",groupDescription:"",name:"",customerName:{firstName:"",lastName:""},companyLegalName:"",email:"",qboRealmId:"",selectedProducts:[]};a.push(ES(),PS(n),TS(n),Vi())}return _(a)}))),(s,i)=>s.pipe(S(QL.match),y((r=>{const{approvalRuleId:t}=r.payload,e=[];if(t!=null){const a=zf(i.value.approvalRuleState,t);if(a!=null){const n={approvalRuleId:t,steps:a.steps,criteria:{amount:Hf(a.criteria),vendor:Yf(a.criteria),department:Kf(a.criteria)},name:a.name,description:a.description,separationOfDuties:a.separationOfDuties};e.push(EI(),PI(n))}}else{const a={steps:[],criteria:{}};e.push(EI(),PI(a))}return _(e)}))),(s,i)=>s.pipe(S(dI.match),y((r=>{const{reimbursementId:t}=r.payload,e=i.value,a=e.reimbursementState.reimbursementById[t];if(a!=null){const n={reportTitle:a?.reportTitle},o=a.reimbursementInfo.stage.code==="pending_approval",c={};a.lines?.forEach((m=>{if(m.type==="out_of_pocket"){const h=m.merchant?.id,g=h!=null?PL(e.merchantState,h):void 0,{recommendedAccount:I}=TL(g?.recommendations,m.lineDetail.account,m.lineDetail.class);c[m.lineId]={lineId:m.lineId,type:m.type,fileId:m.fileId,homeCurrencyConversions:m.homeCurrencyConversions,outOfPocket:{recommendations:g?.recommendations??[],recommendedAccount:I,isCategoryUpdateSelected:!1,isCategoryFirstTimeAutofilled:!1,isRetainedCategorySelected:!1,merchant:{id:g?.id,name:g?.name??""},amount:m.amount,currencyCode:m.currencyCode,currencySymbol:m.currencySymbol,description:m.description,transactionDate:m.transactionDate,lineDetail:m.lineDetail},mileage:{}},o&&(c[m.lineId]={...c[m.lineId],outOfPocket:{...c[m.lineId].outOfPocket,retainedAccount:I!=null?m.lineDetail.account:void 0,isRetainedCategorySelected:!1}})}else c[m.lineId]={lineId:m.lineId,type:m.type,fileId:m.fileId,homeCurrencyConversions:m.homeCurrencyConversions,mileage:{lineDetail:m.lineDetail,amount:m.amount,currencyCode:m.currencyCode,currencySymbol:m.currencySymbol,description:m.description,transactionDate:m.transactionDate,distanceMileage:m.distanceMileage},outOfPocket:{recommendations:[],isCategoryFirstTimeAutofilled:!1,isRetainedCategorySelected:!1,isCategoryUpdateSelected:!1}}}));const d={};a.lines?.forEach((m=>{d[m.lineId]={fetchState:"Not-Started",error:void 0}}));const l=a.amount,u={whatForSection:n,updatesByLineId:c,totalAmount:l,files:a.attachments,currencyConversionStateByLineId:d,paymentTo:a.reimbursementInfo.toAccount.billAccountId};return p(vd({remiDetailLocalData:u,reimbursementId:t}))}return _([])}))),(s,i)=>s.pipe(S(Va.match),y((r=>{const t=i.value,{scheduleAccruedDetailState:e}=t,a=[],{selectedJeScheduleDetailId:n,selectedJEScheduleKey:o,scheduleType:c}=r.payload;let d;if(o!=null&&(d=sa(o,t)),n!=null&&d!=null){const l=((u,m)=>{const h=m.map((B=>({postingDate:B.expectedPostDate,amount:Wa(B.amount?B.amount.amount:0,B.currencyCode??"USD",B.currencySymbol??"$"),runningBalance:Wa(B.runningBalance?B.runningBalance.amount:0,B.currencyCode??"USD",B.currencySymbol??"$"),postingStatus:B.status.code,memo:B.memo,jeLink:UK(B.thirdPartyID,B.transactionID,B.recommendedTransactionID,B.reversalTransactionDetails)}))),{startDate:g,period:I,jeDebit:b,jeCredit:E,memo:P,recurringAmount:O,vendor:C,otherAttributes:U}=u;return{scheduleType:"accrued_expenses",startingBalance:{amount:U.startingBalance?.amount??0,currencyCode:"USD",currencySymbol:"$"},jeScheduleDetails:h,selectedDate:g,selectedMonths:I,selectedAccount:b.account?.accountId,selectedClass:b.accountingClass?.classId,estimatedMonthlyAmount:O,memo:P,selectedVendor:C,selectedAccruedExpenseCategory:E.account?.accountId??""}})(d,d.scheduledJournalEntry);a.push(cn({scheduleType:c,selectedJeScheduleDetailId:n,localData:{...T$,...l}}))}else a.push(cn({scheduleType:c,localData:{...e.newScheduleState},selectedJeScheduleDetailId:void 0}));return _(a)}))),(s,i)=>s.pipe(S(Mr.match),y((r=>{const t=i.value,{scheduleDetailState:e}=t,a=[],{selectedJeScheduleDetailId:n,selectedJEScheduleKey:o,scheduleType:c}=r.payload,d=ft(o,t);if(n!=null){const l=d.scheduledJournalEntry,u=c!=="fixed_assets"?$$(c,d,l):R$(d,l);a.push(un({scheduleType:c,selectedJeScheduleDetailId:n,localData:{...M$[c],...u}}))}else a.push(un({scheduleType:c,localData:{...e.newScheduleState[c]},selectedJeScheduleDetailId:void 0}));return _(a)}))),(s,i)=>s.pipe(S(rq.match),y((r=>{const{subscriptionId:t,tenantId:e}=r.payload,a=[];if(t!=null){const n=sq(i.value.subscriptionState,t);if(n?.subscription!=null){const{subscriptionPlanId:o,subscriptionAddonIds:c,subscriptionCouponIds:d}=n.subscription;let l=!0,u=!1;const m=!0;n.subscription.status.code==="future"&&(l=!1,u=!0);const h={subscriptionPlanId:o,subscriptionAddOnIds:c,subscriptionCouponIds:d,subscriptionId:t,invoiceImmediately:m,applyEndOfTerm:l,shouldProrate:u};a.push(pb({tenantId:e}),mb({tenantId:e,subscriptionData:h}))}}else{const n={subscriptionAddOnIds:[],subscriptionCouponIds:[],invoiceImmediately:!0};a.push(pb({tenantId:e}),mb({tenantId:e,subscriptionData:n}))}return _(a)}))),(s,i)=>s.pipe(S(Ib.match),y((r=>{const{taskId:t}=r.payload,e=i.value,a=X(e.taskState.taskByID,t,void 0);if(a!=null){const n={name:a.name,description:a.description,status:a.status.code,assignee:a.assignees,groupAssignees:a.groupAssignees,dueDate:a.dueDate,priority:a.priority.code,tagIds:a.tagIds,fileIds:a.fileIds,type:a.type,recurringFrequency:a.recurringFrequency,recurringDaysOfWeek:a.recurringDaysOfWeek,recurringEndDateLocalData:{recurringDatePickerOptionsType:"date",recurringEndDate:a.recurringEndDate},savedRecurringEndDate:a.recurringEndDate,recurringStartDate:a.recurringStartDate,timeSpent:a.timeSpent,isPrivate:a.isPrivate,taskGroupId:a.taskGroupIds[0]},o=[Oq({taskDetailLocalData:n,taskId:t}),za({taskId:t,fetchState:"Completed"})];return _(o)}return _([za({taskId:t,fetchState:"Completed"})])}))),(s,i)=>s.pipe(S(bs.match),y((r=>{const{transactionId:t,vendorId:e}=r.payload,a=[],n=i.value.transactionState,o=Be(t),c=At(n,o);if(c!=null){const d=pa(i.value.accountState,i.value.accountListState,"accountList"),l=uj(c,e,d);a.push(pj({transactionId:t})),a.push(mj({transactionId:t,transactionLocalData:l}))}return _(a)}))),(s,i)=>s.pipe(S(_s.match),y((r=>{const{vendorId:t}=r.payload,e=[ma("vendor_address")];if(t!=null){const a=Oe(i.value.vendorState,t),n=a?.addressId!=null?ot(i.value.addressState,a?.addressId):void 0;n!=null&&e.push(qe({addressType:"vendor_address",addressToCreate:n}))}return _(e)}))),(s,i,r)=>s.pipe(S(fV.match),A((t=>{const e=i.value,{companyId:a}=t.payload,{depositAccountState:n,paymentAccountState:o,paymentAccountListState:c,depositAccountListState:d}=e,l=e.chargeCardRepaymentDetailState.localData,u=vV(n,d),m=IV(o,c),h=bV(u.depositAccounts,m.paymentAccounts,c.paymentAccountBalanceFetchStatus).find((I=>I.id===l.transferFrom?.id)),g={funding_account:{account_id:l.transferFrom?.id,account_type:Me(h?.accType)??""},idempotency_key:l.idempotencyKey,is_auto_pay_enabled:l.isAutoRepayment,amount:l.amount.amount};return h!=null&&l.transferFrom!=null?r.postAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/repayments`,g).pipe(y((I=>{if(T(I)&&I.data!=null){const b=[EV(I.data.card_repayment),PV({cardRepaymentId:I.data.card_repayment.card_repayment_id,zeniCreditAccountId:I.data.card_repayment.zeni_credit_account_id}),TV({amount:Wa(I.data.card_repayment.amount,I.data.card_repayment.currency_code,I.data.card_repayment.currency_symbol),date:ee(I.data.card_repayment.repayment_date)}),En({fetchState:"Completed",error:void 0})];return l.transferFrom!=null&&h?.accType!=null&&b.push(Gr({companyId:a,primaryFundingAccountId:l.transferFrom.id,accountType:h.accType,productType:"charge_cards"}),AV({companyId:a,enableAutoPay:l.isAutoRepayment})),_(b)}return p(En({fetchState:"Error",error:I.status}))})),v((I=>p(En({fetchState:"Error",error:f("Unexpected Error","Initiate Charge Card Repayment REST API call errored out"+JSON.stringify(I))}))))):p(En({fetchState:"Error",error:f("Validation Error","Funding account not selected.")}))}))),(s,i)=>s.pipe(S(Mg.match),A((r=>{const{reportIdToResync:t}=r.payload,e=[];switch(t){case"profit_and_loss_by_classes":e.push(yg(!0));break;case"operating_expenses_by_classes":e.push(rg(!0));break;case"revenue_by_classes":e.push(Vg(!0));break;case"net_burn_or_income_by_classes":e.push(iS(!0))}return _(e)}))),(s,i)=>s.pipe(S(Lg.match),A((r=>{const{reportIdToResync:t}=r.payload,e=[];switch(t){case"profit_and_loss_by_projects":e.push(Sg(!0));break;case"operating_expenses_by_projects":e.push(og(!0));break;case"revenue_by_projects":e.push(Fg(!0));break;case"net_burn_or_income_by_projects":e.push(lS(!0))}return _(e)}))),(s,i,r)=>s.pipe(S(aw.match),A((()=>{const t=i.value.peopleState.personDetails.localData,e=H(i.value),a=SK(t,e.company);return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/invites`,a).pipe(y((n=>{if(T(n)){const o=[];return n.data?.user_roles&&Vn(o,n.data?.user_roles[0],!1),p(Y(n.data?.user_roles??[]),V({users:n.data?.users??[]}),ug(n.data),N({messageSection:a.invites.length>1?"people_invite_multiple_people":"people_invite_people",messageText:"success",type:"success"}),...o)}return p(nn(n.status))})),v((n=>p(nn(f("Unexpected error","User Roles REST API call errored out"+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(rw.match),A((t=>{const e=i.value.peopleState.personDetails.localData,a=gK(e);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${t.payload.companyId}`,a).pipe(y((n=>{if(T(n)){const o=[];return n.data?.user_roles&&Vn(o,n.data?.user_roles[0],!0),p(Y(n.data?.user_roles??[]),V({users:n.data?.users??[]}),ug(n.data),N({messageSection:a.users.length>1?"people_invite_multiple_people":"people_invite_people",messageText:"success",type:"success"}),...o)}return p(nn(n.status))})),v((n=>p(nn(f("Unexpected error","User Roles REST API call errored out"+JSON.stringify(n)))))))}))),(s,i,r)=>{const t=()=>`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/data-import`,e=s.pipe(S(zU.match),y((()=>Yr("connect",r.postAndGetJSON(`${t()}/chargebee/connect`,{}))))),a=s.pipe(S(KU.match),y((d=>{const l=new FormData;return d.payload.files.forEach((u=>l.append("files",u,u.name))),Yr("upload",r.postFormData(`${t()}/uploads`,l))}))),n=s.pipe(S(YU.match),y((d=>Yr("start",r.postAndGetJSON(`${t()}/${encodeURIComponent(d.payload)}/import`,{}))))),o=s.pipe(S(HU.match),y((d=>Yr("retry",r.postAndGetJSON(`${t()}/${encodeURIComponent(d.payload)}/retry`,{}))))),c=s.pipe(S(QU.match),y((d=>Yr("rollback",r.postAndGetJSON(`${t()}/${encodeURIComponent(d.payload)}/rollback`,{})))));return vt(e,a,n,o,c)},(s,i,r)=>s.pipe(S($V.match),A((()=>{const t=i.value,e=i.value.tenantState.loggedInUser?.userId,a=t.issueChargeCardState.localData.map((n=>n.chargeCardType==="credit_card"?n.creditCard.cardType==="business_physical_credit_card"?{card_holder_user_ids:n.creditCard.physicalCard.userId!=null?[n.creditCard.physicalCard.userId]:[],card_name:n.creditCard.physicalCard.cardName,purchase_limit:n.creditCard.physicalCard.amount?.amount??0,currency_code:n.creditCard.physicalCard.amount?.currencyCode??"USD",purchase_limit_frequency:{code:n.creditCard.physicalCard.frequency},card_type:n.creditCard.cardType,shipping_address_type:n.creditCard.physicalCard.addressType,shipping_address_id:n.creditCard.physicalCard.addressId}:{card_holder_user_ids:n.creditCard.virtualCard.userIds,card_name:n.creditCard.virtualCard.cardName,purchase_limit:n.creditCard.virtualCard.amount?.amount??0,currency_code:n.creditCard.virtualCard.amount?.currencyCode??"USD",purchase_limit_frequency:{code:n.creditCard.virtualCard.frequency},card_type:n.creditCard.cardType}:n.debitCard.cardType==="business_physical_debit_card"?{card_holder_user_ids:n.debitCard.physicalCard.userId!=null?[n.debitCard.physicalCard.userId]:[],card_name:n.debitCard.physicalCard.cardName,purchase_limit:n.debitCard.physicalCard.amount?.amount??0,currency_code:n.debitCard.physicalCard.amount?.currencyCode??"USD",purchase_limit_frequency:{code:n.debitCard.physicalCard.frequency},card_type:n.debitCard.cardType,shipping_address_type:n.debitCard.physicalCard.addressType,shipping_address_id:n.debitCard.physicalCard.addressId,connected_account_id:n.debitCard.physicalCard.connectedAccountId,connected_account_type:"deposit_account"}:{card_holder_user_ids:n.debitCard.virtualCard.userIds,card_name:n.debitCard.virtualCard.cardName,purchase_limit:n.debitCard.virtualCard.amount?.amount??0,currency_code:n.debitCard.virtualCard.amount?.currencyCode??"USD",purchase_limit_frequency:{code:n.debitCard.virtualCard.frequency},connected_account_id:n.debitCard.virtualCard.connectedAccountId,card_type:n.debitCard.cardType,connected_account_type:"deposit_account"}));return r.postAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards`,{cards:a}).pipe(y((n=>{if(M(n)&&n.data!=null){const o=[],c=n.data.cards;o.push(qa(c),V({users:n.data.users}),Y(n.data.user_roles),Bv({chargeCardListPayload:n.data,keepExistingListItems:!0}),z(n.data.addresses),Qv(n.data?.cards_count_by_user_id??[]),Wv(n.data?.debit_cards_count_by_deposit_account_id??{}),RV(c.map((u=>u.card_id))),Pn({fetchState:"Completed"})),c.length!==1||c[0].card_type.code!=="business_virtual_debit_card"&&c[0].card_type.code!=="business_physical_debit_card"||e!==c[0].holder_user_id||o.push(MV(c[0].card_id));const d=c.map((u=>u.holder_user_id)),l=n.data.users.filter((u=>d.includes(u.user_id))).map((u=>u.first_name?.trim()??u.last_name?.trim())).filter((u=>u!=null));if(c.length>0&&l.length===1){const u=c.length>1?"cards":"card";o.push(N({messageSection:"issue_charge_card",messageText:"success",type:"success",variables:[{variableName:"_user-name_",variableValue:l[0]??""},{variableName:"_card_",variableValue:u}]}))}else o.push(N({messageSection:"issue_charge_cards",messageText:"success",type:"success"}));return _(o)}return p(Pn({fetchState:"Error",error:n.status}))})),v((n=>p(Pn({fetchState:"Error",error:f("Unexpected Error","Issue Charge Card REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(QB.match),y((()=>{const{draft:t}=i.value.invoicingIssueCreditNoteState,{invoiceId:e}=t,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(e)}/issue-credit-note`,n=WB(t);return r.postAndGetJSON(a,n).pipe(y((o=>T(o)&&o.data!=null?[zs([o.data],"merge"),Br({invoiceId:e}),ZB({creditNoteId:o.data.id}),N({messageSection:"invoicing_credit_note_saved",messageText:"success",type:"success"})]:_([Wh(o.status),N({messageSection:"invoicing_credit_note_saved",messageText:"failed",type:"error",variables:Ie(o.status)})]))),v((o=>_([Wh(f("Unexpected Error","Issue credit note REST API call errored out "+JSON.stringify(o))),N({messageSection:"invoicing_credit_note_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(HM.match),A((t=>{const{chargeCardId:e,reason:a,isChargeCardAdmin:n}=t.payload,o={reason:a},c=i.value.chargeCardState.chargeCardByID[e],d=c?.accountLast4??"";return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/lock`,o).pipe(y((l=>M(l)&&l.data!=null?p(st(l.data),Hc({chargeCardId:e,fetchState:"Completed"}),N({messageSection:n?"lock_charge_card":"lock_charge_card_card_user",messageText:"success",type:"success",variables:[{variableName:"_masked_card_number_",variableValue:`•••• ${d}`}]})):p(N({messageSection:n?"lock_charge_card":"lock_charge_card_card_user",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}),Hc({chargeCardId:e,fetchState:"Error",error:l.status})))),v((l=>p(N({messageSection:n?"lock_charge_card":"lock_charge_card_card_user",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(l)}]}),Hc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Lock card API call errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(cV.match),A((t=>{const{cardIds:e,reason:a}=t.payload,n={card_ids:e,reason:a};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/bulk/lock`,n).pipe(y((o=>M(o)&&o.data!=null?p(qa(o.data),sd({fetchState:"Completed"}),N({messageSection:"lock_charge_cards",messageText:"success",type:"success",variables:[{variableName:"_number_of_cards_",variableValue:e.length===1?"1 card":`${e.length} cards`}]})):p(N({messageSection:"lock_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:o.status.message}]}),sd({fetchState:"Error",error:o.status})))),v((o=>p(N({messageSection:"lock_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(o)}]}),sd({fetchState:"Error",error:f("Unexpected Error","Lock cards API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(V$.match),y((t=>{const e=i.value,{scheduleType:a,jeScheduleKey:n}=t.payload,o=[],c=ft(n,e),d=c.jeScheduleId,l=c.vendor.name,u=d!=null?e.scheduleDetailState.editScheduleStateByDetailId[a][d]:e.scheduleDetailState.newScheduleState[a],m={...ec(e,u,n,a,!1,!0)},h={je_schedule_type:a};return(d!=null?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${d}?query=${encodeURIComponent(JSON.stringify(h))}`,m):r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(h))}`,m)).pipe(y((g=>T(g)&&g.data!=null?(o.push(St(g.data.je_schedules,g.data.scheduled_journal_entries,"replace"),sc("Completed"),N({messageSection:"mark_as_complete_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:l}]})),_(o)):(o.push(sc("Error",g.status)),o.push(N({messageSection:"mark_as_complete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]})),_(o)))),v((g=>_([N({messageSection:"mark_as_complete_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(g)}]}),sc("Error",f("Unexpected Error",`Mark As Complete Schedule Detail REST API call errored out ${JSON.stringify(g)}`))]))))}))),(s,i,r)=>s.pipe(S(Mb.match),y((t=>{if(t.payload.isExpenseAutomationEnabled===!0){const e=Be(t.payload.transactionId),a=At(i.value.transactionState,e),n=(t.payload.lineIds?.length??0)>0?t.payload.lineIds:(a?.lines??[]).map((o=>o.id));return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/mark-as-reviewed`,{transactions_reviewed:[{transaction_id:t.payload.transactionId.id,line_ids:n}]}).pipe(y((o=>{if(T(o)){const c=[];c.push(Ka(t.payload.transactionId,"Completed",void 0));const d=t.payload.transactionId.id;if(!(o.data?.transactions_reviewed_failed??[]).some((l=>l.transaction_id===d))){c.push(Vb(e,!1));const{expenseAutomationViewState:l,expenseAutomationTransactionsViewState:u}=i.value,{transactionCategorizationView:m,selectedTransactionCategorizationTab:h}=u,g=H(i.value)?.tenantId,{selectedPeriodByTenantId:I}=l,b=g!=null?I[g]:void 0,E=(m.autoCategorized.transactionReviewLocalDataById[d]?.transactionReviewLocalData.tabSpecificLineItems?.autoCategorized??[]).length>0,{uiState:P}=m[h],O=h==="review"?[d]:E?[]:[d];if(b!=null&&c.push(Ls(h,[d],O,b,"Completed")),E||c.push(zy({transactionIds:[d]})),O.length>0&&b!=null){const C=P.totalCount[Ee(b)]??0,U=Math.max(0,C-1);c.push($s({selectedPeriod:b,selectedTab:h,totalCount:U}))}}return c.push(ol({transactionId:t.payload.transactionId,fetchState:"Completed"})),t.payload.transactionSaveUpdates.anyBulkUpdates===!0?c.push(N({messageSection:"transactionDetails_updatingPastTransactions",messageText:"success",type:"success"})):c.push(N({messageSection:"transactionDetails_transactionUpdated",messageText:"success",type:"success"})),_(c)}return p(Ka(t.payload.transactionId,"Error",o.status))})),v((o=>p(Ka(t.payload.transactionId,"Error",f("Unexpected Error",`Transaction mark as reviewed REST API call errored out ${o}`))))))}return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${t.payload.transactionId.id}/mark-miscategorized-as-correct`,mY(t.payload.transactionId)).pipe(y((e=>{if(M(e)){const a=[];a.push(Ka(t.payload.transactionId,"Completed",void 0));const n=Be(t.payload.transactionId);return a.push(Vb(n,!1)),a.push(ol({transactionId:t.payload.transactionId,fetchState:"Completed"})),t.payload.transactionSaveUpdates.anyBulkUpdates===!0?a.push(N({messageSection:"transactionDetails_updatingPastTransactions",messageText:"success",type:"success"})):a.push(N({messageSection:"transactionDetails_transactionUpdated",messageText:"success",type:"success"})),_(a)}return p(Ka(t.payload.transactionId,"Error",e.status))})),v((e=>p(Ka(t.payload.transactionId,"Error",f("Unexpected Error",`Transaction mark miscategorized as correct REST API call errored out ${e}`))))))}))),(s,i,r)=>s.pipe(S(Hx.match),A((t=>r.postAndGetJSON(`${r.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/feature-interests`,{additional_info:t.payload.additionalInfo,email:t.payload.email,feature:t.payload.feature}).pipe(y((e=>{if(T(e)&&e.data!=null)return _([Qx(e.data)]);const a=e.status??f("Failed to register interest. Please try again.");return _([Qy(a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error registering interest.";return _([Qy(f(a))])})))))),(s,i,r)=>vt(((t,e,a)=>t.pipe(S(ex.match),y((n=>{const o=e.value,{accrualId:c,amount:d}=n.payload,l=tx(ax(c),o.jeSchedulesState),u=o.expenseAutomationJESchedulesViewState.oneTimeAccrualLocalDataById[c],m=u?.jeDebitAccountId??l?.jeDebitAccountId,h=u?.jeCreditAccountId??l?.jeCreditAccountId;if(m==null||h==null)return _(ea("save_schedule",c,"This accrual is missing an expense or liability account."));const g=u?.reverseNextMonth??l?.reversalPolicy==="scheduled_date",I=u?.expectedReversalDate??l?.expectedReversalDate,b=u?.jeDebitAccountingClassId??l?.jeDebitAccountingClassId,E=u?.jeDebitAccountingClassName??l?.jeDebitAccountingClassName,P=u?.jeDebitAccountName??l?.jeDebitAccountName,O=u?.jeCreditAccountName??l?.jeCreditAccountName,C=l?.jeCreditAccountingClassId,U=l?.jeCreditAccountingClassName,B={amount:d,memo:u?.memo??l?.memo??"",je_debit_account_id:m,je_credit_account_id:h,...P!=null?{je_debit_account_name:P}:{},...O!=null?{je_credit_account_name:O}:{},...b!=null?{je_debit_accounting_class_id:b}:{},...E!=null?{je_debit_accounting_class_name:E}:{},...C!=null?{je_credit_accounting_class_id:C}:{},...U!=null?{je_credit_accounting_class_name:U}:{},reverse_next_month:g,...g&&I!=null?{expected_reversal_date:I.format(re)}:{}};return a.putAndGetJSON(`${a.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${c}`,{...B}).pipe(y((x=>T(x)&&x.data!=null?_([Ta([x.data.accrual]),oi({accrualId:c}),rx({accrualId:c}),N({messageSection:"save_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:l?.vendorName??""}]}),...Tl(e.value)]):_(ea("save_schedule",c,x.status.message,x.status)))),v((x=>_(ea("save_schedule",c,`Promote accrual REST API call errored out ${JSON.stringify(x)}`)))),De(t.pipe(S(gt.match))))}))))(s,i,r),((t,e,a)=>t.pipe(S(XC.match),y((n=>{const{accrualId:o,reason:c,note:d}=n.payload,l={reason:c,...d!=null&&d!==""?{note:d}:{}};return a.putAndGetJSON(`${a.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${o}/ignore`,{...l}).pipe(y((u=>T(u)&&u.data!=null?_([Ta([u.data.accrual]),oi({accrualId:o}),N({messageSection:"ignore_accrual",messageText:"success",type:"success"}),...Tl(e.value)]):_(ea("ignore_accrual",o,u.status.message,u.status)))),v((u=>_(ea("ignore_accrual",o,`Ignore accrual REST API call errored out ${JSON.stringify(u)}`)))),De(t.pipe(S(gt.match))))}))))(s,i,r),((t,e,a)=>t.pipe(S(ZC.match),y((n=>{const{accrualId:o,reason:c,note:d}=n.payload,l={reason:c,...d!=null&&d!==""?{note:d}:{}};return a.putAndGetJSON(`${a.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accruals/${o}/revert`,{...l}).pipe(y((u=>T(u)&&u.data!=null?_([Ta([u.data.accrual]),oi({accrualId:o}),N({messageSection:"revert_accrual",messageText:"success",type:"success"}),...Tl(e.value)]):_(ea("revert_accrual",o,u.status.message,u.status)))),v((u=>_(ea("revert_accrual",o,`Revert accrual REST API call errored out ${JSON.stringify(u)}`)))),De(t.pipe(S(gt.match))))}))))(s,i,r)),YG,(s,i)=>s.pipe(S(Nj.match),y((r=>{const t=i.value.transactionListState,e=y0(r.payload.period).filter((a=>r.payload.cacheOverride!==!1||(function(n,o,c,d,l){const u=zb(o,c,d,l),m=n.transactionListByClassKey[u];return m!=null&&(m.fetchState==="In-Progress"||m.hasValidState())})(t.byClass,r.payload.accountId,r.payload.accountType,r.payload.classId,a)===!1));if(e.length>12)return console.error("Only maximum 12 parallel fetch are allowed!"),_([]);{const a=e.map((n=>Gb(r.payload.accountId,r.payload.accountType,r.payload.classId,n,!0)));return _(a)}}))),(s,i)=>s.pipe(S(rE.match),y((r=>{const t=i.value.transactionListState,e=(function(n,o=1){let c=ee(ae(n.start));const d=ee(ae(n.end));c=c.set("date",1);const l=Oj(d,o);c.isBefore(l)&&(c=l);const u=Math.ceil(d.diff(c,"month",!0)),m=[];if(u>=0){let h=c.clone().set("date",1);for(let g=0;g<u-1;++g){const I=h.daysInMonth();m.push({start:{day:1,month:h.month()+1,year:h.year()},end:{day:I,month:h.month()+1,year:h.year()}}),h=h.add(1,"month")}m.push({start:{day:h.date(),month:h.month()+1,year:h.year()},end:{day:d.date(),month:d.month()+1,year:d.year()}})}else console.error(`Invalid time period ${JSON.stringify(n)}`);return m})(r.payload.period,r.payload.fiscalYearStartMonth),a=e.filter((n=>r.payload.cacheOverride!==!1||(function(o,c,d){const l=Hb(c,d),u=o.transactionListByEntityKey[l];return u!=null&&(u.fetchState==="In-Progress"||u.hasValidState())})(t.byEntity,r.payload.entity,n)===!1));if(a.length>12)return console.error("Only maximum 12 parallel fetch are allowed!"),_([]);{const n=a.map((o=>Yb(r.payload.entity,o,!0)));return _(n)}}))),(s,i)=>s.pipe(S(Cj.match),y((r=>{const t=i.value.transactionListState,e=y0(r.payload.period).filter((a=>r.payload.cacheOverride!==!1||(function(n,o,c,d,l){const u=Zb(o,c,d,l),m=n.transactionListByProjectKey[u];return m!=null&&(m.fetchState==="In-Progress"||m.hasValidState())})(t.byProject,r.payload.accountId,r.payload.accountType,r.payload.projectId,a)===!1));if(e.length>12)return console.error("Only maximum 12 parallel fetch are allowed!"),_([]);{const a=e.map((n=>Wb(r.payload.accountId,r.payload.accountType,r.payload.projectId,n,!0)));return _(a)}}))),(s,i)=>s.pipe(S(xj.match),y((r=>{const{transactionCategoryType:t,minimumTransactionAmount:e}=r.payload,a=i.value.transactionListState,n=Uj(r.payload.period).filter((o=>r.payload.cacheOverride!==!1||(function(c,d,l){const u=tE(l,d),m=c.transactionListByCategoryType[u];return m!=null&&(m.fetchState==="In-Progress"||m.hasValidState())})(a.byType[t],o,t)===!1));if(n.length>12)return console.error("Only maximum 12 parallel fetch are allowed!"),_([]);{const o=n.map((c=>eE(!0,t,c,e)));return _(o)}}))),(s,i,r)=>s.pipe(S(tC.match),A((t=>{const{accountId:e,selectedPeriod:a,combinedStatementGroupId:n}=t.payload,o=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/combined-statement-groups/${n}`;return r.getJSON(o).pipe(y((c=>T(c)===!0&&c.data!=null?_([Cs({accountId:e,selectedPeriod:a,parsedStatementData:aC(c.data)}),ty({accountId:e,selectedPeriod:a})]):p(xs({accountId:e,selectedPeriod:a,error:c.status})))),v((c=>p(xs({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Parse Combined Statement REST API call errored out "+(c instanceof Error?c.message:String(c)))})))))}))),(s,i)=>s.pipe(S(Oc.match),y((r=>{const{invoiceProcessingPayload:t,isVendorRecommendationFeatureEnabled:e,billId:a}=r.payload,n=i.value,o=a!=null?Ne(a):null,c=o!=null?n.editBillDetailViewState.editBillStateById[o]:null,d=c?.showSkipAutofill??n.editBillDetailViewState.newBillState.showSkipAutofill,l=c?.replaceBillData??n.editBillDetailViewState.newBillState.replaceBillData;if(d||l){let u=Uc.billDetailLocalData.vendor,m=!1;const h=t.vendors.length>0?t.vendors[0].vendor_name??"":void 0,g=t.bills.length>0?t.bills[0].currency_code:"USD";let I="";const b=Nc(n).vendors;let E,P,O=!1;if(h!=null&&h.length>0&&(u=b.filter((x=>x.name.toLowerCase()===h.toLowerCase()))[0],u==null)){const x=c?.suggestedVendorIdFromParsedInvoice??n.editBillDetailViewState.newBillState.suggestedVendorIdFromParsedInvoice;if(x!=null){P=Oe(n.vendorState,x);const k=P?.matchScore??0;I=P?.vendorCurrencyCode??"USD",e?P?.name.toLowerCase()===h.toLowerCase()?I===g?(u=P,O=!0,E=P?.id):m=!0:(E=P?.id,u=P,O=!0):k>85&&(I===g?(u=P,O=!0):m=!0)}}const C=Sn(t.files[0]),U={...wK(n,O,t.bills[0],u,E),file:C},B=$K(U,m,h,g,I);if(u!=null){let x=[];return u.vendorCurrencyCode!=null&&u.vendorCurrencyCode!=="USD"&&x.push(ya(!0,{amount:U.recipientTotalAmount?.amount??0,currencyCode:u.vendorCurrencyCode,currencySymbol:u.vendorCurrencySymbol},"USD")),x=[...x,lt({billDetailLocalData:U,billId:a}),aa(u.qboId,!1),_c(u.name,u.id,U.totalAmount?.amount??0,U.recipientTotalAmount?.amount??0,U.whatForSection?.invoiceNumber),Ac(!1),Ss({addBillAutoFields:B,billId:a}),xc({fetchState:{fetchState:"Completed",error:void 0},billId:a})],_(x)}{const x=[lt({billDetailLocalData:U,billId:a}),Ac(!1),Ss({addBillAutoFields:B,billId:a}),xc({fetchState:{fetchState:"Completed",error:void 0},billId:a})];return E!=null&&P!=null&&x.push(aa(P.qboId,!1)),_(x)}}{const u=Sn(t.files[0]);return p(lt({billDetailLocalData:{...Uc.billDetailLocalData,file:u},billId:a}),Ss({addBillAutoFields:Uc.addBillAutoFields,billId:a}),xc({fetchState:{fetchState:"Completed",error:void 0},billId:a}))}}))),(s,i)=>s.pipe(S(AL.match),y((r=>{const{receiptsProcessingPayload:t,lineId:e,reimbursementId:a,shouldOverwrite:n,signedInUserId:o}=r.payload,c=i.value,d=a!=null?c.editRemiDetailViewState.editRemiStateById[a]:c.editRemiDetailViewState.newRemiState,l=H(c).accountingClassIDs?.[0],u={...d.remiDetailLocalData.updatesByLineId};if(n===!1){let m=e;t.receipts.forEach((g=>{u[m]={...u[m],type:"out_of_pocket",fileId:g.file_id??"",lineId:String(m)},m++}));const h=t.files.map((g=>Sn(g)));return p(vd({remiDetailLocalData:{...d.remiDetailLocalData,files:d.remiDetailLocalData.files!=null?[...d.remiDetailLocalData.files,...h]:h,updatesByLineId:u},reimbursementId:a}),lI({reimbursementId:a,fetchState:"Completed"}))}{const m=[],h=[],g={};t.merchants.forEach((C=>{C.merchant_id&&(g[C.merchant_id]=NL(C))}));const I={},b={};let E=e;const P=OL(c.merchantState,c.merchantListState.merchantIds);t.receipts.forEach((C=>{const U=C.merchant_id,B=g[U],x=B?.name;let k;x!=null&&x.length>0&&(k=P.filter((L=>L.name.toLowerCase()===x.toLowerCase()))[0]),u[E]={lineId:String(E),type:"out_of_pocket",fileId:C.file_id??"",homeCurrencyConversions:{amount:C.amount,currencyCode:C.currency_code??"USD",currencySymbol:C.currency_symbol??"$"},outOfPocket:{...GK(c.accountState,c.classState,C,k,l)},mileage:{}},C.currency_code!=="USD"&&h.push(cI("USD",E.toString(),a)),I[E]=zK(u[E]);const J=KK(u[E],x);J!=null&&J!==""&&(b[E]=J),k!=null?m.push(hd(!1,E.toString(),a,k.id,void 0)):m.push(hd(!1,E.toString(),a,void 0,b[E])),E++}));const O=t.files.map((C=>Sn(C)));return m.push(vd({remiDetailLocalData:{...d.remiDetailLocalData,files:d.remiDetailLocalData.files!=null?[...d.remiDetailLocalData.files,...O]:O,updatesByLineId:u},reimbursementId:a}),CL({reimbursementId:a,addRemiAutoFields:I}),xL({reimbursementId:a,tentativeMerchantNameByLineId:b}),...h,lI({reimbursementId:a,fetchState:"Completed"})),o!=null&&m.push(Id(o,!0,a)),_(m)}}))),(s,i,r)=>s.pipe(S(rC.match),A((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n}=t.payload,o=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/${n}`;return r.getJSON(o).pipe(y((c=>T(c)===!0&&c.data!=null?_([Cs({accountId:e,selectedPeriod:a,parsedStatementData:sC(c.data)}),ty({accountId:e,selectedPeriod:a})]):p(xs({accountId:e,selectedPeriod:a,error:c.status})))),v((c=>p(xs({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Parse Statement REST API call errored out "+(c instanceof Error?c.message:String(c)))})))))}))),(s,i,r)=>s.pipe(S(YV.match),y((t=>{const{target:e,companyId:a,fileId:n,documentType:o}=t.payload,c=`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/documents/process/sync`,d={provided_document_type:o,files:[{file_id:n}],processing_priority:10,metadata:{source:"kyc_kyb_autofill"}},l=HV({target:e,fileId:n});return r.postAndGetJSON(c,d).pipe(y((u=>{if(!T(u)||u.data==null)return p(l);const m=u.data.files?.[0]?.extracted_data;if(m==null)return p(l);let h;switch(o){case"certificate_of_incorporation":h=(I=>{const b={values:{},autoFilledFieldNames:[]};if(ne(I.company_legal_name)&&ce(b,"companyLegalName",I.company_legal_name.value),ne(I.ein)&&ce(b,"taxIdOrEIN",I.ein.value),ne(I.phone_number)&&ce(b,"phone",I.phone_number.value),ne(I.product_description)&&ce(b,"companyDescription",I.product_description.value),ne(I.website))try{ce(b,"website",zV(I.website.value))}catch{}if(ne(I.industry)&&ce(b,"companyIndustryType",I.industry.value),ne(I.sub_industry)&&ce(b,"companySubIndustry",I.sub_industry.value),ne(I.type_of_incorporation)&&ce(b,"typeOfIncorporation",I.type_of_incorporation.value),ne(I.date_of_incorporation)){const E=Dl(I.date_of_incorporation.value);E!=null&&ce(b,"incDate",E)}return ne(I.state_of_incorporation)&&ce(b,"stateOfIncorporation",I.state_of_incorporation.value),ne(I.countries_of_operations)&&ce(b,"countriesOfOperations",I.countries_of_operations.value),ne(I.source_of_funds)&&ce(b,"sourceOfFunds",I.source_of_funds.value),ne(I.transaction_volume_expectations)&&ce(b,"transactionVolume",I.transaction_volume_expectations.value),ne(I.purpose_of_account)&&ce(b,"purposeOfAccount",I.purpose_of_account.value),ne(I.regulated_status)&&ce(b,"regulatedStatus",I.regulated_status.value),ne(I.us_nexus)&&ce(b,"usNexus",I.us_nexus.value),b})(m);break;case"tax_ein":h=(I=>{const b={values:{},autoFilledFieldNames:[]};return ne(I.legal_business_name)&&ce(b,"companyLegalName",I.legal_business_name.value),ne(I.ein)&&ce(b,"taxIdOrEIN",I.ein.value),b})(m)}if(h.autoFilledFieldNames.length===0)return p(l);const g=e==="setup"?QV({companyId:a,fileId:n,values:h.values,autoFilledFieldNames:h.autoFilledFieldNames}):WV({companyId:a,fileId:n,values:h.values,autoFilledFieldNames:h.autoFilledFieldNames});return p(g)})),v((()=>p(l))))}))),(s,i,r)=>s.pipe(S(ZV.match),y((t=>{const{target:e,companyId:a,officerType:n,fileId:o,documentType:c}=t.payload,d=`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/documents/process/sync`,l={provided_document_type:c,files:[{file_id:o}],processing_priority:10,metadata:{source:"kyc_kyb_autofill"}},u=XV({target:e,fileId:o});return r.postAndGetJSON(d,l).pipe(y((m=>{if(!T(m)||m.data==null)return p(u);const h=m.data.files?.[0]?.extracted_data;if(h==null)return p(u);let g;switch(c){case"passport":g=(b=>{const E={values:{},autoFilledFieldNames:[]};if(ne(b.first_name)&&ce(E,"firstName",b.first_name.value),ne(b.last_name)&&ce(E,"lastName",b.last_name.value),ne(b.date_of_birth)){const P=Dl(b.date_of_birth.value);P!=null&&ce(E,"birthday",P)}return ne(b.nationality)&&ce(E,"nationalityCountryCode",b.nationality.value),E})(h);break;case"driving_license":g=(b=>{const E={values:{},autoFilledFieldNames:[]};if(ne(b.first_name)&&ce(E,"firstName",b.first_name.value),ne(b.last_name)&&ce(E,"lastName",b.last_name.value),ne(b.date_of_birth)){const B=Dl(b.date_of_birth.value);B!=null&&ce(E,"birthday",B)}const P=ne(b.address_street)?b.address_street.value.trim():void 0,O=ne(b.address_city)?b.address_city.value.trim():void 0,C=ne(b.address_state)?b.address_state.value.trim():void 0,U=ne(b.address_zip)?b.address_zip.value.trim():void 0;return P==null&&O==null&&C==null&&U==null||(E.address={street:P!=null?[P]:[],city:O??"",state:C??"",postalCode:U??"",country:"USA",countryCode:"US"},E.autoFilledFieldNames.push("officerAddress")),E})(h);break;case"social_security_card":g=(b=>{const E={values:{},autoFilledFieldNames:[]};if(ne(b.full_name)){const{firstName:P,lastName:O}=(C=>{const U=C.trim().split(/\s+/);if(U.length===1)return{firstName:U[0],lastName:""};const B=U[U.length-1];return{firstName:U.slice(0,-1).join(" "),lastName:B}})(b.full_name.value);P!==""&&ce(E,"firstName",P),O!==""&&ce(E,"lastName",O)}return E})(h)}if(g.autoFilledFieldNames.length===0)return p(u);const I=[e==="setup"?eL({companyId:a,officerType:n,fileId:o,values:g.values,autoFilledFieldNames:g.autoFilledFieldNames}):tL({companyId:a,officerType:n,fileId:o,values:g.values,autoFilledFieldNames:g.autoFilledFieldNames})];if(g.address!=null){const b=`${n.toLowerCase()}_address`;I.push(qe({addressType:b,addressToCreate:g.address}))}return _(I)})),v((()=>p(u))))}))),(s,i,r)=>s.pipe(S(nw.match),y((t=>{const{localData:e,person:a}=i.value.peopleState.personDetails,{userRole:n}=a,{isZeniTenant:o}=t.payload,c=H(i.value),d=fK(e[0],o,a,c.company);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user-roles/${n.userRoleId}`,d).pipe(y((l=>{if(T(l)&&l.data!=null){const u=[Y(l.data?.user_roles??[]),ow(),N({messageSection:"people_update_person",messageText:"success",type:"success"})];return l.data?.user_roles&&Vn(u,l.data?.user_roles[0]),_(u)}{const u=[pg(l.status)];return _(u)}})),v((l=>p(pg(f("Unexpected error","User Roles save updates errored out"+JSON.stringify(l)))))))}))),(s,i)=>s.pipe(S(no.match),y((r=>{const t=i.value.cardPolicyState.policyDocumentExtraction,e=t.aiCfoAnswerId,a=t.aiCfoChatSessionId,n=t.extractedRules;return e==null||a==null||n==null?F:p(Ql(e,a,n))}))),(s,i,r)=>s.pipe(S(Ql.match),A((t=>{const{answerId:e,chatSessionId:a,extractedRules:n}=t.payload,o={extracted_rules:{allowed_entity:{category_codes:n.allowedEntity.categoryCodes,merchant_names:n.allowedEntity.merchantNames},blocked_entity:{category_codes:n.blockedEntity.categoryCodes,merchant_names:n.blockedEntity.merchantNames},confidence_score:n.confidenceScore,policy_name:n.policyName,required_receipt_threshold:n.requiredReceiptThreshold,transaction_limit:n.transactionLimit}};return r.postAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/ai-cfo/policy-recommendation-from-upload`,o).pipe(y((c=>{if(!M(c)||c.data?.wizard_plan?.step_5_review==null)return p(Wl(c.status));const d=c.data,l=d.wizard_plan.step_5_review,u={step5Review:{draftPolicies:(l.draft_policies??[]).map(((h,g)=>({id:`draft-${g}`,name:h.name,description:h.description??"",mode:h.mode,allowedEntity:{categoryCodes:h.allowed_entity?.category_codes??[],merchantNames:h.allowed_entity?.merchant_names??[]},blockedEntity:{categoryCodes:h.blocked_entity?.category_codes??[],merchantNames:h.blocked_entity?.merchant_names??[]},applyToCards:h.apply_to_cards??[],requiredReceiptThreshold:h.required_receipt_threshold??0,spendLimits:{transaction:h.spend_limits?.transaction??0}}))),groupingSource:l.grouping_source??"none",prompt:l.prompt??""}},m=d.source!=null?{confidenceScore:d.source.confidence_score,fileName:d.source.file_name,lowConfidenceFields:d.source.low_confidence_fields??[]}:void 0;return p(yP(),mP({answerId:e,chatSessionId:a,wizardPlan:u,source:m}),pP(u,m))})),v((c=>p(Wl(f("Unexpected Error","Policy recommendation from upload REST API call errored out"+JSON.stringify(c)))))),De(s.pipe(S(Kl.match))))}))),(s,i,r)=>s.pipe(S((t=>Er.match(t)||Na.match(t))),y((t=>{const{batchId:e}=t.payload;let a=!1;const n=Na.match(t)?5e3:3e4;return Ha(n,1e4).pipe(De(vt(s.pipe(S(Ds.match)),s.pipe(S(pi.match),S((o=>o.payload.batchId===e&&o.payload.status==="completed"))),s.pipe(S(Aa.match),S((o=>o.payload.batchId===e))),s.pipe(S(Ry.match),S((o=>o.payload.batchId===e))))),A((()=>r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${e}`).pipe(y((o=>{if(T(o)&&o.data!=null&&zn(o.data.status)){const c=[],d=Kn(o.data.files);return d.length>0&&c.push(Ce(d,(l=>l.transaction_id))),c.push(Aa(Yn(o.data,r.apiEndPoints.fileMicroServiceBaseUrl))),c.push(Pr({cacheOverride:!0})),_(c)}return F})),v((()=>a?F:(a=!0,p(N({messageSection:"receipts_upload",messageText:"failed",type:"error"})))))))))}))),(s,i)=>s.pipe(S(Pa.match),y((r=>{const t=i.value,{period:e}=r.payload,{selectedPageTab:a}=t.expenseAutomationJESchedulesViewState.uiState,n=nx.find((l=>l!==a));if(n==null)return F;const o=H(t),c=t.expenseAutomationViewState.selectedPeriodByTenantId[o.tenantId];if(c==null)return F;const d=cy(n,Ee(c));return t.expenseAutomationJESchedulesViewState.jeScheduleTransactionKeysByPeriodAndTab[d]!=null?F:p(Qa(e,!0,n))}))),s=>s.pipe(S(pi.match),S((i=>i.payload.status==="completed")),si(300),y((i=>_([Pr({cacheOverride:!0}),wy({batchId:i.payload.batchId})])))),HG,(s,i,r)=>s.pipe(S(XB.match),y((t=>{const e=i.value.invoicingRecordPaymentState.newPaymentDraft,a=t.payload.invoiceId;if(a!=null&&a!==""){const u=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(a)}/record-payment`,m=eD(e);return r.postAndGetJSON(u,m).pipe(y((h=>T(h)&&h.data!=null?[Ca([h.data],"merge"),Br({invoiceId:a}),Zh({invoiceId:a}),N({messageSection:"invoicing_payment_recorded",messageText:"success",type:"success"})]:_([Xs(h.status),N({messageSection:"invoicing_payment_recorded",messageText:"failed",type:"error",variables:Ie(h.status)})]))),v((h=>_([Xs(f("Unexpected Error","Record payment REST API call errored out "+JSON.stringify(h))),N({messageSection:"invoicing_payment_recorded",messageText:"failed",type:"error"})]))))}const n=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/payments`,o=tD(e),c=(d=i.value,(l=d.invoicingRecordPaymentState.newPaymentDraft.invoiceToLink).trim()!==""?l.trim():void 0);var d,l;return r.postAndGetJSON(n,{...o}).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[Zs([u.data],"merge"),aD(u.data.id),Zh({transactionId:u.data.id})];return c!=null&&m.push(Br({invoiceId:c})),m.push(N({messageSection:"invoicing_payment_recorded",messageText:"success",type:"success"})),m}return _([Xs(u.status),N({messageSection:"invoicing_payment_recorded",messageText:"failed",type:"error",variables:Ie(u.status)})])})),v((u=>_([Xs(f("Unexpected Error","Record payment REST API call errored out "+JSON.stringify(u))),N({messageSection:"invoicing_payment_recorded",messageText:"failed",type:"error"})]))))}))),s=>s.pipe(S((i=>Tx.match(i)||Ax.match(i))),y((()=>p(Tr(void 0,!0))))),(s,i,r)=>s.pipe(S(wy.match),y((t=>{const{batchId:e}=t.payload,a=Date.now(),n=i.value.expenseAutomationMissingReceiptsViewState.bulkUpload.lastBatchDetailRefreshAtById[e];if(n!=null&&a-n<5e3)return F;const o=r.getJSON(`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/${e}`).pipe(y((c=>{if(!T(c)||c.data==null||!zn(c.data.status))return F;const d=[],l=Kn(c.data.files);return l.length>0&&d.push(Ce(l,(u=>u.transaction_id))),d.push(Gn(Yn(c.data,r.apiEndPoints.fileMicroServiceBaseUrl))),_(d)})),v((c=>(console.error(`Failed to refresh batch details for ${e}:`,f("Unexpected Error","Refresh batch details errored out: "+JSON.stringify(c))),p(S0({batchId:e}))))));return j(p(Nx({batchId:e,timestamp:a})),o)}))),(s,i)=>s.pipe(S(EC.match),A((()=>{const r=i.value,t=H(r),e=t.companyId,{selectedTransactionCategorizationTab:a}=r.expenseAutomationTransactionsViewState,{selectedPeriodByTenantId:n,currentSelectedView:o}=r.expenseAutomationViewState,c=n[t.tenantId],{selectedAccountId:d}=r.expenseAutomationReconciliationViewState,l=Re(c),u=ge(l.start),m=ge(l.end);if(u==null||m==null||e==null)throw Error(`Invalid start - ${u} and end - ${m} period from given ${c}`);switch(o){case"missing_receipts":return _([vr({start:u,end:m},{amount:75,currencyCode:"USD",currencySymbol:"$"},!0,!0)]);case"flux_analysis":return _([ks(c,!0,!0,null)]);case"je_schedules":return _([Pa({start:u,end:m},!0)]);case"month_end_insights":return _([Kp(!0,e,t.tenantId,l.end,!0),Gp(e,t.tenantId)]);case"reconciliation":return _(d!=null?[Rt(c,d,!0,!0)]:[Rt(c,void 0,!0,!0)]);default:return _([fr(a,{start:u,end:m},!0,!1,void 0,void 0,!0,void 0)])}}))),(s,i,r)=>s.pipe(S(cR.match),A((()=>{const t=[];return r.getJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/settings/refresh-all-entities`).pipe(qu(3e3),y((e=>T(e)&&e.data!=null?(t.push(N({messageSection:"data_refresh_update",messageText:"success",type:"success"}),dR()),_(t)):(t.push(hf()),_(t)))),v((()=>(t.push(hf()),_(t)))))}))),(s,i,r)=>s.pipe(S(VJ.match),A((()=>r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/operating-expenses-by-vendor/refresh`).pipe(y((t=>{if(t.status.code>=200&&t.status.code<300){const e=t.status.last_refresh_success_time!=null?ee(t.status.last_refresh_success_time):void 0;return p(LJ({lastRefreshSuccessTime:e}))}return p(ag(t.status))})),v((t=>p(ag(f("Unexpected error","Refresh OpEx by Vendor REST API call errored out: "+JSON.stringify(t)))))))))),(s,i,r)=>s.pipe(S(_G.match),y((t=>{const{merchantId:e}=t.payload,{globalMerchantState:a,vendorGlobalReviewViewState:n}=i.value,{vendorGlobalByMerchantId:o}=n,c=o[e].vendorGlobalReviewViewLocalData,d=yE(a,_E(c.tenantId,e));if(c!=null&&d!=null){const l=Array({globalMerchants:Qn(a,c.recommendationIds)}),u=Array({globalMerchants:c.recommendedNonExistingGlobalMerchants}),m=Xn(l,u),h={...kY(d,m)};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/reviews/global-merchant-list/${e}`,h).pipe(y((g=>{if(M(g)){const I=[{variableName:"_merchant_name_",variableValue:d.tenantMerchantName}],b=[hG(e),N({messageSection:"reject_global_merchant",messageText:"success",type:"success",variables:I})];return _(b)}return g.status.code===409?p(yl({merchantId:e,status:g.status})):p(yl({merchantId:e,status:g.status}),N({messageSection:"reject_global_merchant",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]}))})),v((g=>p(yl({merchantId:e,status:f("Unexpected Error","Reject Vendor Global Review REST API call errored out"+JSON.stringify(g))})))))}return p([])}))),(s,i,r)=>s.pipe(S(zR.match),A((t=>{const{approvalRuleIds:e,useV3:a}=t.payload,n=`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2/reorder`;return r.putAndGetJSON(n,{rule_ids:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.approval_rules.map((l=>l.approval_rule_id)),d=[We(o.data.approval_rules),KR(c),N({messageSection:"bill_pay_approval_reorder",messageText:"success",type:"success"})];return _(d)}{const c=[Zf(o.status),N({messageSection:"bill_pay_approval_reorder",messageText:"failed",type:"error"}),vc(!0,!0,a)];return _(c)}})),v((o=>_([Zf(f("Unexpected Error","Reorder Bill Pay Approval Rules errored out"+JSON.stringify(o))),N({messageSection:"bill_pay_approval_reorder",messageText:"failed",type:"error"}),vc(!0,!0,a)]))))}))),(s,i,r)=>s.pipe(S(WL.match),A((t=>{const{approvalRuleIds:e,useV3:a}=t.payload,n=`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2/reorder`;return r.putAndGetJSON(n,{rule_ids:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.approval_rules.map((l=>l.approval_rule_id)),d=[We(o.data.approval_rules),ZL(c),N({messageSection:"reimbursement_approval_reorder",messageText:"success",type:"success"})];return _(d)}return _([TI(o.status),N({messageSection:"reimbursement_approval_reorder",messageText:"failed",type:"error"}),Od(!0,!1,!1,a)])})),v((o=>_([TI(f("Unexpected Error","Reorder Reimbursement Approval Rules errored out"+JSON.stringify(o))),N({messageSection:"reimbursement_approval_reorder",messageText:"failed",type:"error"}),Od(!0,!1,!1,a)]))))}))),(s,i,r)=>s.pipe(S(nC.match),A((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n}=t.payload;return r.postAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements/${n}/reparse`).pipe(y((o=>{if(T(o)===!0&&o.data!=null){const c=ba(e,a);return _([oC(c,o.data),iC({accountId:e,selectedPeriod:a})])}return p(ay({accountId:e,selectedPeriod:a,error:o.status}))})),v((o=>p(ay({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Reparse Statement REST API call errored out "+(o instanceof Error?o.message:String(o)))})))))}))),(s,i,r)=>s.pipe(S(s$.match),y((t=>{const{reportIdToResync:e}=t.payload,a=n$(e)||o$(e),n=a?"generate-group-by-project-reports":"generate-group-by-class-reports";return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/2.0/tasks/${n}`,{is_hard_refresh:!0}).pipe(A((o=>{if(T(o)){const c=[a?Lg({reportIdToResync:e}):Mg({reportIdToResync:e}),i$({hasNewData:o.status.code===200})];return _(c)}return _([qg({error:o.status}),N({messageSection:"reports_resync",messageText:"failed",type:"error"})])})),v((o=>_([qg({error:f("Unexpected error","Resync API call errored out: "+JSON.stringify(o))}),N({messageSection:"reports_resync",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(dV.match),A((t=>{const{cardId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/resend-reminder`,{card_issuance_request:!0}).pipe(y((a=>M(a)?p(st(a.data),lV({cardId:t.payload.cardId}),N({messageSection:"charge_card_resend_invite",messageText:"success",type:"success"})):p(Mv(a.status)))),v((a=>p(Mv(f("Unexpected Error","Resend Charge Card REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(cw.match),y((t=>r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/invites`,{is_reinvited:!0,user_id:t.payload.userId}).pipe(y((e=>T(e)?p(Y([e.data]),dw(t.payload.userId),N({messageSection:"people_invite_people",messageText:"success",type:"success"})):p(mg(t.payload.userId)))),v((()=>p(mg(t.payload.userId)))))))),QG,(s,i,r)=>s.pipe(S(Tw.match),A((t=>r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referrals`,{reinvite_to:t.payload.emailId}).pipe(y((e=>M(e)&&e.data!=null?[Aw({emailId:t.payload.emailId,timestamp:e.data.last_invite_timestamp}),N({messageSection:"referral_invite_sent",messageText:"success",type:"success"})]:p(on(e.status)))),v((e=>p(on(f("Unexpected error","Resend referral REST API call errored out"+JSON.stringify(e)))))))))),WG,(s,i,r)=>s.pipe(S(VA.match),y((t=>{const e=[];if(t.payload.vendorId!=null){const a=Oe(i.value.vendorState,t.payload.vendorId);a!=null&&e.push(ls({vendorId:t.payload.vendorId,localData:bE(a)}))}else e.push(ls({localData:{},vendorId:void 0}));return _(e)}))),(s,i,r)=>s.pipe(S(xp.match),y((t=>{const e=[];if(t.payload.vendorId!=null){const a=Oe(i.value.vendorState,t.payload.vendorId);a!=null&&e.push(nr({vendorId:t.payload.vendorId,localData:wn(a,i.value)}))}else e.push(nr({localData:void 0,vendorId:void 0}));return _(e)}))),(s,i,r)=>s.pipe(S(wp.match),y((t=>{const e=[],a=Oe(i.value.vendorState,t.payload.vendorId);return a!=null&&e.push(Dp({vendorId:t.payload.vendorId,localData:Jp(a,i.value)})),_(e)}))),(s,i,r)=>s.pipe(S(Ox.match),y((()=>{const t=i.value,{expenseAutomationMissingReceiptsViewState:{bulkUpload:e},expenseAutomationViewState:{selectedPeriodByTenantId:a}}=t;if(e.phase!=="idle")return F;if(e.batchListFetchState.fetchState==="In-Progress")return F;const n=t.tenantState.loggedInUser?.userId;if(n==null)return F;const o=a[H(t).tenantId];if(o==null)return F;const{end:c,start:d}=Al(xy),l={start_date:d,end_date:c,sort_order:"desc"},u=`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches?query=${encodeURIComponent(JSON.stringify(l))}`,m=`${r.apiEndPoints.communicationAgentMicroServiceBaseUrl}/1.0/batches/`,h=Ee(o),g=(e.batchListByPeriod[h]??[]).length>0&&e.batchListFetchState.fetchState==="Completed";return(g?p(null):r.getJSON(u).pipe(v((()=>p(null))))).pipe(y((I=>{const b=g?e.batchListByPeriod[h]??[]:I!=null&&T(I)&&I.data!=null?I.data.batches.map(Uy):null;if(b==null)return F;const E=g?null:Js({batchList:b,selectedPeriod:o}),P=b.filter((C=>{const U=C.status.toLowerCase();return U==="processing"||U==="pending"})),O=_(P).pipe(Oa((C=>r.getJSON(`${m}${C.batchId}`).pipe(y((U=>{if(!T(U)||U.data==null)return F;const B=U.data,x=B.user_id;return x==null||x!==n?F:Cx(B.status)?p(Na({batchId:C.batchId,totalFiles:C.totalFiles})):F})),v((()=>F))))),Ue(1));return E!=null?j(p(E),O):O})))}))),(s,i,r)=>s.pipe(S(ym.match),A((t=>{const{companyId:e}=t.payload,a=cr(i.value.tenantState,e);return a==null?_([yt({status:f("Unexpected error","Tenant not found for company")}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})]):r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounting_provider_project_enablement_status`).pipe(y((n=>T(n)&&n.data!=null?n.data.is_accounting_provider_project_apis_enabled!==!0||n.data.is_accounting_projects_enabled!==!0?_([yt({status:f("Projects not enabled in QBO","Please enable projects in QBO before enabling in the Zeni dashboard!")}),N({messageSection:"accounting_projects_qbo_not_enabled",messageText:"failed",type:"error"})]):_([pm({enabled:!0,tenantId:a}),mm(),N({messageSection:"accounting_projects_enabled_update",messageText:"success",type:"success"})]):_([yt({status:n.status}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})]))),v((n=>p(yt({status:f("Unexpected error",`Accounting provider project enablement status errored out - ${n instanceof Error?n.message:JSON.stringify(n)}`)}),N({messageSection:"accounting_projects_enabled_update",messageText:"failed",type:"error"})))))}))),(s,i,r)=>s.pipe(S(m$.match),y((t=>{const{companyId:e}=t.payload,a=i.value,n=Te(a.companyState,e),o=n?.company.companyInfo.tenantId,c={company_id:e,type:"direct_debit",payment_source_type:"processor_token"};return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/payment-sources`,c,Object.assign({"zeni-tenant-id":o})).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(y$({companyId:e,onboardingInfo:d.data.companies[0].onboarding_info})),d.data.companies[0].onboarding_info?.is_zeni_subscriptions_payment_account_linked!==!1?l.push(N({messageSection:"retry_bank_account_connection",messageText:"success",type:"success"})):l.push(N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error"})),_(l)}return p(Qg({companyId:e,error:d.status}),N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(Qg({companyId:e,error:f("Unexpected error","Bank account connection errored out"+JSON.stringify(d))}),N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"Bank account connection errored out"+JSON.stringify(d)}]})))))}))),(s,i,r)=>s.pipe(S(MD.match),y((t=>{const{companyId:e}=t.payload,a=i.value,n=Mi(a.companyState,e),o=n?.company.companyInfo.tenantId,c={company_id:e,type:"direct_debit",payment_source_type:"processor_token"};return o!=null?r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/payment-sources`,c,Object.assign({"zeni-tenant-id":o})).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(VD({companyId:e})),d.data.companies[0].onboarding_info?.is_zeni_subscriptions_payment_account_linked!==!1?l.push(N({messageSection:"retry_bank_account_connection",messageText:"success",type:"success"}),LD({companyId:e,onboardingInfo:d.data.companies[0].onboarding_info})):l.push(N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error"})),_(l)}return p(AS({companyId:e,error:d.status}),N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(AS({companyId:e,error:f("Unexpected error","Bank account connection for onboarding errored out"+JSON.stringify(d))}),N({messageSection:"retry_bank_account_connection",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"Bank account connection for onboarding errored out"+JSON.stringify(d)}]}))))):_([])}))),(s,i,r)=>s.pipe(S(ox.match),A((t=>{const e=i.value,{expenseAutomationJESchedulesViewState:{jeScheduleLocalDataById:a},expenseAutomationViewState:{selectedPeriodByTenantId:n}}=e,o=H(e),c=n[o.tenantId],{scheduledJournalEntryID:d,jeScheduleTransactionKey:l}=t.payload,u=a[d];if(u==null)return _([]);const m={...Gz(u)};return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/retry_sje_posting`,m).pipe(y((h=>{if(M(h)){const g=[];return g.push(ix({scheduledJournalEntryID:d}),cx(l,c),dx({scheduledJournalEntryID:d}),et({tenantId:o.tenantId,period:c,refreshViewInBackground:!0}),N({messageSection:"je_posted",messageText:"success",type:"success"})),_(g)}{const g=[];return g.push(Ay({status:h.status,scheduledJournalEntryID:d})),g.push(N({messageSection:"je_posted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:h.status.message}]})),_(g)}})),v((h=>{const g=[];return g.push(Ay({status:f("Unexpected Error","retry JE schedule posting REST API call errored out"+JSON.stringify(h)),scheduledJournalEntryID:d})),g.push(N({messageSection:"je_posted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(h)}]})),_(g)})))}))),(s,i,r)=>s.pipe(S(wB.match),y((t=>{const{taskId:e}=t.payload,a=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/sync-tasks/${encodeURIComponent(e)}/retry`;return r.postAndGetJSON(a,{}).pipe(y((n=>T(n)?p($B({status:n.data?.status??"",taskId:n.data?.task_id??e}),xi(),N({messageSection:"invoicing_qbo_sync_health_retry",messageText:"success",type:"success"})):_([Fh({status:n.status,taskId:e}),N({messageSection:"invoicing_qbo_sync_health_retry",messageText:"failed",type:"error",variables:Ie(n.status)})]))),v((n=>_([Fh({status:f("Unexpected Error","Retry QBO sync task REST API call errored out "+JSON.stringify(n)),taskId:e}),N({messageSection:"invoicing_qbo_sync_health_retry",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(JR.match),y((t=>{const{billId:e,actionType:a}=t.payload,{editBillDetailViewState:n}=i.value,o=Ne(e),c=n.editBillStateById[o];let d,l=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions/${e}`;if(a==="retry"){const u=c.billDetailLocalData.paymentDetailsSection;l=`${l}/payment/retry`,d=c.billDetailLocalData.isCollectToAccountInfoFromVendorContact?{bill_pay_info:{to_account_vendor_email:c.billDetailLocalData.toAccountVendorEmail??null,is_collect_to_account_info_from_vendor_contact:c.billDetailLocalData.isCollectToAccountInfoFromVendorContact}}:{bill_pay_provider:"zeni",bill_pay_info:{payment_date:u?.paymentDate??null,to_account:u?.paymentType?.method.includes("international")===!0?{payment_instrument_id:u?.paymentTo??null}:{account_id:u?.paymentTo??null},from_account:{account_id:u?.withdrawFrom?.id??null,account_type:u?.withdrawFrom?.accType?Me(La(u?.withdrawFrom?.accType)):null}}}}else l=`${l}/payment/refund`;return r.putAndGetJSON(l,d).pipe(y((u=>{if(T(u)){const m=[];return u.data!=null&&u.data.transactions[0]?.transaction_id!=null&&m.push(mn(u.data.transactions[0])),m.push(wR(t.payload.billId,t.payload.actionType)),m.push(N({messageSection:t.payload.actionType==="refund"?"bill_pay_refund":"bill_pay_retry",messageText:"success",type:"success"})),_(m)}return p(wf(e,t.payload.actionType,u.status),N({messageSection:"bill_pay_cancelled_deleted",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:u.status.message}]}))})),v((u=>p(wf(t.payload.billId,t.payload.actionType,f("Unexpected Error","Retry Refund bill REST API call errored out "+JSON.stringify(u)))))))}))),(s,i,r)=>s.pipe(S(lx.match),y((t=>{const e=i.value,{expenseAutomationViewState:{selectedPeriodByTenantId:a}}=e,{jeScheduleId:n,jeScheduleTransactionKey:o,reason:c,note:d,scheduleType:l}=t.payload,u=H(e),m=a[u.tenantId],h={je_schedules:[{je_schedule_id:n,feedback:{reason:c,...d!=null&&d!==""?{note:d}:{}}}]};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${n}/revert`,h).pipe(y((g=>T(g)&&g.data!=null?_([ux({jeScheduleTransactionKey:o}),l==="accrued_expenses"?px(o):fy(o,m),et({tenantId:u.tenantId,period:m,refreshViewInBackground:!0}),N({messageSection:"revert_schedule",messageText:"success",type:"success"})]):_([Ny({jeScheduleTransactionKey:o,status:g.status}),N({messageSection:"revert_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]})]))),v((g=>_([Ny({jeScheduleTransactionKey:o,status:f("Unexpected Error",`Revert schedule REST API call errored out ${JSON.stringify(g)}`)}),N({messageSection:"revert_schedule",messageText:"failed",type:"error"})]))),De(s.pipe(S(gt.match))))}))),(s,i,r)=>s.pipe(S(lF.match),y((()=>{const{remisBulkActionViewState:t}=i.value,e={entity_ids:t.remisSelectedForBulkAction};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/reimbursements/transactions/validate?query=${encodeURIComponent(JSON.stringify(e))}`).pipe(y((a=>{if(M(a)){const n=[];return n.push(uF(a.data?.validation_results??[])),_(n)}return p(kI(a.status))})),v((a=>p(kI(f("Unexpected Error","Remi bulk review action REST API call errored out "+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(NC.match),y((t=>{const{actionType:e,operatingExpenseIds:a,selectedPeriod:n}=t.payload,o={...Rz(e,a)},c=H(i.value);return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/month-close/flux-analysis
2
2
  `,o).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[];return l.push(W(d.data.accounts,"account_list"),Ke("class_list",d.data.accounting_class),le(d.data.vendors,"merge"),V({users:d.data.users,updateType:"merge"})),d.data.flux_analysis_entities!=null&&l.push(OC({expensesPayload:d.data.flux_analysis_entities?.operating_expenses??[],currency:d.data.currency,selectedPeriod:n})),c!=null&&l.push(et({tenantId:c.tenantId,period:n,refreshViewInBackground:!0})),l.push(N({messageSection:e==="review"?"flux_analysis_reviewed":"flux_analysis_unreviewed",messageText:"success",type:"success",variables:[{variableName:"_vendors_count_",variableValue:`${a.length}`},{variableName:"_vendor_",variableValue:a.length===1?"vendor":"vendors"}]})),_(l)}return p(ly({operatingExpenseIds:a,status:d.status}))})),v((d=>p(ly({operatingExpenseIds:a,status:f("Unexpected Error","review flux analysis view REST API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(uV.match),A((t=>{const{cardId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/cancel-issue-request`).pipe(y((a=>M(a)?p(pV(e),N({messageSection:"charge_card_revoke_invite",messageText:"success",type:"success"})):p(Vv(a.status)))),v((a=>p(Vv(f("Unexpected Error","Revoke Charge Card REST API call errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(mV.match),A((t=>{const{cardIds:e}=t.payload,a={card_ids:e};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/bulk/cancel-issue-request`,a).pipe(y((n=>M(n)&&n.data!=null?p(nd({fetchState:"Completed",revokedCardIds:e}),N({messageSection:"revoke_invite_charge_cards",messageText:"success",type:"success",variables:[{variableName:"_number_of_cards_",variableValue:e.length===1?"1 card":`${e.length} cards`}]})):p(N({messageSection:"revoke_invite_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]}),nd({fetchState:"Error",error:n.status,revokedCardIds:[]})))),v((n=>p(N({messageSection:"revoke_invite_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(n)}]}),nd({fetchState:"Error",error:f("Unexpected Error","Revoke invite charge cards API call errored out"+JSON.stringify(n)),revokedCardIds:[]})))))}))),(s,i,r)=>s.pipe(S(ek.match),y((t=>{const{action:e,id:a}=t.payload,n={action:e},o=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/plans/${encodeURIComponent(a)}/actions`;return r.postAndGetJSON(o,n).pipe(y((c=>T(c)&&c.data!=null?[xr([c.data],"merge"),tk({id:a})]:p(O_({error:c.status,id:a})))),v((c=>p(O_({error:f("Unexpected Error","Catalog plan action REST API call errored out "+JSON.stringify(c)),id:a})))))}))),(s,i,r)=>s.pipe(S(ak.match),y((t=>{const{action:e,id:a,parentItemId:n}=t.payload,o={action:e},c=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/catalog/products/${encodeURIComponent(a)}/actions`,d=n??a;return r.postAndGetJSON(c,o).pipe(y((l=>T(l)&&l.data!=null?[C_([l.data],"merge"),...n!=null?[x_(n,l.data)]:[],rk({id:d})]:p(U_({error:l.status,id:d})))),v((l=>p(U_({error:f("Unexpected Error","Catalog product action REST API call errored out "+JSON.stringify(l)),id:d})))))}))),(s,i,r)=>s.pipe(S(yk.match),y((t=>{const{action:e,id:a}=t.payload,n={action:e},o=sK[e],c=(l,u)=>o==null?[]:[N({messageSection:o,messageText:l,type:l==="success"?"success":"error",variables:Ie(u)})],d=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/discounts/${encodeURIComponent(a)}/actions`;return r.postAndGetJSON(d,n).pipe(y((l=>T(l)&&l.data!=null?[Gs([l.data],"merge"),_k({id:a}),...c("success")]:_([J_({error:l.status,id:a}),...c("failed",l.status)]))),v((l=>_([J_({error:f("Unexpected Error","Discount action REST API call errored out "+JSON.stringify(l)),id:a}),...c("failed")]))))}))),(s,i,r)=>s.pipe(S(vB.match),y((t=>{const{action:e,body:a,id:n}=t.payload,o=iK[e],c=(l,u)=>o==null?[]:[N({messageSection:o,messageText:l,type:l==="success"?"success":"error",variables:Ie(u)})],d=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/dunning/${encodeURIComponent(n)}/${e}`;return r.postAndGetJSON(d,a??{}).pipe(y((l=>T(l)&&l.data!=null?[Oi([l.data],"merge"),IB({id:n}),...c("success")]:_([bh({error:l.status,id:n}),...c("failed",l.status)]))),v((l=>_([bh({error:f("Unexpected Error","Dunning action REST API call errored out "+JSON.stringify(l)),id:n}),...c("failed")]))))}))),(s,i,r)=>s.pipe(S((t=>Kk.match(t)&&t.payload.action!=="issue-credit-note")),y((t=>{const{action:e,body:a,invoiceId:n}=t.payload,o=oK[e],c=(l,u)=>o==null?[]:[N({messageSection:o,messageText:l,type:l==="success"?"success":"error",variables:Ie(u)})],d=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(n)}/${e}`;return r.postAndGetJSON(d,a??{}).pipe(y((l=>T(l)&&l.data!=null?[Ca([l.data],"merge"),z(Or([l.data])),Q_({invoiceId:n}),...c("success")]:_([Ws({error:l.status,invoiceId:n}),...c("failed",l.status)]))),v((l=>_([Ws({error:f("Unexpected Error","Invoice action REST API call errored out "+JSON.stringify(l)),invoiceId:n}),...c("failed")]))))}))),(s,i,r)=>s.pipe(S(GB.match),y((t=>{const{action:e,body:a,id:n}=t.payload,o=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/payments/${encodeURIComponent(n)}/${e}`;return r.postAndGetJSON(o,a??{}).pipe(y((c=>T(c)&&c.data!=null?[Zs([c.data],"merge"),zB({id:n})]:p(Yh({error:c.status,id:n})))),v((c=>p(Yh({error:f("Unexpected Error","Payment action REST API call errored out "+JSON.stringify(c)),id:n})))))}))),(s,i,r)=>s.pipe(S(wk.match),y((t=>{const{action:e,body:a,id:n}=t.payload,o={action:e,...a??{}},c=nK[e],d=(u,m)=>c==null?[]:[N({messageSection:c,messageText:u,type:u==="success"?"success":"error",variables:Ie(m)})],l=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/subscriptions/${encodeURIComponent(n)}/actions`;return r.postAndGetJSON(l,o).pipe(y((u=>T(u)&&u.data!=null?[Ua([u.data],"merge"),z(xa([u.data])),$k({id:n}),...d("success")]:_([z_({error:u.status,id:n}),...d("failed",u.status)]))),v((u=>_([z_({error:f("Unexpected Error","Subscription action REST API call errored out "+JSON.stringify(u)),id:n}),...d("failed")]))))}))),(s,i,r)=>s.pipe(S(wP.match),y((()=>{const t=(e=>{const a=[],n=(o,c,d)=>{const l=a.find((u=>u.account_id===o));if(l){if(c!==""&&l.labels&&!l.labels.includes(c)&&l.labels.push(c),d!=null){const{is_bank_account:u,...m}=d;l.tax_1099_config={...l.tax_1099_config,...m,is_bank_account:l.tax_1099_config?l.tax_1099_config.is_bank_account:u}}}else o!==""&&a.push({account_id:o,labels:c.length===0?[]:[c],tax_1099_config:d})};if(e.selectedIncomeAccountId!=null?n(e.selectedIncomeAccountId,"uncategorized_income",null):e.previousIncomeAccount&&n(e.previousIncomeAccount.accountId,"",null),e.selectedExpenseAccountId!=null?n(e.selectedExpenseAccountId,"uncategorized_expense",null):e.previousExpenseAccount&&n(e.previousExpenseAccount.accountId,"",null),e.selectedBillPayAccountId!=null?n(e.selectedBillPayAccountId,"bank_charges_and_fees",null):e.previousBillPayAccount&&n(e.previousBillPayAccount.accountId,"",null),e.selectedReimbursementsAccountId!=null?n(e.selectedReimbursementsAccountId,"travel_transportation",null):e.previousReimbursementsAccount&&n(e.previousReimbursementsAccount.accountId,"",null),e.selectedPrepaidExpensesAccountIds.length>0?e.selectedPrepaidExpensesAccountIds.forEach((o=>{n(o,"prepaid_expenses",null)})):e.previousPrepaidExpensesAccount.length>0&&e.previousPrepaidExpensesAccount.forEach((o=>{n(o.accountId,"",null)})),e.selectedFixedAssetsAccountIds.length>0?e.selectedFixedAssetsAccountIds.forEach((o=>{n(o,"fixed_assets",null)})):e.previousFixedAssetsAccount.length>0&&e.previousFixedAssetsAccount.forEach((o=>{n(o.accountId,"",null)})),e.selectedAccruedExpensesAccountIds.length>0?e.selectedAccruedExpensesAccountIds.forEach((o=>{n(o,"accrued_expenses",null)})):e.previousAccruedExpensesAccount.length>0&&e.previousAccruedExpensesAccount.forEach((o=>{n(o.accountId,"",null)})),e.selectedBankAccounts1099FilingAccountIds.length>0?(e.selectedBankAccounts1099FilingAccountIds.forEach((o=>{n(o,"",{is_bank_account:!0,is_expense_account:!1,expense_type:null,type_1099:null,box_type:null})})),e.previousBankAccounts1099FilingAccount.filter((o=>!e.selectedBankAccounts1099FilingAccountIds.includes(o.accountId))).map((o=>o.accountId)).forEach((o=>{n(o,"",null)}))):e.previousBankAccounts1099FilingAccount.length>0&&e.previousBankAccounts1099FilingAccount.forEach((o=>{n(o.accountId,"",null)})),e.selectedExpenseAccounts1099FilingAccountIds.length>1){e.selectedExpenseAccounts1099FilingAccountIds.forEach((c=>{n(c.accountId,"",{is_bank_account:e.selectedBankAccounts1099FilingAccountIds.includes(c.accountId),is_expense_account:!0,expense_type:c.expenseType,type_1099:c.type1099,box_type:c.boxType})}));const o=e.selectedExpenseAccounts1099FilingAccountIds.map((c=>c.accountId));e.previousExpenseAccounts1099FilingAccount.filter((c=>!o.includes(c.accountId))).map((c=>c.accountId)).forEach((c=>{n(c,"",null)}))}else if(e.selectedExpenseAccounts1099FilingAccountIds.length===1&&e.selectedExpenseAccounts1099FilingAccountIds[0].accountId!==""){e.selectedExpenseAccounts1099FilingAccountIds.forEach((c=>{n(c.accountId,"",{is_bank_account:e.selectedBankAccounts1099FilingAccountIds.includes(c.accountId),is_expense_account:!0,expense_type:c.expenseType,type_1099:c.type1099,box_type:c.boxType})}));const o=e.selectedExpenseAccounts1099FilingAccountIds.map((c=>c.accountId));e.previousExpenseAccounts1099FilingAccount.filter((c=>!o.includes(c.accountId))).map((c=>c.accountId)).forEach((c=>{n(c,"",null)}))}else e.previousExpenseAccounts1099FilingAccount.length>0&&e.previousExpenseAccounts1099FilingAccount.forEach((o=>{n(o.accountId,"",null)}));return a})(i.value.accountMappingState.data);if(t.length===0){const e=[co({status:f("No Account Mapping Data to Save")})];return _(e)}return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts`,{accounts:t}).pipe(y((e=>{if(M(e)){const a=[ss(),$P(),N({messageSection:"settings_accounting_accounts_updated",messageText:"success",type:"success"})];return _(a)}{const a=[co({status:e.status})];return _(a)}})),v((e=>p(co({status:f("Unexpected error","Save Account Mapping REST API call errored out"+JSON.stringify(e))})))))}))),(s,i,r)=>s.pipe(S(kC.match),y((()=>{const t=(e=>{const a=[],n=(c,d)=>{const l=a.find((u=>u.account_id===c));l?d!==""&&l.labels&&!l.labels.includes(d)&&(l.labels=[...l.labels,d]):c!==""&&a.push({account_id:c,labels:d.length===0?[]:[d],tax_1099_config:null})},o=(c,d,l)=>{c.length>0?c.forEach((u=>{n(u,l)})):d.length>0&&d.forEach((u=>{n(u.accountId,"")}))};return o(e.selectedPrepaidExpensesAccountIds,e.previousPrepaidExpensesAccount,Mz),o(e.selectedFixedAssetsAccountIds,e.previousFixedAssetsAccount,Vz),o(e.selectedAccruedExpensesAccountIds,e.previousAccruedExpensesAccount,Lz),a})(i.value.expenseAutomationJESchedulesViewState.accountSettings.localData);if(t.length===0){const e=[ri({status:f("No Account Mapping Data to Save")})];return _(e)}return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts`,{accounts:t}).pipe(y((e=>{if(M(e)){const a=[BC(),N({messageSection:"settings_accounting_accounts_updated",messageText:"success",type:"success"})];return _(a)}{const a=[ri({status:e.status})];return _(a)}})),v((e=>p(ri({status:f("Unexpected error","Save Account Mapping REST API call errored out"+JSON.stringify(e))})))))}))),(s,i,r)=>s.pipe(S(NP.match),A((t=>r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${t.payload.connectionId}`,{api_key:t.payload.credentials.api_key,connection_name:t.payload.connectionName,connection_type:t.payload.connectionType,site:t.payload.credentials.site},Object.assign({"zeni-tenant-id":t.payload.tenantId})).pipe(y((e=>{if(T(e))return _([OP(t.payload.tenantId,t.payload.connectionType,e.data)]);const a=e.status??f("Failed to save connection. Please try again.");return _([nu(t.payload.tenantId,a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error saving connection.";return _([nu(t.payload.tenantId,f(a))])})))))),(s,i,r)=>s.pipe(S(T1.match),y((t=>{const e=i.value,{billStageCode:a,billId:n,isForMarkAsPaid:o,isApproverMarkingAsPaid:c}=t.payload,d=Ne(n??""),l=n!=null?e.editBillDetailViewState.editBillStateById[d]:e.editBillDetailViewState.newBillState,u=(function(g,I,b,E,P,O,C,U){const B=P.billId;let x;const k=P.billDetailLocalData.paymentDetailsSection?.withdrawFrom,J=qi(b,k?.id??"")?.zeniAccountId,L=!!P.billDetailLocalData.isRecurring,R={vendor_id:P.billDetailLocalData.vendor?.qboId??"",vendor_name:P.billDetailLocalData.vendor?.name??"",candidate_vendor_name:P.billDetailLocalData.vendor?.qboId!=null?void 0:P.addBillAutoFields.tentativeVendorName??P.billDetailLocalData.candidateVendorname,ocr_parsed_vendor_term:P.addBillAutoFields.tentativeVendorName?P.addBillAutoFields.tentativeVendorName:null,transaction_type:"bill",bill_pay_provider:"zeni",account_id:J!=null?Ze(g,J,"bill_pay")?.qboId:"",file_id:P.billDetailLocalData.file?.fileId??"",transaction_date:P.billDetailLocalData.whatForSection?.invoiceDate?.format("YYYY-MM-DD")??me().format("YYYY-MM-DD"),due_date:P.billDetailLocalData.whatForSection?.billDueDate?.format("YYYY-MM-DD")??null,total_amount:P.billDetailLocalData.totalAmount?.amount??0,recipient_total_amount:P.billDetailLocalData.recipientTotalAmount?.amount??0,bill_pay_info:{stage:{code:O},payment_date:RK(P.billDetailLocalData),from_account:{account_id:P.billDetailLocalData.paymentDetailsSection?.withdrawFrom?.id??"",account_type:Me(P.billDetailLocalData.paymentDetailsSection?.withdrawFrom?.accType)??""},to_account:{...P.billDetailLocalData.paymentDetailsSection?.paymentType?.method.includes("international")===!0?{payment_instrument_id:P.billDetailLocalData.isCollectToAccountInfoFromVendorContact?null:P.billDetailLocalData.paymentDetailsSection?.paymentTo??null}:{account_id:P.billDetailLocalData.isCollectToAccountInfoFromVendorContact?null:P.billDetailLocalData.paymentDetailsSection?.paymentTo??null}},to_account_vendor_email:P.billDetailLocalData.toAccountVendorEmail??null,is_collect_to_account_info_from_vendor_contact:P.billDetailLocalData.isCollectToAccountInfoFromVendorContact,is_cancelled:!1,bill_payment_method_type:tP(P.billDetailLocalData.paymentDetailsSection?.paymentType),international_transfer_fee_bearer_payment_method:P.billDetailLocalData.paymentDetailsSection?.paymentType?.method.includes("international")===!0&&P.billDetailLocalData.vendor?.vendorCurrencyCode==="USD"?P.billDetailLocalData.paymentDetailsSection.internationalTransferFeeBearerPaymentMethod??"swift_our":null,outside_zeni_transaction_payment_mode:P.billDetailLocalData.outsideZeniPaymentLocalData?.paymentMode??null,bill_payment_status:{code:C?"mark_as_paid":null}},document_id:P.billDetailLocalData.whatForSection?.invoiceNumber,transaction_memo:P.billDetailLocalData.whatForSection?.memo,currency_code:P.billDetailLocalData.whatForSection?.currencyCode??"USD",recipient_currency_code:P.billDetailLocalData.whatForSection?.recipientCurrencyCode??"USD",lines:Object.keys(P.billDetailLocalData.updatesByLineId).map((q=>{const $=P.billDetailLocalData.updatesByLineId[q],D=(w=$,{account:P1,class:E1,...w});var w;return N1(D)}))};if(L||(R.vendor_name=P.billDetailLocalData.vendor?.name??""),B!=null?(x=X(I.transactionById,B,void 0),R.sync_token=x?.syncToken??null,R.update_time=x?.updateTime.format("YYYY-MM-DD")??null,U&&(R.is_outside_zeni_bill_marked_as_paid_by_approver=!0),x?.isRecurring===!0&&!P.billDetailLocalData.isRecurring&&(R.is_recurring=!1)):R.are_approvals_serialized=!0,O==="pending_approval"&&P.billDetailLocalData.paymentDetailsSection?.conversionRate!=null&&(R.exchange_rate=1/P.billDetailLocalData.paymentDetailsSection.conversionRate),P.billDetailLocalData.isRecurring){R.is_recurring=!0;const q=P.billDetailLocalData.recurringConfig,$=P.billDetailLocalData.recurringBillInstances;if(q!=null&&(R.recurring_bill_config=O1(q)),q?.id!=null){const D=X(E.recurringBillDetailByConfigId,q.id),w=C1(q,D.recurringBillConfig,!0);if(R.is_update_recurring_bill_config=w,R.is_update_future_recurring_bills=q.updateRecurringBills==="all",!w&&q.updateRecurringBills!=="all"||R.recurring_bill_config==null||(R.recurring_bill_config.sync_token=D.recurringBillConfig.syncToken),$!=null){const K=$.filter((G=>!G.readonly)).slice(1).map((G=>i0(G,P.billDetailLocalData.paymentDetailsSection?.paymentType?.maxPeriod?.value??lv)));R.future_recurring_bill_instances=K,R.recurring_bill_config!=null&&(R.recurring_bill_config.future_total_payment_cycles=K?.length,delete R.recurring_bill_config.total_payment_cycles)}}else R.recurring_bill_instances=$?.map((D=>i0(D,P.billDetailLocalData.paymentDetailsSection?.paymentType?.maxPeriod?.value??lv)))}return R})(e.accountState,e.billTransactionState,e.paymentAccountState,e.recurringBillState,l,a,o,c),m=l.billDetailLocalData.isRecurring,h=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bills/transactions`;return(n!=null?r.putAndGetJSON(o0(h,m,n,e.billTransactionState),u):r.postAndGetJSON(o0(h,m),u)).pipe(y((g=>{if(T(g)&&g.data?.transactions[0]?.transaction_id!=null){const I=[mn(g.data.transactions[0])];return m&&I.push(mc(g.data.recurring_bill_configs??[]),Bf(g.data.recurring_bill_instances??[])),I.push(kc("Completed",t.payload.billId),N({messageSection:MK(o,a),messageText:"success",type:"success"})),_(I)}return p(kc("Error",t.payload.billId,g.status),N({messageSection:"bill_pay_updated",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]}))})),v((g=>p(kc("Error",t.payload.billId,f("Unexpected Error",`REST API call errored out ${JSON.stringify(g)}`))))))}))),(s,i,r)=>s.pipe(S(YR.match),A((t=>{const{billPaySetupApproverViewState:e}=i.value,a=e.billPaySetupApproverViewUpdateData;if(a!=null&&a.data!=null){const{useV3:n}=t.payload,o=n?r0(a.data):s0(a.data),c=n?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/bill-pay/approval-rules`;return r.postAndGetJSON(c,o).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.approval_rules.map((g=>g.approval_rule_id)),u=d.data.affected_entity_ids??[],m=d.data.new_approval_rule?.approval_rule_id,h=[V({users:d.data.users}),We(d.data.approval_rules),N({messageSection:`bill_pay_${a.type}`,messageText:"success",type:"success"}),HR(l,u,m)];return _(h)}{const l=[];return d.status.code===400?l.push(N({messageSection:`bill_pay_duplicate_${a.type}`,messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]})):l.push(N({messageSection:`bill_pay_${a.type}`,messageText:"failed",type:"error"})),l.push(Xf(d.status)),_(l)}})),v((d=>p(Xf(f("Unexpected Error","Save Bill Pay Approval View Updates errored out"+JSON.stringify(d)))))))}return _([])}))),(s,i,r)=>s.pipe(S(hq.match),A((t=>{const{name:e,content:a,cannedResponseId:n}=t.payload,o=n!=null,c=o?`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses/${n}`:`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/canned-responses`;return(o?r.putAndGetJSON(c,{name:e,content:a}):r.postAndGetJSON(c,{name:e,content:a})).pipe(y((d=>T(d)?p(Sq(),hb()):p(gb({error:d.status})))),v((d=>p(gb({error:f("Unexpected Error","Save Canned Response errored: "+JSON.stringify(d))})))))}))),(s,i)=>s.pipe(S(kM.match),y((()=>{const r=i.value.cardUserOnboardingState.cardUserOnboardingLocalData;return _([ff("CardUserOnboarding",r?.phone,r?.otpChallenge,r?.dateOfBirth)])}))),(s,i,r)=>s.pipe(S(lR.match),y((t=>{const{companyId:e}=t.payload;let a;const{newAddressState:n}=i.value.addressViewState,o=_t(i.value,e,[]);return o!=null&&n?.subscription_billing_address.addressToCreate!=null?(a=BK(n.subscription_billing_address.addressToCreate,o.company.company.companyInfo.syncToken),r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,a).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[Q({payload:c.data.companies,schema:{}}),z(c.data.addresses)];return d.push(uR()),_(d)}return p(N({messageSection:"billing_address_view",messageText:"failed",type:"error"}),Sf(c.status))})),v((c=>p(Sf(f("Unexpected Error","Save Billing Address Details errored out"+JSON.stringify(c)))))))):_([])}))),(s,i,r)=>s.pipe(S(dN.match),A((t=>{const e=t.payload,{companyHealthMetricViewState:a}=i.value,n=a.companyHealthMetricUpdateStatusById[e],{netPromoterScore:o,externalProductServiceExposure:c,customerSatisfactionScore:d,additionalChurnFactors:l}=n.companyHealthMetricLocalData,u=l.increasingChurnProbability.map((h=>h.code)),m=l.decreasingChurnProbability.map((h=>h.code));return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-health-metrics/${e}`,{net_promoter_score:o||null,external_product_service_exposure:c,customer_satisfaction_score:d||null,additional_churn_factors:[...u,...m]}).pipe(y((h=>{if(T(h)&&h.data!=null){const g=[];return g.push(Q({payload:h.data.companies,schema:{}})),g.push(Rp({payload:h.data.company_health_metrics})),g.push(Vp(e)),g.push(lN({companyId:e})),_(g)}return p(Lp({companyId:e,error:h.status}))})),v((h=>p(Lp({companyId:e,error:f("Unexpected Error","Save Company Health Metric By Id REST API call errored out"+JSON.stringify(h))})))))}))),(s,i,r)=>s.pipe(S(vN.match),y((t=>{const{agentInsightEdits:e,companyId:a,recipientEmailList:n,subject:o,isPreview:c,fileId:d,zeniRequestsHtml:l,tenantId:u}=t.payload,m=i.value,h=m.companyState.companiesById[a],g=m.companyState.companiesById[a].companyInfo.name,I=u??h.companyInfo.tenantId,b=Qp(me()),E=me(),P=[];if(d!=null&&d!=null){const U=Wp(m.fileState,d);U!=null&&P.push({data:U.base64String,id:U.fileId,name:U.fileName})}const O={template_data:EE(m.companyMonthEndReportViewState.monthEndReportDataByCompanyId[a].companyMonthEndReportData.templateData,o,e),recipient_email_list:n,tenant_receiver_email_list:m.companyMonthEndReportViewState.monthEndReportDataByCompanyId[a].companyMonthEndReportData.tenantReceiverEmailList,last_report_sent_business_day:b,last_report_sent_date:E.format(re),...l!==void 0&&{zeni_requests_html:l===""?null:l},files:P},C={is_preview:c};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${a}/emails/month-end?query=${encodeURIComponent(JSON.stringify(C))}`,O,{"zeni-tenant-id":I}).pipe(y((U=>{if(M(U)&&U.data!=null){const B=[IN(a,c,U.data)];return c||(B.push(Zp({companyId:a,isInDraftMode:!0})),B.push(N({messageSection:"cockpit_month_end_email_save",messageText:"success",type:"success",variables:[{variableName:"_company-name_",variableValue:g}]}))),_(B)}return p(Xp(a,"Error",c,U.status))})),v((U=>p(Xp(a,"Error",c,f("Unexpected Error","save company month end report REST API call errored out"+JSON.stringify(U)))))))}))),(s,i)=>s.pipe(S(MN.match),y((()=>{const r=i.value,t=[],e=r.companyViewState.passportView;e.primaryContact.localData!=null&&t.push(_m(e.companyIds[0],e.primaryContact.localData)),Object.values(e.companyOfficerUpdateStatus).forEach((n=>{n.localData!=null&&n.localData.email&&n.localData.userId!=null&&t.push(hm(e.companyIds[0],n.localData))}));const a=Object.values(e.companyOfficerUpdateStatus).filter((n=>n.localData!=null&&!!n.localData.email&&n.localData?.userId==null)).map((n=>n.localData));return a.length>0&&t.push(cm(e.companyIds[0],a)),e.companyDetails.localData!=null&&t.push(Sm(e.companyIds[0],e.companyDetails.localData)),_(t)}))),(s,i,r)=>s.pipe(S(CP.match),A((t=>r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connectors/${t.payload.connectionName}/credentials`,t.payload.credentials,{"zeni-tenant-id":t.payload.tenantId}).pipe(y((e=>{if(T(e)&&e.data!=null)return _([xP(t.payload.tenantId,t.payload.connectionType,t.payload.connectionName,e.data)]);const a=e.status??f("Failed to save connection. Please try again.");return _([ou(t.payload.tenantId,t.payload.connectionName,a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error saving connection.";return _([ou(t.payload.tenantId,t.payload.connectionName,f(a))])})))))),(s,i,r)=>s.pipe(S(TO.match),A((t=>{const{instructions:e}=t.payload,a=i.value.creditAgentEntityState.macro;if(a==null)return _([Go(f("Save failed","Cannot save macro: macro data has not been loaded yet.")),N({messageSection:"credit_agent_save_macro",messageText:"failed",type:"error"})]);const n=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/macros/credit-agent`,o={instructions:e,name:a.name,description:a.description};return r.putAndGetJSON(n,o).pipe(y((c=>T(c)&&c.data!=null?_([Bm(c.data),AO(),N({messageSection:"credit_agent_save_macro",messageText:"success",type:"success"})]):_([Go(c.status),N({messageSection:"credit_agent_save_macro",messageText:"failed",type:"error"})]))),v((c=>_([Go(f("Unexpected error","REST API call errored out: "+JSON.stringify(c))),N({messageSection:"credit_agent_save_macro",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(YO.match),y((t=>{const e=i.value,{reconcileAction:a}=t.payload,{expenseAutomationViewState:{selectedPeriodByTenantId:n},expenseAutomationReconciliationViewState:{selectedAccountId:o,reconTabsState:{balances:c}}}=e,d=n[H(e).tenantId];let l,u;o!=null&&(l=Ea(e,o,d),u=l?.reconciliationId);let m={};return l!=null&&(m=(function(h,g,I,b,E,P){const{balance:O,initialClearedBalance:C}=b,{expenseAutomationReconciliationViewState:{selectedAccountId:U,reconTabsState:{reconcile:{localData:{selectedTransactionIds:B}}}}}=h,x=Re(g,!0),k=(function(L,R){const q=[];return R.transactionsToReconcile.map((D=>({...D,isTransactionChecked:L.includes(D.id)}))).forEach((D=>{const w=QO(D);q.push(w)})),q})(B,b),J=(function(L){const R=[];return L.transactionsToReview.forEach((q=>{const $=WO(q);R.push($)})),R})(b);return{action:E.reconcileAction==="save_reconcile_for_later"?"save_for_later":E.reconcileAction,account_type:"bank",bank_balance:O?.amount??0,cleared_balance:I.clearedBalance.amount,variance:I.variance.amount,currency_code:O?.currencyCode,transactions:{reconcile:k,review:J},...C?.amount!=null?{initial_cleared_balance:C.amount}:{},...P==="POST"?{account_id:U,start_date:x.start,end_date:x.end}:{},...E.reconcileAction==="exclude"?{exclude_transaction_ids:[E.excludeTransactionId]}:{}}})(e,d,c,l,t.payload,u!=null?"PUT":"POST")),(u!=null?r.putAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/${u}`,m):r.postAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation`,m)).pipe(y((h=>{if(T(h)&&h.data!=null){const g=[],I=CE(h.data.reconciliation[0].transactions.reconcile),b=Ym(h.data.reconciliation);if(g.push(Xo(b,"merge")),g.push(ei(d,h.data.reconciliation)),g.push(gr({selectedTransactionIds:I})),t.payload.reconcileAction==="exclude"){if(o!=null){const E=ba(o,d);g.push(Hm(E,t.payload.excludeTransactionId))}g.push(Qm({reconcileAction:a,excludeTransactionId:t.payload.excludeTransactionId}))}else t.payload.reconcileAction!=="reconcile"&&t.payload.reconcileAction!=="save_reconcile_for_later"||g.push(Qm({reconcileAction:t.payload.reconcileAction}),HO({selectedAccountId:void 0}));return g.push(N({messageSection:t.payload.reconcileAction==="reconcile"?"reconcile":t.payload.reconcileAction==="save_reconcile_for_later"?"save_reconcile_for_later":"exclude_transaction",messageText:"success",type:t.payload.reconcileAction==="reconcile"||t.payload.reconcileAction==="save_reconcile_for_later"?"info":"success",...t.payload.reconcileAction==="reconcile"?{variables:[{variableName:"_reconcile_account_",variableValue:l?.account.accountName??""}]}:{}})),_(g)}{const g=[];return t.payload.reconcileAction==="exclude"?g.push(Os({fetchStateByAction:{reconcileAction:t.payload.reconcileAction,excludeTransactionId:t.payload.excludeTransactionId},error:h.status})):t.payload.reconcileAction!=="reconcile"&&t.payload.reconcileAction!=="save_reconcile_for_later"||g.push(Os({fetchStateByAction:{reconcileAction:t.payload.reconcileAction},error:h.status})),g.push(N({messageSection:t.payload.reconcileAction==="reconcile"?"reconcile":t.payload.reconcileAction==="save_reconcile_for_later"?"save_reconcile_for_later":"exclude_transaction",messageText:"failed",type:"error",variables:[{variableName:"_reconcile_account_",variableValue:l?.account.accountName??""}]})),_(g)}})),v((h=>{const g=[];return t.payload.reconcileAction==="exclude"?g.push(Os({fetchStateByAction:{reconcileAction:t.payload.reconcileAction,excludeTransactionId:t.payload.excludeTransactionId},error:f(`Unexpected Error occured while ${OE(t.payload.reconcileAction)}`,"save REST API call errored out"+JSON.stringify(h))})):t.payload.reconcileAction!=="reconcile"&&t.payload.reconcileAction!=="save_reconcile_for_later"||g.push(Os({fetchStateByAction:{reconcileAction:t.payload.reconcileAction},error:f(`Unexpected Error occured while ${OE(t.payload.reconcileAction)}`,"save REST API call errored out"+JSON.stringify(h))})),g.push(N({messageSection:t.payload.reconcileAction==="reconcile"?"reconcile":t.payload.reconcileAction==="save_reconcile_for_later"?"save_reconcile_for_later":"exclude_transaction",messageText:"failed",type:"error",variables:[{variableName:"_reconcile_account_",variableValue:l?.account.accountName??""}]})),_(g)})))}))),(s,i,r)=>s.pipe(S(cC.match),y((t=>{const e=i.value,a=e.entityState,{transactionId:n}=t.payload,o=e.expenseAutomationReconciliationViewState.reconTabsState.review.localData[n],c=e.expenseAutomationReconciliationViewState.reconTabsState.reconcile.localData,{expenseAutomationViewState:{selectedPeriodByTenantId:d},expenseAutomationReconciliationViewState:{selectedAccountId:l}}=e,u=d[H(e).tenantId];let m,h,g;l!=null&&(m=Ea(e,l,u),h=m?.reconciliationId,g=m?.transactionsToReview.find((P=>P.transactionId===n)));const I={review_action:g?.recommendedAction.action,reconciliation_id:h??"",ref_account_id:l,ref_account_name:m?.account.accountName,ref_account_type:m?.account.accountType};let b={};if(m!=null&&g!=null&&o!=null)switch(g.recommendedAction.action){case"record_expense":case"record_cc_credit":b=Jz(g,o);break;case"record_bill_payment":{const P=g.recommendedAction.recommendedTransactions.find((O=>O.bookTransactionId===o.matchedTransactionId));b=wz(g,P,o,m?.account.accountType);break}case"record_transfer":b=(function(P,O){return{account_id:O.bankAccountId,amount:P.amount.amount,transaction_memo:P.memo,line_description:O.memo,transaction_date:P.transactionDate.format(re),transaction_direction:P.transactionDirection,transaction_id:P.transactionId,currency_code:P.amount.currencyCode}})(g,o);break;case"record_cc_payment":b=(function(P,O,C){return{account_id:C==="credit_card"?O.bankAccountId:O.creditCardId,amount:P.amount.amount,transaction_memo:P.memo,line_description:O.memo,transaction_date:P.transactionDate.format(re),transaction_direction:P.transactionDirection,transaction_id:P.transactionId,currency_code:P.amount.currencyCode}})(g,o,m?.account.accountType);break;case"record_deposit":b=(function(P,O,C){const U=O.customer?.id!=null?lC(C,[O.customer?.id])[0]?.zeniId:void 0;return{amount:P.amount.amount,transaction_memo:P.memo,line_description:O.memo,transaction_date:P.transactionDate.format(re),transaction_direction:P.transactionDirection,transaction_id:P.transactionId,customer_id:U,customer_name:O.customer?.name,account_id:O.categoryId,accounting_class_id:O.classId,currency_code:P.amount.currencyCode}})(g,o,a)}b={...b,is_recommendation_operation_selected:I.review_action===g?.recommendedAction.action};const E=$z(g);return r.postAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/review?query=${encodeURIComponent(JSON.stringify(I))}`,b).pipe(y((P=>{if(T(P)&&P.data!=null){const O=[];if(O.push(ti({transactionId:n,fetchState:"Completed"}),Xo([{allReconciledTransactions:[P.data.reconciliation],currencyPayload:{currency_code:g?.amount.currencyCode??Us.currencyCode,currency_symbol:g?.amount.currencySymbol??Us.currencySymbol}}],"merge")),l!=null){const C=ba(l,u);O.push(Hm(C,n),dC(C,P.data.reconciliation.transaction_id),gr({selectedTransactionIds:[...c.selectedTransactionIds,P.data.reconciliation.transaction_id]}))}return O.push(N({messageSection:E,messageText:"success",type:"success"})),_(O)}{const O=[];return O.push(ti({transactionId:n,fetchState:"Error",error:P.status}),N({messageSection:E,messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:P.status.message}]})),_(O)}})),v((P=>{const O=[];return O.push(ti({transactionId:n,fetchState:"Error",error:f("Unexpected Error occurred while saving reconciliation review","save reconciliation review REST API call errored out"+JSON.stringify(P))}),N({messageSection:E,messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify("error")}]})),_(O)})))}))),ZG,(s,i,r)=>s.pipe(S((t=>ok.match(t))),y((t=>{const{id:e}=t.payload,a=i.value,n=dk(a),o=a.editInvoicingCatalogItemDetailViewState,c=(e!=null?o.editDraftById[e]:o.newItemDraft)??o.newItemDraft,d=rK(c,e==null,n),l=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`,u=e!=null?`${l}/catalog/plans/${encodeURIComponent(e)}`:`${l}/catalog/plans`;return(e!=null?r.putAndGetJSON(u,{...d}):r.postAndGetJSON(u,{...d})).pipe(y((m=>{if(T(m)&&m.data!=null){const h=m.data;return(g=>{const I=g.find((P=>!T(P)||P.data==null));if(I!=null)return _([fi(I.status),N({messageSection:"invoicing_catalog_item_saved",messageText:"failed",type:"error",variables:Ie(I.status)})]);const b=g.flatMap((P=>P.data!=null?[P.data]:[])),E=[xr([h],"merge"),...b.length>0?[C_(b,"merge")]:[],...b.map((P=>x_(h.id,P))),ik({itemId:h.id,kind:"plan"})];if(e==null){const P=h.type==="charge"||h.item_type==="charge"?"charge":h.type==="addon"||h.item_type==="addon"?"addon":"plan";E.push(ck({id:h.id,type:P}))}return E.push(N({messageSection:"invoicing_catalog_item_saved",messageText:"success",type:"success"})),E})([])}return _([fi(m.status),N({messageSection:"invoicing_catalog_item_saved",messageText:"failed",type:"error",variables:Ie(m.status)})])})),v((m=>_([fi(f("Unexpected Error","Save catalog item REST API call errored out "+JSON.stringify(m))),N({messageSection:"invoicing_catalog_item_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S((t=>hk.match(t)||w_.match(t))),y((t=>{const{id:e}=t.payload,a=w_.match(t)?t.payload.data:(()=>{const c=i.value.editInvoicingCouponDetailViewState;return((d,l)=>{const u={apply_on:d.applyOn,discount_type:d.discountType,duration_type:d.durationType,name:d.name.trim()};l&&(u.id=d.couponId.trim());const m=d.couponCode.trim();m!==""&&(u.coupon_code=m),d.discountType==="percentage"&&d.discountPercentage.trim()!==""&&(u.discount_percentage=Number(d.discountPercentage)),d.discountType==="fixed_amount"&&(d.discountAmount!=null&&(u.discount_amount=d.discountAmount.amount),u.currency_code="USD"),d.discountType==="offer_quantity"&&d.discountQuantity.trim()!==""&&(u.discount_quantity=Number(d.discountQuantity)),d.durationType==="limited_period"&&(d.period.trim()!==""&&(u.period=Number(d.period)),u.period_unit=d.periodUnit),d.validFrom.trim()!==""&&(u.valid_from=d.validFrom.trim()),d.validTill.trim()!==""&&(u.valid_till=d.validTill.trim()),d.maxRedemptions.trim()!==""&&(u.max_redemptions=Number(d.maxRedemptions));const h=d.invoiceName.trim();h!==""&&(u.invoice_name=h);const g=d.invoiceNotes.trim();return g!==""&&(u.invoice_notes=g),u})((e!=null?c.editDraftById[e]:c.newCouponDraft)??c.newCouponDraft,e==null)})(),n=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`,o=e!=null?`${n}/discounts/${encodeURIComponent(e)}`:`${n}/discounts`;return(e!=null?r.putAndGetJSON(o,{...a}):r.postAndGetJSON(o,{...a})).pipe(y((c=>{if(T(c)&&c.data!=null){const d=c.data,l=[Gs([d],"merge"),Sk({couponId:d.id})];return e==null&&l.push(gk({id:d.id,status:d.status})),l.push(N({messageSection:"invoicing_coupon_saved",messageText:"success",type:"success"})),l}return _([$_(c.status),N({messageSection:"invoicing_coupon_saved",messageText:"failed",type:"error",variables:Ie(c.status)})])})),v((c=>_([$_(f("Unexpected Error","Save coupon REST API call errored out "+JSON.stringify(c))),N({messageSection:"invoicing_coupon_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(Nk.match),y((t=>{const{id:e}=t.payload,a=i.value,n=a.editInvoicingCustomerDetailViewState,o=(e!=null?n.editDraftById[e]:n.newCustomerDraft)??n.newCustomerDraft,c=a.addressViewState.newAddressState?.[Hs]?.addressToCreate,d=((u,m)=>{const h=ta(u.firstName),g=ta(u.lastName),I=ta(u.company),b=u.netTermDays.trim();return{auto_collection:u.autoCollection?"on":"off",company:I,customer_type:u.customerType,email:ta(u.email),first_name:h,invoice_notes:ta(u.invoiceNotes),last_name:g,notes:u.notes.trim(),phone:ta(u.phone),preferred_currency_code:u.preferredCurrencyCode,taxability:u.taxability,vat_number:ta(u.vatNumber),...b!==""?{net_term_days:Number(b)}:{},...m!=null?{billing_address:xe(m)}:{}}})(o,c),l=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return(e!=null?r.putAndGetJSON(`${l}/customers/${encodeURIComponent(e)}`,{...d}):r.postAndGetJSON(`${l}/customers`,{...d})).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[Ii([u.data],"merge"),z(vi([u.data])),Ok({customerId:u.data.id}),ma(Hs)];return e==null&&m.push(Ck({id:u.data.id,status:u.data.status})),m.push(N({messageSection:"invoicing_customer_saved",messageText:"success",type:"success"})),m}return _([j_(u.status),N({messageSection:"invoicing_customer_saved",messageText:"failed",type:"error",variables:Ie(u.status)})])})),v((u=>_([j_(f("Unexpected Error","Save customer REST API call errored out "+JSON.stringify(u))),N({messageSection:"invoicing_customer_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S($U.match),y((t=>{const{customerId:e,data:a}=t.payload,n=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(e)}/payment-methods`;return r.postAndGetJSON(n,a).pipe(y((o=>T(o)&&o.data!=null?[RU(),Ys({id:e})]:p(h_(o.status)))),v((o=>p(h_(f("Unexpected Error","Save payment method REST API call errored out "+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(aS.match),y((t=>{const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`,{settings:a,snackbarSection:n}=t.payload,o=(c,d)=>n==null?[]:[N({messageSection:n,messageText:c,type:c==="success"?"success":"error",variables:Ie(d)})];return r.putAndGetJSON(e,{...a}).pipe(A((c=>T(c)&&c.data!=null?_([rS(c.data),...o("success")]):_([tn(c.status),...o("failed",c.status)]))),v((c=>_([tn(f("Unexpected Error","Save settings REST API call errored out "+JSON.stringify(c))),...o("failed")]))))}))),(s,i,r)=>s.pipe(S(Vk.match),y((t=>{const{id:e}=t.payload,a=i.value,n=a.editInvoicingSubscriptionDetailViewState,o=(e!=null?n.editDraftById[e]:n.newSubscriptionDraft)??n.newSubscriptionDraft,c=a.addressViewState.newAddressState?.[kr]?.addressToCreate,d=((m,h)=>{const g=[{item_price_code:m.planPriceCode,item_type:"plan",quantity:Ai(m.planQuantity)},...m.addonPriceCodes.map((C=>({item_price_code:C,item_type:"addon",quantity:Ai(m.addonQuantities[C])}))),...m.chargePriceCodes.map((C=>({item_price_code:C,item_type:"charge",quantity:Ai(m.chargeQuantities[C])})))],I=m.setupFee?.amount,b=m.poNumber.trim(),E=m.trialEnd.trim(),P=m.startedAt.trim(),O=Rk(m.remainingBillingCycles);return{auto_collection:m.autoCollection?"on":"off",currency_code:m.preferredCurrencyCode,customer_id:m.customerId,started_at:P!==""?P:Mk(),subscription_items:g,...I!=null?{setup_fee:I}:{},...b!==""?{po_number:b}:{},...E!==""?{trial_end:E}:{},...O!=null?{remaining_billing_cycles:O}:{},...m.couponId!==""?{coupon_ids:[m.couponId]}:{},...h!=null?{shipping_address:xe(h)}:{}}})(o,c);e!=null&&delete d.coupon_ids;const l=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`,u=e!=null?a.invoicingSubscriptionState.invoicingSubscriptionByID[e]?.coupons?.[0]?.couponCode??a.invoicingSubscriptionState.invoicingSubscriptionByID[e]?.coupons?.[0]?.couponID??"":"";return(e!=null?r.putAndGetJSON(`${l}/subscriptions/${encodeURIComponent(e)}`,{...d}):r.postAndGetJSON(`${l}/subscriptions`,{...d})).pipe(y((m=>{if(!T(m)||m.data==null)return[Qs(m.status),N({messageSection:"invoicing_subscription_saved",messageText:"failed",type:"error",variables:Ie(m.status)})];const h=m.data;if(e!=null&&$E(u)!==$E(o.couponId))return[Ua([h],"merge"),z(xa([h])),K_({subscriptionId:h.id,previousCouponCode:u,nextCouponCode:o.couponId})];const g=[Ua([h],"merge"),z(xa([h])),Y_({subscriptionId:h.id}),ma(kr)];return e==null&&g.push(Lk({id:h.id,status:h.status})),g.push(N({messageSection:"invoicing_subscription_saved",messageText:"success",type:"success"})),g})),v((m=>_([Qs(f("Unexpected Error","Save subscription REST API call errored out "+JSON.stringify(m))),N({messageSection:"invoicing_subscription_saved",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(eM.match),A((t=>{const{bankAccount:e,address:a}=i.value.magicLinkViewState,{paymentMethodType:n,paymentSubConfigCodeType:o,vendorId:c,billId:d,isLocalCurrencyEnabled:l}=t.payload,u=n==="wire"&&o==="international",m=u?e.createInternationalBankAccountDetails.localData:e.createBankAccountDetails.localData,h=u?IE(m):vl(m,n);if(Object.assign(h,{transaction_id:d,transaction_type:"bill"}),n==="wire"&&Object.assign(h,{mailing_address:xe(a)}),u&&Object.assign(h,{is_local_currency_enabled:l}),m!=null){const g=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${c}/bank-accounts`;return r.postAndGetJSON(g,h).pipe(y((I=>{const b=[];return M(I)?b.push(wc({fetchState:"Completed",isInternationalBankAccount:u})):(I.status.code,b.push(wc({fetchState:"Error",error:I.status,isInternationalBankAccount:u})),b.push(N({messageSection:"create_bank_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:I.status.message}]}))),_(b)})),v((I=>p(wc({fetchState:"Error",error:f("Unexpected Error","Bank Account Creation REST API call errored out"+JSON.stringify(I)),isInternationalBankAccount:u})))))}return _([])}))),(s,i)=>s.pipe(S(ns.match),y((r=>{const t=r.payload.addressType;switch(t){case"company_address":return p(_u(t,r.payload.companyId));case"officer_1_address":case"officer_2_address":case"officer_3_address":case"officer_4_address":case"officer_5_address":case"officer_6_address":case"officer_7_address":case"officer_8_address":case"officer_9_address":case"officer_10_address":return r.payload.userId!=null?p(hu(t,r.payload.companyId,r.payload.userId)):_([]);default:return p(yu(t))}}))),(s,i,r)=>s.pipe(S(zC.match),y((t=>{const{scheduleType:e}=t.payload,a=i.value,n=a.expenseAutomationJESchedulesViewState.newSchedule.newScheduleState[e],{selectedBaseTransactionId:o}=n,c=o!=null?KC(a.transactionState,Ey(o)):void 0;if(c==null)return _([Bs({status:f("Unexpected Error","No base transaction selected for this schedule.")}),N({messageSection:"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"No base transaction selected."}]})]);const d=YC(c,n,e);if(!d.ok){const E=zz[d.reason];return _([Bs({status:f("Unexpected Error",E)}),N({messageSection:"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:E}]})])}const l=n.selectedVendor?.name??c.vendorName??"",u={je_schedule_type:e},m={...d.payload},h=a.expenseAutomationViewState.selectedPeriodByTenantId[H(a).tenantId],g=h!=null?Re(h):void 0,I=g!=null?ge(g.start):void 0,b=g!=null?ge(g.end):void 0;return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(u))}`,m).pipe(y((E=>{if(T(E)&&E.data!=null){const P=[ut(E.data.je_schedules),St(E.data.je_schedules,E.data.scheduled_journal_entries),by({scheduleType:e}),HC(),N({messageSection:"create_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:l}]})];return I!=null&&b!=null&&P.push(Qa({start:I,end:b},!0)),_(P)}return _([Bs({status:E.status}),N({messageSection:"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:E.status.message}]})])})),v((E=>_([N({messageSection:"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(E)}]}),Bs({status:f("Unexpected Error",`Save New Schedule REST API call errored out ${JSON.stringify(E)}`)})]))),De(s.pipe(S(gt.match))))}))),XG,(s,i,r)=>s.pipe(S(pR.match),A((()=>{const t=mf(r),{notificationSettings:e,notificationSettingsLocalData:a}=i.value.settingsViewState.notification,n=(function(o,c){const{reminderNotificationSettings:d,monthEndInsightsNotificationSettings:l}=c,{reminders:u,monthEndInsights:m}=o,h={is_missing_receipt_notification_active:null,missing_receipt_notification:null,is_uncategorized_transaction_notification_active:null,uncategorized_transaction_notification:null,is_pending_bill_approval_notification_active:null,pending_bill_approval_notification:null,pending_reimbursement_approval_notification:null,is_pending_reimbursement_approval_notification_active:null,is_month_end_insights_active:l.enabled!=null?m.notify:null,month_end_email_recipient_email_ids:m.recipientEmailIds};return d.missingReceiptNotification!=null&&(h.is_missing_receipt_notification_active=u.missingReceiptNotification.preferredMode.length>0,h.missing_receipt_notification=Ln(u.missingReceiptNotification)),d.uncategorizedTransactionNotification!=null&&(h.is_uncategorized_transaction_notification_active=u.uncategorizedTransactionNotification.preferredMode.length>0,h.uncategorized_transaction_notification=Ln(u.uncategorizedTransactionNotification)),d.pendingBillApprovalNotification!=null&&(h.is_pending_bill_approval_notification_active=u.pendingBillApprovalNotification.preferredMode.length>0,h.pending_bill_approval_notification=Ln(u.pendingBillApprovalNotification)),d.pendingReimbursementApprovalNotification!=null&&(h.is_pending_reimbursement_approval_notification_active=u.pendingReimbursementApprovalNotification.preferredMode.length>0,h.pending_reimbursement_approval_notification=Ln(u.pendingReimbursementApprovalNotification)),h})(a,e);return r.putAndGetJSON(t,n).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[mR({data:o.data}),N({messageSection:"notification_settings_saved",messageText:"success",type:"success"})];return p(...c)}return p(gf(o.status))})),v((o=>p(gf(f("Unexpected error","Save Notification Settings REST API call errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(UP.match),A((t=>r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections/${t.payload.connectionId}`,{authorization_code:t.payload.credentials.authorization_code,client_id:t.payload.credentials.client_id,client_secret:t.payload.credentials.client_secret,connection_name:t.payload.connectionName,connection_type:t.payload.connectionType,redirect_uri:t.payload.credentials.redirect_uri},Object.assign({"zeni-tenant-id":t.payload.tenantId})).pipe(y((e=>{if(T(e))return _([kP(t.payload.tenantId,t.payload.connectionType,e.data)]);const a=e.status??f("Failed to save connection. Please try again.");return _([iu(t.payload.tenantId,a)])})),v((e=>{const a=e instanceof Error?e.message:"Unexpected error saving connection.";return _([iu(t.payload.tenantId,f(a))])})))))),(s,i,r)=>s.pipe(S(FD.match),y((t=>{const{isOnboardingCompleted:e,companyId:a,tenantId:n,isOnboardingTenant:o,userEmailWithPreOnboardSuccess:c,companyEmailDomain:d}=t.payload.onboardingCustomerCompletedStatus,l={company_email_domain:d,is_onboarding_completed:e,user_email_with_pre_onboard_success:c,is_onboarding_tenant:o};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/whitelist-companies`,l).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[qD(a),jD(n),GD(a),zD(a)];return _(m)}return p(NS(a,u.status))})),v((u=>p(NS(a,f("Unexpected error","Save Onboarding Customer Complete REST API call errored out"+JSON.stringify(u)))))))}))),(s,i,r)=>s.pipe(S(KD.match),y((t=>{const{companyId:e,note:a}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{note:a}).pipe(y((n=>{if(T(n)&&n.data!=null){const o=[rn({payload:n.data.companies,schema:{}}),YD(e)];return _(o)}return p(OS({companyId:e,error:n.status}))})),v((n=>p(OS({companyId:e,error:f("Unexpected error","Save Onboarding Customer Complete REST API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(WD.match),y((t=>{const{onboardingCockpitViewState:e}=i.value,{sendInvite:a,skipSnackbarOnSuccess:n}=t.payload,{onboardingCustomerLocalData:o}=e;if(o!=null){let c,d;const{companyId:l,tenantId:u}=o;l&&u&&(c=Mi(i.value.companyState,l??""),d=bS(i.value.tenantState,u??""));const m=((h,g,I,b)=>{const{companyId:E,companyEmailDomain:P,groupId:O,groupName:C,groupDescription:U,isEmailGroupCreated:B,customerName:x,name:k,email:J,accountingConnectionCreationMode:L,hubSpotId:R,selectedProducts:q}=h,$={company_email_domain:P,is_onboarding_tenant:!0,is_send_invite_to_users_with_access_to_onboarding:g,is_send_invite_to_customer:g,user_email_with_pre_onboard_success:J,name:k,customer_first_name:x?.firstName,customer_last_name:x?.lastName,customer_email:J,is_book_keeping_enabled:!1,is_banking_enabled:!1,is_card_enabled:!1,is_spend_management_enabled:!1,is_treasury_enabled:!1,is_other_products_enabled:!1,is_payroll_enabled:!1,is_cfo_enabled:!1,is_tax_enabled:!1};if(q!=null){const D=q.includes("zeni_checking"),w=q.includes("zeni_cards"),K=q.includes("bookkeeping"),G=q.includes("zeni_payroll"),Z=q.includes("zeni_cfo"),de=q.includes("zeni_tax"),ue=G||Z||de;if($.is_other_products_enabled=ue,$.is_payroll_enabled=G,$.is_cfo_enabled=Z,$.is_tax_enabled=de,ue)$.is_book_keeping_enabled=!1,$.is_banking_enabled=!1,$.is_spend_management_enabled=!1,$.is_card_enabled=!1;else{$.is_payroll_enabled=!1,$.is_cfo_enabled=!1,$.is_tax_enabled=!1;const te=q.includes("zeni_treasury");K?($.is_book_keeping_enabled=!0,$.is_banking_enabled=D,$.is_spend_management_enabled=!0,$.is_card_enabled=w,$.is_treasury_enabled=te):D&&w?($.is_book_keeping_enabled=!1,$.is_banking_enabled=!0,$.is_spend_management_enabled=!1,$.is_card_enabled=!0,$.is_treasury_enabled=te):w?($.is_book_keeping_enabled=!1,$.is_banking_enabled=!1,$.is_spend_management_enabled=!1,$.is_card_enabled=!0,$.is_treasury_enabled=!1):D?($.is_book_keeping_enabled=!1,$.is_banking_enabled=!0,$.is_spend_management_enabled=!1,$.is_card_enabled=!1,$.is_treasury_enabled=te):($.is_book_keeping_enabled=!1,$.is_banking_enabled=!1,$.is_spend_management_enabled=!1,$.is_card_enabled=!1,$.is_treasury_enabled=!1)}}return E&&($.company_id=E),R&&($.hubspot_id=R),L!=null&&($.accounting_connection_created_by=L),O&&B!=1&&($.email_group_id=O,$.email_group_name=C,$.email_group_description=U),dK(h,$,I,b),$})(o,a,c,d);return(m.company_id!=null?r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/whitelist-companies`,m):r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/whitelist-companies`,m)).pipe(y((h=>{if(T(h)&&h.data!=null){const g=h.data.companies.map((E=>E.company_id)),I=Di(h.data.tenants,h.data.companies),b=[Ji(h.data.tenants,!0),rn({payload:h.data.companies,schema:{},onboardingInviteStatus:h.data.onboarding_invite_status,companyIdTenantIdMapping:I}),z(h.data.addresses??[]),wi(h.data.tenants),$i({onboardingCustomersInfo:h.data.whitelist_companies}),Ri(g),ZD({tenants:h.data.tenants,companies:h.data.companies,sendInvite:a,newTenant:m.company_id==null})];if(h.data.users!=null&&b.push(V({users:h.data.users})),h.data.user_roles!=null&&b.push(Y(h.data.user_roles)),a===!0){const E=KE(h.data.companies[0].onboarding_info,h.data.users),P=h.data.companies[0].name??"";b.push(N({messageSection:"dashboard_invite_sent",messageText:"success",type:"success",variables:[{variableName:"_user-name_",variableValue:E},{variableName:"_company-name_",variableValue:P}]}))}return a!==!0&&n!==!0&&b.push(N({messageSection:"onboarding_info_saved",messageText:"success",type:"success"})),_(b)}{const g=[xS(h.status),N({messageSection:a===!0?"dashboard_invite_sent":"onboarding_info_saved",messageText:"failed",type:"error"})];return _(g)}})),v((h=>{const g=[xS(f("Unexpected Error","Save Onboarding Customer View Updates errored out"+JSON.stringify(h))),N({messageSection:a===!0?"dashboard_invite_sent":"onboarding_info_saved",messageText:"failed",type:"error"})];return _(g)})))}return _([])}))),(s,i,r)=>s.pipe(S(vL.match),y((t=>{const{entityId:e,entityType:a,realTimeApprovalLocalData:n}=t.payload,{userState:o}=i.value,c=jK(n),d=c.real_time_steps.map((u=>u.step_position)),l=a==="bill_pay"?"bill":a;return r.putAndGetJSON(`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/${l}s/entity-approvals`,c).pipe(y((u=>{if(T(u)&&u.data!=null){const m=[];u.data.entity_approval.steps_approval_status.forEach((I=>{I.step_position!=null&&d.indexOf(I.step_position)>=0&&I.actors.forEach((b=>{m.push(b.id)}))}));const h=m.map((I=>{const b=bt(o,I);return`${b?.firstName} ${b?.lastName}`})),g=u.data.attribute_users.map((I=>I.user_id));return _([yn(e,a,!0),Et([u.data.entity_approval]),V({users:u.data.attribute_users??[]}),N({messageSection:"real_time_approver_added",messageText:"success",type:"success",variables:[{variableName:"_approvers-added_",variableValue:h.join(", ")}]}),pd({entityId:e,entityType:a,approverIds:g,fetchState:"Completed"})])}return p(N({messageSection:"real_time_approver_added",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:u.status.message}]}),pd({entityId:e,entityType:a,fetchState:"Error",approverIds:[],error:f("Unexpected error","resources REST API call errored out"+JSON.stringify(u.status.message))}))})),v((u=>p(N({messageSection:"real_time_approver_added",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:u}]}),pd({entityId:e,entityType:a,fetchState:"Error",approverIds:[],error:f("Unexpected error","resources REST API call errored out"+JSON.stringify(u))})))))}))),(s,i,r)=>s.pipe(S(tA.match),y((t=>{const{companyId:e,auditGroupId:a,auditRuleId:n,reasonToPass:o,reasonStatus:c}=t.payload,d=i.value.companyState.companiesById[e].companyInfo.tenantId,l={reason_to_pass:o,reason_status:c,audit_rule_group_id:a},u={audit_rule_id:n},m=`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/reports/audit/reasons?query=${encodeURIComponent(JSON.stringify(u))}`;return r.putAndGetJSON(m,l,{"zeni-tenant-id":d}).pipe(y((h=>{if(M(h)&&h.data!=null){const g=[aA({companyId:e,auditGroupId:a,auditRuleId:n,reasonResponsePayload:h.data})];return c==="approved"&&g.push(is(!0,!0)),_(g)}return p(tp(e,a,n,f("Error","Invalid response status: "+h.status)))})),v((h=>p(tp(e,a,n,f("Unexpected Error","Reason for audit rule REST API call failed: "+JSON.stringify(h)))))))}))),(s,i,r)=>s.pipe(S(UL.match),y((t=>{const e=i.value,{remiStageCode:a,reimbursementId:n,isSubmitted:o}=t.payload,c=n!=null?e.editRemiDetailViewState.editRemiStateById[n]:e.editRemiDetailViewState.newRemiState,d=(function(l,u,m,h,g){const I=m.reimbursementId,b=X(l.reimbursementById,I??"",void 0),E={reimbursement_provider:"zeni",transaction_type:"reimbursement",is_include_approval_info:!0,reimbursee_user_id:b?.reimburseeUserId??u.loggedInUser?.userId,sync_token:b?.syncToken??null,reimbursement_date:me().format("YYYY-MM-DD"),due_date:null,currency_code:m.remiDetailLocalData.totalAmount?.currencyCode,report_title:m.remiDetailLocalData.whatForSection?.reportTitle,is_transaction_submitted:g,total_amount:m.remiDetailLocalData.totalAmount?.amount,reimbursement_info:{stage:{code:h},to_account:m.remiDetailLocalData.paymentTo!=null?{account_id:m.remiDetailLocalData.paymentTo}:void 0},lines:Object.keys(m.remiDetailLocalData.updatesByLineId).map((P=>{const O=m.remiDetailLocalData.updatesByLineId[P];return pI(O)}))};return I==null&&(E.are_approvals_serialized=!0),E})(e.reimbursementState,e.tenantState,c,a,o);return(n!=null?r.putAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions/${t.payload.reimbursementId}`,d):r.postAndGetJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/reimbursements/transactions`,d)).pipe(y((l=>{if(T(l)&&l.data?.transactions[0]?.transaction_id!=null){const u=[bd(l.data.transactions[0]),V({users:l.data.users??[]}),We(l.data.approval_rules),Et(l.data.entity_approvals),ud(l.data.merchants),uI(l.data.merchants),kL(),Ed("Completed",t.payload.reimbursementId),N({messageSection:a==="pending_approval"?"reimbursement_sent_for_approval":"reimbursement_updated",messageText:"success",type:"success"})];return l.data.merchants.forEach((m=>{const h=Hr(m.recommendations??[]);h!=null&&m.merchant_id&&u.push(wr({entityId:m.merchant_id,entityType:"merchant",recommendations:h}))})),_(u)}return p(Ed("Error",t.payload.reimbursementId,l.status),N({messageSection:a==="pending_approval"?"reimbursement_sent_for_approval":"reimbursement_updated",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))})),v((l=>p(Ed("Error",t.payload.reimbursementId,f("Unexpected Error",`REST API call errored out ${JSON.stringify(l)}`))))))}))),(s,i,r)=>s.pipe(S(XL.match),A((t=>{const{remiSetupApproverViewState:e}=i.value,a=e.remiSetupApproverViewUpdateData;if(a!=null&&a.data!=null){const{useV3:n}=t.payload,o=n?r0(a.data):s0(a.data),c=n?`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules-v2`:`${r.apiEndPoints.approvalMicroServiceBaseUrl}/1.0/reimbursements/approval-rules`;return r.postAndGetJSON(c,o).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.approval_rules.map((g=>g.approval_rule_id)),u=d.data.affected_entity_ids??[],m=d.data.new_approval_rule?.approval_rule_id,h=[V({users:d.data.users}),We(d.data.approval_rules),N({messageSection:`reimbursement_${a.type}`,messageText:"success",type:"success"}),eF(l,u,m)];return _(h)}{const l=[];return d.status.code===400?l.push(N({messageSection:`reimbursement_duplicate_${a.type}`,messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]})):l.push(N({messageSection:`reimbursement_${a.type}`,messageText:"failed",type:"error"})),l.push(AI(d.status)),_(l)}})),v((d=>p(AI(f("Unexpected Error","Save Reimbursement Approval View Updates errored out"+JSON.stringify(d)))))))}return _([])}))),(s,i,r)=>s.pipe(S(A$.match),y((t=>{const e=i.value,{scheduleAccruedDetailState:a}=e,{scheduleType:n}=t.payload,o=a.selectedJEAccruedScheduleKey,c=[];let d,l,u,m="";if(o!=null){if(u=sa(o,e),u!=null){l=u.jeScheduleId;const g=e.scheduleAccruedDetailState.editScheduleStateByDetailId[l];m=g.selectedVendor?.name??"",d={...t0(e,g,o)}}}else{const g=e.scheduleAccruedDetailState.newScheduleState;m=g.selectedVendor?.name??"",d={...PK(e,g)}}const h={je_schedule_type:n};return(l!=null?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${l}?query=${encodeURIComponent(JSON.stringify(h))}`,d):r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(h))}`,d)).pipe(y((g=>{if(T(g)&&g.data!=null){const I=g.data.je_schedules[0].je_schedule_id;if(I==null)return c.push(Rr("Error",g.status),N({messageSection:l!=null?"save_schedule":"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"Schedule returned NULL for ID."}]})),_(c);if(c.push(ca(g.data.je_schedules),br(g.data.je_schedules,g.data.scheduled_journal_entries)),l==null){const b=ef(g.data.je_schedules[0]),E=dn("accrued_expenses"),P=ln("all",E);c.push(N$({scheduleType:"accrued_expenses",key:P,jeScheduleAccruedKey:b}))}return c.push(Va(n,o,I),Rr("Completed"),O$(),N({messageSection:l!=null?"save_schedule":"create_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:m}]})),_(c)}return c.push(Rr("Error",g.status)),c.push(N({messageSection:l!=null?"save_schedule":"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]})),_(c)})),v((g=>_([N({messageSection:l!=null?"save_schedule":"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(g)}]}),Rr("Error",f("Unexpected Error",`Save Schedule Accrued Detail REST API call errored out ${JSON.stringify(g)}`))]))))}))),(s,i,r)=>s.pipe(S(L$.match),y((t=>{const e=i.value,{scheduleDetailState:a}=e,{selectedJeScheduleDetailId:n,scheduleType:o,isUpdatingVendorCategoryOrClass:c}=t.payload,d=a.selectedJEScheduleKey,l=[];if(d==null)return _(l);const u=ft(d,e),m=u.vendor.name,h=u.jeScheduleId??n,g=h!=null?e.scheduleDetailState.editScheduleStateByDetailId[o][h]:e.scheduleDetailState.newScheduleState[o],I={...ec(e,g,d,o,void 0,void 0,c)},b={je_schedule_type:o};return(h!=null&&u.status.code!=="marked_as_completed"?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/${h}?query=${encodeURIComponent(JSON.stringify(b))}`,I):r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules?query=${encodeURIComponent(JSON.stringify(b))}`,I)).pipe(y((E=>{if(T(E)&&E.data!=null){const P=E.data.je_schedules[0].je_schedule_id;return P==null?(l.push(Vr("Error",E.status),N({messageSection:h!=null?"save_schedule":"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:"Schedule returned NULL for ID."}]})),_(l)):(l.push(ut(E.data.je_schedules),St(E.data.je_schedules,E.data.scheduled_journal_entries),Mr(o,d,P),Vr("Completed"),N({messageSection:h!=null?"save_schedule":"create_schedule",messageText:"success",type:"success",variables:[{variableName:"_vendor_name_",variableValue:m}]})),_(l))}return l.push(Vr("Error",E.status)),l.push(N({messageSection:h!=null?"save_schedule":"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:E.status.message}]})),_(l)})),v((E=>_([N({messageSection:h!=null?"save_schedule":"create_schedule",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(E)}]}),Vr("Error",f("Unexpected Error",`Save Schedule Detail REST API call errored out ${JSON.stringify(E)}`))]))))}))),(s,i,r)=>s.pipe(S(BT.match),y((t=>{const{draft:e,macroId:a}=t.payload,n=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills`,o={name:e.name,instructions:e.instructions,description:e.description,display_name:e.name,...e.visibility!=null&&{visibility:e.visibility}};return(a!=null&&a!==""?r.putAndGetJSON(`${n}/${encodeURIComponent(a)}`,o):r.postAndGetJSON(n,o)).pipe(y((c=>{if(T(c)&&gl(c.data)){const d=c.data,l=d.skill.macro_id,u=[DT({macroId:l,detail:fl(d)}),po()];return JT(i.value).macroId===l&&u.push(wu({macroId:l})),p(...u)}return p(Vu(c.status))})),v((c=>p(Vu(f("Unexpected Error","Save skill REST API call failed",c instanceof Error?{message:c.message}:void 0))))))}))),(s,i,r)=>s.pipe(S(nq.match),y((t=>{const{tenantId:e,subscriptionSummaryId:a,updates:n}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscription-summaries/${a}`,n,{"zeni-tenant-id":e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[Sa({payload:[o.data]}),Kd({tenantId:e})];return _(c)}return p(kn({tenantId:e,status:o.status}))})),v((o=>p(kn({tenantId:t.payload.tenantId,status:f("Unexpected error","Connection REST API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(oq.match),y((t=>{const{tenantId:e}=t.payload,a=i.value.subscriptionViewState.subscriptionUpdateViewDataByTenantId[e];if(a!=null&&a.data!=null&&a.data.subscriptionEstmiate!=null){const n=a.type==="subscription_update";let o,c;if(n){const d=a.data,{subscriptionId:l}=d;o=u0(d,e),c=r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions/${l}`,o)}else{const d=a.data;o=p0(d,e),c=r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/subscriptions`,o)}return c.pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.subscriptions[0],u=l.company_id,m=[lr({payload:d.data.subscriptions,schema:d.data.schema.subscription}),_a({payload:d.data.subscription_plans,schema:d.data.schema.subscription_plan}),ur({payload:d.data.subscription_coupons,schema:d.data.schema.subscription_coupon}),ha({payload:d.data.subscription_addons,schema:d.data.schema.subscription_addon}),Sa({payload:d.data.subscription_summaries,schema:d.data.schema.subscription_summary})];return n?m.push(Kd({tenantId:e,companyId:u})):m.push(Kd({tenantId:e,companyId:u,subscriptionId:l.subscription_id})),_(m)}return p(kn({tenantId:e,status:d.status}))})),v((d=>p(kn({tenantId:e,status:f("Unexpected error",`Unable to ${n?"update":"create"} subscription`+JSON.stringify(d))})))))}return _([])}))),(s,i,r)=>s.pipe(S(Cq.match),y((t=>{const{taskId:e,taskGroupId:a}=t.payload,n=i.value,o=n.taskListState.fetchState==="Completed",c=e!=null?n.taskDetailState.editTaskStateById[e]?.taskDetailLocalData?.taskGroupId:void 0,d=e!=null&&c===null,l=e!=null?Za(n.taskState,e)?.taskGroupIds??[]:[],u=d?[]:c!=null?[c]:e!=null?l:a!=null?[a]:[],m=u[0],h=nY(n,e,u);return(e!=null?r.putAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${e}`,h):r.postAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks`,h)).pipe(y((g=>{if(T(g)&&g.data!=null&&g.data.tasks.length>0){const I=g.data.tasks[0].task_id,b=[ze(g.data.tasks),tl({fetchState:"Completed",newTaskId:I,taskId:e})],E=g.data.tasks[0],P=E.status?.code==="resolved",O=n.taskListState.currentTab;return o===!0&&d===!1&&m!=null&&(!(O==="live"||O==="completed")||P&&O==="completed"||!P&&O==="live")===!0?b.push(fb({taskGroupId:m,task:g.data.tasks[0],currentTaskState:e!=null?Za(n.taskState,e):void 0})):o===!0&&d===!0&&e!=null&&Za(n.taskState,e)?.taskGroupIds.forEach((U=>{b.push(xq({taskId:e,taskGroupId:U}))})),_(b)}return p(tl({fetchState:"Error",taskId:e,error:g.status}),N({messageSection:"save_task_detail",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:g.status.message}]}))})),v((g=>p(tl({fetchState:"Error",taskId:e,error:f("Unexpected Error","Save Task REST API call errored out"+JSON.stringify(g))})))))}))),(s,i)=>s.pipe(S(Ap.match),y((r=>{const{transactionId:t,cotTransactionTracking:e,isExpenseAutomationEnabled:a}=r.payload,n=[],o=i.value.transactionDetailState,c=i.value.transactionState,d=Ms(i.value),l=Be(t),u=X(o.transactionDetailById,l,void 0),m=At(c,l);if(u!=null&&m!=null){const h=((g,I,b,E=!1)=>{const P={updatesByLineId:{}},O={},C={},U=H0(I,b);P.memo=g.memo,P.documentId=g.documentId,!E||I.type!=="invoice"&&I.type!=="credit_memo"||(P.project=g.project);const B=g.selectedEntity,x=g.updatePreviousTransactionsWithUpdatedVendor===!0?g.vendorUpdates?.qboId:void 0;let k,J,L=!1;const R=new Set(I.lines?.map((D=>D.id))??[]),q=new Set((g.deletedLineIds??[]).filter((D=>R.has(D)))),$=Object.values(g.lineItemById).filter((D=>!R.has(D.id)));return I.lines?.forEach((D=>{if(q.has(D.id))return;const w=g.lineItemById[D.id];if(D.type==="transaction_with_account_and_class_line"||D.type==="transaction_with_product_or_service_line"||D.type==="journal_entry_transaction_line"){if(w==null)return;const K=Hz(B,w,g.vendorUpdates,g.customerUpdates);if(O[D.id]={lineDescription:w.lineDescription,amount:w.amount,class:w.class,account:w.account,...I.type!=="invoice"&&I.type!=="credit_memo"?{project:w.project}:{},recommendation:I0(w.recommendationsWithCOT)},D.type==="journal_entry_transaction_line"||D.platformLineDetailType==="deposit_line_detail"){const fe=w.lineEntity;O[D.id]={...O[D.id],customer:fe!=null&&fe.type==="customer"?w.customer:void 0,vendor:fe!=null&&fe.type==="vendor"?w.vendor:void 0,...D.type==="journal_entry_transaction_line"?{postingType:w.postingType,postingTypeName:w.postingType!=null?w.postingType.charAt(0).toUpperCase()+w.postingType.slice(1):w.postingTypeName}:{}}}let G=!1,Z=!1;const de=D;G=w.account?.qboId!==de.account.qboId&&!!w.account?.qboId,Z=(w.class?.qboId!=null||de.class?.qboId!=null)&&w.class?.qboId!==de.class?.qboId;const ue=K0(w.amount.amount,w.account),te=Y0(w.amount.amount,w.class),ye=w.recommendedAccount,_e=w.recommendedClass,Ve=!!ue&&!!ye&&ue?.qboId===ye?.qboId,Ae=!!te&&!!_e&&te?.qboId===_e?.qboId,pe=(w.isRecommendedCategorySelected===!1||w.isRecommendedClassSelected===!1||Ve===!1||Ae===!1)&&w.recommendationsWithCOT!=null&&(G||Z);if(L=L||(w.isUpdateAllChecked??!1),K!=null&&(pe===!0||w.isUpdateAllChecked!=null&&w.isUpdateAllChecked===!0||x!==null)){k=G===!0||w.isRetainedCategorySelected===!0?ue:void 0,J=Z===!0||w.isRetainedClassSelected===!0?te:void 0;const fe={account:k,class:J};if(fe.class!=null||fe.account!=null||x!=null){const na=g.vendorUpdates?.qboId,oa=g.customerUpdates?.qboId;let ia=K.entityId;na!=null&&B?.type==="vendor"?ia=g.updatePreviousTransactionsWithUpdatedVendor===!0?ia:na:oa!=null&&B?.type==="customer"&&(ia=oa),Yz(C,ia,K.entityType,fe,w.isUpdateAllChecked,x,K.entityName)}}}else O[D.id]=D})),P.updatesByLineId=O,{updates:P,entityRelatedUpdates:C,markAsMiscatUpdates:U,anyBulkUpdates:L,addedLines:$.length>0?$:void 0,deletedLineIds:q.size>0?[...q]:void 0}})(u.transactionDetailLocalData,m,a,d);return n.push(Lb(t,h,a,e)),_(n)}return _(n)}))),(s,i,r)=>s.pipe(S(LA.match),y((t=>{const e=i.value,{expenseAutomationTransactionsViewState:a,accountState:n,accountListState:o}=e,{selectedTransactionCategorizationTab:c,transactionCategorizationView:d}=a,{selectedTransactionId:l,selectedTransactionLineId:u}=d[c],m=pa(n,o,"accountList"),h=e.transactionVendorViewState.newVendorState?.vendorDetailLocalData?.vendorId,g=t.payload.vendorId!=null?e.transactionVendorViewState.editVendorStateById[t.payload.vendorId].vendorDetailLocalData:e.transactionVendorViewState.newVendorState.vendorDetailLocalData,I=t.payload.vendorId!=null?t.payload.vendorId:h,b=((E,P,O)=>{const{vendorState:C,accountState:U,classState:B}=E,x={};if(P!=null&&(x.vendor_name=P.vendorName),O!=null){const k=C.vendorByID[O].syncToken;x.sync_token=k,x.qbo_id=C.vendorByID[O].qboId}else{if(P.vendorCategory!=null){const k=Ze(U,P.vendorCategory,"account_list");k!=null&&(x.account=Qr(k))}else x.account=null;if(P.vendorClass!=null){const k=Xa(B,{classId:P.vendorClass,reportId:"class_list"});k!=null&&(x.accounting_class=Wr(k))}else x.accounting_class=null;P.vendorOwner!=null?x.owner_id=P.vendorOwner:x.owner_id=null}return x})(e,g??jA,I);return(I!=null?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${I}`,b):r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors`,b)).pipe(y((E=>{if(T(E)&&E.data!=null){const P=[le(E.data.vendors??[])];if(P.push(ls({vendorId:E.data.vendors[0].vendor_id,localData:{vendorName:E.data.vendors[0].vendor_name,vendorId:E.data.vendors[0].vendor_id}})),I==null&&t.payload.transactionId!=null&&E.data!=null){if(t.payload.isExpenseAutomationEnabled===!0){if(l!=null&&u!=null){const O=At(e.transactionState,l);O!=null&&P.push(FA({selectedTab:c,transactionId:l,lineId:u,selectedTransaction:O,uncategorizedAccounts:m,isAccountingClassesEnabled:pt(e),updatedVendor:{name:E.data.vendors[0].vendor_name,id:E.data.vendors[0].qbo_id,logo:Oo(E.data.vendors[0].logo?.url??"")},selectedEntity:{name:E.data.vendors[0].vendor_name,id:E.data.vendors[0].qbo_id,type:"vendor",zeniId:E.data.vendors[0].vendor_id,qboId:E.data.vendors[0].qbo_id,logo:Oo(E.data.vendors[0].logo?.url??"")}}))}}else P.push(qA({transactionId:t.payload.transactionId,vendorUpdates:{name:E.data.vendors[0].vendor_name,id:E.data.vendors[0].vendor_id,qboId:E.data.vendors[0].qbo_id},entity:{name:E.data.vendors[0].vendor_name,id:E.data.vendors[0].qbo_id,type:"vendor",zeniId:E.data.vendors[0].vendor_id,qboId:E.data.vendors[0].qbo_id,logo:Oo(E.data.vendors[0].logo?.url??"")},resetRecommendations:!0}));P.push(N({messageSection:"create_vendor",messageText:"success",type:"none"}))}return P.push(Co("Completed",t.payload.vendorId)),t.payload.saveTransaction===!0&&t.payload.transactionId!=null&&P.push(Ap({transactionId:t.payload.transactionId,isExpenseAutomationEnabled:t.payload.isExpenseAutomationEnabled,cotTransactionTracking:[]})),_(P)}{const P=[];return P.push(Co("Error",t.payload.vendorId,E.status)),E.status.code!==409&&P.push(N({messageSection:I==null?"create_vendor":"update_vendor",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:E.status.message}]})),_(P)}})),v((E=>p(Co("Error",t.payload.vendorId,f("Unexpected Error",`Save Transaction Vendor REST API call errored out ${JSON.stringify(E)}`))))))}))),(s,i,r)=>s.pipe(S(sG.match),y((()=>{const{vendorFirstReviewViewState:t}=i.value,e=t.vendorLocalData?.vendorDetails,a=(o=>{const c={};return c.qbo_id=o?.qboId,o?.websiteUrl!=null&&(c.website_url=o.websiteUrl.toString()),c})(e),n=t.vendorLocalData?.vendorDetails.id;return n!=null?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${n}`,a).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[le(o.data.vendors)];return c.push(ll({vendorId:n,fetchState:"Completed"})),_(c)}{const c=[];return o.status.code!==409&&(c.push(ll({vendorId:n,fetchState:"Error"})),c.push(N({messageSection:"update_vendor",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:o.status.message}]}))),_(c)}})),v((o=>p(ll({vendorId:n,fetchState:"Error",error:f("Unexpected Error","Vendor Save on First Review View REST API call errored out "+JSON.stringify(o))}))))):_([])}))),(s,i,r)=>s.pipe(S(kt.match),y((t=>{const e=i.value,a=e.vendorViewState.newVendorState?.vendorDetailLocalData?.vendorId,n=t.payload.vendorId!=null?e.vendorViewState.editVendorStateById[t.payload.vendorId].vendorDetailLocalData:e.vendorViewState.newVendorState.vendorDetailLocalData,o=t.payload.vendorId??a,c=((x,k,J)=>{const{accountState:L,classState:R,addressViewState:q,vendorState:$}=x,D={};if(k!=null){if(D.vendor_name=k.vendorName,k.vendorCategory!=null){const Z=Ze(L,k.vendorCategory,"account_list");Z!=null&&(D.account=Qr(Z))}else D.account=null;if(k.vendorClass!=null){const Z=Xa(R,{classId:k.vendorClass,reportId:"class_list"});Z!=null&&(D.accounting_class=Wr(Z))}else D.accounting_class=null;k.vendorType!=null&&(D.vendor_type=k.vendorType),k.vendorOwner!=null?D.owner_id=k.vendorOwner:D.owner_id=null,k.isVendor1099!=null&&(D.is_vendor_1099=k.isVendor1099),k.documentIds!=null&&(D.document_ids=k.documentIds)}const w=k.contacts??[];if(D.contacts=w.filter((Z=>Z.email.length>0||Z.fullName.length>0)).map((Z=>hs(Z))),J!=null){const Z=$.vendorByID[J].syncToken;D.bank_account_ids=[...new Set(k.bankAccountIds)],D.payment_instrument_ids=[...new Set(k.paymentInstrumentIds)],D.sync_token=Z,D.qbo_id=$.vendorByID[J].qboId}else D.bank_account_ids=k.bankAccountIds,D.payment_instrument_ids=k.paymentInstrumentIds;const K=q.newAddressState?.vendor_address?.addressToCreate,G=K!=null?xe(K):void 0;return G!=null&&(D.address=G),k.countryCode!=null&&(D.country_code=k.countryCode),k.currencyCode!=null&&(D.vendor_currency_code=k.currencyCode),k.currencySymbol!=null&&(D.vendor_currency_symbol=k.currencySymbol),D.is_two_factor_verification_required=!0,D})(e,n??ZA,o);let d=e.editBillDetailViewState.newBillState;const{tenantState:l,companyState:u,expressPayState:m}=e,{currentTenantId:h}=l,g=h!=null?l.tenantsById?.[h]?.companyId:void 0,I=Te(u,g??""),b=I?.company.companyBillPayInfo.payNowCutOffTimeByMethod.ach,E=b!=null&&me().isSameOrBefore(b),P=m.formLocalData;if(t.payload.billId!=null){const x=Ne(t.payload.billId);d=e.editBillDetailViewState.editBillStateById[x]}const O=d.billDetailLocalData.isCancelled,C=d.billDetailLocalData.updatesByLineId,U=o!=null?r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${o}`,c):r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors`,c),B=e.tenantState.loggedInUser?.userId??"";return U.pipe(y((x=>{if(T(x)){const k=x.data?.vendors[0]!=null?or(x.data?.vendors[0]):void 0,J={...C};if(k!=null){const q=k.accountId!=null?Ze(e.accountState,k.accountId,"account_list"):void 0,$=k.classId!=null?Up(e.classState,{classId:k.classId,reportId:"class_list"}):void 0,D=k.vendorCurrencyCode,w=k.vendorCurrencySymbol;Object.keys(J).forEach((K=>{const G=C[K];J[K]={...G,account:q,class:$,...es}})),Object.keys(J).length===0&&(J[1]={account:q,class:$,amount:{amount:0,currencyCode:D,currencySymbol:w},recipientAmount:{amount:0,currencyCode:D,currencySymbol:w},id:"1",lineDescription:"",platformLineDetailType:"account_based_expense_line_detail",type:"transaction_with_account_and_class_line",billable:"not_billable",isCategoryMiscategorized:!1,isClassMiscategorized:!1,...es})}const L=dt(x.data?.vendors??[]),R=[le(x.data?.vendors??[]),mt(x.data?.vendors[0].contacts??[]),z(L),Je(x.data?.vendors[0].bank_accounts??[]),la(x.data?.vendors[0].payment_instruments??[])];if(t.payload.view!=="vendorsTab"){k?.vendorCurrencyCode==null||Uo(k.vendorCurrencyCode)||R.push(ya(!0,{amount:d.billDetailLocalData.totalAmount?.amount??0,currencyCode:k.vendorCurrencyCode??"USD",currencySymbol:k.vendorCurrencySymbol??"$"},"USD",t.payload.billId));const q=d.billDetailLocalData.showVendorGptRecommendationText,$=d.billDetailLocalData.recommendedVendorId,D=d.billDetailLocalData.vendor?.id,w=d.addBillAutoFields.tentativeVendorName;let K;K=$!=null&&$===k?.id||(D==null||k?.id==null||D===k.id)&&q,w&&w===k?.name&&(K=!0,R.push(Ss({addBillAutoFields:{...d.addBillAutoFields,tentativeVendorName:""}})),$==null&&R.push(WA(k?.id))),t.payload.isExpressPayPage!==!0&&(R.push(lt({billDetailLocalData:{showVendorGptRecommendationText:K,vendor:k,isCancelled:O,updatesByLineId:J,whatForSection:{...d.billDetailLocalData.whatForSection,currencyCode:k?.vendorCurrencyCode,recipientCurrencyCode:k?.vendorCurrencyCode},paymentDetailsSection:{...d.billDetailLocalData.paymentDetailsSection,paymentTo:void 0,internationalTransferFeeBearerPaymentMethod:k?.preferredInternationalTransferFeeBearerPaymentMethod,paymentDate:d.billDetailLocalData.paymentDetailsSection?.paymentDate??ee(eo(me().toDate(),[0,6],E?0:1).toISOString())},isCollectToAccountInfoFromVendorContact:!1,isRecurring:d.billDetailLocalData.isRecurring},billId:t.payload.billId})),k?.qboId!=null&&R.push(aa(k.qboId,!1)))}return t.payload.isExpressPayPage!==!0&&R.push(xp(t.payload.vendorId)),R.push(ir("Completed",t.payload.vendorId)),t.payload.view==="vendorsTab"&&R.push(N({messageSection:"update_vendor",messageText:"success",type:"success"})),t.payload.isExpressPayPage===!0&&t.payload.vendorId==null&&k!=null&&(R.push(nr({vendorId:k.id,localData:wn(k,i.value,x.data?.vendors[0])})),R.push(ir("Completed",k.id)),R.push(So({localData:{...P,vendorId:k.id,amount:P?.amount??{amount:0,currencyCode:k.vendorCurrencyCode,currencySymbol:k.vendorCurrencySymbol},paymentDate:P?.paymentDate??me()}}))),_(R)}return x.data?.error_code===1001?p(ir("Error",t.payload.vendorId,x.status,!0),kp({userId:B})):p(ir("Error",t.payload.vendorId,x.status),N({messageSection:"update_vendor",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:x.status.message}]}))})),v((x=>p(ir("Error",t.payload.vendorId,f("Unexpected Error",`REST API call errored out ${JSON.stringify(x)}`))))))}))),(s,i,r)=>s.pipe(S(nG.match),y((t=>{const{vendorFirstReviewViewState:e,globalMerchantState:a,vendorState:n}=i.value,{vendorId:o,markAsEmployee:c,markAsLocalContractor:d}=t.payload,l=e.vendorFirstReviewViewLocalDataById[o].vendorFirstReviewViewLocalData,u=Oe(n,o),{vendorName:m,selectedGlobalMerchant:h,recommendations:g,nonExistingRecommendations:I}=NY(l,a,n),b={...AY(m,g,I,c,d,u?.qboId,h)};return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${o}?query=${encodeURIComponent(JSON.stringify({view:"merchant_review_list"}))}`,b).pipe(y((E=>{if(T(E)&&E.data!=null){const P=[];return P.push(le(Fn(E.data.vendors??[])),V({users:qn(E.data.vendors??[]),updateType:"merge"}),It({globalMerchants:jn(E.data.vendors??[])})),P.push(ul({vendorId:o,vendors:E.data.vendors??[]})),P.push(Kr("Completed",t.payload.vendorId,c,d,E.status,E.data.vendors?.[0].status)),u!=null&&(E.data.vendors?.[0].status.code==="reviewed"?P.push(N({messageSection:"save_vendor_renamed",messageText:"success",type:"success",variables:[{variableName:"_old_vendor_name_",variableValue:u?.name},{variableName:"_updated_vendor_name_",variableValue:m}]})):P.push(N({messageSection:b.is_employee===!0?"save_vendor_marked_as_employee":b.is_local_contractor===!0?"save_vendor_marked_as_local_contractor":"save_vendor_sent_for_review",messageText:"success",type:b.is_employee===!0||b.is_local_contractor===!0?"success":"info",variables:[{variableName:"_vendor_name_",variableValue:u?.name}]}))),_(P)}if(E.status.code===409&&E.data!=null){const P=[];if(P.push(ul({vendorId:o,vendors:E.data.vendors??[]})),P.push(Kr("Error",t.payload.vendorId,c,d,E.status)),P.push(le(Fn(E.data.vendors??[])),V({users:qn(E.data.vendors??[]),updateType:"merge"}),It({globalMerchants:jn(E.data.vendors??[])})),E.status.details==null)P.push(pl({vendorId:t.payload.vendorId,vendorNameSentForReview:m,isVendorMergeError:!0}));else if(E.status.details!=null){let O;g.length>0&&g[0]?.globalMerchants?.[0]!=null?O={...g[0].globalMerchants[0],isReviewed:!1,globalMerchantNameInLowerCase:g[0].globalMerchants[0].globalMerchantName.toLowerCase()}:I.length>0&&I[0]?.globalMerchants?.[0]!=null&&(O={...I[0].globalMerchants[0],isReviewed:!1,globalMerchantNameInLowerCase:I[0].globalMerchants[0].globalMerchantName.toLowerCase()});const C=E.data.vendors?.[0]?.recommendations?.[0]?.global_merchants?.[0]!=null?{...oG(E.data.vendors?.[0]?.recommendations?.[0]?.global_merchants?.[0]),globalMerchantId:E.data.vendors?.[0]?.recommendations?.[0]?.global_merchants?.[0]?.global_merchant_id}:void 0;P.push(pl({vendorId:t.payload.vendorId,vendorNameSentForReview:m,isVendorMergeError:!1,oldRecommendation:O,newRecommendation:C}))}return _(P)}if(E.status.code===400&&E.status.message.includes("There is already a vendor using that entity name.")){const P=[];return P.push(ul({vendorId:o,vendors:E.data&&E.data.vendors?E.data.vendors:[]})),P.push(Kr("Error",t.payload.vendorId,c,d,E.status)),P.push(le(Fn(E.data&&E.data.vendors?E.data.vendors:[])),V({users:qn(E.data&&E.data.vendors?E.data.vendors:[]),updateType:"merge"}),It({globalMerchants:jn(E.data&&E.data.vendors?E.data.vendors:[])})),E.status.details==null&&P.push(pl({vendorId:t.payload.vendorId,vendorNameSentForReview:m,isVendorMergeError:!0})),_(P)}return p(Kr("Error",t.payload.vendorId,c,d,E.status),N({messageSection:"save_vendor_sent_for_review",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:E.status.message}]}))})),v((E=>p(Kr("Error",t.payload.vendorId,c,d,f("Unexpected Error",`Save Vendor First Review View REST API call errored out ${JSON.stringify(E)}`))))))}))),(s,i,r)=>s.pipe(S(rN.match),y((t=>{const e=i.value,a=e.vendorsTabVendorViewState.vendorStateById[t.payload.vendorId].vendorDetailLocalData,n=t.payload.vendorId,o=((c,d,l)=>{const{accountState:u,classState:m,addressViewState:h,vendorState:g}=c,I={};if(d!=null){if(I.vendor_name=d.vendorName,I.legal_name=d.legalName,d.vendorCategory!=null){const O=Ze(u,d.vendorCategory,"account_list");O!=null&&(I.account=Qr(O))}else I.account=null;if(d.vendorClass!=null){const O=Xa(m,{classId:d.vendorClass,reportId:"class_list"});O!=null&&(I.accounting_class=Wr(O))}else I.accounting_class=null;d.vendorOwner!=null?I.owner_id=d.vendorOwner:I.owner_id=null,d.vendorEmail!=null&&(I.email=d.vendorEmail),d.vendorPhone!=null&&(I.phone=d.vendorPhone),d.vendorType!=null&&(I.vendor_type=d.vendorType),d.tin!=null?I.tin={type:d.tin.type,value:d.tin.value}:I.tin=null}const b=d.contacts??[];I.contacts=b.filter((O=>O.email.length>0||O.fullName.length>0||O.phone.length>0)).map((O=>hs(O)));const E=h.newAddressState?.vendor_address.addressToCreate,P=E!=null?xe(E):void 0;if(P!=null&&(I.address=P),l!=null){const O=g.vendorByID[l].syncToken;I.sync_token=O,I.qbo_id=g.vendorByID[l].qboId}return I})(e,a??sN,n);return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${n}`,o).pipe(y((c=>{if(T(c)){const d=dt(c.data?.vendors??[]),l=gs(c.data?.vendors??[]),u=[le(c.data?.vendors??[]),mt(c.data?.vendors[0].contacts??[]),z(d),Je(l)];return u.push(wp(t.payload.vendorId)),u.push(wo("Completed",t.payload.vendorId)),u.push(N({messageSection:"update_vendor",messageText:"success",type:"success"})),_(u)}return p(wo("Error",t.payload.vendorId,c.status),N({messageSection:"update_vendor",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}))})),v((c=>p(wo("Error",t.payload.vendorId,f("Unexpected Error",`Vendors tab save REST API call errored out ${JSON.stringify(c)}`))))))}))),(s,i,r)=>s.pipe(S(NO.match),y((t=>{const{tenantId:e}=t.payload,a=`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/crons/cards/tenant-credit-score`,n=e!=null?{tenant_id:e}:{};return r.postAndGetJSON(a,n).pipe(y((o=>T(o)?_([OO(e),N({messageSection:"credit_agent_schedule_cron",messageText:"success",type:"success"})]):_([Jm(e,o.status),N({messageSection:"credit_agent_schedule_cron",messageText:"failed",type:"error"})]))),v((o=>_([Jm(e,f("Unexpected error","REST API call errored out: "+JSON.stringify(o))),N({messageSection:"credit_agent_schedule_cron",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>{const t=s.pipe(S(xx.match)),e=t.pipe(S((o=>o.payload.pageToken!=null))),a=t.pipe(S((o=>o.payload.pageToken==null&&o.payload.query.trim().length<2))),n=t.pipe(S((o=>o.payload.pageToken==null&&o.payload.query.trim().length>=2)),si(300));return vt(e,a,n).pipe(A((o=>{const{query:c,pageToken:d}=o.payload;if(d==null&&c.trim().length<2)return F;const l=i.value,{expenseAutomationMissingReceiptsViewState:{bulkUpload:{manualSearch:u,sortKey:m,sortOrder:h}}}=l,{end:g,start:I}=Al(90),b=h??"descending",E={start_date:I,end_date:g,auto_categorized:!1,sort_by:ui(m??"date"),sort_order:b==="ascending"?"asc":"desc",page_token:d??null,page_size:u.pageSize,search_text:c,sub_tab:li};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/expense-automation/transactions?query=${encodeURIComponent(JSON.stringify(E))}`).pipe(y((P=>{if(T(P)&&P.data!=null){const{transactions:O,next_page_token:C,total_count:U}=P.data,B=d!=null,x=O.map(Ux),k=[Ce(O,(J=>J.transaction_id),"merge"),kx({append:B,nextPageToken:C??null,results:x,totalCount:U})];return _(k)}return p($y({error:P.status}))})),v((P=>p($y({error:f("Unexpected Error","Search transactions for manual match errored: "+JSON.stringify(P))})))))})))},(s,i,r)=>{const t=s.pipe(S(QC.match)),e=t.pipe(S((n=>n.payload.query.trim().length<ni))),a=t.pipe(S((n=>n.payload.query.trim().length>=ni)),si(300));return vt(e,a).pipe(A((n=>{const o=n.payload.query.trim();if(o.length<ni)return F;const c={page_size:20,search_text:o,je_schedule_type:n.payload.scheduleType};return r.getJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/schedules/base_transaction_search?query=${encodeURIComponent(JSON.stringify(c))}`).pipe(y((d=>{if(T(d)&&d.data!=null){const{transactions:l}=d.data,u={};l.forEach((h=>{const{currency_code:g,currency_symbol:I}=h,b=g??"USD",E=u[b];u[b]=E!=null?{currencySymbol:E.currencySymbol,transactions:[...E.transactions,h]}:{currencySymbol:g==null?"$":I,transactions:[h]}}));const m=Object.keys(u).map((h=>{const g=u[h];return eu(g.transactions,h,g.currencySymbol,"merge")}));return m.push(WC({searchResults:l.map((h=>Ey({id:h.transaction_id,type:Py(h.transaction_type),lineId:h.line_id})))})),_(m)}return p(Ty({status:d.status}))})),v((d=>p(Ty({status:f("Unexpected Error","Search transactions for new schedule errored: "+JSON.stringify(d))})))))})))},(s,i)=>s.pipe(y((r=>{if(Pn.match(r)&&r.payload.fetchState==="Completed")return p(VV());if(!(c=>Av.match(c)||mo.match(c))(r))return F;const t=i.value,e=((c,d)=>d.payload.questionAnswerId!=null?d.payload.questionAnswerId:c.aiCfoState.aiCfoByChatSessionId[d.payload.chatSessionId]?.questionAnswers.slice(-1)[0]?.questionAnswerId)(t,r);if(e==null)return F;const a=((c,d,l)=>{const u=Nv(c.aiCfoState,d,l),m=u?.responses.answer?.content.visualization;if(m?.type!=="interactive_form")return;const h=m.data;return"formType"in h&&h.formType==="cards_creation"?h.payload:void 0})(t,r.payload.chatSessionId,e);if(a==null)return F;const n=l0(t);if(n.length>0)return p(Zv(n,a));const o=i.pipe(nt(l0),Tv(((c,d)=>c.length===d.length&&c.every(((l,u)=>l===d[u])))),S((c=>c.length>0)),Ue(1),nt((c=>Zv(c,a))));return t.userListViewState.userListByType.cardHolderCandidate.fetchState==="In-Progress"?o:j(p($e("cardHolderCandidate",!1)),o)}))),(s,i)=>s.pipe(y((r=>{if((o=>vn.match(o)&&o.payload.fetchState==="Completed")(r))return p(NM());if(!(o=>Av.match(o)||mo.match(o))(r))return F;const t=i.value,e=((o,c)=>c.payload.questionAnswerId!=null?c.payload.questionAnswerId:o.aiCfoState.aiCfoByChatSessionId[c.payload.chatSessionId]?.questionAnswers.slice(-1)[0]?.questionAnswerId)(t,r);if(e==null)return F;const a=((o,c,d)=>{const l=Nv(o.aiCfoState,c,d),u=l?.responses.answer?.content.visualization;if(u?.type!=="interactive_form")return;const m=u.data;return"formType"in m&&m.formType==="card_policy"?m.payload:void 0})(t,r.payload.chatSessionId,e);if(a==null)return F;if(c0(t))return p(d0(t,a));const n=i.pipe(nt((o=>c0(o))),Tv(),S((o=>o)),Ue(1),nt((()=>d0(i.value,a))));return t.cardPolicyState.mccCategoriesFetchState==="In-Progress"?n:j(p(Ev()),n)}))),(s,i)=>s.pipe(S(P_.match),Le(i),y((([r,t])=>{const{id:e}=r.payload,a=lk(t.invoicingPlanState,e);return a==null?F:p(uk({id:e,localData:pk(a)}))}))),(s,i)=>s.pipe(S(B_.match),Le(i),y((([r,t])=>{const{id:e}=r.payload,a=fk(t.invoicingCouponState,e);return a==null?F:p(vk({id:e,localData:Ik(a)}))}))),(s,i)=>s.pipe(S(bi.match),Le(i),y((([r,t])=>{const{id:e}=r.payload,a=q_(t.invoicingCustomerState,e);return a==null?F:p(xk({id:e,localData:Uk(a)}))}))),(s,i)=>s.pipe(S(Ti.match),Le(i),y((([r,t])=>{const{id:e}=r.payload,a=Fk(t,e);return a==null?F:p(qk({id:e,localData:jk(a)}))}))),(s,i,r)=>s.pipe(S(bN.match),y((t=>{const{companyId:e,fileId:a,tenantId:n}=t.payload,o=i.value,c=o.companyMonthEndReportViewState.monthEndReportDataByCompanyId[e].companyMonthEndReportData.recipientEmailList,d=o.companyMonthEndReportViewState.monthEndReportDataByCompanyId[e].companyMonthEndReportData.subject,l=o.companyMonthEndReportViewState.monthEndReportDataByCompanyId[e].companyMonthEndReportData.zeniRequestsHtml,u=o.companyState.companiesById[e],m=o.companyState.companiesById[e].companyInfo.name,h=n??u.companyInfo.tenantId,g=Qp(me()),I=me(),b=[];if(a!=null&&a!=null){const P=Wp(o.fileState,a);P!=null&&b.push({data:P.base64String,id:P.fileId,name:P.fileName})}const E={template_data:EE(o.companyMonthEndReportViewState.monthEndReportDataByCompanyId[e].companyMonthEndReportData.templateData,d),recipient_email_list:c,tenant_receiver_email_list:o.companyMonthEndReportViewState.monthEndReportDataByCompanyId[e].companyMonthEndReportData.tenantReceiverEmailList,last_report_sent_business_day:g,last_report_sent_date:I.format(re),...l!==void 0&&{zeni_requests_html:l===""?null:l},files:b};return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}/emails/month-end`,E,{"zeni-tenant-id":h}).pipe(y((P=>{if(M(P)){const O=[Mo(e,"Completed",void 0),EN({companyId:e}),Zp({companyId:e,isInDraftMode:!1}),PN({companyId:e,reportSent:!0}),N({messageSection:"cockpit_month_end_email_sent",messageText:"success",type:"success",variables:[{variableName:"_company-name_",variableValue:m}]})];return _(O)}return p(Mo(e,"Error",P.status))})),v((P=>p(Mo(e,"Error",f("Unexpected Error","send company month end report REST API call errored out"+JSON.stringify(P)))))))}))),ez,(s,i,r)=>s.pipe(S(MU.match),y((t=>{const{body:e,customerId:a,email:n,subject:o}=t.payload,c=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/customers/${encodeURIComponent(a)}/payment-link`;return r.postAndGetJSON(c,{email:n,...e!=null&&e!==""?{body:e}:{},...o!=null&&o!==""?{subject:o}:{}}).pipe(A((d=>T(d)&&d.data!=null?p(VU({email:d.data.email,magicLinkUrl:d.data.magic_link_url})):p(S_(d.status)))),v((d=>p(S_(f("Unexpected Error","Send payment link REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(HD.match),y((t=>{const{companyId:e}=t.payload,a={is_onboarding_tenant:!0,is_send_invite_to_users_with_access_to_onboarding:!0,is_send_invite_to_customer:!0,company_id:e};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/whitelist-companies`,a).pipe(y((n=>{if(T(n)&&n.data!=null){const o=n.data.companies.map((m=>m.company_id)),c=Di(n.data.tenants,n.data.companies),d=KE(n.data.companies[0].onboarding_info,n.data.users),l=n.data.companies[0].name??"",u=[];return u.push(Ji(n.data.tenants,!0)),u.push(rn({payload:n.data.companies,schema:{},onboardingInviteStatus:n.data.onboarding_invite_status,companyIdTenantIdMapping:c})),u.push(z(n.data.addresses??[])),u.push(wi(n.data.tenants)),u.push($i({onboardingCustomersInfo:n.data.whitelist_companies})),u.push(Ri(o)),u.push(QD({companyId:e})),n.data.users!=null&&u.push(V({users:n.data.users})),n.data.user_roles!=null&&u.push(Y(n.data.user_roles)),u.push(N({messageSection:"dashboard_invite_sent",messageText:"success",type:"success",variables:[{variableName:"_user-name_",variableValue:d},{variableName:"_company-name_",variableValue:l}]})),_(u)}{const o=[];return o.push(CS({error:n.status,companyId:e})),o.push(N({messageSection:"dashboard_invite_sent",messageText:"failed",type:"error"})),_(o)}})),v((n=>{const o=[];return o.push(CS({error:f("Unexpected Error","Send Onboarding Customer View Invite errored out"+JSON.stringify(n)),companyId:e})),o.push(N({messageSection:"dashboard_invite_sent",messageText:"failed",type:"error"})),_(o)})))}))),tz,(s,i,r)=>s.pipe(S(Nw.match),A((()=>{const{referralViewState:t}=i.value,e=t.referralFormLocalData,a=t.rewardsPlan.planId,n={...vK(e,a)};return r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/company-referrals`,n).pipe(y((o=>M(o)?[Ow(),N({messageSection:"referral_invite_sent",messageText:"success",type:"success"})]:p(on(o.status)))),v((o=>p(on(f("Unexpected error","Send referral REST API call errored out"+JSON.stringify(o)))))))}))),az,(s,i,r)=>s.pipe(S(wT.match),y((t=>{const{macroId:e,visibility:a}=t.payload,n=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/skills/${encodeURIComponent(e)}/visibility`;return r.putAndGetJSON(n,{visibility:a}).pipe(y((o=>T(o)&&gl(o.data)?p($T({macroId:e,detail:fl(o.data)}),po()):p(Lu(o.status)))),v((o=>p(Lu(f("Unexpected Error","Set skill visibility REST API call failed",o instanceof Error?{message:o.message}:void 0))))))}))),(s,i,r)=>s.pipe(S(Uq.match),y((t=>iY(t.payload.taskId,t.payload.snoozedUntil,r)))),(s,i,r)=>s.pipe(S(RB.match),A((t=>{const e=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/qbo/backfill`;return r.postAndGetJSON(e,{start_date:t.payload.startDate}).pipe(y((a=>T(a)?_([MB(),xi(),N({messageSection:"invoicing_qbo_backfill",messageText:"success",type:"success"})]):_([qh(a.status),N({messageSection:"invoicing_qbo_backfill",messageText:"failed",type:"error",variables:Ie(a.status)})]))),v((a=>_([qh(f("Unexpected Error","Start QBO backfill REST API call errored out "+JSON.stringify(a))),N({messageSection:"invoicing_qbo_backfill",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(AA.match),A((t=>r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/accounts/${ds(t.payload.accountId)}`,{statement_close_day:t.payload.statementCloseDay.toString()}).pipe(y((e=>M(e)?p(NA({accountId:t.payload.accountId,statementCloseDay:t.payload.statementCloseDay,reportId:"card_balance"})):p(yp(e.status)))),v((e=>p(yp(f("Unexpected error","Update statement close date REST API call errored out"+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(RT.match),A((t=>{const{chatSessionId:e}=t.payload,a=i.value.aiCfoState.aiCfoByChatSessionId[e];if(a==null)return p(os({chatSessionId:e,error:f("Unexpected Error","Session not found")}));const n=[...a.questionAnswers].reverse().find((d=>d.responses==null||Object.keys(d.responses).length===0||d.responses.answer==null)),o=a.questionAnswers.length<=1;if(!n)return p(os({chatSessionId:e,error:{code:404,message:"No pending question found"}}));const c=n.question.messageId;return r.deleteAndGetJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/messages/${c}`).pipe(y((d=>T(d)&&d.data!=null?p(Fu({chatSessionId:e,questionAnswerId:n.questionAnswerId}),MT({chatSessionId:e,question:n.question.questionText,isOnlyQuestionInSession:o})):p(os({chatSessionId:e,error:d.status})))),v((d=>p(os({chatSessionId:e,error:f("Unexpected Error","Stop submit REST API call errored out"+JSON.stringify(d))})))))}))),(s,i)=>s.pipe(S(VT.match),qu(500),A((r=>{const{chatSessionId:t}=r.payload,e=i.value.aiCfoState.aiCfoByChatSessionId[t];if(e==null)return p(ju({chatSessionId:t,error:f("Unexpected Error","Session not found")}));const a=[...e.questionAnswers].reverse().find((o=>o.responses==null||Object.keys(o.responses).length===0||o.responses.answer==null)),n=e.questionAnswers.length<=1;return a?p(Fu({chatSessionId:t,questionAnswerId:a.questionAnswerId}),LT({chatSessionId:t,question:a.question.questionText,isOnlyQuestionInSession:n})):p(ju({chatSessionId:t,error:{code:404,message:"No pending question found"}}))}))),(s,i,r)=>s.pipe(S(t1.match),y((()=>{const{billsBulkActionViewState:t,billTransactionState:e}=i.value,a=(o=e,{operation_type:"send_for_approval",operations:(n=t).billsSelectedForBulkAction.map((d=>{let l={entity_id:d};if(n.bulkReviewStateById[d]?.errors?.some((u=>u.code==="ERR_INVOICE_DATE_OUTSIDE_ACCOUNTING_PERIOD"))===!0){const u=o.transactionById[d];u!=null&&(l={...l,request_data:{transaction_date:Rl("draft",u.date,u.bookCloseDate).format("YYYY-MM-DD")}})}return l}))});var n,o;const c=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/bills/transactions`;return r.putAndGetJSON(c,a).pipe(y((d=>{if(M(d)){const l=[],u=d.data?.total_operations_processing??0;return l.push(Ic({billsProcessing:u,refreshTime:d.data?.hard_refresh_after_sec??0})),l.push(bc(d.data?.operations??[])),u>0&&l.push(N({messageSection:"bill_pay_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:u.toString()},{variableName:"_bill_",variableValue:u>1?"bills":"bill"},{variableName:"_action_",variableValue:"sent for approval"}]})),_(l)}return p(Fa(d.status),N({messageSection:"bill_pay_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}))})),v((d=>p(Fa(f("Unexpected Error","Bulk Send For Approval bill REST API call errored out "+JSON.stringify(d)))))))}))),(s,i,r)=>s.pipe(S(pF.match),y((()=>{const{remisBulkActionViewState:t}=i.value,e={operation_type:"send_for_approval",operations:t.remisSelectedForBulkAction.map((n=>({entity_id:n})))},a=`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/reimbursements/transactions`;return r.putAndGetJSON(a,e).pipe(y((n=>{if(M(n)){const o=[],c=n.data?.total_operations_processing??0;return o.push(xd({remisProcessing:c,refreshTime:n.data?.hard_refresh_after_sec??0})),o.push(Ud(n.data?.operations??[])),c>0&&o.push(N({messageSection:"reimbursement_bulk_submit",messageText:"success",type:"success",variables:[{variableName:"_count_",variableValue:c.toString()},{variableName:"_report_",variableValue:c>1?"reports":"report"},{variableName:"_action_",variableValue:"sent for approval"}]})),_(o)}return p(Ga(n.status),N({messageSection:"reimbursement_bulk_submit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]}))})),v((n=>p(Ga(f("Unexpected Error","Bulk Send For Approval remi REST API call errored out "+JSON.stringify(n)))))))}))),(s,i,r)=>s.pipe(S(wF.match),A((()=>{const{expressPayState:t}=i.value,e=t.formLocalData;return e!=null?r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/transactions/express-pay`,QK(e)).pipe(y((a=>{const n=[];return T(a)&&a.data!=null?(n.push(jd({fetchState:"Completed",error:void 0})),n.push(N({messageSection:"express_pay_submit",messageText:"success",type:"success"}))):(n.push(jd({fetchState:"Error",error:a.status})),n.push(N({messageSection:"express_pay_submit",messageText:"failed",type:"error"}))),_(n)})),v((a=>p(jd({fetchState:"Error",error:f("Unexpected Error","Submit express pay REST API call errored out"+JSON.stringify(a))}))))):_([])}))),(s,i,r)=>s.pipe(S(FT.match),ar((t=>t.payload.chatMessageId)),y((t=>t.pipe(A((e=>{const{chatMessageId:a,chatSessionId:n,feedbackType:o,answerText:c,model:d,questionText:l}=e.payload,u={chat_message_id:a,chat_session_id:n,feedback_type:o,...c!=null&&{answer_text:c},...d!=null&&{model:d},...l!=null&&{question_text:l}};return r.postAndGetJSON(`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/feedback`,u).pipe(y((m=>M(m)?p(qT(a)):p(Gu(a,m.status)))),v((m=>p(Gu(a,f("Feedback REST API call errored out: "+(m instanceof Error?m.message:String(m)),"Unexpected Error"))))))})))))),(s,i,r)=>s.pipe(S(L1.match),A((t=>{const{internationalWireVerificationState:e}=i.value,{companyId:a}=t.payload,n=e.verificationFormLocalData;return n!=null?r.postAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/international-wire/onboarding`,LK(n)).pipe(y((o=>{const c=[];return T(o)&&o.data!=null?(c.push(Jc({fetchState:"Completed",error:void 0})),c.push(N({messageSection:"business_verification_submit",messageText:"success",type:"success"})),o.data!=null&&c.push(F1({companyId:a,status:o.data?.international_wire_onboarding_status}))):(c.push(Jc({fetchState:"Error",error:o.status})),c.push(N({messageSection:"business_verification_submit",messageText:"failed",type:"error"}))),_(c)})),v((o=>p(Jc({fetchState:"Error",error:f("Unexpected Error","Submit international wire verification REST API call errored out"+JSON.stringify(o))}))))):_([])}))),(s,i,r)=>s.pipe(S(cD.match),y((()=>{const t=i.value,{brandingDraft:e,settings:a}=t.invoicingSettingsViewState,n=e??dD(a),o=t.addressViewState.newAddressState?.[an]?.addressToCreate,c=lD(n,o),d=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/settings`;return r.putAndGetJSON(d,{...c}).pipe(y((l=>{if(T(l)&&l.data!=null){const u=l.data.address;return[...u!=null?[z([u])]:[],rS(l.data),ma(an)]}return p(tn(l.status))})),v((l=>p(tn(f("Unexpected Error","Save branding settings REST API call errored out "+JSON.stringify(l)))))))}))),(s,i)=>s.pipe(S(nD.match),Le(i),y((([,r])=>{const{qboDraft:t}=r.invoicingSettingsViewState;return t==null?F:p(aS({settings:{qbo:oD(t,(e=>iD(r,e)))},snackbarSection:"invoicing_qbo_settings_save"}))}))),(s,i,r)=>s.pipe(S(Au.match),y((t=>{const{questionAnswerId:e,userId:a,sessionId:n,questionId:o,createdAt:c,question:d,files:l,macroId:u}=t.payload,{aiCfoViewState:m}=i.value,{uiState:h}=m,g=h.agentId;if(g==null||!!d==0)throw new Error("Invalid State");const I=`${r.apiEndPoints.aiCfoMicroServiceBaseUrl}/1.0/agents/${g}`;let b;if(l!=null&&l.length>0){const E=new FormData;E.append("chat_session_id",n),E.append("message",d),u!=null&&E.append("macro_id",u);for(const P of l)E.append("files",P,P.name);b=r.postFormData(I,E)}else b=r.postAndGetJSON(I,{chat_session_id:n,message:d,...u!=null&&{macro_id:u}});return b.pipe(y((E=>{if(T(E)&&E.data!=null){const P=[];return P.push(mo({chatSessionId:n,questionAnswerId:e,question:{questionId:o,text:d,createdAt:c},answerPayload:E.data,userId:a,insertQuestionAnswer:!1}),jT(n)),p(...P)}return p(zu({sessionId:n,error:E.status}))})),v((E=>p(zu({sessionId:n,error:f("Unexpected Error","Submit question REST API call errored out"+JSON.stringify(E))})))))}))),(s,i,r)=>s.pipe(S(Iw.match),y((t=>{const{transactionId:e}=t.payload;return r.postAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${e}/recommendation-feedback`,(a=t.payload,{line_id:a.lineId??null,dimension:a.dimension,recommendation_set_id:a.recommendationSetId??null,top_pick_source:a.topPickSource??null,shown_recommendations:(a.shownRecommendations??[]).map((n=>({source:n.source,rank:n.rank,value:{name:n.value.name,id:n.value.id??null,integration_id:n.value.integrationId??null},confidence:n.confidence??null,reasoning:n.reasoning??null,cot:n.cot??[]}))),selected:{name:a.selected.name,id:a.selected.id??null,integration_id:a.selected.integrationId??null,is_new_entity:a.selected.isNewEntity??!1},matched_source:a.matchedSource??null,matched_rank:a.matchedRank??null,outcome:a.outcome,reason_text:a.reasonText??null,skipped:a.skipped??!1,retracts_feedback_id:a.retractsFeedbackId??null,features:a.features??null})).pipe(y((n=>(M(n)||console.error("submitRecommendationFeedbackEpic: recommendation feedback was not recorded",n.status),F))),v((n=>(console.error("submitRecommendationFeedbackEpic: failed to submit recommendation feedback",n),F))));var a}))),(s,i)=>s.pipe(S(mx.match),S((r=>r.payload.selectedPageTab!=null)),y((()=>{const r=i.value,{fetchState:t,refreshStatus:e}=r.expenseAutomationJESchedulesViewState;if(t==="In-Progress"||e.fetchState==="In-Progress")return F;const a=H(r),n=r.expenseAutomationViewState.selectedPeriodByTenantId[a.tenantId];if(n==null)return F;const o=Re(n),c=ge(o.start),d=ge(o.end);return c==null||d==null?F:p(Pa({start:c,end:d},!0))}))),(s,i,r)=>s.pipe(S(K_.match),y((t=>{const{subscriptionId:e,previousCouponCode:a,nextCouponCode:n}=t.payload,o=RE(a),c=RE(n);if(o===c)return F;const d=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0`;return(o===""?p({success:!0,payload:null}):ME(r,d,e,"remove-coupon",o)).pipe(y((l=>l.success?(c===""?p({success:!0,payload:l.payload}):ME(r,d,e,"apply-coupon",c)).pipe(y((u=>{if(!u.success)return[Qs(VE(u)),N({messageSection:"invoicing_subscription_saved",messageText:"failed",type:"error"})];const m=u.payload??l.payload,h=[];return m!=null&&h.push(Ua([m],"merge"),z(xa([m]))),h.push(Y_({subscriptionId:e}),ma(kr),N({messageSection:"invoicing_subscription_saved",messageText:"success",type:"success"})),h}))):_([Qs(VE(l)),N({messageSection:"invoicing_subscription_saved",messageText:"failed",type:"error"})]))))}))),(s,i)=>s.pipe(S((r=>Er.match(r)||Na.match(r))),A((r=>{const{batchId:t}=r.payload;return vt(s.pipe(S(Aa.match)),s.pipe(S(Gn.match))).pipe(S((e=>e.payload.batchId===t)),Ue(1),A((e=>{const{summary:a}=e.payload;if(a.matched<=0)return F;const n=i.value,o=H(n);if(o==null)return F;const c=n.expenseAutomationViewState.selectedPeriodByTenantId[o.tenantId];if(c==null)return _([Tr(void 0,!0)]);const d=Re(c),l=ge(d.start),u=ge(d.end);return _(l==null||u==null?[Tr(void 0,!0)]:[vr({start:l,end:u},{amount:75,currencyCode:"USD",currencySymbol:"$"},!0,!0),Tr(void 0,!0)])})),De(s.pipe(S(Ds.match))))}))),(s,i)=>s.pipe(S(Dr.match),A((r=>{const t=[Bw({isForecastModeOn:r.payload.isForecastModeOn,selectedForecast:r.payload.selectedForecast,maxNumOfPeriodsToHighlightWithForecast:r.payload.maxNumOfPeriodsToHighlightWithForecast}),Dw({isForecastModeOn:r.payload.isForecastModeOn,selectedForecast:r.payload.selectedForecast,maxNumOfPeriodsToHighlightWithForecast:r.payload.maxNumOfPeriodsToHighlightWithForecast}),Jw({isForecastModeOn:r.payload.isForecastModeOn,selectedForecast:r.payload.selectedForecast,maxNumOfPeriodsToHighlightWithForecast:r.payload.maxNumOfPeriodsToHighlightWithForecast})];return r.payload.isForecastModeOn&&(t.push(Ug(r.payload.firstMonthOfFY,!1,r.payload.maxNumOfPeriodsToHighlightWithForecast,[])),t.push(kg(r.payload.firstMonthOfFY,i.value.reportUIOptionsState.compareMode,r.payload.maxNumOfPeriodsToHighlightWithForecast,[])),t.push(ww({viewMode:"account_group"})),t.push($w({viewMode:"account_group"})),t.push(Rw({viewMode:"account_group"}))),_(t)}))),(s,i,r)=>s.pipe(S(LF.match),A((t=>{const e=i.value,{depositAccountId:a}=t.payload,n=e.transferDetailState.localData,o={from_account:{account_id:n.transferFrom?.id,account_type:Me(n.transferFrom?.accType)??""},to_account:{account_id:n.transferTo?.id,account_type:Me(n.transferTo?.accType)??""},amount:n.amount.amount,currency_code:n.amount.currencyCode,currency_symbol:n.amount.currencySymbol,payment_method_type:{code:"ach",sub_code:"same-day"}};return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts-transfers`,o).pipe(y((c=>{if(T(c)){const d=[];return a!=null&&d.push(xn(a,!0,5)),d.push(ke(),Gd({fetchState:"Completed"})),_(d)}return p(Gd({fetchState:"Error",error:c.status}))})),v((c=>p(Gd({fetchState:"Error",error:f("Unexpected Error","Transfer money REST API call errored out"+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(TF.match),A((()=>{const t=i.value.treasuryTransferMoneyState.localData;return r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account/transactions`,{...HK(t)}).pipe(y((e=>{if(T(e)&&e.data){const a=[AF({transferTransaction:e.data}),Vd({fetchState:"Completed"}),N({messageSection:"treasury_transfer_money",messageText:"success",type:"success"})];return _(a)}return _([Vd({fetchState:"Error",error:e.status}),N({messageSection:"treasury_transfer_money_failed",messageText:"failed",type:"error"})])})),v((e=>_([Vd({fetchState:"Error",error:f("Unexpected Error","Treasury transfer money REST API call errored out: "+JSON.stringify(e))}),N({messageSection:"treasury_transfer_money_failed",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(YP.match),y((t=>{const{operationType:e,startDate:a,endDate:n}=t.payload,o=i.value.aiAccountantViewState.selectedTenantIdsForJobTrigger,c=`${`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/cockpit-panels`}/ai-accountant/jobs`,d=e==="offboard"?{}:{start_date:a,end_date:n};return r.postAndGetJSON(c,{tenant_ids:o,operation_type:e,params:d}).pipe(y((l=>{if(T(l))return _([HP(),uo(),N({messageSection:"ai_accountant_trigger_job",messageText:"success",type:"success"})]);{const u=uz(l);return _([Eu(l.status),N({messageSection:"ai_accountant_trigger_job",messageText:"failed",type:"error",variables:[{variableName:"__reason__",variableValue:u}]})])}})),v((l=>_([Eu(f("Unexpected error","AI Accountant trigger job failed: "+JSON.stringify(l))),N({messageSection:"ai_accountant_trigger_job",messageText:"failed",type:"error",variables:[{variableName:"__reason__",variableValue:"Unexpected error"}]})]))))}))),(s,i)=>s.pipe(S(Yy.match),y((r=>{const{pendingReviewLineIds:t,transactionId:e}=r.payload;if(t.length===0)return F;const a=i.value;if(a.expenseAutomationTransactionsViewState.transactionCategorizationView.review.transactionReviewLocalDataById[e.id]!=null)return F;const n=H(a),o=a.expenseAutomationViewState.selectedPeriodByTenantId[n.tenantId],c=Re(o),d=ge(c.start),l=ge(c.end);return d==null||l==null?F:p(My({start:d,end:l}))}))),(s,i,r)=>s.pipe(S($F.match),A((t=>{const{accountId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts/${e}`,{is_unlink:!0}).pipe(y((a=>M(a)&&e!=null?p(RF({accountId:e}),HI({accountId:e,fetchState:"Completed",error:void 0})):p(HI({accountId:e,fetchState:"Error",error:a.status}),N({messageSection:"unlink_deposit_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:a.status.message}]})))),v((a=>p(N({messageSection:"unlink_deposit_account",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(a)}]})))))}))),(s,i,r)=>s.pipe(S(QM.match),A((t=>{const{isChargeCardAdmin:e,chargeCardId:a}=t.payload,n=i.value.chargeCardState.chargeCardByID[a],o=n?.accountLast4??"";return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${a}/unlock`).pipe(y((c=>M(c)&&c.data!=null?p(st(c.data),Qc({chargeCardId:a,fetchState:"Completed"}),N({messageSection:e?"unlock_charge_card":"unlock_charge_card_card_user",messageText:"success",type:"success",variables:[{variableName:"_masked_card_number_",variableValue:`•••• ${o}`}]})):p(N({messageSection:e?"unlock_charge_card":"unlock_charge_card_card_user",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}),Qc({chargeCardId:a,fetchState:"Error",error:c.status})))),v((c=>p(N({messageSection:e?"unlock_charge_card":"unlock_charge_card_card_user",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(c)}]}),Qc({chargeCardId:a,fetchState:"Error",error:f("Unexpected Error","Unlock card API call errored out"+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(yV.match),A((t=>{const{cardIds:e}=t.payload,a={card_ids:e};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/bulk/unlock`,a).pipe(y((n=>M(n)&&n.data!=null?p(qa(n.data),od({fetchState:"Completed"}),N({messageSection:"unlock_charge_cards",messageText:"success",type:"success",variables:[{variableName:"_number_of_cards_",variableValue:e.length===1?"1 card":`${e.length} cards`}]})):p(N({messageSection:"unlock_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:n.status.message}]}),od({fetchState:"Error",error:n.status})))),v((n=>p(N({messageSection:"unlock_charge_cards",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(n)}]}),od({fetchState:"Error",error:f("Unexpected Error","Unlock cards API call errored out"+JSON.stringify(n))})))))}))),(s,i,r)=>s.pipe(S(Bq.match),y((t=>dY(t.payload.taskId,r)))),(s,i,r)=>s.pipe(S(VN.match),A((t=>{const{companyId:e,enabled:a}=t.payload,n=cr(i.value.tenantState,e);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_accounting_classes_enabled:a}).pipe(y((o=>{const c=o.data?.companies??[];if(T(o)&&c.length>0){const d=[Q({payload:c,schema:{}})];return n!=null&&d.push(LN({enabled:a,tenantId:n})),d.push(FN()),d.push(N({messageSection:"accounting_classes_enabled_update",messageText:"success",type:"success"})),_(d)}return _([gm({status:o.status}),N({messageSection:"accounting_classes_enabled_update",messageText:"failed",type:"error"})])})),v((o=>_([gm({status:f("Unexpected error","Update Accounting Classes Enabled errored out"+(o instanceof Error?o.message:JSON.stringify(o)))}),N({messageSection:"accounting_classes_enabled_update",messageText:"failed",type:"error"})]))))}))),s=>s.pipe(S(ca.match),y((i=>{const r=[];if(i.payload.jeAccruedSchedulesTransactionsPayload.length>0){const t=[],e=[],a=[],n=[];i.payload.jeAccruedSchedulesTransactionsPayload.forEach((o=>{t.push(o.vendor),e.push(o.updated_by),Zl.forEach((c=>{const d=_P(o,c);d!=null&&a.push(d);const l=Xl(o,c);l!=null&&n.push(l)}))})),r.push(W(a,"account_list"),Ke("class_list",n),le(t,"merge"),V({users:e,updateType:"merge"})),r.push(hP({jeAccruedSchedulesTransactionsPayload:i.payload.jeAccruedSchedulesTransactionsPayload}))}return _(r)}))),(s,i,r)=>s.pipe(S(MP.match),A((t=>{const{addressId:e,addressToUpdate:a}=t.payload,n=xe(a);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/addresses/${e}`,n).pipe(y((o=>{if(T(o)){const c=o.data?.addresses??[];return p(z(c),VP(e))}return p(fu({addressId:e,status:o.status}))})),v((o=>p(fu({addressId:e,status:f("Unexpected Error","Update Address REST API call errored out"+JSON.stringify(o))})))))}))),(s,i)=>s.pipe(S(C$.match),y((r=>{const t=[],e=i.value,{scheduleAccruedDetailState:a}=e,n=a.selectedJEAccruedScheduleKey,o=r.payload.scheduleType;if(n!=null){const c=r.payload.jeScheduleDetailId,d=xK(c!=null?a.editScheduleStateByDetailId[c].jeScheduleDetails:a.newScheduleState.jeScheduleDetails,r.payload.rowId),l=c!=null?a.editScheduleStateByDetailId[c]:a.newScheduleState;t.push(cn({scheduleType:o,selectedJeScheduleDetailId:c,localData:{...l,jeScheduleDetails:d}}))}return _(t)}))),(s,i)=>s.pipe(S(F$.match),y((r=>{const t=[],e=i.value,{scheduleDetailState:a}=e,n=a.selectedJEScheduleKey,o=r.payload.scheduleType;if(n!=null){const c=ft(n,e),d=r.payload.jeScheduleDetailId,l=c.baseTransaction.amount.amount,u=d!=null?rf(a.editScheduleStateByDetailId[o][d].jeScheduleDetails,a.editScheduleStateByDetailId[o][d].selectedMonths??0,r.payload.rowId,l):rf(a.newScheduleState[o].jeScheduleDetails,a.newScheduleState[o].selectedMonths??0,r.payload.rowId,l),m=d!=null?a.editScheduleStateByDetailId[o][d]:a.newScheduleState[o];t.push(un({scheduleType:o,selectedJeScheduleDetailId:d,localData:{...m,jeScheduleDetails:u}}))}return _(t)}))),(s,i,r)=>s.pipe(S(NR.match),A((t=>{const{ruleId:e,pauseRule:a,resumeRule:n}=t.payload,o=a0(i.value.autotransferRulesState.ruleUpdateLocalData,a,n);return r.putAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/rules/transfer/auto/${e}`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=kl(c.data.auto_transfer_rule),l=Object.keys(o).length===1&&"is_active"in o?o.is_active===!1?"auto_transfer_rule_pause":"auto_transfer_rule_resume":"auto_transfer_rule_update",u=[OR({rule:d}),N({messageSection:l,messageText:"success",type:"success",variables:[{variableName:"__ruleName__",variableValue:d.ruleType==="minimum_balance"?"Maintain a Minimum Balance":d.ruleType==="recurring"?"Make a Recurring Transfer":"Distribute Balance by Percentage"}]})];return _(u)}return _([Of({ruleId:e,fetchState:"Error",error:c.status}),N({messageSection:"auto_transfer_rule_update",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]})])})),v((c=>p(Of({ruleId:e,fetchState:"Error",error:f("Unexpected Error","Update auto transfer rule REST API call errored out "+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(mJ.match),y((t=>{const{companyId:e,officerType:a,setupViewType:n,sendForVerification:o,fromBillListScreen:c,isSubmittingAdditionalDocuments:d}=t.payload,{setupViewState:l}=i.value,u=l.companyDetails.localData,m=l.primaryContactDetails.localData,h=l.companyOfficerUpdateStatus[a].localData;if(u!=null){const g=_t(i.value,e,[]),{newAddressState:I}=i.value.addressViewState,b=I?.company_address?.addressToCreate,E=I?.company_registered_address?.addressToCreate,P=a.toLowerCase().concat("_address"),O=I?.[P]?.addressToCreate,C=m?.userId==null||m?.email!==g?.primaryContact?.user.email,U=YE(u,o,b,E,n),B=m!=null&&m.email?HE(m,C):{},x=h!=null&&h.email?QE(h,d,O):{},k=yK(n);let J={company:U,company_officer:x,primary_contact_user:B};return o===!0&&(J={...J,business_verification_submitted_for_feature:k}),r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,J).pipe(y((L=>{if(T(L)&&L.data!=null){const{users:R}=L.data,q=[V({users:R}),Y(L.data.user_roles),Q({payload:L.data.companies,schema:{}}),z(L.data.addresses),ve({files:L.data.files}),W(L.data.accounts,Da(n)),Se(L.data.payment_accounts),we({companyId:L.data.companies[0].company_id})];return o===!1&&h?.officerType!=null&&q.push(yJ(h?.officerType)),c!==!0&&n!=="zeni_treasury"&&q.push(N({messageSection:o===!0?"business_verification_submit":"business_verification_save",messageText:"success",type:"success"})),n==="zeni_treasury"&&o===!1&&q.push(N({messageSection:"business_verification_save",messageText:"success",type:"success"})),q.push(_J()),_(q)}return p(N({messageSection:o===!0?"business_verification_submit":"business_verification_save",messageText:"failed",type:"error"}),LS(L.status))})),v((L=>p(LS(f("Unexpected Error","Update Business Verification Details errored out"+JSON.stringify(L)))))))}return _([])}))),(s,i,r)=>s.pipe(S(qN.match),A((t=>{const{companyId:e,accountId:a,threshold:n,dismissOnboardingForAccount:o,allOverrides:c}=t.payload,d=cr(i.value.tenantState,e);let l;c!==void 0?l=c??{}:(l={...d!=null?i.value.tenantState.tenantsById[d]?.capitalizableAccountOverrides:{}},n===null?delete l[a]:l[a]=n);const u={capitalizable_account_overrides:Object.keys(l).length>0?l:null};return o===!0&&(u.capitalization_onboarding_dismissed_accounts={[a]:!0}),r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,u).pipe(y((m=>{if(T(m)){const h=m.data?.companies??[],g=[];return h.length>0&&g.push(Q({payload:h,schema:{}})),d!=null&&(g.push(jN({tenantId:d,accountId:a,threshold:n,allOverrides:c!==void 0?Object.keys(l).length>0?l:null:void 0})),o===!0&&g.push(lm({tenantId:d,accountId:a}))),g.push(GN()),g.push(N({messageSection:"capitalization_threshold_update",messageText:"success",type:"success"})),_(g)}return _([fm({status:m.status}),N({messageSection:"capitalization_threshold_update",messageText:"failed",type:"error"})])})),v((m=>_([fm({status:f("Unexpected error","Update Capitalization Threshold errored out"+(m instanceof Error?m.message:JSON.stringify(m)))}),N({messageSection:"capitalization_threshold_update",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(cM.match),y((t=>{const e=t.payload,a=i.value.cardPolicyDetailState.formDraft;if(a==null)return p(fn({fetchState:"Error",error:f("Missing form draft",`Cannot update card-policy ${e} — no formDraft is loaded.`)}));const n=dM(a);return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/policy-templates/${e}`,n).pipe(y((o=>{if(M(o)&&o.data!=null){const{template:c}=o.data,d=[Rc(c),fn({fetchState:"Completed"})];return _(d)}return p(fn({fetchState:"Error",error:o.status}))})),v((o=>p(fn({fetchState:"Error",error:f("Unexpected Error","Update card-policy REST API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(CO.match),y((t=>{const{tenantId:e,tenantEmailDomain:a,update:n}=t.payload,o=`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cockpit/card-tenant-profiles`,c={tenant_namespace:a};return n.cardStatus!=null&&(c.card_status=n.cardStatus),n.creditLimit!=null&&(c.credit_limit=n.creditLimit),n.updatedByName!=null&&(c.updated_by_name=n.updatedByName),n.reason!=null&&n.reason.trim()!==""&&(c.reason=n.reason.trim()),r.putAndGetJSON(o,c).pipe(y((d=>T(d)&&d.data!=null&&d.data.profile!=null?_([xO({payload:d.data.profile,tenantId:e}),UO(e),N({messageSection:"credit_agent_update_profile",messageText:"success",type:"success"})]):_([wm(e,d.status),N({messageSection:"credit_agent_update_profile",messageText:"failed",type:"error"})]))),v((d=>_([wm(e,f("Unexpected error","REST API call errored out: "+JSON.stringify(d))),N({messageSection:"credit_agent_update_profile",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(WM.match),A((t=>{const{chargeCardId:e,colorCode:a}=t.payload,n={card_color_code:a};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}`,n).pipe(y((o=>M(o)&&o.data!=null?p(st(o.data.card),V({users:o.data.users}),Y(o.data.user_roles),Wc({chargeCardId:e,fetchState:"Completed"})):p(N({messageSection:"update_charge_card",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:o.status.message}]}),Wc({chargeCardId:e,fetchState:"Error",error:o.status})))),v((o=>p(N({messageSection:"update_charge_card",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(o)}]}),Wc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Update card detail API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(ZM.match),A((t=>{const{chargeCardId:e,updatedSpendLimit:a,frequency:n,formattedAmount:o}=t.payload,c={purchase_limit:a.amount,currency_code:a.currencyCode,purchase_limit_frequency:{code:n}};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/modify_limit`,c).pipe(y((d=>M(d)&&d.data!=null?p(st(d.data),Zc({chargeCardId:e,fetchState:"Completed"}),N({messageSection:"charge_card_update_limit",messageText:"success",type:"success",variables:[{variableName:"_amount_",variableValue:o}]})):p(N({messageSection:"charge_card_update_limit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:d.status.message}]}),Zc({chargeCardId:e,fetchState:"Error",error:d.status})))),v((d=>p(N({messageSection:"charge_card_update_limit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(d)}]}),Zc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Update card limit API call errored out"+JSON.stringify(d))})))))}))),(s,i,r)=>s.pipe(S(XM.match),A((t=>{const{chargeCardId:e,name:a,isChargeCardAdmin:n}=t.payload,o={card_name:a},c=i.value.chargeCardState.chargeCardByID[e],d=c?.accountLast4??"";return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/rename`,o).pipe(y((l=>M(l)&&l.data!=null?p(st(l.data),Xc({chargeCardId:e,fetchState:"Completed"}),N({messageSection:n?"update_charge_card_name":"update_charge_card_name_card_user",messageText:"success",type:"success",variables:[{variableName:"_masked_card_number_",variableValue:`•••• ${d}`},{variableName:"_new_card_name_",variableValue:a}]})):p(N({messageSection:n?"update_charge_card_name":"update_charge_card_name_card_user",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}),Xc({chargeCardId:e,fetchState:"Error",error:l.status})))),v((l=>p(N({messageSection:n?"update_charge_card_name":"update_charge_card_name_card_user",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(l)}]}),Xc({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Update card name API call errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(_V.match),A((t=>{const{chargeCardIds:e,updatedSpendLimit:a,frequency:n}=t.payload,o={card_ids:e,limit_details:{purchase_limit:a.amount,currency_code:a.currencyCode,purchase_limit_frequency:{code:n}}};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/bulk/modify_limit`,o).pipe(y((c=>M(c)&&c.data!=null?p(qa(c.data),id({fetchState:"Completed"}),N({messageSection:"charge_cards_update_limit",messageText:"success",type:"success",variables:[{variableName:"_number_of_cards_",variableValue:e.length===1?"1 card":`${e.length} cards`}]})):p(N({messageSection:"charge_cards_update_limit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}),id({fetchState:"Error",error:c.status})))),v((c=>p(N({messageSection:"charge_cards_update_limit",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(c)}]}),id({fetchState:"Error",error:f("Unexpected Error","Update cards limit API call errored out"+JSON.stringify(c))})))))}))),(s,i,r)=>s.pipe(S(_C.match),A((t=>{const{accountId:e,selectedPeriod:a}=t.payload,n=i.value.expenseAutomationReconciliationViewState.accountReconciliationRecordsBySelectedPeriod[Ee(a)]?.reconciliationByAccountID[e],o=n?.parsedStatementData,c=n?.localData?.statementUpdateLocalDataByUploadId,d=ry(o);if(o==null||c==null||d.length===0||d.some((h=>c[h.statementMeta.statementUploadId]==null)))return p(ht({accountId:e,selectedPeriod:a,error:f("Missing Data","No statement update data found for combined accounts")}));const l=Gm(n);if(l==="")return p(ht({accountId:e,selectedPeriod:a,error:f("Missing Data","No combined statement group id found for bulk update")}));const u=((h,g)=>{const I=ry(g).map((b=>{const E=b.statementMeta.statementUploadId,P=h[E];if(P==null)throw new Error(`Missing statement update local data for upload ${E}`);return{statementUploadId:E,localData:xE(P,b)}}));return uC(I)})(c,o),m=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/combined-statement-groups/${l}`;return r.putAndGetJSON(m,u).pipe(y((h=>{if(T(h)===!0&&h.data!=null)return p(Cs({accountId:e,selectedPeriod:a,parsedStatementData:ny(h.data)}),sy({accountId:e,selectedPeriod:a}),Rt(a,void 0,!0,!0));const g=oy(h)?iy(h):null;return p(ht({accountId:e,selectedPeriod:a,error:h.status,dateConflict:g}))})),v((h=>p(ht({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Update Statement REST API call errored out "+(h instanceof Error?h.message:String(h)))})))))}))),(s,i,r)=>s.pipe(S(Sm.match),y((t=>{const{companyDetails:e,companyId:a}=t.payload,n={...(o=e.companyInfo,{name:o.companyName,company_legal_name:o.legalName,phone:o.phone,company_industry:o.industry,company_business_model:o.businessModel,company_url:o.website!=null?o.website.toString():null,meeting_url:o.meetingLink!=null?o.meetingLink.toString():null,is_new_company_industry_verified:!0,...o.companySourceOfFunds!=null&&{company_source_of_funds:o.companySourceOfFunds},...o.companySourceOfFundsDescription!=null&&{company_source_of_funds_desc:o.companySourceOfFundsDescription},...o.countriesOfOperations!=null&&o.countriesOfOperations.length>0&&{company_countries_of_operations:o.countriesOfOperations},...o.transactionVolume!=null&&{company_transaction_vol_expectations:o.transactionVolume},...o.transactionVolumeDescription!=null&&{company_transaction_vol_expectations_desc:o.transactionVolumeDescription},...o.purposeOfAccount!=null&&{company_purpose_of_account:o.purposeOfAccount},...o.purposeOfAccountDescription!=null&&{company_purpose_of_account_desc:o.purposeOfAccountDescription},...o.regulatedStatus!=null&&{company_regulated_states:o.regulatedStatus==="yes"},...o.regulatedStatusDescription!=null&&{company_regulated_states_desc:o.regulatedStatusDescription},...o.usNexus!=null&&{company_us_nexus:o.usNexus==="yes"},...o.usNexusTypes!=null&&o.usNexusTypes.length>0&&{company_us_nexus_desc:o.usNexusTypes.map(Nz)}}),...Oz(e.incInfo),...Cz(e.taxDetails),...xz(e.incInfo,e.taxDetails),...e.companyInfo.companyIndustryType!=null&&{company_industry_type:e.companyInfo.companyIndustryType},...e.companyInfo.companySubIndustry!=null&&{company_industry_sub_type:e.companyInfo.companySubIndustry}};var o;const{newAddressState:c}=i.value.addressViewState,d=c?.company_address?.addressToCreate;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${a}`,n).pipe(y((l=>{const u=l.data?.companies??[];if(T(l)&&u.length>0){const m=[Q({payload:u,schema:{}})];return d!=null&&m.push(ns({addressType:"company_address",companyId:a})),m.push(zN(a)),_(m)}return p(vm({companyId:a,status:l.status}))})),v((l=>p(vm({companyId:a,status:f("Unexpected error","Update Company Details errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(hm.match),y((t=>{const e=t.payload.officer,a=t.payload.companyId,{userId:n,officerType:o}=e,c=$n(e),d=o.toLowerCase().concat("_address"),{newAddressState:l}=i.value.addressViewState,u=l?.[d]?.addressToCreate;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/users/${n}`,c).pipe(y((m=>{const h=m.data?.users??[];if(T(m)&&h.length>0){const g=[V({users:h})];return u!=null&&g.push(ns({addressType:d,companyId:a,userId:h[0].user_id})),g.push(KN({companyId:a,officerType:o})),_(g)}return p(Im({companyId:a,officerType:o,status:m.status}))})),v((m=>p(Im({companyId:a,officerType:o,status:f("Unexpected error",`Update Company Officer REST API call errored out ${JSON.stringify(m)}`)})))))}))),(s,i)=>s.pipe(S(um.match),y((r=>{const t=r.payload.companyId,{companyViewState:e,fileState:a}=i.value,n=X(e.passportView.subscriptionIDsByCompanyID,t,void 0),o=_t(i.value,t,n??[]),c=[];if(o!=null){const d=o.company.company.incInfo.fileIds,l=bm(a,d),u=YN(o,l);c.push(HN(),Fo(u)),c.push(Em(PE));const m=El(o);m!=null&&Object.keys(m).forEach((h=>{c.push(qe({addressType:h,addressToCreate:m[h]}))}))}return _(c)}))),(s,i,r)=>s.pipe(S(oO.match),y((t=>{const{companyId:e,services:a}=t.payload,{isBookkeepingEnabled:n,isBillPayEnabled:o,isReimbursementEnabled:c}=a,d=Om(i.value,e),l={};return n!=null&&(l.is_book_keeping_enabled=n,l.is_spend_management_enabled=n),o!=null&&(l.is_bill_pay_feature_enabled=o),c!=null&&(l.is_reimbursement_feature_enabled=c),Object.keys(l).length===0?_([Cm({companyId:e})]):r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,l).pipe(y((u=>{if(T(u)){const m=u.data?.companies??[],h=[];return m.length>0&&h.push(Q({payload:m,schema:{},isUpdate:!0})),n!=null&&d!=null&&h.push(iO({tenantId:d,isBookkeepingEnabled:n,isSpendManagementEnabled:n})),h.push(Cm({companyId:e})),h.push(N({messageSection:"product_services_update",messageText:"success",type:"success"})),_(h)}return _([xm(e,u.status),N({messageSection:"product_services_update",messageText:"failed",type:"error"})])})),v((u=>_([xm(e,f("Unexpected error","Update Company Product Services errored out: "+(u instanceof Error?u.message:JSON.stringify(u)))),N({messageSection:"product_services_update",messageText:"failed",type:"error"})]))))}))),(s,i,r)=>s.pipe(S(cO.match),y((t=>{const{companyId:e,qboRealmId:a}=t.payload,n=Om(i.value,e);return n==null?_([jo(e,f("Unexpected error",`No tenant found for companyId: ${e}`)),N({messageSection:"qbo_realm_id_update",messageText:"failed",type:"error"})]):r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/qbo-realm-id`,{qbo_realm_id:a??null},{"zeni-tenant-id":n}).pipe(y((o=>T(o)?_([dO({companyId:e}),N({messageSection:"qbo_realm_id_update",messageText:"success",type:"success"})]):_([jo(e,o.status),N({messageSection:"qbo_realm_id_update",messageText:"failed",type:"error"})]))),v((o=>_([jo(e,f("Unexpected error","Update Company QBO realm id errored out: "+(o instanceof Error?o.message:JSON.stringify(o)))),N({messageSection:"qbo_realm_id_update",messageText:"failed",type:"error"})]))))}))),(s,i)=>s.pipe(S(xN.match),A((r=>{const t=r.payload.filters;if(!(t?.categories==null||t?.categories?.every((a=>a.field!=null&&a.values!=null&&a.values.length>0))))return F;const{uiState:e}=i.value.companyTaskManagerViewState;return p(fs(0,e.sortKey,e.sortOrder,!1,e.filterText,t))}))),(s,i,r)=>s.pipe(S(As.match),A((t=>{const e=i.value,a=e.dashboardLayoutState.fetchState==="Error"&&e.dashboardLayoutState.error?.code===404,n={preferences:{card_order:t.payload}};return(a===!0?r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/webapp-preferences`,n):r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/webapp-preferences`,n)).pipe(y((o=>T(o)&&o.data?p(RO(o.data.preferences.card_order)):p(Lm(o.status)))),v((o=>p(Lm(f("Unexpected Error","User preferences put REST API call errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(eV.match),A((t=>{const{chargeCardId:e,statusCode:a}=t.payload,n={status_code:a,is_card_pin_change_attempted:!0};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}/pin/events`,n).pipe(y((o=>M(o)&&o.data!=null?p(st(o.data.card),V({users:o.data.users}),Y(o.data.user_roles),ed({chargeCardId:e,fetchState:"Completed"})):p(ed({chargeCardId:e,fetchState:"Error",error:o.status})))),v((o=>p(ed({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Update physical card attempt API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(UF.match),A((t=>{const{depositAccountId:e,updateType:a,nickname:n}=t.payload,o=a==="closeAccount"?{is_close_account:!0}:{account_name:n};return r.putAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${e}`,o).pipe(y((c=>T(c)?p(Qe(c.data?.deposit_accounts??[]),N({messageSection:"update_zeni_account_nickname",messageText:"success",type:"success"}),qd({depositAccountId:e,updateType:a,fetchState:"Completed"})):p(N({messageSection:"update_zeni_account_nickname",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}),qd({depositAccountId:e,updateType:a,fetchState:"Error",error:c.status})))),v((c=>p(N({messageSection:"update_zeni_account_nickname",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:JSON.stringify(c)}]}),qd({depositAccountId:e,updateType:a,fetchState:"Error",error:f("Unexpected Error","Update deposit Account REST API call errored out"+JSON.stringify(c))})))))}))),(s,i)=>s.pipe(S(gr.match),y((r=>{const t=i.value,{transactionState:e,expenseAutomationReconciliationViewState:a,expenseAutomationViewState:{selectedPeriodByTenantId:n}}=t,{selectedAccountId:o}=a,c=n[H(t).tenantId],d=[],{selectedTransactionIds:l}=r.payload;if(o!=null){const u=[],m=Ea(t,o,c);if(m==null)return _(d);const h=m.initialClearedBalance??{amount:0,currencyCode:m.currency.currencyCode,currencySymbol:m.currency.currencySymbol},g=m.balance??{amount:0,currencyCode:m.currency.currencyCode,currencySymbol:m.currency.currencySymbol};l.forEach((B=>{const x=hC(e,B);x!=null&&u.push(x)}));const I=m.account.accountType,b=(function(B,x,k){let J=ra(x.amount);const L=k==="credit_card";return B.forEach((R=>{R.transactionDirection==="payment"?J=L?J.plus(ra(R.amount.amount)):J.minus(ra(R.amount.amount)):R.transactionDirection==="deposit"&&(J=L?J.minus(ra(R.amount.amount)):J.plus(ra(R.amount.amount)))})),{amount:parseFloat(J.toFixed(2)),currencyCode:x.currencyCode,currencySymbol:x.currencySymbol}})(u,h,I),{variance:E,variancePercentage:P}=(function(B,x){const k=ra(x.amount).minus(B.amount),J=Math.abs(k.toNumber()),L=x.amount!=0?parseFloat((J/Math.abs(x.amount)*100).toFixed(2)):void 0;return{variance:{amount:J,currencyCode:x.currencyCode,currencySymbol:x.currencySymbol},variancePercentage:L}})(b,g),O={currencyCode:g.currencyCode,currencySymbol:g.currencySymbol},C=UE(u,"deposit",O),U=UE(u,"payment",O);d.push(SC({clearedBalance:b,variance:E,variancePercentage:P,deposits:C,payments:U}))}return _(d)}))),(s,i,r)=>s.pipe(S(sU.match),A((t=>{const{fileId:e,name:a,tenantId:n}=t.payload;return(n!=null?r.putAndGetJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}`,{file_name:a},Object.assign({"zeni-tenant-id":n})):r.putAndGetJSON(`${r.apiEndPoints.fileMicroServiceBaseUrl}/1.0/files/${e}`,{file_name:a})).pipe(y((o=>T(o)?p(ve({files:o.data?.files??[]}),nU({fileId:e})):p(a_({fileId:e,status:o.status})))),v((o=>p(a_({fileId:e,status:f("Unexpected Error","Update File REST API call errored out"+JSON.stringify(o))})))))}))),(s,i)=>s.pipe(S(oU.match),y((r=>{const{filesPayload:t}=r.payload,e=[];return e.push(ve({files:t})),_(e)}))),(s,i,r)=>s.pipe(S(Yk.match),y((t=>{const{data:e,invoiceId:a}=t.payload,n=`${r.apiEndPoints.invoicingMicroServiceBaseUrl}/1.0/invoices/${encodeURIComponent(a)}`;return r.putAndGetJSON(n,e).pipe(y((o=>T(o)&&o.data!=null?[Ca([o.data],"merge"),z(Or([o.data])),Q_({invoiceId:a}),N({messageSection:"invoicing_invoice_saved",messageText:"success",type:"success"})]:_([Ws({error:o.status,invoiceId:a}),N({messageSection:"invoicing_invoice_saved",messageText:"failed",type:"error",variables:Ie(o.status)})]))),v((o=>_([Ws({error:f("Unexpected Error","Invoice update REST API call errored out "+JSON.stringify(o)),invoiceId:a}),N({messageSection:"invoicing_invoice_saved",messageText:"failed",type:"error"})]))))}))),s=>s.pipe(S(ut.match),y((i=>{const r=[];if(i.payload.jeSchedulesTransactionsPayload.length>0){const t=[],e=[],a=[],n=[],o={};i.payload.jeSchedulesTransactionsPayload.forEach((c=>{const{currency_code:d}=c,l=o[d];o[d]=l!=null?{currency:l.currency,transactions:[...l.transactions,c.base_transaction]}:{currency:{currency_code:c.currency_code,currency_symbol:c.currency_symbol},transactions:[c.base_transaction]},t.push(c.vendor),e.push(c.updated_by),Zl.forEach((u=>{const m=SP(c,u);m!=null&&a.push(m);const h=Xl(c,u);h!=null&&n.push(h)}))})),r.push(W(a,"account_list"),Ke("class_list",n),le(t,"merge")),Object.keys(o).forEach((c=>{const d=o[c];r.push(eu(d.transactions,d.currency.currency_code,d.currency.currency_symbol))})),r.push(V({users:e,updateType:"merge"})),r.push(gP({jeSchedulesTransactionsPayload:i.payload.jeSchedulesTransactionsPayload}))}return _(r)}))),(s,i,r)=>s.pipe(S(sL.match),y((t=>{const{plaidAccountKeyType:e,accountId:a,depositAccountId:n}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/deposit-accounts/${n}`,{zeni_mapped_account_id:a}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[Qe(o.data?.deposit_accounts??[]),nL(e)];return _(c)}return p(aI(e,o.status))})),v((o=>p(aI(e,f("Unexpected Error","Update Mapped Cash Account errored out"+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(aF.match),A((t=>{const{companyId:e}=t.payload,a=_t(i.value,e,[]),{remiSetupViewState:n}=i.value,{mileageDetails:o}=n,c=a?.company.company.configInfo.mileageRateConfig,d=c?.mileageUnitAmount!=null;if(o.localData!=null){const l=o.localData,u={mileage_rate_config:{mileage_unit_amount:l.mileageAmountInDenomination,mileage_unit:l.mileageUnit,mileage_unit_amount_denomination:l.denomination}};return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,u).pipe(y((m=>{if(T(m)&&m.data!=null){const h=[V({users:m.data.users}),Y(m.data.user_roles),Q({payload:m.data.companies,schema:{}}),we({companyId:m.data.companies[0].company_id}),Cd({companyId:m.data.companies[0].company_id}),N({messageSection:d?"reimbursement_update_mileage":"reimbursement_create_mileage",messageText:"success",type:"success"}),CI()];return _(h)}return p(xI(m.status),N({messageSection:d?"reimbursement_update_mileage":"reimbursement_create_mileage",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:m.status.message}]}))})),v((m=>p(xI(f("Unexpected Error","Update Mileage details errored out"+JSON.stringify(m)))))))}return p(CI())}))),(s,i,r)=>s.pipe(S(ff.match),A((t=>{const e=i.value.tenantState.loggedInUser?.userId;if(e==null)return[];const a=bt(i.value.userState,e);if(a==null)return[];const n=a.addressId!=null?ot(i.value.addressState,a?.addressId):void 0,o=DK({...t.payload},a,n);return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user/self`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=vf(e,c.data.users),l=vf(yR(e,c.data.user_roles),c.data.users),u=[];switch(t.payload.origin){case"CardUserOnboarding":u.push(_R());break;case"CompleteProfile":u.push(N({messageSection:"complete_profile_done",messageText:"success",type:"success"}))}return u.push(Y(c.data.user_roles),V({users:c.data.users})),c.data.addresses!=null&&u.push(z(c.data.addresses)),l&&d!=null&&u.push(If({userType:"manager",usersPayload:l})),u.push(_f()),u.push(hR()),p(...u)}return p(bf(c.status))})),v((c=>p(bf(f("Unexpected error","Update User Profile REST API call errored out"+JSON.stringify(c)))))))}))),rz,(s,i,r)=>s.pipe(S(bD.match),A((t=>{const{notificationGroup:e,status:a}=t.payload,{notificationViewState:n}=i.value,{stateByTab:o}=n,{allNotificationsIds:c}=o.tasks,d={mark_all_as_read:a==="read"};return r.putAndGetJSON(`${r.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/user-notification-dashboard?query=${encodeURIComponent(JSON.stringify(d))}`).pipe(A((l=>M(l)?p(N({messageSection:"notification_mark_as_read",messageText:"success",type:"success"}),yS(c,a),ED(e)):p(_S({status:l.status,notificationGroup:e}),N({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]})))),v((l=>p(_S({status:f("Unexpected Error","Update All Notifications Status API call errored out"+JSON.stringify(l)),notificationGroup:e})))))}))),(s,i,r)=>s.pipe(S(PD.match),A((t=>{const{notificationGroup:e,status:a,notificationIds:n,showSnackBarOnSuccess:o}=t.payload,{notificationViewState:c,notificationState:d}=i.value,{stateByTab:l}=c,u=mS(e),m=l[u],{selectedNotificationIds:h}=m,g={notifications:[]};let I=0;return n.length>0?(n.forEach((b=>{g.notifications.push({user_notification_id:b,status:a})})),I=n.length):(h.forEach((b=>{g.notifications.push({user_notification_id:b,status:a})})),u!=="comments"&&h.forEach((b=>{d.notificationById[b]!=null&&d.notificationById[b].status!==a&&(I+=1)}))),r.putAndGetJSON(`${r.apiEndPoints.notificationMicroServiceBaseUrl}/1.0/user-notification`,{notifications:g.notifications}).pipe(A((b=>{if(M(b)){const E=g.notifications.map((O=>O.user_notification_id)),P=[];return o===!0&&P.push(N({messageSection:"notification_mark_as_read",messageText:"success",type:"success"})),P.push(yS(E,a),TD(e,I)),_(P)}return p(hS({status:b.status,notificationGroup:e}),N({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:b.status.message}]}))})),v((b=>p(hS({status:f("Unexpected Error","Update Notification Status API call errored out"+JSON.stringify(b)),notificationGroup:e})))))}))),(s,i,r)=>s.pipe(S(dJ.match),y((t=>{const{companyId:e,checkOnboardingComplete:a,productSuitePage:n}=t.payload,o={};return n===!1&&a===!1?o.is_onboarding_completed=!0:(a&&(o.should_complete_onboarding=!0),n&&(o.is_user_landed_to_interim_page=!0)),r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,o).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[Q({payload:c.data.companies,schema:{}}),lJ()];return _(d)}return p(N({messageSection:"onboarding_customer_view_complete",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:c.status.message}]}),MS(c.status))})),v((c=>p(MS(f("Unexpected Error","Update - Onboarding Customer View Complete Status errored out"+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(uJ.match),y((t=>{const{companyId:e}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,{is_dashboard_loaded:!0}).pipe(y((a=>{if(M(a)){const n=[pJ()];return a.data?.companies!=null&&n.unshift(Q({payload:a.data.companies,schema:{}})),_(n)}return p(VS(a.status))})),v((a=>p(VS(f("Unexpected Error","Update - Onboarding Customer View Dashboard Loaded errored out"+JSON.stringify(a)))))))}))),(s,i,r)=>s.pipe(S(hJ.match),y((t=>{const{companyId:e,officerType:a,sendForVerification:n,reCalculateCurrentStep:o=!1,isBillingAddressUpdate:c}=t.payload,{onboardingCustomerViewState:d}=i.value,{companyDetails:l,primaryContactDetails:u,companyOfficerUpdateStatus:m,currentStep:h,currentSubStep:g}=d,I=l.localData,b=u.localData;let E;c===!1&&a!=null&&(E=m[a].localData);const{newAddressState:P}=i.value.addressViewState;let O={};if(I!=null){c===!0&&P?.subscription_billing_address.addressToCreate!=null&&(O=hK(I,P.subscription_billing_address.addressToCreate));const C=_t(i.value,e,[]),U=P?.company_address?.addressToCreate,B=P?.company_registered_address?.addressToCreate,x=a?.toLowerCase().concat("_address"),k=P?.[x]?.addressToCreate,J=b?.userId==null||b?.email!==C?.primaryContact?.user.email,L=YE(I,n,U,B),R=b!=null&&b.email?HE(b,J):{},q=E!=null&&E.email?QE(E,!1,k):{},$=h==="verification"&&g==="company_officer";c===!1&&(O=$?{company:_K(I),company_officer:q}:{company:L,primary_contact_user:R});const D=c===!0?"setup_billing":$?"company_officer":"company_details",w={company_officer:{sendForVerification:"onboarding_customer_identity_verification_submit",save:"onboarding_customer_identity_verification_save"},company_details:{sendForVerification:"onboarding_customer_business_verification_submit",save:"onboarding_customer_business_verification_save"},setup_billing:{save:"billing_address_view",sendForVerification:"billing_address_view"}};let K;return K=c===!0?w[D].save:n===!0?w[D].sendForVerification:w[D].save,r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,O).pipe(y((G=>{if(T(G)&&G.data!=null){const{users:Z}=G.data,de=[V({users:Z}),Y(G.data.user_roles),Q({payload:G.data.companies,schema:{}}),z(G.data.addresses),ve({files:G.data.files}),W(G.data.accounts,"onboarding"),Se(G.data.payment_accounts)],ue=H(i.value).externalConnections,te=ue?.accounting?.some((_e=>_e.connectionName.match(/quickbooks/i)))??!1,{allSteps:ye}=SJ(i.value,e);return h==="setup_billing"&&(te===!0&&ye.includes("connect_ledger")?de.push(Fi({step:"connect_ledger"})):de.push(Fi({step:"verification"}))),de.push(sn({companyId:G.data.companies[0].company_id,currentStep:h,reCalculateCurrentStep:o}),N({messageSection:K,messageText:"success",type:"success"}),gJ()),_(de)}return p(N({messageSection:K,messageText:"failed",type:"error"}),FS(G.status))})),v((G=>p(FS(f("Unexpected Error","Update Onboarding Customer View Details errored out"+JSON.stringify(G)))))))}return _([])}))),(s,i)=>s.pipe(S(sn.match),y((r=>{const{companyId:t,currentStep:e,reCalculateCurrentStep:a}=r.payload,{companyState:n,companyViewState:o,userState:c,userRoleState:d,onboardingCustomerViewState:l,subscriptionPaymentAccountState:u,paymentAccountState:m,addressState:h}=i.value,{subscriptionPaymentAccountIds:g}=l,I=X(o.passportView.subscriptionIDsByCompanyID,t,void 0),b=_t(i.value,t,I??[]),E=Te(n,t)?.company,P=E?.companyOnboardingInfo.subscriptionBillingAddressId;let O;P!=null&&(O=ot(h,P));const C=qS(c,E?.managementInfo.companyOfficerUserIds??[]),U=E?.managementInfo.primaryContactUserId!=null?bt(c,E?.managementInfo.primaryContactUserId):void 0,B=jS(d,E?.managementInfo.companyOfficerUserIds??[]),x=[];if(E!=null){const k=(function(te,ye,_e,Ve){return WE(te,ye,_e,Ve)})(E,C,B,U),{companyDetails:J,officers:L,primaryContactDetails:R}=k;let q=J;if(e==="verification"&&l.currentSubStep==="company_officer"&&l.companyDetails.localData!=null){const{companyInfo:te}=E,{syncToken:ye}=te;q={...l.companyDetails.localData,syncToken:ye}}let $,D="setup_billing";const{companyOnboardingInfo:w}=E,K=w?.onboardingInfo?.accountingConnectionCreationMode;if(g.length>0){const te=g[0];$=IJ(u,te)}const G=H(i.value),Z=G.externalConnections,de=Z?.accounting[0]?.isValid??!1;if(a===!0){let te;const{paymentAccountDetails:ye}=l,{paymentAccountIds:_e}=ye;if(_e?.length>0){const Ae=_e[0];te=qi(m,Ae)}const Ve=i.value.cardPaymentViewState;(te?.providerVerificationStatus?.code?.includes("verified")===!0&&te?.isLoginRequired===!1||$?.providerVerificationStatus?.code?.includes("verified")===!0||Ve.cardPaymentsIds.length>0)&&b?.company.company.companyOnboardingInfo.subscriptionBillingAddressId!=null&&(D="connect_ledger",de&&(w?.onboardingInfo?.onboardingAiActivationInfo?.isOnboardingAiActivationViewed??!1)&&(D="connect_data_source"))}const{allStepsData:ue}=bJ(de,G?.productSettings??[],K);if(ue.length>0&&ue.indexOf(D)===-1&&(D=ue[0]),x.push(EJ(),PJ({companyDetails:q,officers:L,primaryContactDetails:R}),Vi()),O!=null&&x.push(qe({addressType:"subscription_billing_address",addressToCreate:O})),a===!0&&(x.push(Fi({step:D})),D!==l.currentStep)){const te=D==="verification"?"unlock-stack":"default";x.push(TJ({subStep:te}))}}if(b!=null){const k=El(b);k!=null&&Object.keys(k).forEach((J=>{x.push(qe({addressType:J,addressToCreate:k[J]}))}))}return _(x)}))),(s,i,r)=>s.pipe(S(AJ.match),y((t=>{const{isLoginRequired:e,paymentAccountId:a,linkTokenType:n}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts/${a}`,{is_login_required:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.payment_accounts.map((l=>l.payment_account_id)),d=[W(o.data.accounts,"onboarding"),Se(o.data.payment_accounts),NJ(c,n)];return _(d)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),GS(o.status,n))})),v((o=>p(GS(f("Unexpected Error","Update Onboarding Payment Account Login Status failed "+JSON.stringify(o)),n)))))}))),(s,i,r)=>s.pipe(S(OJ.match),y((t=>{const{verificationStatusCode:e,paymentAccountId:a,linkTokenType:n}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts/${a}`,{provider_verification_status_code:e}).pipe(y((o=>{if(T(o)&&o.data!=null){const c=o.data.payment_accounts.map((l=>l.payment_account_id)),d=[W(o.data.accounts,"onboarding"),Se(o.data.payment_accounts),CJ(c,n)];return _(d)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),zS(o.status,n))})),v((o=>p(zS(f("Unexpected Error","Update Onboarding Payment Account Status failed "+JSON.stringify(o)),n)))))}))),(s,i,r)=>s.pipe(S(oL.match),y((t=>{const{accountId:e,paymentAccountId:a,setupViewType:n,plaidAccountKeyType:o}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts/${a}`,{zeni_mapped_account_id:e}).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[W(c.data.accounts,Da(n)),Se(c.data.payment_accounts),iL(o)];return _(d)}return p(rI(c.status,o))})),v((c=>p(rI(f("Unexpected Error","Update Payment Account errored out"+JSON.stringify(c)),o)))))}))),(s,i,r)=>s.pipe(S(cL.match),y((t=>{const{isLoginRequired:e,paymentAccountId:a,setupViewType:n,linkTokenType:o,plaidAccountKeyType:c}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts/${a}`,{is_login_required:e}).pipe(y((d=>{if(T(d)&&d.data!=null){const l=d.data.payment_accounts.map((m=>m.payment_account_id)),u=[W(d.data.accounts,Da(n)),Se(d.data.payment_accounts),dL(l,o,c)];return _(u)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),sI(d.status,o,c))})),v((d=>p(sI(f("Unexpected Error","Update Payment Account Login Status failed "+JSON.stringify(d)),o,c)))))}))),(s,i,r)=>s.pipe(S(lL.match),y((t=>{const{verificationStatusCode:e,paymentAccountId:a,setupViewType:n,linkTokenType:o,plaidAccountKeyType:c}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/payment-accounts/${a}`,{provider_verification_status_code:e}).pipe(y((d=>{if(T(d)&&d.data!=null){const l=[W(d.data.accounts,Da(n)),Se(d.data.payment_accounts),uL(o,c)];return _(l)}return p(N({messageSection:"plaid_connection",messageText:"failed",type:"error"}),nI(d.status,o,c))})),v((d=>p(nI(f("Unexpected Error","Update Payment Account Status failed "+JSON.stringify(d)),o,c)))))}))),(s,i,r)=>s.pipe(S(tV.match),A((t=>{const{chargeCardId:e,statusCode:a}=t.payload,n={status_code:a,is_card_activation_attempted:!0};return r.putAndGetJSON(`${r.apiEndPoints.cardMicroServiceBaseUrl}/1.0/cards/${e}`,n).pipe(y((o=>M(o)&&o.data!=null?p(st(o.data.card),V({users:o.data.users}),Y(o.data.user_roles),td({chargeCardId:e,fetchState:"Completed"})):p(td({chargeCardId:e,fetchState:"Error",error:o.status})))),v((o=>p(td({chargeCardId:e,fetchState:"Error",error:f("Unexpected Error","Update physical card attempt API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(IF.match),A((t=>{const e=i.value.treasurySetupViewState.fundAllocationLocalData,{isEdit:a}=t.payload,n={allocation_percentages:e.allocation};return(a?r.putAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account`,n):r.postAndGetJSON(`${r.apiEndPoints.bankingMicroServiceBaseUrl}/1.0/treasury-account`,n)).pipe(y((o=>{if(T(o)){const c=[bF(o.data||{fund_allocation_percentages:{},custom_corporate_id:null})];return a&&c.push(N({messageSection:"treasury_update_portfolio_allocation",messageText:"success",type:"success"})),_(c)}return p(LI(o.status))})),v((o=>p(LI(f("Unexpected Error",(a?"Update":"Create")+" portfolio allocation REST API call errored out: "+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(_m.match),y((t=>{let{primaryContact:e}=t.payload;const a=t.payload.companyId,{userId:n,email:o}=e,c=_t(i.value,a,[]),d=n==null||o!==c?.primaryContact?.user.email;let l;return d&&(e=Object.assign({},e,{isPrimaryContact:!0})),d?l={users:[Object.assign({},$n(e),{is_changes_in_response_only:!1})]}:l=$n(e),(d?r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${a}/users`,l):r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/users/${n}`,l)).pipe(y((u=>{const m=u.data?.users??[];if(T(u)&&m.length>0){const h=[V({users:m})];return d&&h.push(Q({payload:u.data?.companies??[],schema:{}}),Y(u.data?.user_roles??[]),Fo({primaryContact:{...t.payload.primaryContact,firstName:m[0].first_name?.trim()??t.payload.primaryContact.firstName,lastName:m[0].last_name?.trim()??t.payload.primaryContact.lastName,userId:m[0].user_id}})),h.push(QN(a)),_(h)}return p(Pm({companyId:a,status:u.status}))})),v((u=>p(Pm({companyId:a,status:f("Unexpected error",`${d?"Create":"Update"} Primary Contact REST API call errored out ${JSON.stringify(u)}`)})))))}))),(s,i,r)=>s.pipe(S(pL.match),y((t=>{const{companyId:e,plaidAccountKeyType:a,accountId:n,accountType:o}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/companies/${e}`,(function(c,d,l){switch(c){case"bill_pay_setup":return{bill_pay_primary_funding_account_id:d,bill_pay_primary_funding_account_type:Me(La(l))};case"reimbursement_setup":return{reimbursement_primary_funding_account_id:d,reimbursement_primary_funding_account_type:Me(La(l))};case"charge_card_setup":return{charge_cards_primary_funding_account_id:d,charge_cards_primary_funding_account_type:Me(La(l))};case"treasury_setup":return{treasury_accounts_primary_funding_account_id:d,treasury_accounts_primary_funding_account_type:Me(La(l))};default:return{deposit_accounts_primary_funding_account_id:d,deposit_accounts_primary_funding_account_type:Me(La(l))}}})(a,n,o)).pipe(y((c=>{if(T(c)&&c.data!=null){const d=[Q({payload:c.data.companies??[],schema:{}}),mL(a),N({messageSection:"primary_funding_account_updated",messageText:"success",type:"success",variables:[{variableName:"_productType_",variableValue:qK(a)}]})];return _(d)}return p(oI(a,c.status))})),v((c=>p(oI(a,f("Unexpected Error","Update Primary Funding Account errored out"+JSON.stringify(c)))))))}))),(s,i,r)=>s.pipe(S(XD.match),A((t=>r.postAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/connections-pool`,{connection_type:t.payload.connectionMeta.connection_type,connection_name:t.payload.connectionMeta.connection_name,authorization_code:t.payload.connectionMeta.authorization_code,realm_id:t.payload.connectionMeta.realm_id,user_id:t.payload.connectionMeta.user_id,redirect_uri:eJ(t.payload.redirectUri.href,"/")}).pipe(y((e=>{if(T(e)&&e.data!=null){const a=e.data;return p(tJ(a))}return p(US(e.status))})),v((e=>p(US(f("Unexpected error","QBO Connection Pool Save errored Out: "+JSON.stringify(e)))))))))),(s,i,r)=>s.pipe(S(Cw.match),A((()=>r.putAndGetJSON(`${r.apiEndPoints.tenantMicroServiceBaseUrl}/1.0/user/self`,{has_viewed_refer_reward_plan:!0}).pipe(y((t=>M(t)?p(Uw(),xw()):p(Cg(t.status)))),v((t=>p(Cg(f("Unexpected error","Update user refer viewed REST API call errored out"+JSON.stringify(t)))))))))),(s,i)=>s.pipe(S(Cd.match),y((r=>{const{companyId:t}=r.payload,e=Te(i.value.companyState,t)?.company,a=[];return e!=null&&a.push(rF(),sF((function(n){const{configInfo:o}=n,{mileageRateConfig:c}=o,{mileageUnit:d,mileageUnitAmount:l,mileageCurrencyCode:u,mileageCurrencySymbol:m,description:h,denominationConversions:{denomination:g,denominationSymbol:I,amount:b}}=c;return{mileageDetails:{mileageUnitAmount:l!=null?Wa(l,u,m):void 0,mileageUnit:d,mileageCurrencyCode:u,mileageCurrencySymbol:m,denomination:g,denominationSymbol:I,mileageAmountInDenomination:b,description:h}}})(e))),_(a)}))),(s,i)=>s.pipe(S(Mw.match),A((r=>{const t=r.payload.selectedCOABalancesRange,e=t.thisPeriod,a=t.orderBy,n=t.numberOfPeriods,o=i.value.reportUIOptionsState.isCompareModeOn===!0?n:1,c=r.payload.highlightedCOABalancesRange==null&&e!=null?{numberOfPeriods:o,orderBy:a,thisPeriod:e}:r.payload.highlightedCOABalancesRange,d=i.value.netBurnOrIncomeState.uiState.selectedCOABalancesRange,l=i.value.opExState.uiState.selectedCOABalancesRange,u=i.value.revenueState.uiState.selectedCOABalancesRange,m=i.value.cashPositionState.uiState.selectedCOABalancesRange,h=i.value.cashInCashOutState.uiState.selectedCOABalancesRange;return p(Gw({selectedCOABalancesRange:{thisPeriod:e,orderBy:a,numberOfPeriods:d.numberOfPeriods},highlightedCOABalancesRange:c}),jw({selectedCOABalancesRange:{thisPeriod:e,orderBy:a,numberOfPeriods:l.numberOfPeriods},highlightedCOABalancesRange:c}),qw({selectedCOABalancesRange:{thisPeriod:e,orderBy:a,numberOfPeriods:u.numberOfPeriods},highlightedCOABalancesRange:c}),Fw({selectedCOABalancesRange:{thisPeriod:e,orderBy:a,numberOfPeriods:m.numberOfPeriods},highlightedCOABalancesRange:c}),Lw({selectedCOABalancesRange:{thisPeriod:e,orderBy:a,numberOfPeriods:h.numberOfPeriods},highlightedCOABalancesRange:c}),Vw({thisPeriod:r.payload.highlightedCOABalancesRange!=null?r.payload.highlightedCOABalancesRange.thisPeriod:e,numberOfPeriods:n,orderBy:a}))}))),(s,i)=>s.pipe(S(kg.match),A((r=>{const{additionalBalances:t}=r.payload,e=i.value.reportUIOptionsState.isCompareModeOn,a=r.payload.compareMode==="compare_mode_percent"?"this_period_vs_last_period_percent":"this_period_vs_last_period",n=Yi(i.value),o=t.filter((d=>d!=="this_period_vs_last_period"&&d!=="this_period_vs_last_period_percent")),c=e?[...o,a]:o;return p(Rg({isCompareModeOn:e,additionalBalances:e?[a]:[],maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),$g({isCompareModeOn:e,additionalBalances:e?[a]:[],maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),wg({isCompareModeOn:e,additionalBalances:e?[a]:[],maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),Jg({isCompareModeOn:e,additionalBalances:e?[a]:[],maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),Dg({isCompareModeOn:e,additionalBalances:e?[a]:[],maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),Bg({firstMonthOfFY:r.payload.firstMonthOfFY,isCompareModeOn:e,additionalBalances:c,maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight,coaBalances:n.balancesInTimeframe}))}))),(s,i)=>s.pipe(S(Ug.match),A((r=>{const{additionalBalances:t}=r.payload,e=r.payload.isCompareModeOn?i.value.reportUIOptionsState.compareMode==="compare_mode_percent"?["this_period_vs_last_period_percent"]:["this_period_vs_last_period"]:[],a=Yi(i.value),n=[...t.filter((c=>c!=="this_period_vs_last_period"&&c!=="this_period_vs_last_period_percent")),...e],o=[Rg({isCompareModeOn:r.payload.isCompareModeOn,additionalBalances:e,maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),$g({isCompareModeOn:r.payload.isCompareModeOn,additionalBalances:e,maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),wg({isCompareModeOn:r.payload.isCompareModeOn,additionalBalances:e,maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),Jg({isCompareModeOn:r.payload.isCompareModeOn,additionalBalances:e,maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),Dg({isCompareModeOn:r.payload.isCompareModeOn,additionalBalances:e,maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight}),Bg({firstMonthOfFY:r.payload.firstMonthOfFY,isCompareModeOn:r.payload.isCompareModeOn,additionalBalances:n,maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToHighlight,coaBalances:a.balancesInTimeframe})];return r.payload.isCompareModeOn&&o.push(Dr(r.payload.firstMonthOfFY,!1,r.payload.maxNumOfPeriodsToHighlight)),_(o)}))),(s,i)=>s.pipe(S(zw.match),A((r=>{const t=Yi(i.value);return p(Ww({thisPeriod:r.payload.thisPeriod}),Qw({thisPeriod:r.payload.thisPeriod}),Hw({thisPeriod:r.payload.thisPeriod}),bp({thisPeriod:r.payload.thisPeriod}),vp({thisPeriod:r.payload.thisPeriod}),Kw({firstMonthOfFY:r.payload.firstMonthOfFY,thisPeriod:r.payload.thisPeriod,coaBalances:t.balancesInTimeframe,maxNumOfPeriodsToHighlight:r.payload.maxNumOfPeriodsToSelect??Yw.maxNumOfPeriodsToHighlight}))}))),s=>s.pipe(S(Zw.match),A((i=>p(r$(i.payload),a$(i.payload),t$(i.payload),e$(i.payload),Xw(i.payload))))),s=>s.pipe(S(fP.match),y((i=>{const r=[],t=i.payload.sectionPayload,e=i.payload.sectionId,a=i.payload.timeframe,n=i.payload.reportId,o=i.payload.accountsMetadataPayload,c=i.payload.accountGroupMetadataPayload,d=i.payload.currencyPayload,l=o.map((m=>tu(m))),u=oo(o);if(t.accounts!=null){const m=t.accounts,h=Sl(m,u,e);h.length>0&&r.push(rs(h,d,n,a))}if(t.account_groups!=null){const m=t.account_groups,h=[],g=[];Object.keys(m).forEach((I=>{const b=c.find((E=>I===E.account_group_id));if(b!=null){const E=Object.keys(m[I].accounts),P=au(E,l);h.push({accountGroupMetadataPayload:b,accountGroupBalances:m[I],nestedAccountIds:P});const O=Sl(m[I].accounts,u,e);g.push(...O)}})),r.push(vP(a,h,d,e,n)),r.push(rs(g,d,n,a))}return _(r)}))),s=>s.pipe(S(oe.match),y((i=>{const r=[],t=i.payload.classesMetadataPayload,e=i.payload.sectionPayload,a=i.payload.sectionId,n=i.payload.timeframe,o=i.payload.reportId,c=i.payload.accountsMetadataPayload,d=i.payload.currencyPayload,l=IP(t),u=[],m=[],h=c.map((I=>tu(I))),g=oo(c);return e.classes!=null&&Object.keys(e.classes).forEach((I=>{const b=l[I].nestedClassId,E=l[I].classMetadataPayload,P=e.classes[I].accounts,O=Sl(P,g,a,{parentClassId:b,sectionId:a});m.push(...O);const C=Object.keys(P??{}),U=au(C,h);E!=null&&u.push({nestedClassId:b,classMetadata:E,classBalances:e.classes[I],nestedAccountIds:U})})),u.length>0&&r.push(bP(o,n,a,u,d)),m.length>0&&r.push(rs(m,d,o,n)),_(r)}))),s=>s.pipe(S(ie.match),y((i=>{const r=[],t=i.payload.sectionPayload,e=i.payload.sectionId,a=i.payload.timeframe,n=i.payload.reportId,o=i.payload.currencyPayload,c=i.payload.accountsMetadataPayload,d=oo(c),l=[];return t.projects!=null&&Object.keys(t.projects).forEach((u=>{const m=t.projects[u].accounts;dz(m,d,e,{projectId:u,sectionId:e},l)})),l.length>0&&r.push(rs(l,o,n,a)),_(r)}))),(s,i,r)=>s.pipe(S(eN.match),y((t=>{const e=Oe(i.value.vendorState,t.payload),a=[Op({vendorId:void 0}),_s(t.payload)];return e!=null&&a.push(nr({localData:wn(e,i.value)})),_(a)}))),(s,i)=>s.pipe(S(we.match),y((r=>{const{companyId:t}=r.payload,e=X(i.value.companyViewState.passportView.subscriptionIDsByCompanyID,t,void 0),a=_t(i.value,t,e??[]),n=Te(i.value.companyState,t)?.company,o=qS(i.value.userState,n?.managementInfo.companyOfficerUserIds??[]),c=n?.managementInfo.primaryContactUserId!=null?bt(i.value.userState,n?.managementInfo.primaryContactUserId):void 0,d=jS(i.value.userRoleState,n?.managementInfo.companyOfficerUserIds??[]),l=[];if(n!=null){const u=WE(n,o,d,c);l.push(fJ(),vJ(u)),l.push(Em(PE))}if(a!=null){const u=El(a);u!=null&&Object.keys(u).forEach((m=>{l.push(qe({addressType:m,addressToCreate:u[m]}))}))}return _(l)}))),(s,i,r)=>s.pipe(S(gC.match),A((t=>{const{accountId:e,selectedPeriod:a,statementUploadId:n}=t.payload,o=i.value.expenseAutomationReconciliationViewState.accountReconciliationRecordsBySelectedPeriod[Ee(a)]?.reconciliationByAccountID[e],c=o?.parsedStatementData,d=o?.localData?.statementUpdateLocalDataByUploadId?.[n];if(c==null||d==null)return p(ht({accountId:e,selectedPeriod:a,error:f("Missing Data","No statement update data found")}));if(d.statementTransactions.updated.some((m=>m.statementTransactionId==null))===!0)return p(ht({accountId:e,selectedPeriod:a,error:f("Invalid Data","One or more edited transactions are missing statement transaction ids")}));const l=((m,h)=>pC(xE(m,h.statementUpload)))(d,c),u=`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/2.0/statement-uploads/${n}`;return r.putAndGetJSON(u,l).pipe(y((m=>{if(T(m)===!0&&m.data!=null)return p(Cs({accountId:e,selectedPeriod:a,parsedStatementData:ny(m.data)}),sy({accountId:e,selectedPeriod:a}));const h=oy(m)?iy(m):null;return p(ht({accountId:e,selectedPeriod:a,error:m.status,dateConflict:h}))})),v((m=>p(ht({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Update Statement REST API call errored out "+(m instanceof Error?m.message:String(m)))})))))}))),(s,i,r)=>s.pipe(S(Zq.match),A((t=>{const e=i.value,{task:a,updates:n}=t.payload,o=a.id,{snoozed_until:c,...d}=((l,u,m)=>{const{taskState:h}=l,g=X(h.taskByID,u);return pY(l,{...g,...m})})(e,o,n);return r.putAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/tasks/${o}`,d).pipe(y((l=>T(l)&&l.data!=null?_([ze(l.data.tasks),Xq()]):p(Bb({error:l.status})))),v((l=>p(Bb({error:f("Unexpected Error","update task from list view REST API call errored out"+JSON.stringify(l))})))))}))),(s,i,r)=>s.pipe(S(zq.match),A((t=>{const{taskGroupId:e,taskGroupName:a}=t.payload,n={name:a};return r.putAndGetJSON(`${r.apiEndPoints.taskMicroServiceBaseUrl}/1.0/task-manager/groups/${e}`,n).pipe(y((o=>{if(T(o)&&o.data!=null){const c=[Ab(o.data.task_groups[0]),nl({fetchState:"Completed"}),Kq({taskGroupId:e,taskGroupName:a}),N({messageSection:"task_group_update_success",messageText:"success",type:"success"})];return _(c)}return p(nl({fetchState:"Error",error:o.status}))})),v((o=>p(nl({fetchState:"Error",error:f("Unexpected Error","Update Task Group REST API call errored out"+JSON.stringify(o))})))))}))),(s,i,r)=>s.pipe(S(Lb.match),y((t=>{const{transactionState:e,vendorState:a,transactionDetailState:n}=i.value,o=Ms(i.value),{cotTransactionTracking:c,transactionId:d,transactionSaveUpdates:l}=t.payload;return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/transactions/${t.payload.transactionId.id}/categorize`,(function(u,m,h,g,I,b,E){const P=Be(g),O=At(u,P),C=X(h.transactionDetailById,P,void 0),U=C?.transactionDetailLocalData.vendorUpdates,B=C?.transactionDetailLocalData.customerUpdates,x=C?.transactionDetailLocalData.selectedEntity;let k;if(U?.qboId!=null&&x!=null&&x.type==="vendor"){const L=Oe(m,U.qboId)??U;L!=null&&(k={id:L.qboId===L.name?"":L.qboId??"",name:L.name})}let J;if(B?.qboId!=null&&x!=null&&x.type==="customer"&&(J={id:B.qboId,name:B.name}),O!=null){const L=yY(I.updates,O,b,E,k,J,x,I.deletedLineIds,I.addedLines);return{entity_related_updates:SY(I.entityRelatedUpdates),transaction_id:g.id,transaction:L}}})(e,a,n,d,l,c,o)).pipe(y((u=>{if(T(u)&&u.data!=null){const m=Is(u.data.transaction),h=Be(m),g=[];u.data.vendors!=null&&g.push(le(u.data.vendors,"merge")),g.push(va(h,u.data.transaction,"replace")),g.push(bs({transactionId:m,vendorId:u.data.vendors?.[0]?.vendor_id})),g.push(Dn(m,"Completed"));const I=pa(i.value.accountState,i.value.accountListState,"accountList"),b=_j(u.data.transaction),E=pt(i.value),P=_Y(b,I,E,t.payload.isExpenseAutomationEnabled);t.payload.transactionSaveUpdates.markAsMiscatUpdates===!0&&P.length>0?g.push(Mb(m,t.payload.transactionSaveUpdates,t.payload.isExpenseAutomationEnabled,P)):(g.push(ol({transactionId:t.payload.transactionId,fetchState:"Completed"})),t.payload.transactionSaveUpdates.anyBulkUpdates===!0?g.push(N({messageSection:"transactionDetails_updatingPastTransactions",messageText:"success",type:"success"})):g.push(N({messageSection:"transactionDetails_transactionUpdated",messageText:"success",type:"success"}))),g.push(Ce([u.data.transaction],(U=>U.transaction_id),"merge"));const O=Vs(b),C=hj(O);return g.push(Yy(m,O,C)),_(g)}return Sj(u)?p(Dn(t.payload.transactionId,"Error",u.status),gj({transactionId:t.payload.transactionId})):p(Dn(t.payload.transactionId,"Error",u.status))})),v((u=>p(Dn(t.payload.transactionId,"Error",f("Unexpected Error",`REST API call errored out ${u}`))))))}))),(s,i,r)=>s.pipe(S(U1.match),y((t=>{const e=i.value,{emailId:a,vendorId:n,billId:o}=t.payload,c=e.vendorState?.vendorByID?.[n],d=(function(u,m,h){const g={};if(g.vendor_name=m.name,g.account=null,m.accountId!=null){const E=Ze(u.accountState,m.accountId,"account_list");E!=null&&(g.account=Qr(E))}if(g.accounting_class=null,m.classId!=null){const E=Up(u.classState,{classId:m.classId,reportId:"class_list"});E!=null&&(g.accounting_class=Wr(E))}g.vendor_type=m.vendorType,g.owner_id=m.ownerId??null,g.is_vendor_1099=m.isVendor1099,g.document_ids=m.documentIds,g.bank_account_ids=m.bankAccountIds,g.sync_token=m.syncToken,g.qbo_id=m.qboId,g.country_code=m.countryCode,g.vendor_currency_code=m.vendorCurrencyCode??Us.currencyCode,g.vendor_currency_symbol=m.vendorCurrencySymbol??Us.currencySymbol;const I=h0(u.contactState,m.contactIds);g.contacts=I.map((E=>hs(E)));const b=hs({fullName:"",email:h,phone:""});return g.contacts?.push(b),g})(e,c,a);let l=e.editBillDetailViewState.newBillState;if(o!=null){const u=Ne(o);l=e.editBillDetailViewState.editBillStateById[u]}return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${n}`,d).pipe(y((u=>{if(T(u)){const m=u.data?.vendors[0]!=null?or(u.data?.vendors[0]):void 0,h=dt(u.data?.vendors??[]),g=[le(u.data?.vendors??[]),mt(u.data?.vendors[0].contacts??[]),z(h),Je(u.data?.vendors[0].bank_accounts??[])];return g.push(lt({billDetailLocalData:{...l.billDetailLocalData,vendor:m,paymentDetailsSection:{...l.billDetailLocalData.paymentDetailsSection,paymentTo:void 0},isCollectToAccountInfoFromVendorContact:!0,toAccountVendorEmail:a},billId:o})),g.push(Bc("Completed")),g.push(N({messageSection:"update_vendor",messageText:"success",type:"success"})),_(g)}return p(Bc("Error",u.status),N({messageSection:"update_vendor",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:u.status.message}]}))})),v((u=>p(Bc("Error",f("Unexpected Error",`REST API call errored out ${JSON.stringify(u)}`))))))}))),(s,i,r)=>s.pipe(S(fC.match),y((t=>{const{accountId:e,selectedPeriod:a,payload:n,statementAccountScope:o}=t.payload,{start:c,end:d}=Re(a,!0),l=Ze(i.value.accountState,e,"account_reconciliation");if(l==null)return p(ai({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Account not found")}));const u=l.accountType=="credit_card"?"card":"bank",m=i.value.expenseAutomationReconciliationViewState.accountReconciliationRecordsBySelectedPeriod[Ee(a)]?.reconciliationByAccountID[e]?.localData?.statementAccountScope,h=(o??m??"single_account")==="multi_account",g={account_id:e,statement_start_date:c.toString(),statement_end_date:d.toString(),processor_run_id:n.processor_run_id,file_id:n.files[0].file_id,statement_type:u,is_combined_statement:h};return r.postAndGetJSON(`${r.apiEndPoints.reconciliationMicroServiceBaseUrl}/1.0/reconciliation/statements`,g).pipe(y((I=>{if(T(I)===!0&&I.data!=null){const b=[],E=ba(e,a);return b.push(vC(E,I.data)),b.push(ve({files:[I.data.file]})),b.push(IC({accountId:e,selectedPeriod:a})),_(b)}return p(ai({accountId:e,selectedPeriod:a,error:I.status}))})),v((I=>p(ai({accountId:e,selectedPeriod:a,error:f("Unexpected Error","Upload Account Statement REST API call errored out "+JSON.stringify(I))})))))}))),s=>s.pipe(S(fj.match),A((i=>{const r=Is(i.payload.payload),t=Be(r);return p(N({messageSection:"receipts_upload",messageText:"success",type:"success"}),va(t,i.payload.payload))}))),(s,i)=>s.pipe(S(Bx.match),y((r=>{const{transactionPayload:t,updateType:e}=r.payload,a=[],n=H(i.value),o=i.value.expenseAutomationViewState.selectedPeriodByTenantId;if(a.push(va(t.transaction_id,t,e)),n!=null){const c=o[n.tenantId];c!=null&&a.push(et({tenantId:n.tenantId,period:c,refreshViewInBackground:!0}))}return _(a)}))),(s,i)=>s.pipe(S(Gx.match),y((r=>{const{transactionPayload:t,updateType:e}=r.payload,a=[],n=H(i.value),o=i.value.expenseAutomationViewState.selectedPeriodByTenantId;if(a.push(va(t.transaction_id,t,e)),n!=null){const c=o[n.tenantId];c!=null&&a.push(et({tenantId:n.tenantId,period:c,refreshViewInBackground:!0}))}return _(a)}))),(s,i,r)=>s.pipe(S(a1.match),y((()=>{const{billsBulkActionViewState:t}=i.value,{billsSelectedForBulkAction:e,bulkOperationTypeSelected:a}=t,n={entity_ids:e,validations:[a==="send_for_approval"?"all":"sufficient_funds"]};return r.getJSON(`${r.apiEndPoints.spendManagementMicroServiceBaseUrl}/1.0/bulk/bills/transactions/validate?query=${encodeURIComponent(JSON.stringify(n))}`).pipe(y((o=>{if(M(o)){const c=[];return c.push(r1(o.data?.validation_results??[])),_(c)}return p(rv(o.status))})),v((o=>p(rv(f("Unexpected Error","Bill bulk review action REST API call errored out "+JSON.stringify(o)))))))}))),(s,i,r)=>s.pipe(S(Kj.match),y((t=>{const e=i.value,a=e.vendorFiling1099UploadDetailsState,n=t.payload.signal,o=i.value.addressViewState.newAddressState?.vendor_address.addressToCreate,c=t.payload.vendorId,d=Yj(e,a.vendor1099DetailsLocalData,c,o);return r.putAndGetJSON(`${r.apiEndPoints.accountMicroServiceBaseUrl}/1.0/vendors/${c}`,d,{},n).pipe(y((l=>{if(T(l)&&l.data!=null){const u=dt(l.data.vendors),m=gs(l.data.vendors),h=[le(l.data.vendors),mt(l.data.vendors[0].contacts??[]),z(u),Je(m)];return h.push(Hj(t.payload.vendorId)),h.push(dl("Completed")),h.push(N({messageSection:"update_vendor",messageText:"success",type:"success"})),_(h)}return p(dl("Error",l.status),N({messageSection:"update_vendor",messageText:"failed",type:"error",variables:[{variableName:"_api-error_",variableValue:l.status.message}]}))})),v((l=>p(dl("Error",f("Unexpected Error",`Vendors Filing 1099 Upload Details save REST API call errored out ${JSON.stringify(l)}`))))))}))),sz,nz,oz,(s,i)=>s.pipe(S(Pc.match),A((r=>{const{billId:t}=r.payload;return s.pipe(S((e=>yc.match(e))),Ue(1),y((()=>p(Tc(t)))))}))),(s,i)=>s.pipe(S(oS.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;return s.pipe(S((a=>qs.match(a)||Nr.match(a))),Ue(1),y((()=>p(nS(t,e)))))}))),(s,i)=>s.pipe(S(WS.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;return s.pipe(S((a=>qs.match(a)||Nr.match(a))),Ue(1),y((()=>p(QS(t,e)))))}))),(s,i)=>s.pipe(S(Gg.match),A((r=>{const{cacheOverride:t,forecastId:e}=r.payload;return s.pipe(S((a=>qs.match(a)||Nr.match(a))),Ue(1),y((()=>p(jg(t,e)))))}))),(s,i)=>s.pipe(S(Tn.match),Oa((r=>{const{reimbursementId:t}=r.payload;return s.pipe(S((e=>ms.match(e))),Ue(1),y((e=>{const a=i.value,{entityType:n,entityIdOrName:o}=e.payload;if(n==="merchant"&&o){const c=a.editRemiDetailViewState;let d;d=t!=null?c.editRemiStateById[t]:c.newRemiState;const l=Object.values(d.remiDetailLocalData.updatesByLineId).filter((u=>u.type==="out_of_pocket"&&(u.outOfPocket.merchant?.id===o||u.outOfPocket.merchant?.name===o))).map((u=>u.lineId)).filter((u=>!!u));if(l.length===0){const u=d.tentativeMerchantNameByLineId;Object.keys(u).forEach((m=>{u[m]===o&&l.push(m)}))}if(l.length>0){const{recommendations:u=[]}=ps(a,o,"merchant"),m=t!=null?a.reimbursementState.reimbursementById[t]:void 0;return _(l.map((h=>Sd({reimbursementId:t,lineId:h,recommendations:u,reimbursementStageCode:m?.reimbursementInfo.stage.code,shouldAutofill:!0}))))}}return _([])})))}))),(s,i)=>s.pipe(S(nv.match),A((r=>{const{vendorId:t}=r.payload;return s.pipe(S((e=>Cp.match(e))),Ue(1),y((()=>{const e=i.value,a=[],n=Oe(e.vendorState,t);let o=e.editBillDetailViewState.newBillState;if(r.payload.billId!=null){const c=Ne(r.payload.billId);o=e.editBillDetailViewState.editBillStateById[c]}return n!=null&&(n.vendorCurrencyCode==null||Uo(n.vendorCurrencyCode)||a.push(ya(!0,{amount:o.billDetailLocalData.totalAmount?.amount??0,currencyCode:n.vendorCurrencyCode??"USD",currencySymbol:n.vendorCurrencySymbol??"$"},"USD",r.payload.billId)),a.push(lt({billDetailLocalData:Bl(e,o,n),billId:r.payload.billId})),a.push(aa(n.qboId,!1))),_(a)})))}))),(s,i)=>s.pipe(S(ov.match),A((r=>{const{invoiceProcessingPayload:t,isVendorRecommendationFeatureEnabled:e,billId:a}=r.payload;return s.pipe(S((n=>hc.match(n)||Cc.match(n))),Ue(1),y((()=>p(Oc(t,e,a)))))}))),(s,i)=>s.pipe(S(kf.match),A((r=>{const{billId:t,billDetail:e,vendorId:a}=r.payload;return s.pipe(S((n=>hc.match(n))),Ue(1),y((()=>_([yc({billId:t,billDetail:e}),Lr(t,"Completed",void 0,a)]))))}))),(s,i)=>s.pipe(S(us.match),A((r=>{const{vendorName:t}=r.payload;return s.pipe(S((e=>ms.match(e))),Ue(1),y((()=>{const e=i.value;if(t!=null){const{recommendations:a=[]}=ps(e,t,"vendor");return p(Np({recommendations:a,vendorId:void 0}))}return _([])})))}))),(s,i,r)=>s.pipe(S(rM.match),A((t=>{const{code:e,profileId:a,tenantId:n}=t.payload;return r.getJSON(`${r.apiEndPoints.payMicroServiceBaseUrl}/1.0/wise/callback/link-account?code=${encodeURIComponent(e)}&profileId=${encodeURIComponent(a)}&state=${encodeURIComponent(n)}`).pipe(y((o=>M(o)?p($c({fetchState:"Completed"})):p($c({fetchState:"Error",error:o.status})))),v((o=>p($c({fetchState:"Error",error:f("Unexpected Error","Fetch wiseRedirect REST API call errored out"+JSON.stringify(o))})))))})))],DY=new Set(iz),JY=AG(...BY.filter((s=>!DY.has(s)))),MY=(s,i,r)=>JY(s,i,r).pipe(nt(cz),v(((t,e)=>(console.error(t),e))));export{MY as featureRootEpic};