@accounter/client 0.0.8-alpha-20251031025517-bd142395bc1d7267ab00d6b53b116062b581b7d8 → 0.0.8-alpha-20251031141702-e34a767c5819bcbc513f11c64581c7a3a88fb731

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 (86) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/dist/assets/{Checkbox-CMTNcrRo.js → Checkbox-EjZjNgQc.js} +2 -2
  3. package/dist/assets/{MultiSelect-DP26KzMa.js → MultiSelect-pA_gFLBj.js} +1 -1
  4. package/dist/assets/{Progress-C3jVWDXK.js → Progress-P37eknhY.js} +1 -1
  5. package/dist/assets/{Table-c1ug6Rpw.js → Table-x3b8wkFT.js} +1 -1
  6. package/dist/assets/{Typography-BC-9NaKB.js → Typography-Dqx19Ych.js} +1 -1
  7. package/dist/assets/{YearPickerInput-CNSe9Fno.js → YearPickerInput-CF-aCG1y.js} +1 -1
  8. package/dist/assets/{accordion-CLvZdMsA.js → accordion-3XvqAlbw.js} +1 -1
  9. package/dist/assets/{accountant-approvals-BbNBYszL.js → accountant-approvals-CqMhre_9.js} +1 -1
  10. package/dist/assets/{accounter-table-C7UgjlTA.js → accounter-table-Bzhu1KyK.js} +1 -1
  11. package/dist/assets/{addDays-CB-j-d4t.js → addDays-DldjqWfe.js} +1 -1
  12. package/dist/assets/{all-charges-vuUUzmwW.js → all-charges-BtyyrpZO.js} +1 -1
  13. package/dist/assets/{arrow-up-down-DWlT-GED.js → arrow-up-down-B7_YFjTx.js} +2 -2
  14. package/dist/assets/{building-2-Dkd3B-3N.js → building-2-DRzzSI-s.js} +2 -2
  15. package/dist/assets/{business-BuVKb8Oy.js → business-BYRi1yRS.js} +11 -11
  16. package/dist/assets/{business-extended-info-B4Wt-Sq3.js → business-extended-info-kcznxGFW.js} +3 -3
  17. package/dist/assets/{business-header-BpYfBk40.js → business-header-LCjlTmGu.js} +1 -1
  18. package/dist/assets/{business-ledger-filters-ByAYFfgh.js → business-ledger-filters-DZnTpjrX.js} +1 -1
  19. package/dist/assets/{business-ledger-single-cLd56KYs.js → business-ledger-single-BRLmO8EZ.js} +1 -1
  20. package/dist/assets/{business-trip-BWUbbHEK.js → business-trip-mPiWeXFZ.js} +1 -1
  21. package/dist/assets/{charge-DyLqPZn0.js → charge-CYQZsbrJ.js} +1 -1
  22. package/dist/assets/{charges-filters-CUyYbpwk.js → charges-filters-DzWxzt2a.js} +1 -1
  23. package/dist/assets/{charges-ledger-validation-Br2BBUCN.js → charges-ledger-validation-COcmP_i2.js} +1 -1
  24. package/dist/assets/{charges-table-Cw-X1ZkK.js → charges-table-DAO5k4Bj.js} +13 -13
  25. package/dist/assets/{chart-TrN24kVd.js → chart-DLv5UJh2.js} +1 -1
  26. package/dist/assets/{contracts-CbwbCzFG.js → contracts-BsMfXlsk.js} +4 -4
  27. package/dist/assets/{data-table-pagination-BZmytrQe.js → data-table-pagination-GvSV7KMc.js} +3 -3
  28. package/dist/assets/{download-csv-button-r9hq7Mun.js → download-csv-button-gUEYkLnA.js} +1 -1
  29. package/dist/assets/{edit-issue-document-modal-aZgmep8e.js → edit-issue-document-modal-C7AJC7Gv.js} +1 -1
  30. package/dist/assets/{editable-business-trip-BCj8haJN.js → editable-business-trip-BP1JS8k9.js} +4 -4
  31. package/dist/assets/{eye-off-Cd4HW5Ki.js → eye-off-VrVhXbwE.js} +2 -2
  32. package/dist/assets/{funnel-DlU6IKDd.js → funnel-B5QD_sUF.js} +2 -2
  33. package/dist/assets/{index-BnDJ3EgW.js → index-3XKTkGeA.js} +1 -1
  34. package/dist/assets/{index-BwqfmUGW.js → index-8WXdaWuS.js} +1 -1
  35. package/dist/assets/{index-CLyrvG5S.js → index-B2X7nla9.js} +1 -1
  36. package/dist/assets/{index-Cuu0j4Ul.js → index-BKff0lem.js} +1 -1
  37. package/dist/assets/{index-C4ozKIHg.js → index-BV1vMuJT.js} +1 -1
  38. package/dist/assets/{index-DnkSW9Wf.js → index-Bdhc2Ro4.js} +1 -1
  39. package/dist/assets/{index-UOt3vExk.js → index-Bn7IEPHV.js} +95 -95
  40. package/dist/assets/{index-4Zj8Hp3W.js → index-Bv5uUjxc.js} +1 -1
  41. package/dist/assets/{index-as7vp0Ty.js → index-Bvb4j6AQ.js} +1 -1
  42. package/dist/assets/{index-jFDc_D4d.js → index-BwVwcbu8.js} +1 -1
  43. package/dist/assets/{index-CsxUWF65.js → index-C0swtdF8.js} +1 -1
  44. package/dist/assets/{index-Bo91VSNv.js → index-ClPpSN0B.js} +1 -1
  45. package/dist/assets/{index-DPLJ9sZn.js → index-CzB3y5x-.js} +1 -1
  46. package/dist/assets/{index-DmC4088R.js → index-D5Rv5AFZ.js} +1 -1
  47. package/dist/assets/{index-BGcp3XaM.js → index-D5dxKSVA.js} +1 -1
  48. package/dist/assets/{index-Dzi5mI80.js → index-DItleVvH.js} +2 -2
  49. package/dist/assets/{index-VYPC3lji.js → index-Dc9nbmlo.js} +1 -1
  50. package/dist/assets/{index-CS2mkstk.js → index-DlSfhUOv.js} +3 -3
  51. package/dist/assets/{index-BovGiTUZ.js → index-DwNkycV3.js} +1 -1
  52. package/dist/assets/{index-Dl3yi4zQ.js → index-DwY7eVGk.js} +1 -1
  53. package/dist/assets/{index-jpqj1MvA.js → index-DzYnXJV_.js} +7 -7
  54. package/dist/assets/{index-BM_DgFX-.js → index-J6zcs7kz.js} +1 -1
  55. package/dist/assets/index-VKofQ0dE.js +6 -0
  56. package/dist/assets/{index-DOzNNsNU.js → index-ajxNuIuk.js} +1 -1
  57. package/dist/assets/{index-Wu-q9oyp.js → index-gRDFqnGA.js} +1 -1
  58. package/dist/assets/{index.es-CuvVRlqN.js → index.es-NV1-ohev.js} +1 -1
  59. package/dist/assets/{insert-business-trip-modal-DyHAvuG6.js → insert-business-trip-modal-B8m5Xa9k.js} +2 -2
  60. package/dist/assets/issue-document-CMLk1fnW.js +1 -0
  61. package/dist/assets/{list-plus-CYtq--On.js → list-plus-CqwiCMO8.js} +2 -2
  62. package/dist/assets/{login-page-DcZw6k7i.js → login-page-CSC5qCbL.js} +1 -1
  63. package/dist/assets/match-document-modal-Buzom-Fk.js +16 -0
  64. package/dist/assets/{missing-info-charges-e6O9it1V.js → missing-info-charges-xOHiyLYM.js} +1 -1
  65. package/dist/assets/{modal-CqL_DX_G.js → modal-DkGVozcN.js} +1 -1
  66. package/dist/assets/{modify-contract-dialog-C8WuljxW.js → modify-contract-dialog-CYbNcgde.js} +1 -1
  67. package/dist/assets/{page-layout-DfZJtWW1.js → page-layout-QRk5gzBF.js} +1 -1
  68. package/dist/assets/{page-not-found-DnA0E-xR.js → page-not-found-BVPDMvr5.js} +1 -1
  69. package/dist/assets/{panel-top-open-D0lkFvhk.js → panel-top-open-C3IsjKjM.js} +3 -3
  70. package/dist/assets/{pencil-DhN5v-Lb.js → pencil-DT0jV6eN.js} +2 -2
  71. package/dist/assets/{report-commentary-row-DvvXelmb.js → report-commentary-row-CXGHMRJt.js} +1 -1
  72. package/dist/assets/{save-CCZ-i4rw.js → save--uHr1_DC.js} +2 -2
  73. package/dist/assets/{similar-transactions-modal-kFlTMg9C.js → similar-transactions-modal--mkXZQzE.js} +1 -1
  74. package/dist/assets/{sub-BKVGhLrr.js → sub-M6JLC8qJ.js} +1 -1
  75. package/dist/assets/subMonths-Ct7ldZ6v.js +1 -0
  76. package/dist/assets/{summary-BuSv6nwb.js → summary-Dm_FUd-t.js} +1 -1
  77. package/dist/assets/{toggle-expansion-button-CojtDNtC.js → toggle-expansion-button-BUAVmBSl.js} +1 -1
  78. package/dist/assets/tooltip-CCRs753Z.js +1 -0
  79. package/dist/assets/{use-url-query-90MrwS1C.js → use-url-query-CbV37ELv.js} +1 -1
  80. package/dist/index.html +1 -1
  81. package/package.json +2 -2
  82. package/dist/assets/index-Bt94reMP.js +0 -6
  83. package/dist/assets/issue-document-BvIvdS89.js +0 -1
  84. package/dist/assets/match-document-modal-Bs-5Zbj9.js +0 -16
  85. package/dist/assets/subMonths-Cbkj4M6-.js +0 -1
  86. package/dist/assets/tooltip-CoQF2skM.js +0 -1
