@accounter/client 0.0.9-alpha-20260104171016-0827494e597ab1c75ea9146a53f1b084291d7541 → 0.0.9-alpha-20260104174635-d97eb8078eafe181887dd878f1ed40e5b36b1e59

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 (95) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/dist/assets/{Checkbox-CIjNLOvn.js → Checkbox-DB0ksED6.js} +1 -1
  3. package/dist/assets/{MultiSelect-E2FPCJdH.js → MultiSelect-zOjALMtX.js} +1 -1
  4. package/dist/assets/{Progress-DMJQvFdk.js → Progress-t6R1Ap8G.js} +1 -1
  5. package/dist/assets/{Table-0rvmS2wr.js → Table-BKmRkEex.js} +1 -1
  6. package/dist/assets/{Typography-4nqQ7puF.js → Typography-ZEktyHzY.js} +1 -1
  7. package/dist/assets/{YearPickerInput-XVeVR1Oa.js → YearPickerInput-D5CNiDUw.js} +1 -1
  8. package/dist/assets/{accordion-L1IRyzyA.js → accordion-ByPdqgz2.js} +1 -1
  9. package/dist/assets/{accountant-approvals-D3Rk9Awv.js → accountant-approvals-V3cGFQxe.js} +1 -1
  10. package/dist/assets/{accounter-table-DO07S-Ok.js → accounter-table-DFs02wur.js} +1 -1
  11. package/dist/assets/{addDays-B1nYv7cD.js → addDays-CqDW575k.js} +1 -1
  12. package/dist/assets/{all-charges-Bl4rmLPr.js → all-charges-BvCbQ1Hs.js} +1 -1
  13. package/dist/assets/{arrow-up-down-RAyr4F6x.js → arrow-up-down-BgwxCALK.js} +1 -1
  14. package/dist/assets/{building-2-CJWjJWAd.js → building-2-Br1I1DXZ.js} +1 -1
  15. package/dist/assets/{business-extended-info-CZ8kd93o.js → business-extended-info-DNF3mKMK.js} +1 -1
  16. package/dist/assets/{business-header-DnJ4wJTw.js → business-header-dEe-9q-5.js} +1 -1
  17. package/dist/assets/{business-ledger-filters-b6ihKqcv.js → business-ledger-filters-Dr56dJhD.js} +1 -1
  18. package/dist/assets/{business-ledger-single-CTJvfW-L.js → business-ledger-single-DCVgQAfG.js} +1 -1
  19. package/dist/assets/{business-trip-D71-CjJS.js → business-trip-BWsOs-ZR.js} +1 -1
  20. package/dist/assets/{business-CD7jRx3V.js → business-zgPPVNSB.js} +1 -1
  21. package/dist/assets/{charge-BKa3ocZT.js → charge-CpynqQxr.js} +1 -1
  22. package/dist/assets/{charges-filters-f-g5zs9d.js → charges-filters-DhCpuaf1.js} +1 -1
  23. package/dist/assets/{charges-ledger-validation-C1uzo7m-.js → charges-ledger-validation-DpRFgT2v.js} +1 -1
  24. package/dist/assets/{charges-table-BlXyOjYT.js → charges-table-Ca8NLtQw.js} +1 -1
  25. package/dist/assets/{chart-CVakbbuJ.js → chart-DOzAbHsx.js} +1 -1
  26. package/dist/assets/{contracts-BEtzHuzD.js → contracts-CRNguAZo.js} +1 -1
  27. package/dist/assets/{data-table-column-header-Dm4KLrte.js → data-table-column-header-BvxwVRjw.js} +1 -1
  28. package/dist/assets/{data-table-pagination-DXDS4nhy.js → data-table-pagination-CfvjMjRT.js} +1 -1
  29. package/dist/assets/{deposits-transactions-table-CTYnxtJU.js → deposits-transactions-table-Bv0SsZOc.js} +1 -1
  30. package/dist/assets/{download-csv-button-BMcEBrSS.js → download-csv-button-BeYQaUZA.js} +1 -1
  31. package/dist/assets/{editable-business-trip-Bp6IxoxB.js → editable-business-trip-BzM8VJGV.js} +1 -1
  32. package/dist/assets/{eye-off-CEEw38cP.js → eye-off--kONYNyo.js} +1 -1
  33. package/dist/assets/{funnel-wCPsNKWN.js → funnel-B3hXp3Nu.js} +1 -1
  34. package/dist/assets/{index-Bnf9EGJh.js → index-5G0OomuH.js} +1 -1
  35. package/dist/assets/{index-BwIk76Fe.js → index-5oJW1xOa.js} +1 -1
  36. package/dist/assets/{index-DM8ePwsN.js → index-B-9ash87.js} +1 -1
  37. package/dist/assets/{index-DKpeP7IO.js → index-B-F9i6BN.js} +1 -1
  38. package/dist/assets/index-B0-LYemC.css +1 -0
  39. package/dist/assets/{index-CeNpBiZt.js → index-B7rFfcI3.js} +1 -1
  40. package/dist/assets/{index-D9594uhM.js → index-B8fQ4SCv.js} +1 -1
  41. package/dist/assets/{index-DpHMidPk.js → index-BGOlECQl.js} +1 -1
  42. package/dist/assets/{index-qmr8EzkY.js → index-BHPLIvfC.js} +1 -1
  43. package/dist/assets/{index-D740cLRg.js → index-BOmBs1Cf.js} +1 -1
  44. package/dist/assets/{index-DSnmInPt.js → index-BrmDi3nI.js} +1 -1
  45. package/dist/assets/{index-CLejPZ03.js → index-BzBXqTGh.js} +1 -1
  46. package/dist/assets/{index-CDqlmlUs.js → index-C35jI3My.js} +2 -2
  47. package/dist/assets/{index-Dtg9Ebru.js → index-CKDVNElF.js} +1 -1
  48. package/dist/assets/{index-DI-u7X-4.js → index-CKxDAbAb.js} +1 -1
  49. package/dist/assets/{index-aKsfgLig.js → index-CNSYIQL0.js} +1 -1
  50. package/dist/assets/{index-CoZLNRyy.js → index-ClCVi_Pq.js} +1 -1
  51. package/dist/assets/{index-B8pw7b-t.js → index-CooQs47i.js} +1 -1
  52. package/dist/assets/{index-B0iyn-mI.js → index-D2dFcVF6.js} +1 -1
  53. package/dist/assets/{index-Bhwo2jRi.js → index-D9mftpgT.js} +1 -1
  54. package/dist/assets/{index-CJQEWig2.js → index-DEV5LiNl.js} +81 -81
  55. package/dist/assets/{index-DMYTBz5s.js → index-D_vjD22L.js} +1 -1
  56. package/dist/assets/{index-BXce2cs4.js → index-DvGcGd-M.js} +1 -1
  57. package/dist/assets/{index-MwL919Y6.js → index-SSi9xYyM.js} +1 -1
  58. package/dist/assets/{index-B_RJNtUo.js → index-nq1clO0t.js} +1 -1
  59. package/dist/assets/{index-Dc3RBoFY.js → index-vFIYBZRp.js} +1 -1
  60. package/dist/assets/{index-oG-TuXTF.js → index-yS8Dzz8d.js} +1 -1
  61. package/dist/assets/{index.es-D5j_e-90.js → index.es-o1buw8cn.js} +1 -1
  62. package/dist/assets/{insert-business-trip-modal-DAddh4SL.js → insert-business-trip-modal-FZvpLLha.js} +1 -1
  63. package/dist/assets/issue-document-CEl-ww76.js +1 -0
  64. package/dist/assets/{list-plus-D47DH24w.js → list-plus-uhcKtu05.js} +1 -1
  65. package/dist/assets/{login-page-BrIhzx0o.js → login-page-D_KXZh5N.js} +1 -1
  66. package/dist/assets/match-document-modal-CoD32N9X.js +1 -0
  67. package/dist/assets/{missing-info-charges-D-yagKqj.js → missing-info-charges-DymipNvy.js} +1 -1
  68. package/dist/assets/{modal-B-dHSlvi.js → modal-BU8TISCI.js} +1 -1
  69. package/dist/assets/{modify-contract-dialog-CPd5HePs.js → modify-contract-dialog-Bp9pVouf.js} +1 -1
  70. package/dist/assets/{page-layout-B2gYTWUz.js → page-layout-DzyS2SLh.js} +1 -1
  71. package/dist/assets/{page-not-found-DNb-8ubr.js → page-not-found-BrbsbcFH.js} +1 -1
  72. package/dist/assets/{panel-top-open-et1B6Qub.js → panel-top-open-BVYyrhXF.js} +1 -1
  73. package/dist/assets/{report-commentary-row-BEtZ8QZo.js → report-commentary-row-CfIk3EUM.js} +1 -1
  74. package/dist/assets/{save-DYKKYhD4.js → save-BVkPTt8i.js} +1 -1
  75. package/dist/assets/{similar-transactions-modal-DPUwmIYc.js → similar-transactions-modal-BJxT9GAZ.js} +1 -1
  76. package/dist/assets/{sub-CP-0oRhw.js → sub-Dz0fJPLy.js} +1 -1
  77. package/dist/assets/subMonths-B0TEAjr8.js +1 -0
  78. package/dist/assets/{summary-CzvCns1x.js → summary-B3q161uS.js} +1 -1
  79. package/dist/assets/{toggle-expansion-button-CERf5wnd.js → toggle-expansion-button-D8u5XCV3.js} +1 -1
  80. package/dist/assets/{use-issue-monthly-documents-BxcraBxY.js → use-issue-monthly-documents-C9q3hH_f.js} +1 -1
  81. package/dist/assets/{use-url-query-B4uMZFi3.js → use-url-query-B0EImNN2.js} +1 -1
  82. package/dist/index.html +2 -2
  83. package/package.json +3 -3
  84. package/src/components/common/inputs/combo-box.tsx +59 -42
  85. package/src/components/common/inputs/tag-input.tsx +3 -15
  86. package/src/components/common/inputs/tags-input.tsx +2 -14
  87. package/src/components/documents-table/cells/creditor.tsx +1 -1
  88. package/src/components/documents-table/cells/debtor.tsx +1 -1
  89. package/src/components/documents-table/cells/description.tsx +1 -1
  90. package/src/components/documents-table/cells/remarks.tsx +1 -1
  91. package/src/components/documents-table/cells/type.tsx +1 -1
  92. package/dist/assets/index-DTtRdw34.css +0 -1
  93. package/dist/assets/issue-document-DhsyLMjh.js +0 -1
  94. package/dist/assets/match-document-modal-CIlUk8Ew.js +0 -1
  95. package/dist/assets/subMonths-Cu93C5UH.js +0 -1
