@accounter/client 0.0.8-alpha-20251029152834-4e95d9a4cd7f292ec1789163f46763388b63a377 → 0.0.8-alpha-20251029232510-4bc0c8b8c08a26f0c27788725ae584e515236d20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1 -1
- package/dist/assets/{Checkbox-qIwbw1Vm.js → Checkbox-Cmx4P-eR.js} +2 -2
- package/dist/assets/{MultiSelect-Uj0K1auE.js → MultiSelect-tfWMeMsf.js} +1 -1
- package/dist/assets/{Pagination-D9TkQfLt.js → Pagination-p2BVFuhf.js} +1 -1
- package/dist/assets/{Progress-lLgzD5SX.js → Progress-BwoJerOb.js} +1 -1
- package/dist/assets/{Table-Cr3nIx5M.js → Table-Cve82Lq5.js} +1 -1
- package/dist/assets/{Typography-D8eUZCfX.js → Typography-CAgQOS4U.js} +1 -1
- package/dist/assets/{YearPickerInput-BdNLRDw_.js → YearPickerInput-BPVLgEAY.js} +1 -1
- package/dist/assets/{accordion-DwkOqBRF.js → accordion-Ca5XgpUz.js} +1 -1
- package/dist/assets/accountant-approvals-BXTzXE96.js +1 -0
- package/dist/assets/{accounter-table-R92v4QWf.js → accounter-table-CBlUbpQl.js} +1 -1
- package/dist/assets/{addDays-CHr5nY3e.js → addDays-ClGDfhvI.js} +1 -1
- package/dist/assets/{all-charges-DVKRQLII.js → all-charges-DV7V8QJ6.js} +1 -1
- package/dist/assets/{arrow-up-down-CTxePA5K.js → arrow-up-down-DMdWvrmz.js} +1 -1
- package/dist/assets/{building-2-B6TvGHom.js → building-2-Y3dys8Pf.js} +1 -1
- package/dist/assets/business-CRd0ns94.js +37 -0
- package/dist/assets/{business-extended-info-tkrkodR7.js → business-extended-info-BKVk3weU.js} +2 -2
- package/dist/assets/{business-header-Dx4N1uVn.js → business-header-S5R7Fq8P.js} +1 -1
- package/dist/assets/{business-ledger-filters-GmMxns0y.js → business-ledger-filters-C_x4y5uJ.js} +1 -1
- package/dist/assets/{business-ledger-single-BeO0VVgy.js → business-ledger-single-Dku8gbU9.js} +1 -1
- package/dist/assets/business-trip-CB51p6xt.js +1 -0
- package/dist/assets/{charge-DPnVzmY7.js → charge-C79C95t6.js} +1 -1
- package/dist/assets/{charges-filters-BSbPgdun.js → charges-filters-RFRXF1Oa.js} +1 -1
- package/dist/assets/{charges-ledger-validation-zkS0soMY.js → charges-ledger-validation-DTglElRA.js} +1 -1
- package/dist/assets/{charges-table-BIpECr1x.js → charges-table-D3WwcB50.js} +7 -7
- package/dist/assets/{chart-Caa1VlDy.js → chart-2MG3qLL8.js} +1 -1
- package/dist/assets/{data-table-pagination-psKhAMGL.js → data-table-pagination-Dhmbf7BR.js} +1 -1
- package/dist/assets/{download-csv-button-B1TMXv92.js → download-csv-button-BQSz29rY.js} +1 -1
- package/dist/assets/{editable-business-trip-CCy91YvH.js → editable-business-trip-BlqinsvU.js} +2 -2
- package/dist/assets/{funnel-DP2XBopJ.js → funnel-B2plvroD.js} +1 -1
- package/dist/assets/{index-BsxEk8Re.js → index--xgmdJzW.js} +1 -1
- package/dist/assets/{index-CvxMeW9Y.js → index-5R7-0kTp.js} +1 -1
- package/dist/assets/{index-lk_kdDxO.js → index-BRNnfzgV.js} +2 -2
- package/dist/assets/{index-D9OJexEV.js → index-BdRubi2c.js} +1 -1
- package/dist/assets/{index-CY-XVbUJ.js → index-BgLtHIxa.js} +1 -1
- package/dist/assets/{index-CV2QxRmK.js → index-Bs4RBq4h.js} +1 -1
- package/dist/assets/{index-PfXGaCrc.js → index-C0ZATVhv.js} +1 -1
- package/dist/assets/{index-xJNjwngg.js → index-C4gCwrJJ.js} +1 -1
- package/dist/assets/{index-fZcP3X7C.js → index-C6OmHOHr.js} +191 -191
- package/dist/assets/index-CIdZZL-X.js +1 -0
- package/dist/assets/{index-BfV_NJXM.js → index-CSEktEoZ.js} +7 -7
- package/dist/assets/{index-CDhroLKu.js → index-Cn4t95Q9.js} +1 -1
- package/dist/assets/{index-dsDfIa4Y.js → index-Csdsjvrl.js} +2 -2
- package/dist/assets/{index-4ge3Am6D.js → index-DA3Ccstm.js} +1 -1
- package/dist/assets/{index-CdGH-wdf.js → index-DKZGNBg3.js} +2 -2
- package/dist/assets/{index-BiaDwWnW.js → index-DZ6Bqs7R.js} +1 -1
- package/dist/assets/{index-CFIvwwkB.js → index-DemO-kJJ.js} +2 -2
- package/dist/assets/index-DhRIY5eN.js +1 -0
- package/dist/assets/{index-DtwTITCT.js → index-HG5RXBPG.js} +1 -1
- package/dist/assets/{index-CRuhKIVD.js → index-P9_YuS6e.js} +1 -1
- package/dist/assets/index-aEEtRfbo.js +1 -0
- package/dist/assets/{index-DjTdlXK_.js → index-arYAg9nt.js} +1 -1
- package/dist/assets/{index-PaMjwOfa.js → index-eIVAASqp.js} +1 -1
- package/dist/assets/index-nshyF-PE.js +6 -0
- package/dist/assets/{index-CeSVmmFv.js → index-qMYyjtmt.js} +1 -1
- package/dist/assets/{index.es-tIpBPUgx.js → index.es-BrfHJ6Yj.js} +1 -1
- package/dist/assets/{insert-business-trip-modal-qIM7A1Dw.js → insert-business-trip-modal-COXHjjIY.js} +2 -2
- package/dist/assets/issue-document-CBKTg1VC.js +1 -0
- package/dist/assets/{list-plus-ZIHrrCaO.js → list-plus-DbuCDPM8.js} +1 -1
- package/dist/assets/{login-page-z7UM7kNz.js → login-page-ChNFTZLU.js} +1 -1
- package/dist/assets/{match-document-modal-CpUhpMJc.js → match-document-modal-Cp2DKG3j.js} +4 -4
- package/dist/assets/{missing-info-charges-C1tPzMqU.js → missing-info-charges-IUzXIDY1.js} +1 -1
- package/dist/assets/{modal-B_jJz-4Z.js → modal-CCAYjiOC.js} +1 -1
- package/dist/assets/{page-layout-DUgx8eXl.js → page-layout-DpwpZHY3.js} +1 -1
- package/dist/assets/{page-not-found-D8UJ6_C9.js → page-not-found-NbOMK1Jv.js} +1 -1
- package/dist/assets/{panel-top-open-CcWXXds7.js → panel-top-open-CNX1-h4c.js} +1 -1
- package/dist/assets/{pencil-zApPUfTb.js → pencil-Z4i9z0vF.js} +1 -1
- package/dist/assets/{report-commentary-row-BonuPEAK.js → report-commentary-row-C4I-ATEX.js} +1 -1
- package/dist/assets/{save-tZoVFUtG.js → save-D0kOxdMh.js} +1 -1
- package/dist/assets/similar-transactions-modal-DgD48GZ2.js +1 -0
- package/dist/assets/{sub-zRppNrG0.js → sub-BAZr7Qdd.js} +1 -1
- package/dist/assets/subMonths-Df-03cZk.js +1 -0
- package/dist/assets/{summary-yiqSbK4V.js → summary-CkpRtdVA.js} +1 -1
- package/dist/assets/{toggle-expansion-button-pWLCCDmM.js → toggle-expansion-button-Babot8nj.js} +1 -1
- package/dist/assets/tooltip-DStdzzhK.js +1 -0
- package/dist/assets/{use-url-query-DyJg_rMw.js → use-url-query-BSUiacze.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/business/admin-business-section.tsx +299 -103
- package/src/gql/gql.ts +3 -3
- package/src/gql/graphql.ts +53 -17
- package/src/providers/index.ts +4 -0
- package/dist/assets/accountant-approvals-DX9vcA7l.js +0 -1
- package/dist/assets/business-CCLPxEIP.js +0 -37
- package/dist/assets/business-trip-D3REiwV6.js +0 -1
- package/dist/assets/index-8gQaTQhF.js +0 -6
- package/dist/assets/index-CLvGPwjT.js +0 -1
- package/dist/assets/index-CmRnzPuP.js +0 -1
- package/dist/assets/index-DkgLEg6I.js +0 -1
- package/dist/assets/issue-document-CAewRj6P.js +0 -1
- package/dist/assets/similar-transactions-modal-Cdv2FmQ8.js +0 -1
- package/dist/assets/subMonths-CLe-U48r.js +0 -1
- package/dist/assets/tooltip-r34BEIrK.js +0 -1
- package/src/providers/index.tsx +0 -56
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as a,F as h,a8 as v,aa as C,u as P,j as e,L as A,h9 as F}from"./index-fZcP3X7C.js";import{u as b}from"./use-url-query-DyJg_rMw.js";import{C as y}from"./charges-filters-BSbPgdun.js";import{P as j}from"./page-layout-DUgx8eXl.js";import{P as D}from"./Progress-lLgzD5SX.js";import"./modal-B_jJz-4Z.js";import"./Pagination-D9TkQfLt.js";import"./create-event-handler-BiA-1lGu.js";import"./funnel-DP2XBopJ.js";import"./sub-zRppNrG0.js";import"./addDays-CHr5nY3e.js";import"./subMonths-CLe-U48r.js";import"./MultiSelect-Uj0K1auE.js";const T=()=>{const{setFiltersContext:i}=a.useContext(h),{get:c}=b(),{userContext:p}=a.useContext(v),[s,m]=a.useState(c("chargesFilters")?JSON.parse(decodeURIComponent(c("chargesFilters"))):{byOwners:p?.context.adminBusinessId?[p?.context.adminBusinessId]:[],sortBy:{field:C.Date,asc:!1},toAnyDate:null,fromAnyDate:null}),[{data:r,fetching:u}]=P({query:F,variables:{filters:s,page:1,limit:999999}}),t=r?.allCharges?.nodes.length??0;let o=0,l=0,n=0;r?.allCharges?.nodes.map(f=>{switch(f.accountantApproval){case"APPROVED":o+=1;break;case"PENDING":l+=1;break;case"UNAPPROVED":n+=1;break}});const x=100*o/t,d=100*l/t,g=100*n/t;return a.useEffect(()=>{i(e.jsx("div",{className:"flex flex-row gap-x-5",children:e.jsx(y,{filter:s,setFilter:m,activePage:1,setPage:()=>{},totalPages:1})}))},[r,u,s,i,m]),e.jsx(j,{title:"Accountant Approvals Status",children:u?e.jsx(A,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsxs("div",{className:"mx-10 mt-5 flex flex-col gap-5",children:[`Total charges: ${t}`,e.jsx(D,{color:"green",radius:"xl",size:"xl",sections:[{value:x,color:"green",label:`${x.toFixed(1)}% (${o})`},{value:d,color:"orange",label:`${d.toFixed(1)}% (${l})`},{value:g,color:"red",label:`${g.toFixed(1)}% (${n})`}]})]})})};export{T as AccountantApprovals};
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import{v as se,w as be,S as Se,x as pe,u as te,y as Rs,r as b,j as e,D as Ge,z as We,E as Ms,c as ps,g as Ie,t as M,i as De,U as $s,G as Te,H as Ke,J as Ce,K as z,N as q,O as js,P as G,Q as W,V as Be,W as K,X as j,Y as g,Z as f,_ as N,I as T,$ as k,a0 as C,a1 as re,a2 as He,B as P,a3 as Us,a4 as Xe,a5 as Je,a6 as _,a7 as gs,a8 as Qe,a9 as zs,aa as qs,ab as V,ac as ts,ad as Gs,ae as Ws,af as Ks,ag as ee,ah as Q,ai as Hs,aj as Xs,ak as Js,al as Ve,am as je,an as ge,ao as fe,ap as ve,aq as Qs,ar as ye,as as Ys,at as Zs,au as Y,av as Z,aw as le,ax as et,ay as st,az as _e,aA as Re,aB as fs,aC as tt,aD as Me,aE as nt,aF as $e,aG as vs,aH as ns,aI as ys,aJ as at,aK as it,aL as Ye,aM as Ns,aN as Ze,aO as bs,aP as Cs,aQ as ws,aR as ks,aS as Ss,aT as As,aU as rt,aV as ue,aW as lt,aX as as,aY as ct,aZ as ot,a_ as dt,a$ as mt,b0 as ut,b1 as ht,b2 as xt,b3 as pt,b4 as A,b5 as jt,b6 as es,b7 as gt,b8 as ft,b9 as vt,ba as yt,bb as Nt,F as bt,bc as Ct,bd as wt,be as H,bf as kt,bg as St,bh as $,bi as At,a as It,b as Dt,bj as Tt}from"./index-fZcP3X7C.js";import{S as ss}from"./save-tZoVFUtG.js";import{B as Bt}from"./business-extended-info-tkrkodR7.js";import{B as Et}from"./business-header-Dx4N1uVn.js";import{S as Pt,C as Lt,L as Ot}from"./charges-table-BIpECr1x.js";import{P as Ft}from"./Pagination-D9TkQfLt.js";import{i as Vt,D as _t,f as Rt,E as Mt,L as Pe,a as we,C as $t,A as Ut,b as he,c as zt,d as Ue,h as qt,e as Gt,g as Is,u as Wt,G as Kt,j as is,k as Ht,X as Ds,Y as Ts,l as Xt,m as Jt,R as Qt,n as Yt,o as Zt,p as en}from"./chart-Caa1VlDy.js";import{P as sn}from"./pencil-zApPUfTb.js";import{E as tn,T as nn}from"./index-8gQaTQhF.js";import{A as an,a as Le,b as Oe,c as rs}from"./accordion-DwkOqBRF.js";import{B as rn}from"./building-2-B6TvGHom.js";import"./download-csv-button-B1TMXv92.js";import"./Table-Cr3nIx5M.js";import"./toggle-expansion-button-pWLCCDmM.js";import"./panel-top-open-CcWXXds7.js";import"./summary-yiqSbK4V.js";import"./create-event-handler-BiA-1lGu.js";import"./list-plus-ZIHrrCaO.js";import"./sequential-CAnleQny.js";import"./similar-transactions-modal-Cdv2FmQ8.js";import"./addDays-CHr5nY3e.js";import"./tooltip-r34BEIrK.js";/**
|
|
2
|
-
* @license lucide-react v0.548.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const ln=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"m19 9-5 5-4-4-3 3",key:"2osh9i"}]],cn=se("chart-line",ln);/**
|
|
7
|
-
* @license lucide-react v0.548.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const on=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ls=se("circle-check",on);/**
|
|
12
|
-
* @license lucide-react v0.548.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const dn=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],ke=se("dollar-sign",dn);/**
|
|
17
|
-
* @license lucide-react v0.548.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const mn=[["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"}]],un=se("file-check",mn);/**
|
|
22
|
-
* @license lucide-react v0.548.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const hn=[["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"}]],xn=se("notebook",hn);/**
|
|
27
|
-
* @license lucide-react v0.548.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const pn=[["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"}]],jn=se("plug",pn);/**
|
|
32
|
-
* @license lucide-react v0.548.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const gn=[["path",{d:"M16 7h6v6",key:"box55l"}],["path",{d:"m22 7-8.5 8.5-5-5L2 17",key:"1t1m79"}]],Fe=se("trending-up",gn);function Bs(s){switch(s){case be.Annual:return"Annual";case be.Monthly:return"Monthly";default:throw new Error(`Unsupported Billing Cycle: ${s}`)}}function Es(s){switch(s){case Se.Enterprise:return"Enterprise";case Se.Pro:return"Pro";default:throw new Error(`Unsupported Subscription plan: ${s}`)}}function fn(s){return pe(s,"yyyy-MM-dd")}function vn({businessId:s,tagIds:t,description:n,open:a,onOpenChange:l,onClose:o}){const[{data:r,fetching:i},c]=te({pause:!0,query:Rs,variables:{businessId:s,tagsDifferentThan:t?t.map(h=>h.id):void 0,descriptionDifferentThan:n}});b.useEffect(()=>{a&&(t||n)&&!r&&c()},[a,t,n,c,r]);const d=b.useCallback(h=>{l(h),a&&!h&&o?.()},[l,o,a]),u=b.useMemo(()=>a&&(!!t||!!n)&&r&&r?.similarChargesByBusiness.length>0,[a,t,n,r]);return e.jsx(Ge,{open:u,onOpenChange:d,children:e.jsx(We,{className:"overflow-scroll max-h-screen w-full sm:max-w-[640px] md:max-w-[768px] lg:max-w-[900px]",onClick:h=>h.stopPropagation(),children:e.jsx(Ms,{fallback:e.jsx("div",{children:"Error fetching similar charges"}),children:i?e.jsx(ps,{}):t||n?e.jsx(Pt,{data:r?.similarChargesByBusiness??[],tagIds:t,description:n,onOpenChange:d,title:"Similar Charges by Business"}):null})})})}const yn="updateAdminBusiness",Nn=()=>{const[{fetching:s},t]=Ie($s),n=b.useCallback(async a=>{const l=`Error updating admin business ID [${a.adminBusinessId}]`,o=`${yn}-${a.adminBusinessId}`;M.loading("Updating admin business",{id:o});try{const r=await t(a),i=De(r,l,o,"updateAdminBusiness");if(i)return M.success("Success",{id:o,description:"Admin Business Updated"}),i.updateAdminBusiness}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateAdminBusiness:n}},bn=Xe({withholdingTaxBookNumber:_().min(1,{message:"Withholding Tax Book Number is required"}),withholdingTaxFileNumber:_().min(1,{message:"Withholding Tax File Number is required"}),socialSecurityEmployerId:_().min(1,{message:"National Insurance Employer ID is required"}),taxAdvancesRate:gs().min(0,{message:"Advance Tax Rate must be at least 0"}).max(100,{message:"Advance Tax Rate must be at most 100"}),taxAdvancesId:_().min(1,{message:"Tax Advances ID is required"}),registrationDate:_().min(1,{message:"Business Registration Start Date is required"})});function cs(s){return!s||s.__typename!=="LtdFinancialEntity"||!s.adminInfo?{}:{withholdingTaxBookNumber:s.adminInfo.withholdingTaxBookNumber??"",withholdingTaxFileNumber:s.adminInfo.withholdingTaxFileNumber??"",socialSecurityEmployerId:s.adminInfo.socialSecurityEmployerId??"",taxAdvancesRate:s.adminInfo.taxAdvancesRate??0,taxAdvancesId:s.adminInfo.taxAdvancesId??"",registrationDate:s.adminInfo.registrationDate??""}}function Cn(s){return{withholdingTaxBookNumber:s.withholdingTaxBookNumber,withholdingTaxFileNumber:s.withholdingTaxFileNumber,socialSecurityEmployerId:s.socialSecurityEmployerId,taxAdvancesRate:s.taxAdvancesRate,taxAdvancesId:s.taxAdvancesId,registrationDate:s.registrationDate?fn(new Date(s.registrationDate)):void 0}}function wn({data:s,refetchBusiness:t}){const n=Ce(Us,s),[a,l]=b.useState(cs(n)),{updateAdminBusiness:o,fetching:r}=Nn(),i=Te({resolver:Ke(bn),defaultValues:a}),c=async d=>{if(!n)return;const u=Je(d,i.formState.dirtyFields);if(!u)return;const h=Cn(u);await o({adminBusinessId:n.id,fields:h}),t?.()};return b.useEffect(()=>{if(n){const d=cs(n);l(d),i.reset(d)}},[n,i]),e.jsxs(z,{children:[e.jsxs(q,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(js,{className:"h-5 w-5 text-primary"}),e.jsx(G,{children:"Admin Business Configuration"})]}),e.jsx(W,{children:"Tax and registration information for the business operating this application"})]}),e.jsx(Be,{...i,children:e.jsxs("form",{onSubmit:i.handleSubmit(c),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(j,{control:i.control,name:"withholdingTaxBookNumber",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Book Number"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter book number",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:i.control,name:"withholdingTaxFileNumber",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"File Number"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter file number",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(re,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Tax Advances"}),e.jsx(j,{control:i.control,name:"taxAdvancesId",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Identification number"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter tax advances ID",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:i.control,name:"taxAdvancesRate",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Rate (%)"}),e.jsx(N,{children:e.jsx(T,{type:"number",step:"0.01",min:"0",max:"100",placeholder:"Enter tax rate",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(re,{className:"md:col-span-2"}),e.jsx("h3",{className:"text-sm font-semibold text-foreground md:col-span-2",children:"Social Security"}),e.jsx(j,{control:i.control,name:"socialSecurityEmployerId",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Employer Identifier"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter employer ID",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(re,{className:"md:col-span-2"}),e.jsx(j,{control:i.control,name:"registrationDate",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Registration Start Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...d,className:k(u)})}),e.jsx(C,{})]})})]})}),e.jsx(He,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(P,{type:"submit",disabled:r||Object.keys(i.formState.dirtyFields).length===0||!i.formState.isValid,children:[e.jsx(ss,{className:"h-4 w-4"}),"Save Changes"]})})]})})]})}function kn({businessId:s}){return e.jsxs(z,{children:[e.jsx(q,{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(G,{children:"Balance"}),e.jsx(W,{children:"Business balance overview"})]})})}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Bt,{businessID:s,filter:{}})})})]})}function Sn({businessId:s}){const{userContext:t}=b.useContext(Qe),[n,a]=b.useState(1),[{data:l,fetching:o}]=te({query:zs,variables:{filters:{byOwners:t?.context.adminBusinessId?[t.context.adminBusinessId]:void 0,sortBy:{field:qs.Date,asc:!1},byBusinesses:[s]},page:n,limit:100}}),r=l?.allCharges?.pageInfo.totalPages??1,i=l?.allCharges?.nodes??[];return o?e.jsx("div",{children:"Loading charges..."}):e.jsxs(z,{children:[e.jsxs(q,{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(G,{children:"Charges"}),e.jsx(W,{children:"Recurring and one-time charges for this business"})]})}),r>1&&e.jsx(Ft,{className:"flex-fit",value:n,onChange:a,total:r})]}),e.jsx(K,{children:e.jsx("div",{className:"rounded-md border",children:e.jsx(Lt,{data:i,isAllOpened:!1})})})]})}var An=["type","layout","connectNulls","ref"],In=["key"];function ce(s){"@babel/helpers - typeof";return ce=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ce(s)}function os(s,t){if(s==null)return{};var n=Dn(s,t),a,l;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(s);for(l=0;l<o.length;l++)a=o[l],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(s,a)&&(n[a]=s[a])}return n}function Dn(s,t){if(s==null)return{};var n={};for(var a in s)if(Object.prototype.hasOwnProperty.call(s,a)){if(t.indexOf(a)>=0)continue;n[a]=s[a]}return n}function Ne(){return Ne=Object.assign?Object.assign.bind():function(s){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(s[a]=n[a])}return s},Ne.apply(this,arguments)}function ds(s,t){var n=Object.keys(s);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(s);t&&(a=a.filter(function(l){return Object.getOwnPropertyDescriptor(s,l).enumerable})),n.push.apply(n,a)}return n}function R(s){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?ds(Object(n),!0).forEach(function(a){U(s,a,n[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(n)):ds(Object(n)).forEach(function(a){Object.defineProperty(s,a,Object.getOwnPropertyDescriptor(n,a))})}return s}function ie(s){return Pn(s)||En(s)||Bn(s)||Tn()}function Tn(){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 Bn(s,t){if(s){if(typeof s=="string")return ze(s,t);var n=Object.prototype.toString.call(s).slice(8,-1);if(n==="Object"&&s.constructor&&(n=s.constructor.name),n==="Map"||n==="Set")return Array.from(s);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ze(s,t)}}function En(s){if(typeof Symbol<"u"&&s[Symbol.iterator]!=null||s["@@iterator"]!=null)return Array.from(s)}function Pn(s){if(Array.isArray(s))return ze(s)}function ze(s,t){(t==null||t>s.length)&&(t=s.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=s[n];return a}function Ln(s,t){if(!(s instanceof t))throw new TypeError("Cannot call a class as a function")}function ms(s,t){for(var n=0;n<t.length;n++){var a=t[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(s,Ls(a.key),a)}}function On(s,t,n){return t&&ms(s.prototype,t),n&&ms(s,n),Object.defineProperty(s,"prototype",{writable:!1}),s}function Fn(s,t,n){return t=Ae(t),Vn(s,Ps()?Reflect.construct(t,n||[],Ae(s).constructor):t.apply(s,n))}function Vn(s,t){if(t&&(ce(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return _n(s)}function _n(s){if(s===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return s}function Ps(){try{var s=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(Ps=function(){return!!s})()}function Ae(s){return Ae=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Ae(s)}function Rn(s,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");s.prototype=Object.create(t&&t.prototype,{constructor:{value:s,writable:!0,configurable:!0}}),Object.defineProperty(s,"prototype",{writable:!1}),t&&qe(s,t)}function qe(s,t){return qe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,l){return a.__proto__=l,a},qe(s,t)}function U(s,t,n){return t=Ls(t),t in s?Object.defineProperty(s,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):s[t]=n,s}function Ls(s){var t=Mn(s,"string");return ce(t)=="symbol"?t:t+""}function Mn(s,t){if(ce(s)!="object"||!s)return s;var n=s[Symbol.toPrimitive];if(n!==void 0){var a=n.call(s,t);if(ce(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(s)}var oe=(function(s){function t(){var n;Ln(this,t);for(var a=arguments.length,l=new Array(a),o=0;o<a;o++)l[o]=arguments[o];return n=Fn(this,t,[].concat(l)),U(n,"state",{isAnimationFinished:!0,totalLength:0}),U(n,"generateSimpleStrokeDasharray",function(r,i){return"".concat(i,"px ").concat(r-i,"px")}),U(n,"getStrokeDasharray",function(r,i,c){var d=c.reduce(function(L,m){return L+m});if(!d)return n.generateSimpleStrokeDasharray(i,r);for(var u=Math.floor(r/d),h=r%d,x=i-r,p=[],w=0,I=0;w<c.length;I+=c[w],++w)if(I+c[w]>h){p=[].concat(ie(c.slice(0,w)),[h-I]);break}var B=p.length%2===0?[0,x]:[x];return[].concat(ie(t.repeat(c,u)),ie(p),B).map(function(L){return"".concat(L,"px")}).join(", ")}),U(n,"id",Wt("recharts-line-")),U(n,"pathRef",function(r){n.mainCurve=r}),U(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),U(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return Rn(t,s),On(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();this.setState({totalLength:a})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var a=this.getTotalLength();a!==this.state.totalLength&&this.setState({totalLength:a})}}},{key:"getTotalLength",value:function(){var a=this.mainCurve;try{return a&&a.getTotalLength&&a.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(a,l){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var o=this.props,r=o.points,i=o.xAxis,c=o.yAxis,d=o.layout,u=o.children,h=Rt(u,Mt);if(!h)return null;var x=function(I,B){return{x:I.x,y:I.y,value:I.value,errorVal:Is(I.payload,B)}},p={clipPath:a?"url(#clipPath-".concat(l,")"):null};return V.createElement(Pe,p,h.map(function(w){return V.cloneElement(w,{key:"bar-".concat(w.props.dataKey),data:r,xAxis:i,yAxis:c,layout:d,dataPointFormatter:x})}))}},{key:"renderDots",value:function(a,l,o){var r=this.props.isAnimationActive;if(r&&!this.state.isAnimationFinished)return null;var i=this.props,c=i.dot,d=i.points,u=i.dataKey,h=we(this.props,!1),x=we(c,!0),p=d.map(function(I,B){var L=R(R(R({key:"dot-".concat(B),r:3},h),x),{},{index:B,cx:I.x,cy:I.y,value:I.value,dataKey:u,payload:I.payload,points:d});return t.renderDotItem(c,L)}),w={clipPath:a?"url(#clipPath-".concat(l?"":"dots-").concat(o,")"):null};return V.createElement(Pe,Ne({className:"recharts-line-dots",key:"dots"},w),p)}},{key:"renderCurveStatically",value:function(a,l,o,r){var i=this.props,c=i.type,d=i.layout,u=i.connectNulls;i.ref;var h=os(i,An),x=R(R(R({},we(h,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:l?"url(#clipPath-".concat(o,")"):null,points:a},r),{},{type:c,layout:d,connectNulls:u});return V.createElement($t,Ne({},x,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(a,l){var o=this,r=this.props,i=r.points,c=r.strokeDasharray,d=r.isAnimationActive,u=r.animationBegin,h=r.animationDuration,x=r.animationEasing,p=r.animationId,w=r.animateNewValues,I=r.width,B=r.height,L=this.state,m=L.prevPoints,v=L.totalLength;return V.createElement(Ut,{begin:u,duration:h,isActive:d,easing:x,from:{t:0},to:{t:1},key:"line-".concat(p),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var F=O.t;if(m){var J=m.length/i.length,X=i.map(function(E,Ee){var de=Math.floor(Ee*J);if(m[de]){var me=m[de],ae=he(me.x,E.x),Fs=he(me.y,E.y);return R(R({},E),{},{x:ae(F),y:Fs(F)})}if(w){var Vs=he(I*2,E.x),_s=he(B/2,E.y);return R(R({},E),{},{x:Vs(F),y:_s(F)})}return R(R({},E),{},{x:E.x,y:E.y})});return o.renderCurveStatically(X,a,l)}var ne=he(0,v),y=ne(F),S;if(c){var D="".concat(c).split(/[,\s]+/gim).map(function(E){return parseFloat(E)});S=o.getStrokeDasharray(y,v,D)}else S=o.generateSimpleStrokeDasharray(v,y);return o.renderCurveStatically(i,a,l,{strokeDasharray:S})})}},{key:"renderCurve",value:function(a,l){var o=this.props,r=o.points,i=o.isAnimationActive,c=this.state,d=c.prevPoints,u=c.totalLength;return i&&r&&r.length&&(!d&&u>0||!zt(d,r))?this.renderCurveWithAnimation(a,l):this.renderCurveStatically(r,a,l)}},{key:"render",value:function(){var a,l=this.props,o=l.hide,r=l.dot,i=l.points,c=l.className,d=l.xAxis,u=l.yAxis,h=l.top,x=l.left,p=l.width,w=l.height,I=l.isAnimationActive,B=l.id;if(o||!i||!i.length)return null;var L=this.state.isAnimationFinished,m=i.length===1,v=ts("recharts-line",c),O=d&&d.allowDataOverflow,F=u&&u.allowDataOverflow,J=O||F,X=Ue(B)?this.id:B,ne=(a=we(r,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},y=ne.r,S=y===void 0?3:y,D=ne.strokeWidth,E=D===void 0?2:D,Ee=qt(r)?r:{},de=Ee.clipDot,me=de===void 0?!0:de,ae=S*2+E;return V.createElement(Pe,{className:v},O||F?V.createElement("defs",null,V.createElement("clipPath",{id:"clipPath-".concat(X)},V.createElement("rect",{x:O?x:x-p/2,y:F?h:h-w/2,width:O?p:p*2,height:F?w:w*2})),!me&&V.createElement("clipPath",{id:"clipPath-dots-".concat(X)},V.createElement("rect",{x:x-ae/2,y:h-ae/2,width:p+ae,height:w+ae}))):null,!m&&this.renderCurve(J,X),this.renderErrorBar(J,X),(m||r)&&this.renderDots(J,me,X),(!I||L)&&Gt.renderCallByParent(this.props,i))}}],[{key:"getDerivedStateFromProps",value:function(a,l){return a.animationId!==l.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,prevPoints:l.curPoints}:a.points!==l.curPoints?{curPoints:a.points}:null}},{key:"repeat",value:function(a,l){for(var o=a.length%2!==0?[].concat(ie(a),[0]):a,r=[],i=0;i<l;++i)r=[].concat(ie(r),ie(o));return r}},{key:"renderDotItem",value:function(a,l){var o;if(V.isValidElement(a))o=V.cloneElement(a,l);else if(Vt(a))o=a(l);else{var r=l.key,i=os(l,In),c=ts("recharts-line-dot",typeof a!="boolean"?a.className:"");o=V.createElement(_t,Ne({key:r},i,{className:c}))}return o}}])})(b.PureComponent);U(oe,"displayName","Line");U(oe,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!Kt.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});U(oe,"getComposedData",function(s){var t=s.props,n=s.xAxis,a=s.yAxis,l=s.xAxisTicks,o=s.yAxisTicks,r=s.dataKey,i=s.bandSize,c=s.displayedData,d=s.offset,u=t.layout,h=c.map(function(x,p){var w=Is(x,r);return u==="horizontal"?{x:is({axis:n,ticks:l,bandSize:i,entry:x,index:p}),y:Ue(w)?null:a.scale(w),value:w,payload:x}:{x:Ue(w)?null:n.scale(w),y:is({axis:a,ticks:o,bandSize:i,entry:x,index:p}),value:w,payload:x}});return R({points:h,layout:u},d)});var $n=Ht({chartName:"LineChart",GraphicalChild:oe,axisComponents:[{axisType:"xAxis",AxisComp:Ds},{axisType:"yAxis",AxisComp:Ts}],formatAxisMap:Xt});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 Un(){const s=xe.reduce((n,a)=>n+a.revenue,0),t=s/xe.length;return e.jsxs(z,{children:[e.jsxs(q,{children:[e.jsx(G,{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(ke,{className:"h-4 w-4"}),"Total Revenue"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",s.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+24.5% from last period"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Average Monthly"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",t.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+18.2% growth rate"})]})]}),e.jsxs("div",{className:"rounded-lg border p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ke,{className:"h-4 w-4"}),"Current Month"]}),e.jsxs("p",{className:"text-2xl font-bold",children:["$",xe[xe.length-1].revenue.toLocaleString()]}),e.jsxs("div",{className:"flex items-center gap-1 text-sm text-green-600",children:[e.jsx(Fe,{className:"h-3 w-3"}),e.jsx("span",{children:"+8.0% from last month"})]})]})]}),e.jsx(Jt,{config:{revenue:{label:"Revenue",color:"hsl(var(--chart-1))"},expenses:{label:"Expenses",color:"hsl(var(--chart-2))"}},className:"h-[400px]",children:e.jsx(Qt,{width:"100%",height:"100%",children:e.jsxs($n,{data:xe,margin:{top:5,right:10,left:10,bottom:5},children:[e.jsx(Yt,{strokeDasharray:"3 3",className:"stroke-muted"}),e.jsx(Ds,{dataKey:"month",className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Ts,{className:"text-xs",tick:{fill:"hsl(var(--muted-foreground))"}}),e.jsx(Zt,{content:e.jsx(en,{})}),e.jsx(oe,{type:"monotone",dataKey:"revenue",stroke:"var(--color-revenue)",strokeWidth:2,dot:{fill:"var(--color-revenue)",r:4}}),e.jsx(oe,{type:"monotone",dataKey:"expenses",stroke:"var(--color-expenses)",strokeWidth:2,dot:{fill:"var(--color-expenses)",r:4}})]})})})]})]})}const zn="updateBusiness",Os=()=>{const[{fetching:s},t]=Ie(Gs),n=b.useCallback(async a=>{const l=`Error updating business ID [${a.businessId}]`,o=`${zn}-${a.businessId}`;M.loading("Updating business",{id:o});try{const r=await t(a),i=De(r,l,o,"updateBusiness");if(i)return M.success("Success",{id:o,description:"Business updated"}),i.updateBusiness}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{fetching:s,updateBusiness:n}},qn=Object.values(et);function us(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(t=>t.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 Gn(s){const n=s.internalLinks||s.useMessageBody||s.attachmentTypes?{internalEmailLinks:s.internalLinks,emailBody:s.useMessageBody,attachments:s.attachmentTypes}:void 0,l=s.description||s.tags||s.phrases||s.emails||n?{description:s.description,tags:s.tags?.map(o=>({id:o})),phrases:s.phrases,emails:s.emails,emailListener:n}: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:l}}function Wn({data:s,refetchBusiness:t}){const n=Ce(Ks,s),[a,l]=b.useState(us(n)),{userContext:o}=b.useContext(Qe),{updateBusiness:r,fetching:i}=Os(),[c,d]=b.useState(!1),[u,h]=b.useState(void 0),x=Te({defaultValues:a}),p=async I=>{if(!n||!o?.context.adminBusinessId)return;const B=Je(I,x.formState.dirtyFields);if(!B)return;const L=Gn(B);await r({businessId:n.id,ownerId:o.context.adminBusinessId,fields:L}),B.tags?.length||B.description?(h({tagIds:B.tags?.map(m=>({id:m})),description:B.description}),d(!0)):t?.()};if(b.useEffect(()=>{if(n){const I=us(n);l(I),x.reset(I)}},[n,x]),!n)return e.jsx("div",{});const w=x.watch("isClient");return e.jsxs(z,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Configurations"}),e.jsx(W,{children:"Business status, tax settings, automation rules, and integration preferences"})]}),!w&&e.jsx(Ws,{businessId:n.id,onDone:t})]})}),e.jsx(Be,{...x,children:e.jsxs("form",{onSubmit:x.handleSubmit(p),children:[e.jsxs(K,{className:"space-y-6",children:[e.jsx(Kn,{form:x}),e.jsx(re,{}),e.jsx(Hn,{form:x}),e.jsx(re,{}),e.jsx(Xn,{form:x}),e.jsx(re,{}),e.jsx(Jn,{form:x})]}),e.jsx(He,{className:"flex justify-end border-t pt-6",children:e.jsxs(P,{type:"submit",disabled:i||Object.keys(x.formState.dirtyFields).length===0,children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})}),e.jsx(vn,{businessId:n.id,tagIds:u?.tagIds,description:u?.description,open:c,onOpenChange:d,onClose:t})]})}function Kn({form:s}){return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Business Status & Behavior"}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(j,{control:s.control,name:"isClient",render:({field:t,fieldState:n})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Client"}),e.jsx(ee,{children:"Mark this business as a client"})]}),e.jsx(N,{children:e.jsx(Q,{disabled:!0,checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isActive",render:({field:t,fieldState:n})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Active"}),e.jsx(ee,{children:"Business is currently active"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isReceiptEnough",render:({field:t,fieldState:n})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Receipt Enough"}),e.jsx(ee,{children:"Generate ledger for receipt documents if no invoice available"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isDocumentsOptional",render:({field:t,fieldState:n})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"No Docs Required"}),e.jsx(ee,{children:"Skip document validation for common charges"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isVatOptional",render:({field:t,fieldState:n})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is VAT Optional"}),e.jsx(ee,{children:"Mute missing VAT indicator"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})}),e.jsx(j,{control:s.control,name:"isExemptDealer",render:({field:t,fieldState:n})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Is Exempt Dealer"}),e.jsx(ee,{children:"Business is exempt from VAT requirements"})]}),e.jsx(N,{children:e.jsx(Q,{checked:t.value,onCheckedChange:t.onChange,className:k(n)})})]})})]})]})}function Hn({form:s}){const{selectableTaxCategories:t,fetching:n}=Hs(),{selectableSortCodes:a,fetching:l,sortCodes:o}=Xs(),{selectableTags:r,fetching:i}=Js(),c=b.useCallback(d=>{if(d){const u=o.find(h=>Number(h.key)===Number(d));u&&(u.defaultIrsCode?s.setValue("irsCode",u.defaultIrsCode,{shouldDirty:!0}):s.setValue("irsCode",null,{shouldDirty:!0}))}},[s,o]);return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Default Settings"}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:s.control,name:"sortCode",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Sort Code"}),e.jsx(N,{children:e.jsx(Ve,{onChange:h=>{c(h),d.onChange(h)},data:a,value:d.value,disabled:l,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:k(u)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"taxCategory",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tax Category"}),e.jsx(N,{children:e.jsx(Ve,{data:t,disabled:n,value:d.value,onChange:d.onChange,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:k(u)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"pcn874RecordType",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"PCN874 Record Type"}),e.jsxs(je,{onValueChange:d.onChange,value:d.value,children:[e.jsx(N,{children:e.jsx(ge,{className:k(u),children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.entries(Qs).map(([h,x])=>e.jsx(ye,{value:h,children:`${x} (${h})`},h))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"irsCode",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(N,{children:e.jsx(Ys,{value:d.value??void 0,onValueChange:h=>d.onChange(h??null),hideControls:!0,decimalScale:0,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"description",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Charge Description"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Enter default charge description",...d,className:k(u)})}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"tags",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Tags"}),e.jsx(N,{children:e.jsx(Zs,{options:Object.values(r).map(({value:h,label:x})=>({label:x,value:h})),onValueChange:d.onChange,defaultValue:d.value,value:d.value,placeholder:"Select Default Tags",variant:"default",disabled:i,className:k(u)})}),e.jsx(C,{})]})})]})]})}function Xn({form:s}){const[t,n]=b.useState(""),[a,l]=b.useState(""),o=()=>{if(t.trim()){const d=s.getValues("phrases");s.setValue("phrases",[...d,t.trim()],{shouldDirty:!0}),n("")}},r=()=>{if(a.trim()){const d=s.getValues("emails");s.setValue("emails",[...d,a.trim()],{shouldDirty:!0}),l("")}},i=d=>{const u=s.getValues("phrases");s.setValue("phrases",u.filter((h,x)=>x!==d),{shouldDirty:!0})},c=d=>{const u=s.getValues("emails");s.setValue("emails",u.filter((h,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(j,{control:s.control,name:"phrases",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Phrases"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add phrase...",value:t,onChange:h=>n(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),o())},className:k(u)}),e.jsx(P,{type:"button",size:"sm",onClick:o,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,x)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[h,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>i(x),children:e.jsx(le,{className:"size-3 cursor-pointer",onClick:()=>i(x)})})]},x))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"emails",render:({field:d,fieldState:u})=>e.jsxs(g,{children:[e.jsx(f,{children:"Email Addresses"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"email",placeholder:"Add email...",value:a,onChange:h=>l(h.target.value),onKeyDown:h=>{h.key==="Enter"&&(h.preventDefault(),r())},className:k(u)}),e.jsx(P,{type:"button",size:"sm",onClick:r,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:d.value?.map((h,x)=>e.jsxs(Z,{variant:"secondary",className:"gap-1",children:[h,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>c(x),children:e.jsx(le,{className:"size-3 cursor-pointer"})})]},x))}),e.jsx(C,{})]})})]})}function Jn({form:s}){const[t,n]=b.useState(""),a=()=>{if(t.trim()){const r=s.getValues("internalLinks");s.setValue("internalLinks",[...r,t.trim()],{shouldDirty:!0}),n("")}},l=r=>{const i=s.getValues("attachmentTypes");s.setValue("attachmentTypes",i?.includes(r)?i.filter(c=>c!==r):[...i,r],{shouldDirty:!0})},o=r=>{const i=s.getValues("internalLinks");s.setValue("internalLinks",i.filter((c,d)=>d!==r),{shouldDirty:!0})};return e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-foreground",children:"Gmail Feature Configuration"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure Gmail integration settings for document processing"}),e.jsx(j,{control:s.control,name:"attachmentTypes",render:({field:r,fieldState:i})=>e.jsxs(g,{children:[e.jsx(f,{children:"Attachment Types"}),e.jsx("div",{className:k(i)+" rounded-md flex flex-wrap gap-2",children:qn.map(c=>e.jsx(Z,{variant:r.value?.includes(c)?"default":"outline",className:"cursor-pointer",onClick:()=>l(c),children:c},c))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"internalLinks",render:({field:r,fieldState:i})=>e.jsxs(g,{children:[e.jsx(f,{children:"Internal Links"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{type:"url",placeholder:"Add internal link...",value:t,onChange:c=>n(c.target.value),onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),a())}}),e.jsx(P,{type:"button",size:"sm",onClick:a,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:k(i)+" flex flex-wrap gap-2 rounded-md",children:r.value?.map((c,d)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[c,e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>o(d),children:e.jsx(le,{className:"size-3 cursor-pointer flex-shrink-0"})})]},d))}),e.jsx(C,{})]})}),e.jsx(j,{control:s.control,name:"useMessageBody",render:({field:r,fieldState:i})=>e.jsxs(g,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"space-y-0.5",children:[e.jsx(f,{children:"Should Use Message Body"}),e.jsx(ee,{children:"Extract information from email message body"})]}),e.jsx(N,{children:e.jsx(Q,{checked:r.value,onCheckedChange:r.onChange,className:k(i)})})]})})]})}const Qn=Xe({businessName:_().min(1,"Business name is required"),locality:_().min(1,"Locality is required"),localName:_().optional(),govId:_().optional(),address:_().optional(),localAddress:_().optional(),phone:_().optional(),website:vs("Invalid URL").optional().or(ys("")),generalContacts:$e(ns()).optional(),billingEmails:$e(ns()).optional()});function hs(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(t=>t.trim()),billingEmails:s.clientInfo?.emails}}function Yn(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 Zn({data:s,refetchBusiness:t}){const n=Ce(nt,s),[a,l]=b.useState(hs(n)),{userContext:o}=b.useContext(Qe),{updateBusiness:r,fetching:i}=Os(),c=Te({resolver:Ke(Qn),defaultValues:a}),{countries:d,fetching:u}=st(),[h,x]=b.useState(""),[p,w]=b.useState(""),I=c.watch("locality"),B=c.watch("address"),L=c.watch("localAddress");b.useEffect(()=>{B!==a.address&&c.setValue("address",B,{shouldDirty:!0})},[B,a.address,c]),b.useEffect(()=>{L!==a.localAddress&&c.setValue("localAddress",L,{shouldDirty:!0})},[L,a.localAddress,c]);const m=n&&"clientInfo"in n&&!!n.clientInfo,v=I===o?.context.locality,O=y=>{h.trim()&&(c.setValue("generalContacts",[...y,h.trim()],{shouldDirty:!0}),x(""))},F=(y,S)=>{c.setValue("generalContacts",y.filter((D,E)=>E!==S),{shouldDirty:!0})},J=y=>{p.trim()&&(c.setValue("billingEmails",[...y,p.trim()],{shouldDirty:!0}),w(""))},X=(y,S)=>{c.setValue("billingEmails",y.filter((D,E)=>E!==S),{shouldDirty:!0})},ne=async y=>{if(!n||!o?.context.adminBusinessId)return;const S=Je(y,c.formState.dirtyFields);if(!S)return;const D=Yn(S);await r({businessId:n.id,ownerId:o.context.adminBusinessId,fields:D}),t?.()};return b.useEffect(()=>{if(n){const y=hs(n);l(y),c.reset(y)}},[n,c]),e.jsxs(z,{children:[e.jsxs(q,{children:[e.jsx(G,{children:"Contact Information"}),e.jsx(W,{children:"Business contact details and address information"})]}),e.jsx(Be,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(ne),children:[e.jsx(K,{children:e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsx(j,{control:c.control,name:"businessName",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Business Name"}),e.jsx(N,{children:e.jsx(T,{...y,className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"locality",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Locality / Country"}),e.jsx(Ve,{onChange:y.onChange,data:d.map(D=>({value:D.code,label:D.name})),value:y.value,disabled:u,placeholder:"Scroll to see all options",formPart:!0,triggerProps:{className:k(S)}}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"localName",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Local Name"}),e.jsx(N,{children:e.jsx(T,{...y,placeholder:"Business name in local language",className:k(S)})}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"govId",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsx(f,{children:"Government ID"}),e.jsx(N,{children:e.jsx(T,{...y,placeholder:"Enter Government ID",className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"address",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Address"]}),e.jsx(N,{children:e.jsx(Re,{...y,rows:3,placeholder:"Enter business address",className:k(S)})}),e.jsx(C,{})]})}),v&&e.jsx(j,{control:c.control,name:"localAddress",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Local Address"]}),e.jsx(N,{children:e.jsx(Re,{...y,rows:3,placeholder:"Enter address in local language",className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"phone",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(fs,{className:"h-4 w-4"}),"Phone"]}),e.jsx(N,{children:e.jsx(T,{...y,type:"tel",placeholder:"+1 (555) 123-4567",className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"website",render:({field:y,fieldState:S})=>e.jsxs(g,{children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(tt,{className:"h-4 w-4"}),"Website"]}),e.jsx(N,{children:e.jsx(T,{...y,type:"url",placeholder:"https://example.com",className:k(S)})}),e.jsx(C,{})]})}),e.jsx(j,{control:c.control,name:"generalContacts",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"General Contacts"]}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:k(S)+" flex flex-wrap gap-2 mb-2 rounded-md",children:y.value?.map((D,E)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 pr-1",children:[D,e.jsx("button",{type:"button",onClick:()=>F(y.value??[],E),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(le,{className:"h-3 w-3"})})]},E))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:h,onChange:D=>x(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),O(y.value??[]))},placeholder:"Add contact email",type:"email"}),e.jsx(P,{type:"button",variant:"outline",size:"icon",disabled:!h.trim(),onClick:()=>O(y.value??[]),children:e.jsx(Y,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})}),m&&e.jsx(j,{control:c.control,name:"billingEmails",render:({field:y,fieldState:S})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsxs(f,{className:"flex items-center gap-2",children:[e.jsx(Me,{className:"h-4 w-4"}),"Billing Emails"]}),e.jsx(N,{children:e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:k(S)+" flex flex-wrap gap-2 mb-2 rounded-md",children:y.value?.map((D,E)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 pr-1",children:[D,e.jsx("button",{type:"button",onClick:()=>X(y.value??[],E),className:"ml-1 hover:bg-muted rounded-sm p-0.5",children:e.jsx(le,{className:"h-3 w-3"})})]},E))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{value:p,onChange:D=>w(D.target.value),onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),J(y.value??[]))},placeholder:"Add billing email",type:"email"}),e.jsx(P,{type:"button",variant:"outline",size:"icon",disabled:!p.trim(),onClick:()=>J(y.value??[]),children:e.jsx(Y,{className:"h-4 w-4"})})]})]})}),e.jsx(C,{})]})})]})}),e.jsx(He,{className:"flex justify-end border-t mt-4 pt-6",children:e.jsxs(P,{type:"submit",disabled:i||Object.keys(c.formState.dirtyFields).length===0,children:[e.jsx(ss,{className:"h-4 w-4 mr-2"}),"Save Changes"]})})]})})]})}const ea="createContract",sa=()=>{const[{fetching:s},t]=Ie(at),n=b.useCallback(async a=>{const l=`Error creating new contract for client[${a.input.clientId}]`,o=`${ea}-${a.input.clientId}`;M.loading("Creating contract",{id:o});try{const r=await t(a);De(r,l,o)&&M.success("Success",{id:o,description:`Contract for client ${a.input.clientId} was successfully created`})}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{creating:s,createContract:n}},ta="updateContract",na=()=>{const[{fetching:s},t]=Ie(it),n=b.useCallback(async a=>{const l=`Error updating contract ID [${a.contractId}]`,o=`${ta}-${a.contractId}`;M.loading("Updating contract",{id:o});try{const r=await t(a),i=De(r,l,o,"updateContract");if(i)return M.success("Success",{id:o,description:"Contract updated"}),i.updateContract}catch(r){console.error(`${l}: ${r}`),M.error("Error",{id:o,description:l,duration:1e5,closeButton:!0})}},[t]);return{updating:s,updateContract:n}},aa=Xe({id:ct().optional(),startDate:as("Start date is required"),endDate:as("End date is required"),pos:$e(_()),paymentAmount:gs().min(0,"Payment amount must be non-negative"),paymentCurrency:ue(Object.values(Ze),"Currency is required"),productType:ue(Object.values(Ns)).optional(),msCloudLink:vs().optional().or(ys("")),billingCycle:ue(Object.values(be)).optional(),subscriptionPlan:ue(Object.values(Se)).optional(),isActive:lt(),defaultRemark:_().optional(),defaultDocumentType:ue(Object.values(Ye)),operationsLimit:rt().min(0,"Operations limit must be non-negative")}),xs={startDate:"",endDate:"",pos:[],paymentAmount:0,paymentCurrency:Ze.Usd,productType:Ns.Hive,msCloudLink:void 0,billingCycle:be.Monthly,subscriptionPlan:void 0,isActive:!0,defaultRemark:void 0,defaultDocumentType:Ye.Proforma,operationsLimit:0};function ia({clientId:s,contract:t,onDone:n}){const[a,l]=b.useState(!1),[o,r]=b.useState(null),[i,c]=b.useState(""),{updateContract:d,updating:u}=na(),{createContract:h,creating:x}=sa(),p=Te({resolver:Ke(aa),defaultValues:t||xs}),w=()=>{const m=i.trim();if(m){const v=p.getValues("pos");v.includes(m)||p.setValue("pos",[...v,m],{shouldDirty:!0}),c("")}},I=m=>{const v=p.getValues("pos");p.setValue("pos",v.filter((O,F)=>F!==m),{shouldDirty:!0})};b.useEffect(()=>{t&&(r(t),p.reset({startDate:t.startDate,endDate:t.endDate,pos:t.pos,paymentAmount:t.paymentAmount,paymentCurrency:t.paymentCurrency,productType:t.productType,msCloudLink:t.msCloudLink,billingCycle:t.billingCycle,subscriptionPlan:t.subscriptionPlan,isActive:t.isActive,defaultRemark:t.defaultRemark,defaultDocumentType:t.defaultDocumentType,operationsLimit:t.operationsLimit}),l(!0))},[t,p]);const B=()=>{r(null),p.reset(xs),l(!0)},L=b.useCallback(async m=>{if(o)await d({contractId:o.id,input:{amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:pe(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrders:m.pos,remarks:m.defaultRemark,startDate:pe(new Date(m.startDate),"yyyy-MM-dd"),operationsLimit:m.operationsLimit}});else{if(!m.billingCycle){p.setError("billingCycle",{message:"Billing cycle is required"});return}await h({input:{clientId:s,amount:{raw:m.paymentAmount,currency:m.paymentCurrency},billingCycle:m.billingCycle,documentType:m.defaultDocumentType,endDate:pe(new Date(m.endDate),"yyyy-MM-dd"),isActive:m.isActive,msCloud:m.msCloudLink,plan:m.subscriptionPlan,product:m.productType,purchaseOrders:m.pos,remarks:m.defaultRemark,startDate:pe(new Date(m.startDate),"yyyy-MM-dd"),operationsLimit:m.operationsLimit}})}l(!1),r(null),n?.()},[o,n,h,d,s,p]);return e.jsxs(Ge,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{size:"sm",onClick:B,children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"New Contract"]})}),e.jsxs(We,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs(Cs,{children:[e.jsx(ws,{children:o?"Edit Contract":"Create New Contract"}),e.jsx(ks,{children:o?"Update contract details":"Add a new contract with all required details"})]}),e.jsx(Be,{...p,children:e.jsxs("form",{onSubmit:p.handleSubmit(L),children:[e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"operationsLimit",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Operations Limit"}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:"500",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"pos",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Purchase Orders"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(T,{placeholder:"Add PO...",value:i,onChange:v=>c(v.target.value),onKeyDown:v=>{v.key==="Enter"&&(v.preventDefault(),w())}}),e.jsx(P,{type:"button",size:"sm",onClick:w,children:e.jsx(Y,{className:"h-4 w-4"})})]}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-2",children:m.value?.map((v,O)=>e.jsxs(Z,{variant:"secondary",className:"gap-1 max-w-xs truncate",children:[v,O===m.value.length-1&&e.jsx(P,{variant:"ghost",size:"icon",className:"p-0 size-3",onClick:()=>I(O),children:e.jsx(le,{className:"size-3 cursor-pointer flex-shrink-0"})})]},v))}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"startDate",render:({field:{onChange:m,...v}})=>e.jsxs(g,{children:[e.jsx(f,{children:"Start Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...v,onInput:O=>m(O)})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"endDate",render:({field:{onChange:m,...v}})=>e.jsxs(g,{children:[e.jsx(f,{children:"End Date"}),e.jsx(N,{children:e.jsx(T,{type:"date",...v,onInput:O=>m(O)})}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-3",children:[e.jsx(j,{control:p.control,name:"paymentAmount",render:({field:m})=>e.jsxs(g,{className:"md:col-span-2",children:[e.jsx(f,{children:"Payment Amount"}),e.jsx(N,{children:e.jsx(T,{type:"number",placeholder:"24000",...m,onChange:v=>{m.onChange(v?.target.value?Number(v?.target.value):void 0)}})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"paymentCurrency",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Currency"}),e.jsxs(je,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(ge,{children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.values(Ze).map(v=>e.jsx(ye,{value:v,children:v},v))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"productType",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Product Type"}),e.jsx(N,{children:e.jsx(T,{placeholder:"Cloud Services",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"billingCycle",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Billing Cycle"}),e.jsxs(je,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(ge,{children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.values(be).map(v=>e.jsx(ye,{value:v,children:Bs(v)},v))})]}),e.jsx(C,{})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsx(j,{control:p.control,name:"subscriptionPlan",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Subscription Plan"}),e.jsx(N,{children:e.jsxs(je,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(ge,{children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.values(Se).map(v=>e.jsx(ye,{value:v,children:Es(v)},v))})]})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"isActive",render:({field:m})=>e.jsxs(g,{className:"flex flex-row items-center justify-between rounded-lg border p-4",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{className:"text-base",children:"Active Status"})}),e.jsx(N,{children:e.jsx(Q,{checked:m.value,onCheckedChange:m.onChange})})]})})]}),e.jsx(j,{control:p.control,name:"msCloudLink",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"MS Cloud Link"}),e.jsx(N,{children:e.jsx(T,{type:"url",placeholder:"https://portal.azure.com/contract-id",...m})}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"defaultDocumentType",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Document Type"}),e.jsxs(je,{onValueChange:m.onChange,defaultValue:m.value,children:[e.jsx(N,{children:e.jsx(ge,{children:e.jsx(fe,{})})}),e.jsx(ve,{children:Object.values(Ye).map(v=>e.jsx(ye,{value:v,children:Ss(v)},v))})]}),e.jsx(C,{})]})}),e.jsx(j,{control:p.control,name:"defaultRemark",render:({field:m})=>e.jsxs(g,{children:[e.jsx(f,{children:"Default Remark"}),e.jsx(N,{children:e.jsx(Re,{placeholder:"Enter default remark for this contract...",rows:3,...m})}),e.jsx(C,{})]})})]}),e.jsxs(As,{children:[e.jsx(P,{type:"button",variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(P,{type:"submit",disabled:x||u,children:o?"Update Contract":"Create Contract"})]})]})})]})]})}function ra(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 la({clientId:s}){const[t,n]=b.useState(null),[{data:a,fetching:l},o]=te({query:ot,variables:{clientId:s}}),r=a?.contractsByClient??[];return l?e.jsx("div",{children:"Loading contracts..."}):e.jsxs(z,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Contracts"}),e.jsx(W,{children:"Current and past contracts sorted by start date"})]}),e.jsx(ia,{clientId:s,contract:t,onDone:o})]})}),e.jsx(K,{className:"space-y-4",children:r.map(i=>{const c=!!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(Z,{variant:c?"default":"secondary",children:i.isActive?"Active":"Inactive"})]}),e.jsx("p",{className:"text-sm text-muted-foreground font-mono",children:i.id})]}),e.jsx(P,{variant:"ghost",size:"sm",onClick:()=>n(ra(i)),children:e.jsx(sn,{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(dt,{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:mt(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:Bs(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?Es(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:Ss(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(P,{variant:"outline",size:"sm",asChild:!0,children:e.jsxs("a",{href:i.msCloud.toString(),target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ut,{className:"h-4 w-4 mr-2"}),"MS Cloud",e.jsx(tn,{className:"h-3 w-3 ml-1"})]})})})]},i.id)})})]})}function ca({businessId:s}){return e.jsxs(z,{children:[e.jsx(q,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(G,{children:"Documents"}),e.jsx(W,{children:"Invoices, proformas, receipts, and other accounting documents"})]})})}),e.jsx(K,{children:e.jsx(ht,{businessId:s,linkedDocumentIds:[],limit:1e3})})]})}const oa=[{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 da({data:s}){const t=Ce(gt,s),[{data:n,fetching:a},l]=te({query:xt,variables:{clientId:t?.id??""},pause:!t?.clientInfo?.greenInvoiceId||!t?.id}),{updateClient:o}=pt(),r=b.useCallback((c,d)=>{if(!t?.id)return;const u={};u[d]=c,o({businessId:t?.id,fields:u})},[t?.id,o]);b.useEffect(()=>{t?.clientInfo?.greenInvoiceId&&t?.id&&l()},[t?.clientInfo?.greenInvoiceId,t?.id,l]);const i=n?.greenInvoiceClient;return e.jsxs(z,{children:[e.jsx(q,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(G,{children:"Integrations"}),e.jsx(W,{children:"Connected external services and providers"})]}),e.jsxs(P,{size:"sm",children:[e.jsx(Y,{className:"h-4 w-4 mr-2"}),"Add Integration"]})]})}),e.jsx(K,{className:"space-y-6",children:e.jsxs(an,{type:"multiple",defaultValue:["green-invoice"],className:"space-y-4",children:[a?e.jsxs(Le,{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(A,{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(A,{className:"h-6 w-32"}),e.jsx(A,{className:"h-5 w-5 rounded-full"})]}),e.jsx(A,{className:"h-4 w-64"})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-8 w-24"}),e.jsx(A,{className:"h-8 w-8"})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{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(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{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(A,{className:"h-3 w-32"}),e.jsx(A,{className:"h-6 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(A,{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(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(A,{className:"h-3 w-24"}),e.jsx(A,{className:"h-4 w-full"})]})]})]})]})})]}):e.jsxs(Le,{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(ls,{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(ma,{id:t?.clientInfo?.greenInvoiceId,provider:"Green Invoice",updateClient:async c=>r(c,"greenInvoiceId")}),e.jsx(rs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Oe,{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:t?.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(Me,{className:"h-3.5 w-3.5"}),"Email Addresses"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:i.emails?.map((c,d)=>e.jsx("span",{className:"text-sm px-2 py-1 bg-muted rounded",children:c},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(fs,{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(_e,{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})]})]})]})]})})]}),oa.map(c=>e.jsxs(Le,{value:c.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:c.name}),c.status==="connected"?e.jsx(ls,{className:"h-4 w-4 text-green-600"}):e.jsx(jt,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:c.description})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(P,{variant:"ghost",size:"sm",onClick:d=>d.stopPropagation(),children:e.jsx(es,{className:"h-4 w-4"})}),e.jsx(rs,{className:"hover:no-underline p-2"})]})]})}),e.jsx(Oe,{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:c.lastSync})]})})})]},c.id))]})})]})}function ma({id:s,provider:t,updateClient:n}){const[a,l]=b.useState(!1),[o,r]=b.useState(s),i=b.useCallback(async()=>{await n(o),l(!1)},[o,n]);return e.jsxs(Ge,{open:a,onOpenChange:l,children:[e.jsx(bs,{asChild:!0,children:e.jsxs(P,{variant:"outline",size:"sm",onClick:c=>c.stopPropagation(),children:[e.jsx(es,{className:"h-4 w-4 mr-2"}),"Configure"]})}),e.jsxs(We,{onClick:c=>c.stopPropagation(),children:[e.jsxs(Cs,{children:[e.jsxs(ws,{children:["Configure ",t]}),e.jsxs(ks,{children:["Update your ",t," integration settings"]})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs(ft,{htmlFor:"id",children:[t," ID"]}),e.jsx(T,{id:"id",value:o,onChange:c=>r(c.target.value),placeholder:`Enter ${t} ID`})]})}),e.jsxs(As,{children:[e.jsx(P,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(P,{onClick:i,disabled:!o,children:"Save Changes"})]})]})]})}function ua({businessId:s}){const[{data:t,fetching:n}]=te({query:vt,variables:{businessId:s}});return n?e.jsx("div",{children:"Loading ledger records..."}):e.jsxs(z,{children:[e.jsx(q,{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(G,{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(Ot,{ledgerRecordsData:t?.ledgerRecordsByFinancialEntity??[]})})})]})}function ha({businessId:s}){const[{data:t,fetching:n}]=te({query:yt,variables:{businessId:s}});return n?e.jsx("div",{children:"Loading transactions..."}):e.jsxs(z,{children:[e.jsx(q,{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(G,{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(nn,{transactionsProps:t?.transactionsByFinancialEntity??[]})})})]})}function xa({data:s,refetchBusiness:t}){const n=Ce(At,s),[a,l]=Nt(),{setFiltersContext:o}=b.useContext(bt);b.useEffect(()=>{o(null)},[o]);const r=a.get("tab")||"contact",i=u=>{l({tab:u})};if(!n)return e.jsx("div",{children:"Business not found"});const c="clientInfo"in n&&!!n.clientInfo,d="adminInfo"in n&&!!n.adminInfo;return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx(Et,{data:n}),e.jsx("main",{className:"container mx-auto px-4 py-6 md:px-6 lg:px-8 max-w-7xl",children:e.jsxs(Ct,{value:r,onValueChange:i,className:"w-full",children:[e.jsxs(wt,{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(H,{value:"contact",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(rn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contact"})]}),e.jsxs(H,{value:"config",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(es,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Config"})]}),e.jsxs(H,{value:"charges",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(ke,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Charges"})]}),e.jsxs(H,{value:"transactions",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(kt,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Transactions"})]}),e.jsxs(H,{value:"documents",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(St,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Documents"})]}),e.jsxs(H,{value:"ledger",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(xn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ledger"})]}),e.jsxs(H,{value:"balance",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(cn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Balance"})]}),c&&e.jsxs(e.Fragment,{children:[e.jsxs(H,{value:"contracts",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(un,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Contracts"})]}),e.jsxs(H,{value:"integrations",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(jn,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Integrations"})]})]}),d&&e.jsxs(H,{value:"admin",className:"flex items-center gap-2 data-[state=active]:bg-background",children:[e.jsx(js,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Admin"})]})]}),e.jsx($,{value:"contact",className:"mt-0",children:e.jsx(Zn,{data:n,refetchBusiness:t})}),e.jsx($,{value:"config",className:"mt-0",children:e.jsx(Wn,{data:n,refetchBusiness:t})}),e.jsx($,{value:"charges",className:"mt-0",children:e.jsx(Sn,{businessId:n.id})}),e.jsx($,{value:"transactions",className:"mt-0",children:e.jsx(ha,{businessId:n.id})}),e.jsx($,{value:"documents",className:"mt-0",children:e.jsx(ca,{businessId:n.id})}),e.jsx($,{value:"ledger",className:"mt-0",children:e.jsx(ua,{businessId:n.id})}),e.jsx($,{value:"balance",className:"mt-0",children:e.jsx(kn,{businessId:n.id})}),c&&e.jsxs(e.Fragment,{children:[e.jsx($,{value:"contracts",className:"mt-0",children:e.jsx(la,{clientId:n.id})}),e.jsx($,{value:"integrations",className:"mt-0",children:e.jsx(da,{data:n})}),e.jsx($,{value:"charts",className:"mt-0",children:e.jsx(Un,{})})]}),d&&e.jsx($,{value:"admin",className:"mt-0",children:e.jsx(wn,{data:n})})]})})]})}const Va=()=>{const{businessId:s}=It();let t;try{t=Dt()}catch{}const[{data:n,fetching:a},l]=te({query:Tt,pause:!s||!!t,variables:{businessId:s??""}}),o=t||n;return!t&&a&&!o?.business?e.jsx(ps,{}):!s||!o?.business?e.jsx("div",{children:"Business not found"}):e.jsx(xa,{data:o.business,refetchBusiness:async()=>l()})};export{Va as BusinessScreen};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as p,r as n,F as u,u as m,j as s,c,bz as x}from"./index-fZcP3X7C.js";import{P as d,C as l,E as b}from"./editable-business-trip-CCy91YvH.js";import{P as f}from"./page-layout-DUgx8eXl.js";import"./list-plus-ZIHrrCaO.js";import"./summary-yiqSbK4V.js";import"./create-event-handler-BiA-1lGu.js";import"./Table-Cr3nIx5M.js";import"./toggle-expansion-button-pWLCCDmM.js";import"./panel-top-open-CcWXXds7.js";import"./MultiSelect-Uj0K1auE.js";import"./similar-transactions-modal-Cdv2FmQ8.js";import"./tooltip-r34BEIrK.js";const L=({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(f,{title:`Business Trip: ${r.businessTrip.name}`,description:"Manage business trip",children:s.jsx(l,{className:"mt-5",children:e&&s.jsx(b,{tripId:e,isExtended:!0})})})};export{L as BusinessTrip};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{v as bn,gs as ne,fJ as A,fH as pe,gt as qe,gu as Dn,dx as kn,j as i,T as mt,bU as gt,R as yt,B as z,m as N,bS as Mn,gv as wn,e8 as Cn,u as pt,gw as Sn,G as xt,r as S,cQ as vt,d as jn,V as bt,e9 as Nn,X as re,Y as oe,Z as ae,am as On,_ as ge,an as Tn,ao as Wn,ap as En,ar as _n,a0 as le,bs as Dt,x as ue,ah as In,a5 as Fn,g as Yn,gx as Pn,t as Ee,i as Bn,L as Rn,al as et,br as tt,bM as zn,bt as An,gy as qn,I as kt,gz as Hn,gA as $n,fI as Zn,gB as Un,gC as Ln,gD as Kn,gE as Gn,gF as Vn,gG as Jn,gH as Qn,gI as Mt,ab as m,gJ as Xn,gK as es,dq as se,gL as nt,gM as ts,gN as ns,a_ as ss,gO as rs,ee as os,ef as as,gP as is,D as cs,aO as ls,z as ds,aP as us,aQ as fs,gQ as hs,gR as ms,gS as gs,cw as ys,bq as ps,cr as xs,q as vs,e as bs,dp as ce,fE as Ds,J as ks,fq as Ms,cS as ws,d6 as Cs,d5 as Ss,d7 as js,cV as Ns,cW as Os,cX as _e,cY as Ts,cZ as st,c_ as Ws,c$ as rt}from"./index-fZcP3X7C.js";import{u as Ze,S as Es}from"./similar-transactions-modal-Cdv2FmQ8.js";import{a as wt}from"./addDays-CHr5nY3e.js";import{L as _s}from"./list-plus-ZIHrrCaO.js";import{T as Is}from"./tooltip-r34BEIrK.js";/**
|
|
2
|
-
* @license lucide-react v0.548.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Fs=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ys=bn("external-link",Fs);function Ps(e,t,n){return wt(e,t*7,n)}function Bs(e,t){let n,s=t?.in;return e.forEach(r=>{!s&&typeof r=="object"&&(s=ne.bind(null,r));const a=A(r,s);(!n||n<a||isNaN(+a))&&(n=a)}),ne(s,n||NaN)}function Rs(e,t){let n,s=t?.in;return e.forEach(r=>{!s&&typeof r=="object"&&(s=ne.bind(null,r));const a=A(r,s);(!n||n>a||isNaN(+a))&&(n=a)}),ne(s,n||NaN)}function zs(e,t,n){const[s,r]=pe(n?.in,e,t);return+qe(s)==+qe(r)}function As(e,t,n){const[s,r]=pe(n?.in,e,t),a=s.getFullYear()-r.getFullYear(),c=s.getMonth()-r.getMonth();return a*12+c}function qs(e,t){const n=A(e,t?.in),s=n.getMonth();return n.setFullYear(n.getFullYear(),s+1,0),n.setHours(23,59,59,999),n}function Ct(e,t){const[n,s]=pe(e,t.start,t.end);return{start:n,end:s}}function Hs(e,t){const{start:n,end:s}=Ct(t?.in,e);let r=+n>+s;const a=r?+n:+s,c=r?s:n;c.setHours(0,0,0,0),c.setDate(1);let o=1;const l=[];for(;+c<=a;)l.push(ne(n,c)),c.setMonth(c.getMonth()+o);return r?l.reverse():l}function $s(e,t){const n=A(e,t?.in);return n.setDate(1),n.setHours(0,0,0,0),n}function Zs(e,t){const{start:n,end:s}=Ct(t?.in,e);let r=+n>+s;const a=r?+n:+s,c=r?s:n;c.setHours(0,0,0,0),c.setMonth(0,1);let o=1;const l=[];for(;+c<=a;)l.push(ne(n,c)),c.setFullYear(c.getFullYear()+o);return r?l.reverse():l}function St(e,t){const n=Dn(),s=t?.weekStartsOn??t?.locale?.options?.weekStartsOn??n.weekStartsOn??n.locale?.options?.weekStartsOn??0,r=A(e,t?.in),a=r.getDay(),c=(a<s?-7:0)+6-(a-s);return r.setDate(r.getDate()+c),r.setHours(23,59,59,999),r}function Us(e,t){return St(e,{...t,weekStartsOn:1})}function Ls(e,t){const n=A(e,t?.in),s=n.getFullYear(),r=n.getMonth(),a=ne(n,0);return a.setFullYear(s,r+1,0),a.setHours(0,0,0,0),a.getDate()}function Ks(e,t){return A(e,t?.in).getMonth()}function Gs(e,t){return A(e,t?.in).getFullYear()}function Vs(e,t){return+A(e)>+A(t)}function Js(e,t){return+A(e)<+A(t)}function Qs(e,t,n){const[s,r]=pe(n?.in,e,t);return s.getFullYear()===r.getFullYear()&&s.getMonth()===r.getMonth()}function Xs(e,t,n){const[s,r]=pe(n?.in,e,t);return s.getFullYear()===r.getFullYear()}function er(e,t,n){const s=A(e,n?.in),r=s.getFullYear(),a=s.getDate(),c=ne(e,0);c.setFullYear(r,t,15),c.setHours(0,0,0,0);const o=Ls(c);return s.setMonth(t,Math.min(a,o)),s}function tr(e,t,n){const s=A(e,n?.in);return isNaN(+s)?ne(e,NaN):(s.setFullYear(t),s)}var Ie={exports:{}},Fe,ot;function nr(){if(ot)return Fe;ot=1;var e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";return Fe=e,Fe}var Ye,at;function sr(){if(at)return Ye;at=1;var e=nr();function t(){}function n(){}return n.resetWarningCache=t,Ye=function(){function s(c,o,l,d,f,u){if(u!==e){var h=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw h.name="Invariant Violation",h}}s.isRequired=s;function r(){return s}var a={array:s,bigint:s,bool:s,func:s,number:s,object:s,string:s,symbol:s,any:s,arrayOf:r,element:s,elementType:s,instanceOf:r,node:s,objectOf:r,oneOf:r,oneOfType:r,shape:r,exact:r,checkPropTypes:n,resetWarningCache:t};return a.PropTypes=a,a},Ye}var it;function rr(){return it||(it=1,Ie.exports=sr()()),Ie.exports}var or=rr();const ga=kn(or);function ar(e){return i.jsx(mt,{label:"To Charge",children:i.jsx(gt,{to:yt.CHARGES.DETAIL(e.chargeId),target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),className:"inline-block",children:i.jsx(z,{...e,className:N("size-7.5",e.className),variant:"ghost",children:i.jsx(Ys,{className:"size-5"})})})})}function ir({transactionId:e}){const{updateTransaction:t}=Ze();function n(){t({transactionId:e,fields:{chargeId:Cn}})}return i.jsx(Mn,{onConfirm:n,title:"Are you sure you want to unlink this transaction from the charge?",children:i.jsx(z,{variant:"ghost",size:"icon",className:"size-7.5",children:i.jsx(wn,{className:"size-5"})})})}const cr=({transactionID:e,onDone:t,onChange:n})=>{const[{data:s,fetching:r}]=pt({query:Sn,variables:{transactionIDs:[e]}}),a=s?.transactionsByIDs?.[0],c=xt({defaultValues:a??{}});S.useEffect(()=>{a&&c.reset(a)},[a,c]);const{control:o,handleSubmit:l,formState:{dirtyFields:d}}=c,{updateTransaction:f,fetching:u}=Ze(),h=v=>{if(!a)return;const y=Fn(v,d);t?.(),y&&Object.keys(y).length>0&&f({transactionId:a.id,fields:y}).then(n)},{selectableFinancialEntities:g,fetching:C}=vt();return i.jsxs(i.Fragment,{children:[r&&i.jsx(jn,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),!r&&a&&i.jsx(bt,{...c,children:i.jsxs("form",{onSubmit:l(h),children:[i.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:i.jsxs(Nn,{cols:3,children:[i.jsx(re,{name:"counterpartyId",control:o,defaultValue:a.counterparty?.id,rules:{minLength:{value:2,message:"Minimum 2 characters"}},render:({field:v})=>i.jsxs(oe,{children:[i.jsx(ae,{children:"Counterparty"}),i.jsxs(On,{onValueChange:v.onChange,value:v.value??void 0,disabled:C,children:[i.jsx(ge,{children:i.jsx(Tn,{className:"w-full truncate",children:i.jsx(Wn,{placeholder:"Scroll to see all options"})})}),i.jsx(En,{onClick:y=>y.stopPropagation(),children:g.map(({value:y,label:k})=>i.jsx(_n,{value:y,children:k},y))})]}),i.jsx(le,{})]})}),a?.account.__typename==="CardFinancialAccount"?i.jsx(re,{name:"effectiveDate",control:o,rules:{pattern:{value:Dt,message:"Date must be im format yyyy-mm-dd"}},render:({field:v})=>i.jsxs(oe,{children:[i.jsx(ae,{children:"Effective Date"}),i.jsx(ge,{children:i.jsx(Xo,{...v,onChange:y=>{const k=y?ue(y,"yyyy-MM-dd"):void 0;k!==v.value&&v.onChange(k)},value:v.value?new Date(v.value):void 0})}),i.jsx(le,{})]})}):i.jsx(i.Fragment,{}),i.jsx(re,{name:"isFee",control:o,defaultValue:a.isFee,render:({field:v})=>i.jsxs(oe,{className:"flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm",children:[i.jsx("div",{className:"space-y-0.5",children:i.jsx(ae,{children:"Fee Transaction"})}),i.jsx(ge,{children:i.jsx(In,{checked:v.value===!0,onCheckedChange:v.onChange})})]})})]})}),i.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[i.jsx("button",{type:"submit",onClick:()=>l(h),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:u||Object.keys(d).length===0,children:"Accept"}),i.jsx("button",{type:"button",className:"mt-8 text-white bg-rose-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-rose-600 rounded-sm text-lg",onClick:t,children:"Cancel"})]})]})})]})},lr="insertMiscExpense",dr=()=>{const[{fetching:e},t]=Yn(Pn),n=S.useCallback(async s=>{const r="Error creating misc expense",a=`${lr}-${s.chargeId}`;Ee.loading("Creating misc expense",{id:a});try{const c=await t(s),o=Bn(c,r,a);if(o)return Ee.success("Success",{id:a,description:"Misc expense was created"}),o.insertMiscExpense}catch(c){console.error(`${r}: ${c}`),Ee.error("Error",{id:a,description:r,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,insertMiscExpense:n}},ur=({onDone:e,defaultValues:t={},chargeId:n})=>{const{insertMiscExpense:s,fetching:r}=dr(),a=S.useCallback(async c=>{await s({chargeId:n,fields:c}),e()},[s,n,e]);return i.jsx(fr,{defaultValues:t,onInsertDone:a,fetching:r})},fr=({onInsertDone:e,defaultValues:t,fetching:n})=>{const s=o=>{o&&Object.keys(o).length>0&&e(o)},r=xt({defaultValues:{...t}}),{handleSubmit:a,formState:{dirtyFields:c}}=r;return i.jsx(bt,{...r,children:i.jsx("form",{onSubmit:a(s),noValidate:!0,children:i.jsxs("div",{className:"px-5 flex flex-col gap-5 relative",children:[n&&i.jsx("div",{className:"absolute bg-white/60 z-10 h-full w-full flex items-center justify-center",children:i.jsx("div",{className:"flex items-center",children:i.jsx("span",{className:"text-3xl mr-4",children:i.jsx(Rn,{className:"h-10 w-10 animate-spin mr-2 self-center"})})})}),i.jsx(hr,{formManager:r,isInsert:!0}),i.jsx("div",{className:"flex justify-right gap-5 mt-5",children:i.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",disabled:n||Object.keys(c).length===0,children:"Accept"})})]})})})},hr=({formManager:e,isInsert:t})=>{const{control:n,setValue:s}=e,{selectableFinancialEntities:r,fetching:a}=vt();return i.jsxs(i.Fragment,{children:[i.jsx(re,{name:"creditorId",control:n,rules:{required:t?"Required":void 0},render:({field:c})=>i.jsxs(oe,{children:[i.jsx(ae,{children:"Creditor"}),i.jsx(et,{...c,data:r,value:c.value??void 0,disabled:a,placeholder:"Select creditor",formPart:!0}),i.jsx(le,{})]})}),i.jsx(re,{name:"debtorId",control:n,rules:{required:t?"Required":void 0},render:({field:c})=>i.jsxs(oe,{children:[i.jsx(ae,{children:"Debtor"}),i.jsx(et,{...c,data:r,value:c.value??void 0,disabled:a,placeholder:"Select debtor",formPart:!0}),i.jsx(le,{})]})}),i.jsx(tt,{name:"amount",control:n,rules:{required:t?"Required":void 0},render:({field:c,fieldState:o})=>i.jsx(tt,{name:"currency",control:n,rules:{required:t?"Required":void 0},render:({field:l,fieldState:d})=>i.jsx(zn,{...c,required:t,value:c.value??void 0,error:o.error?.message||d.error?.message,label:"Amount",currencyCodeProps:{...l,required:t,label:"Currency"}})})}),i.jsx(re,{name:"invoiceDate",control:n,rules:{...t?{required:"Required"}:{},pattern:{value:Dt,message:"Date must be im format yyyy-mm-dd"}},render:({field:c})=>{const o=c.value?new Date(c.value):void 0;return i.jsxs(oe,{children:[i.jsx(ae,{children:"Invoice Date"}),i.jsx(ge,{children:i.jsx(An,{...c,required:t,onChange:l=>{const d=l?typeof l=="string"?l:ue(l,"yyyy-MM-dd"):void 0;d!==c.value&&(s("invoiceDate",d),c.onChange(d))},value:o,valueFormat:"DD/MM/YYYY"})}),i.jsx(le,{})]})}}),i.jsx(re,{name:"valueDate",control:n,rules:{...t?{required:"Required"}:{},validate:c=>c?!Number.isNaN(c.getTime())||"Invalid date and time format":!0},render:({field:c})=>i.jsxs(oe,{children:[i.jsx(ae,{children:"Value Date"}),i.jsx(ge,{children:i.jsx(qn,{...c,onChange:o=>{s("valueDate",o),c.onChange(o)},onPointerEnterCapture:()=>{},onPointerLeaveCapture:()=>{},required:t,placeholder:"Pick date and time",valueFormat:"DD/MM/YYYY HH:mm:ss",withSeconds:!0})}),i.jsx(le,{})]})}),i.jsx(re,{name:"description",control:n,rules:{required:t?"Required":void 0},render:({field:c})=>i.jsxs(oe,{children:[i.jsx(ae,{children:"Description"}),i.jsx(ge,{children:i.jsx(kt,{...c,required:t,value:c.value??void 0})}),i.jsx(le,{})]})})]})};function mr(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const gr={},ye={};function de(e,t){try{const s=(gr[e]||=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format)(t).split("GMT")[1];return s in ye?ye[s]:ct(s,s.split(":"))}catch{if(e in ye)return ye[e];const n=e?.match(yr);return n?ct(e,n.slice(1)):NaN}}const yr=/([+-]\d\d):?(\d\d)?/;function ct(e,t){const n=+(t[0]||0),s=+(t[1]||0),r=+(t[2]||0)/60;return ye[e]=n*60+s>0?n*60+s+r:n*60-s-r}class J extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(de(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),jt(this),He(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new J(...n,t):new J(Date.now(),t)}withTimeZone(t){return new J(+this,t)}getTimezoneOffset(){const t=-de(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),He(this),+this}[Symbol.for("constructDateFrom")](t){return new J(+new Date(t),this.timeZone)}}const lt=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!lt.test(e))return;const t=e.replace(lt,"$1UTC");J.prototype[t]&&(e.startsWith("get")?J.prototype[e]=function(){return this.internal[t]()}:(J.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),pr(this),+this},J.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),He(this),+this}))});function He(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-de(e.timeZone,e)*60))}function pr(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),jt(e)}function jt(e){const t=de(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),s=new Date(+e);s.setUTCHours(s.getUTCHours()-1);const r=-new Date(+e).getTimezoneOffset(),a=-new Date(+s).getTimezoneOffset(),c=r-a,o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();c&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+c);const l=r-n;l&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+l);const d=new Date(+e);d.setUTCSeconds(0);const f=r>0?d.getSeconds():(d.getSeconds()-60)%60,u=Math.round(-(de(e.timeZone,e)*60))%60;(u||f)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+f));const h=de(e.timeZone,e),g=h>0?Math.floor(h):Math.ceil(h),v=-new Date(+e).getTimezoneOffset()-g,y=g!==n,k=v-l;if(y&&k){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+k);const W=de(e.timeZone,e),b=W>0?Math.floor(W):Math.ceil(W),T=g-b;T&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+T),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+T))}}class P extends J{static tz(t,...n){return n.length?new P(...n,t):new P(Date.now(),t)}toISOString(){const[t,n,s]=this.tzComponents(),r=`${t}${n}:${s}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,s,r]=this.internal.toUTCString().split(" ");return`${t?.slice(0,-1)} ${s} ${n} ${r}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,s,r]=this.tzComponents();return`${t} GMT${n}${s}${r} (${mr(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:n?.timeZone||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",s=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),r=String(Math.abs(t)%60).padStart(2,"0");return[n,s,r]}withTimeZone(t){return new P(+this,t)}[Symbol.for("constructDateFrom")](t){return new P(+new Date(t),this.timeZone)}}const dt=5,xr=4;function vr(e,t){const n=t.startOfMonth(e),s=n.getDay()>0?n.getDay():7,r=t.addDays(e,-s+1),a=t.addDays(r,dt*7-1);return t.getMonth(e)===t.getMonth(a)?dt:xr}function Nt(e,t){const n=t.startOfMonth(e),s=n.getDay();return s===1?n:s===0?t.addDays(n,-6):t.addDays(n,-1*(s-1))}function br(e,t){const n=Nt(e,t),s=vr(e,t);return t.addDays(n,s*7-1)}class ${constructor(t,n){this.Date=Date,this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?P.tz(this.options.timeZone):new this.Date,this.newDate=(s,r,a)=>this.overrides?.newDate?this.overrides.newDate(s,r,a):this.options.timeZone?new P(s,r,a,this.options.timeZone):new Date(s,r,a),this.addDays=(s,r)=>this.overrides?.addDays?this.overrides.addDays(s,r):wt(s,r),this.addMonths=(s,r)=>this.overrides?.addMonths?this.overrides.addMonths(s,r):Hn(s,r),this.addWeeks=(s,r)=>this.overrides?.addWeeks?this.overrides.addWeeks(s,r):Ps(s,r),this.addYears=(s,r)=>this.overrides?.addYears?this.overrides.addYears(s,r):$n(s,r),this.differenceInCalendarDays=(s,r)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(s,r):Zn(s,r),this.differenceInCalendarMonths=(s,r)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(s,r):As(s,r),this.eachMonthOfInterval=s=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(s):Hs(s),this.eachYearOfInterval=s=>{const r=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(s):Zs(s),a=new Set(r.map(o=>this.getYear(o)));if(a.size===r.length)return r;const c=[];return a.forEach(o=>{c.push(new Date(o,0,1))}),c},this.endOfBroadcastWeek=s=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(s):br(s,this),this.endOfISOWeek=s=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(s):Us(s),this.endOfMonth=s=>this.overrides?.endOfMonth?this.overrides.endOfMonth(s):qs(s),this.endOfWeek=(s,r)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(s,r):St(s,this.options),this.endOfYear=s=>this.overrides?.endOfYear?this.overrides.endOfYear(s):Un(s),this.format=(s,r,a)=>{const c=this.overrides?.format?this.overrides.format(s,r,this.options):ue(s,r,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(c):c},this.getISOWeek=s=>this.overrides?.getISOWeek?this.overrides.getISOWeek(s):Ln(s),this.getMonth=(s,r)=>this.overrides?.getMonth?this.overrides.getMonth(s,this.options):Ks(s,this.options),this.getYear=(s,r)=>this.overrides?.getYear?this.overrides.getYear(s,this.options):Gs(s,this.options),this.getWeek=(s,r)=>this.overrides?.getWeek?this.overrides.getWeek(s,this.options):Kn(s,this.options),this.isAfter=(s,r)=>this.overrides?.isAfter?this.overrides.isAfter(s,r):Vs(s,r),this.isBefore=(s,r)=>this.overrides?.isBefore?this.overrides.isBefore(s,r):Js(s,r),this.isDate=s=>this.overrides?.isDate?this.overrides.isDate(s):Gn(s),this.isSameDay=(s,r)=>this.overrides?.isSameDay?this.overrides.isSameDay(s,r):zs(s,r),this.isSameMonth=(s,r)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(s,r):Qs(s,r),this.isSameYear=(s,r)=>this.overrides?.isSameYear?this.overrides.isSameYear(s,r):Xs(s,r),this.max=s=>this.overrides?.max?this.overrides.max(s):Bs(s),this.min=s=>this.overrides?.min?this.overrides.min(s):Rs(s),this.setMonth=(s,r)=>this.overrides?.setMonth?this.overrides.setMonth(s,r):er(s,r),this.setYear=(s,r)=>this.overrides?.setYear?this.overrides.setYear(s,r):tr(s,r),this.startOfBroadcastWeek=(s,r)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(s,this):Nt(s,this),this.startOfDay=s=>this.overrides?.startOfDay?this.overrides.startOfDay(s):qe(s),this.startOfISOWeek=s=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(s):Vn(s),this.startOfMonth=s=>this.overrides?.startOfMonth?this.overrides.startOfMonth(s):$s(s),this.startOfWeek=(s,r)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(s,this.options):Jn(s,this.options),this.startOfYear=s=>this.overrides?.startOfYear?this.overrides.startOfYear(s):Qn(s),this.options={locale:Mt,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),s={};for(let r=0;r<10;r++)s[r.toString()]=n.format(r);return s}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,s=>n[s]||s)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){const t=this.options.locale?.code;return t&&$.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:s,numerals:r}=this.options,a=n?.code;if(a&&$.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:"long",year:"numeric",timeZone:s,numberingSystem:r}).format(t)}catch{}const c=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,c)}}$.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const Q=new $;class Ot{constructor(t,n,s=Q){this.date=t,this.displayMonth=n,this.outside=!!(n&&!s.isSameMonth(t,n)),this.dateLib=s}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class Dr{constructor(t,n){this.date=t,this.weeks=n}}class kr{constructor(t,n){this.days=n,this.weekNumber=t}}function Mr(e){return m.createElement("button",{...e})}function wr(e){return m.createElement("span",{...e})}function Cr(e){const{size:t=24,orientation:n="left",className:s}=e;return m.createElement("svg",{className:s,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&m.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&m.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&m.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&m.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function Sr(e){const{day:t,modifiers:n,...s}=e;return m.createElement("td",{...s})}function jr(e){const{day:t,modifiers:n,...s}=e,r=m.useRef(null);return m.useEffect(()=>{n.focused&&r.current?.focus()},[n.focused]),m.createElement("button",{ref:r,...s})}var p;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(p||(p={}));var F;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(F||(F={}));var K;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(K||(K={}));var H;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(H||(H={}));function Nr(e){const{options:t,className:n,components:s,classNames:r,...a}=e,c=[r[p.Dropdown],n].join(" "),o=t?.find(({value:l})=>l===a.value);return m.createElement("span",{"data-disabled":a.disabled,className:r[p.DropdownRoot]},m.createElement(s.Select,{className:c,...a},t?.map(({value:l,label:d,disabled:f})=>m.createElement(s.Option,{key:l,value:l,disabled:f},d))),m.createElement("span",{className:r[p.CaptionLabel],"aria-hidden":!0},o?.label,m.createElement(s.Chevron,{orientation:"down",size:18,className:r[p.Chevron]})))}function Or(e){return m.createElement("div",{...e})}function Tr(e){return m.createElement("div",{...e})}function Wr(e){const{calendarMonth:t,displayIndex:n,...s}=e;return m.createElement("div",{...s},e.children)}function Er(e){const{calendarMonth:t,displayIndex:n,...s}=e;return m.createElement("div",{...s})}function _r(e){return m.createElement("table",{...e})}function Ir(e){return m.createElement("div",{...e})}const Tt=S.createContext(void 0);function xe(){const e=S.useContext(Tt);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function Fr(e){const{components:t}=xe();return m.createElement(t.Dropdown,{...e})}function Yr(e){const{onPreviousClick:t,onNextClick:n,previousMonth:s,nextMonth:r,...a}=e,{components:c,classNames:o,labels:{labelPrevious:l,labelNext:d}}=xe(),f=S.useCallback(h=>{r&&n?.(h)},[r,n]),u=S.useCallback(h=>{s&&t?.(h)},[s,t]);return m.createElement("nav",{...a},m.createElement(c.PreviousMonthButton,{type:"button",className:o[p.PreviousMonthButton],tabIndex:s?void 0:-1,"aria-disabled":s?void 0:!0,"aria-label":l(s),onClick:u},m.createElement(c.Chevron,{disabled:s?void 0:!0,className:o[p.Chevron],orientation:"left"})),m.createElement(c.NextMonthButton,{type:"button",className:o[p.NextMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":d(r),onClick:f},m.createElement(c.Chevron,{disabled:r?void 0:!0,orientation:"right",className:o[p.Chevron]})))}function Pr(e){const{components:t}=xe();return m.createElement(t.Button,{...e})}function Br(e){return m.createElement("option",{...e})}function Rr(e){const{components:t}=xe();return m.createElement(t.Button,{...e})}function zr(e){const{rootRef:t,...n}=e;return m.createElement("div",{...n,ref:t})}function Ar(e){return m.createElement("select",{...e})}function qr(e){const{week:t,...n}=e;return m.createElement("tr",{...n})}function Hr(e){return m.createElement("th",{...e})}function $r(e){return m.createElement("thead",{"aria-hidden":!0},m.createElement("tr",{...e}))}function Zr(e){const{week:t,...n}=e;return m.createElement("th",{...n})}function Ur(e){return m.createElement("th",{...e})}function Lr(e){return m.createElement("tbody",{...e})}function Kr(e){const{components:t}=xe();return m.createElement(t.Dropdown,{...e})}const Gr=Object.freeze(Object.defineProperty({__proto__:null,Button:Mr,CaptionLabel:wr,Chevron:Cr,Day:Sr,DayButton:jr,Dropdown:Nr,DropdownNav:Or,Footer:Tr,Month:Wr,MonthCaption:Er,MonthGrid:_r,Months:Ir,MonthsDropdown:Fr,Nav:Yr,NextMonthButton:Pr,Option:Br,PreviousMonthButton:Rr,Root:zr,Select:Ar,Week:qr,WeekNumber:Zr,WeekNumberHeader:Ur,Weekday:Hr,Weekdays:$r,Weeks:Lr,YearsDropdown:Kr},Symbol.toStringTag,{value:"Module"}));function ee(e,t,n=!1,s=Q){let{from:r,to:a}=e;const{differenceInCalendarDays:c,isSameDay:o}=s;return r&&a?(c(a,r)<0&&([r,a]=[a,r]),c(t,r)>=(n?1:0)&&c(a,t)>=(n?1:0)):!n&&a?o(a,t):!n&&r?o(r,t):!1}function Wt(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function Ue(e){return!!(e&&typeof e=="object"&&"from"in e)}function Et(e){return!!(e&&typeof e=="object"&&"after"in e)}function _t(e){return!!(e&&typeof e=="object"&&"before"in e)}function It(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function Ft(e,t){return Array.isArray(e)&&e.every(t.isDate)}function te(e,t,n=Q){const s=Array.isArray(t)?t:[t],{isSameDay:r,differenceInCalendarDays:a,isAfter:c}=n;return s.some(o=>{if(typeof o=="boolean")return o;if(n.isDate(o))return r(e,o);if(Ft(o,n))return o.includes(e);if(Ue(o))return ee(o,e,!1,n);if(It(o))return Array.isArray(o.dayOfWeek)?o.dayOfWeek.includes(e.getDay()):o.dayOfWeek===e.getDay();if(Wt(o)){const l=a(o.before,e),d=a(o.after,e),f=l>0,u=d<0;return c(o.before,o.after)?u&&f:f||u}return Et(o)?a(e,o.after)>0:_t(o)?a(o.before,e)>0:typeof o=="function"?o(e):!1})}function Vr(e,t,n,s,r){const{disabled:a,hidden:c,modifiers:o,showOutsideDays:l,broadcastCalendar:d,today:f}=t,{isSameDay:u,isSameMonth:h,startOfMonth:g,isBefore:C,endOfMonth:v,isAfter:y}=r,k=n&&g(n),W=s&&v(s),b={[F.focused]:[],[F.outside]:[],[F.disabled]:[],[F.hidden]:[],[F.today]:[]},T={};for(const x of e){const{date:D,displayMonth:M}=x,O=!!(M&&!h(D,M)),Y=!!(k&&C(D,k)),B=!!(W&&y(D,W)),R=!!(a&&te(D,a,r)),Z=!!(c&&te(D,c,r))||Y||B||!d&&!l&&O||d&&l===!1&&O,fe=u(D,f??r.today());O&&b.outside.push(x),R&&b.disabled.push(x),Z&&b.hidden.push(x),fe&&b.today.push(x),o&&Object.keys(o).forEach(he=>{const me=o?.[he];me&&te(D,me,r)&&(T[he]?T[he].push(x):T[he]=[x])})}return x=>{const D={[F.focused]:!1,[F.disabled]:!1,[F.hidden]:!1,[F.outside]:!1,[F.today]:!1},M={};for(const O in b){const Y=b[O];D[O]=Y.some(B=>B===x)}for(const O in T)M[O]=T[O].some(Y=>Y===x);return{...D,...M}}}function Jr(e,t,n={}){return Object.entries(e).filter(([,r])=>r===!0).reduce((r,[a])=>(n[a]?r.push(n[a]):t[F[a]]?r.push(t[F[a]]):t[K[a]]&&r.push(t[K[a]]),r),[t[p.Day]])}function Qr(e){return{...Gr,...e}}function Xr(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,s])=>{n.startsWith("data-")&&(t[n]=s)}),t}function Le(){const e={};for(const t in p)e[p[t]]=`rdp-${p[t]}`;for(const t in F)e[F[t]]=`rdp-${F[t]}`;for(const t in K)e[K[t]]=`rdp-${K[t]}`;for(const t in H)e[H[t]]=`rdp-${H[t]}`;return e}function Yt(e,t,n){return(n??new $(t)).formatMonthYear(e)}const eo=Yt;function to(e,t,n){return(n??new $(t)).format(e,"d")}function no(e,t=Q){return t.format(e,"LLLL")}function so(e,t,n){return(n??new $(t)).format(e,"cccccc")}function ro(e,t=Q){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function oo(){return""}function Pt(e,t=Q){return t.format(e,"yyyy")}const ao=Pt,io=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:Yt,formatDay:to,formatMonthCaption:eo,formatMonthDropdown:no,formatWeekNumber:ro,formatWeekNumberHeader:oo,formatWeekdayName:so,formatYearCaption:ao,formatYearDropdown:Pt},Symbol.toStringTag,{value:"Module"}));function co(e){return e?.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e?.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...io,...e}}function lo(e,t,n,s,r){const{startOfMonth:a,startOfYear:c,endOfYear:o,eachMonthOfInterval:l,getMonth:d}=r;return l({start:c(e),end:o(e)}).map(h=>{const g=s.formatMonthDropdown(h,r),C=d(h),v=t&&h<a(t)||n&&h>a(n)||!1;return{value:C,label:g,disabled:v}})}function uo(e,t={},n={}){let s={...t?.[p.Day]};return Object.entries(e).filter(([,r])=>r===!0).forEach(([r])=>{s={...s,...n?.[r]}}),s}function fo(e,t,n){const s=e.today(),r=t?e.startOfISOWeek(s):e.startOfWeek(s),a=[];for(let c=0;c<7;c++){const o=e.addDays(r,c);a.push(o)}return a}function ho(e,t,n,s,r=!1){if(!e||!t)return;const{startOfYear:a,endOfYear:c,eachYearOfInterval:o,getYear:l}=s,d=a(e),f=c(t),u=o({start:d,end:f});return r&&u.reverse(),u.map(h=>{const g=n.formatYearDropdown(h,s);return{value:l(h),label:g,disabled:!1}})}function Bt(e,t,n,s){let r=(s??new $(n)).format(e,"PPPP");return t.today&&(r=`Today, ${r}`),t.selected&&(r=`${r}, selected`),r}const mo=Bt;function Rt(e,t,n){return(n??new $(t)).formatMonthYear(e)}const go=Rt;function yo(e,t,n,s){let r=(s??new $(n)).format(e,"PPPP");return t?.today&&(r=`Today, ${r}`),r}function po(e){return"Choose the Month"}function xo(){return""}function vo(e){return"Go to the Next Month"}function bo(e){return"Go to the Previous Month"}function Do(e,t,n){return(n??new $(t)).format(e,"cccc")}function ko(e,t){return`Week ${e}`}function Mo(e){return"Week Number"}function wo(e){return"Choose the Year"}const Co=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:go,labelDay:mo,labelDayButton:Bt,labelGrid:Rt,labelGridcell:yo,labelMonthDropdown:po,labelNav:xo,labelNext:vo,labelPrevious:bo,labelWeekNumber:ko,labelWeekNumberHeader:Mo,labelWeekday:Do,labelYearDropdown:wo},Symbol.toStringTag,{value:"Module"})),ve=e=>e instanceof HTMLElement?e:null,Pe=e=>[...e.querySelectorAll("[data-animated-month]")??[]],So=e=>ve(e.querySelector("[data-animated-month]")),Be=e=>ve(e.querySelector("[data-animated-caption]")),Re=e=>ve(e.querySelector("[data-animated-weeks]")),jo=e=>ve(e.querySelector("[data-animated-nav]")),No=e=>ve(e.querySelector("[data-animated-weekdays]"));function Oo(e,t,{classNames:n,months:s,focused:r,dateLib:a}){const c=S.useRef(null),o=S.useRef(s),l=S.useRef(!1);S.useLayoutEffect(()=>{const d=o.current;if(o.current=s,!t||!e.current||!(e.current instanceof HTMLElement)||s.length===0||d.length===0||s.length!==d.length)return;const f=a.isSameMonth(s[0].date,d[0].date),u=a.isAfter(s[0].date,d[0].date),h=u?n[H.caption_after_enter]:n[H.caption_before_enter],g=u?n[H.weeks_after_enter]:n[H.weeks_before_enter],C=c.current,v=e.current.cloneNode(!0);if(v instanceof HTMLElement?(Pe(v).forEach(b=>{if(!(b instanceof HTMLElement))return;const T=So(b);T&&b.contains(T)&&b.removeChild(T);const x=Be(b);x&&x.classList.remove(h);const D=Re(b);D&&D.classList.remove(g)}),c.current=v):c.current=null,l.current||f||r)return;const y=C instanceof HTMLElement?Pe(C):[],k=Pe(e.current);if(k?.every(W=>W instanceof HTMLElement)&&y&&y.every(W=>W instanceof HTMLElement)){l.current=!0,e.current.style.isolation="isolate";const W=jo(e.current);W&&(W.style.zIndex="1"),k.forEach((b,T)=>{const x=y[T];if(!x)return;b.style.position="relative",b.style.overflow="hidden";const D=Be(b);D&&D.classList.add(h);const M=Re(b);M&&M.classList.add(g);const O=()=>{l.current=!1,e.current&&(e.current.style.isolation=""),W&&(W.style.zIndex=""),D&&D.classList.remove(h),M&&M.classList.remove(g),b.style.position="",b.style.overflow="",b.contains(x)&&b.removeChild(x)};x.style.pointerEvents="none",x.style.position="absolute",x.style.overflow="hidden",x.setAttribute("aria-hidden","true");const Y=No(x);Y&&(Y.style.opacity="0");const B=Be(x);B&&(B.classList.add(u?n[H.caption_before_exit]:n[H.caption_after_exit]),B.addEventListener("animationend",O));const R=Re(x);R&&R.classList.add(u?n[H.weeks_before_exit]:n[H.weeks_after_exit]),b.insertBefore(x,b.firstChild)})}})}function To(e,t,n,s){const r=e[0],a=e[e.length-1],{ISOWeek:c,fixedWeeks:o,broadcastCalendar:l}=n??{},{addDays:d,differenceInCalendarDays:f,differenceInCalendarMonths:u,endOfBroadcastWeek:h,endOfISOWeek:g,endOfMonth:C,endOfWeek:v,isAfter:y,startOfBroadcastWeek:k,startOfISOWeek:W,startOfWeek:b}=s,T=l?k(r,s):c?W(r):b(r),x=l?h(a):c?g(C(a)):v(C(a)),D=f(x,T),M=u(a,r)+1,O=[];for(let R=0;R<=D;R++){const Z=d(T,R);if(t&&y(Z,t))break;O.push(Z)}const B=(l?35:42)*M;if(o&&O.length<B){const R=B-O.length;for(let Z=0;Z<R;Z++){const fe=d(O[O.length-1],1);O.push(fe)}}return O}function Wo(e){const t=[];return e.reduce((n,s)=>{const r=s.weeks.reduce((a,c)=>a.concat(c.days.slice()),t.slice());return n.concat(r.slice())},t.slice())}function Eo(e,t,n,s){const{numberOfMonths:r=1}=n,a=[];for(let c=0;c<r;c++){const o=s.addMonths(e,c);if(t&&o>t)break;a.push(o)}return a}function ut(e,t,n,s){const{month:r,defaultMonth:a,today:c=s.today(),numberOfMonths:o=1}=e;let l=r||a||c;const{differenceInCalendarMonths:d,addMonths:f,startOfMonth:u}=s;if(n&&d(n,l)<o-1){const h=-1*(o-1);l=f(n,h)}return t&&d(l,t)<0&&(l=t),u(l)}function _o(e,t,n,s){const{addDays:r,endOfBroadcastWeek:a,endOfISOWeek:c,endOfMonth:o,endOfWeek:l,getISOWeek:d,getWeek:f,startOfBroadcastWeek:u,startOfISOWeek:h,startOfWeek:g}=s,C=e.reduce((v,y)=>{const k=n.broadcastCalendar?u(y,s):n.ISOWeek?h(y):g(y),W=n.broadcastCalendar?a(y):n.ISOWeek?c(o(y)):l(o(y)),b=t.filter(M=>M>=k&&M<=W),T=n.broadcastCalendar?35:42;if(n.fixedWeeks&&b.length<T){const M=t.filter(O=>{const Y=T-b.length;return O>W&&O<=r(W,Y)});b.push(...M)}const x=b.reduce((M,O)=>{const Y=n.ISOWeek?d(O):f(O),B=M.find(Z=>Z.weekNumber===Y),R=new Ot(O,y,s);return B?B.days.push(R):M.push(new kr(Y,[R])),M},[]),D=new Dr(y,x);return v.push(D),v},[]);return n.reverseMonths?C.reverse():C}function Io(e,t){let{startMonth:n,endMonth:s}=e;const{startOfYear:r,startOfDay:a,startOfMonth:c,endOfMonth:o,addYears:l,endOfYear:d,newDate:f,today:u}=t,{fromYear:h,toYear:g,fromMonth:C,toMonth:v}=e;!n&&C&&(n=C),!n&&h&&(n=t.newDate(h,0,1)),!s&&v&&(s=v),!s&&g&&(s=f(g,11,31));const y=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=c(n):h?n=f(h,0,1):!n&&y&&(n=r(l(e.today??u(),-100))),s?s=o(s):g?s=f(g,11,31):!s&&y&&(s=d(e.today??u())),[n&&a(n),s&&a(s)]}function Fo(e,t,n,s){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:a=1}=n,{startOfMonth:c,addMonths:o,differenceInCalendarMonths:l}=s,d=r?a:1,f=c(e);if(!t)return o(f,d);if(!(l(t,e)<a))return o(f,d)}function Yo(e,t,n,s){if(n.disableNavigation)return;const{pagedNavigation:r,numberOfMonths:a}=n,{startOfMonth:c,addMonths:o,differenceInCalendarMonths:l}=s,d=r?a??1:1,f=c(e);if(!t)return o(f,-d);if(!(l(f,t)<=0))return o(f,-d)}function Po(e){const t=[];return e.reduce((n,s)=>n.concat(s.weeks.slice()),t.slice())}function Me(e,t){const[n,s]=S.useState(e);return[t===void 0?n:t,s]}function Bo(e,t){const[n,s]=Io(e,t),{startOfMonth:r,endOfMonth:a}=t,c=ut(e,n,s,t),[o,l]=Me(c,e.month?c:void 0);S.useEffect(()=>{const D=ut(e,n,s,t);l(D)},[e.timeZone]);const d=Eo(o,s,e,t),f=To(d,e.endMonth?a(e.endMonth):void 0,e,t),u=_o(d,f,e,t),h=Po(u),g=Wo(u),C=Yo(o,n,e,t),v=Fo(o,s,e,t),{disableNavigation:y,onMonthChange:k}=e,W=D=>h.some(M=>M.days.some(O=>O.isEqualTo(D))),b=D=>{if(y)return;let M=r(D);n&&M<r(n)&&(M=r(n)),s&&M>r(s)&&(M=r(s)),l(M),k?.(M)};return{months:u,weeks:h,days:g,navStart:n,navEnd:s,previousMonth:C,nextMonth:v,goToMonth:b,goToDay:D=>{W(D)||b(D.date)}}}var V;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(V||(V={}));function ft(e){return!e[F.disabled]&&!e[F.hidden]&&!e[F.outside]}function Ro(e,t,n,s){let r,a=-1;for(const c of e){const o=t(c);ft(o)&&(o[F.focused]&&a<V.FocusedModifier?(r=c,a=V.FocusedModifier):s?.isEqualTo(c)&&a<V.LastFocused?(r=c,a=V.LastFocused):n(c.date)&&a<V.Selected?(r=c,a=V.Selected):o[F.today]&&a<V.Today&&(r=c,a=V.Today))}return r||(r=e.find(c=>ft(t(c)))),r}function zo(e,t,n,s,r,a,c){const{ISOWeek:o,broadcastCalendar:l}=a,{addDays:d,addMonths:f,addWeeks:u,addYears:h,endOfBroadcastWeek:g,endOfISOWeek:C,endOfWeek:v,max:y,min:k,startOfBroadcastWeek:W,startOfISOWeek:b,startOfWeek:T}=c;let D={day:d,week:u,month:f,year:h,startOfWeek:M=>l?W(M,c):o?b(M):T(M),endOfWeek:M=>l?g(M):o?C(M):v(M)}[e](n,t==="after"?1:-1);return t==="before"&&s?D=y([s,D]):t==="after"&&r&&(D=k([r,D])),D}function zt(e,t,n,s,r,a,c,o=0){if(o>365)return;const l=zo(e,t,n.date,s,r,a,c),d=!!(a.disabled&&te(l,a.disabled,c)),f=!!(a.hidden&&te(l,a.hidden,c)),u=l,h=new Ot(l,u,c);return!d&&!f?h:zt(e,t,h,s,r,a,c,o+1)}function Ao(e,t,n,s,r){const{autoFocus:a}=e,[c,o]=S.useState(),l=Ro(t.days,n,s||(()=>!1),c),[d,f]=S.useState(a?l:void 0);return{isFocusTarget:v=>!!l?.isEqualTo(v),setFocused:f,focused:d,blur:()=>{o(d),f(void 0)},moveFocus:(v,y)=>{if(!d)return;const k=zt(v,y,d,t.navStart,t.navEnd,e,r);k&&(e.disableNavigation&&!t.days.some(b=>b.isEqualTo(k))||(t.goToDay(k),f(k)))}}}function qo(e,t){const{selected:n,required:s,onSelect:r}=e,[a,c]=Me(n,r?n:void 0),o=r?n:a,{isSameDay:l}=t,d=g=>o?.some(C=>l(C,g))??!1,{min:f,max:u}=e;return{selected:o,select:(g,C,v)=>{let y=[...o??[]];if(d(g)){if(o?.length===f||s&&o?.length===1)return;y=o?.filter(k=>!l(k,g))}else o?.length===u?y=[g]:y=[...y,g];return r||c(y),r?.(y,g,C,v),y},isSelected:d}}function Ho(e,t,n=0,s=0,r=!1,a=Q){const{from:c,to:o}=t||{},{isSameDay:l,isAfter:d,isBefore:f}=a;let u;if(!c&&!o)u={from:e,to:n>0?void 0:e};else if(c&&!o)l(c,e)?n===0?u={from:c,to:e}:r?u={from:c,to:void 0}:u=void 0:f(e,c)?u={from:e,to:c}:u={from:c,to:e};else if(c&&o)if(l(c,e)&&l(o,e))r?u={from:c,to:o}:u=void 0;else if(l(c,e))u={from:c,to:n>0?void 0:e};else if(l(o,e))u={from:e,to:n>0?void 0:e};else if(f(e,c))u={from:e,to:o};else if(d(e,c))u={from:c,to:e};else if(d(e,o))u={from:c,to:e};else throw new Error("Invalid range");if(u?.from&&u?.to){const h=a.differenceInCalendarDays(u.to,u.from);s>0&&h>s?u={from:e,to:void 0}:n>1&&h<n&&(u={from:e,to:void 0})}return u}function $o(e,t,n=Q){const s=Array.isArray(t)?t:[t];let r=e.from;const a=n.differenceInCalendarDays(e.to,e.from),c=Math.min(a,6);for(let o=0;o<=c;o++){if(s.includes(r.getDay()))return!0;r=n.addDays(r,1)}return!1}function ht(e,t,n=Q){return ee(e,t.from,!1,n)||ee(e,t.to,!1,n)||ee(t,e.from,!1,n)||ee(t,e.to,!1,n)}function Zo(e,t,n=Q){const s=Array.isArray(t)?t:[t];if(s.filter(o=>typeof o!="function").some(o=>typeof o=="boolean"?o:n.isDate(o)?ee(e,o,!1,n):Ft(o,n)?o.some(l=>ee(e,l,!1,n)):Ue(o)?o.from&&o.to?ht(e,{from:o.from,to:o.to},n):!1:It(o)?$o(e,o.dayOfWeek,n):Wt(o)?n.isAfter(o.before,o.after)?ht(e,{from:n.addDays(o.after,1),to:n.addDays(o.before,-1)},n):te(e.from,o,n)||te(e.to,o,n):Et(o)||_t(o)?te(e.from,o,n)||te(e.to,o,n):!1))return!0;const c=s.filter(o=>typeof o=="function");if(c.length){let o=e.from;const l=n.differenceInCalendarDays(e.to,e.from);for(let d=0;d<=l;d++){if(c.some(f=>f(o)))return!0;o=n.addDays(o,1)}}return!1}function Uo(e,t){const{disabled:n,excludeDisabled:s,selected:r,required:a,onSelect:c}=e,[o,l]=Me(r,c?r:void 0),d=c?r:o;return{selected:d,select:(h,g,C)=>{const{min:v,max:y}=e,k=h?Ho(h,d,v,y,a,t):void 0;return s&&n&&k?.from&&k.to&&Zo({from:k.from,to:k.to},n,t)&&(k.from=h,k.to=void 0),c||l(k),c?.(k,h,g,C),k},isSelected:h=>d&&ee(d,h,!1,t)}}function Lo(e,t){const{selected:n,required:s,onSelect:r}=e,[a,c]=Me(n,r?n:void 0),o=r?n:a,{isSameDay:l}=t;return{selected:o,select:(u,h,g)=>{let C=u;return!s&&o&&o&&l(u,o)&&(C=void 0),r||c(C),r?.(C,u,h,g),C},isSelected:u=>o?l(o,u):!1}}function Ko(e,t){const n=Lo(e,t),s=qo(e,t),r=Uo(e,t);switch(e.mode){case"single":return n;case"multiple":return s;case"range":return r;default:return}}function Go(e){let t=e;t.timeZone&&(t={...e},t.today&&(t.today=new P(t.today,t.timeZone)),t.month&&(t.month=new P(t.month,t.timeZone)),t.defaultMonth&&(t.defaultMonth=new P(t.defaultMonth,t.timeZone)),t.startMonth&&(t.startMonth=new P(t.startMonth,t.timeZone)),t.endMonth&&(t.endMonth=new P(t.endMonth,t.timeZone)),t.mode==="single"&&t.selected?t.selected=new P(t.selected,t.timeZone):t.mode==="multiple"&&t.selected?t.selected=t.selected?.map(j=>new P(j,t.timeZone)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?new P(t.selected.from,t.timeZone):void 0,to:t.selected.to?new P(t.selected.to,t.timeZone):void 0}));const{components:n,formatters:s,labels:r,dateLib:a,locale:c,classNames:o}=S.useMemo(()=>{const j={...Mt,...t.locale};return{dateLib:new $({locale:j,weekStartsOn:t.broadcastCalendar?1:t.weekStartsOn,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},t.dateLib),components:Qr(t.components),formatters:co(t.formatters),labels:{...Co,...t.labels},locale:j,classNames:{...Le(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.components,t.formatters,t.labels,t.classNames]),{captionLayout:l,mode:d,navLayout:f,numberOfMonths:u=1,onDayBlur:h,onDayClick:g,onDayFocus:C,onDayKeyDown:v,onDayMouseEnter:y,onDayMouseLeave:k,onNextClick:W,onPrevClick:b,showWeekNumber:T,styles:x}=t,{formatCaption:D,formatDay:M,formatMonthDropdown:O,formatWeekNumber:Y,formatWeekNumberHeader:B,formatWeekdayName:R,formatYearDropdown:Z}=s,fe=Bo(t,a),{days:he,months:me,navStart:be,navEnd:we,previousMonth:U,nextMonth:L,goToMonth:X}=fe,Ce=Vr(he,t,be,we,a),{isSelected:Se,select:je,selected:De}=Ko(t,a)??{},{blur:Ke,focused:Ge,isFocusTarget:Ut,moveFocus:Ve,setFocused:ke}=Ao(t,fe,Ce,Se??(()=>!1),a),{labelDayButton:Lt,labelGridcell:Kt,labelGrid:Gt,labelMonthDropdown:Vt,labelNav:Je,labelPrevious:Jt,labelNext:Qt,labelWeekday:Xt,labelWeekNumber:en,labelWeekNumberHeader:tn,labelYearDropdown:nn}=r,sn=S.useMemo(()=>fo(a,t.ISOWeek),[a,t.ISOWeek]),Qe=d!==void 0||g!==void 0,Ne=S.useCallback(()=>{U&&(X(U),b?.(U))},[U,X,b]),Oe=S.useCallback(()=>{L&&(X(L),W?.(L))},[X,L,W]),rn=S.useCallback((j,I)=>w=>{w.preventDefault(),w.stopPropagation(),ke(j),je?.(j.date,I,w),g?.(j.date,I,w)},[je,g,ke]),on=S.useCallback((j,I)=>w=>{ke(j),C?.(j.date,I,w)},[C,ke]),an=S.useCallback((j,I)=>w=>{Ke(),h?.(j.date,I,w)},[Ke,h]),cn=S.useCallback((j,I)=>w=>{const _={ArrowLeft:[w.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[w.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[w.shiftKey?"year":"week","after"],ArrowUp:[w.shiftKey?"year":"week","before"],PageUp:[w.shiftKey?"year":"month","before"],PageDown:[w.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(_[w.key]){w.preventDefault(),w.stopPropagation();const[q,E]=_[w.key];Ve(q,E)}v?.(j.date,I,w)},[Ve,v,t.dir]),ln=S.useCallback((j,I)=>w=>{y?.(j.date,I,w)},[y]),dn=S.useCallback((j,I)=>w=>{k?.(j.date,I,w)},[k]),un=S.useCallback(j=>I=>{const w=Number(I.target.value),_=a.setMonth(a.startOfMonth(j),w);X(_)},[a,X]),fn=S.useCallback(j=>I=>{const w=Number(I.target.value),_=a.setYear(a.startOfMonth(j),w);X(_)},[a,X]),{className:hn,style:mn}=S.useMemo(()=>({className:[o[p.Root],t.className].filter(Boolean).join(" "),style:{...x?.[p.Root],...t.style}}),[o,t.className,t.style,x]),gn=Xr(t),Xe=S.useRef(null);Oo(Xe,!!t.animate,{classNames:o,months:me,focused:Ge,dateLib:a});const yn={dayPickerProps:t,selected:De,select:je,isSelected:Se,months:me,nextMonth:L,previousMonth:U,goToMonth:X,getModifiers:Ce,components:n,classNames:o,styles:x,labels:r,formatters:s};return m.createElement(Tt.Provider,{value:yn},m.createElement(n.Root,{rootRef:t.animate?Xe:void 0,className:hn,style:mn,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...gn},m.createElement(n.Months,{className:o[p.Months],style:x?.[p.Months]},!t.hideNavigation&&!f&&m.createElement(n.Nav,{"data-animated-nav":t.animate?"true":void 0,className:o[p.Nav],style:x?.[p.Nav],"aria-label":Je(),onPreviousClick:Ne,onNextClick:Oe,previousMonth:U,nextMonth:L}),me.map((j,I)=>m.createElement(n.Month,{"data-animated-month":t.animate?"true":void 0,className:o[p.Month],style:x?.[p.Month],key:I,displayIndex:I,calendarMonth:j},f==="around"&&!t.hideNavigation&&I===0&&m.createElement(n.PreviousMonthButton,{type:"button",className:o[p.PreviousMonthButton],tabIndex:U?void 0:-1,"aria-disabled":U?void 0:!0,"aria-label":Jt(U),onClick:Ne,"data-animated-button":t.animate?"true":void 0},m.createElement(n.Chevron,{disabled:U?void 0:!0,className:o[p.Chevron],orientation:t.dir==="rtl"?"right":"left"})),m.createElement(n.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:o[p.MonthCaption],style:x?.[p.MonthCaption],calendarMonth:j,displayIndex:I},l?.startsWith("dropdown")?m.createElement(n.DropdownNav,{className:o[p.Dropdowns],style:x?.[p.Dropdowns]},(()=>{const w=l==="dropdown"||l==="dropdown-months"?m.createElement(n.MonthsDropdown,{key:"month",className:o[p.MonthsDropdown],"aria-label":Vt(),classNames:o,components:n,disabled:!!t.disableNavigation,onChange:un(j.date),options:lo(j.date,be,we,s,a),style:x?.[p.Dropdown],value:a.getMonth(j.date)}):m.createElement("span",{key:"month"},O(j.date,a)),_=l==="dropdown"||l==="dropdown-years"?m.createElement(n.YearsDropdown,{key:"year",className:o[p.YearsDropdown],"aria-label":nn(a.options),classNames:o,components:n,disabled:!!t.disableNavigation,onChange:fn(j.date),options:ho(be,we,s,a,!!t.reverseYears),style:x?.[p.Dropdown],value:a.getYear(j.date)}):m.createElement("span",{key:"year"},Z(j.date,a));return a.getMonthYearOrder()==="year-first"?[_,w]:[w,_]})(),m.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},D(j.date,a.options,a))):m.createElement(n.CaptionLabel,{className:o[p.CaptionLabel],role:"status","aria-live":"polite"},D(j.date,a.options,a))),f==="around"&&!t.hideNavigation&&I===u-1&&m.createElement(n.NextMonthButton,{type:"button",className:o[p.NextMonthButton],tabIndex:L?void 0:-1,"aria-disabled":L?void 0:!0,"aria-label":Qt(L),onClick:Oe,"data-animated-button":t.animate?"true":void 0},m.createElement(n.Chevron,{disabled:L?void 0:!0,className:o[p.Chevron],orientation:t.dir==="rtl"?"left":"right"})),I===u-1&&f==="after"&&!t.hideNavigation&&m.createElement(n.Nav,{"data-animated-nav":t.animate?"true":void 0,className:o[p.Nav],style:x?.[p.Nav],"aria-label":Je(),onPreviousClick:Ne,onNextClick:Oe,previousMonth:U,nextMonth:L}),m.createElement(n.MonthGrid,{role:"grid","aria-multiselectable":d==="multiple"||d==="range","aria-label":Gt(j.date,a.options,a)||void 0,className:o[p.MonthGrid],style:x?.[p.MonthGrid]},!t.hideWeekdays&&m.createElement(n.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:o[p.Weekdays],style:x?.[p.Weekdays]},T&&m.createElement(n.WeekNumberHeader,{"aria-label":tn(a.options),className:o[p.WeekNumberHeader],style:x?.[p.WeekNumberHeader],scope:"col"},B()),sn.map(w=>m.createElement(n.Weekday,{"aria-label":Xt(w,a.options,a),className:o[p.Weekday],key:String(w),style:x?.[p.Weekday],scope:"col"},R(w,a.options,a)))),m.createElement(n.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:o[p.Weeks],style:x?.[p.Weeks]},j.weeks.map(w=>m.createElement(n.Week,{className:o[p.Week],key:w.weekNumber,style:x?.[p.Week],week:w},T&&m.createElement(n.WeekNumber,{week:w,style:x?.[p.WeekNumber],"aria-label":en(w.weekNumber,{locale:c}),className:o[p.WeekNumber],scope:"row",role:"rowheader"},Y(w.weekNumber,a)),w.days.map(_=>{const{date:q}=_,E=Ce(_);if(E[F.focused]=!E.hidden&&!!Ge?.isEqualTo(_),E[K.selected]=Se?.(q)||E.selected,Ue(De)){const{from:Te,to:We}=De;E[K.range_start]=!!(Te&&We&&a.isSameDay(q,Te)),E[K.range_end]=!!(Te&&We&&a.isSameDay(q,We)),E[K.range_middle]=ee(De,q,!0,a)}const pn=uo(E,x,t.modifiersStyles),xn=Jr(E,o,t.modifiersClassNames),vn=!Qe&&!E.hidden?Kt(q,E,a.options,a):void 0;return m.createElement(n.Day,{key:`${a.format(q,"yyyy-MM-dd")}_${a.format(_.displayMonth,"yyyy-MM")}`,day:_,modifiers:E,className:xn.join(" "),style:pn,role:"gridcell","aria-selected":E.selected||void 0,"aria-label":vn,"data-day":a.format(q,"yyyy-MM-dd"),"data-month":_.outside?a.format(q,"yyyy-MM"):void 0,"data-selected":E.selected||void 0,"data-disabled":E.disabled||void 0,"data-hidden":E.hidden||void 0,"data-outside":_.outside||void 0,"data-focused":E.focused||void 0,"data-today":E.today||void 0},!E.hidden&&Qe?m.createElement(n.DayButton,{className:o[p.DayButton],style:x?.[p.DayButton],type:"button",day:_,modifiers:E,disabled:E.disabled||void 0,tabIndex:Ut(_)?0:-1,"aria-label":Lt(q,E,a.options,a),onClick:rn(_,E),onBlur:an(_,E),onFocus:on(_,E),onKeyDown:cn(_,E),onMouseEnter:ln(_,E),onMouseLeave:dn(_,E)},M(q,a.options,a)):!E.hidden&&M(_.date,a.options,a))})))))))),t.footer&&m.createElement(n.Footer,{className:o[p.Footer],style:x?.[p.Footer],role:"status","aria-live":"polite"},t.footer)))}function Vo({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:s="label",buttonVariant:r="ghost",formatters:a,components:c,...o}){const l=Le();return i.jsx(Go,{showOutsideDays:n,className:N("bg-white group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent dark:bg-gray-950",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:s,formatters:{formatMonthDropdown:d=>d.toLocaleString("default",{month:"short"}),...a},classNames:{root:N("w-fit",l.root),months:N("flex gap-4 flex-col md:flex-row relative",l.months),month:N("flex flex-col w-full gap-4",l.month),nav:N("flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between",l.nav),button_previous:N(nt({variant:r}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",l.button_previous),button_next:N(nt({variant:r}),"size-(--cell-size) aria-disabled:opacity-50 p-0 select-none",l.button_next),month_caption:N("flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)",l.month_caption),dropdowns:N("w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5",l.dropdowns),dropdown_root:N("relative has-focus:border-gray-950 border border-gray-200 shadow-xs has-focus:ring-gray-950/50 has-focus:ring-[3px] rounded-md dark:has-focus:border-gray-300 dark:border-gray-800 dark:has-focus:ring-gray-300/50",l.dropdown_root),dropdown:N("absolute bg-white inset-0 opacity-0 dark:bg-gray-950",l.dropdown),caption_label:N("select-none font-medium",s==="label"?"text-sm":"rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-gray-500 [&>svg]:size-3.5 dark:[&>svg]:text-gray-400",l.caption_label),table:"w-full border-collapse",weekdays:N("flex",l.weekdays),weekday:N("text-gray-500 rounded-md flex-1 font-normal text-[0.8rem] select-none dark:text-gray-400",l.weekday),week:N("flex w-full mt-2",l.week),week_number_header:N("select-none w-(--cell-size)",l.week_number_header),week_number:N("text-[0.8rem] select-none text-gray-500 dark:text-gray-400",l.week_number),day:N("relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none",l.day),range_start:N("rounded-l-md bg-gray-100 dark:bg-gray-800",l.range_start),range_middle:N("rounded-none",l.range_middle),range_end:N("rounded-r-md bg-gray-100 dark:bg-gray-800",l.range_end),today:N("bg-gray-100 text-gray-900 rounded-md data-[selected=true]:rounded-none dark:bg-gray-800 dark:text-gray-50",l.today),outside:N("text-gray-500 aria-selected:text-gray-500 dark:text-gray-400 dark:aria-selected:text-gray-400",l.outside),disabled:N("text-gray-500 opacity-50 dark:text-gray-400",l.disabled),hidden:N("invisible",l.hidden),...t},components:{Root:({className:d,rootRef:f,...u})=>i.jsx("div",{"data-slot":"calendar",ref:f,className:N(d),...u}),Chevron:({className:d,orientation:f,...u})=>f==="left"?i.jsx(Xn,{className:N("size-4",d),...u}):f==="right"?i.jsx(es,{className:N("size-4",d),...u}):i.jsx(se,{className:N("size-4",d),...u}),DayButton:Jo,WeekNumber:({children:d,...f})=>i.jsx("td",{...f,children:i.jsx("div",{className:"flex size-(--cell-size) items-center justify-center text-center",children:d})}),...c},...o})}function Jo({className:e,day:t,modifiers:n,...s}){const r=Le(),a=m.useRef(null);return m.useEffect(()=>{n.focused&&a.current?.focus()},[n.focused]),i.jsx(z,{ref:a,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:N("data-[selected-single=true]:bg-gray-900 data-[selected-single=true]:text-gray-50 data-[range-middle=true]:bg-gray-100 data-[range-middle=true]:text-gray-900 data-[range-start=true]:bg-gray-900 data-[range-start=true]:text-gray-50 data-[range-end=true]:bg-gray-900 data-[range-end=true]:text-gray-50 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-gray-900 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70 dark:data-[selected-single=true]:bg-gray-50 dark:data-[selected-single=true]:text-gray-900 dark:data-[range-middle=true]:bg-gray-800 dark:data-[range-middle=true]:text-gray-50 dark:data-[range-start=true]:bg-gray-50 dark:data-[range-start=true]:text-gray-900 dark:data-[range-end=true]:bg-gray-50 dark:data-[range-end=true]:text-gray-900 dark:dark:hover:text-gray-50",r.day,e),...s})}function ze(e){return e?ue(e,"yyyy-MM-dd"):""}function Qo(e){return e?!Number.isNaN(e.getTime()):!1}function Xo({value:e,onChange:t,disabled:n,...s}){const[r,a]=m.useState(!1),[c,o]=m.useState(e),[l,d]=m.useState(ze(e));return S.useEffect(()=>{e&&d(ze(e))},[e]),i.jsxs("div",{className:"relative flex gap-2",children:[i.jsx(kt,{...s,disabled:n,value:l,onChange:f=>{d(f.target.value);const u=f.target.value?new Date(f.target.value):void 0;Qo(u)&&(t?.(u),o(u))},onKeyDown:f=>{f.key==="ArrowDown"&&(f.preventDefault(),a(!0))}}),i.jsxs(ts,{open:r,onOpenChange:a,children:[i.jsx(ns,{asChild:!0,children:i.jsxs(z,{id:"date-picker",variant:"ghost",className:"absolute top-1/2 right-2 size-6 -translate-y-1/2",disabled:n,children:[i.jsx(ss,{className:"size-3.5"}),i.jsx("span",{className:"sr-only",children:"Select date"})]})}),i.jsx(rs,{className:"w-auto overflow-hidden p-0",align:"end",alignOffset:-8,sideOffset:10,children:i.jsx(Vo,{mode:"single",selected:e,captionLayout:"dropdown",month:c,onMonthChange:o,onSelect:f=>{t?.(f),d(ze(f??void 0)),a(!1)}})})]})]})}const ea=({close:e,transactionID:t,onChange:n})=>t?i.jsx(os,{modalSize:"fit-content",position:"bottom",title:i.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[i.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Transaction:"}),i.jsxs("div",{className:"flex flex-row gap-2",children:["ID: ",t,i.jsx(as,{content:t}),i.jsx(ir,{transactionId:t})]})]}),opened:!!t,onClose:e,children:i.jsx(cr,{transactionID:t,onDone:e,onChange:n})}):null,ta=({onDone:e,transactionId:t,chargeId:n})=>{const[s,r]=S.useState(!1),[{data:a,fetching:c}]=pt({query:is,pause:!t,variables:{transactionId:t}}),o=a?.transactionsByIDs[0];function l(){r(!1),e?.()}return i.jsxs(cs,{open:s,onOpenChange:r,children:[i.jsx(ls,{asChild:!0,children:i.jsx(mt,{label:"Insert Related Misc Expense",children:i.jsx(z,{variant:"ghost",size:"icon",className:"size-7.5",disabled:c,children:i.jsx(_s,{className:"size-5"})})})}),i.jsxs(ds,{className:"sm:max-w-[425px]",children:[i.jsx(us,{children:i.jsx(fs,{children:"Insert Misc Expense"})}),o&&i.jsx(ur,{onDone:l,chargeId:n,defaultValues:{amount:o?.amount.raw?Math.abs(o?.amount.raw):void 0,currency:o?.amount.currency,invoiceDate:o?.eventDate,valueDate:o?.exactEffectiveDate||o?.effectiveDate?new Date(o.exactEffectiveDate??o.effectiveDate):void 0,creditorId:(o?.amount.raw??0)>0?o?.counterparty?.id:void 0,debtorId:(o?.amount.raw??0)<0?o?.counterparty?.id:void 0}})]})]})},At=({onChange:e,total:t,value:n,...s})=>{if(t<=1)return null;const r=n+1;return i.jsx(qt,{...s,children:i.jsxs(Ht,{children:[i.jsx(G,{children:i.jsx($t,{disabled:r<=1,onClick:()=>e(n-1)})}),t>3&&r>1&&i.jsx(G,{children:i.jsx(ie,{onClick:()=>e(0),children:"1"})}),t>3&&r>3&&i.jsx(G,{children:i.jsx($e,{})}),r>2&&i.jsx(G,{children:i.jsx(ie,{onClick:()=>e(n-1),children:r-1})}),i.jsx(G,{children:i.jsx(ie,{onClick:()=>{},isActive:!0,children:r})}),r<t-1&&i.jsx(G,{children:i.jsx(ie,{onClick:()=>e(n+1),children:r+1})}),t>3&&r<t-2&&i.jsx(G,{children:i.jsx($e,{})}),t>3&&r<t&&i.jsx(G,{children:i.jsx(ie,{onClick:()=>e(t-1),children:t})}),i.jsx(G,{children:i.jsx(Zt,{disabled:r>=t,onClick:()=>e(n+1)})})]})})};At.displayName="Pagination";const qt=({className:e,...t})=>i.jsx("nav",{role:"navigation","aria-label":"paginationWrapper",className:N("mx-auto flex w-full justify-center",e),...t});qt.displayName="PaginationWrapper";const Ht=m.forwardRef(({className:e,...t},n)=>i.jsx("ul",{ref:n,className:N("flex flex-row items-center gap-1",e),...t}));Ht.displayName="PaginationContent";const G=m.forwardRef(({className:e,...t},n)=>i.jsx("li",{ref:n,className:N("",e),...t}));G.displayName="PaginationItem";const ie=({className:e,isActive:t,size:n="icon",children:s,...r})=>i.jsx(z,{"aria-current":t?"page":void 0,variant:t?"outline":"ghost",size:n,className:e,...r,children:s});ie.displayName="PaginationLink";const $t=({className:e,...t})=>i.jsx(ie,{"aria-label":"Go to previous page",size:"default",className:N("gap-1 pl-2.5",e),...t,children:i.jsx(hs,{className:"h-4 w-4"})});$t.displayName="PaginationPrevious";const Zt=({className:e,...t})=>i.jsx(ie,{"aria-label":"Go to next page",size:"default",className:N("gap-1 pr-2.5",e),...t,children:i.jsx(gs,{className:"h-4 w-4"})});Zt.displayName="PaginationNext";const $e=({className:e,...t})=>i.jsxs("span",{"aria-hidden":!0,className:N("flex h-9 w-9 items-center justify-center",e),...t,children:[i.jsx(ms,{className:"h-4 w-4"}),i.jsx("span",{className:"sr-only",children:"More pages"})]});$e.displayName="PaginationEllipsis";const na=({transaction:e})=>{const t="effectiveDate"in e?e.effectiveDate:void 0;return i.jsxs("div",{className:"flex flex-col justify-center",children:[i.jsx("div",{children:t&&ue(new Date(t),"dd/MM/yy")}),e.sourceEffectiveDate&&i.jsxs("div",{className:"text-xs text-gray-500",children:["(Originally ",ue(new Date(e.sourceEffectiveDate),"dd/MM/yy"),")"]})]})},sa=({transaction:e})=>{const t="eventDate"in e?e.eventDate:void 0;return i.jsx("div",{className:"flex flex-col justify-center",children:t&&ue(new Date(t),"dd/MM/yy")})},ra=({transaction:e})=>{const t="amount"in e?e.amount:void 0;return i.jsxs("div",{style:{color:Number(t?.raw)>0?"green":"red",whiteSpace:"nowrap"},children:[t?.formatted,i.jsx("br",{}),e.cryptoExchangeRate&&i.jsxs("span",{style:{color:"gray",marginLeft:"0.5rem"},children:[`(Rate: ${e.cryptoExchangeRate.rate})`,i.jsx("br",{}),t?.raw?`${ys(t.raw*e.cryptoExchangeRate.rate)}$`:null]})]})},oa=({transaction:e})=>{const{account:t}=e,n=t.type,s=t.name;return i.jsxs("div",{className:"flex flex-col justify-center",children:[i.jsx("p",{children:n}),i.jsx("p",{children:s})]})},aa=({transaction:e})=>{const t="sourceDescription"in e?e.sourceDescription:"Missing";return i.jsx("div",{className:"flex flex-wrap",children:i.jsx("div",{className:"flex flex-col justify-center",children:t})})},ia=({transaction:e})=>i.jsx("div",{className:"flex flex-wrap",children:i.jsx("div",{className:"flex flex-col justify-center",children:e.referenceKey})});function ca({transaction:e,onChange:t}){const{id:n,counterparty:s,missingInfoSuggestions:r,id:a,sourceDescription:c,enableEdit:o}=e,l=!!r?.business&&o,d=l?r?.business?.name:"Missing",f=l?r?.business?.id:null,u=s?.name??d,[h,g]=S.useState(!1),{updateTransaction:C,fetching:v}=Ze(),y=S.useCallback(async O=>{await C({transactionId:a,fields:{counterpartyId:O}}),g(!0)},[a,C]),k=S.useCallback(async O=>{await y(O),t?.()},[y,t]),{selectableBusinesses:W,fetching:b}=ps(),[T,x]=S.useState(f??null),[D,M]=S.useState(c);return i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"flex flex-wrap flex-col justify-center",children:s?.id?i.jsx(gt,{to:yt.BUSINESSES.DETAIL(s.id),target:"_blank",rel:"noreferrer",onClick:O=>O.stopPropagation(),className:"inline-flex items-center font-semibold",children:u}):i.jsxs(i.Fragment,{children:[i.jsx(xs,{options:W,value:T,onChange:x,search:D,onSearchChange:M,placeholder:"Choose or create a business",empty:D?i.jsx(vs,{description:D,onAdd:k}):null}),i.jsx(Is,{content:"Approve",children:i.jsx(z,{variant:"outline",size:"icon",onClick:()=>T&&y(T),disabled:v||b||!T,children:i.jsx(bs,{className:"size-4"})})})]})}),i.jsx(Es,{transactionId:n,counterpartyId:s?.id??T,open:h,onOpenChange:g,onClose:t})]})}const Ae=[{accessorKey:"counterparty.name",header:({column:e})=>i.jsxs(z,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Counterparty",e.getIsSorted()&&(e.getIsSorted()==="asc"?i.jsx(ce,{className:"ml-2 h-4 w-4"}):i.jsx(se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>i.jsx(ca,{transaction:e.original})},{accessorKey:"eventDate",sortingFn:e=>"eventDate"in e.original&&e.original.eventDate?new Date(e.original.eventDate).getTime():0,header:({column:e})=>i.jsxs(z,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Event Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?i.jsx(ce,{className:"ml-2 h-4 w-4"}):i.jsx(se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>i.jsx(sa,{transaction:e.original})},{accessorKey:"effectiveDate",sortingFn:e=>"effectiveDate"in e.original&&e.original.effectiveDate?new Date(e.original.effectiveDate).getTime():0,header:({column:e})=>i.jsxs(z,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Debit Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?i.jsx(ce,{className:"ml-2 h-4 w-4"}):i.jsx(se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>i.jsx(na,{transaction:e.original})},{accessorKey:"amount.raw",header:({column:e})=>i.jsxs(z,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?i.jsx(ce,{className:"ml-2 h-4 w-4"}):i.jsx(se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>i.jsx(ra,{transaction:e.original})},{accessorKey:"account.name",header:({column:e})=>i.jsxs(z,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?i.jsx(ce,{className:"ml-2 h-4 w-4"}):i.jsx(se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>i.jsx(oa,{transaction:e.original})},{accessorKey:"sourceDescription",header:({column:e})=>i.jsxs(z,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Description",e.getIsSorted()&&(e.getIsSorted()==="asc"?i.jsx(ce,{className:"ml-2 h-4 w-4"}):i.jsx(se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>i.jsx(aa,{transaction:e.original})},{accessorKey:"referenceKey",header:({column:e})=>i.jsxs(z,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Reference#",e.getIsSorted()&&(e.getIsSorted()==="asc"?i.jsx(ce,{className:"ml-2 h-4 w-4"}):i.jsx(se,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>i.jsx(ia,{transaction:e.original})}],la={accessorKey:"id",header:"Actions",cell:({row:e})=>e.original.enableEdit?i.jsxs(i.Fragment,{children:[i.jsx(Ds,{onClick:()=>e.original.editTransaction(e.original.id)}),i.jsx(ta,{chargeId:e.original.chargeId,transactionId:e.original.id,onDone:e.original.onUpdate})]}):e.original.enableChargeLink?i.jsx(ar,{chargeId:e.original.chargeId}):null},ya=({transactionsProps:e,onChange:t,enableEdit:n,enableChargeLink:s})=>{const[r,a]=S.useState(void 0),[c,o]=S.useState([]),l=S.useMemo(()=>(console.log("rendering Transactions"),e.map(h=>ks(Ms,h))),[e]),d=S.useMemo(()=>l.map(h=>({...h,editTransaction:a,onUpdate:t||(()=>{}),enableEdit:n,enableChargeLink:s})),[l,n,s,t]),f=S.useMemo(()=>n||s?[...Ae,la]:Ae,[n,s]),u=ws({data:d,columns:f,getCoreRowModel:js(),onSortingChange:o,getSortedRowModel:Ss(),getPaginationRowModel:Cs(),state:{sorting:c},initialState:{pagination:{pageIndex:0,pageSize:100},sorting:[{id:"eventDate",desc:!0}]}});return i.jsxs(i.Fragment,{children:[i.jsxs(Ns,{children:[i.jsx(Os,{children:u.getHeaderGroups().map(h=>i.jsx(_e,{children:h.headers.map(g=>i.jsx(Ts,{colSpan:g.colSpan,children:g.isPlaceholder?null:st(g.column.columnDef.header,g.getContext())},g.id))},h.id))}),i.jsx(Ws,{children:u.getRowModel().rows?.length?u.getRowModel().rows.map(h=>i.jsx(_e,{children:h.getVisibleCells().map(g=>i.jsx(rt,{children:st(g.column.columnDef.cell,g.getContext())},g.id))},h.id)):i.jsx(_e,{children:i.jsx(rt,{colSpan:Ae.length,className:"h-24 text-center",children:"No results."})})})]}),u.getPageCount()>1&&i.jsx("div",{className:"flex items-center justify-end space-x-2 py-4",children:i.jsx(At,{value:u.getState().pagination.pageIndex,total:u.getPageCount(),onChange:h=>u.setPageIndex(h)})}),i.jsx(ea,{transactionID:r,close:()=>a(void 0),onChange:t??(()=>{})})]})};export{ra as A,ca as C,na as D,Ys as E,ur as I,hr as M,ga as P,ia as S,ya as T,At as a,sa as b,oa as c,aa as d,ar as e};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{g as v,hH as U,r as u,t as h,i as F,aj as B,j as e,X as C,Y as j,Z as f,_ as p,I as L,$ as y,a0 as S,br as V,bu as _,as as z,ah as K,D,aO as E,B as m,z as M,aP as R,aQ as A,G as $,V as O,hI as G,bW as Q,u as P,hJ as W,L as k,F as X,cS as Y,cV as Z,cW as J,cX as T,cY as ee,cZ as b,c_ as se,c$ as w,hK as te,d5 as ae,d6 as re,d7 as oe}from"./index-fZcP3X7C.js";import{D as ne}from"./data-table-pagination-psKhAMGL.js";import{P as ie}from"./page-layout-DUgx8eXl.js";import{A as I}from"./arrow-up-down-CTxePA5K.js";const de="insertTaxCategory",ce=()=>{const[{fetching:s},n]=v(U),t=u.useCallback(async a=>{const d="Error creating tax category",r=de;h.loading("Adding Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r);if(l)return h.success("Success",{id:r,description:`${l.insertTaxCategory.name} was created`}),l.insertTaxCategory}catch(i){console.error(`${d}: ${i}`),h.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,insertTaxCategory:t}};function q({formManager:s,setFetching:n,isInsert:t}){const{control:a,watch:d,setValue:r}=s,{selectableSortCodes:i,fetching:l,sortCodes:x}=B();u.useEffect(()=>{n(l)},[n,l]);const c=d("sortCode");return u.useEffect(()=>{if(c){const o=x.find(g=>g.key===c);o?.defaultIrsCode&&r("irsCode",o.defaultIrsCode,{shouldDirty:!0})}},[c,x,r]),e.jsxs(e.Fragment,{children:[e.jsx(C,{name:"name",control:a,rules:{required:"Required",minLength:{value:2,message:"Must be at least 2 characters"}},render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"Name"}),e.jsx(p,{children:e.jsx(L,{...o,value:o.value??void 0,required:!0,className:t?"":y(g)})}),e.jsx(S,{})]})}),e.jsx(V,{name:"sortCode",control:a,render:({field:o,fieldState:g})=>e.jsx(_,{...o,onChange:H=>{o.onChange(Number(H))},data:i,value:o.value?.toString(),disabled:l,label:"Sort Code",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,className:t?"":y(g)})}),e.jsx(C,{name:"irsCode",control:a,render:({field:o,fieldState:g})=>e.jsxs(j,{children:[e.jsx(f,{children:"IRS Code"}),e.jsx(p,{children:e.jsx(z,{...o,className:t?"":y(g),value:o.value??void 0,hideControls:!0,decimalScale:0})}),e.jsx(S,{})]})}),e.jsx(C,{control:a,name:"taxExcluded",render:({field:o})=>e.jsxs(j,{className:"flex flex-row items-center justify-between",children:[e.jsx("div",{className:"space-y-0.5",children:e.jsx(f,{children:"Tax excluded category"})}),e.jsx(p,{children:e.jsx(K,{onCheckedChange:o.onChange,checked:o.value??void 0})})]})})]})}function le({onAdd:s}){const[n,t]=u.useState(!1);return e.jsxs(D,{open:n,onOpenChange:t,children:[e.jsx(E,{asChild:!0,children:e.jsx(m,{children:"Add Tax Category"})}),e.jsxs(M,{className:"w-[90vw] max-w-screen-md",children:[e.jsx(R,{children:e.jsx(A,{children:"Add New Tax Category"})}),e.jsx(xe,{close:()=>t(!1),onAdd:s})]})]})}function xe({close:s,onAdd:n}){const t=$({}),{handleSubmit:a}=t,[d,r]=u.useState(!1),{insertTaxCategory:i,fetching:l}=ce(),x=c=>{c.sortCode&&=parseInt(c.sortCode.toString()),i({fields:c}).then(o=>{o?.id&&(n?.(o.id),s())})};return e.jsx(O,{...t,children:e.jsxs("form",{onSubmit:a(x),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!0,formManager:t,setFetching:r})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(m,{type:"submit",disabled:l||d,children:"Add Tax Category"})})]})})}const ue="updateTaxCategory",ge=()=>{const[{fetching:s},n]=v(G),t=u.useCallback(async a=>{const d="Error updating tax category",r=`${ue}-${a.taxCategoryId}`;h.loading("Uploading Tax Category",{id:r});try{const i=await n(a),l=F(i,d,r,"updateTaxCategory");if(l)return h.success("Success",{id:r,description:`${l.updateTaxCategory.name} was updated`}),l.updateTaxCategory}catch(i){console.error(`${d}: ${i}`),h.error("Error",{id:r,description:d,duration:1e5,closeButton:!0})}},[n]);return{fetching:s,updateTaxCategory:t}};function he({taxCategoryId:s,onAdd:n}){const[t,a]=u.useState(!1);return e.jsxs(D,{open:t,onOpenChange:a,children:[e.jsx(E,{asChild:!0,children:e.jsx(m,{variant:"outline",size:"icon",children:e.jsx(Q,{})})}),e.jsxs(M,{className:"w-[400px] max-w-screen-md",children:[e.jsx(R,{children:e.jsx(A,{children:"Edit Tax Category"})}),e.jsx(me,{taxCategoryId:s,close:()=>a(!1),onAdd:n})]})]})}function me({taxCategoryId:s,close:n,onAdd:t}){const[{data:a,fetching:d}]=P({query:W,variables:{id:s}}),r=a?.taxCategory;return!r&&!d&&h.error("Error",{description:"Couldn'nt find tax category"}),d?e.jsx(k,{className:"h-10 w-10 animate-spin"}):e.jsx(Ce,{taxCategory:r,close:n,onAdd:t})}function Ce({taxCategory:s,close:n,onAdd:t}){const a=$({defaultValues:{sortCode:s.sortCode?.key,name:s.name,irsCode:s.irsCode}}),{handleSubmit:d}=a,[r,i]=u.useState(!1),{updateTaxCategory:l,fetching:x}=ge(),c=o=>{o.sortCode&&=parseInt(o.sortCode.toString()),l({fields:o,taxCategoryId:s.id}).then(g=>{g?.id&&(t?.(g.id),n())})};return e.jsx(O,{...a,children:e.jsxs("form",{onSubmit:d(c),children:[e.jsx("div",{className:"flex flex-col gap-4 my-4",children:e.jsx(q,{isInsert:!1,formManager:a,setFetching:i})}),e.jsx("div",{className:"flex justify-end mt-4",children:e.jsx(m,{type:"submit",disabled:x||r,children:"Update"})})]})})}const je=({data:s})=>e.jsx("td",{children:s.name}),fe=({data:s})=>e.jsx("td",{children:s.sortCode?e.jsxs("span",{children:[s.sortCode?.name," (",s.sortCode?.id,")"]}):"N/A"}),N=[{id:"name",accessorKey:"name",cell:({row:s})=>e.jsx(je,{data:s.original}),header:({column:s})=>e.jsxs(m,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Name",e.jsx(I,{})]})},{id:"sortCode",accessorKey:"sortCode.key",cell:({row:s})=>e.jsx(fe,{data:s.original}),header:({column:s})=>e.jsxs(m,{variant:"ghost",onClick:()=>s.toggleSorting(s.getIsSorted()==="asc"),children:["Sort Code",e.jsx(I,{})]})},{id:"edit",cell:({row:s})=>e.jsx(he,{taxCategoryId:s.original.id})}],be=()=>{const[{data:s,fetching:n,error:t},a]=P({query:te}),{setFiltersContext:d}=u.useContext(X),r=s?.taxCategories??[],i=Y({data:r,columns:N,getCoreRowModel:oe(),getPaginationRowModel:re(),getSortedRowModel:ae(),initialState:{pagination:{pageSize:30}}}),l=i.getPageOptions();return u.useEffect(()=>{d(e.jsx("div",{className:"flex items-center justify-end gap-10 space-x-2 py-4",children:e.jsx("div",{className:"flex items-center justify-between px-2",children:e.jsx(ne,{table:i})})}))},[d,i,l]),u.useEffect(()=>{t&&h.error("Error",{description:"Error fetching tax categories"})},[t]),e.jsx(ie,{title:`Tax Categories (${r.length})`,description:"All tax categories",headerActions:e.jsx(le,{onAdd:()=>a()}),children:n?e.jsx("div",{className:"flex flex-row justify-center",children:e.jsx(k,{className:"h-10 w-10 animate-spin mr-2"})}):e.jsx("div",{className:"flex flex-col gap-4 rounded-md border",children:e.jsxs(Z,{children:[e.jsx(J,{children:i.getHeaderGroups().map(x=>e.jsx(T,{children:x.headers.map(c=>e.jsx(ee,{children:c.isPlaceholder?null:b(c.column.columnDef.header,c.getContext())},c.id))},x.id))}),e.jsx(se,{children:i.getRowModel().rows.length===0?e.jsx(T,{children:e.jsx(w,{colSpan:N.length,className:"text-center py-8",children:"No tax categories found"})}):i.getRowModel().rows.map(x=>e.jsx(T,{children:x.getVisibleCells().map(c=>e.jsx(w,{children:b(c.column.columnDef.cell,c.getContext())},c.id))},x.id))})]})})})};export{be as TaxCategories};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,T as se,B as $,au as ae,bq as ne,u as I,hb as te,r as x,a8 as H,hc as oe,hd as z,G as V,t as f,V as le,e9 as ie,cK as G,br as u,bu as k,X as de,he as ce,Y as me,Z as ue,_ as xe,I as ye,a0 as pe,bM as g,bK as S,x as E,a5 as ge,g as W,hf as he,i as Y,hg as je,ee as _,d as fe,hh as ve,gH as be,bo as Ne,bv as Se,J as w,hi as Ee,hj as we,hk as Fe,hl as Ce,hm as Ie,fE as De,hn as Ae,ho as Pe,hp as Re,F as Te,L as ke,hq as Me}from"./index-fZcP3X7C.js";import{u as J}from"./use-url-query-DyJg_rMw.js";import{P as Be}from"./page-layout-DUgx8eXl.js";import{P as Le}from"./modal-B_jJz-4Z.js";import{F as Ze}from"./funnel-DP2XBopJ.js";import{M as qe}from"./MultiSelect-Uj0K1auE.js";function K(t){return e.jsx(se,{disabled:!t.tooltip,label:t.tooltip,children:e.jsx($,{variant:"ghost",size:"icon",className:"size-7.5",...t,children:e.jsx(ae,{className:"size-5"})})})}const Q=({isNewInsert:t=!0,defaultValues:s,month:l,onDone:d,isModifying:o})=>{const{selectableBusinesses:i,fetching:n}=ne(),[{data:c,fetching:y,error:j}]=I({query:te}),{userContext:v}=x.useContext(H),[{data:b,fetching:F,error:R}]=I({query:oe}),[{data:D,fetching:M,error:C}]=I({query:z,variables:{employerId:v?.context.adminBusinessId??""}}),[p,N]=x.useState([]),[A,T]=x.useState([]),[X,ee]=x.useState([]),P=s?.month??l,Z=V({defaultValues:{...s,month:P}}),{control:m,handleSubmit:q,formState:{dirtyFields:O},setValue:B}=Z;x.useEffect(()=>{j&&f.error("Error",{description:"Oh no!, we have an error fetching pension funds! 🤥"})},[j]),x.useEffect(()=>{R&&f.error("Error",{description:"Oh no!, we have an error fetching training funds! 🤥"})},[R]),x.useEffect(()=>{C&&f.error("Error",{description:"Oh no!, we have an error employees! 🤥"})},[C]),x.useEffect(()=>{c?.allPensionFunds?.length&&N(c.allPensionFunds.map(r=>({value:r.id,label:r.name})).sort((r,a)=>r.label>a.label?1:-1))},[c,T]),x.useEffect(()=>{b?.allTrainingFunds?.length&&T(b.allTrainingFunds.map(r=>({value:r.id,label:r.name})).sort((r,a)=>r.label>a.label?1:-1))},[b,T]),x.useEffect(()=>{D?.employeesByEmployerId.length&&ee(D.employeesByEmployerId.filter(r=>!r.name.toLocaleLowerCase().includes("batched")).map(r=>({value:r.id,label:r.name})).sort((r,a)=>r.label>a.label?1:-1))},[D,T]),x.useEffect(()=>{!s?.employer&&v?.context.adminBusinessId&&B("employer",v.context.adminBusinessId,{shouldDirty:!0,shouldTouch:!0})},[B,s?.employer,v?.context.adminBusinessId]);const U=r=>{const a=ge(r,O);if(!(t&&(!a?.directPaymentAmount||!a?.employeeId||!a?.employer||!a?.month)))if(a&&Object.keys(a).length>0){if(!t){if(!s)return;a.employeeId??=s.employeeId,a.month??=s.month}d(a)}else d()};function re(r){B("month",E(r,"yyyy-MM-dd"),{shouldDirty:!0,shouldTouch:!0})}return e.jsx(le,{...Z,children:e.jsxs("form",{onSubmit:q(U),children:[e.jsx("div",{className:"flex-row px-10 h-max justify-start block",children:e.jsxs(ie,{cols:4,children:[e.jsxs("div",{className:"flex-column h-max justify-start block",children:[e.jsx(G,{defaultDate:P?new Date(P):void 0,defaultValue:P?new Date(P):void 0,onChange:re,popoverProps:{withinPortal:!0}}),e.jsx(u,{name:"employer",control:m,defaultValue:s?.employer,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:i,value:r.value,disabled:n,label:"Employer",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(de,{name:"chargeId",control:m,defaultValue:s?.chargeId,rules:{pattern:{value:ce,message:"Invalid UUID"}},render:({field:r})=>e.jsxs(me,{children:[e.jsx(ue,{children:"Charge ID"}),e.jsx(xe,{children:e.jsx(ye,{...r,value:r.value??void 0})}),e.jsx(pe,{})]})}),e.jsx(u,{name:"employeeId",control:m,defaultValue:s?.employeeId,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:X,value:r.value,disabled:M,label:"Employee",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"baseSalary",control:m,defaultValue:s?.baseSalary,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Base Salary",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"globalAdditionalHours",control:m,defaultValue:s?.globalAdditionalHours,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Global Additional Hours",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"bonus",control:m,defaultValue:s?.bonus,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Bonus",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"gift",control:m,defaultValue:s?.gift,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Gift",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"travelAndSubsistence",control:m,defaultValue:s?.travelAndSubsistence,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Travel and Subsistence",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"recovery",control:m,defaultValue:s?.recovery,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Recovery",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency"}})}),e.jsx(u,{name:"vacationTakeout",control:m,defaultValue:s?.vacationTakeout,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Vacation Takeout",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"directPaymentAmount",control:m,defaultValue:s?.directPaymentAmount,rules:{required:"Required"},render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Direct Payment",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"pensionFundId",control:m,defaultValue:s?.pensionFundId,render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:p,value:r.value,disabled:y,label:"Pension Fund",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(u,{name:"pensionEmployeeAmount",control:m,defaultValue:s?.pensionEmployeeAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Pension Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployeePercentage",control:m,defaultValue:s?.pensionEmployeePercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Pension Employee Percentage"})}),e.jsx(u,{name:"pensionEmployerAmount",control:m,defaultValue:s?.pensionEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Pension Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"pensionEmployerPercentage",control:m,defaultValue:s?.pensionEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Pension Employer Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"compensationsEmployerAmount",control:m,defaultValue:s?.compensationsEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Compensations Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"compensationsEmployerPercentage",control:m,defaultValue:s?.compensationsEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Compensations Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"trainingFundId",control:m,defaultValue:s?.trainingFundId,render:({field:r,fieldState:a})=>e.jsx(k,{...r,data:A,value:r.value,disabled:F,label:"Training Fund",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:a.error?.message})}),e.jsx(u,{name:"trainingFundEmployeeAmount",control:m,defaultValue:s?.trainingFundEmployeeAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Training Employee Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployeePercentage",control:m,defaultValue:s?.trainingFundEmployeePercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Training Employee Percentage"})}),e.jsx(u,{name:"trainingFundEmployerAmount",control:m,defaultValue:s?.trainingFundEmployerAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Training Employer Amount",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"trainingFundEmployerPercentage",control:m,defaultValue:s?.trainingFundEmployerPercentage,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,rightSection:"%",value:r??void 0,error:h.error?.message,label:"Training Employer Percentage"})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"socialSecurityAmountEmployee",control:m,defaultValue:s?.socialSecurityAmountEmployee,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Social Security - Employee",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"socialSecurityAmountEmployer",control:m,defaultValue:s?.socialSecurityAmountEmployer,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Social Security - Employer",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"healthPaymentAmount",control:m,defaultValue:s?.healthPaymentAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Health Insurance",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"taxAmount",control:m,defaultValue:s?.taxAmount,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,label:"Income Tax",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})}),e.jsx(u,{name:"zkufot",control:m,defaultValue:s?.zkufot,render:({field:r,fieldState:a})=>e.jsx(g,{...r,value:r.value??void 0,error:a.error?.message,precision:0,label:"Notional Expense",removeTrailingZeros:!0,currencyCodeProps:{value:"ILS",label:"Currency",disabled:!0}})})]}),e.jsxs("div",{className:"flex-row px-10 h-max justify-start block",children:[e.jsx(u,{name:"workDays",control:m,defaultValue:s?.workDays,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Work Days"})}),e.jsx(u,{name:"addedVacationDays",control:m,defaultValue:s?.addedVacationDays,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Added Vacation Days"})}),e.jsx(u,{name:"vacationDaysBalance",control:m,defaultValue:s?.vacationDaysBalance,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Vacation Days Balance"})}),e.jsx(u,{name:"sicknessDaysBalance",control:m,defaultValue:s?.sicknessDaysBalance,render:({field:{value:r,...a},fieldState:h})=>e.jsx(S,{...a,hideControls:!0,precision:2,removeTrailingZeros:!0,value:r??void 0,error:h.error?.message,label:"Sickness Days Balance"})})]})]})}),e.jsxs("div",{className:"mt-10 mb-5 flex justify-center gap-5",children:[e.jsx("button",{type:"submit",onClick:()=>q(U),className:"mt-8 text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",disabled:o||Object.keys(O).length===0,children:"Accept"}),e.jsx("button",{type:"button",className:"mt-8 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"})]})]})})},Oe="updateSalaryRecord",Ue=()=>{const[{fetching:t},s]=W(he),l=x.useCallback(async d=>{const o=`Error updating salary record [${d.salaryRecord.month}] employee [${d.salaryRecord.employeeId}]`,i=Oe;f.loading("Updating Salary Record",{id:i});try{const n=await s(d),c=Y(n,o,i,"updateSalaryRecord");if(c)return f.success("Success",{id:i,description:"Salary record was updated"}),c.updateSalaryRecord.salaryRecord}catch(n){console.error(`${o}: ${n}`),f.error("Error",{id:i,description:o,duration:1e5,closeButton:!0})}},[s]);return{fetching:t,updateSalaryRecord:l}},$e=({recordVariables:t,onDone:s})=>t?e.jsx(He,{recordVariables:t,onDone:s}):null,He=({recordVariables:t,onDone:s})=>{const{updateSalaryRecord:l,fetching:d}=Ue(),[{data:o,fetching:i}]=I({query:je,variables:{employeeIDs:[t.employeeId],month:E(new Date(t.month),"yyyy-MM-dd")}}),n=o?.salaryRecordsByDates?.[0],c=x.useCallback(j=>{s(),j&&l({salaryRecord:j})},[s,l]);if(!n?.employer?.id||!n?.employee?.id)return e.jsx(e.Fragment,{});const y={addedVacationDays:n?.vacationDays?.added,baseSalary:n?.baseAmount?.raw,bonus:n?.bonus?.raw,chargeId:n?.charge?.id,compensationsEmployerAmount:n?.compensationsAmount?.raw,compensationsEmployerPercentage:n?.compensationsPercentage,directPaymentAmount:n?.directAmount?.raw,employer:n.employer.id,employeeId:n.employee.id,gift:n?.gift?.raw,globalAdditionalHours:n?.globalAdditionalHoursAmount?.raw,healthPaymentAmount:n?.healthInsuranceAmount?.raw,month:n?.month,pensionEmployeeAmount:n?.pensionEmployeeAmount?.raw,pensionEmployeePercentage:n?.pensionEmployeePercentage,pensionEmployerAmount:n?.pensionEmployerAmount?.raw,pensionEmployerPercentage:n?.pensionEmployerPercentage,pensionFundId:n?.pensionFund?.id,recovery:n?.recovery?.raw,sicknessDaysBalance:n?.sicknessDays?.balance,socialSecurityAmountEmployee:n?.socialSecurityEmployeeAmount?.raw,socialSecurityAmountEmployer:n?.socialSecurityEmployerAmount?.raw,taxAmount:n?.incomeTaxAmount?.raw,trainingFundEmployeeAmount:n?.trainingFundEmployeeAmount?.raw,trainingFundEmployeePercentage:n?.trainingFundEmployeePercentage,trainingFundEmployerAmount:n?.trainingFundEmployerAmount?.raw,trainingFundEmployerPercentage:n?.trainingFundEmployerPercentage,trainingFundId:n?.trainingFund?.id,travelAndSubsistence:n?.travelAndSubsistence?.raw,vacationDaysBalance:n?.vacationDays?.balance,vacationTakeout:n?.vacationTakeout?.raw,workDays:n?.workDays,zkufot:n?.notionalExpense?.raw};return e.jsx(_,{modalSize:"fit-content",position:"bottom",title:e.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Salary Record:"}),e.jsxs("div",{className:"flex flex-row gap-2",children:["month: ",t.month," employeeId: ",t.employeeId]})]}),opened:!!t,onClose:s,children:i||!n?e.jsx(fe,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):e.jsx(Q,{isNewInsert:!1,defaultValues:y,onDone:c,isModifying:d})})},ze="insertSalaryRecords",Ve=()=>{const[{fetching:t},s]=W(ve),l=x.useCallback(async d=>{const o=ze;if(f.loading("Adding salary record",{id:o}),!d.salaryRecords||Array.isArray(d.salaryRecords)&&d.salaryRecords.length===0){f.error("Error",{id:o,description:"No salary records to insert",duration:1e5,closeButton:!0});return}const i=Array.isArray(d.salaryRecords)?d.salaryRecords[0]:d.salaryRecords;if(!i?.directPaymentAmount||!i?.employeeId||!i?.employer||!i?.month){f.error("Error",{id:o,description:"Missing required salary record fields",duration:1e5,closeButton:!0});return}const n=`Error adding salary record [${i.month}] employee [${i.employeeId}]`;try{const c=await s(d),y=Y(c,n,o,"insertSalaryRecords");if(y)return f.success("Success",{id:o,description:"Salary record was added"}),y.insertSalaryRecords.salaryRecords[0]}catch(c){console.error(`${n}: ${c}`),f.error("Error",{id:o,description:n,duration:1e5,closeButton:!0})}},[s]);return{fetching:t,insertSalaryRecord:l}},Ge=({insertSalaryRecordParams:t,setInsertSalaryRecord:s})=>{const{insertSalaryRecord:l,fetching:d}=Ve(),o=x.useCallback(i=>{i&&l({salaryRecords:[i]}),s(void 0)},[s,l]);return e.jsx(_,{modalSize:"40%",position:"bottom",title:e.jsx("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:e.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Insert Salary Record:"})}),opened:!!t,onClose:()=>s(void 0),children:e.jsx(Q,{isNewInsert:!0,onDone:o,isModifying:d,month:t.month})})};function L(){const t=new Date,s=E(t,"yyyy-MM-dd"),l=E(be(t),"yyyy-MM-dd");return{fromDate:s,toDate:l}}function We({filter:t,setFilter:s,closeModal:l}){const{control:d,handleSubmit:o,setValue:i}=V({defaultValues:{...t}}),[n,c]=x.useState([]),{userContext:y}=x.useContext(H),[{data:j,fetching:v,error:b},F]=I({query:z,variables:{employerId:y?.context.adminBusinessId??""},pause:!0});x.useEffect(()=>{F()},[y?.context.adminBusinessId,F]),x.useEffect(()=>{b&&f.error("Error",{description:"Oh no!, we have an error fetching employees! 🤥"})},[b]);const R=p=>{p.employeeIDs?.length===0&&delete p.employeeIDs,s(p),l()};function D(){s({...L()}),l()}x.useEffect(()=>{j?.employeesByEmployerId.length&&c(j.employeesByEmployerId.filter(p=>!p.name.toLocaleLowerCase().includes("batched")).map(p=>({value:p.id,label:p.name})).sort((p,N)=>p.label>N.label?1:-1))},[j,c]);function M([p,N]){if(N){const A=new Date(N.getFullYear(),N.getMonth()+1,0);i("toDate",E(A,"yyyy-MM-dd"))}if(p){const A=new Date(p.getFullYear(),p.getMonth(),1);i("fromDate",E(A,"yyyy-MM-dd"))}}const C=L();return e.jsxs(e.Fragment,{children:[v?e.jsx("div",{children:"Loading..."}):e.jsx("div",{}),e.jsxs("form",{onSubmit:o(R),children:[e.jsx(G,{type:"range",numberOfColumns:2,defaultValue:[new Date(t?.fromDate??C.fromDate),new Date(t?.toDate??C.toDate)],defaultDate:new Date(t?.fromDate??C.fromDate),onChange:M,popoverProps:{withinPortal:!0}}),e.jsx(u,{name:"employeeIDs",control:d,defaultValue:t.employeeIDs,render:({field:p,fieldState:N})=>e.jsx(qe,{...p,data:n,value:p.value??[],disabled:v,label:"Employees",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:N.error?.message})}),e.jsxs("div",{className:"flex justify-center mt-5 gap-3",children:[e.jsx("button",{type:"submit",disabled:v,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:D,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:l,children:"Cancel"})]})]})]})}function Ye({filter:t,setFilter:s}){const[l,d]=x.useState(!1),{get:o,set:i}=J();x.useEffect(()=>{const c=Ne(t)?null:encodeURIComponent(JSON.stringify(t)),y=o("salariesFilters");c!==y&&i("salariesFilters",c)},[t,o,i]);const n=x.useCallback(c=>{Se(c,t)||s(c)},[t,s]);return e.jsxs("div",{className:"flex flex-row gap-5 items-center",children:[e.jsx(Le,{opened:l,onClose:()=>d(!1),content:e.jsx(We,{filter:t,setFilter:n,closeModal:()=>d(!1)}),modalSize:"xl"}),e.jsx($,{variant:"outline",size:"icon",className:"size-7.5",onClick:()=>d(!0),children:e.jsx(Ze,{className:"size-5"})})]})}const _e=({month:t,setInsertSalaryRecord:s})=>{const l=E(new Date(t),"MMMM yyyy");return e.jsx("tr",{tabIndex:0,className:"h-16 rounded-sm",children:e.jsx("td",{colSpan:100,children:e.jsxs("div",{className:"flex justify-between pl-5",children:[e.jsx("p",{className:"text-lg font-bold text-gray-800",children:l}),e.jsx("div",{className:"flex items-center",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(K,{onClick:s})})})]})})})},Je=({data:t})=>{const{employee:s,month:l}=w(Ee,t),d=E(new Date(l),"MMMM yyyy");return e.jsx("td",{className:"",children:e.jsx("div",{className:"flex items-center pl-5",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-base font-bold text-gray-800",children:s?.name}),e.jsx("p",{className:"text-base font-medium text-gray-800",children:d})]})})})},Ke=({data:t})=>{const{pensionEmployeeAmount:s,pensionEmployeePercentage:l,pensionEmployerAmount:d,pensionEmployerPercentage:o,compensationsAmount:i,compensationsPercentage:n,pensionFund:c,trainingFund:y,trainingFundEmployeeAmount:j,trainingFundEmployeePercentage:v,trainingFundEmployerAmount:b,trainingFundEmployerPercentage:F}=w(we,t);return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-md font-bold text-gray-800",children:"Pension Fund"}),e.jsx("p",{className:"text-md font-medium text-gray-800",children:c?.name}),!!s?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[s?.formatted,l&&` (${l}%)`]})]}),!!d?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[d?.formatted,o&&` (${o}%)`]})]}),!!i?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Compensations Amount:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[i?.formatted,n&&` (${n}%)`]})]}),e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Training Fund"}),e.jsx("p",{className:"text-md font-medium text-gray-800",children:y?.name}),!!j?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[j?.formatted,v&&` (${v}%)`]})]}),!!b?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsxs("p",{className:"text-sm leading-none text-gray-600 ml-2",children:[b?.formatted,F&&` (${F}%)`]})]})]})})})},Qe=({data:t})=>{const{healthInsuranceAmount:s,socialSecurityEmployeeAmount:l,socialSecurityEmployerAmount:d,incomeTaxAmount:o,notionalExpense:i}=w(Fe,t),n=!!l||!!d;return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center pl-5",children:e.jsxs("div",{className:"flex flex-col",children:[n&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800",children:"Social Security"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employee Part:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l?.formatted})]}),e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Pension Fund"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Employer Part:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:d?.formatted})]})]}),!!s?.raw&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Health Insurance"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:s?.formatted})]})]}),(!!o?.raw||!!i?.raw)&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md font-bold text-gray-800 mt-2",children:"Taxes"}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Income Tax:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o?.formatted})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Notional Expense:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i?.formatted})]})]})]})})})},Xe=({data:t})=>{const{baseAmount:s,directAmount:l,globalAdditionalHoursAmount:d,bonus:o,gift:i,recovery:n,vacationTakeout:c}=w(Ce,t);return e.jsx("td",{className:"pl-24",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Base Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:s?.formatted})]}),e.jsxs("div",{className:"flex justify-between mb-2",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Global Extra Hours:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:d?.formatted})]}),!!o?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Bonus:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o?.formatted})]}),!!i?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Gift:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i?.formatted})]}),!!n?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Recovery:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:n?.formatted})]}),!!c?.raw&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Vacation Takeout:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:c?.formatted})]}),e.jsxs("div",{className:"flex justify-between mt-2",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Direct Amount:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l?.formatted})]})]})})})},er=({data:t})=>{const{vacationDays:s,workDays:l,sicknessDays:d}=w(Ie,t),{added:o,taken:i,balance:n}=s??{},{balance:c}=d??{},y=!!o||!!i||!!n;return e.jsx("td",{className:"pl-5",children:e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{className:"flex flex-col",children:[!!l&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md leading-none text-gray-800",children:"Work Days:"}),e.jsx("div",{className:"flex justify-between",children:e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:l})})]}),y&&e.jsxs("div",{className:"flex flex-col",children:[e.jsx("p",{className:"text-md leading-none text-gray-800 mt-2",children:"Vacation Days:"}),!!o&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Added:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:o})]}),!!i&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Taken:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:i})]}),!!n&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:"Balance:"}),e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:n})]})]}),!!c&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-md leading-none text-gray-800 mt-2",children:"Sickness Days:"}),e.jsx("div",{className:"flex justify-between",children:e.jsx("p",{className:"text-sm leading-none text-gray-600 ml-2",children:c})})]})]})})})},rr=({setEditSalaryRecord:t,data:s})=>{const l=w(Ae,s);return e.jsxs(e.Fragment,{children:[e.jsxs("tr",{tabIndex:0,className:"h-16 border border-gray-100 hover:bg-gray-100 rounded-sm",children:[e.jsx(Je,{data:l}),e.jsx(Xe,{data:l}),e.jsx(Ke,{data:l}),e.jsx(Qe,{data:l}),e.jsx(er,{data:l}),e.jsx("td",{className:"pl-2",children:e.jsx("div",{className:"flex items-center",children:e.jsx("div",{className:"flex flex-col",children:e.jsx(De,{onClick:t})})})})]}),e.jsx("tr",{className:"h-3"})]})},sr=({setEditSalaryRecord:t,setInsertSalaryRecord:s,data:l})=>{const d=l?.map(o=>w(Pe,o))??[];return e.jsxs(e.Fragment,{children:[e.jsx("tr",{className:"h-3"}),e.jsx(_e,{month:d[0].month,setInsertSalaryRecord:s}),e.jsx("tr",{className:"h-3"}),d.map(o=>e.jsx(rr,{data:o,setEditSalaryRecord:()=>t(o.employee?.id)},`${o.month} ${o.employee?.id}`))]})},ar=({setEditSalaryRecord:t,setInsertSalaryRecord:s,data:l})=>{const d=x.useMemo(()=>{const o=l?.map(n=>w(Re,n))??[],i=new Map;return o.map(n=>{const{month:c}=n,y=i.get(c)??[];i.set(c,[...y,n])}),i},[l]);return e.jsx("div",{className:"sm:px-6 w-full",children:e.jsxs("div",{className:"bg-white py-4 md:py-7 px-4 md:px-8 xl:px-10",children:[e.jsxs("div",{className:"sm:flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800",children:e.jsx("div",{className:"py-2 px-8 bg-indigo-100 text-indigo-700 rounded-full",children:e.jsx("p",{children:"All"})})}),e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800 ml-4 sm:ml-8",children:e.jsx("div",{className:"py-2 px-8 text-gray-600 hover:text-indigo-700 hover:bg-indigo-100 rounded-full ",children:e.jsx("p",{children:"Done"})})}),e.jsx("div",{className:"rounded-full focus:outline-hidden focus:ring-2 focus:bg-indigo-50 focus:ring-indigo-800 ml-4 sm:ml-8",children:e.jsx("div",{className:"py-2 px-8 text-gray-600 hover:text-indigo-700 hover:bg-indigo-100 rounded-full ",children:e.jsx("p",{children:"Pending"})})})]}),e.jsx("button",{className:"focus:ring-2 focus:ring-offset-2 focus:ring-indigo-600 mt-4 sm:mt-0 inline-flex items-start justify-start px-6 py-3 bg-indigo-700 hover:bg-indigo-600 focus:outline-hidden rounded-sm",children:e.jsx("p",{className:"text-sm font-medium leading-none text-white",children:"Add Task"})})]}),e.jsx("div",{className:"mt-7 overflow-x-auto",children:e.jsx("table",{className:"w-full whitespace-nowrap",children:e.jsx("tbody",{children:Array.from(d).map(([o,i])=>e.jsx(sr,{data:i,setEditSalaryRecord:n=>t(n?{month:o,employeeId:n}:void 0),setInsertSalaryRecord:()=>s({month:o})},o))})})})]})})},cr=()=>{const{setFiltersContext:t}=x.useContext(Te),[s,l]=x.useState(void 0),[d,o]=x.useState(void 0),{get:i}=J(),[n,c]=x.useState(i("salariesFilters")?JSON.parse(decodeURIComponent(i("salariesFilters"))):{...L()}),[{data:y,fetching:j}]=I({query:Me,variables:{...n}});return x.useEffect(()=>{t(e.jsxs("div",{className:"flex flex-row gap-x-5",children:[e.jsx(Ye,{filter:n,setFilter:c}),e.jsx(K,{variant:"default",onClick:()=>o({})})]}))},[y,j,n,t,c]),e.jsxs(Be,{title:"Salaries",description:"View and manage salaries of employees.",children:[j?e.jsx(ke,{className:"h-10 w-10 animate-spin mr-2 self-center"}):e.jsx(ar,{setEditSalaryRecord:l,setInsertSalaryRecord:o,data:y?.salaryRecordsByDates}),e.jsx($e,{recordVariables:s,onDone:()=>l(void 0)}),d&&e.jsx(Ge,{insertSalaryRecordParams:d,setInsertSalaryRecord:o})]})};export{cr as Salaries};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{u as M,d9 as W,t as C,r as s,g as K,i as Q,da as X,db as Y,J as F,dc as E,j as e,D as R,aO as G,B as v,au as _,z as V,aP as J,aQ as U,am as Z,an as ee,ao as se,ap as te,ar as ne,dd as ae,de as re,df as q,dg as z,bW as ce,dh as $,di as ie,K as k,W as B,L as A,dj as le,e as oe,N as de,P as ue,dk as me,bg as he,b1 as xe,dl as je,x as P,dm as H,G as pe,bI as fe,w as ge,V as ye,b8 as ve,cK as De,cV as be,cW as Ce,cX as O,cY as g,c_ as Ne,c$ as y,aw as we,bS as Ie,F as Me,c as Te}from"./index-fZcP3X7C.js";import{s as L}from"./subMonths-CLe-U48r.js";const Se=()=>{const[{data:u,fetching:o,error:c},x]=M({query:W});c&&(console.error(`Error fetching contracts: ${c}`),C.error("Error",{description:"Unable to fetch contracts"}));const a=s.useMemo(()=>u?.allOpenContracts?.slice().sort((t,d)=>t.client.originalBusiness.name>d.client.originalBusiness.name?1:-1)??[],[u]),i=s.useMemo(()=>a.map(t=>({value:t.id,label:t.client.originalBusiness.name})),[a]);return{fetching:o,refresh:()=>x(),openContracts:a,selectableOpenContracts:i}},Fe="IssueMonthlyDocuments",Ee=()=>{const[{fetching:u},o]=K(X),c=s.useCallback(async x=>{const a="Error issuing monthly documents",i=Fe;C.loading("Issuing documents",{id:i});try{const t=await o(x),d=Q(t,a,i);if(d?.issueGreenInvoiceDocuments?.success){C.success("Success",{id:i,description:"Documents issued successfully"});return}d?.issueGreenInvoiceDocuments?.errors&&console.error(d.issueGreenInvoiceDocuments.errors),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}catch(t){console.error(`${a}: ${t}`),C.error("Error",{id:i,description:a,duration:1e5,closeButton:!0})}},[o]);return{fetching:u,issueDocuments:c}};function Pe({issueMonth:u,contracts:o,onAdd:c}){const[x,a]=s.useState(!1),[i,t]=s.useState(""),[{data:d},h]=M({query:Y,variables:{issueMonth:u,clientId:i}}),j=s.useCallback(n=>{t(n),h()},[h,t]);return s.useEffect(()=>{i!==""&&d&&(c(F(E,d.clientMonthlyChargeDraft)),a(!1))},[i,d,c]),e.jsxs(R,{open:x,onOpenChange:a,children:[e.jsx(G,{asChild:!0,children:e.jsx(v,{variant:"outline",size:"icon",children:e.jsx(_,{})})}),e.jsxs(V,{className:"w-[400px] max-w-screen-md",children:[e.jsx(J,{children:e.jsx(U,{children:"Select document recipient"})}),e.jsxs(Z,{onValueChange:j,children:[e.jsx(ee,{children:e.jsx(se,{placeholder:"Recipient"})}),e.jsx(te,{children:o.map(n=>e.jsx(ne,{value:n.client.originalBusiness.id,children:n.client.originalBusiness.name},n.client.originalBusiness.id))})]})]})]})}function ke({onApprove:u,draft:o}){const[c,x]=s.useState(!1),[a,i]=s.useState(!1),[t,d]=s.useState(null),{previewDocument:h,fetching:j}=ae(),[n,N]=s.useState(re(o)),T=s.useCallback((l,p)=>{N(f=>({...f,[l]:p}))},[]);s.useEffect(()=>{i(!1)},[n]);const D=s.useCallback(async()=>{try{const l=await h({input:n});if(!l)throw new Error("No preview data returned");d(l),i(!0)}catch(l){console.error("Failed to generate preview:",l)}},[n,h]);s.useEffect(()=>{c&&!t&&D()},[c,t,D]);const w=n.income?.reduce((l,p)=>{const f=p.price*p.quantity,r=f*((p.vatRate||0)/100);return l+f+r},0)||0,I=()=>{u(n),x(!1)};return e.jsxs(R,{open:c,onOpenChange:x,children:[e.jsx(G,{asChild:!0,type:"button",children:e.jsxs(q,{children:[e.jsx(z,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>x(l=>!l),type:"button",children:e.jsx(ce,{className:"size-5"})})}),e.jsx($,{children:e.jsx("p",{children:"Edit document"})})]})}),e.jsx(V,{className:"w-7xl sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:e.jsx("div",{className:"min-h-screen bg-gray-50 p-4",children:e.jsxs("div",{className:"max-w-7xl mx-auto",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900",children:"Edit Document"}),e.jsx("p",{className:"text-gray-600 mt-2",children:"Modify and preview your accounting document before issuing"})]}),e.jsxs("div",{className:"grid lg:grid-cols-2 gap-6",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsx(ie,{formData:n,updateFormData:T}),e.jsx(k,{children:e.jsxs(B,{className:"pt-6",children:[e.jsxs("div",{className:"flex gap-3",children:[e.jsx(v,{onClick:D,disabled:j||a,variant:"outline",className:"flex-1 bg-transparent",children:j?e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-4 h-4 mr-2 animate-spin"}),"Generating..."]}):e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-4 h-4 mr-2"}),"Preview"]})}),e.jsxs(v,{onClick:I,className:"flex-1",children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),"Accept Changes"]})]}),w>0&&e.jsx("div",{className:"mt-4 p-3 bg-blue-50 rounded-lg",children:e.jsxs("div",{className:"flex justify-between items-center font-medium text-blue-900",children:[e.jsx("span",{children:"Total Document Amount:"}),e.jsxs("span",{children:[w.toFixed(2)," ",n.currency]})]})})]})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(k,{className:"h-fit",children:[e.jsx(de,{children:e.jsx(ue,{children:"Document Preview"})}),e.jsx(B,{children:e.jsx("div",{className:"border-2 border-dashed border-gray-200 rounded-lg min-h-[600px] flex items-center justify-center bg-gray-50",children:j?e.jsxs("div",{className:"text-center",children:[e.jsx(A,{className:"w-8 h-8 animate-spin mx-auto mb-4 text-gray-400"}),e.jsx("p",{className:"text-gray-500",children:"Generating document preview..."})]}):t?e.jsx("div",{className:"w-full",children:e.jsx("div",{className:"bg-white shadow-lg rounded-lg overflow-hidden",children:e.jsx("div",{className:"aspect-[8.5/11] bg-white border",children:e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsxs("div",{className:"text-center p-6",children:[e.jsx(me,{src:t}),!a&&e.jsx("p",{className:"text-xs text-amber-600 mt-3 bg-amber-50 px-2 py-1 rounded",children:"Preview may be outdated"})]})})})})}):e.jsxs("div",{className:"text-center",children:[e.jsx(he,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),e.jsx("p",{className:"text-gray-500 mb-2",children:"No preview available"}),e.jsx("p",{className:"text-sm text-gray-400",children:"Click Preview to generate document"})]})})})]}),n.client?.id&&e.jsx(xe,{businessId:n.client?.id,linkedDocumentIds:n.linkedDocumentIds??[]}),e.jsx(je,{documentType:n.type})]})]})]})})})]})}const Be=({drafts:u})=>{const[o,c]=s.useState(u.map(r=>F(E,r))),x=P(L(new Date,1),"yyyy-MM-dd"),[a,i]=s.useState(x),[{data:t},d]=M({query:H,variables:{issueMonth:a},pause:!0});s.useEffect(()=>{t?.clientMonthlyChargesDrafts&&c(t.clientMonthlyChargesDrafts.map(r=>F(E,r)))},[t,c]),s.useEffect(()=>{d()},[a,d]);const h=pe({values:{generateDocumentsInfo:o}}),{issueDocuments:j}=Ee(),{openContracts:n}=Se(),{fields:N,append:T,remove:D,update:w}=fe({control:h.control,name:"generateDocumentsInfo"}),I=h.watch("generateDocumentsInfo"),l=s.useMemo(()=>N.map((r,m)=>({...r,...I[m],id:r.client?.id})),[N,I]),p=s.useCallback(r=>{j(r)},[j]),f=s.useMemo(()=>n.filter(r=>r.billingCycle===ge.Monthly&&!l.some(m=>m.client?.id===r.client.originalBusiness.id)),[l,n]);return e.jsx("div",{className:"p-2",children:e.jsx(ye,{...h,children:e.jsxs("form",{onSubmit:h.handleSubmit(p),children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(ve,{children:"Issue Month:"}),e.jsx(De,{value:new Date(a),onChange:r=>{const m=new Date(r.getFullYear(),r.getMonth(),15);i(P(m,"yyyy-MM-dd"))},popoverProps:{withinPortal:!0}})]}),e.jsxs(be,{children:[e.jsx(Ce,{children:e.jsxs(O,{children:[e.jsx(g,{children:"Name"}),e.jsx(g,{children:"Document"}),e.jsx(g,{children:"Amount"}),e.jsx(g,{children:"Remark"}),e.jsx(g,{children:"Recipients"}),e.jsx(g,{})]})}),e.jsx(Ne,{children:l.map(({id:r,...m},S)=>e.jsxs(O,{children:[e.jsx(y,{children:m.client?.name}),e.jsx(y,{children:m.type}),e.jsxs(y,{children:[m.income?.[0]?.price," ",m.income?.[0]?.currency]}),e.jsx(y,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:m.remarks})}),e.jsx(y,{children:e.jsx("div",{className:"flex flex-col",children:m.client?.emails?.map(b=>e.jsx("span",{className:"text-sm text-gray-500",children:b},b))})}),e.jsx(y,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(q,{children:[e.jsx(z,{asChild:!0,type:"button",children:e.jsx(v,{className:"size-7.5",variant:"secondary",onClick:()=>D(S),children:e.jsx(we,{size:16})})}),e.jsx($,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(ke,{draft:m,onApprove:b=>{h.setValue(`generateDocumentsInfo.${S}`,b,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),w(S,{...b})}})]})})]},r))})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4",children:[e.jsx(Pe,{contracts:f,onAdd:T,issueMonth:a}),e.jsx(Ie,{onConfirm:h.handleSubmit(p),title:`Are you sure you want to issue ${l.length} documents?`,children:e.jsx(v,{children:"Issue"})})]})]})})})},Re=()=>{const{setFiltersContext:u}=s.useContext(Me),[{data:o,fetching:c}]=M({query:H,variables:{issueMonth:P(L(new Date,1),"yyyy-MM-dd")}});return s.useEffect(()=>{o?.clientMonthlyChargesDrafts||u(null)},[o,u]),c?e.jsx(Te,{}):e.jsx(Be,{drafts:o?.clientMonthlyChargesDrafts??[]})};export{Re as IssueDocuments};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,d8 as t}from"./index-fZcP3X7C.js";import{P as o}from"./page-layout-DUgx8eXl.js";const n=()=>e.jsx(o,{title:"New Document",description:"Issue a document for a client",children:e.jsx(t,{})});export{n as IssueDocumentScreen};
|