@@ -1,37 +1,37 @@
1
- import{v as ae,w as es,u as te,S as vs,r as g,j as e,D as ss,x as as,E as ys,c as ts,g as ns,t as le,i as is,U as Ns,y as Oe,z as rs,G as ge,H as fe,J as U,K as G,N as ls,O as q,Q as W,V as Fe,W as K,X as y,Y as N,Z as b,_ as k,I as T,$ as C,a0 as B,a1 as pe,B as I,a2 as X,a3 as J,a4 as ce,a5 as _e,a6 as bs,a7 as Ne,a8 as Re,a9 as re,aa as z,ab as cs,ac as Cs,ad as Ve,ae as ws,P as As,af as Is,ag as O,ah as $e,ai as Ss,aj as ks,ak as Ds,al as Z,am as ee,an as Ts,ao as Bs,ap as Es,aq as De,ar as Ps,as as Ls,at as Os,au as Fs,av as _s,aw as Rs,ax as Vs,ay as Ms,az as se,aA as zs,aB as $s,aC as Te,aD as Ue,aE as os,aF as Us,aG as Be,aH as Gs,aI as qs,aJ as Ge,aK as Ws,aL as Ks,aM as Hs,aN as Ys,aO as Xs,aP as Js,aQ as Qs,aR as Zs,aS as ea,aT as v,aU as sa,aV as Me,aW as aa,aX as ta,aY as na,aZ as ia,a_ as ra,a$ as la,b0 as ca,b1 as oa,b2 as da,F as ma,b3 as ua,b4 as ha,b5 as Y,b6 as xa,b7 as pa,b8 as M,b9 as ja,a as ga,b as fa,ba as va}from"./index-UOt3vExk.js";import{S as ze}from"./save-CCZ-i4rw.js";import{B as ya}from"./business-extended-info-B4Wt-Sq3.js";import{B as Na}from"./business-header-BpYfBk40.js";import{S as ba,C as Ca,L as wa}from"./charges-table-Cw-X1ZkK.js";import{i as Aa,D as Ia,f as Sa,E as ka,L as we,a as ve,C as Da,A as Ta,b as he,c as Ba,d as Ee,h as Ea,e as Pa,g as ds,u as La,G as Oa,j as qe,k as Fa,X as ms,Y as us,l as _a,m as Ra,R as Va,n as Ma,o as za,p as $a}from"./chart-TrN24kVd.js";import{M as Ua,s as Ga,a as qa}from"./modify-contract-dialog-C8WuljxW.js";import{P as Wa}from"./pencil-DhN5v-Lb.js";import{E as Ka,T as Ha}from"./index-Dzi5mI80.js";import{A as Ya,a as Ae,b as Ie,c as We}from"./accordion-CLvZdMsA.js";import{B as Xa}from"./building-2-Dkd3B-3N.js";import"./download-csv-button-r9hq7Mun.js";import"./Table-c1ug6Rpw.js";import"./toggle-expansion-button-CojtDNtC.js";import"./panel-top-open-D0lkFvhk.js";import"./summary-BuSv6nwb.js";import"./list-plus-CYtq--On.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-kFlTMg9C.js";import"./addDays-CB-j-d4t.js";import"./tooltip-CoQF2skM.js";/**
2
- * @license lucide-react v0.548.0 - ISC
1
+ import{v as ae,w as es,u as te,S as vs,r as g,j as e,D as ss,x as as,E as ys,c as ts,g as ns,t as le,i as is,U as Ns,y as Oe,z as rs,G as ge,H as fe,J as U,K as G,N as ls,O as W,Q as q,V as Fe,W as K,X as y,Y as N,Z as b,_ as k,I as T,$ as C,a0 as B,a1 as pe,B as I,a2 as X,a3 as J,a4 as ce,a5 as _e,a6 as bs,a7 as Ne,a8 as Re,a9 as re,aa as z,ab as cs,ac as Cs,ad as Ve,ae as ws,P as As,af as Is,ag as O,ah as $e,ai as Ss,aj as ks,ak as Ds,al as Z,am as ee,an as Ts,ao as Bs,ap as Es,aq as De,ar as Ps,as as Ls,at as Os,au as Fs,av as _s,aw as Rs,ax as Vs,ay as Ms,az as se,aA as zs,aB as $s,aC as Te,aD as Ue,aE as os,aF as Us,aG as Be,aH as Gs,aI as Ws,aJ as Ge,aK as qs,aL as Ks,aM as Hs,aN as Ys,aO as Xs,aP as Js,aQ as Qs,aR as Zs,aS as ea,aT as v,aU as sa,aV as Me,aW as aa,aX as ta,aY as na,aZ as ia,a_ as ra,a$ as la,b0 as ca,b1 as oa,b2 as da,F as ma,b3 as ua,b4 as ha,b5 as Y,b6 as xa,b7 as pa,b8 as M,b9 as ja,a as ga,b as fa,ba as va}from"./index-Bn7IEPHV.js";import{S as ze}from"./save--uHr1_DC.js";import{B as ya}from"./business-extended-info-kcznxGFW.js";import{B as Na}from"./business-header-LCjlTmGu.js";import{S as ba,C as Ca,L as wa}from"./charges-table-DAO5k4Bj.js";import{i as Aa,D as Ia,f as Sa,E as ka,L as we,a as ve,C as Da,A as Ta,b as he,c as Ba,d as Ee,h as Ea,e as Pa,g as ds,u as La,G as Oa,j as We,k as Fa,X as ms,Y as us,l as _a,m as Ra,R as Va,n as Ma,o as za,p as $a}from"./chart-DLv5UJh2.js";import{M as Ua,s as Ga,a as Wa}from"./modify-contract-dialog-CYbNcgde.js";import{P as qa}from"./pencil-DT0jV6eN.js";import{E as Ka,T as Ha}from"./index-DItleVvH.js";import{A as Ya,a as Ae,b as Ie,c as qe}from"./accordion-3XvqAlbw.js";import{B as Xa}from"./building-2-DRzzSI-s.js";import"./download-csv-button-gUEYkLnA.js";import"./Table-x3b8wkFT.js";import"./toggle-expansion-button-BUAVmBSl.js";import"./panel-top-open-C3IsjKjM.js";import"./summary-Dm_FUd-t.js";import"./list-plus-CqwiCMO8.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal--mkXZQzE.js";import"./addDays-DldjqWfe.js";import"./tooltip-CCRs753Z.js";/**
2
+ * @license lucide-react v0.552.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
6
  */const Ja=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],Qa=ae("chart-line",Ja);/**
7
- * @license lucide-react v0.548.0 - ISC
7
+ * @license lucide-react v0.552.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
11
  */const Za=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Ke=ae("circle-check",Za);/**
12
- * @license lucide-react v0.548.0 - ISC
12
+ * @license lucide-react v0.552.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
16
  */const et=[["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"}]],ye=ae("dollar-sign",et);/**
17
- * @license lucide-react v0.548.0 - ISC
17
+ * @license lucide-react v0.552.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const st=[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m9 15 2 2 4-4",key:"1grp1n"}]],at=ae("file-check",st);/**
22
- * @license lucide-react v0.548.0 - ISC
21
+ */const st=[["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"}]],at=ae("file-check",st);/**
22
+ * @license lucide-react v0.552.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
26
  */const tt=[["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"}]],nt=ae("notebook",tt);/**
27
- * @license lucide-react v0.548.0 - ISC
27
+ * @license lucide-react v0.552.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
31
  */const it=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],rt=ae("plug",it);/**
32
- * @license lucide-react v0.548.0 - ISC
32
+ * @license lucide-react v0.552.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const lt=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Se=ae("trending-up",lt);function ct(s){return es(s,"yyyy-MM-dd")}function ot({businessId:s,tagIds:a,description:t,open:n,onOpenChange:c,onClose:o}){const[{data:l,fetching:i},r]=te({pause:!0,query:vs,variables:{businessId:s,tagsDifferentThan:a?a.map(m=>m.id):void 0,descriptionDifferentThan:t}});g.useEffect(()=>{n&&(a||t)&&!l&&r()},[n,a,t,r,l]);const d=g.useCallback(m=>{c(m),n&&!m&&o?.()},[c,o,n]),h=g.useMemo(()=>n&&(!!a||!!t)&&l&&l?.similarChargesByBusiness.length>0,[n,a,t,l]);return e.jsx(ss,{open:h,onOpenChange:d,children:e.jsx(as,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:m=>m.stopPropagation(),children:e.jsx(ys,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:i?e.jsx(ts,{}):a||t?e.jsx(ba,{data:l?.similarChargesByBusiness??[],tagIds:a,description:t,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const dt="updateAdminBusiness",mt=()=>{const[{fetching:s},a]=ns(Ns),t=g.useCallback(async n=>{const c=`Error updating admin business ID [${n.adminBusinessId}]`,o=`${dt}-${n.adminBusinessId}`;le.loading("Updating admin business",{id:o});try{const l=await a(n),i=is(l,c,o,"updateAdminBusiness");if(i)return le.success("Success",{id:o,description:"Admin Business Updated"}),i.updateAdminBusiness}catch(l){console.error(`${c}: ${l}`),le.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[a]);return{fetching:s,updateAdminBusiness:t}},ke=Ne({year:cs().min(2e3).max(2100),id:z().min(1,{message:"ID is required"})}),ut=Ne({registrationDate:z().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:re(ke),withholdingTaxCompanyId:z().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:re(ke),socialSecurityDeductionsId:z().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:re(ke),taxAdvancesRates:re(Ne({date:Cs(),rate:cs().min(0,{message:"Rate must be at least 0"}).max(100,{message:"Rate must be at most 100"})}))});function He(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{registrationDate:s.adminInfo.registrationDate,withholdingTaxAnnualIds:s.adminInfo.withholdingTaxAnnualIds.sort((a,t)=>t.year-a.year),withholdingTaxCompanyId:s.adminInfo.withholdingTaxCompanyId??void 0,socialSecurityEmployerIds:s.adminInfo.socialSecurityEmployerIds.sort((a,t)=>t.year-a.year),socialSecurityDeductionsId:s.adminInfo.socialSecurityDeductionsId??void 0,taxAdvancesAnnualIds:s.adminInfo.taxAdvancesAnnualIds.sort((a,t)=>t.year-a.year),taxAdvancesRates:s.adminInfo.taxAdvancesRates?.map(a=>({date:a.date,rate:a.rate*100}))}}function ht(s){return{registrationDate:s.registrationDate?ct(new Date(s.registrationDate)):void 0,withholdingTaxAnnualIds:s.withholdingTaxAnnualIds,withholdingTaxCompanyId:s.withholdingTaxCompanyId,socialSecurityEmployerIds:s.socialSecurityEmployerIds,taxAdvancesRates:s.taxAdvancesRates?.map(a=>({date:a.date,rate:a.rate/100})),taxAdvancesAnnualIds:s.taxAdvancesAnnualIds}}function xt({data:s,refetchBusiness:a}){const t=ge(bs,s),[n,c]=g.useState(He(t)),{updateAdminBusiness:o,fetching:l}=mt(),i=Oe({resolver:rs(ut),defaultValues:n}),r=async u=>{if(!t)return;const p=Re(u,i.formState.dirtyFields);if(!p)return;const S=ht(p);await o({adminBusinessId:t.id,fields:S}),a?.()};g.useEffect(()=>{if(t){const u=He(t);c(u),i.reset(u)}},[t,i]);const{fields:d,append:h,remove:m}=fe({control:i.control,name:"taxAdvancesAnnualIds"}),{fields:x,append:w,remove:f}=fe({control:i.control,name:"withholdingTaxAnnualIds"}),{fields:A,append:D,remove:E}=fe({control:i.control,name:"socialSecurityEmployerIds"}),P={withholdingTaxAnnualIds:{append:w,remove:f},taxAdvancesAnnualIds:{append:h,remove:m},socialSecurityEmployerIds:{append:D,remove:E}},F=u=>{P[u].append({year:new Date().getFullYear(),id:""})},_=(u,p)=>{P[u].remove(p)},{fields:L,append:H,remove:V}=fe({control:i.control,name:"taxAdvancesRates"}),Q=()=>{H({date:es(new Date,"yyyy-MM-dd"),rate:0})},j=u=>{V(u)};return e.jsxs(U,{children:[e.jsxs(G,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ls,{className:"h-5 w-5 text-primary"}),e.jsx(q,{children:"Admin Business Configuration"})]}),e.jsx(W,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Fe,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(r),className:"space-y-6",children:[e.jsx(K,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Withholding Tax"}),e.jsx(y,{control:i.control,name:"withholdingTaxCompanyId",render:({field:u,fieldState:p})=>e.jsxs(N,{children:[e.jsx(b,{children:"Company Tax ID"}),e.jsx(k,{children:e.jsx(T,{placeholder:"Enter company ID",...u,className:C(p)})}),e.jsx(B,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Annual IDs"}),e.jsx(I,{type:"button",variant:"outline",size:"sm",onClick:()=>F("withholdingTaxAnnualIds"),children:e.jsx(X,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:x.map((u,p)=>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(T,{placeholder:"Year",type:"number",...i.register(`withholdingTaxAnnualIds.${p}.year`,{valueAsNumber:!0})}),e.jsx(T,{placeholder:"ID",...i.register(`withholdingTaxAnnualIds.${p}.id`)})]}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>_("withholdingTaxAnnualIds",p),children:e.jsx(J,{className:"size-4"})})]},u.id))})]}),e.jsx(ce,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Tax Advances"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Annual IDs"}),e.jsx(I,{type:"button",variant:"outline",size:"sm",onClick:()=>F("taxAdvancesAnnualIds"),children:e.jsx(X,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:d.map((u,p)=>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(T,{placeholder:"Year",type:"number",...i.register(`taxAdvancesAnnualIds.${p}.year`,{valueAsNumber:!0})}),e.jsx(T,{placeholder:"ID",...i.register(`taxAdvancesAnnualIds.${p}.id`)})]}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>_("taxAdvancesAnnualIds",p),children:e.jsx(J,{className:"size-4"})})]},u.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Rates (%)"}),e.jsx(I,{type:"button",variant:"outline",size:"sm",onClick:Q,children:e.jsx(X,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:L.map((u,p)=>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(T,{placeholder:"Date",type:"date",...i.register(`taxAdvancesRates.${p}.date`)}),e.jsx(T,{placeholder:"Rate",...i.register(`taxAdvancesRates.${p}.rate`,{valueAsNumber:!0})})]}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>j(p),children:e.jsx(J,{className:"size-4"})})]},u.id))})]}),e.jsx(ce,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Social Security"}),e.jsx(y,{control:i.control,name:"socialSecurityDeductionsId",render:({field:u,fieldState:p})=>e.jsxs(N,{children:[e.jsx(b,{children:"Deductions ID"}),e.jsx(k,{children:e.jsx(T,{placeholder:"Enter deductions ID",...u,className:C(p)})}),e.jsx(B,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Annual Employer IDs"}),e.jsx(I,{type:"button",variant:"outline",size:"sm",onClick:()=>F("socialSecurityEmployerIds"),children:e.jsx(X,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:A.map((u,p)=>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(T,{placeholder:"Year",type:"number",...i.register(`socialSecurityEmployerIds.${p}.year`,{valueAsNumber:!0})}),e.jsx(T,{placeholder:"ID",...i.register(`socialSecurityEmployerIds.${p}.id`)})]}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>_("socialSecurityEmployerIds",p),children:e.jsx(J,{className:"size-4"})})]},u.id))})]}),e.jsx(ce,{className:"md:col-span-2"}),e.jsx(y,{control:i.control,name:"registrationDate",render:({field:u,fieldState:p})=>e.jsxs(N,{children:[e.jsx(b,{children:"Business Registration Start Date"}),e.jsx(k,{children:e.jsx(T,{type:"date",...u,className:C(p)})}),e.jsx(B,{})]})})]})}),e.jsx(_e,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(I,{type:"submit",disabled:l||Object.keys(i.formState.dirtyFields).length===0||!i.formState.isValid,children:[e.jsx(ze,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function pt({businessId:s}){return e.jsxs(U,{children:[e.jsx(G,{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(q,{children:"Balance"}),e.jsx(W,{children:"Business balance overview"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(ya,{businessID:s,filter:{}})})})]})}function jt({businessId:s}){const{userContext:a}=g.useContext(Ve),[t,n]=g.useState(0),[{data:c,fetching:o}]=te({query:ws,variables:{filters:{byOwners:a?.context.adminBusinessId?[a.context.adminBusinessId]:void 0,sortBy:{field:Is.Date,asc:!1},byBusinesses:[s]},page:t-1,limit:10}}),l=c?.allCharges?.pageInfo.totalPages??1,i=c?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(U,{children:[e.jsxs(G,{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(q,{children:"Charges"}),e.jsx(W,{children:"Recurring and one-time charges for this business"})]})}),l>1&&e.jsx(As,{className:"flex-fit w-fit mx-0",value:t,onChange:n,total:l})]}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Ca,{data:i,isAllOpened:!1})})})]})}var gt=["type","layout","connectNulls","ref"],ft=["key"];function oe(s){"@babel/helpers - typeof";return oe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},oe(s)}function Ye(s,a){if(s==null)return{};var t=vt(s,a),n,c;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(c=0;c<o.length;c++)n=o[c],!(a.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function vt(s,a){if(s==null)return{};var t={};for(var n in s)if(Object.prototype.hasOwnProperty.call(s,n)){if(a.indexOf(n)>=0)continue;t[n]=s[n]}return t}function je(){return je=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},je.apply(this,arguments)}function Xe(s,a){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);a&&(n=n.filter(function(c){return Object.getOwnPropertyDescriptor(s,c).enumerable})),t.push.apply(t,n)}return t}function R(s){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?Xe(Object(t),!0).forEach(function(n){$(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Xe(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function ie(s){return Ct(s)||bt(s)||Nt(s)||yt()}function yt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
37
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nt(s,a){if(s){if(typeof s=="string")return Pe(s,a);var t=Object.prototype.toString.call(s).slice(8,-1);if(t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set")return Array.from(s);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Pe(s,a)}}function bt(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function Ct(s){if(Array.isArray(s))return Pe(s)}function Pe(s,a){(a==null||a>s.length)&&(a=s.length);for(var t=0,n=new Array(a);t<a;t++)n[t]=s[t];return n}function wt(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Je(s,a){for(var t=0;t<a.length;t++){var n=a[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(s,xs(n.key),n)}}function At(s,a,t){return a&&Je(s.prototype,a),t&&Je(s,t),Object.defineProperty(s,"prototype",{writable:!1}),s}function It(s,a,t){return a=be(a),St(s,hs()?Reflect.construct(a,t||[],be(s).constructor):a.apply(s,t))}function St(s,a){if(a&&(oe(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kt(s)}function kt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function hs(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(hs=function(){return!!s})()}function be(s){return be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},be(s)}function Dt(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Le(s,a)}function Le(s,a){return Le=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,c){return n.__proto__=c,n},Le(s,a)}function $(s,a,t){return a=xs(a),a in s?Object.defineProperty(s,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[a]=t,s}function xs(s){var a=Tt(s,"string");return oe(a)=="symbol"?a:a+""}function Tt(s,a){if(oe(s)!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,a);if(oe(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var de=(function(s){function a(){var t;wt(this,a);for(var n=arguments.length,c=new Array(n),o=0;o<n;o++)c[o]=arguments[o];return t=It(this,a,[].concat(c)),$(t,"state",{isAnimationFinished:!0,totalLength:0}),$(t,"generateSimpleStrokeDasharray",function(l,i){return"".concat(i,"px ").concat(l-i,"px")}),$(t,"getStrokeDasharray",function(l,i,r){var d=r.reduce(function(E,P){return E+P});if(!d)return t.generateSimpleStrokeDasharray(i,l);for(var h=Math.floor(l/d),m=l%d,x=i-l,w=[],f=0,A=0;f<r.length;A+=r[f],++f)if(A+r[f]>m){w=[].concat(ie(r.slice(0,f)),[m-A]);break}var D=w.length%2===0?[0,x]:[x];return[].concat(ie(a.repeat(r,h)),ie(w),D).map(function(E){return"".concat(E,"px")}).join(", ")}),$(t,"id",La("recharts-line-")),$(t,"pathRef",function(l){t.mainCurve=l}),$(t,"handleAnimationEnd",function(){t.setState({isAnimationFinished:!0}),t.props.onAnimationEnd&&t.props.onAnimationEnd()}),$(t,"handleAnimationStart",function(){t.setState({isAnimationFinished:!1}),t.props.onAnimationStart&&t.props.onAnimationStart()}),t}return Dt(a,s),At(a,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,c){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,l=o.points,i=o.xAxis,r=o.yAxis,d=o.layout,h=o.children,m=Sa(h,ka);if(!m)return null;var x=function(A,D){return{x:A.x,y:A.y,value:A.value,errorVal:ds(A.payload,D)}},w={clipPath:n?"url(#clipPath-".concat(c,")"):null};return O.createElement(we,w,m.map(function(f){return O.cloneElement(f,{key:"bar-".concat(f.props.dataKey),data:l,xAxis:i,yAxis:r,layout:d,dataPointFormatter:x})}))}},{key:"renderDots",value:function(n,c,o){var l=this.props.isAnimationActive;if(l&&!this.state.isAnimationFinished)return null;var i=this.props,r=i.dot,d=i.points,h=i.dataKey,m=ve(this.props,!1),x=ve(r,!0),w=d.map(function(A,D){var E=R(R(R({key:"dot-".concat(D),r:3},m),x),{},{index:D,cx:A.x,cy:A.y,value:A.value,dataKey:h,payload:A.payload,points:d});return a.renderDotItem(r,E)}),f={clipPath:n?"url(#clipPath-".concat(c?"":"dots-").concat(o,")"):null};return O.createElement(we,je({className:"recharts-line-dots",key:"dots"},f),w)}},{key:"renderCurveStatically",value:function(n,c,o,l){var i=this.props,r=i.type,d=i.layout,h=i.connectNulls;i.ref;var m=Ye(i,gt),x=R(R(R({},ve(m,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:r,layout:d,connectNulls:h});return O.createElement(Da,je({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,c){var o=this,l=this.props,i=l.points,r=l.strokeDasharray,d=l.isAnimationActive,h=l.animationBegin,m=l.animationDuration,x=l.animationEasing,w=l.animationId,f=l.animateNewValues,A=l.width,D=l.height,E=this.state,P=E.prevPoints,F=E.totalLength;return O.createElement(Ta,{begin:h,duration:m,isActive:d,easing:x,from:{t:0},to:{t:1},key:"line-".concat(w),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(_){var L=_.t;if(P){var H=P.length/i.length,V=i.map(function(S,Ce){var me=Math.floor(Ce*H);if(P[me]){var ue=P[me],ne=he(ue.x,S.x),js=he(ue.y,S.y);return R(R({},S),{},{x:ne(L),y:js(L)})}if(f){var gs=he(A*2,S.x),fs=he(D/2,S.y);return R(R({},S),{},{x:gs(L),y:fs(L)})}return R(R({},S),{},{x:S.x,y:S.y})});return o.renderCurveStatically(V,n,c)}var Q=he(0,F),j=Q(L),u;if(r){var p="".concat(r).split(/[,\s]+/gim).map(function(S){return parseFloat(S)});u=o.getStrokeDasharray(j,F,p)}else u=o.generateSimpleStrokeDasharray(F,j);return o.renderCurveStatically(i,n,c,{strokeDasharray:u})})}},{key:"renderCurve",value:function(n,c){var o=this.props,l=o.points,i=o.isAnimationActive,r=this.state,d=r.prevPoints,h=r.totalLength;return i&&l&&l.length&&(!d&&h>0||!Ba(d,l))?this.renderCurveWithAnimation(n,c):this.renderCurveStatically(l,n,c)}},{key:"render",value:function(){var n,c=this.props,o=c.hide,l=c.dot,i=c.points,r=c.className,d=c.xAxis,h=c.yAxis,m=c.top,x=c.left,w=c.width,f=c.height,A=c.isAnimationActive,D=c.id;if(o||!i||!i.length)return null;var E=this.state.isAnimationFinished,P=i.length===1,F=$e("recharts-line",r),_=d&&d.allowDataOverflow,L=h&&h.allowDataOverflow,H=_||L,V=Ee(D)?this.id:D,Q=(n=ve(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},j=Q.r,u=j===void 0?3:j,p=Q.strokeWidth,S=p===void 0?2:p,Ce=Ea(l)?l:{},me=Ce.clipDot,ue=me===void 0?!0:me,ne=u*2+S;return O.createElement(we,{className:F},_||L?O.createElement("defs",null,O.createElement("clipPath",{id:"clipPath-".concat(V)},O.createElement("rect",{x:_?x:x-w/2,y:L?m:m-f/2,width:_?w:w*2,height:L?f:f*2})),!ue&&O.createElement("clipPath",{id:"clipPath-dots-".concat(V)},O.createElement("rect",{x:x-ne/2,y:m-ne/2,width:w+ne,height:f+ne}))):null,!P&&this.renderCurve(H,V),this.renderErrorBar(H,V),(P||l)&&this.renderDots(H,ue,V),(!A||E)&&Pa.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,c){return n.animationId!==c.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:c.curPoints}:n.points!==c.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,c){for(var o=n.length%2!==0?[].concat(ie(n),[0]):n,l=[],i=0;i<c;++i)l=[].concat(ie(l),ie(o));return l}},{key:"renderDotItem",value:function(n,c){var o;if(O.isValidElement(n))o=O.cloneElement(n,c);else if(Aa(n))o=n(c);else{var l=c.key,i=Ye(c,ft),r=$e("recharts-line-dot",typeof n!="boolean"?n.className:"");o=O.createElement(Ia,je({key:l},i,{className:r}))}return o}}])})(g.PureComponent);$(de,"displayName","Line");$(de,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Oa.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});$(de,"getComposedData",function(s){var a=s.props,t=s.xAxis,n=s.yAxis,c=s.xAxisTicks,o=s.yAxisTicks,l=s.dataKey,i=s.bandSize,r=s.displayedData,d=s.offset,h=a.layout,m=r.map(function(x,w){var f=ds(x,l);return h==="horizontal"?{x:qe({axis:t,ticks:c,bandSize:i,entry:x,index:w}),y:Ee(f)?null:n.scale(f),value:f,payload:x}:{x:Ee(f)?null:t.scale(f),y:qe({axis:n,ticks:o,bandSize:i,entry:x,index:w}),value:f,payload:x}});return R({points:m,layout:h},d)});var Bt=Fa({chartName:"LineChart",GraphicalChild:de,axisComponents:[{axisType:"xAxis",AxisComp:ms},{axisType:"yAxis",AxisComp:us}],formatAxisMap:_a});const xe=[{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 Et(){const s=xe.reduce((t,n)=>t+n.revenue,0),a=s/xe.length;return e.jsxs(U,{children:[e.jsxs(G,{children:[e.jsx(q,{children:"Revenue Analytics"}),e.jsx(W,{children:"Revenue and expenses over time"})]}),e.jsxs(K,{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(ye,{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(Se,{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(ye,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",a.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Se,{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(ye,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",xe[xe.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Se,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Ra,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Va,{width:"100%",height:"100%",children:e.jsxs(Bt,{data:xe,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Ma,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(ms,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(us,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(za,{content:e.jsx($a,{})}),e.jsx(de,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(de,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Pt="updateBusiness",ps=()=>{const[{fetching:s},a]=ns(Ss),t=g.useCallback(async n=>{const c=`Error updating business ID [${n.businessId}]`,o=`${Pt}-${n.businessId}`;le.loading("Updating business",{id:o});try{const l=await a(n),i=is(l,c,o,"updateBusiness");if(i)return le.success("Success",{id:o,description:"Business updated"}),i.updateBusiness}catch(l){console.error(`${c}: ${l}`),le.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[a]);return{fetching:s,updateBusiness:t}},Lt=Object.values(zs);function Qe(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(a=>a.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 Ot(s){const t=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||t?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:t}: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 Ft({data:s,refetchBusiness:a}){const t=ge(Ds,s),[n,c]=g.useState(Qe(t)),{userContext:o}=g.useContext(Ve),{updateBusiness:l,fetching:i}=ps(),[r,d]=g.useState(!1),[h,m]=g.useState(void 0),x=Oe({defaultValues:n}),w=async A=>{if(!t||!o?.context.adminBusinessId)return;const D=Re(A,x.formState.dirtyFields);if(!D)return;const E=Ot(D);await l({businessId:t.id,ownerId:o.context.adminBusinessId,fields:E}),D.tags?.length||D.description?(m({tagIds:D.tags?.map(P=>({id:P})),description:D.description}),d(!0)):a?.()};if(g.useEffect(()=>{if(t){const A=Qe(t);c(A),x.reset(A)}},[t,x]),!t)return e.jsx("div",{});const f=x.watch("isClient");return e.jsxs(U,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(q,{children:"Configurations"}),e.jsx(W,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!f&&e.jsx(ks,{businessId:t.id,onDone:a})]})}),e.jsx(Fe,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(w),children:[e.jsxs(K,{className:"space-y-6",children:[e.jsx(_t,{form:x}),e.jsx(ce,{}),e.jsx(Rt,{form:x}),e.jsx(ce,{}),e.jsx(Vt,{form:x}),e.jsx(ce,{}),e.jsx(Mt,{form:x})]}),e.jsx(_e,{className:"flex justify-end border-t pt-6",children:e.jsxs(I,{type:"submit",disabled:i||Object.keys(x.formState.dirtyFields).length===0,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(ot,{businessId:t.id,tagIds:h?.tagIds,description:h?.description,open:r,onOpenChange:d,onClose:a})]})}function _t({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(y,{control:s.control,name:"isClient",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Client"}),e.jsx(Z,{children:"Mark this business as a client"})]}),e.jsx(k,{children:e.jsx(ee,{disabled:!0,checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isActive",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Active"}),e.jsx(Z,{children:"Business is currently active"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isReceiptEnough",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Receipt Enough"}),e.jsx(Z,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isDocumentsOptional",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"No Docs Required"}),e.jsx(Z,{children:"Skip document validation for common charges"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isVatOptional",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is VAT Optional"}),e.jsx(Z,{children:"Mute missing VAT indicator"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isExemptDealer",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Exempt Dealer"}),e.jsx(Z,{children:"Business is exempt from VAT requirements"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})})]})]})}function Rt({form:s}){const{selectableTaxCategories:a,fetching:t}=Ts(),{selectableSortCodes:n,fetching:c,sortCodes:o}=Bs(),{selectableTags:l,fetching:i}=Es(),r=g.useCallback(d=>{if(d){const h=o.find(m=>Number(m.key)===Number(d));h&&(h.defaultIrsCode?s.setValue("irsCode",h.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(y,{control:s.control,name:"sortCode",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Sort Code"}),e.jsx(k,{children:e.jsx(De,{onChange:m=>{r(m),d.onChange(m)},data:n,value:d.value,disabled:c,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(h)}})}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"taxCategory",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Tax Category"}),e.jsx(k,{children:e.jsx(De,{data:a,disabled:t,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(h)}})}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"PCN874 Record Type"}),e.jsxs(Ps,{onValueChange:d.onChange,value:d.value,children:[e.jsx(k,{children:e.jsx(Ls,{className:C(h),children:e.jsx(Os,{})})}),e.jsx(Fs,{children:Object.entries(_s).map(([m,x])=>e.jsx(Rs,{value:m,children:`${x} (${m})`},m))})]}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"irsCode",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"IRS Code"}),e.jsx(k,{children:e.jsx(Vs,{value:d.value??void 0,onValueChange:m=>d.onChange(m??null),hideControls:!0,decimalScale:0,className:C(h)})}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"description",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Charge Description"}),e.jsx(k,{children:e.jsx(T,{placeholder:"Enter default charge description",...d,className:C(h)})}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"tags",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Tags"}),e.jsx(k,{children:e.jsx(Ms,{options:Object.values(l).map(({value:m,label:x})=>({label:x,value:m})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:i,className:C(h)})}),e.jsx(B,{})]})})]})]})}function Vt({form:s}){const[a,t]=g.useState(""),[n,c]=g.useState(""),o=()=>{if(a.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,a.trim()],{shouldDirty:!0}),t("")}},l=()=>{if(n.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,n.trim()],{shouldDirty:!0}),c("")}},i=d=>{const h=s.getValues("phrases");s.setValue("phrases",h.filter((m,x)=>x!==d),{shouldDirty:!0})},r=d=>{const h=s.getValues("emails");s.setValue("emails",h.filter((m,x)=>x!==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(y,{control:s.control,name:"phrases",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add phrase...",value:a,onChange:m=>t(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),o())},className:C(h)}),e.jsx(I,{type:"button",size:"sm",onClick:o,children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((m,x)=>e.jsxs(se,{variant:"secondary",className:"gap-1",children:[m,e.jsx(I,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>i(x),children:e.jsx(J,{className:"size-3 cursor-pointer",onClick:()=>i(x)})})]},x))}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"emails",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"email",placeholder:"Add email...",value:n,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),l())},className:C(h)}),e.jsx(I,{type:"button",size:"sm",onClick:l,children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((m,x)=>e.jsxs(se,{variant:"secondary",className:"gap-1",children:[m,e.jsx(I,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>r(x),children:e.jsx(J,{className:"size-3 cursor-pointer"})})]},x))}),e.jsx(B,{})]})})]})}function Mt({form:s}){const[a,t]=g.useState(""),n=()=>{if(a.trim()){const l=s.getValues("internalLinks");s.setValue("internalLinks",[...l,a.trim()],{shouldDirty:!0}),t("")}},c=l=>{const i=s.getValues("attachmentTypes");s.setValue("attachmentTypes",i?.includes(l)?i.filter(r=>r!==l):[...i,l],{shouldDirty:!0})},o=l=>{const i=s.getValues("internalLinks");s.setValue("internalLinks",i.filter((r,d)=>d!==l),{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(y,{control:s.control,name:"attachmentTypes",render:({field:l,fieldState:i})=>e.jsxs(N,{children:[e.jsx(b,{children:"Attachment Types"}),e.jsx("div",{className:C(i)+" rounded-md flex flex-wrap gap-2",children:Lt.map(r=>e.jsx(se,{variant:l.value?.includes(r)?"default":"outline",className:"cursor-pointer",onClick:()=>c(r),children:r},r))}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"internalLinks",render:({field:l,fieldState:i})=>e.jsxs(N,{children:[e.jsx(b,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"url",placeholder:"Add internal link...",value:a,onChange:r=>t(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),n())}}),e.jsx(I,{type:"button",size:"sm",onClick:n,children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx("div",{className:C(i)+" flex flex-wrap gap-2 rounded-md",children:l.value?.map((r,d)=>e.jsxs(se,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[r,e.jsx(I,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(J,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"useMessageBody",render:({field:l,fieldState:i})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Should Use Message Body"}),e.jsx(Z,{children:"Extract information from email message body"})]}),e.jsx(k,{children:e.jsx(ee,{checked:l.value,onCheckedChange:l.onChange,className:C(i)})})]})})]})}const zt=Ne({businessName:z().min(1,"Business name is required"),locality:z().min(1,"Locality is required"),localName:z().optional(),govId:z().optional(),address:z().optional(),localAddress:z().optional(),phone:z().optional(),website:qs("Invalid URL").optional().or(Ws("")),generalContacts:re(Ge()).optional(),billingEmails:re(Ge()).optional()});function Ze(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(a=>a.trim()),billingEmails:s.clientInfo?.emails}}function $t(s){return{name:s.businessName,country:s.locality,hebrewName:s.localName,governmentId:s.govId,address:s.address,phoneNumber:s.phone,website:s.website,email:s.generalContacts?.join(", ")}}function Ut({data:s,refetchBusiness:a}){const t=ge(Gs,s),[n,c]=g.useState(Ze(t)),{userContext:o}=g.useContext(Ve),{updateBusiness:l,fetching:i}=ps(),r=Oe({resolver:rs(zt),defaultValues:n}),{countries:d,fetching:h}=$s(),[m,x]=g.useState(""),[w,f]=g.useState(""),A=r.watch("locality"),D=r.watch("address"),E=r.watch("localAddress");g.useEffect(()=>{D!==n.address&&r.setValue("address",D,{shouldDirty:!0})},[D,n.address,r]),g.useEffect(()=>{E!==n.localAddress&&r.setValue("localAddress",E,{shouldDirty:!0})},[E,n.localAddress,r]);const P=t&&"clientInfo"in t&&!!t.clientInfo,F=A===o?.context.locality,_=j=>{m.trim()&&(r.setValue("generalContacts",[...j,m.trim()],{shouldDirty:!0}),x(""))},L=(j,u)=>{r.setValue("generalContacts",j.filter((p,S)=>S!==u),{shouldDirty:!0})},H=j=>{w.trim()&&(r.setValue("billingEmails",[...j,w.trim()],{shouldDirty:!0}),f(""))},V=(j,u)=>{r.setValue("billingEmails",j.filter((p,S)=>S!==u),{shouldDirty:!0})},Q=async j=>{if(!t||!o?.context.adminBusinessId)return;const u=Re(j,r.formState.dirtyFields);if(!u)return;const p=$t(u);await l({businessId:t.id,ownerId:o.context.adminBusinessId,fields:p}),a?.()};return g.useEffect(()=>{if(t){const j=Ze(t);c(j),r.reset(j)}},[t,r]),e.jsxs(U,{children:[e.jsxs(G,{children:[e.jsx(q,{children:"Contact Information"}),e.jsx(W,{children:"Business contact details and address information"})]}),e.jsx(Fe,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(Q),children:[e.jsx(K,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(y,{control:r.control,name:"businessName",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Business Name"}),e.jsx(k,{children:e.jsx(T,{...j,className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"locality",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Locality / Country"}),e.jsx(De,{onChange:j.onChange,data:d.map(p=>({value:p.code,label:p.name})),value:j.value,disabled:h,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(u)}}),e.jsx(B,{})]})}),F&&e.jsx(y,{control:r.control,name:"localName",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Local Name"}),e.jsx(k,{children:e.jsx(T,{...j,placeholder:"Business name in local language",className:C(u)})}),e.jsx(B,{})]})}),F&&e.jsx(y,{control:r.control,name:"govId",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Government ID"}),e.jsx(k,{children:e.jsx(T,{...j,placeholder:"Enter Government ID",className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"address",render:({field:j,fieldState:u})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),"Address"]}),e.jsx(k,{children:e.jsx(Ue,{...j,rows:3,placeholder:"Enter business address",className:C(u)})}),e.jsx(B,{})]})}),F&&e.jsx(y,{control:r.control,name:"localAddress",render:({field:j,fieldState:u})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(k,{children:e.jsx(Ue,{...j,rows:3,placeholder:"Enter address in local language",className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"phone",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(os,{className:"h-4 w-4"}),"Phone"]}),e.jsx(k,{children:e.jsx(T,{...j,type:"tel",placeholder:"+1 (555) 123-4567",className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"website",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Us,{className:"h-4 w-4"}),"Website"]}),e.jsx(k,{children:e.jsx(T,{...j,type:"url",placeholder:"https://example.com",className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"generalContacts",render:({field:j,fieldState:u})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:C(u)+" flex flex-wrap gap-2 mb-2 rounded-md",children:j.value?.map((p,S)=>e.jsxs(se,{variant:"secondary",className:"gap-1 pr-1",children:[p,e.jsx("button",{type:"button",onClick:()=>L(j.value??[],S),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(J,{className:"h-3 w-3"})})]},S))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:m,onChange:p=>x(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),_(j.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(I,{type:"button",variant:"outline",size:"icon",disabled:!m.trim(),onClick:()=>_(j.value??[]),children:e.jsx(X,{className:"h-4 w-4"})})]})]})}),e.jsx(B,{})]})}),P&&e.jsx(y,{control:r.control,name:"billingEmails",render:({field:j,fieldState:u})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:C(u)+" flex flex-wrap gap-2 mb-2 rounded-md",children:j.value?.map((p,S)=>e.jsxs(se,{variant:"secondary",className:"gap-1 pr-1",children:[p,e.jsx("button",{type:"button",onClick:()=>V(j.value??[],S),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(J,{className:"h-3 w-3"})})]},S))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:w,onChange:p=>f(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),H(j.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(I,{type:"button",variant:"outline",size:"icon",disabled:!w.trim(),onClick:()=>H(j.value??[]),children:e.jsx(X,{className:"h-4 w-4"})})]})]})}),e.jsx(B,{})]})})]})}),e.jsx(_e,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(I,{type:"submit",disabled:i||Object.keys(r.formState.dirtyFields).length===0,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}function Gt(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 qt({clientId:s}){const[a,t]=g.useState(null),[{data:n,fetching:c},o]=te({query:Ks,variables:{clientId:s}}),l=n?.contractsByClient??[];return c?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(U,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(q,{children:"Contracts"}),e.jsx(W,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Ua,{clientId:s,contract:a,onDone:o})]})}),e.jsx(K,{className:"space-y-4",children:l.map(i=>{const r=!!i.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:i.product}),e.jsx(se,{variant:r?"default":"secondary",children:i.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:i.id})]}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>t(Gt(i)),children:e.jsx(Wa,{className:"h-4 w-4"})})]}),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(Hs,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(i.startDate).toLocaleDateString()," →"," ",new Date(i.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:i.purchaseOrders.toReversed()[0]??""}),i.purchaseOrders.length>1&&e.jsx("div",{className:"space-x-1",children:i.purchaseOrders.toReversed().slice(1).map(d=>e.jsx("span",{className:"text-xs font-thin font-mono",children:d},d))})]}),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:Ys(i.amount.raw,i.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:Ga(i.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:i.plan?qa(i.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:i.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:Xs(i.documentType)})]})]}),i.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:i.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.msCloud&&e.jsx(I,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Js,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(Ka,{className:"h-3 w-3 ml-1"})]})})})]},i.id)})})]})}function Wt({businessId:s}){return e.jsxs(U,{children:[e.jsx(G,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(q,{children:"Documents"}),e.jsx(W,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(K,{children:e.jsx(Qs,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const Kt=[{id:"hive",name:"Hive",description:"Schema registry, analytics, metrics and gateway for GraphQL federation and other GraphQL APIs",status:"disconnected",lastSync:"Never"},{id:"slack",name:"Slack",description:"Team communication and notifications",status:"disconnected",lastSync:"Never"},{id:"retool",name:"Retool",description:"Internal tools and dashboards",status:"disconnected",lastSync:"Never"},{id:"linear",name:"Linear",description:"Issue tracking and project management",status:"disconnected",lastSync:"Never"},{id:"workflowy",name:"Workflowy",description:"Task management and note taking",status:"disconnected",lastSync:"Never"}];function Ht({data:s}){const a=ge(aa,s),[{data:t,fetching:n},c]=te({query:Zs,variables:{clientId:a?.id??""},pause:!a?.clientInfo?.greenInvoiceId||!a?.id}),{updateClient:o}=ea(),l=g.useCallback((r,d)=>{if(!a?.id)return;const h={};h[d]=r,o({businessId:a?.id,fields:h})},[a?.id,o]);g.useEffect(()=>{a?.clientInfo?.greenInvoiceId&&a?.id&&c()},[a?.clientInfo?.greenInvoiceId,a?.id,c]);const i=t?.greenInvoiceClient;return e.jsxs(U,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(q,{children:"Integrations"}),e.jsx(W,{children:"Connected external services and providers"})]}),e.jsxs(I,{size:"sm",children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(K,{className:"space-y-6",children:e.jsxs(Ya,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[n?e.jsxs(Ae,{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(v,{className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-6 w-32"}),e.jsx(v,{className:"h-5 w-5 rounded-full"})]}),e.jsx(v,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-8 w-24"}),e.jsx(v,{className:"h-8 w-8"})]})]})}),e.jsx(Ie,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{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(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{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(v,{className:"h-3 w-32"}),e.jsx(v,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{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(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(Ae,{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(Ke,{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(Yt,{id:a?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async r=>l(r,"greenInvoiceId")}),e.jsx(We,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Ie,{children:i&&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:a?.clientInfo?.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:i.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:i.country})]}),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:i.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(Be,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.emails?.map((r,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:r},d))})]}),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(os,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:i.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:i.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:i.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(Te,{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:i.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:i.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:i.zip})]})]})]})]})})]}),Kt.map(r=>e.jsxs(Ae,{value:r.id,className:"rounded-lg border",children:[e.jsx("div",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3 flex-1",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:r.name}),r.status==="connected"?e.jsx(Ke,{className:"h-4 w-4 text-green-600"}):e.jsx(sa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(Me,{className:"h-4 w-4"})}),e.jsx(We,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Ie,{children:e.jsx("div",{className:"px-4 pb-4 pt-2 border-t",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last sync: "}),e.jsx("span",{className:"font-medium",children:r.lastSync})]})})})]},r.id))]})})]})}function Yt({id:s,provider:a,updateClient:t}){const[n,c]=g.useState(!1),[o,l]=g.useState(s),i=g.useCallback(async()=>{await t(o),c(!1)},[o,t]);return e.jsxs(ss,{open:n,onOpenChange:c,children:[e.jsx(ta,{asChild:!0,children:e.jsxs(I,{variant:"outline",size:"sm",onClick:r=>r.stopPropagation(),children:[e.jsx(Me,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(as,{onClick:r=>r.stopPropagation(),children:[e.jsxs(na,{children:[e.jsxs(ia,{children:["Configure ",a]}),e.jsxs(ra,{children:["Update your ",a," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(pe,{htmlFor:"id",children:[a," ID"]}),e.jsx(T,{id:"id",value:o,onChange:r=>l(r.target.value),placeholder:`Enter ${a} ID`})]})}),e.jsxs(la,{children:[e.jsx(I,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(I,{onClick:i,disabled:!o,children:"Save Changes"})]})]})]})}function Xt({businessId:s}){const[{data:a,fetching:t}]=te({query:ca,variables:{businessId:s}});return t?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(U,{children:[e.jsx(G,{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(q,{children:"Ledger Records"}),e.jsx(W,{children:"Complete ledger history for this business"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(wa,{ledgerRecordsData:a?.ledgerRecordsByFinancialEntity??[]})})})]})}function Jt({businessId:s}){const[{data:a,fetching:t}]=te({query:oa,variables:{businessId:s}});return t?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(U,{children:[e.jsx(G,{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(q,{children:"Transactions"}),e.jsx(W,{children:"Complete transaction history for this business"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Ha,{transactionsProps:a?.transactionsByFinancialEntity??[]})})})]})}function Qt({data:s,refetchBusiness:a}){const t=ge(ja,s),[n,c]=da(),{setFiltersContext:o}=g.useContext(ma);g.useEffect(()=>{o(null)},[o]);const l=n.get("tab")||"contact",i=h=>{c({tab:h})};if(!t)return e.jsx("div",{children:"Business not found"});const r="clientInfo"in t&&!!t.clientInfo,d="adminInfo"in t&&!!t.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Na,{data:t}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(ua,{value:l,onValueChange:i,className:"w-full",children:[e.jsxs(ha,{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(Y,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Xa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(Y,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Me,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(Y,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ye,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(Y,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(xa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(Y,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(pa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),e.jsxs(Y,{value:"ledger",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(nt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ledger"})]}),e.jsxs(Y,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Qa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(Y,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(at,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(Y,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(rt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),d&&e.jsxs(Y,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ls,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx(M,{value:"contact",className:"mt-0",children:e.jsx(Ut,{data:t,refetchBusiness:a})}),e.jsx(M,{value:"config",className:"mt-0",children:e.jsx(Ft,{data:t,refetchBusiness:a})}),e.jsx(M,{value:"charges",className:"mt-0",children:e.jsx(jt,{businessId:t.id})}),e.jsx(M,{value:"transactions",className:"mt-0",children:e.jsx(Jt,{businessId:t.id})}),e.jsx(M,{value:"documents",className:"mt-0",children:e.jsx(Wt,{businessId:t.id})}),e.jsx(M,{value:"ledger",className:"mt-0",children:e.jsx(Xt,{businessId:t.id})}),e.jsx(M,{value:"balance",className:"mt-0",children:e.jsx(pt,{businessId:t.id})}),r&&e.jsxs(e.Fragment,{children:[e.jsx(M,{value:"contracts",className:"mt-0",children:e.jsx(qt,{clientId:t.id})}),e.jsx(M,{value:"integrations",className:"mt-0",children:e.jsx(Ht,{data:t})}),e.jsx(M,{value:"charts",className:"mt-0",children:e.jsx(Et,{})})]}),d&&e.jsx(M,{value:"admin",className:"mt-0",children:e.jsx(xt,{data:t})})]})})]})}const Nn=()=>{const{businessId:s}=ga();let a;try{a=fa()}catch{}const[{data:t,fetching:n},c]=te({query:va,pause:!s||!!a,variables:{businessId:s??""}}),o=a||t;return!a&&n&&!o?.business?e.jsx(ts,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(Qt,{data:o.business,refetchBusiness:async()=>c()})};export{Nn as BusinessScreen};
36
+ */const lt=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Se=ae("trending-up",lt);function ct(s){return es(s,"yyyy-MM-dd")}function ot({businessId:s,tagIds:a,description:t,open:n,onOpenChange:c,onClose:o}){const[{data:l,fetching:i},r]=te({pause:!0,query:vs,variables:{businessId:s,tagsDifferentThan:a?a.map(m=>m.id):void 0,descriptionDifferentThan:t}});g.useEffect(()=>{n&&(a||t)&&!l&&r()},[n,a,t,r,l]);const d=g.useCallback(m=>{c(m),n&&!m&&o?.()},[c,o,n]),h=g.useMemo(()=>n&&(!!a||!!t)&&l&&l?.similarChargesByBusiness.length>0,[n,a,t,l]);return e.jsx(ss,{open:h,onOpenChange:d,children:e.jsx(as,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:m=>m.stopPropagation(),children:e.jsx(ys,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:i?e.jsx(ts,{}):a||t?e.jsx(ba,{data:l?.similarChargesByBusiness??[],tagIds:a,description:t,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const dt="updateAdminBusiness",mt=()=>{const[{fetching:s},a]=ns(Ns),t=g.useCallback(async n=>{const c=`Error updating admin business ID [${n.adminBusinessId}]`,o=`${dt}-${n.adminBusinessId}`;le.loading("Updating admin business",{id:o});try{const l=await a(n),i=is(l,c,o,"updateAdminBusiness");if(i)return le.success("Success",{id:o,description:"Admin Business Updated"}),i.updateAdminBusiness}catch(l){console.error(`${c}: ${l}`),le.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[a]);return{fetching:s,updateAdminBusiness:t}},ke=Ne({year:cs().min(2e3).max(2100),id:z().min(1,{message:"ID is required"})}),ut=Ne({registrationDate:z().min(1,{message:"Business Registration Start Date is required"}),withholdingTaxAnnualIds:re(ke),withholdingTaxCompanyId:z().min(1,{message:"Withholding Tax Company ID is required"}),socialSecurityEmployerIds:re(ke),socialSecurityDeductionsId:z().min(1,{message:"Social Security Deductions ID is required"}),taxAdvancesAnnualIds:re(ke),taxAdvancesRates:re(Ne({date:Cs(),rate:cs().min(0,{message:"Rate must be at least 0"}).max(100,{message:"Rate must be at most 100"})}))});function He(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{registrationDate:s.adminInfo.registrationDate,withholdingTaxAnnualIds:s.adminInfo.withholdingTaxAnnualIds.sort((a,t)=>t.year-a.year),withholdingTaxCompanyId:s.adminInfo.withholdingTaxCompanyId??void 0,socialSecurityEmployerIds:s.adminInfo.socialSecurityEmployerIds.sort((a,t)=>t.year-a.year),socialSecurityDeductionsId:s.adminInfo.socialSecurityDeductionsId??void 0,taxAdvancesAnnualIds:s.adminInfo.taxAdvancesAnnualIds.sort((a,t)=>t.year-a.year),taxAdvancesRates:s.adminInfo.taxAdvancesRates?.map(a=>({date:a.date,rate:a.rate*100}))}}function ht(s){return{registrationDate:s.registrationDate?ct(new Date(s.registrationDate)):void 0,withholdingTaxAnnualIds:s.withholdingTaxAnnualIds,withholdingTaxCompanyId:s.withholdingTaxCompanyId,socialSecurityEmployerIds:s.socialSecurityEmployerIds,taxAdvancesRates:s.taxAdvancesRates?.map(a=>({date:a.date,rate:a.rate/100})),taxAdvancesAnnualIds:s.taxAdvancesAnnualIds}}function xt({data:s,refetchBusiness:a}){const t=ge(bs,s),[n,c]=g.useState(He(t)),{updateAdminBusiness:o,fetching:l}=mt(),i=Oe({resolver:rs(ut),defaultValues:n}),r=async u=>{if(!t)return;const p=Re(u,i.formState.dirtyFields);if(!p)return;const S=ht(p);await o({adminBusinessId:t.id,fields:S}),a?.()};g.useEffect(()=>{if(t){const u=He(t);c(u),i.reset(u)}},[t,i]);const{fields:d,append:h,remove:m}=fe({control:i.control,name:"taxAdvancesAnnualIds"}),{fields:x,append:w,remove:f}=fe({control:i.control,name:"withholdingTaxAnnualIds"}),{fields:A,append:D,remove:E}=fe({control:i.control,name:"socialSecurityEmployerIds"}),P={withholdingTaxAnnualIds:{append:w,remove:f},taxAdvancesAnnualIds:{append:h,remove:m},socialSecurityEmployerIds:{append:D,remove:E}},F=u=>{P[u].append({year:new Date().getFullYear(),id:""})},_=(u,p)=>{P[u].remove(p)},{fields:L,append:H,remove:V}=fe({control:i.control,name:"taxAdvancesRates"}),Q=()=>{H({date:es(new Date,"yyyy-MM-dd"),rate:0})},j=u=>{V(u)};return e.jsxs(U,{children:[e.jsxs(G,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ls,{className:"h-5 w-5 text-primary"}),e.jsx(W,{children:"Admin Business Configuration"})]}),e.jsx(q,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Fe,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(r),className:"space-y-6",children:[e.jsx(K,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Withholding Tax"}),e.jsx(y,{control:i.control,name:"withholdingTaxCompanyId",render:({field:u,fieldState:p})=>e.jsxs(N,{children:[e.jsx(b,{children:"Company Tax ID"}),e.jsx(k,{children:e.jsx(T,{placeholder:"Enter company ID",...u,className:C(p)})}),e.jsx(B,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Annual IDs"}),e.jsx(I,{type:"button",variant:"outline",size:"sm",onClick:()=>F("withholdingTaxAnnualIds"),children:e.jsx(X,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:x.map((u,p)=>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(T,{placeholder:"Year",type:"number",...i.register(`withholdingTaxAnnualIds.${p}.year`,{valueAsNumber:!0})}),e.jsx(T,{placeholder:"ID",...i.register(`withholdingTaxAnnualIds.${p}.id`)})]}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>_("withholdingTaxAnnualIds",p),children:e.jsx(J,{className:"size-4"})})]},u.id))})]}),e.jsx(ce,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Tax Advances"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Annual IDs"}),e.jsx(I,{type:"button",variant:"outline",size:"sm",onClick:()=>F("taxAdvancesAnnualIds"),children:e.jsx(X,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:d.map((u,p)=>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(T,{placeholder:"Year",type:"number",...i.register(`taxAdvancesAnnualIds.${p}.year`,{valueAsNumber:!0})}),e.jsx(T,{placeholder:"ID",...i.register(`taxAdvancesAnnualIds.${p}.id`)})]}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>_("taxAdvancesAnnualIds",p),children:e.jsx(J,{className:"size-4"})})]},u.id))})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Rates (%)"}),e.jsx(I,{type:"button",variant:"outline",size:"sm",onClick:Q,children:e.jsx(X,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:L.map((u,p)=>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(T,{placeholder:"Date",type:"date",...i.register(`taxAdvancesRates.${p}.date`)}),e.jsx(T,{placeholder:"Rate",...i.register(`taxAdvancesRates.${p}.rate`,{valueAsNumber:!0})})]}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>j(p),children:e.jsx(J,{className:"size-4"})})]},u.id))})]}),e.jsx(ce,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Social Security"}),e.jsx(y,{control:i.control,name:"socialSecurityDeductionsId",render:({field:u,fieldState:p})=>e.jsxs(N,{children:[e.jsx(b,{children:"Deductions ID"}),e.jsx(k,{children:e.jsx(T,{placeholder:"Enter deductions ID",...u,className:C(p)})}),e.jsx(B,{})]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(pe,{children:"Annual Employer IDs"}),e.jsx(I,{type:"button",variant:"outline",size:"sm",onClick:()=>F("socialSecurityEmployerIds"),children:e.jsx(X,{className:"size-4"})})]}),e.jsx("div",{className:"space-y-3",children:A.map((u,p)=>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(T,{placeholder:"Year",type:"number",...i.register(`socialSecurityEmployerIds.${p}.year`,{valueAsNumber:!0})}),e.jsx(T,{placeholder:"ID",...i.register(`socialSecurityEmployerIds.${p}.id`)})]}),e.jsx(I,{type:"button",variant:"ghost",size:"icon",onClick:()=>_("socialSecurityEmployerIds",p),children:e.jsx(J,{className:"size-4"})})]},u.id))})]}),e.jsx(ce,{className:"md:col-span-2"}),e.jsx(y,{control:i.control,name:"registrationDate",render:({field:u,fieldState:p})=>e.jsxs(N,{children:[e.jsx(b,{children:"Business Registration Start Date"}),e.jsx(k,{children:e.jsx(T,{type:"date",...u,className:C(p)})}),e.jsx(B,{})]})})]})}),e.jsx(_e,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(I,{type:"submit",disabled:l||Object.keys(i.formState.dirtyFields).length===0||!i.formState.isValid,children:[e.jsx(ze,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function pt({businessId:s}){return e.jsxs(U,{children:[e.jsx(G,{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(W,{children:"Balance"}),e.jsx(q,{children:"Business balance overview"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(ya,{businessID:s,filter:{}})})})]})}function jt({businessId:s}){const{userContext:a}=g.useContext(Ve),[t,n]=g.useState(0),[{data:c,fetching:o}]=te({query:ws,variables:{filters:{byOwners:a?.context.adminBusinessId?[a.context.adminBusinessId]:void 0,sortBy:{field:Is.Date,asc:!1},byBusinesses:[s]},page:t-1,limit:10}}),l=c?.allCharges?.pageInfo.totalPages??1,i=c?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(U,{children:[e.jsxs(G,{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(W,{children:"Charges"}),e.jsx(q,{children:"Recurring and one-time charges for this business"})]})}),l>1&&e.jsx(As,{className:"flex-fit w-fit mx-0",value:t,onChange:n,total:l})]}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Ca,{data:i,isAllOpened:!1})})})]})}var gt=["type","layout","connectNulls","ref"],ft=["key"];function oe(s){"@babel/helpers - typeof";return oe=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(a){return typeof a}:function(a){return a&&typeof Symbol=="function"&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},oe(s)}function Ye(s,a){if(s==null)return{};var t=vt(s,a),n,c;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(c=0;c<o.length;c++)n=o[c],!(a.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(s,n)&&(t[n]=s[n])}return t}function vt(s,a){if(s==null)return{};var t={};for(var n in s)if(Object.prototype.hasOwnProperty.call(s,n)){if(a.indexOf(n)>=0)continue;t[n]=s[n]}return t}function je(){return je=Object.assign?Object.assign.bind():function(s){for(var a=1;a<arguments.length;a++){var t=arguments[a];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(s[n]=t[n])}return s},je.apply(this,arguments)}function Xe(s,a){var t=Object.keys(s);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(s);a&&(n=n.filter(function(c){return Object.getOwnPropertyDescriptor(s,c).enumerable})),t.push.apply(t,n)}return t}function R(s){for(var a=1;a<arguments.length;a++){var t=arguments[a]!=null?arguments[a]:{};a%2?Xe(Object(t),!0).forEach(function(n){$(s,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(t)):Xe(Object(t)).forEach(function(n){Object.defineProperty(s,n,Object.getOwnPropertyDescriptor(t,n))})}return s}function ie(s){return Ct(s)||bt(s)||Nt(s)||yt()}function yt(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
37
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nt(s,a){if(s){if(typeof s=="string")return Pe(s,a);var t=Object.prototype.toString.call(s).slice(8,-1);if(t==="Object"&&s.constructor&&(t=s.constructor.name),t==="Map"||t==="Set")return Array.from(s);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return Pe(s,a)}}function bt(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function Ct(s){if(Array.isArray(s))return Pe(s)}function Pe(s,a){(a==null||a>s.length)&&(a=s.length);for(var t=0,n=new Array(a);t<a;t++)n[t]=s[t];return n}function wt(s,a){if(!(s instanceof a))throw new TypeError("Cannot call a class as a function")}function Je(s,a){for(var t=0;t<a.length;t++){var n=a[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(s,xs(n.key),n)}}function At(s,a,t){return a&&Je(s.prototype,a),t&&Je(s,t),Object.defineProperty(s,"prototype",{writable:!1}),s}function It(s,a,t){return a=be(a),St(s,hs()?Reflect.construct(a,t||[],be(s).constructor):a.apply(s,t))}function St(s,a){if(a&&(oe(a)==="object"||typeof a=="function"))return a;if(a!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return kt(s)}function kt(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function hs(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(hs=function(){return!!s})()}function be(s){return be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},be(s)}function Dt(s,a){if(typeof a!="function"&&a!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(a&&a.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),a&&Le(s,a)}function Le(s,a){return Le=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(n,c){return n.__proto__=c,n},Le(s,a)}function $(s,a,t){return a=xs(a),a in s?Object.defineProperty(s,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):s[a]=t,s}function xs(s){var a=Tt(s,"string");return oe(a)=="symbol"?a:a+""}function Tt(s,a){if(oe(s)!="object"||!s)return s;var t=s[Symbol.toPrimitive];if(t!==void 0){var n=t.call(s,a);if(oe(n)!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var de=(function(s){function a(){var t;wt(this,a);for(var n=arguments.length,c=new Array(n),o=0;o<n;o++)c[o]=arguments[o];return t=It(this,a,[].concat(c)),$(t,"state",{isAnimationFinished:!0,totalLength:0}),$(t,"generateSimpleStrokeDasharray",function(l,i){return"".concat(i,"px ").concat(l-i,"px")}),$(t,"getStrokeDasharray",function(l,i,r){var d=r.reduce(function(E,P){return E+P});if(!d)return t.generateSimpleStrokeDasharray(i,l);for(var h=Math.floor(l/d),m=l%d,x=i-l,w=[],f=0,A=0;f<r.length;A+=r[f],++f)if(A+r[f]>m){w=[].concat(ie(r.slice(0,f)),[m-A]);break}var D=w.length%2===0?[0,x]:[x];return[].concat(ie(a.repeat(r,h)),ie(w),D).map(function(E){return"".concat(E,"px")}).join(", ")}),$(t,"id",La("recharts-line-")),$(t,"pathRef",function(l){t.mainCurve=l}),$(t,"handleAnimationEnd",function(){t.setState({isAnimationFinished:!0}),t.props.onAnimationEnd&&t.props.onAnimationEnd()}),$(t,"handleAnimationStart",function(){t.setState({isAnimationFinished:!1}),t.props.onAnimationStart&&t.props.onAnimationStart()}),t}return Dt(a,s),At(a,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();this.setState({totalLength:n})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var n=this.getTotalLength();n!==this.state.totalLength&&this.setState({totalLength:n})}}},{key:"getTotalLength",value:function(){var n=this.mainCurve;try{return n&&n.getTotalLength&&n.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(n,c){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,l=o.points,i=o.xAxis,r=o.yAxis,d=o.layout,h=o.children,m=Sa(h,ka);if(!m)return null;var x=function(A,D){return{x:A.x,y:A.y,value:A.value,errorVal:ds(A.payload,D)}},w={clipPath:n?"url(#clipPath-".concat(c,")"):null};return O.createElement(we,w,m.map(function(f){return O.cloneElement(f,{key:"bar-".concat(f.props.dataKey),data:l,xAxis:i,yAxis:r,layout:d,dataPointFormatter:x})}))}},{key:"renderDots",value:function(n,c,o){var l=this.props.isAnimationActive;if(l&&!this.state.isAnimationFinished)return null;var i=this.props,r=i.dot,d=i.points,h=i.dataKey,m=ve(this.props,!1),x=ve(r,!0),w=d.map(function(A,D){var E=R(R(R({key:"dot-".concat(D),r:3},m),x),{},{index:D,cx:A.x,cy:A.y,value:A.value,dataKey:h,payload:A.payload,points:d});return a.renderDotItem(r,E)}),f={clipPath:n?"url(#clipPath-".concat(c?"":"dots-").concat(o,")"):null};return O.createElement(we,je({className:"recharts-line-dots",key:"dots"},f),w)}},{key:"renderCurveStatically",value:function(n,c,o,l){var i=this.props,r=i.type,d=i.layout,h=i.connectNulls;i.ref;var m=Ye(i,gt),x=R(R(R({},ve(m,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:c?"url(#clipPath-".concat(o,")"):null,points:n},l),{},{type:r,layout:d,connectNulls:h});return O.createElement(Da,je({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(n,c){var o=this,l=this.props,i=l.points,r=l.strokeDasharray,d=l.isAnimationActive,h=l.animationBegin,m=l.animationDuration,x=l.animationEasing,w=l.animationId,f=l.animateNewValues,A=l.width,D=l.height,E=this.state,P=E.prevPoints,F=E.totalLength;return O.createElement(Ta,{begin:h,duration:m,isActive:d,easing:x,from:{t:0},to:{t:1},key:"line-".concat(w),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(_){var L=_.t;if(P){var H=P.length/i.length,V=i.map(function(S,Ce){var me=Math.floor(Ce*H);if(P[me]){var ue=P[me],ne=he(ue.x,S.x),js=he(ue.y,S.y);return R(R({},S),{},{x:ne(L),y:js(L)})}if(f){var gs=he(A*2,S.x),fs=he(D/2,S.y);return R(R({},S),{},{x:gs(L),y:fs(L)})}return R(R({},S),{},{x:S.x,y:S.y})});return o.renderCurveStatically(V,n,c)}var Q=he(0,F),j=Q(L),u;if(r){var p="".concat(r).split(/[,\s]+/gim).map(function(S){return parseFloat(S)});u=o.getStrokeDasharray(j,F,p)}else u=o.generateSimpleStrokeDasharray(F,j);return o.renderCurveStatically(i,n,c,{strokeDasharray:u})})}},{key:"renderCurve",value:function(n,c){var o=this.props,l=o.points,i=o.isAnimationActive,r=this.state,d=r.prevPoints,h=r.totalLength;return i&&l&&l.length&&(!d&&h>0||!Ba(d,l))?this.renderCurveWithAnimation(n,c):this.renderCurveStatically(l,n,c)}},{key:"render",value:function(){var n,c=this.props,o=c.hide,l=c.dot,i=c.points,r=c.className,d=c.xAxis,h=c.yAxis,m=c.top,x=c.left,w=c.width,f=c.height,A=c.isAnimationActive,D=c.id;if(o||!i||!i.length)return null;var E=this.state.isAnimationFinished,P=i.length===1,F=$e("recharts-line",r),_=d&&d.allowDataOverflow,L=h&&h.allowDataOverflow,H=_||L,V=Ee(D)?this.id:D,Q=(n=ve(l,!1))!==null&&n!==void 0?n:{r:3,strokeWidth:2},j=Q.r,u=j===void 0?3:j,p=Q.strokeWidth,S=p===void 0?2:p,Ce=Ea(l)?l:{},me=Ce.clipDot,ue=me===void 0?!0:me,ne=u*2+S;return O.createElement(we,{className:F},_||L?O.createElement("defs",null,O.createElement("clipPath",{id:"clipPath-".concat(V)},O.createElement("rect",{x:_?x:x-w/2,y:L?m:m-f/2,width:_?w:w*2,height:L?f:f*2})),!ue&&O.createElement("clipPath",{id:"clipPath-dots-".concat(V)},O.createElement("rect",{x:x-ne/2,y:m-ne/2,width:w+ne,height:f+ne}))):null,!P&&this.renderCurve(H,V),this.renderErrorBar(H,V),(P||l)&&this.renderDots(H,ue,V),(!A||E)&&Pa.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(n,c){return n.animationId!==c.prevAnimationId?{prevAnimationId:n.animationId,curPoints:n.points,prevPoints:c.curPoints}:n.points!==c.curPoints?{curPoints:n.points}:null}},{key:"repeat",value:function(n,c){for(var o=n.length%2!==0?[].concat(ie(n),[0]):n,l=[],i=0;i<c;++i)l=[].concat(ie(l),ie(o));return l}},{key:"renderDotItem",value:function(n,c){var o;if(O.isValidElement(n))o=O.cloneElement(n,c);else if(Aa(n))o=n(c);else{var l=c.key,i=Ye(c,ft),r=$e("recharts-line-dot",typeof n!="boolean"?n.className:"");o=O.createElement(Ia,je({key:l},i,{className:r}))}return o}}])})(g.PureComponent);$(de,"displayName","Line");$(de,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Oa.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});$(de,"getComposedData",function(s){var a=s.props,t=s.xAxis,n=s.yAxis,c=s.xAxisTicks,o=s.yAxisTicks,l=s.dataKey,i=s.bandSize,r=s.displayedData,d=s.offset,h=a.layout,m=r.map(function(x,w){var f=ds(x,l);return h==="horizontal"?{x:We({axis:t,ticks:c,bandSize:i,entry:x,index:w}),y:Ee(f)?null:n.scale(f),value:f,payload:x}:{x:Ee(f)?null:t.scale(f),y:We({axis:n,ticks:o,bandSize:i,entry:x,index:w}),value:f,payload:x}});return R({points:m,layout:h},d)});var Bt=Fa({chartName:"LineChart",GraphicalChild:de,axisComponents:[{axisType:"xAxis",AxisComp:ms},{axisType:"yAxis",AxisComp:us}],formatAxisMap:_a});const xe=[{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 Et(){const s=xe.reduce((t,n)=>t+n.revenue,0),a=s/xe.length;return e.jsxs(U,{children:[e.jsxs(G,{children:[e.jsx(W,{children:"Revenue Analytics"}),e.jsx(q,{children:"Revenue and expenses over time"})]}),e.jsxs(K,{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(ye,{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(Se,{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(ye,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",a.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Se,{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(ye,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",xe[xe.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Se,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Ra,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Va,{width:"100%",height:"100%",children:e.jsxs(Bt,{data:xe,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Ma,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(ms,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(us,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(za,{content:e.jsx($a,{})}),e.jsx(de,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(de,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const Pt="updateBusiness",ps=()=>{const[{fetching:s},a]=ns(Ss),t=g.useCallback(async n=>{const c=`Error updating business ID [${n.businessId}]`,o=`${Pt}-${n.businessId}`;le.loading("Updating business",{id:o});try{const l=await a(n),i=is(l,c,o,"updateBusiness");if(i)return le.success("Success",{id:o,description:"Business updated"}),i.updateBusiness}catch(l){console.error(`${c}: ${l}`),le.error("Error",{id:o,description:c,duration:1e5,closeButton:!0})}},[a]);return{fetching:s,updateBusiness:t}},Lt=Object.values(zs);function Qe(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(a=>a.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 Ot(s){const t=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||t?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:t}: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 Ft({data:s,refetchBusiness:a}){const t=ge(Ds,s),[n,c]=g.useState(Qe(t)),{userContext:o}=g.useContext(Ve),{updateBusiness:l,fetching:i}=ps(),[r,d]=g.useState(!1),[h,m]=g.useState(void 0),x=Oe({defaultValues:n}),w=async A=>{if(!t||!o?.context.adminBusinessId)return;const D=Re(A,x.formState.dirtyFields);if(!D)return;const E=Ot(D);await l({businessId:t.id,ownerId:o.context.adminBusinessId,fields:E}),D.tags?.length||D.description?(m({tagIds:D.tags?.map(P=>({id:P})),description:D.description}),d(!0)):a?.()};if(g.useEffect(()=>{if(t){const A=Qe(t);c(A),x.reset(A)}},[t,x]),!t)return e.jsx("div",{});const f=x.watch("isClient");return e.jsxs(U,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Configurations"}),e.jsx(q,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!f&&e.jsx(ks,{businessId:t.id,onDone:a})]})}),e.jsx(Fe,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(w),children:[e.jsxs(K,{className:"space-y-6",children:[e.jsx(_t,{form:x}),e.jsx(ce,{}),e.jsx(Rt,{form:x}),e.jsx(ce,{}),e.jsx(Vt,{form:x}),e.jsx(ce,{}),e.jsx(Mt,{form:x})]}),e.jsx(_e,{className:"flex justify-end border-t pt-6",children:e.jsxs(I,{type:"submit",disabled:i||Object.keys(x.formState.dirtyFields).length===0,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(ot,{businessId:t.id,tagIds:h?.tagIds,description:h?.description,open:r,onOpenChange:d,onClose:a})]})}function _t({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(y,{control:s.control,name:"isClient",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Client"}),e.jsx(Z,{children:"Mark this business as a client"})]}),e.jsx(k,{children:e.jsx(ee,{disabled:!0,checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isActive",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Active"}),e.jsx(Z,{children:"Business is currently active"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isReceiptEnough",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Receipt Enough"}),e.jsx(Z,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isDocumentsOptional",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"No Docs Required"}),e.jsx(Z,{children:"Skip document validation for common charges"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isVatOptional",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is VAT Optional"}),e.jsx(Z,{children:"Mute missing VAT indicator"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})}),e.jsx(y,{control:s.control,name:"isExemptDealer",render:({field:a,fieldState:t})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Is Exempt Dealer"}),e.jsx(Z,{children:"Business is exempt from VAT requirements"})]}),e.jsx(k,{children:e.jsx(ee,{checked:a.value,onCheckedChange:a.onChange,className:C(t)})})]})})]})]})}function Rt({form:s}){const{selectableTaxCategories:a,fetching:t}=Ts(),{selectableSortCodes:n,fetching:c,sortCodes:o}=Bs(),{selectableTags:l,fetching:i}=Es(),r=g.useCallback(d=>{if(d){const h=o.find(m=>Number(m.key)===Number(d));h&&(h.defaultIrsCode?s.setValue("irsCode",h.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(y,{control:s.control,name:"sortCode",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Sort Code"}),e.jsx(k,{children:e.jsx(De,{onChange:m=>{r(m),d.onChange(m)},data:n,value:d.value,disabled:c,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(h)}})}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"taxCategory",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Tax Category"}),e.jsx(k,{children:e.jsx(De,{data:a,disabled:t,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(h)}})}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"PCN874 Record Type"}),e.jsxs(Ps,{onValueChange:d.onChange,value:d.value,children:[e.jsx(k,{children:e.jsx(Ls,{className:C(h),children:e.jsx(Os,{})})}),e.jsx(Fs,{children:Object.entries(_s).map(([m,x])=>e.jsx(Rs,{value:m,children:`${x} (${m})`},m))})]}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"irsCode",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"IRS Code"}),e.jsx(k,{children:e.jsx(Vs,{value:d.value??void 0,onValueChange:m=>d.onChange(m??null),hideControls:!0,decimalScale:0,className:C(h)})}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"description",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Charge Description"}),e.jsx(k,{children:e.jsx(T,{placeholder:"Enter default charge description",...d,className:C(h)})}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"tags",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Tags"}),e.jsx(k,{children:e.jsx(Ms,{options:Object.values(l).map(({value:m,label:x})=>({label:x,value:m})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:i,className:C(h)})}),e.jsx(B,{})]})})]})]})}function Vt({form:s}){const[a,t]=g.useState(""),[n,c]=g.useState(""),o=()=>{if(a.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,a.trim()],{shouldDirty:!0}),t("")}},l=()=>{if(n.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,n.trim()],{shouldDirty:!0}),c("")}},i=d=>{const h=s.getValues("phrases");s.setValue("phrases",h.filter((m,x)=>x!==d),{shouldDirty:!0})},r=d=>{const h=s.getValues("emails");s.setValue("emails",h.filter((m,x)=>x!==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(y,{control:s.control,name:"phrases",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add phrase...",value:a,onChange:m=>t(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),o())},className:C(h)}),e.jsx(I,{type:"button",size:"sm",onClick:o,children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((m,x)=>e.jsxs(se,{variant:"secondary",className:"gap-1",children:[m,e.jsx(I,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>i(x),children:e.jsx(J,{className:"size-3 cursor-pointer",onClick:()=>i(x)})})]},x))}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"emails",render:({field:d,fieldState:h})=>e.jsxs(N,{children:[e.jsx(b,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"email",placeholder:"Add email...",value:n,onChange:m=>c(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),l())},className:C(h)}),e.jsx(I,{type:"button",size:"sm",onClick:l,children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((m,x)=>e.jsxs(se,{variant:"secondary",className:"gap-1",children:[m,e.jsx(I,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>r(x),children:e.jsx(J,{className:"size-3 cursor-pointer"})})]},x))}),e.jsx(B,{})]})})]})}function Mt({form:s}){const[a,t]=g.useState(""),n=()=>{if(a.trim()){const l=s.getValues("internalLinks");s.setValue("internalLinks",[...l,a.trim()],{shouldDirty:!0}),t("")}},c=l=>{const i=s.getValues("attachmentTypes");s.setValue("attachmentTypes",i?.includes(l)?i.filter(r=>r!==l):[...i,l],{shouldDirty:!0})},o=l=>{const i=s.getValues("internalLinks");s.setValue("internalLinks",i.filter((r,d)=>d!==l),{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(y,{control:s.control,name:"attachmentTypes",render:({field:l,fieldState:i})=>e.jsxs(N,{children:[e.jsx(b,{children:"Attachment Types"}),e.jsx("div",{className:C(i)+" rounded-md flex flex-wrap gap-2",children:Lt.map(r=>e.jsx(se,{variant:l.value?.includes(r)?"default":"outline",className:"cursor-pointer",onClick:()=>c(r),children:r},r))}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"internalLinks",render:({field:l,fieldState:i})=>e.jsxs(N,{children:[e.jsx(b,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"url",placeholder:"Add internal link...",value:a,onChange:r=>t(r.target.value),onKeyDown:r=>{r.key==="Enter"&&(r.preventDefault(),n())}}),e.jsx(I,{type:"button",size:"sm",onClick:n,children:e.jsx(X,{className:"h-4 w-4"})})]}),e.jsx("div",{className:C(i)+" flex flex-wrap gap-2 rounded-md",children:l.value?.map((r,d)=>e.jsxs(se,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[r,e.jsx(I,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(J,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(B,{})]})}),e.jsx(y,{control:s.control,name:"useMessageBody",render:({field:l,fieldState:i})=>e.jsxs(N,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(b,{children:"Should Use Message Body"}),e.jsx(Z,{children:"Extract information from email message body"})]}),e.jsx(k,{children:e.jsx(ee,{checked:l.value,onCheckedChange:l.onChange,className:C(i)})})]})})]})}const zt=Ne({businessName:z().min(1,"Business name is required"),locality:z().min(1,"Locality is required"),localName:z().optional(),govId:z().optional(),address:z().optional(),localAddress:z().optional(),phone:z().optional(),website:Ws("Invalid URL").optional().or(qs("")),generalContacts:re(Ge()).optional(),billingEmails:re(Ge()).optional()});function Ze(s){return!s||s.__typename!=="LtdFinancialEntity"?{}:{businessName:s.name,locality:s.country,localName:s.hebrewName??void 0,govId:s.governmentId??void 0,address:s.address??void 0,phone:s.phoneNumber??void 0,website:s.website??void 0,generalContacts:s.email?.split(",").map(a=>a.trim()),billingEmails:s.clientInfo?.emails}}function $t(s){return{name:s.businessName,country:s.locality,hebrewName:s.localName,governmentId:s.govId,address:s.address,phoneNumber:s.phone,website:s.website,email:s.generalContacts?.join(", ")}}function Ut({data:s,refetchBusiness:a}){const t=ge(Gs,s),[n,c]=g.useState(Ze(t)),{userContext:o}=g.useContext(Ve),{updateBusiness:l,fetching:i}=ps(),r=Oe({resolver:rs(zt),defaultValues:n}),{countries:d,fetching:h}=$s(),[m,x]=g.useState(""),[w,f]=g.useState(""),A=r.watch("locality"),D=r.watch("address"),E=r.watch("localAddress");g.useEffect(()=>{D!==n.address&&r.setValue("address",D,{shouldDirty:!0})},[D,n.address,r]),g.useEffect(()=>{E!==n.localAddress&&r.setValue("localAddress",E,{shouldDirty:!0})},[E,n.localAddress,r]);const P=t&&"clientInfo"in t&&!!t.clientInfo,F=A===o?.context.locality,_=j=>{m.trim()&&(r.setValue("generalContacts",[...j,m.trim()],{shouldDirty:!0}),x(""))},L=(j,u)=>{r.setValue("generalContacts",j.filter((p,S)=>S!==u),{shouldDirty:!0})},H=j=>{w.trim()&&(r.setValue("billingEmails",[...j,w.trim()],{shouldDirty:!0}),f(""))},V=(j,u)=>{r.setValue("billingEmails",j.filter((p,S)=>S!==u),{shouldDirty:!0})},Q=async j=>{if(!t||!o?.context.adminBusinessId)return;const u=Re(j,r.formState.dirtyFields);if(!u)return;const p=$t(u);await l({businessId:t.id,ownerId:o.context.adminBusinessId,fields:p}),a?.()};return g.useEffect(()=>{if(t){const j=Ze(t);c(j),r.reset(j)}},[t,r]),e.jsxs(U,{children:[e.jsxs(G,{children:[e.jsx(W,{children:"Contact Information"}),e.jsx(q,{children:"Business contact details and address information"})]}),e.jsx(Fe,{...r,children:e.jsxs("form",{onSubmit:r.handleSubmit(Q),children:[e.jsx(K,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(y,{control:r.control,name:"businessName",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Business Name"}),e.jsx(k,{children:e.jsx(T,{...j,className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"locality",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Locality / Country"}),e.jsx(De,{onChange:j.onChange,data:d.map(p=>({value:p.code,label:p.name})),value:j.value,disabled:h,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:C(u)}}),e.jsx(B,{})]})}),F&&e.jsx(y,{control:r.control,name:"localName",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Local Name"}),e.jsx(k,{children:e.jsx(T,{...j,placeholder:"Business name in local language",className:C(u)})}),e.jsx(B,{})]})}),F&&e.jsx(y,{control:r.control,name:"govId",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsx(b,{children:"Government ID"}),e.jsx(k,{children:e.jsx(T,{...j,placeholder:"Enter Government ID",className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"address",render:({field:j,fieldState:u})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),"Address"]}),e.jsx(k,{children:e.jsx(Ue,{...j,rows:3,placeholder:"Enter business address",className:C(u)})}),e.jsx(B,{})]})}),F&&e.jsx(y,{control:r.control,name:"localAddress",render:({field:j,fieldState:u})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Te,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(k,{children:e.jsx(Ue,{...j,rows:3,placeholder:"Enter address in local language",className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"phone",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(os,{className:"h-4 w-4"}),"Phone"]}),e.jsx(k,{children:e.jsx(T,{...j,type:"tel",placeholder:"+1 (555) 123-4567",className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"website",render:({field:j,fieldState:u})=>e.jsxs(N,{children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Us,{className:"h-4 w-4"}),"Website"]}),e.jsx(k,{children:e.jsx(T,{...j,type:"url",placeholder:"https://example.com",className:C(u)})}),e.jsx(B,{})]})}),e.jsx(y,{control:r.control,name:"generalContacts",render:({field:j,fieldState:u})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:C(u)+" flex flex-wrap gap-2 mb-2 rounded-md",children:j.value?.map((p,S)=>e.jsxs(se,{variant:"secondary",className:"gap-1 pr-1",children:[p,e.jsx("button",{type:"button",onClick:()=>L(j.value??[],S),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(J,{className:"h-3 w-3"})})]},S))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:m,onChange:p=>x(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),_(j.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(I,{type:"button",variant:"outline",size:"icon",disabled:!m.trim(),onClick:()=>_(j.value??[]),children:e.jsx(X,{className:"h-4 w-4"})})]})]})}),e.jsx(B,{})]})}),P&&e.jsx(y,{control:r.control,name:"billingEmails",render:({field:j,fieldState:u})=>e.jsxs(N,{className:"md:col-span-2",children:[e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(Be,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(k,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:C(u)+" flex flex-wrap gap-2 mb-2 rounded-md",children:j.value?.map((p,S)=>e.jsxs(se,{variant:"secondary",className:"gap-1 pr-1",children:[p,e.jsx("button",{type:"button",onClick:()=>V(j.value??[],S),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(J,{className:"h-3 w-3"})})]},S))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:w,onChange:p=>f(p.target.value),onKeyDown:p=>{p.key==="Enter"&&(p.preventDefault(),H(j.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(I,{type:"button",variant:"outline",size:"icon",disabled:!w.trim(),onClick:()=>H(j.value??[]),children:e.jsx(X,{className:"h-4 w-4"})})]})]})}),e.jsx(B,{})]})})]})}),e.jsx(_e,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(I,{type:"submit",disabled:i||Object.keys(r.formState.dirtyFields).length===0,children:[e.jsx(ze,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}function Gt(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[a,t]=g.useState(null),[{data:n,fetching:c},o]=te({query:Ks,variables:{clientId:s}}),l=n?.contractsByClient??[];return c?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(U,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Contracts"}),e.jsx(q,{children:"Current and past contracts sorted by start date"})]}),e.jsx(Ua,{clientId:s,contract:a,onDone:o})]})}),e.jsx(K,{className:"space-y-4",children:l.map(i=>{const r=!!i.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:i.product}),e.jsx(se,{variant:r?"default":"secondary",children:i.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:i.id})]}),e.jsx(I,{variant:"ghost",size:"sm",onClick:()=>t(Gt(i)),children:e.jsx(qa,{className:"h-4 w-4"})})]}),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(Hs,{className:"h-3 w-3"}),"Contract Period"]}),e.jsxs("p",{className:"text-sm font-medium",children:[new Date(i.startDate).toLocaleDateString()," →"," ",new Date(i.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:i.purchaseOrders.toReversed()[0]??""}),i.purchaseOrders.length>1&&e.jsx("div",{className:"space-x-1",children:i.purchaseOrders.toReversed().slice(1).map(d=>e.jsx("span",{className:"text-xs font-thin font-mono",children:d},d))})]}),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:Ys(i.amount.raw,i.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:Ga(i.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:i.plan?Wa(i.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:i.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:Xs(i.documentType)})]})]}),i.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:i.remarks})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.msCloud&&e.jsx(I,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(Js,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(Ka,{className:"h-3 w-3 ml-1"})]})})})]},i.id)})})]})}function qt({businessId:s}){return e.jsxs(U,{children:[e.jsx(G,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(W,{children:"Documents"}),e.jsx(q,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(K,{children:e.jsx(Qs,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const Kt=[{id:"hive",name:"Hive",description:"Schema registry, analytics, metrics and gateway for GraphQL federation and other GraphQL APIs",status:"disconnected",lastSync:"Never"},{id:"slack",name:"Slack",description:"Team communication and notifications",status:"disconnected",lastSync:"Never"},{id:"retool",name:"Retool",description:"Internal tools and dashboards",status:"disconnected",lastSync:"Never"},{id:"linear",name:"Linear",description:"Issue tracking and project management",status:"disconnected",lastSync:"Never"},{id:"workflowy",name:"Workflowy",description:"Task management and note taking",status:"disconnected",lastSync:"Never"}];function Ht({data:s}){const a=ge(aa,s),[{data:t,fetching:n},c]=te({query:Zs,variables:{clientId:a?.id??""},pause:!a?.clientInfo?.greenInvoiceId||!a?.id}),{updateClient:o}=ea(),l=g.useCallback((r,d)=>{if(!a?.id)return;const h={};h[d]=r,o({businessId:a?.id,fields:h})},[a?.id,o]);g.useEffect(()=>{a?.clientInfo?.greenInvoiceId&&a?.id&&c()},[a?.clientInfo?.greenInvoiceId,a?.id,c]);const i=t?.greenInvoiceClient;return e.jsxs(U,{children:[e.jsx(G,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(W,{children:"Integrations"}),e.jsx(q,{children:"Connected external services and providers"})]}),e.jsxs(I,{size:"sm",children:[e.jsx(X,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(K,{className:"space-y-6",children:e.jsxs(Ya,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[n?e.jsxs(Ae,{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(v,{className:"h-10 w-10 rounded-lg"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-6 w-32"}),e.jsx(v,{className:"h-5 w-5 rounded-full"})]}),e.jsx(v,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{className:"h-8 w-24"}),e.jsx(v,{className:"h-8 w-8"})]})]})}),e.jsx(Ie,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{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(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{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(v,{className:"h-3 w-32"}),e.jsx(v,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(v,{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(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(Ae,{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(Ke,{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(Yt,{id:a?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async r=>l(r,"greenInvoiceId")}),e.jsx(qe,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Ie,{children:i&&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:a?.clientInfo?.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:i.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:i.country})]}),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:i.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(Be,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.emails?.map((r,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:r},d))})]}),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(os,{className:"h-3.5 w-3.5"}),"Phone"]}),e.jsx("p",{className:"text-sm font-mono",children:i.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:i.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:i.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(Te,{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:i.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:i.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:i.zip})]})]})]})]})})]}),Kt.map(r=>e.jsxs(Ae,{value:r.id,className:"rounded-lg border",children:[e.jsx("div",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex items-center gap-3 flex-1",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:r.name}),r.status==="connected"?e.jsx(Ke,{className:"h-4 w-4 text-green-600"}):e.jsx(sa,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(I,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(Me,{className:"h-4 w-4"})}),e.jsx(qe,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Ie,{children:e.jsx("div",{className:"px-4 pb-4 pt-2 border-t",children:e.jsxs("div",{className:"text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:"Last sync: "}),e.jsx("span",{className:"font-medium",children:r.lastSync})]})})})]},r.id))]})})]})}function Yt({id:s,provider:a,updateClient:t}){const[n,c]=g.useState(!1),[o,l]=g.useState(s),i=g.useCallback(async()=>{await t(o),c(!1)},[o,t]);return e.jsxs(ss,{open:n,onOpenChange:c,children:[e.jsx(ta,{asChild:!0,children:e.jsxs(I,{variant:"outline",size:"sm",onClick:r=>r.stopPropagation(),children:[e.jsx(Me,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(as,{onClick:r=>r.stopPropagation(),children:[e.jsxs(na,{children:[e.jsxs(ia,{children:["Configure ",a]}),e.jsxs(ra,{children:["Update your ",a," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(pe,{htmlFor:"id",children:[a," ID"]}),e.jsx(T,{id:"id",value:o,onChange:r=>l(r.target.value),placeholder:`Enter ${a} ID`})]})}),e.jsxs(la,{children:[e.jsx(I,{variant:"outline",onClick:()=>c(!1),children:"Cancel"}),e.jsx(I,{onClick:i,disabled:!o,children:"Save Changes"})]})]})]})}function Xt({businessId:s}){const[{data:a,fetching:t}]=te({query:ca,variables:{businessId:s}});return t?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(U,{children:[e.jsx(G,{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(W,{children:"Ledger Records"}),e.jsx(q,{children:"Complete ledger history for this business"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(wa,{ledgerRecordsData:a?.ledgerRecordsByFinancialEntity??[]})})})]})}function Jt({businessId:s}){const[{data:a,fetching:t}]=te({query:oa,variables:{businessId:s}});return t?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(U,{children:[e.jsx(G,{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(W,{children:"Transactions"}),e.jsx(q,{children:"Complete transaction history for this business"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Ha,{transactionsProps:a?.transactionsByFinancialEntity??[]})})})]})}function Qt({data:s,refetchBusiness:a}){const t=ge(ja,s),[n,c]=da(),{setFiltersContext:o}=g.useContext(ma);g.useEffect(()=>{o(null)},[o]);const l=n.get("tab")||"contact",i=h=>{c({tab:h})};if(!t)return e.jsx("div",{children:"Business not found"});const r="clientInfo"in t&&!!t.clientInfo,d="adminInfo"in t&&!!t.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Na,{data:t}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(ua,{value:l,onValueChange:i,className:"w-full",children:[e.jsxs(ha,{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(Y,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Xa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(Y,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Me,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(Y,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ye,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(Y,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(xa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(Y,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(pa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),e.jsxs(Y,{value:"ledger",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(nt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ledger"})]}),e.jsxs(Y,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(Qa,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),r&&e.jsxs(e.Fragment,{children:[e.jsxs(Y,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(at,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(Y,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(rt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),d&&e.jsxs(Y,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ls,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx(M,{value:"contact",className:"mt-0",children:e.jsx(Ut,{data:t,refetchBusiness:a})}),e.jsx(M,{value:"config",className:"mt-0",children:e.jsx(Ft,{data:t,refetchBusiness:a})}),e.jsx(M,{value:"charges",className:"mt-0",children:e.jsx(jt,{businessId:t.id})}),e.jsx(M,{value:"transactions",className:"mt-0",children:e.jsx(Jt,{businessId:t.id})}),e.jsx(M,{value:"documents",className:"mt-0",children:e.jsx(qt,{businessId:t.id})}),e.jsx(M,{value:"ledger",className:"mt-0",children:e.jsx(Xt,{businessId:t.id})}),e.jsx(M,{value:"balance",className:"mt-0",children:e.jsx(pt,{businessId:t.id})}),r&&e.jsxs(e.Fragment,{children:[e.jsx(M,{value:"contracts",className:"mt-0",children:e.jsx(Wt,{clientId:t.id})}),e.jsx(M,{value:"integrations",className:"mt-0",children:e.jsx(Ht,{data:t})}),e.jsx(M,{value:"charts",className:"mt-0",children:e.jsx(Et,{})})]}),d&&e.jsx(M,{value:"admin",className:"mt-0",children:e.jsx(xt,{data:t})})]})})]})}const Nn=()=>{const{businessId:s}=ga();let a;try{a=fa()}catch{}const[{data:t,fetching:n},c]=te({query:va,pause:!s||!!a,variables:{businessId:s??""}}),o=a||t;return!a&&n&&!o?.business?e.jsx(ts,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(Qt,{data:o.business,refetchBusiness:async()=>c()})};export{Nn as BusinessScreen};
@@ -1,10 +1,10 @@
1
- import{v as M,c5 as G,r as D,c7 as J,ag as V,c9 as H,j as e,de as K,w as v,u as Y,dX as q,bd as o,c as Q,T as W,B as X,bo as P,R as S,aN as A,bf as Z}from"./index-UOt3vExk.js";import{D as ee}from"./download-csv-button-r9hq7Mun.js";import{T as ne}from"./Table-c1ug6Rpw.js";/**
2
- * @license lucide-react v0.548.0 - ISC
1
+ import{v as M,c5 as G,r as D,c7 as J,ag as V,c9 as H,j as e,de as K,w as v,u as Y,dX as q,bd as o,c as Q,T as W,B as X,bo as P,R as S,aN as A,bf as Z}from"./index-Bn7IEPHV.js";import{D as ee}from"./download-csv-button-gUEYkLnA.js";import{T as ne}from"./Table-x3b8wkFT.js";/**
2
+ * @license lucide-react v0.552.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
6
  */const te=[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"m17 7 5 5-5 5",key:"1xlxn0"}],["path",{d:"m7 7-5 5 5 5",key:"19njba"}],["path",{d:"M8 12h.01",key:"czm47f"}]],se=M("chevrons-left-right-ellipsis",te);/**
7
- * @license lucide-react v0.548.0 - ISC
7
+ * @license lucide-react v0.552.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
@@ -1 +1 @@
1
- import{G as l,j as e,az as t,w as m,bb as x}from"./index-UOt3vExk.js";import{B as o}from"./building-2-Dkd3B-3N.js";function h({data:n}){const s=l(x,n);if(!s||s.__typename!=="LtdFinancialEntity")return e.jsx("div",{});const{isActive:i,adminInfo:r,clientInfo:a}=s,d=!!r?.id,c=!!a?.id;return e.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border bg-card/95 backdrop-blur supports-[backdrop-filter]:bg-card/60",children:e.jsx("div",{className:"container mx-auto px-4 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs("div",{className:"flex h-16 items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-accent",children:e.jsx(o,{className:"h-5 w-5 text-accent-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:s.name}),i?e.jsx(t,{variant:"secondary",children:"Active"}):e.jsx(t,{variant:"destructive",children:"Inactive"}),d&&e.jsx(t,{variant:"outline",children:"Admin"}),c&&e.jsx(t,{variant:"outline",children:"Client"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["Business ID: ",s.id]})]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-6 text-sm",children:[s.governmentId&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"font-medium text-foreground",children:s.governmentId})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Since"}),e.jsx("p",{className:"font-medium text-foreground",children:m(s.createdAt,"MMM yyyy")})]})]})]})})})}export{h as B};
1
+ import{G as l,j as e,az as t,w as m,bb as x}from"./index-Bn7IEPHV.js";import{B as o}from"./building-2-DRzzSI-s.js";function h({data:n}){const s=l(x,n);if(!s||s.__typename!=="LtdFinancialEntity")return e.jsx("div",{});const{isActive:i,adminInfo:r,clientInfo:a}=s,d=!!r?.id,c=!!a?.id;return e.jsx("header",{className:"sticky top-0 z-50 w-full border-b border-border bg-card/95 backdrop-blur supports-[backdrop-filter]:bg-card/60",children:e.jsx("div",{className:"container mx-auto px-4 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs("div",{className:"flex h-16 items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[e.jsx("div",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-accent",children:e.jsx(o,{className:"h-5 w-5 text-accent-foreground"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:s.name}),i?e.jsx(t,{variant:"secondary",children:"Active"}):e.jsx(t,{variant:"destructive",children:"Inactive"}),d&&e.jsx(t,{variant:"outline",children:"Admin"}),c&&e.jsx(t,{variant:"outline",children:"Client"})]}),e.jsxs("p",{className:"text-sm text-muted-foreground truncate",children:["Business ID: ",s.id]})]})]}),e.jsxs("div",{className:"hidden md:flex items-center gap-6 text-sm",children:[s.governmentId&&e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Tax ID"}),e.jsx("p",{className:"font-medium text-foreground",children:s.governmentId})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-muted-foreground",children:"Since"}),e.jsx("p",{className:"font-medium text-foreground",children:m(s.createdAt,"MMM yyyy")})]})]})]})})})}export{h as B};
@@ -1 +1 @@
1
- import{r as x,bg as y,j as e,bh as C,B as S,y as I,bi as F,ad as B,bj as m,bk as v,bl as j,w as f,bm as E,bn as w}from"./index-UOt3vExk.js";import{u as N}from"./use-url-query-90MrwS1C.js";import{P as L}from"./modal-CqL_DX_G.js";import{F as R}from"./funnel-DlU6IKDd.js";import{M as D}from"./MultiSelect-DP26KzMa.js";function A({filter:r,setFilter:b,closeModal:u,single:l=!1}){const{control:a,handleSubmit:p}=I({defaultValues:{...r}}),{selectableBusinesses:d,fetching:i}=F(),{userContext:g}=x.useContext(B),h=s=>{b(s),u()};function o(){b({businessIDs:l?r.businessIDs:void 0}),u()}return e.jsxs(e.Fragment,{children:[i?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:p(h),children:[e.jsx(m,{name:"ownerIds",control:a,defaultValue:r.ownerIds,render:({field:s,fieldState:n})=>e.jsx(D,{...s,data:d,value:s.value??(g?.context.adminBusinessId?[g.context.adminBusinessId]:void 0),disabled:i,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),!l&&e.jsx(m,{name:"businessIDs",control:a,defaultValue:r.businessIDs,render:({field:s,fieldState:n})=>e.jsx(D,{...s,data:d,value:s.value??void 0,disabled:i,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),e.jsx(m,{name:"fromDate",control:a,defaultValue:r.fromDate,rules:{pattern:{value:v,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"toDate",control:a,defaultValue:r.toDate,rules:{pattern:{value:v,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"type",control:a,defaultValue:null,render:({field:s,fieldState:n})=>e.jsx(E,{...s,onChange:t=>s.onChange(t==="NULL"?null:t),data:[{value:"NULL",label:"All"},{value:"BUSINESS",label:"Business"},{value:"TAX_CATEGORY",label:"Tax Category"}],error:n.error?.message,label:"Type"})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",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:o,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:u,children:"Cancel"})]})]})]})}function O({filter:r,setFilter:b}){const[u,l]=x.useState(!1),[a,p]=x.useState(!y(r)),{get:d,set:i}=N();function g(o){return Object.entries(o??{}).filter(([n,t])=>t!==void 0&&Array.isArray(t)&&t.length>0).length>0}function h(o){o.fromDate?.trim()===""&&(o.fromDate=void 0),o.toDate?.trim()===""&&(o.toDate=void 0),w(o,r)||(b(o),p(g(o)))}return x.useEffect(()=>{const o=y(r)?null:encodeURIComponent(JSON.stringify(r)),s=d("ledgerRecordsFilters");o!==s&&i("ledgerRecordsFilters",o)},[r,d,i]),e.jsxs(e.Fragment,{children:[e.jsx(L,{opened:u,onClose:()=>l(!1),content:e.jsx(A,{single:!0,filter:r,setFilter:h,closeModal:()=>l(!1)})}),e.jsx(C,{inline:!0,size:16,disabled:!a,children:e.jsx(S,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:e.jsx(R,{className:"size-5"})})})]})}export{O as B};
1
+ import{r as x,bg as y,j as e,bh as C,B as S,y as I,bi as F,ad as B,bj as m,bk as v,bl as j,w as f,bm as E,bn as w}from"./index-Bn7IEPHV.js";import{u as N}from"./use-url-query-CbV37ELv.js";import{P as L}from"./modal-DkGVozcN.js";import{F as R}from"./funnel-B5QD_sUF.js";import{M as D}from"./MultiSelect-pA_gFLBj.js";function A({filter:r,setFilter:b,closeModal:u,single:l=!1}){const{control:a,handleSubmit:p}=I({defaultValues:{...r}}),{selectableBusinesses:d,fetching:i}=F(),{userContext:g}=x.useContext(B),h=s=>{b(s),u()};function o(){b({businessIDs:l?r.businessIDs:void 0}),u()}return e.jsxs(e.Fragment,{children:[i?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:p(h),children:[e.jsx(m,{name:"ownerIds",control:a,defaultValue:r.ownerIds,render:({field:s,fieldState:n})=>e.jsx(D,{...s,data:d,value:s.value??(g?.context.adminBusinessId?[g.context.adminBusinessId]:void 0),disabled:i,label:"Owners",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),!l&&e.jsx(m,{name:"businessIDs",control:a,defaultValue:r.businessIDs,render:({field:s,fieldState:n})=>e.jsx(D,{...s,data:d,value:s.value??void 0,disabled:i,label:"Businesses",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:n.error?.message})}),e.jsx(m,{name:"fromDate",control:a,defaultValue:r.fromDate,rules:{pattern:{value:v,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"From Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"toDate",control:a,defaultValue:r.toDate,rules:{pattern:{value:v,message:"Date must be im format yyyy-mm-dd"}},render:({field:s,fieldState:n})=>e.jsx(j,{...s,onChange:t=>{const c=t?typeof t=="string"?t:f(t,"yyyy-MM-dd"):void 0;c!==s.value&&s.onChange(c)},value:s.value?new Date(s.value):void 0,error:n.error?.message,label:"To Date",popoverProps:{withinPortal:!0}})}),e.jsx(m,{name:"type",control:a,defaultValue:null,render:({field:s,fieldState:n})=>e.jsx(E,{...s,onChange:t=>s.onChange(t==="NULL"?null:t),data:[{value:"NULL",label:"All"},{value:"BUSINESS",label:"Business"},{value:"TAX_CATEGORY",label:"Tax Category"}],error:n.error?.message,label:"Type"})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",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:o,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:u,children:"Cancel"})]})]})]})}function O({filter:r,setFilter:b}){const[u,l]=x.useState(!1),[a,p]=x.useState(!y(r)),{get:d,set:i}=N();function g(o){return Object.entries(o??{}).filter(([n,t])=>t!==void 0&&Array.isArray(t)&&t.length>0).length>0}function h(o){o.fromDate?.trim()===""&&(o.fromDate=void 0),o.toDate?.trim()===""&&(o.toDate=void 0),w(o,r)||(b(o),p(g(o)))}return x.useEffect(()=>{const o=y(r)?null:encodeURIComponent(JSON.stringify(r)),s=d("ledgerRecordsFilters");o!==s&&i("ledgerRecordsFilters",o)},[r,d,i]),e.jsxs(e.Fragment,{children:[e.jsx(L,{opened:u,onClose:()=>l(!1),content:e.jsx(A,{single:!0,filter:r,setFilter:h,closeModal:()=>l(!1)})}),e.jsx(C,{inline:!0,size:16,disabled:!a,children:e.jsx(S,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>l(!0),children:e.jsx(R,{className:"size-5"})})})]})}export{O as B};
@@ -1 +1 @@
1
- import{a as S,r as c,F as w,u as C,j as n,c as x,bd as o,be as y}from"./index-UOt3vExk.js";import{u as h}from"./use-url-query-90MrwS1C.js";import{a as F}from"./accounter-table-C7UgjlTA.js";import{M as p,B as R}from"./business-extended-info-B4Wt-Sq3.js";import{B as v}from"./business-ledger-filters-ByAYFfgh.js";import"./Table-c1ug6Rpw.js";import"./download-csv-button-r9hq7Mun.js";import"./modal-CqL_DX_G.js";import"./funnel-DlU6IKDd.js";import"./MultiSelect-DP26KzMa.js";const M=({businessId:t})=>{const{businessId:r}=S(),{get:s}=h(),{setFiltersContext:u}=c.useContext(w),l=t||r,[m,d]=c.useState(s("ledgerRecordsFilters")?{...JSON.parse(decodeURIComponent(s("ledgerRecordsFilters"))),businessIDs:l?[l]:[]}:{businessIDs:l?[l]:[]}),[{data:a,fetching:f}]=C({query:y,variables:{filters:m}});c.useEffect(()=>{u(n.jsx(v,{filter:m,setFilter:d}))},[a,m,u,d]);const b=c.useMemo(()=>a?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:a?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?a.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((e,g)=>e.business.name.localeCompare(g.business.name)):[],[a?.businessTransactionsSumFromLedgerRecords]);return f?n.jsx(x,{}):n.jsx(F,{moreInfo:e=>n.jsx(R,{businessID:e.business.id,filter:m}),striped:!0,highlightOnHover:!0,stickyHeader:!0,items:b,columns:[{title:"Business Name",value:e=>e.business.name},{title:"Debit",value:e=>e.debit.formatted,style:{whiteSpace:"nowrap"}},{title:"Credit",value:e=>e.credit.formatted,style:{whiteSpace:"nowrap"}},{title:"Total",value:e=>e.total.raw&&(e.total.raw<-1e-4||e.total.raw>1e-4)?n.jsx(p,{color:e.total.raw>0?"green":"red",children:e.total.formatted}):e.total.formatted,style:{whiteSpace:"nowrap"}},...i(o.Eur),...i(o.Usd),...i(o.Gbp),...i(o.Cad),...i(o.Jpy),...i(o.Aud),...i(o.Sek)]})};function i(t){return[{title:`${t} Debit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.debit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Credit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.credit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:r=>{const s=r.foreignCurrenciesSum.find(u=>u.currency===t);return s?.total?.raw&&(s.total.raw<-1e-4||s.total.raw>1e-4)?n.jsx(p,{color:s.total.raw>0?"green":"red",children:s.total.formatted}):s?.total?.formatted},style:{whiteSpace:"nowrap"}}]}export{M as BusinessLedgerRecordsSingle};
1
+ import{a as S,r as c,F as w,u as C,j as n,c as x,bd as o,be as y}from"./index-Bn7IEPHV.js";import{u as h}from"./use-url-query-CbV37ELv.js";import{a as F}from"./accounter-table-Bzhu1KyK.js";import{M as p,B as R}from"./business-extended-info-kcznxGFW.js";import{B as v}from"./business-ledger-filters-DZnTpjrX.js";import"./Table-x3b8wkFT.js";import"./download-csv-button-gUEYkLnA.js";import"./modal-DkGVozcN.js";import"./funnel-B5QD_sUF.js";import"./MultiSelect-pA_gFLBj.js";const M=({businessId:t})=>{const{businessId:r}=S(),{get:s}=h(),{setFiltersContext:u}=c.useContext(w),l=t||r,[m,d]=c.useState(s("ledgerRecordsFilters")?{...JSON.parse(decodeURIComponent(s("ledgerRecordsFilters"))),businessIDs:l?[l]:[]}:{businessIDs:l?[l]:[]}),[{data:a,fetching:f}]=C({query:y,variables:{filters:m}});c.useEffect(()=>{u(n.jsx(v,{filter:m,setFilter:d}))},[a,m,u,d]);const b=c.useMemo(()=>a?.businessTransactionsSumFromLedgerRecords.__typename==="CommonError"?[]:a?.businessTransactionsSumFromLedgerRecords.businessTransactionsSum?a.businessTransactionsSumFromLedgerRecords.businessTransactionsSum.sort((e,g)=>e.business.name.localeCompare(g.business.name)):[],[a?.businessTransactionsSumFromLedgerRecords]);return f?n.jsx(x,{}):n.jsx(F,{moreInfo:e=>n.jsx(R,{businessID:e.business.id,filter:m}),striped:!0,highlightOnHover:!0,stickyHeader:!0,items:b,columns:[{title:"Business Name",value:e=>e.business.name},{title:"Debit",value:e=>e.debit.formatted,style:{whiteSpace:"nowrap"}},{title:"Credit",value:e=>e.credit.formatted,style:{whiteSpace:"nowrap"}},{title:"Total",value:e=>e.total.raw&&(e.total.raw<-1e-4||e.total.raw>1e-4)?n.jsx(p,{color:e.total.raw>0?"green":"red",children:e.total.formatted}):e.total.formatted,style:{whiteSpace:"nowrap"}},...i(o.Eur),...i(o.Usd),...i(o.Gbp),...i(o.Cad),...i(o.Jpy),...i(o.Aud),...i(o.Sek)]})};function i(t){return[{title:`${t} Debit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.debit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Credit`,value:r=>r.foreignCurrenciesSum.find(s=>s.currency===t)?.credit?.formatted,style:{whiteSpace:"nowrap"}},{title:`${t} Total`,value:r=>{const s=r.foreignCurrenciesSum.find(u=>u.currency===t);return s?.total?.raw&&(s.total.raw<-1e-4||s.total.raw>1e-4)?n.jsx(p,{color:s.total.raw>0?"green":"red",children:s.total.formatted}):s?.total?.formatted},style:{whiteSpace:"nowrap"}}]}export{M as BusinessLedgerRecordsSingle};
@@ -1 +1 @@
1
- import{a as p,r as n,F as u,u as m,j as s,c,c4 as x}from"./index-UOt3vExk.js";import{P as d,C as l,E as f}from"./editable-business-trip-BCj8haJN.js";import{P as T}from"./page-layout-DfZJtWW1.js";import"./list-plus-CYtq--On.js";import"./summary-BuSv6nwb.js";import"./Table-c1ug6Rpw.js";import"./toggle-expansion-button-CojtDNtC.js";import"./panel-top-open-D0lkFvhk.js";import"./MultiSelect-DP26KzMa.js";import"./similar-transactions-modal-kFlTMg9C.js";import"./tooltip-CoQF2skM.js";const v=({businessTripId:o})=>{const{businessTripId:a}=p(),{setFiltersContext:i}=n.useContext(u),e=o??a??"",[{data:r,fetching:t}]=m({query:x,variables:{businessTripId:e}});return n.useEffect(()=>{i(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(d,{filename:"business_trip_report"})}))},[r,t,i]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(T,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(f,{tripId:e,isExtended:!0})})})};export{v as BusinessTrip};
1
+ import{a as p,r as n,F as u,u as m,j as s,c,c4 as x}from"./index-Bn7IEPHV.js";import{P as d,C as l,E as f}from"./editable-business-trip-BP1JS8k9.js";import{P as T}from"./page-layout-QRk5gzBF.js";import"./list-plus-CqwiCMO8.js";import"./summary-Dm_FUd-t.js";import"./Table-x3b8wkFT.js";import"./toggle-expansion-button-BUAVmBSl.js";import"./panel-top-open-C3IsjKjM.js";import"./MultiSelect-pA_gFLBj.js";import"./similar-transactions-modal--mkXZQzE.js";import"./tooltip-CCRs753Z.js";const v=({businessTripId:o})=>{const{businessTripId:a}=p(),{setFiltersContext:i}=n.useContext(u),e=o??a??"",[{data:r,fetching:t}]=m({query:x,variables:{businessTripId:e}});return n.useEffect(()=>{i(s.jsx("div",{className:"flex flex-row gap-x-5",children:s.jsx(d,{filename:"business_trip_report"})}))},[r,t,i]),t||!r?.businessTrip?s.jsx(c,{}):s.jsx(T,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(f,{tripId:e,isExtended:!0})})})};export{v as BusinessTrip};
@@ -1 +1 @@
1
- import{a as I,b as x,r,u as D,j as e,c as f,C as j}from"./index-UOt3vExk.js";import{C as v}from"./charges-table-Cw-X1ZkK.js";import{E as M,I as E,M as S}from"./match-document-modal-Bs-5Zbj9.js";import"./toggle-expansion-button-CojtDNtC.js";import"./panel-top-open-D0lkFvhk.js";import"./index-Dzi5mI80.js";import"./similar-transactions-modal-kFlTMg9C.js";import"./addDays-CB-j-d4t.js";import"./list-plus-CYtq--On.js";import"./tooltip-CoQF2skM.js";import"./Table-c1ug6Rpw.js";import"./summary-BuSv6nwb.js";import"./YearPickerInput-CNSe9Fno.js";import"./insert-business-trip-modal-DyHAvuG6.js";import"./accounter-table-C7UgjlTA.js";import"./modal-CqL_DX_G.js";const G=({chargeId:u})=>{const{chargeId:g}=I(),a=u||g;let t;try{t=x()}catch{}const[o,n]=r.useState(void 0),[s,i]=r.useState(void 0),[c,d]=r.useState(void 0),[{data:p,fetching:l},m]=D({query:j,pause:!a||!!t,variables:{chargeId:a??""}});r.useEffect(()=>{a&&!t&&m()},[a,t,m]);const h=t||p,C=!t&&l;return a?e.jsxs(e.Fragment,{children:[C?e.jsx(f,{}):e.jsx(v,{setEditChargeId:n,setInsertDocument:i,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),o&&e.jsx(M,{chargeId:o?.id,close:()=>n(void 0),onChange:o.onChange}),s&&e.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>i(void 0)}),c&&e.jsx(S,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>d(void 0)})]}):e.jsx("div",{children:"Charge not found"})};export{G as Charge};
1
+ import{a as I,b as x,r,u as D,j as e,c as f,C as j}from"./index-Bn7IEPHV.js";import{C as v}from"./charges-table-DAO5k4Bj.js";import{E as M,I as E,M as S}from"./match-document-modal-Buzom-Fk.js";import"./toggle-expansion-button-BUAVmBSl.js";import"./panel-top-open-C3IsjKjM.js";import"./index-DItleVvH.js";import"./similar-transactions-modal--mkXZQzE.js";import"./addDays-DldjqWfe.js";import"./list-plus-CqwiCMO8.js";import"./tooltip-CCRs753Z.js";import"./Table-x3b8wkFT.js";import"./summary-Dm_FUd-t.js";import"./YearPickerInput-CF-aCG1y.js";import"./insert-business-trip-modal-B8m5Xa9k.js";import"./accounter-table-Bzhu1KyK.js";import"./modal-DkGVozcN.js";const G=({chargeId:u})=>{const{chargeId:g}=I(),a=u||g;let t;try{t=x()}catch{}const[o,n]=r.useState(void 0),[s,i]=r.useState(void 0),[c,d]=r.useState(void 0),[{data:p,fetching:l},m]=D({query:j,pause:!a||!!t,variables:{chargeId:a??""}});r.useEffect(()=>{a&&!t&&m()},[a,t,m]);const h=t||p,C=!t&&l;return a?e.jsxs(e.Fragment,{children:[C?e.jsx(f,{}):e.jsx(v,{setEditChargeId:n,setInsertDocument:i,setMatchDocuments:d,data:h?.charge?[h.charge]:[],isAllOpened:!0}),o&&e.jsx(M,{chargeId:o?.id,close:()=>n(void 0),onChange:o.onChange}),s&&e.jsx(E,{chargeId:s.id,onChange:s.onChange,close:()=>i(void 0)}),c&&e.jsx(S,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>d(void 0)})]}):e.jsx("div",{children:"Charge not found"})};export{G as Charge};
@@ -1 +1 @@
1
- import{r as i,bg as B,bn as R,j as e,P as W,bh as z,B as G,ad as U,y as _,w as N,af as D,dg as X,ap as q,V as J,dh as Q,bj as h,eh as Y,bk as P,bl as O,bm as L,e8 as A,am as m,hc as Z,a1 as K,X as x,Y as j,Z as p,_ as g,bG as $,bH as ee,bI as se}from"./index-UOt3vExk.js";import{u as ae}from"./use-url-query-90MrwS1C.js";import{P as te}from"./modal-CqL_DX_G.js";import{F as ne}from"./funnel-DlU6IKDd.js";import{s as oe}from"./sub-BKVGhLrr.js";import{M as k}from"./MultiSelect-DP26KzMa.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:A.All},{label:"Income",value:A.Income},{label:"Expense",value:A.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:b}=i.useContext(U),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}=X(),{selectableTags:v,fetching:I}=q(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const V=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(J,{...o,children:e.jsxs("form",{onSubmit:T(V),children:[e.jsxs(Q,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(k,{...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(k,{...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(k,{...s,data:v,itemComponent:Y,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,M)=>M.label?.toLowerCase().includes(r.toLowerCase().trim())||M.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:P,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:P,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(L,{...s,data:ce,value:s.value??A.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(L,{...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(k,{...s,value:s.value??[],data:Z,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(K,{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>1?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(1))},[a,c,u,b]);const S=i.useCallback(t=>{R(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(W,{className:"flex-fit w-fit mx-0",value:d,onChange:b,total:o}),e.jsx(z,{inline:!0,size:16,disabled:!y,children:e.jsx(G,{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,bg as B,bn as R,j as e,P as W,bh as z,B as G,ad as U,y as _,w as N,af as D,dg as X,ap as q,V as J,dh as Q,bj as h,eh as Y,bk as P,bl as O,bm as L,e8 as A,am as m,hc as Z,a1 as K,X as x,Y as j,Z as p,_ as g,bG as $,bH as ee,bI as se}from"./index-Bn7IEPHV.js";import{u as ae}from"./use-url-query-CbV37ELv.js";import{P as te}from"./modal-DkGVozcN.js";import{F as ne}from"./funnel-B5QD_sUF.js";import{s as oe}from"./sub-M6JLC8qJ.js";import{M as k}from"./MultiSelect-pA_gFLBj.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:A.All},{label:"Income",value:A.Income},{label:"Expense",value:A.Expense}];function ie({filter:a,setFilter:w,closeModal:d}){const{userContext:b}=i.useContext(U),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}=X(),{selectableTags:v,fetching:I}=q(),E=C("sortBy.field");i.useEffect(()=>{E&&!c?u(!0):!E&&c&&u(!1)},[E,c]);const V=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(J,{...o,children:e.jsxs("form",{onSubmit:T(V),children:[e.jsxs(Q,{cols:2,children:[e.jsx(h,{name:"byOwners",control:l,defaultValue:a.byOwners,render:({field:s,fieldState:n})=>e.jsx(k,{...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(k,{...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(k,{...s,data:v,itemComponent:Y,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,M)=>M.label?.toLowerCase().includes(r.toLowerCase().trim())||M.description?.toLowerCase().includes(r.toLowerCase().trim())})}),e.jsx(h,{name:"fromAnyDate",control:l,defaultValue:a.fromAnyDate,rules:{pattern:{value:P,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:P,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(L,{...s,data:ce,value:s.value??A.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(L,{...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(k,{...s,value:s.value??[],data:Z,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(K,{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>1?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(1))},[a,c,u,b]);const S=i.useCallback(t=>{R(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(W,{className:"flex-fit w-fit mx-0",value:d,onChange:b,total:o}),e.jsx(z,{inline:!0,size:16,disabled:!y,children:e.jsx(G,{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 b,e as z,f as W}from"./index-UOt3vExk.js";import{u as O}from"./use-url-query-90MrwS1C.js";import{C as k}from"./charges-filters-CUyYbpwk.js";import{C as B,T as R}from"./charges-table-Cw-X1ZkK.js";import{M as V}from"./index-CS2mkstk.js";import{E as A,I as Q,M as U}from"./match-document-modal-Bs-5Zbj9.js";import{P as q}from"./page-layout-DfZJtWW1.js";import{P as J}from"./Progress-C3jVWDXK.js";import{P as $,a as G}from"./panel-top-open-D0lkFvhk.js";import"./modal-CqL_DX_G.js";import"./funnel-DlU6IKDd.js";import"./sub-BKVGhLrr.js";import"./addDays-CB-j-d4t.js";import"./subMonths-Cbkj4M6-.js";import"./MultiSelect-DP26KzMa.js";import"./toggle-expansion-button-CojtDNtC.js";import"./index-Dzi5mI80.js";import"./similar-transactions-modal-kFlTMg9C.js";import"./list-plus-CYtq--On.js";import"./tooltip-CoQF2skM.js";import"./Table-c1ug6Rpw.js";import"./summary-BuSv6nwb.js";import"./Checkbox-CMTNcrRo.js";import"./YearPickerInput-CNSe9Fno.js";import"./insert-business-trip-modal-DyHAvuG6.js";import"./accounter-table-C7UgjlTA.js";const Me=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[l,x]=t.useState(void 0),[c,C]=t.useState(void 0),[g,f]=t.useState(!1),[r,d]=t.useState([]),{get:F}=O(),m=F("chargesFilters"),I=t.useMemo(()=>{if(m)try{return JSON.parse(decodeURIComponent(m))}catch{return}},[m]),[o,j]=t.useState(I),S=t.useCallback((s,y)=>{r.map(h=>h.id).includes(s)?d(r.filter(h=>h.id!==s)):d([...r,{id:s,onChange:y}])},[r]),[{data:a,fetching:M},v]=E({query:W,variables:{filters:o},pause:!0});function P(){d([])}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:1,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{label:"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(V,{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(B,{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(b,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(R,{radius:"xl",size:"xl",color:"green",children:e.jsx(z,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),l&&e.jsx(Q,{chargeId:l.id,onChange:l.onChange,close:()=>x(void 0)}),c&&e.jsx(U,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Me 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 b,e as z,f as W}from"./index-Bn7IEPHV.js";import{u as O}from"./use-url-query-CbV37ELv.js";import{C as k}from"./charges-filters-DzWxzt2a.js";import{C as B,T as R}from"./charges-table-DAO5k4Bj.js";import{M as V}from"./index-DlSfhUOv.js";import{E as A,I as Q,M as U}from"./match-document-modal-Buzom-Fk.js";import{P as q}from"./page-layout-QRk5gzBF.js";import{P as J}from"./Progress-P37eknhY.js";import{P as $,a as G}from"./panel-top-open-C3IsjKjM.js";import"./modal-DkGVozcN.js";import"./funnel-B5QD_sUF.js";import"./sub-M6JLC8qJ.js";import"./addDays-DldjqWfe.js";import"./subMonths-Ct7ldZ6v.js";import"./MultiSelect-pA_gFLBj.js";import"./toggle-expansion-button-BUAVmBSl.js";import"./index-DItleVvH.js";import"./similar-transactions-modal--mkXZQzE.js";import"./list-plus-CqwiCMO8.js";import"./tooltip-CCRs753Z.js";import"./Table-x3b8wkFT.js";import"./summary-Dm_FUd-t.js";import"./Checkbox-EjZjNgQc.js";import"./YearPickerInput-CF-aCG1y.js";import"./insert-business-trip-modal-B8m5Xa9k.js";import"./accounter-table-Bzhu1KyK.js";const Me=()=>{const{setFiltersContext:p}=t.useContext(D),[n,u]=t.useState(void 0),[l,x]=t.useState(void 0),[c,C]=t.useState(void 0),[g,f]=t.useState(!1),[r,d]=t.useState([]),{get:F}=O(),m=F("chargesFilters"),I=t.useMemo(()=>{if(m)try{return JSON.parse(decodeURIComponent(m))}catch{return}},[m]),[o,j]=t.useState(I),S=t.useCallback((s,y)=>{r.map(h=>h.id).includes(s)?d(r.filter(h=>h.id!==s)):d([...r,{id:s,onChange:y}])},[r]),[{data:a,fetching:M},v]=E({query:W,variables:{filters:o},pause:!0});function P(){d([])}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:1,setPage:()=>{},initiallyOpened:!0}),e.jsx(N,{label:"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(V,{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(B,{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(b,{}),i===100&&!a?.chargesWithLedgerChanges.filter(s=>!!s.charge).length&&e.jsx(R,{radius:"xl",size:"xl",color:"green",children:e.jsx(z,{})})]})]}),n&&e.jsx(A,{chargeId:n?.id,close:()=>u(void 0),onChange:n.onChange}),l&&e.jsx(Q,{chargeId:l.id,onChange:l.onChange,close:()=>x(void 0)}),c&&e.jsx(U,{chargeId:c.id,ownerId:c.ownerId,setMatchDocuments:()=>C(void 0)})]})};export{Me as ChargesLedgerValidation};