@@ -1,2 +1,2 @@
1
- import{v as ce,w as Qe,u as le,S as Ks,r as v,j as e,D as Te,x as Be,y as Ys,c as Ze,g as Ee,t as X,i as Pe,U as Xs,z as Oe,E as Je,G as fe,H as Ce,J as Q,K as Z,N as As,O as J,Q as ee,V as Le,W as se,X as de,Y as j,Z as g,_ as f,$ as y,I as C,a0 as S,a1 as b,a2 as Ae,B as T,a3 as te,a4 as ie,a5 as es,a6 as Qs,a7 as xe,a8 as ss,a9 as ns,aa as ue,ab as M,ac as as,ad as Zs,ae as q,af as Js,ag as re,ah as en,ai as pe,R as Is,aj as sn,ak as nn,al as ts,am as is,an as rs,ao as ws,ap as Ds,aq as ks,ar as Ss,as as Ts,at as oe,au as Bs,av as Es,aw as Ps,ax as an,ay as Os,az as Ue,aA as tn,aB as rn,aC as cs,aD as cn,P as ln,aE as on,aF as H,aG as os,aH as Me,aI as dn,aJ as mn,aK as un,aL as Ls,aM as xn,aN as hn,aO as pn,aP as jn,aQ as gn,aR as Fs,aS as fn,aT as P,aU as qe,aV as Ms,aW as He,aX as ds,aY as vn,aZ as _s,a_ as yn,a$ as Nn,b0 as bn,b1 as me,b2 as Cn,b3 as An,b4 as In,b5 as Ge,b6 as wn,b7 as Dn,b8 as kn,b9 as Sn,ba as Tn,bb as ms,bc as Bn,bd as En,be as Pn,bf as On,bg as us,bh as Ln,bi as Fn,bj as Mn,bk as _n,F as Rn,bl as zn,bm as Vn,bn as ne,bo as $n,bp as Un,bq as Y,br as qn,a as Hn,b as Gn,bs as Wn}from"./index-CJQEWig2.js";import{S as ls}from"./save-DYKKYhD4.js";import{B as De}from"./building-2-CJWjJWAd.js";import{B as Kn}from"./business-extended-info-CZ8kd93o.js";import{B as Yn}from"./business-header-DnJ4wJTw.js";import{S as Xn,C as Qn,L as Zn,W as Jn}from"./charges-table-BlXyOjYT.js";import{i as ea,D as sa,f as na,E as aa,L as _e,a as we,C as ta,A as ia,b as ve,c as ra,d as We,h as ca,e as la,g as Rs,u as oa,G as da,j as xs,k as ma,X as zs,Y as Vs,l as ua,m as xa,R as ha,n as pa,o as ja,p as ga}from"./chart-CVakbbuJ.js";import{M as Ke,s as fa,a as va}from"./modify-contract-dialog-CPd5HePs.js";import{u as ya,E as Na}from"./use-issue-monthly-documents-BxcraBxY.js";import{s as ba}from"./subMonths-Cu93C5UH.js";import{E as Ca,T as Aa}from"./index-MwL919Y6.js";import{A as Ia,a as Re,b as hs,c as ps}from"./accordion-L1IRyzyA.js";import"./data-table-column-header-Dm4KLrte.js";import"./eye-off-CEEw38cP.js";import"./download-csv-button-BMcEBrSS.js";import"./toggle-expansion-button-CERf5wnd.js";import"./panel-top-open-et1B6Qub.js";import"./Table-0rvmS2wr.js";import"./summary-CzvCns1x.js";import"./list-plus-D47DH24w.js";import"./deposits-transactions-table-CTYnxtJU.js";import"./Checkbox-CIjNLOvn.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-DPUwmIYc.js";import"./addDays-B1nYv7cD.js";const wa=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]],Da=ce("badge-question-mark",wa);const ka=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],Sa=ce("bitcoin",ka);const Ta=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Ba=ce("chart-line",Ta);const Ea=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ze=ce("circle-check",Ea);const Pa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],js=ce("circle-slash",Pa);const Oa=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ke=ce("dollar-sign",Oa);const La=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],Fa=ce("file-check",La);const Ma=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],_a=ce("fullscreen",Ma);const Ra=[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]],za=ce("notebook",Ra);const Va=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],$a=ce("plug",Va);function Ua(s){return Qe(s,"yyyy-MM-dd")}function qa({businessId:s,tagIds:n,description:a,open:t,onOpenChange:c,onClose:o}){const[{data:i,fetching:l},x]=le({pause:!0,query:Ks,variables:{businessId:s,tagsDifferentThan:n?n.map(h=>h.id):void 0,descriptionDifferentThan:a}});v.useEffect(()=>{t&&(n||a)&&!i&&x()},[t,n,a,x,i]);const d=v.useCallback(h=>{c(h),t&&!h&&o?.()},[c,o,t]),m=v.useMemo(()=>t&&(!!n||!!a)&&i&&i?.similarChargesByBusiness.length>0,[t,n,a,i]);return e.jsx(Te,{open:m,onOpenChange:d,children:e.jsx(Be,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:h=>h.stopPropagation(),children:e.jsx(Ys,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:l?e.jsx(Ze,{}):n||a?e.jsx(Xn,{data:i?.similarChargesByBusiness??[],tagIds:n,description:a,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const Ha="updateAdminBusiness",Ga=()=>{const[{fetching:s},n]=Ee(Xs),a=v.useCallback(async t=>{const c=`Error updating admin business ID [${t.adminBusinessId}]`,o=`${Ha}-${t.adminBusinessId}`;X.loading("Updating admin business",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateAdminBusiness");if(l)return X.success("Success",{id:o,description:"Admin Business Updated"}),l.updateAdminBusiness}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:a}},Ve=xe({year:as().min(2e3).max(2100),id:M().min(1,{message:"ID is required"})}),Wa=xe({registrationDate:M().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:ue(Ve),withholdingTaxCompanyId:M().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:ue(Ve),socialSecurityDeductionsId:M().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:ue(Ve),taxAdvancesRates:ue(xe({date:Zs(),rate:as().min(0,{message:"Rate must be at least 0"}).max(100,{message:"Rate must be at most 100"})}))}),ye={WITHHOLDING_TAX:"https://secapp.taxes.gov.il/NikPay/StartPage.aspx#/Home",TAX_ADVANCES:"https://secapp.taxes.gov.il/gmftashmh/main/entrance",SOCIAL_SECURITY:"https://b2b.btl.gov.il/BTL.ILG.Payments/ChovDochMaasikInfo.aspx",VAT:"https://secapp.taxes.gov.il/emdvhmfrt/wLogOnMenu.aspx"},Ne=({href:s,children:n})=>e.jsxs("h3",{className:"flex flex-row gap-2 text-sm font-semibold text-foreground md:col-span-2",children:[e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.jsx(ss,{size:12})}),e.jsx("span",{children:n})]});function gs(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{registrationDate:s.adminInfo.registrationDate,withholdingTaxAnnualIds:s.adminInfo.withholdingTaxAnnualIds.sort((n,a)=>a.year-n.year),withholdingTaxCompanyId:s.adminInfo.withholdingTaxCompanyId??void 0,socialSecurityEmployerIds:s.adminInfo.socialSecurityEmployerIds.sort((n,a)=>a.year-n.year),socialSecurityDeductionsId:s.adminInfo.socialSecurityDeductionsId??void 0,taxAdvancesAnnualIds:s.adminInfo.taxAdvancesAnnualIds.sort((n,a)=>a.year-n.year),taxAdvancesRates:s.adminInfo.taxAdvancesRates?.map(n=>({date:n.date,rate:n.rate*100}))}}function Ka(s){return{registrationDate:s.registrationDate?Ua(new Date(s.registrationDate)):void 0,withholdingTaxAnnualIds:s.withholdingTaxAnnualIds,withholdingTaxCompanyId:s.withholdingTaxCompanyId,socialSecurityEmployerIds:s.socialSecurityEmployerIds,taxAdvancesRates:s.taxAdvancesRates?.map(n=>({date:n.date,rate:n.rate/100})),taxAdvancesAnnualIds:s.taxAdvancesAnnualIds}}function Ya({data:s,refetchBusiness:n}){const a=fe(Qs,s),[t,c]=v.useState(gs(a)),{updateAdminBusiness:o,fetching:i}=Ga(),l=Oe({resolver:Je(Wa),defaultValues:t}),x=async w=>{if(!a)return;const D=ns(w,l.formState.dirtyFields);if(!D)return;const z=Ka(D);await o({adminBusinessId:a.id,fields:z}),n?.()};v.useEffect(()=>{if(a){const w=gs(a);c(w),l.reset(w)}},[a,l]);const{fields:d,append:m,remove:h}=Ce({control:l.control,name:"taxAdvancesAnnualIds"}),{fields:u,append:p,remove:I}=Ce({control:l.control,name:"withholdingTaxAnnualIds"}),{fields:k,append:B,remove:_}=Ce({control:l.control,name:"socialSecurityEmployerIds"}),O={withholdingTaxAnnualIds:{append:p,remove:I},taxAdvancesAnnualIds:{append:m,remove:h},socialSecurityEmployerIds:{append:B,remove:_}},V=w=>{O[w].append({year:new Date().getFullYear(),id:""})},$=(w,D)=>{O[w].remove(D)},{fields:R,append:K,remove:r}=Ce({control:l.control,name:"taxAdvancesRates"}),L=()=>{K({date:Qe(new Date,"yyyy-MM-dd"),rate:0})},U=w=>{r(w)};return e.jsxs(Q,{children:[e.jsxs(Z,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(As,{className:"h-5 w-5 text-primary"}),e.jsx(J,{children:"Admin Business Configuration"})]}),e.jsx(ee,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Le,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(x),className:"space-y-6",children:[e.jsx(se,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(Ne,{href:ye.VAT,children:"VAT"}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.WITHHOLDING_TAX,children:"Withholding Tax"}),e.jsx(j,{control:l.control,name:"withholdingTaxCompanyId",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Company Tax ID"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter company ID",...w,className:S(D)})}),e.jsx(b,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("withholdingTaxAnnualIds"),children:e.jsx(te,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:u.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`withholdingTaxAnnualIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`withholdingTaxAnnualIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("withholdingTaxAnnualIds",D),children:e.jsx(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("taxAdvancesAnnualIds"),children:e.jsx(te,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:d.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`taxAdvancesAnnualIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`taxAdvancesAnnualIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("taxAdvancesAnnualIds",D),children:e.jsx(ie,{className:"size-4"})})]},w.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Rates (%)"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:L,children:e.jsx(te,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:R.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Date",type:"date",...l.register(`taxAdvancesRates.${D}.date`)}),e.jsx(C,{placeholder:"Rate",...l.register(`taxAdvancesRates.${D}.rate`,{valueAsNumber:!0})})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>U(D),children:e.jsx(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.SOCIAL_SECURITY,children:"Social Security"}),e.jsx(j,{control:l.control,name:"socialSecurityDeductionsId",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Deductions ID"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter deductions ID",...w,className:S(D)})}),e.jsx(b,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual Employer IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("socialSecurityEmployerIds"),children:e.jsx(te,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:k.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`socialSecurityEmployerIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`socialSecurityEmployerIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("socialSecurityEmployerIds",D),children:e.jsx(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(j,{control:l.control,name:"registrationDate",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Registration Start Date"}),e.jsx(y,{children:e.jsx(C,{type:"date",...w,className:S(D)})}),e.jsx(b,{})]})})]})}),e.jsx(es,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(T,{type:"submit",disabled:i||Object.keys(l.formState.dirtyFields).length===0||!l.formState.isValid,children:[e.jsx(ls,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}const Xa=s=>{switch(s){case q.BankAccount:return e.jsx(De,{className:"h-5 w-5"});case q.CreditCard:return e.jsx(Js,{className:"h-5 w-5"});case q.CryptoWallet:return e.jsx(Sa,{className:"h-5 w-5"});case q.BankDepositAccount:return e.jsx(De,{className:"h-5 w-5"});case q.ForeignSecurities:return e.jsx(De,{className:"h-5 w-5"});default:return e.jsx(Da,{className:"h-5 w-5"})}},$s=s=>{switch(s){case q.BankAccount:return"Bank Account";case q.CreditCard:return"Credit Card";case q.CryptoWallet:return"Crypto Wallet";case q.BankDepositAccount:return"Bank Deposit Account";case q.ForeignSecurities:return"Foreign Securities";default:return"Unknown Account Type"}};function Qa({account:s,handleOpenModal:n}){return e.jsxs(Q,{children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:Xa(s.type)}),e.jsxs("div",{children:[e.jsxs(J,{className:"text-lg",children:[s.name,s.name===s.number?"":` (${s.number})`]}),e.jsxs(ee,{className:"flex items-center gap-2 mt-1",children:[e.jsx(re,{variant:"outline",children:$s(s.type)}),!s.isBusiness&&e.jsx(re,{variant:"secondary",children:"Private"})]})]})]}),e.jsx("div",{className:"flex gap-1",children:e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(s),"aria-label":`Edit account ${s.name}`,children:e.jsx(en,{className:"h-4 w-4","aria-hidden":"true"})})})]})}),e.jsxs(se,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Currencies & Tax Categories"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.currencies?.map(a=>e.jsx(pe,{to:Is.TAX_CATEGORIES,target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),children:e.jsxs(re,{variant:"secondary",className:"text-xs",children:[a.currency," → ",a.taxCategory.name]})},a.currency))})]}),s.type===q.BankAccount&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Bank Details"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Bank Number:"}),e.jsx("p",{className:"font-medium",children:s.bankNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Branch Number:"}),e.jsx("p",{className:"font-medium",children:s.branchNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Extended Bank Number:"}),e.jsx("p",{className:"font-medium",children:s.extendedBankNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"IBAN:"}),e.jsx("p",{className:"font-medium",children:s.iban})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Party Preferred Indication:"}),e.jsx("p",{className:"font-medium",children:s.partyPreferredIndication})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Party Account Involvement:"}),e.jsx("p",{className:"font-medium",children:s.partyAccountInvolvementCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Account Deal Date:"}),e.jsx("p",{className:"font-medium",children:s.accountDealDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Account Update Date:"}),e.jsx("p",{className:"font-medium",children:s.accountUpdateDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Meteg Dora Net:"}),e.jsx("p",{className:"font-medium",children:s.metegDoarNet})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Kod Harshaot Peilut:"}),e.jsx("p",{className:"font-medium",children:s.kodHarshaatPeilut})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Closing Reason Code:"}),e.jsx("p",{className:"font-medium",children:s.accountClosingReasonCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Agreement Opening Date:"}),e.jsx("p",{className:"font-medium",children:s.accountAgreementOpeningDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Branch Type Code:"}),e.jsx("p",{className:"font-medium",children:s.branchTypeCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Mymail Entitlement:"}),e.jsx("p",{className:"font-medium",children:s.mymailEntitlementSwitch})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Service Authorization:"}),e.jsx("p",{className:"font-medium",children:s.serviceAuthorizationDesc})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Product Label:"}),e.jsx("p",{className:"font-medium",children:s.productLabel})]})]})]})]})]})}const Za="createFinancialAccount",Ja=()=>{const[{fetching:s},n]=Ee(sn),a=v.useCallback(async t=>{const c=`Error creating new account "${t.input.name}"`,o=`${Za}-${t.input.name}`;X.loading("Creating account",{id:o});try{const i=await n(t);Pe(i,c,o)&&X.success("Success",{id:o,description:`Financial Account ${t.input.name} was successfully created`})}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createFinancialAccount:a}},et="updateFinancialAccount",st=()=>{const[{fetching:s},n]=Ee(nn),a=v.useCallback(async t=>{const c=`Error updating financial account ID [${t.financialAccountId}]`,o=`${et}-${t.financialAccountId}`;X.loading("Updating financial account",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateFinancialAccount");if(l)return X.success("Success",{id:o,description:"Financial account updated"}),l.updateFinancialAccount}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateFinancialAccount:a}},nt=xe({currency:Ps(Object.values(Os),"Currency is required"),taxCategory:xe({id:tn("Tax category ID is required"),name:M().min(1,"Tax category name is required")})}),G=Es(s=>{if(s===""||s===void 0||s===null)return;const n=typeof s=="string"?parseInt(s,10):s;return Number.isNaN(n)?void 0:n},as().int().optional()),at=xe({name:M().min(1,"Name is required"),number:M().min(1,"Account number is required"),isBusiness:an().default(!1).optional(),type:Ps(Object.values(q),"Account type is required"),currencies:ue(nt),bankNumber:G,branchNumber:G,iban:Es(s=>s===""?void 0:s,M().optional()),extendedBankNumber:G,partyPreferredIndication:G,partyAccountInvolvementCode:G,accountDealDate:G,accountUpdateDate:G,metegDoarNet:G,kodHarshaatPeilut:G,accountClosingReasonCode:G,accountAgreementOpeningDate:G,serviceAuthorizationDesc:M().optional(),branchTypeCode:G,mymailEntitlementSwitch:G,productLabel:M().optional()}),tt=v.forwardRef(function({ownerId:n,onDone:a},t){const[c,o]=v.useState(!1),[i,l]=v.useState(null),{createFinancialAccount:x,creating:d}=Ja(),{updateFinancialAccount:m,updating:h}=st(),u=Oe({resolver:Je(at),defaultValues:{name:"",number:"",isBusiness:!1,type:q.BankAccount,currencies:[],bankNumber:void 0,branchNumber:void 0,iban:void 0,extendedBankNumber:void 0,partyPreferredIndication:void 0,partyAccountInvolvementCode:void 0,accountDealDate:void 0,accountUpdateDate:void 0,metegDoarNet:void 0,kodHarshaatPeilut:void 0,accountClosingReasonCode:void 0,accountAgreementOpeningDate:void 0,serviceAuthorizationDesc:void 0,branchTypeCode:void 0,mymailEntitlementSwitch:void 0,productLabel:void 0},mode:"onBlur"}),{control:p,handleSubmit:I,watch:k,reset:B}=u,_=r=>{r?(l(r),B(r)):(l(null),B()),o(!0)};v.useImperativeHandle(t,()=>({open:_}));const O=Ce({control:p,name:"currencies"}),V=()=>{o(!1),l(null),B()},$=async r=>{try{const L=r.isBusiness?Ue.Business:Ue.Private,U=r.type===q.BankAccount&&r.bankNumber!==void 0&&r.branchNumber!==void 0?{bankNumber:r.bankNumber,branchNumber:r.branchNumber,...r.iban!==void 0&&{iban:r.iban},...r.extendedBankNumber!==void 0&&{extendedBankNumber:r.extendedBankNumber},...r.partyPreferredIndication!==void 0&&{partyPreferredIndication:r.partyPreferredIndication},...r.partyAccountInvolvementCode!==void 0&&{partyAccountInvolvementCode:r.partyAccountInvolvementCode},...r.accountDealDate!==void 0&&{accountDealDate:r.accountDealDate},...r.accountUpdateDate!==void 0&&{accountUpdateDate:r.accountUpdateDate},...r.metegDoarNet!==void 0&&{metegDoarNet:r.metegDoarNet},...r.kodHarshaatPeilut!==void 0&&{kodHarshaatPeilut:r.kodHarshaatPeilut},...r.accountClosingReasonCode!==void 0&&{accountClosingReasonCode:r.accountClosingReasonCode},...r.accountAgreementOpeningDate!==void 0&&{accountAgreementOpeningDate:r.accountAgreementOpeningDate},...r.serviceAuthorizationDesc!==void 0&&{serviceAuthorizationDesc:r.serviceAuthorizationDesc},...r.branchTypeCode!==void 0&&{branchTypeCode:r.branchTypeCode},...r.mymailEntitlementSwitch!==void 0&&{mymailEntitlementSwitch:r.mymailEntitlementSwitch},...r.productLabel!==void 0&&{productLabel:r.productLabel}}:void 0;i?await m({financialAccountId:i.id,fields:{name:r.name,number:r.number,type:r.type,privateOrBusiness:L,bankAccountDetails:U}}):await x({input:{name:r.name,number:r.number,ownerId:n,type:r.type,privateOrBusiness:L,bankAccountDetails:U}}),V(),a?.()}catch{}},R=()=>{O.append({currency:Os.Usd,taxCategory:{id:"",name:""}})},K=r=>{O.remove(r)};return e.jsx(Te,{open:c,onOpenChange:o,children:e.jsxs(Be,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ts,{children:[e.jsx(is,{children:i?"Edit Account":"New Account"}),e.jsx(rs,{children:i?"Update account details and settings":"Add a new financial account"})]}),e.jsx(Le,{...u,children:e.jsxs("form",{onSubmit:I($),className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(j,{control:p,name:"name",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Name *"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"number",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Number *"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"type",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Type *"}),e.jsxs(ws,{value:r.value,onValueChange:r.onChange,children:[e.jsx(Ds,{id:"type",children:e.jsx(ks,{})}),e.jsx(Ss,{children:Object.values(q).map(L=>e.jsx(Ts,{value:L,children:$s(L)},L))})]}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"isBusiness",render:({field:r})=>e.jsxs(g,{className:"flex items-center space-x-2",children:[e.jsx(y,{children:e.jsx(oe,{id:"isBusiness",checked:r.value,onCheckedChange:r.onChange})}),e.jsx(f,{children:"Business Account"})]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Currencies & Tax Categories"}),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:R,"aria-label":"Add currency row",children:[e.jsx(te,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Add Currency"]})]}),e.jsx("div",{className:"space-y-3",children:O.fields.map((r,L)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(j,{control:p,name:`currencies.${L}.currency`,render:({field:U})=>e.jsxs(g,{children:[e.jsx(y,{children:e.jsx(C,{placeholder:"Currency (e.g., ILS, USD)",...U})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:`currencies.${L}.taxCategory.id`,render:({field:U})=>e.jsxs(g,{children:[e.jsx(y,{children:e.jsx(C,{placeholder:"Tax Category ID",...U})}),e.jsx(b,{})]})})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>K(L),"aria-label":`Remove currency ${k(`currencies.${L}.currency`)||""}`,children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})})]},r.id))})]}),k("type")===q.BankAccount&&e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Bank-Specific Details"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx(j,{control:p,name:"bankNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Bank Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"branchNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Branch Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"iban",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"IBAN"}),e.jsx(y,{children:e.jsx(C,{value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"extendedBankNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Extended Bank Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"partyPreferredIndication",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Party Preferred Indication"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"partyAccountInvolvementCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Party Account Involvement Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountDealDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Deal Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountUpdateDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Update Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"metegDoarNet",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Meteg Dora Net"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"kodHarshaatPeilut",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Kod Harshaot Peilut"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountClosingReasonCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Closing Reason Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountAgreementOpeningDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Agreement Opening Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"branchTypeCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Branch Type Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"mymailEntitlementSwitch",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Mymail Entitlement Switch"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"serviceAuthorizationDesc",render:({field:r})=>e.jsxs(g,{className:"space-y-2 md:col-span-2",children:[e.jsx(f,{children:"Service Authorization Description"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"productLabel",render:({field:r})=>e.jsxs(g,{className:"space-y-2 md:col-span-2 lg:col-span-3",children:[e.jsx(f,{children:"Product Label"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})})]})]}),e.jsxs(Bs,{children:[e.jsx(T,{type:"button",variant:"outline",onClick:V,children:"Cancel"}),e.jsx(T,{type:"submit",disabled:d||h,children:i?h?"Updating…":"Update Account":d?"Creating…":"Create Account"})]})]})})]})})});function it(s){return{id:s.id,name:s.name,number:s.number,isBusiness:s.privateOrBusiness===Ue.Business,type:s.type,currencies:s.accountTaxCategories.map(n=>({currency:n.currency,taxCategory:{id:n.taxCategory.id,name:n.taxCategory.name}})),...s.__typename==="BankFinancialAccount"?{bankNumber:s.bankNumber,branchNumber:s.branchNumber,iban:s.iban??void 0,extendedBankNumber:s.extendedBankNumber??void 0,partyPreferredIndication:s.partyPreferredIndication??void 0,partyAccountInvolvementCode:s.partyAccountInvolvementCode??void 0,accountDealDate:s.accountDealDate??void 0,accountUpdateDate:s.accountUpdateDate??void 0,metegDoarNet:s.metegDoarNet??void 0,kodHarshaatPeilut:s.kodHarshaatPeilut??void 0,accountClosingReasonCode:s.accountClosingReasonCode??void 0,accountAgreementOpeningDate:s.accountAgreementOpeningDate??void 0,serviceAuthorizationDesc:s.serviceAuthorizationDesc??void 0,branchTypeCode:s.branchTypeCode??void 0,mymailEntitlementSwitch:s.mymailEntitlementSwitch??void 0,productLabel:s.productLabel??void 0}:{}}}function rt({adminId:s}){const[n,a]=v.useState([]),[{data:t,fetching:c},o]=le({query:rn,variables:{adminId:s}});v.useEffect(()=>{t?.financialAccountsByOwner&&a(t.financialAccountsByOwner?.map(it)??[])},[t]);const i=v.useRef(null),l=x=>{i.current?.open(x)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Financial Accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage bank accounts, credit cards, and crypto wallets"})]}),e.jsxs(T,{onClick:()=>l(),"aria-label":"Create new financial account",children:[e.jsx(te,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"New Account"]})]}),c?e.jsx("p",{children:"Loading..."}):e.jsxs("div",{className:"grid gap-4",children:[n.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No financial accounts added yet."}),n.map(x=>e.jsx(Qa,{account:x,handleOpenModal:l},x.id))]}),e.jsx(tt,{ownerId:s,ref:i,onDone:()=>o()})]})}function ct({businessId:s}){return e.jsxs(Q,{children:[e.jsxs(Z,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Balance"}),e.jsx(ee,{children:"Business balance overview"})]})}),e.jsx(pe,{to:Is.BUSINESSES.DETAIL_LEDGER(s),children:e.jsx(T,{variant:"outline",size:"icon",children:e.jsx(_a,{})})})]}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Kn,{businessID:s,filter:{}})})})]})}function lt({businessId:s}){const{userContext:n}=v.useContext(cs),[a,t]=v.useState(0),[{data:c,fetching:o}]=le({query:cn,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:on.Date,asc:!1},byBusinesses:[s]},page:a,limit:10}}),i=c?.allCharges?.pageInfo.totalPages??1,l=c?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(Q,{children:[e.jsxs(Z,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Charges"}),e.jsx(ee,{children:"Recurring and one-time charges for this business"})]})}),i>1&&e.jsx(ln,{className:"flex-fit w-fit mx-0",currentPageIndex:a,onChange:t,totalPages:i})]}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Qn,{data:l,isAllOpened:!1})})})]})}var ot=["type","layout","connectNulls","ref"],dt=["key"];function je(s){"@babel/helpers - typeof";return je=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},je(s)}function fs(s,n){if(s==null)return{};var a=mt(s,n),t,c;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(c=0;c<o.length;c++)t=o[c],!(n.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(s,t)&&(a[t]=s[t])}return a}function mt(s,n){if(s==null)return{};var a={};for(var t in s)if(Object.prototype.hasOwnProperty.call(s,t)){if(n.indexOf(t)>=0)continue;a[t]=s[t]}return a}function Ie(){return Ie=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(s[t]=a[t])}return s},Ie.apply(this,arguments)}function vs(s,n){var a=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(c){return Object.getOwnPropertyDescriptor(s,c).enumerable})),a.push.apply(a,t)}return a}function W(s){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?vs(Object(a),!0).forEach(function(t){ae(s,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):vs(Object(a)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(a,t))})}return s}function he(s){return pt(s)||ht(s)||xt(s)||ut()}function ut(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
1
+ import{v as ce,w as Qe,u as le,S as Ks,r as v,j as e,D as Te,x as Be,y as Ys,c as Ze,g as Ee,t as X,i as Pe,U as Xs,z as Oe,E as Je,G as fe,H as Ce,J as Q,K as Z,N as As,O as J,Q as ee,V as Le,W as se,X as de,Y as j,Z as g,_ as f,$ as y,I as C,a0 as S,a1 as b,a2 as Ae,B as T,a3 as te,a4 as ie,a5 as es,a6 as Qs,a7 as xe,a8 as ss,a9 as ns,aa as ue,ab as M,ac as as,ad as Zs,ae as q,af as Js,ag as re,ah as en,ai as pe,R as Is,aj as sn,ak as nn,al as ts,am as is,an as rs,ao as ws,ap as Ds,aq as ks,ar as Ss,as as Ts,at as oe,au as Bs,av as Es,aw as Ps,ax as an,ay as Os,az as Ue,aA as tn,aB as rn,aC as cs,aD as cn,P as ln,aE as on,aF as H,aG as os,aH as Me,aI as dn,aJ as mn,aK as un,aL as Ls,aM as xn,aN as hn,aO as pn,aP as jn,aQ as gn,aR as Fs,aS as fn,aT as P,aU as qe,aV as Ms,aW as He,aX as ds,aY as vn,aZ as _s,a_ as yn,a$ as Nn,b0 as bn,b1 as me,b2 as Cn,b3 as An,b4 as In,b5 as Ge,b6 as wn,b7 as Dn,b8 as kn,b9 as Sn,ba as Tn,bb as ms,bc as Bn,bd as En,be as Pn,bf as On,bg as us,bh as Ln,bi as Fn,bj as Mn,bk as _n,F as Rn,bl as zn,bm as Vn,bn as ne,bo as $n,bp as Un,bq as Y,br as qn,a as Hn,b as Gn,bs as Wn}from"./index-DEV5LiNl.js";import{S as ls}from"./save-BVkPTt8i.js";import{B as De}from"./building-2-Br1I1DXZ.js";import{B as Kn}from"./business-extended-info-DNF3mKMK.js";import{B as Yn}from"./business-header-dEe-9q-5.js";import{S as Xn,C as Qn,L as Zn,W as Jn}from"./charges-table-Ca8NLtQw.js";import{i as ea,D as sa,f as na,E as aa,L as _e,a as we,C as ta,A as ia,b as ve,c as ra,d as We,h as ca,e as la,g as Rs,u as oa,G as da,j as xs,k as ma,X as zs,Y as Vs,l as ua,m as xa,R as ha,n as pa,o as ja,p as ga}from"./chart-DOzAbHsx.js";import{M as Ke,s as fa,a as va}from"./modify-contract-dialog-Bp9pVouf.js";import{u as ya,E as Na}from"./use-issue-monthly-documents-C9q3hH_f.js";import{s as ba}from"./subMonths-B0TEAjr8.js";import{E as Ca,T as Aa}from"./index-SSi9xYyM.js";import{A as Ia,a as Re,b as hs,c as ps}from"./accordion-ByPdqgz2.js";import"./data-table-column-header-BvxwVRjw.js";import"./eye-off--kONYNyo.js";import"./download-csv-button-BeYQaUZA.js";import"./toggle-expansion-button-D8u5XCV3.js";import"./panel-top-open-BVYyrhXF.js";import"./Table-BKmRkEex.js";import"./summary-B3q161uS.js";import"./list-plus-uhcKtu05.js";import"./deposits-transactions-table-Bv0SsZOc.js";import"./Checkbox-DB0ksED6.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-BJxT9GAZ.js";import"./addDays-CqDW575k.js";const wa=[["path",{d:"M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z",key:"3c2336"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["line",{x1:"12",x2:"12.01",y1:"17",y2:"17",key:"io3f8k"}]],Da=ce("badge-question-mark",wa);const ka=[["path",{d:"M11.767 19.089c4.924.868 6.14-6.025 1.216-6.894m-1.216 6.894L5.86 18.047m5.908 1.042-.347 1.97m1.563-8.864c4.924.869 6.14-6.025 1.215-6.893m-1.215 6.893-3.94-.694m5.155-6.2L8.29 4.26m5.908 1.042.348-1.97M7.48 20.364l3.126-17.727",key:"yr8idg"}]],Sa=ce("bitcoin",ka);const Ta=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Ba=ce("chart-line",Ta);const Ea=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ze=ce("circle-check",Ea);const Pa=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],js=ce("circle-slash",Pa);const Oa=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ke=ce("dollar-sign",Oa);const La=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],Fa=ce("file-check",La);const Ma=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["rect",{width:"10",height:"8",x:"7",y:"8",rx:"1",key:"vys8me"}]],_a=ce("fullscreen",Ma);const Ra=[["path",{d:"M2 6h4",key:"aawbzj"}],["path",{d:"M2 10h4",key:"l0bgd4"}],["path",{d:"M2 14h4",key:"1gsvsf"}],["path",{d:"M2 18h4",key:"1bu2t1"}],["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",key:"1nb95v"}],["path",{d:"M16 2v20",key:"rotuqe"}]],za=ce("notebook",Ra);const Va=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]],$a=ce("plug",Va);function Ua(s){return Qe(s,"yyyy-MM-dd")}function qa({businessId:s,tagIds:n,description:a,open:t,onOpenChange:c,onClose:o}){const[{data:i,fetching:l},x]=le({pause:!0,query:Ks,variables:{businessId:s,tagsDifferentThan:n?n.map(h=>h.id):void 0,descriptionDifferentThan:a}});v.useEffect(()=>{t&&(n||a)&&!i&&x()},[t,n,a,x,i]);const d=v.useCallback(h=>{c(h),t&&!h&&o?.()},[c,o,t]),m=v.useMemo(()=>t&&(!!n||!!a)&&i&&i?.similarChargesByBusiness.length>0,[t,n,a,i]);return e.jsx(Te,{open:m,onOpenChange:d,children:e.jsx(Be,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:h=>h.stopPropagation(),children:e.jsx(Ys,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:l?e.jsx(Ze,{}):n||a?e.jsx(Xn,{data:i?.similarChargesByBusiness??[],tagIds:n,description:a,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const Ha="updateAdminBusiness",Ga=()=>{const[{fetching:s},n]=Ee(Xs),a=v.useCallback(async t=>{const c=`Error updating admin business ID [${t.adminBusinessId}]`,o=`${Ha}-${t.adminBusinessId}`;X.loading("Updating admin business",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateAdminBusiness");if(l)return X.success("Success",{id:o,description:"Admin Business Updated"}),l.updateAdminBusiness}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateAdminBusiness:a}},Ve=xe({year:as().min(2e3).max(2100),id:M().min(1,{message:"ID is required"})}),Wa=xe({registrationDate:M().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:ue(Ve),withholdingTaxCompanyId:M().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:ue(Ve),socialSecurityDeductionsId:M().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:ue(Ve),taxAdvancesRates:ue(xe({date:Zs(),rate:as().min(0,{message:"Rate must be at least 0"}).max(100,{message:"Rate must be at most 100"})}))}),ye={WITHHOLDING_TAX:"https://secapp.taxes.gov.il/NikPay/StartPage.aspx#/Home",TAX_ADVANCES:"https://secapp.taxes.gov.il/gmftashmh/main/entrance",SOCIAL_SECURITY:"https://b2b.btl.gov.il/BTL.ILG.Payments/ChovDochMaasikInfo.aspx",VAT:"https://secapp.taxes.gov.il/emdvhmfrt/wLogOnMenu.aspx"},Ne=({href:s,children:n})=>e.jsxs("h3",{className:"flex flex-row gap-2 text-sm font-semibold text-foreground md:col-span-2",children:[e.jsx("a",{href:s,target:"_blank",rel:"noreferrer",onClick:a=>a.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.jsx(ss,{size:12})}),e.jsx("span",{children:n})]});function gs(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{registrationDate:s.adminInfo.registrationDate,withholdingTaxAnnualIds:s.adminInfo.withholdingTaxAnnualIds.sort((n,a)=>a.year-n.year),withholdingTaxCompanyId:s.adminInfo.withholdingTaxCompanyId??void 0,socialSecurityEmployerIds:s.adminInfo.socialSecurityEmployerIds.sort((n,a)=>a.year-n.year),socialSecurityDeductionsId:s.adminInfo.socialSecurityDeductionsId??void 0,taxAdvancesAnnualIds:s.adminInfo.taxAdvancesAnnualIds.sort((n,a)=>a.year-n.year),taxAdvancesRates:s.adminInfo.taxAdvancesRates?.map(n=>({date:n.date,rate:n.rate*100}))}}function Ka(s){return{registrationDate:s.registrationDate?Ua(new Date(s.registrationDate)):void 0,withholdingTaxAnnualIds:s.withholdingTaxAnnualIds,withholdingTaxCompanyId:s.withholdingTaxCompanyId,socialSecurityEmployerIds:s.socialSecurityEmployerIds,taxAdvancesRates:s.taxAdvancesRates?.map(n=>({date:n.date,rate:n.rate/100})),taxAdvancesAnnualIds:s.taxAdvancesAnnualIds}}function Ya({data:s,refetchBusiness:n}){const a=fe(Qs,s),[t,c]=v.useState(gs(a)),{updateAdminBusiness:o,fetching:i}=Ga(),l=Oe({resolver:Je(Wa),defaultValues:t}),x=async w=>{if(!a)return;const D=ns(w,l.formState.dirtyFields);if(!D)return;const z=Ka(D);await o({adminBusinessId:a.id,fields:z}),n?.()};v.useEffect(()=>{if(a){const w=gs(a);c(w),l.reset(w)}},[a,l]);const{fields:d,append:m,remove:h}=Ce({control:l.control,name:"taxAdvancesAnnualIds"}),{fields:u,append:p,remove:I}=Ce({control:l.control,name:"withholdingTaxAnnualIds"}),{fields:k,append:B,remove:_}=Ce({control:l.control,name:"socialSecurityEmployerIds"}),O={withholdingTaxAnnualIds:{append:p,remove:I},taxAdvancesAnnualIds:{append:m,remove:h},socialSecurityEmployerIds:{append:B,remove:_}},V=w=>{O[w].append({year:new Date().getFullYear(),id:""})},$=(w,D)=>{O[w].remove(D)},{fields:R,append:K,remove:r}=Ce({control:l.control,name:"taxAdvancesRates"}),L=()=>{K({date:Qe(new Date,"yyyy-MM-dd"),rate:0})},U=w=>{r(w)};return e.jsxs(Q,{children:[e.jsxs(Z,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(As,{className:"h-5 w-5 text-primary"}),e.jsx(J,{children:"Admin Business Configuration"})]}),e.jsx(ee,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Le,{...l,children:e.jsxs("form",{onSubmit:l.handleSubmit(x),className:"space-y-6",children:[e.jsx(se,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(Ne,{href:ye.VAT,children:"VAT"}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.WITHHOLDING_TAX,children:"Withholding Tax"}),e.jsx(j,{control:l.control,name:"withholdingTaxCompanyId",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Company Tax ID"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter company ID",...w,className:S(D)})}),e.jsx(b,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("withholdingTaxAnnualIds"),children:e.jsx(te,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:u.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`withholdingTaxAnnualIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`withholdingTaxAnnualIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("withholdingTaxAnnualIds",D),children:e.jsx(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.TAX_ADVANCES,children:"Tax Advances"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("taxAdvancesAnnualIds"),children:e.jsx(te,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:d.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`taxAdvancesAnnualIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`taxAdvancesAnnualIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("taxAdvancesAnnualIds",D),children:e.jsx(ie,{className:"size-4"})})]},w.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Rates (%)"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:L,children:e.jsx(te,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:R.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Date",type:"date",...l.register(`taxAdvancesRates.${D}.date`)}),e.jsx(C,{placeholder:"Rate",...l.register(`taxAdvancesRates.${D}.rate`,{valueAsNumber:!0})})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>U(D),children:e.jsx(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(Ne,{href:ye.SOCIAL_SECURITY,children:"Social Security"}),e.jsx(j,{control:l.control,name:"socialSecurityDeductionsId",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Deductions ID"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter deductions ID",...w,className:S(D)})}),e.jsx(b,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(Ae,{children:"Annual Employer IDs"}),e.jsx(T,{type:"button",variant:"outline",size:"sm",onClick:()=>V("socialSecurityEmployerIds"),children:e.jsx(te,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:k.map((w,D)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(C,{placeholder:"Year",type:"number",...l.register(`socialSecurityEmployerIds.${D}.year`,{valueAsNumber:!0})}),e.jsx(C,{placeholder:"ID",...l.register(`socialSecurityEmployerIds.${D}.id`)})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>$("socialSecurityEmployerIds",D),children:e.jsx(ie,{className:"size-4"})})]},w.id))})]}),e.jsx(de,{className:"md:col-span-2"}),e.jsx(j,{control:l.control,name:"registrationDate",render:({field:w,fieldState:D})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Registration Start Date"}),e.jsx(y,{children:e.jsx(C,{type:"date",...w,className:S(D)})}),e.jsx(b,{})]})})]})}),e.jsx(es,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(T,{type:"submit",disabled:i||Object.keys(l.formState.dirtyFields).length===0||!l.formState.isValid,children:[e.jsx(ls,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}const Xa=s=>{switch(s){case q.BankAccount:return e.jsx(De,{className:"h-5 w-5"});case q.CreditCard:return e.jsx(Js,{className:"h-5 w-5"});case q.CryptoWallet:return e.jsx(Sa,{className:"h-5 w-5"});case q.BankDepositAccount:return e.jsx(De,{className:"h-5 w-5"});case q.ForeignSecurities:return e.jsx(De,{className:"h-5 w-5"});default:return e.jsx(Da,{className:"h-5 w-5"})}},$s=s=>{switch(s){case q.BankAccount:return"Bank Account";case q.CreditCard:return"Credit Card";case q.CryptoWallet:return"Crypto Wallet";case q.BankDepositAccount:return"Bank Deposit Account";case q.ForeignSecurities:return"Foreign Securities";default:return"Unknown Account Type"}};function Qa({account:s,handleOpenModal:n}){return e.jsxs(Q,{children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10 text-primary",children:Xa(s.type)}),e.jsxs("div",{children:[e.jsxs(J,{className:"text-lg",children:[s.name,s.name===s.number?"":` (${s.number})`]}),e.jsxs(ee,{className:"flex items-center gap-2 mt-1",children:[e.jsx(re,{variant:"outline",children:$s(s.type)}),!s.isBusiness&&e.jsx(re,{variant:"secondary",children:"Private"})]})]})]}),e.jsx("div",{className:"flex gap-1",children:e.jsx(T,{variant:"ghost",size:"sm",onClick:()=>n(s),"aria-label":`Edit account ${s.name}`,children:e.jsx(en,{className:"h-4 w-4","aria-hidden":"true"})})})]})}),e.jsxs(se,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium mb-2",children:"Currencies & Tax Categories"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:s.currencies?.map(a=>e.jsx(pe,{to:Is.TAX_CATEGORIES,target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),children:e.jsxs(re,{variant:"secondary",className:"text-xs",children:[a.currency," → ",a.taxCategory.name]})},a.currency))})]}),s.type===q.BankAccount&&e.jsxs("div",{className:"border-t pt-4",children:[e.jsx("h4",{className:"text-sm font-medium mb-3",children:"Bank Details"}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Bank Number:"}),e.jsx("p",{className:"font-medium",children:s.bankNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Branch Number:"}),e.jsx("p",{className:"font-medium",children:s.branchNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Extended Bank Number:"}),e.jsx("p",{className:"font-medium",children:s.extendedBankNumber})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"IBAN:"}),e.jsx("p",{className:"font-medium",children:s.iban})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Party Preferred Indication:"}),e.jsx("p",{className:"font-medium",children:s.partyPreferredIndication})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Party Account Involvement:"}),e.jsx("p",{className:"font-medium",children:s.partyAccountInvolvementCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Account Deal Date:"}),e.jsx("p",{className:"font-medium",children:s.accountDealDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Account Update Date:"}),e.jsx("p",{className:"font-medium",children:s.accountUpdateDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Meteg Dora Net:"}),e.jsx("p",{className:"font-medium",children:s.metegDoarNet})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Kod Harshaot Peilut:"}),e.jsx("p",{className:"font-medium",children:s.kodHarshaatPeilut})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Closing Reason Code:"}),e.jsx("p",{className:"font-medium",children:s.accountClosingReasonCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Agreement Opening Date:"}),e.jsx("p",{className:"font-medium",children:s.accountAgreementOpeningDate})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Branch Type Code:"}),e.jsx("p",{className:"font-medium",children:s.branchTypeCode})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Mymail Entitlement:"}),e.jsx("p",{className:"font-medium",children:s.mymailEntitlementSwitch})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Service Authorization:"}),e.jsx("p",{className:"font-medium",children:s.serviceAuthorizationDesc})]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-muted-foreground text-xs",children:"Product Label:"}),e.jsx("p",{className:"font-medium",children:s.productLabel})]})]})]})]})]})}const Za="createFinancialAccount",Ja=()=>{const[{fetching:s},n]=Ee(sn),a=v.useCallback(async t=>{const c=`Error creating new account "${t.input.name}"`,o=`${Za}-${t.input.name}`;X.loading("Creating account",{id:o});try{const i=await n(t);Pe(i,c,o)&&X.success("Success",{id:o,description:`Financial Account ${t.input.name} was successfully created`})}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{creating:s,createFinancialAccount:a}},et="updateFinancialAccount",st=()=>{const[{fetching:s},n]=Ee(nn),a=v.useCallback(async t=>{const c=`Error updating financial account ID [${t.financialAccountId}]`,o=`${et}-${t.financialAccountId}`;X.loading("Updating financial account",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateFinancialAccount");if(l)return X.success("Success",{id:o,description:"Financial account updated"}),l.updateFinancialAccount}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{updating:s,updateFinancialAccount:a}},nt=xe({currency:Ps(Object.values(Os),"Currency is required"),taxCategory:xe({id:tn("Tax category ID is required"),name:M().min(1,"Tax category name is required")})}),G=Es(s=>{if(s===""||s===void 0||s===null)return;const n=typeof s=="string"?parseInt(s,10):s;return Number.isNaN(n)?void 0:n},as().int().optional()),at=xe({name:M().min(1,"Name is required"),number:M().min(1,"Account number is required"),isBusiness:an().default(!1).optional(),type:Ps(Object.values(q),"Account type is required"),currencies:ue(nt),bankNumber:G,branchNumber:G,iban:Es(s=>s===""?void 0:s,M().optional()),extendedBankNumber:G,partyPreferredIndication:G,partyAccountInvolvementCode:G,accountDealDate:G,accountUpdateDate:G,metegDoarNet:G,kodHarshaatPeilut:G,accountClosingReasonCode:G,accountAgreementOpeningDate:G,serviceAuthorizationDesc:M().optional(),branchTypeCode:G,mymailEntitlementSwitch:G,productLabel:M().optional()}),tt=v.forwardRef(function({ownerId:n,onDone:a},t){const[c,o]=v.useState(!1),[i,l]=v.useState(null),{createFinancialAccount:x,creating:d}=Ja(),{updateFinancialAccount:m,updating:h}=st(),u=Oe({resolver:Je(at),defaultValues:{name:"",number:"",isBusiness:!1,type:q.BankAccount,currencies:[],bankNumber:void 0,branchNumber:void 0,iban:void 0,extendedBankNumber:void 0,partyPreferredIndication:void 0,partyAccountInvolvementCode:void 0,accountDealDate:void 0,accountUpdateDate:void 0,metegDoarNet:void 0,kodHarshaatPeilut:void 0,accountClosingReasonCode:void 0,accountAgreementOpeningDate:void 0,serviceAuthorizationDesc:void 0,branchTypeCode:void 0,mymailEntitlementSwitch:void 0,productLabel:void 0},mode:"onBlur"}),{control:p,handleSubmit:I,watch:k,reset:B}=u,_=r=>{r?(l(r),B(r)):(l(null),B()),o(!0)};v.useImperativeHandle(t,()=>({open:_}));const O=Ce({control:p,name:"currencies"}),V=()=>{o(!1),l(null),B()},$=async r=>{try{const L=r.isBusiness?Ue.Business:Ue.Private,U=r.type===q.BankAccount&&r.bankNumber!==void 0&&r.branchNumber!==void 0?{bankNumber:r.bankNumber,branchNumber:r.branchNumber,...r.iban!==void 0&&{iban:r.iban},...r.extendedBankNumber!==void 0&&{extendedBankNumber:r.extendedBankNumber},...r.partyPreferredIndication!==void 0&&{partyPreferredIndication:r.partyPreferredIndication},...r.partyAccountInvolvementCode!==void 0&&{partyAccountInvolvementCode:r.partyAccountInvolvementCode},...r.accountDealDate!==void 0&&{accountDealDate:r.accountDealDate},...r.accountUpdateDate!==void 0&&{accountUpdateDate:r.accountUpdateDate},...r.metegDoarNet!==void 0&&{metegDoarNet:r.metegDoarNet},...r.kodHarshaatPeilut!==void 0&&{kodHarshaatPeilut:r.kodHarshaatPeilut},...r.accountClosingReasonCode!==void 0&&{accountClosingReasonCode:r.accountClosingReasonCode},...r.accountAgreementOpeningDate!==void 0&&{accountAgreementOpeningDate:r.accountAgreementOpeningDate},...r.serviceAuthorizationDesc!==void 0&&{serviceAuthorizationDesc:r.serviceAuthorizationDesc},...r.branchTypeCode!==void 0&&{branchTypeCode:r.branchTypeCode},...r.mymailEntitlementSwitch!==void 0&&{mymailEntitlementSwitch:r.mymailEntitlementSwitch},...r.productLabel!==void 0&&{productLabel:r.productLabel}}:void 0;i?await m({financialAccountId:i.id,fields:{name:r.name,number:r.number,type:r.type,privateOrBusiness:L,bankAccountDetails:U}}):await x({input:{name:r.name,number:r.number,ownerId:n,type:r.type,privateOrBusiness:L,bankAccountDetails:U}}),V(),a?.()}catch{}},R=()=>{O.append({currency:Os.Usd,taxCategory:{id:"",name:""}})},K=r=>{O.remove(r)};return e.jsx(Te,{open:c,onOpenChange:o,children:e.jsxs(Be,{className:"max-w-4xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(ts,{children:[e.jsx(is,{children:i?"Edit Account":"New Account"}),e.jsx(rs,{children:i?"Update account details and settings":"Add a new financial account"})]}),e.jsx(Le,{...u,children:e.jsxs("form",{onSubmit:I($),className:"space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Basic Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(j,{control:p,name:"name",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Name *"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"number",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Number *"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"type",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Type *"}),e.jsxs(ws,{value:r.value,onValueChange:r.onChange,children:[e.jsx(Ds,{id:"type",children:e.jsx(ks,{})}),e.jsx(Ss,{children:Object.values(q).map(L=>e.jsx(Ts,{value:L,children:$s(L)},L))})]}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"isBusiness",render:({field:r})=>e.jsxs(g,{className:"flex items-center space-x-2",children:[e.jsx(y,{children:e.jsx(oe,{id:"isBusiness",checked:r.value,onCheckedChange:r.onChange})}),e.jsx(f,{children:"Business Account"})]})})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Currencies & Tax Categories"}),e.jsxs(T,{type:"button",variant:"outline",size:"sm",onClick:R,"aria-label":"Add currency row",children:[e.jsx(te,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"Add Currency"]})]}),e.jsx("div",{className:"space-y-3",children:O.fields.map((r,L)=>e.jsxs("div",{className:"flex gap-2 items-start",children:[e.jsxs("div",{className:"flex-1 grid grid-cols-2 gap-2",children:[e.jsx(j,{control:p,name:`currencies.${L}.currency`,render:({field:U})=>e.jsxs(g,{children:[e.jsx(y,{children:e.jsx(C,{placeholder:"Currency (e.g., ILS, USD)",...U})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:`currencies.${L}.taxCategory.id`,render:({field:U})=>e.jsxs(g,{children:[e.jsx(y,{children:e.jsx(C,{placeholder:"Tax Category ID",...U})}),e.jsx(b,{})]})})]}),e.jsx(T,{type:"button",variant:"ghost",size:"icon",onClick:()=>K(L),"aria-label":`Remove currency ${k(`currencies.${L}.currency`)||""}`,children:e.jsx(ie,{className:"h-4 w-4","aria-hidden":"true"})})]},r.id))})]}),k("type")===q.BankAccount&&e.jsxs("div",{className:"space-y-4 border-t pt-4",children:[e.jsx("h3",{className:"text-sm font-semibold",children:"Bank-Specific Details"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsx(j,{control:p,name:"bankNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Bank Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"branchNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Branch Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"iban",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"IBAN"}),e.jsx(y,{children:e.jsx(C,{value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"extendedBankNumber",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Extended Bank Number"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"partyPreferredIndication",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Party Preferred Indication"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"partyAccountInvolvementCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Party Account Involvement Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountDealDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Deal Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountUpdateDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Update Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"metegDoarNet",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Meteg Dora Net"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"kodHarshaatPeilut",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Kod Harshaot Peilut"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountClosingReasonCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Closing Reason Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"accountAgreementOpeningDate",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Account Agreement Opening Date"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",placeholder:"YYYYMMDD",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"branchTypeCode",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Branch Type Code"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"mymailEntitlementSwitch",render:({field:r})=>e.jsxs(g,{className:"space-y-2",children:[e.jsx(f,{children:"Mymail Entitlement Switch"}),e.jsx(y,{children:e.jsx(C,{inputMode:"numeric",value:r.value??"",onChange:r.onChange})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"serviceAuthorizationDesc",render:({field:r})=>e.jsxs(g,{className:"space-y-2 md:col-span-2",children:[e.jsx(f,{children:"Service Authorization Description"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})}),e.jsx(j,{control:p,name:"productLabel",render:({field:r})=>e.jsxs(g,{className:"space-y-2 md:col-span-2 lg:col-span-3",children:[e.jsx(f,{children:"Product Label"}),e.jsx(y,{children:e.jsx(C,{...r})}),e.jsx(b,{})]})})]})]}),e.jsxs(Bs,{children:[e.jsx(T,{type:"button",variant:"outline",onClick:V,children:"Cancel"}),e.jsx(T,{type:"submit",disabled:d||h,children:i?h?"Updating…":"Update Account":d?"Creating…":"Create Account"})]})]})})]})})});function it(s){return{id:s.id,name:s.name,number:s.number,isBusiness:s.privateOrBusiness===Ue.Business,type:s.type,currencies:s.accountTaxCategories.map(n=>({currency:n.currency,taxCategory:{id:n.taxCategory.id,name:n.taxCategory.name}})),...s.__typename==="BankFinancialAccount"?{bankNumber:s.bankNumber,branchNumber:s.branchNumber,iban:s.iban??void 0,extendedBankNumber:s.extendedBankNumber??void 0,partyPreferredIndication:s.partyPreferredIndication??void 0,partyAccountInvolvementCode:s.partyAccountInvolvementCode??void 0,accountDealDate:s.accountDealDate??void 0,accountUpdateDate:s.accountUpdateDate??void 0,metegDoarNet:s.metegDoarNet??void 0,kodHarshaatPeilut:s.kodHarshaatPeilut??void 0,accountClosingReasonCode:s.accountClosingReasonCode??void 0,accountAgreementOpeningDate:s.accountAgreementOpeningDate??void 0,serviceAuthorizationDesc:s.serviceAuthorizationDesc??void 0,branchTypeCode:s.branchTypeCode??void 0,mymailEntitlementSwitch:s.mymailEntitlementSwitch??void 0,productLabel:s.productLabel??void 0}:{}}}function rt({adminId:s}){const[n,a]=v.useState([]),[{data:t,fetching:c},o]=le({query:rn,variables:{adminId:s}});v.useEffect(()=>{t?.financialAccountsByOwner&&a(t.financialAccountsByOwner?.map(it)??[])},[t]);const i=v.useRef(null),l=x=>{i.current?.open(x)};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Financial Accounts"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Manage bank accounts, credit cards, and crypto wallets"})]}),e.jsxs(T,{onClick:()=>l(),"aria-label":"Create new financial account",children:[e.jsx(te,{className:"h-4 w-4 mr-2","aria-hidden":"true"}),"New Account"]})]}),c?e.jsx("p",{children:"Loading..."}):e.jsxs("div",{className:"grid gap-4",children:[n.length===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:"No financial accounts added yet."}),n.map(x=>e.jsx(Qa,{account:x,handleOpenModal:l},x.id))]}),e.jsx(tt,{ownerId:s,ref:i,onDone:()=>o()})]})}function ct({businessId:s}){return e.jsxs(Q,{children:[e.jsxs(Z,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Balance"}),e.jsx(ee,{children:"Business balance overview"})]})}),e.jsx(pe,{to:Is.BUSINESSES.DETAIL_LEDGER(s),children:e.jsx(T,{variant:"outline",size:"icon",children:e.jsx(_a,{})})})]}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Kn,{businessID:s,filter:{}})})})]})}function lt({businessId:s}){const{userContext:n}=v.useContext(cs),[a,t]=v.useState(0),[{data:c,fetching:o}]=le({query:cn,variables:{filters:{byOwners:n?.context.adminBusinessId?[n.context.adminBusinessId]:void 0,sortBy:{field:on.Date,asc:!1},byBusinesses:[s]},page:a,limit:10}}),i=c?.allCharges?.pageInfo.totalPages??1,l=c?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(Q,{children:[e.jsxs(Z,{className:"flex w-full justify-between items-center",children:[e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Charges"}),e.jsx(ee,{children:"Recurring and one-time charges for this business"})]})}),i>1&&e.jsx(ln,{className:"flex-fit w-fit mx-0",currentPageIndex:a,onChange:t,totalPages:i})]}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Qn,{data:l,isAllOpened:!1})})})]})}var ot=["type","layout","connectNulls","ref"],dt=["key"];function je(s){"@babel/helpers - typeof";return je=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(n){return typeof n}:function(n){return n&&typeof Symbol=="function"&&n.constructor===Symbol&&n!==Symbol.prototype?"symbol":typeof n},je(s)}function fs(s,n){if(s==null)return{};var a=mt(s,n),t,c;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(c=0;c<o.length;c++)t=o[c],!(n.indexOf(t)>=0)&&Object.prototype.propertyIsEnumerable.call(s,t)&&(a[t]=s[t])}return a}function mt(s,n){if(s==null)return{};var a={};for(var t in s)if(Object.prototype.hasOwnProperty.call(s,t)){if(n.indexOf(t)>=0)continue;a[t]=s[t]}return a}function Ie(){return Ie=Object.assign?Object.assign.bind():function(s){for(var n=1;n<arguments.length;n++){var a=arguments[n];for(var t in a)Object.prototype.hasOwnProperty.call(a,t)&&(s[t]=a[t])}return s},Ie.apply(this,arguments)}function vs(s,n){var a=Object.keys(s);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(s);n&&(t=t.filter(function(c){return Object.getOwnPropertyDescriptor(s,c).enumerable})),a.push.apply(a,t)}return a}function W(s){for(var n=1;n<arguments.length;n++){var a=arguments[n]!=null?arguments[n]:{};n%2?vs(Object(a),!0).forEach(function(t){ae(s,t,a[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(a)):vs(Object(a)).forEach(function(t){Object.defineProperty(s,t,Object.getOwnPropertyDescriptor(a,t))})}return s}function he(s){return pt(s)||ht(s)||xt(s)||ut()}function ut(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function xt(s,n){if(s){if(typeof s=="string")return Ye(s,n);var a=Object.prototype.toString.call(s).slice(8,-1);if(a==="Object"&&s.constructor&&(a=s.constructor.name),a==="Map"||a==="Set")return Array.from(s);if(a==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a))return Ye(s,n)}}function ht(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function pt(s){if(Array.isArray(s))return Ye(s)}function Ye(s,n){(n==null||n>s.length)&&(n=s.length);for(var a=0,t=new Array(n);a<n;a++)t[a]=s[a];return t}function jt(s,n){if(!(s instanceof n))throw new TypeError("Cannot call a class as a function")}function ys(s,n){for(var a=0;a<n.length;a++){var t=n[a];t.enumerable=t.enumerable||!1,t.configurable=!0,"value"in t&&(t.writable=!0),Object.defineProperty(s,qs(t.key),t)}}function gt(s,n,a){return n&&ys(s.prototype,n),a&&ys(s,a),Object.defineProperty(s,"prototype",{writable:!1}),s}function ft(s,n,a){return n=Se(n),vt(s,Us()?Reflect.construct(n,a||[],Se(s).constructor):n.apply(s,a))}function vt(s,n){if(n&&(je(n)==="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return yt(s)}function yt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Us(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Us=function(){return!!s})()}function Se(s){return Se=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},Se(s)}function Nt(s,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(n&&n.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),n&&Xe(s,n)}function Xe(s,n){return Xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,c){return t.__proto__=c,t},Xe(s,n)}function ae(s,n,a){return n=qs(n),n in s?Object.defineProperty(s,n,{value:a,enumerable:!0,configurable:!0,writable:!0}):s[n]=a,s}function qs(s){var n=bt(s,"string");return je(n)=="symbol"?n:n+""}function bt(s,n){if(je(s)!="object"||!s)return s;var a=s[Symbol.toPrimitive];if(a!==void 0){var t=a.call(s,n);if(je(t)!="object")return t;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var ge=(function(s){function n(){var a;jt(this,n);for(var t=arguments.length,c=new Array(t),o=0;o<t;o++)c[o]=arguments[o];return a=ft(this,n,[].concat(c)),ae(a,"state",{isAnimationFinished:!0,totalLength:0}),ae(a,"generateSimpleStrokeDasharray",function(i,l){return"".concat(l,"px ").concat(i-l,"px")}),ae(a,"getStrokeDasharray",function(i,l,x){var d=x.reduce(function(_,O){return _+O});if(!d)return a.generateSimpleStrokeDasharray(l,i);for(var m=Math.floor(i/d),h=i%d,u=l-i,p=[],I=0,k=0;I<x.length;k+=x[I],++I)if(k+x[I]>h){p=[].concat(he(x.slice(0,I)),[h-k]);break}var B=p.length%2===0?[0,u]:[u];return[].concat(he(n.repeat(x,m)),he(p),B).map(function(_){return"".concat(_,"px")}).join(", ")}),ae(a,"id",oa("recharts-line-")),ae(a,"pathRef",function(i){a.mainCurve=i}),ae(a,"handleAnimationEnd",function(){a.setState({isAnimationFinished:!0}),a.props.onAnimationEnd&&a.props.onAnimationEnd()}),ae(a,"handleAnimationStart",function(){a.setState({isAnimationFinished:!1}),a.props.onAnimationStart&&a.props.onAnimationStart()}),a}return Nt(n,s),gt(n,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var t=this.getTotalLength();this.setState({totalLength:t})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var t=this.getTotalLength();t!==this.state.totalLength&&this.setState({totalLength:t})}}},{key:"getTotalLength",value:function(){var t=this.mainCurve;try{return t&&t.getTotalLength&&t.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(t,c){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,i=o.points,l=o.xAxis,x=o.yAxis,d=o.layout,m=o.children,h=na(m,aa);if(!h)return null;var u=function(k,B){return{x:k.x,y:k.y,value:k.value,errorVal:Rs(k.payload,B)}},p={clipPath:t?"url(#clipPath-".concat(c,")"):null};return H.createElement(_e,p,h.map(function(I){return H.cloneElement(I,{key:"bar-".concat(I.props.dataKey),data:i,xAxis:l,yAxis:x,layout:d,dataPointFormatter:u})}))}},{key:"renderDots",value:function(t,c,o){var i=this.props.isAnimationActive;if(i&&!this.state.isAnimationFinished)return null;var l=this.props,x=l.dot,d=l.points,m=l.dataKey,h=we(this.props,!1),u=we(x,!0),p=d.map(function(k,B){var _=W(W(W({key:"dot-".concat(B),r:3},h),u),{},{index:B,cx:k.x,cy:k.y,value:k.value,dataKey:m,payload:k.payload,points:d});return n.renderDotItem(x,_)}),I={clipPath:t?"url(#clipPath-".concat(c?"":"dots-").concat(o,")"):null};return H.createElement(_e,Ie({className:"recharts-line-dots",key:"dots"},I),p)}},{key:"renderCurveStatically",value:function(t,c,o,i){var l=this.props,x=l.type,d=l.layout,m=l.connectNulls;l.ref;var h=fs(l,ot),u=W(W(W({},we(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(o,")"):null,points:t},i),{},{type:x,layout:d,connectNulls:m});return H.createElement(ta,Ie({},u,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(t,c){var o=this,i=this.props,l=i.points,x=i.strokeDasharray,d=i.isAnimationActive,m=i.animationBegin,h=i.animationDuration,u=i.animationEasing,p=i.animationId,I=i.animateNewValues,k=i.width,B=i.height,_=this.state,O=_.prevPoints,V=_.totalLength;return H.createElement(ia,{begin:m,duration:h,isActive:d,easing:u,from:{t:0},to:{t:1},key:"line-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function($){var R=$.t;if(O){var K=O.length/l.length,r=l.map(function(z,N){var A=Math.floor(N*K);if(O[A]){var E=O[A],F=ve(E.x,z.x),Fe=ve(E.y,z.y);return W(W({},z),{},{x:F(R),y:Fe(R)})}if(I){var Gs=ve(k*2,z.x),Ws=ve(B/2,z.y);return W(W({},z),{},{x:Gs(R),y:Ws(R)})}return W(W({},z),{},{x:z.x,y:z.y})});return o.renderCurveStatically(r,t,c)}var L=ve(0,V),U=L(R),w;if(x){var D="".concat(x).split(/[,\s]+/gim).map(function(z){return parseFloat(z)});w=o.getStrokeDasharray(U,V,D)}else w=o.generateSimpleStrokeDasharray(V,U);return o.renderCurveStatically(l,t,c,{strokeDasharray:w})})}},{key:"renderCurve",value:function(t,c){var o=this.props,i=o.points,l=o.isAnimationActive,x=this.state,d=x.prevPoints,m=x.totalLength;return l&&i&&i.length&&(!d&&m>0||!ra(d,i))?this.renderCurveWithAnimation(t,c):this.renderCurveStatically(i,t,c)}},{key:"render",value:function(){var t,c=this.props,o=c.hide,i=c.dot,l=c.points,x=c.className,d=c.xAxis,m=c.yAxis,h=c.top,u=c.left,p=c.width,I=c.height,k=c.isAnimationActive,B=c.id;if(o||!l||!l.length)return null;var _=this.state.isAnimationFinished,O=l.length===1,V=os("recharts-line",x),$=d&&d.allowDataOverflow,R=m&&m.allowDataOverflow,K=$||R,r=We(B)?this.id:B,L=(t=we(i,!1))!==null&&t!==void 0?t:{r:3,strokeWidth:2},U=L.r,w=U===void 0?3:U,D=L.strokeWidth,z=D===void 0?2:D,N=ca(i)?i:{},A=N.clipDot,E=A===void 0?!0:A,F=w*2+z;return H.createElement(_e,{className:V},$||R?H.createElement("defs",null,H.createElement("clipPath",{id:"clipPath-".concat(r)},H.createElement("rect",{x:$?u:u-p/2,y:R?h:h-I/2,width:$?p:p*2,height:R?I:I*2})),!E&&H.createElement("clipPath",{id:"clipPath-dots-".concat(r)},H.createElement("rect",{x:u-F/2,y:h-F/2,width:p+F,height:I+F}))):null,!O&&this.renderCurve(K,r),this.renderErrorBar(K,r),(O||i)&&this.renderDots(K,E,r),(!k||_)&&la.renderCallByParent(this.props,l))}}],[{key:"getDerivedStateFromProps",value:function(t,c){return t.animationId!==c.prevAnimationId?{prevAnimationId:t.animationId,curPoints:t.points,prevPoints:c.curPoints}:t.points!==c.curPoints?{curPoints:t.points}:null}},{key:"repeat",value:function(t,c){for(var o=t.length%2!==0?[].concat(he(t),[0]):t,i=[],l=0;l<c;++l)i=[].concat(he(i),he(o));return i}},{key:"renderDotItem",value:function(t,c){var o;if(H.isValidElement(t))o=H.cloneElement(t,c);else if(ea(t))o=t(c);else{var i=c.key,l=fs(c,dt),x=os("recharts-line-dot",typeof t!="boolean"?t.className:"");o=H.createElement(sa,Ie({key:i},l,{className:x}))}return o}}])})(v.PureComponent);ae(ge,"displayName","Line");ae(ge,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!da.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});ae(ge,"getComposedData",function(s){var n=s.props,a=s.xAxis,t=s.yAxis,c=s.xAxisTicks,o=s.yAxisTicks,i=s.dataKey,l=s.bandSize,x=s.displayedData,d=s.offset,m=n.layout,h=x.map(function(u,p){var I=Rs(u,i);return m==="horizontal"?{x:xs({axis:a,ticks:c,bandSize:l,entry:u,index:p}),y:We(I)?null:t.scale(I),value:I,payload:u}:{x:We(I)?null:a.scale(I),y:xs({axis:t,ticks:o,bandSize:l,entry:u,index:p}),value:I,payload:u}});return W({points:h,layout:m},d)});var Ct=ma({chartName:"LineChart",GraphicalChild:ge,axisComponents:[{axisType:"xAxis",AxisComp:zs},{axisType:"yAxis",AxisComp:Vs}],formatAxisMap:ua});const be=[{month:"Jan",revenue:12500,expenses:8200},{month:"Feb",revenue:15800,expenses:9100},{month:"Mar",revenue:18200,expenses:10500},{month:"Apr",revenue:16900,expenses:9800},{month:"May",revenue:21300,expenses:11200},{month:"Jun",revenue:24500,expenses:12800},{month:"Jul",revenue:22800,expenses:11900},{month:"Aug",revenue:26100,expenses:13500},{month:"Sep",revenue:28900,expenses:14200},{month:"Oct",revenue:31200,expenses:15100}];function At(){const s=be.reduce((a,t)=>a+t.revenue,0),n=s/be.length;return e.jsxs(Q,{children:[e.jsxs(Z,{children:[e.jsx(J,{children:"Revenue Analytics"}),e.jsx(ee,{children:"Revenue and expenses over time"})]}),e.jsxs(se,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-3 mb-6",children:[e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Total Revenue"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",s.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Me,{className:"h-3 w-3"}),e.jsx("span",{children:"+24.5% from last period"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",n.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Me,{className:"h-3 w-3"}),e.jsx("span",{children:"+18.2% growth rate"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",be[be.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Me,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(xa,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(ha,{width:"100%",height:"100%",children:e.jsxs(Ct,{data:be,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(pa,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(zs,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Vs,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(ja,{content:e.jsx(ga,{})}),e.jsx(ge,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(ge,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const It=({contractId:s})=>{const[n,a]=v.useState(!1),[t,c]=v.useState(void 0),{issueDocuments:o}=ya(),i=Qe(ba(new Date,1),"yyyy-MM-dd"),[{data:l,fetching:x},d]=le({query:dn,variables:{issueMonth:i,contractId:s},pause:!n});v.useEffect(()=>{n&&d()},[n,d]),v.useEffect(()=>{if(l?.periodicalDocumentDraftsByContracts?.length){const h=mn(fe(un,l.periodicalDocumentDraftsByContracts[0]));c(h)}else l&&c(void 0)},[l,c]);const m=v.useCallback(async h=>{await o({generateDocumentsInfo:[h]}),a(!1)},[o]);return e.jsxs(Te,{open:n,onOpenChange:a,children:[e.jsx(Ls,{asChild:!0,children:e.jsx(T,{className:"size-7.5",variant:"ghost",children:e.jsx(xn,{className:"size-5"})})}),e.jsxs(Be,{className:"w-[90vw] sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:[e.jsxs(ts,{children:[e.jsx(is,{children:"Issue Document for Contract"}),e.jsx(rs,{children:"Issue periodically documents based on contract"})]}),x?e.jsx(Ze,{}):t?e.jsx(Na,{draft:t,onApprove:m}):e.jsx("div",{className:"text-center p-4 text-muted-foreground",children:"No document draft available to issue for this contract and period."})]})]})};function Ns(s){return{id:s.id,pos:s.purchaseOrders??void 0,startDate:s.startDate,endDate:s.endDate,paymentAmount:s.amount.raw,paymentCurrency:s.amount.currency,productType:s.product??void 0,billingCycle:s.billingCycle,msCloudLink:s.msCloud?.toString(),isActive:s.isActive,subscriptionPlan:s.plan??void 0,defaultRemark:s.remarks??void 0,defaultDocumentType:s.documentType??void 0,operationsLimit:s.operationsLimit}}function wt({clientId:s}){const[{data:n,fetching:a},t]=le({query:hn,variables:{clientId:s}}),c=v.useMemo(()=>[...n?.contractsByClient??[]].sort((o,i)=>new Date(i.startDate).getTime()-new Date(o.startDate).getTime()),[n?.contractsByClient]);return a?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(Q,{children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(J,{children:"Contracts"}),e.jsx(ee,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Ke,{clientId:s,onDone:t})]})}),e.jsx(se,{className:"space-y-4",children:c.map(o=>e.jsx(Dt,{clientId:s,contract:o,refetch:t},o.id))})]})}function Dt({clientId:s,contract:n,refetch:a}){const t=!!n.isActive;return e.jsxs("div",{className:"rounded-lg border p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h4",{className:"font-semibold",children:n.product}),e.jsx(re,{variant:t?"default":"secondary",children:n.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:n.id})]}),e.jsxs("div",{children:[e.jsx(Ke,{clientId:s,contract:Ns(n),onDone:a}),e.jsx(Ke,{clientId:s,contract:Ns(n),onDone:a,duplicate:!0}),e.jsx(It,{contractId:n.id})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[e.jsxs("div",{className:"space-y-0",children:[e.jsxs("p",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(pn,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(n.startDate).toLocaleDateString()," →"," ",new Date(n.endDate).toLocaleDateString()]})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"PO Numbers"}),e.jsx("p",{className:"text-sm font-medium font-mono",children:n.purchaseOrders.toReversed()[0]??""}),n.purchaseOrders.length>1&&e.jsx("div",{className:"space-x-1",children:n.purchaseOrders.toReversed().slice(1).map(c=>e.jsx("span",{className:"text-xs font-thin font-mono",children:c},c))})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Payment"}),e.jsx("p",{className:"text-sm font-medium",children:jn(n.amount.raw,n.amount.currency)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Billing Cycle"}),e.jsx("p",{className:"text-sm font-medium",children:fa(n.billingCycle)})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subscription Plan"}),e.jsx("p",{className:"text-sm font-medium",children:n.plan?va(n.plan):"N/A"})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Operations Limit"}),e.jsx("p",{className:"text-sm font-medium",children:n.operationsLimit.toLocaleString()})]}),e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Document Type"}),e.jsx("p",{className:"text-sm font-medium",children:gn(n.documentType)})]})]}),n.remarks&&e.jsxs("div",{className:"space-y-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Remark"}),e.jsx("p",{className:"text-sm",children:n.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:n.msCloud&&e.jsx(T,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:n.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(Ca,{className:"h-3 w-3 ml-1"})]})})})]},n.id)}const kt=[{id:"linearId",name:"Linear",description:"Issue tracking and project management",url:"https://linear.app/the-guild/customer/[ID]",color:"indigo-500"},{id:"slackChannelKey",name:"Slack",description:"Team communication and notifications",keyType:"Channel Key",url:"https://guild-oss.slack.com/archives/[ID]"},{id:"notionId",name:"Notion",description:"Documentation and knowledge management",url:"https://www.notion.so/theguildoss/[ID]"},{id:"workflowyUrl",name:"Workflowy",keyType:"URL",description:"Task management and note taking",url:"[ID]"}];function St({data:s}){const[n,a]=v.useState([]),t=fe(vn,s),c=t?.clientInfo?.integrations,{updateClient:o}=Fs(),[{data:i,fetching:l},x]=le({query:fn,variables:{clientId:t?.id??""},pause:!c?.greenInvoiceInfo||!t?.id||!n.includes("green-invoice")}),d=i?.greenInvoiceClient,m=c?.hiveId,h=v.useCallback((u,p)=>{if(!t?.id)return;const I={};I[p]=u,o({businessId:t?.id,fields:{integrations:I}})},[t?.id,o]);return v.useEffect(()=>{c?.greenInvoiceInfo?.greenInvoiceId&&t?.id&&n.includes("green-invoice")&&x()},[c?.greenInvoiceInfo?.greenInvoiceId,t?.id,x,n]),e.jsxs(Q,{children:[e.jsx(Z,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Integrations"}),e.jsx(ee,{children:"Connected external services and providers"})]})})}),e.jsx(se,{className:"space-y-6",children:e.jsxs(Ia,{type:"multiple",value:n,onValueChange:a,className:"space-y-4",children:[e.jsxs(Re,{value:"green-invoice",className:"rounded-lg border-2 border-green-600/20 bg-green-600/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-600/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-600 flex items-center justify-center text-white font-bold",children:"GI"}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Green Invoice"}),e.jsx(ze,{className:"h-5 w-5 text-green-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Israeli invoicing system integration"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx($e,{id:t?.clientInfo?.integrations.greenInvoiceInfo?.greenInvoiceId??void 0,provider:"Green Invoice",updateClient:async u=>h(u,"greenInvoiceId")}),t?.clientInfo?.integrations.greenInvoiceInfo?.greenInvoiceId&&e.jsx(hs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(ps,{children:l?e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-32"}),e.jsx(P,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(P,{className:"h-4 w-40"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-2 md:col-span-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(P,{className:"h-3 w-24"}),e.jsx(P,{className:"h-4 w-full"})]})]})]})]}):d&&e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Business Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Integration ID"}),e.jsx("p",{className:"text-sm font-mono",children:t?.clientInfo?.integrations.greenInvoiceInfo?.greenInvoiceId})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Business Name"}),e.jsx("p",{className:"text-sm",children:d.name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Country"}),e.jsx("p",{className:"text-sm",children:d.country?.name})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"text-sm font-mono",children:d.taxId})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide",children:"Contact Information"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(qe,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.emails?.map((u,p)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:u},p))})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("span",{className:"text-sm font-medium text-muted-foreground flex items-center gap-2",children:[e.jsx(Ms,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:d.phone})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Mobile"}),e.jsx("p",{className:"text-sm font-mono",children:d.mobile})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Fax"}),e.jsx("p",{className:"text-sm font-mono",children:d.fax})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h4",{className:"font-semibold text-sm text-muted-foreground uppercase tracking-wide flex items-center gap-2",children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"Address"]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsxs("div",{className:"space-y-1 md:col-span-2",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Street Address"}),e.jsx("p",{className:"text-sm",children:d.address})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"City"}),e.jsx("p",{className:"text-sm",children:d.city})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("span",{className:"text-sm font-medium text-muted-foreground",children:"Zip Code"}),e.jsx("p",{className:"text-sm font-mono",children:d.zip})]})]})]})]})})]}),e.jsxs(Re,{value:"hiveId",className:"rounded-lg border-2 border-green-900/20 bg-green-900/5",children:[e.jsx("div",{className:"px-4 py-3 bg-green-900/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[m?e.jsx(pe,{to:"https://the-guild.dev/graphql/hive",target:"_blank",rel:"noreferrer",onClick:u=>u.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-900 flex items-center justify-center text-white font-bold",children:e.jsx("img",{src:"/icons/logos/hive.svg",alt:"Hive logo",className:"size-8 object-cover"})})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-green-900 flex items-center justify-center text-white font-bold",children:e.jsx(ds,{})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:"Hive"}),m?e.jsx(ze,{className:"h-5 w-5 text-green-600"}):e.jsx(js,{className:"h-5 w-5 text-red-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Schema registry, analytics, metrics and gateway for GraphQL federation and other GraphQL APIs"})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx($e,{id:c?.hiveId??void 0,provider:"Hive",updateClient:async u=>h(u,"hiveId")})}),m&&e.jsx(hs,{className:"hover:no-underline p-2"})]})}),e.jsx(ps,{children:m&&e.jsxs("div",{className:"flex flex-col gap-4 px-4 pb-4 pt-2 border-t",children:[e.jsx("div",{className:"text-sm",children:e.jsxs(pe,{to:"https://the-guild.dev/graphql/hive",target:"_blank",rel:"noreferrer",onClick:u=>u.stopPropagation(),className:"inline-flex items-center font-semibold gap-2",children:[e.jsx("img",{src:"/icons/logos/hive.svg",alt:"Hive logo",className:"size-8 object-cover"}),"Hive"]})}),e.jsx("div",{className:"text-sm",children:e.jsxs(pe,{to:`https://graphcdn.retool.com/apps/f6c244bc-b7ce-11ef-a86c-0b05f221c5b4/Hive/Hive%20Admin/explore_organization?id=${c.hiveId}`,target:"_blank",rel:"noreferrer",onClick:u=>u.stopPropagation(),className:"inline-flex items-center font-semibold gap-2",children:[e.jsx("img",{src:"/icons/logos/retool.svg",alt:"Retool logo",className:"size-8 object-cover"}),"Retool"]})})]})})]},"hiveId"),kt.map(u=>e.jsx(Re,{value:u.id,className:"rounded-lg border-2 border-gray-500/20 bg-gray-500/5",children:e.jsx("div",{className:"px-4 py-3 bg-gray-500/10 rounded-t-lg",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3 flex-1",children:[c?.[u.id]?e.jsx(pe,{to:u.url.replace("[ID]",c?.[u.id]??""),target:"_blank",rel:"noreferrer",onClick:p=>p.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.jsx("div",{className:"h-10 w-10 rounded-lg bg-gray-500 flex items-center justify-center text-white font-bold",children:e.jsx(ss,{})})}):e.jsx("div",{className:"h-10 w-10 rounded-lg bg-gray-500 flex items-center justify-center text-white font-bold",children:e.jsx(ds,{})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:u.name}),c?.[u.id]==null?e.jsx(js,{className:"h-5 w-5 text-red-600"}):e.jsx(ze,{className:"h-5 w-5 text-green-600"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:u.description})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx($e,{id:t?.clientInfo?.integrations[u.id]??void 0,provider:u.name,keyType:u.keyType,updateClient:async p=>h(p,u.id)})})]})})},u.id))]})})]})}function $e({id:s,provider:n,keyType:a,updateClient:t}){const[c,o]=v.useState(!1),[i,l]=v.useState(s),x=v.useCallback(async()=>{await t(i),o(!1)},[i,t]);return e.jsxs(Te,{open:c,onOpenChange:o,children:[e.jsx(Ls,{asChild:!0,children:e.jsx(T,{variant:"outline",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(_s,{className:"h-4 w-4"})})}),e.jsxs(Be,{onClick:d=>d.stopPropagation(),children:[e.jsxs(ts,{children:[e.jsxs(is,{children:["Configure ",n]}),e.jsxs(rs,{children:["Update your ",n," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(Ae,{htmlFor:"id",children:[n," ",a??"ID"]}),e.jsx(C,{id:"id",value:i,onChange:d=>l(d.target.value),placeholder:`Enter ${n} ${a??"ID"}`})]})}),e.jsxs(Bs,{children:[e.jsx(T,{variant:"outline",onClick:()=>o(!1),children:"Cancel"}),e.jsx(T,{onClick:x,disabled:!i,children:"Save Changes"})]})]})]})}const Tt="updateBusiness",Hs=()=>{const[{fetching:s},n]=Ee(yn),a=v.useCallback(async t=>{const c=`Error updating business ID [${t.businessId}]`,o=`${Tt}-${t.businessId}`;X.loading("Updating business",{id:o});try{const i=await n(t),l=Pe(i,c,o,"updateBusiness");if(l)return X.success("Success",{id:o,description:"Business updated"}),l.updateBusiness}catch(i){console.error(`${c}: ${i}`),X.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateBusiness:a}},Bt=Object.values(Sn);function bs(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{isClient:!!s.clientInfo?.id,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough??void 0,isDocumentsOptional:s.isDocumentsOptional??void 0,isVatOptional:s.optionalVAT??void 0,isExemptDealer:s.exemptDealer??void 0,sortCode:s.sortCode?.key?.toString()??void 0,taxCategory:s.taxCategory?.id??void 0,pcn874RecordType:s?.pcn874RecordType??void 0,irsCode:s?.irsCode??void 0,description:s.suggestions?.description??void 0,tags:s.suggestions?.tags?.map(n=>n.id)??[],phrases:s.suggestions?.phrases??[],emails:s.suggestions?.emails??[],internalLinks:s.suggestions?.emailListener?.internalEmailLinks??[],attachmentTypes:s.suggestions?.emailListener?.attachments??[],useMessageBody:s.suggestions?.emailListener?.emailBody??void 0}}function Et(s){const a=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,c=s.description||s.tags||s.phrases||s.emails||a?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:a}:void 0;return{optionalVAT:s.isVatOptional,exemptDealer:s.isExemptDealer,sortCode:s.sortCode?parseInt(s.sortCode):void 0,taxCategory:s.taxCategory,pcn874RecordType:s.pcn874RecordType,irsCode:s.irsCode,isActive:s.isActive,isReceiptEnough:s.isReceiptEnough,isDocumentsOptional:s.isDocumentsOptional,suggestions:c}}function Pt({data:s,refetchBusiness:n}){const a=fe(bn,s),[t,c]=v.useState(bs(a)),{userContext:o}=v.useContext(cs),{updateBusiness:i,fetching:l}=Hs(),[x,d]=v.useState(!1),[m,h]=v.useState(void 0),u=Oe({defaultValues:t}),p=async k=>{if(!a||!o?.context.adminBusinessId)return;const B=ns(k,u.formState.dirtyFields);if(!B)return;const _=Et(B);await i({businessId:a.id,ownerId:o.context.adminBusinessId,fields:_}),B.tags?.length||B.description?(h({tagIds:B.tags?.map(O=>({id:O})),description:B.description}),d(!0)):n?.()};if(v.useEffect(()=>{if(a){const k=bs(a);c(k),u.reset(k)}},[a,u]),!a)return e.jsx("div",{});const I=u.watch("isClient");return e.jsxs(Q,{children:[e.jsx(Z,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(J,{children:"Configurations"}),e.jsx(ee,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!I&&e.jsx(Nn,{businessId:a.id,onDone:n})]})}),e.jsx(Le,{...u,children:e.jsxs("form",{onSubmit:u.handleSubmit(p),children:[e.jsxs(se,{className:"space-y-6",children:[e.jsx(Ot,{form:u}),e.jsx(de,{}),e.jsx(Lt,{form:u}),e.jsx(de,{}),e.jsx(Ft,{form:u}),e.jsx(de,{}),e.jsx(Mt,{form:u})]}),e.jsx(es,{className:"flex justify-end border-t pt-6",children:e.jsxs(T,{type:"submit",disabled:l||Object.keys(u.formState.dirtyFields).length===0,children:[e.jsx(ls,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(qa,{businessId:a.id,tagIds:m?.tagIds,description:m?.description,open:x,onOpenChange:d,onClose:n})]})}function Ot({form:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Business Status & Behavior"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:s.control,name:"isClient",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Client"}),e.jsx(me,{children:"Mark this business as a client"})]}),e.jsx(y,{children:e.jsx(oe,{disabled:!0,checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isActive",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Active"}),e.jsx(me,{children:"Business is currently active"})]}),e.jsx(y,{children:e.jsx(oe,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isReceiptEnough",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Receipt Enough"}),e.jsx(me,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(y,{children:e.jsx(oe,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isDocumentsOptional",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"No Docs Required"}),e.jsx(me,{children:"Skip document validation for common charges"})]}),e.jsx(y,{children:e.jsx(oe,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isVatOptional",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is VAT Optional"}),e.jsx(me,{children:"Mute missing VAT indicator"})]}),e.jsx(y,{children:e.jsx(oe,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})}),e.jsx(j,{control:s.control,name:"isExemptDealer",render:({field:n,fieldState:a})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Exempt Dealer"}),e.jsx(me,{children:"Business is exempt from VAT requirements"})]}),e.jsx(y,{children:e.jsx(oe,{checked:n.value,onCheckedChange:n.onChange,className:S(a)})})]})})]})]})}function Lt({form:s}){const{selectableTaxCategories:n,fetching:a}=Cn(),{selectableSortCodes:t,fetching:c,sortCodes:o}=An(),{selectableTags:i,fetching:l}=In(),x=v.useCallback(d=>{if(d){const m=o.find(h=>Number(h.key)===Number(d));m&&(m.defaultIrsCode?s.setValue("irsCode",m.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,o]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Default Settings"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:s.control,name:"sortCode",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Sort Code"}),e.jsx(y,{children:e.jsx(Ge,{onChange:h=>{x(h),d.onChange(h)},data:t,value:d.value,disabled:c,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:S(m)}})}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"taxCategory",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Category"}),e.jsx(y,{children:e.jsx(Ge,{data:n,disabled:a,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:S(m)}})}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"PCN874 Record Type"}),e.jsxs(ws,{onValueChange:d.onChange,value:d.value,children:[e.jsx(y,{children:e.jsx(Ds,{className:S(m),children:e.jsx(ks,{})})}),e.jsx(Ss,{children:Object.entries(wn).map(([h,u])=>e.jsx(Ts,{value:h,children:`${u} (${h})`},h))})]}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"irsCode",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(y,{children:e.jsx(Dn,{value:d.value??void 0,onValueChange:h=>d.onChange(h??null),hideControls:!0,decimalScale:0,className:S(m)})}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"description",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Charge Description"}),e.jsx(y,{children:e.jsx(C,{placeholder:"Enter default charge description",...d,className:S(m)})}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"tags",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tags"}),e.jsx(y,{children:e.jsx(kn,{options:Object.values(i).map(({value:h,label:u})=>({label:u,value:h})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:l,className:S(m)})}),e.jsx(b,{})]})})]})]})}function Ft({form:s}){const[n,a]=v.useState(""),[t,c]=v.useState(""),o=()=>{if(n.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,n.trim()],{shouldDirty:!0}),a("")}},i=()=>{if(t.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,t.trim()],{shouldDirty:!0}),c("")}},l=d=>{const m=s.getValues("phrases");s.setValue("phrases",m.filter((h,u)=>u!==d),{shouldDirty:!0})},x=d=>{const m=s.getValues("emails");s.setValue("emails",m.filter((h,u)=>u!==d),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Auto-matching Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure patterns for automatic matching of bank transactions and documents"}),e.jsx(j,{control:s.control,name:"phrases",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{placeholder:"Add phrase...",value:n,onChange:h=>a(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),o())},className:S(m)}),e.jsx(T,{type:"button",size:"sm",onClick:o,children:e.jsx(te,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,u)=>e.jsxs(re,{variant:"secondary",className:"gap-1",children:[h,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>l(u),children:e.jsx(ie,{className:"size-3 cursor-pointer",onClick:()=>l(u)})})]},u))}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"emails",render:({field:d,fieldState:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{type:"email",placeholder:"Add email...",value:t,onChange:h=>c(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),i())},className:S(m)}),e.jsx(T,{type:"button",size:"sm",onClick:i,children:e.jsx(te,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,u)=>e.jsxs(re,{variant:"secondary",className:"gap-1",children:[h,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>x(u),children:e.jsx(ie,{className:"size-3 cursor-pointer"})})]},u))}),e.jsx(b,{})]})})]})}function Mt({form:s}){const[n,a]=v.useState(""),t=()=>{if(n.trim()){const i=s.getValues("internalLinks");s.setValue("internalLinks",[...i,n.trim()],{shouldDirty:!0}),a("")}},c=i=>{const l=s.getValues("attachmentTypes");s.setValue("attachmentTypes",l?.includes(i)?l.filter(x=>x!==i):[...l,i],{shouldDirty:!0})},o=i=>{const l=s.getValues("internalLinks");s.setValue("internalLinks",l.filter((x,d)=>d!==i),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Gmail Feature Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Gmail integration settings for document processing"}),e.jsx(j,{control:s.control,name:"attachmentTypes",render:({field:i,fieldState:l})=>e.jsxs(g,{children:[e.jsx(f,{children:"Attachment Types"}),e.jsx("div",{className:S(l)+" rounded-md flex flex-wrap gap-2",children:Bt.map(x=>e.jsx(re,{variant:i.value?.includes(x)?"default":"outline",className:"cursor-pointer",onClick:()=>c(x),children:x},x))}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"internalLinks",render:({field:i,fieldState:l})=>e.jsxs(g,{children:[e.jsx(f,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{type:"url",placeholder:"Add internal link...",value:n,onChange:x=>a(x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),t())}}),e.jsx(T,{type:"button",size:"sm",onClick:t,children:e.jsx(te,{className:"h-4 w-4"})})]}),e.jsx("div",{className:S(l)+" flex flex-wrap gap-2 rounded-md",children:i.value?.map((x,d)=>e.jsxs(re,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[x,e.jsx(T,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(ie,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(b,{})]})}),e.jsx(j,{control:s.control,name:"useMessageBody",render:({field:i,fieldState:l})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Should Use Message Body"}),e.jsx(me,{children:"Extract information from email message body"})]}),e.jsx(y,{children:e.jsx(oe,{checked:i.value,onCheckedChange:i.onChange,className:S(l)})})]})})]})}const _t=xe({businessName:M().min(1,"Business name is required"),locality:M().min(1,"Locality is required"),localName:M().optional(),govId:M().optional(),address:M().optional(),city:M().optional(),zipCode:M().optional(),localAddress:M().optional(),phone:M().optional(),website:Pn("Invalid URL").optional().or(On("")),generalContacts:ue(us()).optional(),billingEmails:ue(us()).optional()});function Cs(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country?.code,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,city:s.city??void 0,zipCode:s.zipCode??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(n=>n.trim()),billingEmails:s.clientInfo?.emails}}function Rt(s){return{name:s.businessName,country:s.locality,hebrewName:s.localName,governmentId:s.govId,address:s.address,city:s.city,zipCode:s.zipCode,phoneNumber:s.phone,website:s.website,email:s.generalContacts?.join(", ")}}function zt({data:s,refetchBusiness:n}){const a=fe(En,s),[t,c]=v.useState(Cs(a)),{userContext:o}=v.useContext(cs),{updateBusiness:i,fetching:l}=Hs(),{updateClient:x,fetching:d}=Fs(),m=Oe({resolver:Je(_t),defaultValues:t}),{countries:h,fetching:u}=Tn(),[p,I]=v.useState(""),[k,B]=v.useState(""),_=m.watch("locality"),O=m.watch("address"),V=m.watch("city"),$=m.watch("zipCode"),R=m.watch("localAddress");v.useEffect(()=>{O!==t.address&&m.setValue("address",O,{shouldDirty:!0})},[O,t.address,m]),v.useEffect(()=>{V!==t.city&&m.setValue("city",V,{shouldDirty:!0})},[V,t.city,m]),v.useEffect(()=>{$!==t.zipCode&&m.setValue("zipCode",$,{shouldDirty:!0})},[$,t.zipCode,m]),v.useEffect(()=>{R!==t.localAddress&&m.setValue("localAddress",R,{shouldDirty:!0})},[R,t.localAddress,m]);const K=a&&"clientInfo"in a&&!!a.clientInfo,r=_===o?.context.locality,L=N=>{p.trim()&&(m.setValue("generalContacts",[...N,p.trim()],{shouldDirty:!0}),I(""))},U=(N,A)=>{m.setValue("generalContacts",N.filter((E,F)=>F!==A),{shouldDirty:!0})},w=N=>{k.trim()&&(m.setValue("billingEmails",[...N,k.trim()],{shouldDirty:!0}),B(""))},D=(N,A)=>{m.setValue("billingEmails",N.filter((E,F)=>F!==A),{shouldDirty:!0})},z=async N=>{if(!a||!o?.context.adminBusinessId)return;const A=ns(N,m.formState.dirtyFields);if(!A)return;const E=Rt(A),F=[];Object.values(E).some(Fe=>Fe!=null)&&F.push(i({businessId:a.id,ownerId:o.context.adminBusinessId,fields:E})),K&&A.billingEmails&&F.push(x({businessId:a.id,fields:{emails:A.billingEmails}})),await Promise.all(F),n?.()};return v.useEffect(()=>{if(a){const N=Cs(a);c(N),m.reset(N)}},[a,m]),e.jsxs(Q,{children:[e.jsxs(Z,{children:[e.jsx(J,{children:"Contact Information"}),e.jsx(ee,{children:"Business contact details and address information"})]}),e.jsx(Le,{...m,children:e.jsxs("form",{onSubmit:m.handleSubmit(z),children:[e.jsx(se,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:m.control,name:"businessName",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Name"}),e.jsx(y,{children:e.jsx(C,{...N,className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"locality",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Locality / Country"}),e.jsx(Ge,{onChange:N.onChange,data:h.map(E=>({value:E.code,label:E.name})),value:N.value,disabled:u,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:S(A)}}),e.jsx(b,{})]})}),r&&e.jsx(j,{control:m.control,name:"localName",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Local Name"}),e.jsx(y,{children:e.jsx(C,{...N,placeholder:"Business name in local language",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"govId",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Government ID"}),e.jsx(y,{children:e.jsx(C,{...N,placeholder:"Enter Government ID",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"address",render:({field:N,fieldState:A})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"Address"]}),e.jsx(y,{children:e.jsx(ms,{...N,rows:3,placeholder:"Enter business address",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"city",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"City"}),e.jsx(y,{children:e.jsx(C,{...N,placeholder:"Enter City",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"zipCode",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsx(f,{children:"Zip Code"}),e.jsx(y,{children:e.jsx(C,{...N,placeholder:"Enter Zip Code",className:S(A)})}),e.jsx(b,{})]})}),r&&e.jsx(j,{control:m.control,name:"localAddress",render:({field:N,fieldState:A})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(He,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(y,{children:e.jsx(ms,{...N,rows:3,placeholder:"Enter address in local language",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"phone",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Ms,{className:"h-4 w-4"}),"Phone"]}),e.jsx(y,{children:e.jsx(C,{...N,type:"tel",placeholder:"+1 (555) 123-4567",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"website",render:({field:N,fieldState:A})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Bn,{className:"h-4 w-4"}),"Website"]}),e.jsx(y,{children:e.jsx(C,{...N,type:"url",placeholder:"https://example.com",className:S(A)})}),e.jsx(b,{})]})}),e.jsx(j,{control:m.control,name:"generalContacts",render:({field:N,fieldState:A})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(y,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:S(A)+" flex flex-wrap gap-2 mb-2 rounded-md",children:N.value?.map((E,F)=>e.jsxs(re,{variant:"secondary",className:"gap-1 pr-1",children:[E,e.jsx("button",{type:"button",onClick:()=>U(N.value??[],F),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ie,{className:"h-3 w-3"})})]},F))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{value:p,onChange:E=>I(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),L(N.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(T,{type:"button",variant:"outline",size:"icon",disabled:!p.trim(),onClick:()=>L(N.value??[]),children:e.jsx(te,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})}),K&&e.jsx(j,{control:m.control,name:"billingEmails",render:({field:N,fieldState:A})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(y,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:S(A)+" flex flex-wrap gap-2 mb-2 rounded-md",children:N.value?.map((E,F)=>e.jsxs(re,{variant:"secondary",className:"gap-1 pr-1",children:[E,e.jsx("button",{type:"button",onClick:()=>D(N.value??[],F),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(ie,{className:"h-3 w-3"})})]},F))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(C,{value:k,onChange:E=>B(E.target.value),onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),w(N.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(T,{type:"button",variant:"outline",size:"icon",disabled:!k.trim(),onClick:()=>w(N.value??[]),children:e.jsx(te,{className:"h-4 w-4"})})]})]})}),e.jsx(b,{})]})})]})}),e.jsx(es,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(T,{type:"submit",disabled:l||d||Object.keys(m.formState.dirtyFields).length===0,children:[e.jsx(ls,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}function Vt({businessId:s}){return e.jsxs(Q,{children:[e.jsx(Z,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Documents"}),e.jsx(ee,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(se,{children:e.jsx(Ln,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}function $t({businessId:s}){const[{data:n,fetching:a}]=le({query:Fn,variables:{businessId:s}});return a?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(Q,{children:[e.jsx(Z,{className:"flex w-full justify-between items-center",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Ledger Records"}),e.jsx(ee,{children:"Complete ledger history for this business"})]})})}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Zn,{ledgerRecordsData:n?.ledgerRecordsByFinancialEntity??[]})})})]})}function Ut({businessId:s}){const[{data:n,fetching:a}]=le({query:Mn,variables:{businessId:s}});return a?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(Q,{children:[e.jsx(Z,{className:"flex w-full justify-between items-center",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(J,{children:"Transactions"}),e.jsx(ee,{children:"Complete transaction history for this business"})]})})}),e.jsx(se,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Aa,{transactionsProps:n?.transactionsByFinancialEntity??[]})})})]})}function qt({data:s,refetchBusiness:n}){const a=fe(qn,s),[t,c]=_n(),{setFiltersContext:o}=v.useContext(Rn);v.useEffect(()=>{o(null)},[o]);const i=t.get("tab")||"contact",l=m=>{c({tab:m})};if(!a)return e.jsx("div",{children:"Business not found"});const x="clientInfo"in a&&!!a.clientInfo,d="adminInfo"in a&&!!a.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Yn,{data:a}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(zn,{value:i,onValueChange:l,className:"w-full",children:[e.jsxs(Vn,{className:"grid w-full lg:grid-cols-8 sm:grid-cols-4 grid-cols-8 mb-6 h-auto gap-1 bg-muted/50 p-1",children:[e.jsxs(ne,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(ne,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(_s,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(ne,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ke,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(ne,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx($n,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(ne,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),e.jsxs(ne,{value:"ledger",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(za,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ledger"})]}),e.jsxs(ne,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Ba,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),x&&e.jsxs(e.Fragment,{children:[e.jsxs(ne,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Fa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(ne,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx($a,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),d&&e.jsxs(e.Fragment,{children:[e.jsxs(ne,{value:"accounts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Jn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Accounts"})]}),e.jsxs(ne,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(As,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]})]}),e.jsx(Y,{value:"contact",className:"mt-0",children:e.jsx(zt,{data:a,refetchBusiness:n})}),e.jsx(Y,{value:"config",className:"mt-0",children:e.jsx(Pt,{data:a,refetchBusiness:n})}),e.jsx(Y,{value:"charges",className:"mt-0",children:e.jsx(lt,{businessId:a.id})}),e.jsx(Y,{value:"transactions",className:"mt-0",children:e.jsx(Ut,{businessId:a.id})}),e.jsx(Y,{value:"documents",className:"mt-0",children:e.jsx(Vt,{businessId:a.id})}),e.jsx(Y,{value:"ledger",className:"mt-0",children:e.jsx($t,{businessId:a.id})}),e.jsx(Y,{value:"balance",className:"mt-0",children:e.jsx(ct,{businessId:a.id})}),x&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{value:"contracts",className:"mt-0",children:e.jsx(wt,{clientId:a.id})}),e.jsx(Y,{value:"integrations",className:"mt-0",children:e.jsx(St,{data:a})}),e.jsx(Y,{value:"charts",className:"mt-0",children:e.jsx(At,{})})]}),d&&e.jsxs(e.Fragment,{children:[e.jsx(Y,{value:"accounts",className:"mt-0",children:e.jsx(rt,{adminId:a.id})}),e.jsx(Y,{value:"admin",className:"mt-0",children:e.jsx(Ya,{data:a})})]})]})})]})}const ji=()=>{const{businessId:s}=Hn();let n;try{n=Gn()}catch{}const[{data:a,fetching:t},c]=le({query:Wn,pause:!s||!!n,variables:{businessId:s??""}}),o=n||a;return!n&&t&&!o?.business?e.jsx(Ze,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(qt,{data:o.business,refetchBusiness:async()=>c()})};export{ji as BusinessScreen};
@@ -1 +1 @@
1
- import{a as I,b as x,r as o,u as D,j as t,c as f,C as j}from"./index-CJQEWig2.js";import{C as v}from"./charges-table-BlXyOjYT.js";import{E as M,I as E,M as S}from"./match-document-modal-CIlUk8Ew.js";import"./toggle-expansion-button-CERf5wnd.js";import"./panel-top-open-et1B6Qub.js";import"./index-MwL919Y6.js";import"./similar-transactions-modal-DPUwmIYc.js";import"./addDays-B1nYv7cD.js";import"./list-plus-D47DH24w.js";import"./Table-0rvmS2wr.js";import"./summary-CzvCns1x.js";import"./deposits-transactions-table-CTYnxtJU.js";import"./Checkbox-CIjNLOvn.js";import"./accordion-L1IRyzyA.js";import"./data-table-column-header-Dm4KLrte.js";import"./eye-off-CEEw38cP.js";import"./YearPickerInput-XVeVR1Oa.js";import"./insert-business-trip-modal-DAddh4SL.js";import"./accounter-table-DO07S-Ok.js";import"./modal-B-dHSlvi.js";const N=({chargeId:p})=>{const{chargeId:u}=I(),r=p||u;let e;try{e=x()}catch{}const[a,c]=o.useState(void 0),[s,n]=o.useState(void 0),[i,d]=o.useState(void 0),[{data:g,fetching:l},m]=D({query:j,pause:!r||!!e,variables:{chargeId:r??""}});o.useEffect(()=>{r&&!e&&m()},[r,e,m]);const h=e||g,C=!e&&l;return r?t.jsxs(t.Fragment,{children:[C?t.jsx(f,{}):t.jsx(v,{setEditChargeId:c,setInsertDocument:n,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),a&&t.jsx(M,{chargeId:a?.id,close:()=>c(void 0),onChange:a.onChange}),s&&t.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>n(void 0)}),i&&t.jsx(S,{chargeId:i.id,ownerId:i.ownerId,setMatchDocuments:()=>d(void 0)})]}):t.jsx("div",{children:"Charge not found"})};export{N as Charge};
1
+ import{a as I,b as x,r as o,u as D,j as t,c as f,C as j}from"./index-DEV5LiNl.js";import{C as v}from"./charges-table-Ca8NLtQw.js";import{E as M,I as E,M as S}from"./match-document-modal-CoD32N9X.js";import"./toggle-expansion-button-D8u5XCV3.js";import"./panel-top-open-BVYyrhXF.js";import"./index-SSi9xYyM.js";import"./similar-transactions-modal-BJxT9GAZ.js";import"./addDays-CqDW575k.js";import"./list-plus-uhcKtu05.js";import"./Table-BKmRkEex.js";import"./summary-B3q161uS.js";import"./deposits-transactions-table-Bv0SsZOc.js";import"./Checkbox-DB0ksED6.js";import"./accordion-ByPdqgz2.js";import"./data-table-column-header-BvxwVRjw.js";import"./eye-off--kONYNyo.js";import"./YearPickerInput-D5CNiDUw.js";import"./insert-business-trip-modal-FZvpLLha.js";import"./accounter-table-DFs02wur.js";import"./modal-BU8TISCI.js";const N=({chargeId:p})=>{const{chargeId:u}=I(),r=p||u;let e;try{e=x()}catch{}const[a,c]=o.useState(void 0),[s,n]=o.useState(void 0),[i,d]=o.useState(void 0),[{data:g,fetching:l},m]=D({query:j,pause:!r||!!e,variables:{chargeId:r??""}});o.useEffect(()=>{r&&!e&&m()},[r,e,m]);const h=e||g,C=!e&&l;return r?t.jsxs(t.Fragment,{children:[C?t.jsx(f,{}):t.jsx(v,{setEditChargeId:c,setInsertDocument:n,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),a&&t.jsx(M,{chargeId:a?.id,close:()=>c(void 0),onChange:a.onChange}),s&&t.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>n(void 0)}),i&&t.jsx(S,{chargeId:i.id,ownerId:i.ownerId,setMatchDocuments:()=>d(void 0)})]}):t.jsx("div",{children:"Charge not found"})};export{N as Charge};
@@ -1 +1 @@
1
- import{r as i,bA as B,bH as z,j as e,P as R,bB as U,B as W,aC as G,z as _,w as N,aE as D,dq as q,b4 as J,V as K,dr as Q,bD as h,er as X,bE as M,bF as O,bG as V,ek as k,at as m,hK as Y,a2 as Z,Y as x,Z as j,_ as p,$ as g,bT as $,bU as ee,bV as se}from"./index-CJQEWig2.js";import{u as ae}from"./use-url-query-B4uMZFi3.js";import{P as te}from"./modal-B-dHSlvi.js";import{F as ne}from"./funnel-wCPsNKWN.js";import{s as oe}from"./sub-CP-0oRhw.js";import{M as A}from"./MultiSelect-E2FPCJdH.js";function re(a){return!a||B(a)?null:encodeURIComponent(JSON.stringify(a))}const le=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ce=[{label:"All",value:k.All},{label:"Income",value:k.Income},{label:"Expense",value:k.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:b}=i.useContext(G),o=_({defaultValues:{byOwners:b?.context.adminBusinessId?[b.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(oe(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:l,handleSubmit:T,watch:C}=o,[y,F]=i.useState(a.sortBy?.asc??!1),[c,u]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:S,fetching:t}=q(),{selectableTags:v,fetching:I}=J(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const L=s=>{y!=null&&s.sortBy?.field&&(s.sortBy.asc=y),w(s),d()};function H(){w({}),F(!1),d()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(K,{...o,children:e.jsxs("form",{onSubmit:T(L),children:[e.jsxs(Q,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:S,value:s.value??[],disabled:t,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byBusinesses",control:l,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:S,value:s.value??[],disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byTags",control:l,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:v,itemComponent:X,value:s.value??[],disabled:I,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(r,f,P)=>P.label?.toLowerCase().includes(r.toLowerCase().trim())||P.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"toAnyDate",control:l,defaultValue:a.toAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"chargesType",control:l,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:ce,value:s.value??k.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"sortBy.field",control:l,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:le,label:"Field to sort by",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,rightSectionProps:{style:{width:"5rem"}},withinPortal:!0,rightSection:e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(m,{defaultChecked:a.sortBy?.asc??!1,checked:y??!1,disabled:!c,onCheckedChange:F}),e.jsx("span",{className:"text-xs",children:y?"ASC":"DESC"})]})})}),e.jsx(h,{name:"accountantStatus",control:l,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(A,{...s,value:s.value??[],data:Y,disabled:t,label:"Accountant Status",placeholder:"All",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4 rounded-lg border p-3 shadow-sm space-y-2",children:[e.jsx(Z,{children:"Missing Information:"}),e.jsx(x,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Invoice"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Receipts"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Documents"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"With Open Documents"})}),e.jsx(g,{children:e.jsxs($,{children:[e.jsx(ee,{children:e.jsx(m,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(se,{children:e.jsx("p",{children:"Show only charges with documents that are currently open"})})]})})]})}),e.jsx(x,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Transactions"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Unbalanced businesses"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without ledger"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutLedger??!1,onCheckedChange:s.onChange})})]})})]})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:t||I,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:H,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:d,children:"Cancel"})]})]})})]})}function pe({filter:a={},setFilter:w,activePage:d,setPage:b,totalPages:o=1,initiallyOpened:l=!1}){const[T,C]=i.useState(l),[y,F]=i.useState(!B(a)),{get:c,set:u}=ae();i.useEffect(()=>{const t=d>0?d.toFixed(0):null,v=c("page");t!==v&&u("page",t)},[d,c,u]),i.useEffect(()=>{const t=re(a),v=c("chargesFilters");t!==v&&(u("chargesFilters",t),u("page"),b(0))},[a,c,u,b]);const S=i.useCallback(t=>{z(t,a)||(w(t),F(!B(t)))},[a,w]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(te,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(R,{className:"flex-fit w-fit mx-0",currentPageIndex:d,onChange:b,totalPages:o}),e.jsx(U,{inline:!0,size:16,disabled:!y,children:e.jsx(W,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(ne,{className:"size-5"})})})]})}export{pe as C,ce as c};
1
+ import{r as i,bA as B,bH as z,j as e,P as R,bB as U,B as W,aC as G,z as _,w as N,aE as D,dq as q,b4 as J,V as K,dr as Q,bD as h,hJ as X,bE as M,bF as O,bG as V,ek as k,at as m,hK as Y,a2 as Z,Y as x,Z as j,_ as p,$ as g,bT as $,bU as ee,bV as se}from"./index-DEV5LiNl.js";import{u as ae}from"./use-url-query-B0EImNN2.js";import{P as te}from"./modal-BU8TISCI.js";import{F as ne}from"./funnel-B3hXp3Nu.js";import{s as oe}from"./sub-Dz0fJPLy.js";import{M as A}from"./MultiSelect-zOjALMtX.js";function re(a){return!a||B(a)?null:encodeURIComponent(JSON.stringify(a))}const le=[{value:D.AbsAmount,label:"Abs Amount"},{value:D.Amount,label:"Amount"},{value:D.Date,label:"Date"}],ce=[{label:"All",value:k.All},{label:"Income",value:k.Income},{label:"Expense",value:k.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:b}=i.useContext(G),o=_({defaultValues:{byOwners:b?.context.adminBusinessId?[b.context.adminBusinessId]:void 0,sortBy:{field:D.Date,asc:!1},toAnyDate:N(new Date,"yyyy-MM-dd"),fromAnyDate:N(oe(new Date,{years:1}),"yyyy-MM-dd"),...a}}),{control:l,handleSubmit:T,watch:C}=o,[y,F]=i.useState(a.sortBy?.asc??!1),[c,u]=i.useState(!!a.sortBy?.field),{selectableFinancialEntities:S,fetching:t}=q(),{selectableTags:v,fetching:I}=J(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const L=s=>{y!=null&&s.sortBy?.field&&(s.sortBy.asc=y),w(s),d()};function H(){w({}),F(!1),d()}return e.jsxs(e.Fragment,{children:[t?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsx(K,{...o,children:e.jsxs("form",{onSubmit:T(L),children:[e.jsxs(Q,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:S,value:s.value??[],disabled:t,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byBusinesses",control:l,defaultValue:a.byBusinesses,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:S,value:s.value??[],disabled:t,label:"Financial Entities",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"byTags",control:l,defaultValue:a.byTags,render:({field:s,fieldState:n})=>e.jsx(A,{...s,data:v,itemComponent:X,value:s.value??[],disabled:I,label:"Tags",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,withinPortal:!0,filter:(r,f,P)=>P.label?.toLowerCase().includes(r.toLowerCase().trim())||P.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"toAnyDate",control:l,defaultValue:a.toAnyDate,rules:{pattern:{value:M,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(O,{...s,onChange:r=>{const f=r?typeof r=="string"?r:N(r,"yyyy-MM-dd"):void 0;f!==s.value&&s.onChange(f)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(h,{name:"chargesType",control:l,defaultValue:a.chargesType,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:ce,value:s.value??k.All,disabled:t,label:"Charge Type",placeholder:"Filter income/expense",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsx(h,{name:"sortBy.field",control:l,defaultValue:a.sortBy?.field??D.Date,render:({field:s,fieldState:n})=>e.jsx(V,{...s,data:le,label:"Field to sort by",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message,rightSectionProps:{style:{width:"5rem"}},withinPortal:!0,rightSection:e.jsxs("div",{className:"flex flex-row items-center gap-1",children:[e.jsx(m,{defaultChecked:a.sortBy?.asc??!1,checked:y??!1,disabled:!c,onCheckedChange:F}),e.jsx("span",{className:"text-xs",children:y?"ASC":"DESC"})]})})}),e.jsx(h,{name:"accountantStatus",control:l,defaultValue:a.accountantStatus,render:({field:s,fieldState:n})=>e.jsx(A,{...s,value:s.value??[],data:Y,disabled:t,label:"Accountant Status",placeholder:"All",maxDropdownHeight:160,error:n.error?.message,withinPortal:!0})}),e.jsxs("div",{className:"flex flex-col gap-2 mt-4 rounded-lg border p-3 shadow-sm space-y-2",children:[e.jsx(Z,{children:"Missing Information:"}),e.jsx(x,{control:o.control,name:"withoutInvoice",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Invoice"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutInvoice??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutReceipt",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Receipts"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutReceipt??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Documents"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutDocuments??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withOpenDocuments",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"With Open Documents"})}),e.jsx(g,{children:e.jsxs($,{children:[e.jsx(ee,{children:e.jsx(m,{defaultChecked:a.withOpenDocuments??!1,onCheckedChange:s.onChange})}),e.jsx(se,{children:e.jsx("p",{children:"Show only charges with documents that are currently open"})})]})})]})}),e.jsx(x,{control:o.control,name:"withoutTransactions",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without Transactions"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutTransactions??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"unbalanced",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Unbalanced businesses"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.unbalanced??!1,onCheckedChange:s.onChange})})]})}),e.jsx(x,{control:o.control,name:"withoutLedger",render:({field:s})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(p,{children:"Without ledger"})}),e.jsx(g,{children:e.jsx(m,{defaultChecked:a.withoutLedger??!1,onCheckedChange:s.onChange})})]})})]})]}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:t||I,className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Filter"}),e.jsx("button",{type:"button",className:"text-white bg-orange-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-orange-600 rounded-sm text-lg",onClick:H,children:"Clear"}),e.jsx("button",{type:"button",className:"text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:d,children:"Cancel"})]})]})})]})}function pe({filter:a={},setFilter:w,activePage:d,setPage:b,totalPages:o=1,initiallyOpened:l=!1}){const[T,C]=i.useState(l),[y,F]=i.useState(!B(a)),{get:c,set:u}=ae();i.useEffect(()=>{const t=d>0?d.toFixed(0):null,v=c("page");t!==v&&u("page",t)},[d,c,u]),i.useEffect(()=>{const t=re(a),v=c("chargesFilters");t!==v&&(u("chargesFilters",t),u("page"),b(0))},[a,c,u,b]);const S=i.useCallback(t=>{z(t,a)||(w(t),F(!B(t)))},[a,w]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(te,{opened:T,onClose:()=>C(!1),content:e.jsx(ie,{filter:a,setFilter:S,closeModal:()=>C(!1)}),modalSize:"xl"}),o>1&&e.jsx(R,{className:"flex-fit w-fit mx-0",currentPageIndex:d,onChange:b,totalPages:o}),e.jsx(U,{inline:!0,size:16,disabled:!y,children:e.jsx(W,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>C(!0),children:e.jsx(ne,{className:"size-5"})})})]})}export{pe as C,ce as c};
@@ -1 +1 @@
1
- import{r as t,F as D,u as E,j as e,T as N,B as w,L as T,d as z,e as W,f as b}from"./index-CJQEWig2.js";import{u as O}from"./use-url-query-B4uMZFi3.js";import{C as k}from"./charges-filters-f-g5zs9d.js";import{M as B,C as R,T as V}from"./charges-table-BlXyOjYT.js";import{E as A,I as Q,M as U}from"./match-document-modal-CIlUk8Ew.js";import{P as q}from"./page-layout-B2gYTWUz.js";import{P as J}from"./Progress-DMJQvFdk.js";import{P as $,a as G}from"./panel-top-open-et1B6Qub.js";import"./modal-B-dHSlvi.js";import"./funnel-wCPsNKWN.js";import"./sub-CP-0oRhw.js";import"./addDays-B1nYv7cD.js";import"./subMonths-Cu93C5UH.js";import"./MultiSelect-E2FPCJdH.js";import"./toggle-expansion-button-CERf5wnd.js";import"./index-MwL919Y6.js";import"./similar-transactions-modal-DPUwmIYc.js";import"./list-plus-D47DH24w.js";import"./Table-0rvmS2wr.js";import"./summary-CzvCns1x.js";import"./deposits-transactions-table-CTYnxtJU.js";import"./Checkbox-CIjNLOvn.js";import"./accordion-L1IRyzyA.js";import"./data-table-column-header-Dm4KLrte.js";import"./eye-off-CEEw38cP.js";import"./YearPickerInput-XVeVR1Oa.js";import"./insert-business-trip-modal-DAddh4SL.js";import"./accounter-table-DO07S-Ok.js";const Le=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[c,x]=t.useState(void 0),[l,C]=t.useState(void 0),[g,f]=t.useState(!1),[r,m]=t.useState([]),{get:F}=O(),d=F("chargesFilters"),I=t.useMemo(()=>{if(d)try{return JSON.parse(decodeURIComponent(d))}catch{return}},[d]),[o,j]=t.useState(I),S=t.useCallback((s,y)=>{r.map(h=>h.id).includes(s)?m(r.filter(h=>h.id!==s)):m([...r,{id:s,onChange:y}])},[r]),[{data:a,fetching:M},v]=E({query:b,variables:{filters:o},pause:!0});function P(){m([])}const i=t.useMemo(()=>a?.chargesWithLedgerChanges?.length?a.chargesWithLedgerChanges[a.chargesWithLedgerChanges.length-1].progress:0,[a?.chargesWithLedgerChanges]),L=t.useCallback(s=>{j(s)},[j]);return t.useEffect(()=>{o&&v()},[o,v]),t.useEffect(()=>{p(e.jsxs("div",{className:"flex flex-row gap-x-5 items-center",children:[e.jsx(J,{value:i,label:`${i?.toFixed(2)}%`,size:"xl",animate:i<100,className:"min-w-52"}),e.jsx(k,{filter:o,setFilter:L,activePage:0,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{content:"Expand all accounts",children:e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>f(s=>!s),children:g?e.jsx($,{className:"size-5"}):e.jsx(G,{className:"size-5"})})}),e.jsx(B,{selected:r,resetMerge:P})]}))},[a,M,o,g,p,f,r,i,L]),e.jsxs(q,{title:"Charges Ledger Validation",description:"Manage charges",children:[M?e.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(R,{setEditChargeId:u,setInsertDocument:x,setMatchDocuments:C,toggleMergeCharge:S,mergeSelectedCharges:new Set(r.map(s=>s.id)),data:a?.chargesWithLedgerChanges.filter(s=>!!s.charge).map(s=>s.charge)??[],isAllOpened:g}),e.jsxs("div",{className:"flex flex-row justify-center my-2",children:[i>0&&i<100&&e.jsx(z,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(V,{radius:"xl",size:"xl",color:"green",children:e.jsx(W,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),c&&e.jsx(Q,{chargeId:c.id,onChange:c.onChange,close:()=>x(void 0)}),l&&e.jsx(U,{chargeId:l.id,ownerId:l.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Le as ChargesLedgerValidation};
1
+ import{r as t,F as D,u as E,j as e,T as N,B as w,L as T,d as z,e as W,f as b}from"./index-DEV5LiNl.js";import{u as O}from"./use-url-query-B0EImNN2.js";import{C as k}from"./charges-filters-DhCpuaf1.js";import{M as B,C as R,T as V}from"./charges-table-Ca8NLtQw.js";import{E as A,I as Q,M as U}from"./match-document-modal-CoD32N9X.js";import{P as q}from"./page-layout-DzyS2SLh.js";import{P as J}from"./Progress-t6R1Ap8G.js";import{P as $,a as G}from"./panel-top-open-BVYyrhXF.js";import"./modal-BU8TISCI.js";import"./funnel-B3hXp3Nu.js";import"./sub-Dz0fJPLy.js";import"./addDays-CqDW575k.js";import"./subMonths-B0TEAjr8.js";import"./MultiSelect-zOjALMtX.js";import"./toggle-expansion-button-D8u5XCV3.js";import"./index-SSi9xYyM.js";import"./similar-transactions-modal-BJxT9GAZ.js";import"./list-plus-uhcKtu05.js";import"./Table-BKmRkEex.js";import"./summary-B3q161uS.js";import"./deposits-transactions-table-Bv0SsZOc.js";import"./Checkbox-DB0ksED6.js";import"./accordion-ByPdqgz2.js";import"./data-table-column-header-BvxwVRjw.js";import"./eye-off--kONYNyo.js";import"./YearPickerInput-D5CNiDUw.js";import"./insert-business-trip-modal-FZvpLLha.js";import"./accounter-table-DFs02wur.js";const Le=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[c,x]=t.useState(void 0),[l,C]=t.useState(void 0),[g,f]=t.useState(!1),[r,m]=t.useState([]),{get:F}=O(),d=F("chargesFilters"),I=t.useMemo(()=>{if(d)try{return JSON.parse(decodeURIComponent(d))}catch{return}},[d]),[o,j]=t.useState(I),S=t.useCallback((s,y)=>{r.map(h=>h.id).includes(s)?m(r.filter(h=>h.id!==s)):m([...r,{id:s,onChange:y}])},[r]),[{data:a,fetching:M},v]=E({query:b,variables:{filters:o},pause:!0});function P(){m([])}const i=t.useMemo(()=>a?.chargesWithLedgerChanges?.length?a.chargesWithLedgerChanges[a.chargesWithLedgerChanges.length-1].progress:0,[a?.chargesWithLedgerChanges]),L=t.useCallback(s=>{j(s)},[j]);return t.useEffect(()=>{o&&v()},[o,v]),t.useEffect(()=>{p(e.jsxs("div",{className:"flex flex-row gap-x-5 items-center",children:[e.jsx(J,{value:i,label:`${i?.toFixed(2)}%`,size:"xl",animate:i<100,className:"min-w-52"}),e.jsx(k,{filter:o,setFilter:L,activePage:0,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{content:"Expand all accounts",children:e.jsx(w,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>f(s=>!s),children:g?e.jsx($,{className:"size-5"}):e.jsx(G,{className:"size-5"})})}),e.jsx(B,{selected:r,resetMerge:P})]}))},[a,M,o,g,p,f,r,i,L]),e.jsxs(q,{title:"Charges Ledger Validation",description:"Manage charges",children:[M?e.jsx(T,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs(e.Fragment,{children:[e.jsx(R,{setEditChargeId:u,setInsertDocument:x,setMatchDocuments:C,toggleMergeCharge:S,mergeSelectedCharges:new Set(r.map(s=>s.id)),data:a?.chargesWithLedgerChanges.filter(s=>!!s.charge).map(s=>s.charge)??[],isAllOpened:g}),e.jsxs("div",{className:"flex flex-row justify-center my-2",children:[i>0&&i<100&&e.jsx(z,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(V,{radius:"xl",size:"xl",color:"green",children:e.jsx(W,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),c&&e.jsx(Q,{chargeId:c.id,onChange:c.onChange,close:()=>x(void 0)}),l&&e.jsx(U,{chargeId:l.id,ownerId:l.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Le as ChargesLedgerValidation};