@accounter/client 0.0.11-alpha-20260126102906-e2f97aac11150a8d1bac3d3fba7a2805e5a71368 → 0.0.11-alpha-20260126121840-9987d09cc7cb596314ad01124c1061feba2117b0
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-Dmuz3t7B.js → Checkbox-D5PsdcQv.js} +1 -1
- package/dist/assets/{MultiSelect-DBeIExB5.js → MultiSelect-C5wjF9jC.js} +1 -1
- package/dist/assets/{Progress---sZILQb.js → Progress-CUpt9lUI.js} +1 -1
- package/dist/assets/{Table-BQv3frL8.js → Table-pGQWLQ8H.js} +1 -1
- package/dist/assets/{Typography-B8Kph7eR.js → Typography-B3aRT5ej.js} +1 -1
- package/dist/assets/{accordion-Bn08_4fN.js → accordion-Bd6kAhfN.js} +1 -1
- package/dist/assets/{accountant-approvals-DuNl7y6H.js → accountant-approvals-BJGkKn8O.js} +1 -1
- package/dist/assets/{accounter-table-DTsgtq5M.js → accounter-table-CioecC_Y.js} +1 -1
- package/dist/assets/{addDays-DTiBTTns.js → addDays-DhQZBfTq.js} +1 -1
- package/dist/assets/{all-charges-DPyM-a74.js → all-charges-UjLePnh5.js} +1 -1
- package/dist/assets/{arrow-up-down-VY6mkkTR.js → arrow-up-down-YhPbp1Ud.js} +1 -1
- package/dist/assets/{building-2-CMKd_bU8.js → building-2-Df516nsd.js} +1 -1
- package/dist/assets/{business-BVMKhHFx.js → business-CryBsRqy.js} +1 -1
- package/dist/assets/{business-extended-info-B94y5ZK6.js → business-extended-info-zz1obrFs.js} +1 -1
- package/dist/assets/{business-header-BC86M-9m.js → business-header-DL-hzsQ4.js} +1 -1
- package/dist/assets/{business-ledger-filters-es3H4rPK.js → business-ledger-filters-Dh6IJIbe.js} +1 -1
- package/dist/assets/{business-ledger-single-U3zkqgW2.js → business-ledger-single-ebXw596v.js} +1 -1
- package/dist/assets/{business-trip-BUKYnQkG.js → business-trip-Bn5hm1D5.js} +1 -1
- package/dist/assets/charge-DhvD1RST.js +1 -0
- package/dist/assets/{charges-filters-CFCAP-bP.js → charges-filters-BLSfy08K.js} +1 -1
- package/dist/assets/{charges-ledger-validation-CCTNRpCE.js → charges-ledger-validation-BOn22w9P.js} +1 -1
- package/dist/assets/charges-table-Bjk5Mz--.js +7 -0
- package/dist/assets/{contracts-ljjcB_x7.js → contracts-iKKpsNnL.js} +1 -1
- package/dist/assets/{data-table-column-header-CZ1dXiU0.js → data-table-column-header--gzXkv5r.js} +1 -1
- package/dist/assets/{data-table-pagination-XAlQIbO9.js → data-table-pagination-CLXUcmJJ.js} +1 -1
- package/dist/assets/{deposits-transactions-table-2rtRFZgK.js → deposits-transactions-table-CV-YceTW.js} +1 -1
- package/dist/assets/{download-csv-button-CMQBUQeX.js → download-csv-button-DVLHjMAB.js} +1 -1
- package/dist/assets/{download-csv-BSGaUZsM.js → download-csv-weF1Lwst.js} +1 -1
- package/dist/assets/{editable-business-trip-CED1Su3d.js → editable-business-trip-DRSlJ54m.js} +1 -1
- package/dist/assets/{eye-off-Buv7eciz.js → eye-off-DWYC0Eax.js} +1 -1
- package/dist/assets/{funnel-Cfb9Pxmr.js → funnel-0IvwyZBf.js} +1 -1
- package/dist/assets/{index-CPMJQkvw.js → index-1oajNqKA.js} +1 -1
- package/dist/assets/{index-CcZll7L2.js → index-AI_GyykK.js} +1 -1
- package/dist/assets/{index-B4OP8iL7.js → index-B6VKQBtu.js} +1 -1
- package/dist/assets/{index-DIrLsKod.js → index-BA-I_zCt.js} +1 -1
- package/dist/assets/{index-DRBzHdu9.js → index-BESPuoZl.js} +1 -1
- package/dist/assets/{index-8fdLByFg.js → index-BFEE5U-A.js} +1 -1
- package/dist/assets/{index-DGAT1KYx.js → index-BINmUTjA.js} +1 -1
- package/dist/assets/{index-DokXNUuN.js → index-BoVSybOL.js} +1 -1
- package/dist/assets/{index-C7p19nIa.js → index-BrgWieYs.js} +1 -1
- package/dist/assets/{index-CSdQtH7c.js → index-Bw_9Tifu.js} +1 -1
- package/dist/assets/{index-BN-I0GSO.js → index-CAAL0SGN.js} +1 -1
- package/dist/assets/{index-Dq33WQoi.js → index-CGpiJ6wl.js} +1 -1
- package/dist/assets/{index-X9rrwleE.js → index-CHzieg87.js} +1 -1
- package/dist/assets/{index-B0hZ0TDG.js → index-CVefTdZ8.js} +1 -1
- package/dist/assets/{index-DOy0Yf1i.js → index-CYLoUT7S.js} +1 -1
- package/dist/assets/{index-Dal_ULkA.js → index-CgvjLFyG.js} +1 -1
- package/dist/assets/{index-DzzUoyj4.js → index-CkPv0ZF8.js} +1 -1
- package/dist/assets/{index-X3RoQQa9.js → index-Cm0VDoDd.js} +1 -1
- package/dist/assets/{index-rI994S3C.js → index-D1_HHRLX.js} +4 -4
- package/dist/assets/{index-BhFsGqUx.js → index-DSAS0BpU.js} +1 -1
- package/dist/assets/{index-7gCTV42h.js → index-DZFQ92ui.js} +1 -1
- package/dist/assets/{index-3ev2Q3E9.js → index-D_XfDEW8.js} +1 -1
- package/dist/assets/{index-Bui9zV-z.js → index-DaDghnaZ.js} +1 -1
- package/dist/assets/{index-DJY6AKiM.js → index-MPZl3TTq.js} +1 -1
- package/dist/assets/{index-GlUqZUgQ.js → index-ajJcMQms.js} +1 -1
- package/dist/assets/{index-CjG9JDZB.js → index-v8SIf-h9.js} +1 -1
- package/dist/assets/{index.es-C2YDJ0AL.js → index.es-Dkm1W8bL.js} +1 -1
- package/dist/assets/issue-document-yi3XXbpe.js +1 -0
- package/dist/assets/{login-page-BimTSmTC.js → login-page-B5bqhOTx.js} +1 -1
- package/dist/assets/{missing-info-charges-CVhY60ZL.js → missing-info-charges-DiIM7lBQ.js} +1 -1
- package/dist/assets/{modal-BXR_xgUm.js → modal-CNW2FGYc.js} +1 -1
- package/dist/assets/{modify-contract-dialog-flMl2p_T.js → modify-contract-dialog-BBPR_IL8.js} +1 -1
- package/dist/assets/{page-layout-DMGj5xhW.js → page-layout-BOjYoqoi.js} +1 -1
- package/dist/assets/{page-not-found-B_GB5ntj.js → page-not-found-UQZi0ekr.js} +1 -1
- package/dist/assets/{panel-top-open-Bf39HBrp.js → panel-top-open-Bxnxp1BU.js} +1 -1
- package/dist/assets/{report-commentary-row-BMyeQR9J.js → report-commentary-row-BtmSnv64.js} +1 -1
- package/dist/assets/{save-jkuyCWyY.js → save-BHNOV5fu.js} +1 -1
- package/dist/assets/{similar-transactions-modal-DX3CPrMo.js → similar-transactions-modal-BTidmv0G.js} +1 -1
- package/dist/assets/{sub-CEXBz_OW.js → sub-6-HnNA3H.js} +1 -1
- package/dist/assets/subMonths-nC9-M0qS.js +1 -0
- package/dist/assets/{summary-CPKS_69D.js → summary-C5TvRXn1.js} +1 -1
- package/dist/assets/{toggle-expansion-button-Y2eS7nqg.js → toggle-expansion-button-Dg_XsE6y.js} +1 -1
- package/dist/assets/{update-accountant-status-zL6vnwU9.js → update-accountant-status-CU6mIJqS.js} +1 -1
- package/dist/assets/{use-issue-monthly-documents-D9vQpbaZ.js → use-issue-monthly-documents-CdxtNiuP.js} +1 -1
- package/dist/assets/{use-url-query-CqWra6gD.js → use-url-query-RoURh24O.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/components/common/merge-charges/index.tsx +1 -1
- package/src/components/common/modals/preview-document-modal.tsx +5 -2
- package/src/gql/graphql.ts +1 -1
- package/dist/assets/charge-DuqIMfNm.js +0 -1
- package/dist/assets/charges-table-BJtpvXfL.js +0 -7
- package/dist/assets/issue-document-zNxGzRkY.js +0 -1
- package/dist/assets/subMonths-DY4HlBVa.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import{v as at,r as p,ep as Zo,eq as ea,di as ta,bz as Ke,er as na,es as ra,et as sa,aF as F,bA as Me,by as Ye,eu as k,ev as Oe,ew as oa,ex as gs,ey as aa,ez as ia,eA as ca,eB as la,eC as fn,bv as He,eD as da,d as it,cr as hs,eE as xs,j as r,a6 as L,eF as ua,g as Te,eG as fa,t as R,i as $e,eH as pa,T as Ue,bX as on,B as Y,m as ys,eI as ma,E as an,V as vs,eJ as ga,eK as ha,eL as xa,eM as ya,ay as _t,cb as va,eN as ja,eO as ct,eP as lt,eQ as rr,eR as sr,dP as ba,eS as js,eT as Da,l as jt,eU as Ca,eV as Sa,aT as or,eW as wa,u as Ne,eX as _a,eY as Ia,c as Oa,eZ as Fn,e_ as kn,D as cn,aL as bs,bU as Ea,bV as Pa,bW as Aa,x as ln,al as Ds,am as Cs,e$ as Na,f0 as Ss,f1 as Ta,f2 as ws,R as We,ag as Mn,f3 as $a,bC as Be,f4 as Fa,ah as bt,f5 as _s,f6 as Is,f7 as qe,w as tt,f8 as ka,f9 as Os,fa as Es,fb as Ps,fc as Ma,fd as Ra,fe as As,ff as Bt,fg as Ns,fh as za,fi as La,fj as Ba,a3 as Va,fk as Ts,n as yt,bE as ke,bF as $s,bG as Fs,cq as ks,bH as Vt,fl as Ha,fm as Ua,cw as Rn,e as Ka,fn as Ga,a9 as qa,fo as Wa,L as zn,fp as Ya,cp as pn,dt as Qa,fq as _n,fr as Ms,fs as Rs,ft as Xa,fu as mn,fv as ar,fw as zs,du as Ja,fx as Za,dI as we,b$ as je,af as Ls,fy as ir,fz as ei,bY as Bs,c4 as ti,c5 as Vs,c6 as Hs,bO as Ln,bP as Bn,bQ as Ve,bR as Pe,c2 as Ht,bS as Vn,bT as De,P as ni,dw as Us,fA as Ks,fB as Gs,fC as ri,fD as si,fE as oi,ao as cr,ap as lr,aq as dr,ar as ur,as as fr,a2 as ai,au as ii,fF as ci,fG as qs,p as li,c3 as di,bZ as ui,b_ as fi,c0 as pi,c1 as mi,fH as gi,fI as hi,dp as ot,fJ as Ws,fK as xi,fL as Ys,J as yi,W as vi,O as ji,fM as Qs,fN as bi,fO as Xs,fP as Js,fQ as Ee,fR as be,fS as Di,fT as pr,fU as Zs,fV as Je,fW as Ci,fX as Si}from"./index-D1_HHRLX.js";import{T as eo}from"./toggle-expansion-button-Dg_XsE6y.js";import{U as wi}from"./update-accountant-status-CU6mIJqS.js";import{M as _i,P as W,I as Ii,T as to,a as Oi,D as Ei,A as Pi,b as Ai,c as Ni,S as Ti,d as $i,C as Fi}from"./index-BrgWieYs.js";import{T as no}from"./Table-pGQWLQ8H.js";import{R as ki,S as Mi,M as oe,B as Ri,L as mr,G as gn,C as gr}from"./summary-C5TvRXn1.js";import{A as ro,a as _e,b as Ie,c as he}from"./accordion-Bd6kAhfN.js";import{u as zi,D as Li}from"./deposits-transactions-table-CV-YceTW.js";import{C as Bi,M as Vi}from"./Checkbox-D5PsdcQv.js";import{D as Le}from"./data-table-column-header--gzXkv5r.js";const Hi=[["path",{d:"m3 16 4 4 4-4",key:"1co6wj"}],["path",{d:"M7 20V4",key:"1yoxec"}],["path",{d:"M11 4h10",key:"1w87gc"}],["path",{d:"M11 8h7",key:"djye34"}],["path",{d:"M11 12h4",key:"q8tih4"}]],Ui=at("arrow-down-wide-narrow",Hi);const Ki=[["path",{d:"M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"1l7d7l"}],["path",{d:"M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"9955pe"}],["path",{d:"m7 15 3 3",key:"4hkfgk"}],["path",{d:"m7 21 3-3H5a2 2 0 0 1-2-2v-2",key:"1xljwe"}],["rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",key:"1cdgtw"}],["rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",key:"zi3rio"}]],Gi=at("combine",Ki);const qi=[["path",{d:"M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35",key:"17jvcc"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M14 19h6",key:"bvotb8"}],["path",{d:"M17 16v6",key:"18yu1i"}]],hr=at("file-plus-corner",qi);const Wi=[["path",{d:"M21 12a9 9 0 0 0-9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"14sxne"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M3 12a9 9 0 0 0 9 9 9.75 9.75 0 0 0 6.74-2.74L21 16",key:"1hlbsb"}],["path",{d:"M16 16h5v5",key:"ccwih5"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]],Yi=at("refresh-ccw-dot",Wi);const Qi=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],Pt=at("square-check-big",Qi);const Xi=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]],At=at("square-x",Xi);function xr(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}var Ji=Object.defineProperty,Zi=Object.defineProperties,ec=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertySymbols,so=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable,yr=(e,t,n)=>t in e?Ji(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ze=(e,t)=>{for(var n in t||(t={}))so.call(t,n)&&yr(e,n,t[n]);if(Ut)for(var n of Ut(t))oo.call(t,n)&&yr(e,n,t[n]);return e},hn=(e,t)=>Zi(e,ec(t)),tc=(e,t)=>{var n={};for(var s in e)so.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Ut)for(var s of Ut(e))t.indexOf(s)<0&&oo.call(e,s)&&(n[s]=e[s]);return n};function nc(e){if(!e||typeof e=="string")return 0;const t=e/36;return Math.round((4+15*t**.25+t/5)*10)}function xn(e){return e?.current?e.current.scrollHeight:"auto"}const Nt=typeof window<"u"&&window.requestAnimationFrame;function rc({transitionDuration:e,transitionTimingFunction:t="ease",onTransitionEnd:n=()=>{},opened:s}){const o=p.useRef(null),a=0,i={display:"none",height:0,overflow:"hidden"},[c,l]=p.useState(s?{}:i),d=u=>{ta.flushSync(()=>l(u))},h=u=>{d(m=>Ze(Ze({},m),u))};function f(u){return{transition:`height ${e||nc(u)}ms ${t}`}}Zo(()=>{Nt(s?()=>{h({willChange:"height",display:"block",overflow:"hidden"}),Nt(()=>{const u=xn(o);h(hn(Ze({},f(u)),{height:u}))})}:()=>{const u=xn(o);h(hn(Ze({},f(u)),{willChange:"height",height:u})),Nt(()=>h({height:a,overflow:"hidden"}))})},[s]);const g=u=>{if(!(u.target!==o.current||u.propertyName!=="height"))if(s){const m=xn(o);m===c.height?d({}):h({height:m}),n()}else c.height===a&&(d(i),n())};function x(u={}){var m=u,{style:j={},refKey:v="ref"}=m,b=tc(m,["style","refKey"]);const D=b[v];return hn(Ze({"aria-hidden":!s},b),{[v]:ea(o,D),onTransitionEnd:g,style:Ze(Ze({boxSizing:"border-box"},j),c)})}return x}var sc=Object.defineProperty,Kt=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,io=Object.prototype.propertyIsEnumerable,vr=(e,t,n)=>t in e?sc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tt=(e,t)=>{for(var n in t||(t={}))ao.call(t,n)&&vr(e,n,t[n]);if(Kt)for(var n of Kt(t))io.call(t,n)&&vr(e,n,t[n]);return e},oc=(e,t)=>{var n={};for(var s in e)ao.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Kt)for(var s of Kt(e))t.indexOf(s)<0&&io.call(e,s)&&(n[s]=e[s]);return n};const ac={transitionDuration:200,transitionTimingFunction:"ease",animateOpacity:!0},co=p.forwardRef((e,t)=>{const n=Ke("Collapse",ac,e),{children:s,in:o,transitionDuration:a,transitionTimingFunction:i,style:c,onTransitionEnd:l,animateOpacity:d}=n,h=oc(n,["children","in","transitionDuration","transitionTimingFunction","style","onTransitionEnd","animateOpacity"]),f=na(),g=ra(),u=(f.respectReducedMotion?g:!1)?0:a,{systemStyles:m,rest:j}=sa(h),v=rc({opened:o,transitionDuration:u,transitionTimingFunction:i,onTransitionEnd:l});return u===0?o?F.createElement(Me,Tt({},j),s):null:F.createElement(Me,Tt({},v(Tt(Tt({style:c,ref:t},j),m))),F.createElement("div",{style:{opacity:o||!d?1:0,transition:d?`opacity ${u}ms ${i}`:"none"}},s))});co.displayName="@mantine/core/Collapse";var ic=Object.defineProperty,cc=Object.defineProperties,lc=Object.getOwnPropertyDescriptors,jr=Object.getOwnPropertySymbols,dc=Object.prototype.hasOwnProperty,uc=Object.prototype.propertyIsEnumerable,br=(e,t,n)=>t in e?ic(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yn=(e,t)=>{for(var n in t||(t={}))dc.call(t,n)&&br(e,n,t[n]);if(jr)for(var n of jr(t))uc.call(t,n)&&br(e,n,t[n]);return e},fc=(e,t)=>cc(e,lc(t));const pc=["light","filled","outline","dot","gradient"],vn={xs:{fontSize:k(9),height:k(16)},sm:{fontSize:k(10),height:k(18)},md:{fontSize:k(11),height:k(20)},lg:{fontSize:k(13),height:k(26)},xl:{fontSize:k(16),height:k(32)}},mc={xs:k(4),sm:k(4),md:k(6),lg:k(8),xl:k(10)};function gc({theme:e,variant:t,color:n,size:s,gradient:o}){if(!pc.includes(t))return null;if(t==="dot"){const i=Oe({size:s,sizes:mc});return{backgroundColor:"transparent",color:e.colorScheme==="dark"?e.colors.dark[0]:e.colors.gray[7],border:`${k(1)} solid ${e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[3]}`,paddingLeft:`calc(${Oe({size:s,sizes:e.spacing})} / 1.5 - ${i} / 2)`,"&::before":{content:'""',display:"block",width:i,height:i,borderRadius:i,backgroundColor:e.fn.themeColor(n,e.colorScheme==="dark"?4:e.fn.primaryShade("light"),!0),marginRight:i}}}const a=e.fn.variant({color:n,variant:t,gradient:o});return{background:a.background,color:a.color,border:`${k(t==="gradient"?0:1)} solid ${a.border}`}}var hc=Ye((e,{color:t,radius:n,gradient:s,fullWidth:o},{variant:a,size:i})=>{const{fontSize:c,height:l}=i in vn?vn[i]:vn.md;return{leftSection:{marginRight:`calc(${e.spacing.xs} / 2)`},rightSection:{marginLeft:`calc(${e.spacing.xs} / 2)`},inner:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},root:yn(fc(yn(yn({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:c,height:l,WebkitTapHighlightColor:"transparent",lineHeight:`calc(${l} - ${k(2)})`,textDecoration:"none",padding:`0 calc(${Oe({size:i,sizes:e.spacing})} / 1.5)`,boxSizing:"border-box",display:o?"flex":"inline-flex",alignItems:"center",justifyContent:"center",width:o?"100%":"auto",textTransform:"uppercase",borderRadius:e.fn.radius(n),fontWeight:700,letterSpacing:k(.25),cursor:"inherit",textOverflow:"ellipsis",overflow:"hidden"}),gc({theme:e,variant:a,color:t,size:i,gradient:s}))}}),xc=Object.defineProperty,Gt=Object.getOwnPropertySymbols,lo=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,Dr=(e,t,n)=>t in e?xc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yc=(e,t)=>{for(var n in t||(t={}))lo.call(t,n)&&Dr(e,n,t[n]);if(Gt)for(var n of Gt(t))uo.call(t,n)&&Dr(e,n,t[n]);return e},vc=(e,t)=>{var n={};for(var s in e)lo.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Gt)for(var s of Gt(e))t.indexOf(s)<0&&uo.call(e,s)&&(n[s]=e[s]);return n};const jc={variant:"light",size:"md",radius:"xl"},fo=p.forwardRef((e,t)=>{const n=Ke("Badge",jc,e),{className:s,color:o,variant:a,fullWidth:i,children:c,size:l,leftSection:d,rightSection:h,radius:f,gradient:g,classNames:x,styles:u,unstyled:m}=n,j=vc(n,["className","color","variant","fullWidth","children","size","leftSection","rightSection","radius","gradient","classNames","styles","unstyled"]),{classes:v,cx:b}=hc({fullWidth:i,color:o,radius:f,gradient:g},{classNames:x,styles:u,name:"Badge",unstyled:m,variant:a,size:l});return F.createElement(Me,yc({className:b(v.root,s),ref:t},j),d&&F.createElement("span",{className:v.leftSection},d),F.createElement("span",{className:v.inner},c),h&&F.createElement("span",{className:v.rightSection},h))});fo.displayName="@mantine/core/Badge";const In=oa(fo);var bc=Object.defineProperty,qt=Object.getOwnPropertySymbols,po=Object.prototype.hasOwnProperty,mo=Object.prototype.propertyIsEnumerable,Cr=(e,t,n)=>t in e?bc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sr=(e,t)=>{for(var n in t||(t={}))po.call(t,n)&&Cr(e,n,t[n]);if(qt)for(var n of qt(t))mo.call(t,n)&&Cr(e,n,t[n]);return e},Dc=(e,t)=>{var n={};for(var s in e)po.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&qt)for(var s of qt(e))t.indexOf(s)<0&&mo.call(e,s)&&(n[s]=e[s]);return n};const Cc={multiple:!1},go=p.forwardRef((e,t)=>{const n=Ke("FileButton",Cc,e),{onChange:s,children:o,multiple:a,accept:i,name:c,form:l,resetRef:d,disabled:h,capture:f,inputProps:g}=n,x=Dc(n,["onChange","children","multiple","accept","name","form","resetRef","disabled","capture","inputProps"]),u=p.useRef(),m=()=>{!h&&u.current.click()},j=b=>{s(a?Array.from(b.currentTarget.files):b.currentTarget.files[0]||null)};return gs(d,()=>{u.current.value=""}),F.createElement(F.Fragment,null,o(Sr({onClick:m},x)),F.createElement("input",Sr({style:{display:"none"},type:"file",accept:i,multiple:a,onChange:j,ref:aa(t,u),name:c,form:l,capture:f},g)))});go.displayName="@mantine/core/FileButton";var Sc=Ye(()=>({placeholder:{},input:{cursor:"pointer"}})),wc=Object.defineProperty,_c=Object.defineProperties,Ic=Object.getOwnPropertyDescriptors,Wt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,wr=(e,t,n)=>t in e?wc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,st=(e,t)=>{for(var n in t||(t={}))ho.call(t,n)&&wr(e,n,t[n]);if(Wt)for(var n of Wt(t))xo.call(t,n)&&wr(e,n,t[n]);return e},$t=(e,t)=>_c(e,Ic(t)),Oc=(e,t)=>{var n={};for(var s in e)ho.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Wt)for(var s of Wt(e))t.indexOf(s)<0&&xo.call(e,s)&&(n[s]=e[s]);return n};const Ec=({value:e})=>F.createElement(He,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Array.isArray(e)?e.map(t=>t.name).join(", "):e?.name),Pc={size:"sm",valueComponent:Ec},yo=p.forwardRef((e,t)=>{const n=ia("FileInput",Pc,e),{inputProps:s,wrapperProps:o,placeholder:a,value:i,defaultValue:c,onChange:l,multiple:d,accept:h,name:f,form:g,classNames:x,styles:u,unstyled:m,valueComponent:j,rightSection:v,clearable:b,clearButtonProps:D,readOnly:C,capture:A,fileInputProps:E}=n,w=Oc(n,["inputProps","wrapperProps","placeholder","value","defaultValue","onChange","multiple","accept","name","form","classNames","styles","unstyled","valueComponent","rightSection","clearable","clearButtonProps","readOnly","capture","fileInputProps"]),O=p.useRef(),{classes:_,cx:M}=Sc(null,{name:"FileInput",classNames:x,styles:u,unstyled:m}),[P,U]=ca({value:i,defaultValue:c,onChange:l,finalValue:d?[]:null}),y=Array.isArray(P)?P.length!==0:P!==null,N=v||(b&&y&&!C?F.createElement(la,$t(st({},D),{variant:"transparent",onClick:()=>U(d?[]:null),size:s.size,unstyled:m})):null);return p.useEffect(()=>{(Array.isArray(P)&&P.length===0||P===null)&&O.current()},[P]),F.createElement(fn.Wrapper,$t(st({},o),{__staticSelector:"FileInput"}),F.createElement(go,{onChange:U,multiple:d,accept:h,name:f,form:g,resetRef:O,disabled:C,capture:A,inputProps:E},B=>F.createElement(fn,$t(st(st(st({multiline:!0},B),s),w),{component:"button",type:"button",ref:t,__staticSelector:"FileInput",rightSection:N,classNames:$t(st({},x),{input:M(_.input,x?.input)})}),y?F.createElement(j,{value:P}):F.createElement(fn.Placeholder,{className:_.placeholder},a))))});yo.displayName="@mantine/core/FileInput";const Ac=yo;var Nc=Object.defineProperty,Tc=Object.defineProperties,$c=Object.getOwnPropertyDescriptors,_r=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,kc=Object.prototype.propertyIsEnumerable,Ir=(e,t,n)=>t in e?Nc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Mc=(e,t)=>{for(var n in t||(t={}))Fc.call(t,n)&&Ir(e,n,t[n]);if(_r)for(var n of _r(t))kc.call(t,n)&&Ir(e,n,t[n]);return e},Rc=(e,t)=>Tc(e,$c(t)),zc=Ye(e=>({root:Rc(Mc({},e.fn.cover()),{display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"})})),Lc=Object.defineProperty,Bc=Object.defineProperties,Vc=Object.getOwnPropertyDescriptors,Yt=Object.getOwnPropertySymbols,vo=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable,Or=(e,t,n)=>t in e?Lc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ft=(e,t)=>{for(var n in t||(t={}))vo.call(t,n)&&Or(e,n,t[n]);if(Yt)for(var n of Yt(t))jo.call(t,n)&&Or(e,n,t[n]);return e},Hc=(e,t)=>Bc(e,Vc(t)),Uc=(e,t)=>{var n={};for(var s in e)vo.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Yt)for(var s of Yt(e))t.indexOf(s)<0&&jo.call(e,s)&&(n[s]=e[s]);return n};const Kc={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:xs("overlay")},bo=p.forwardRef((e,t)=>{const n=Ke("LoadingOverlay",Kc,e),{className:s,visible:o,loaderProps:a,overlayOpacity:i,overlayColor:c,transitionDuration:l,exitTransitionDuration:d,zIndex:h,style:f,loader:g,radius:x,overlayBlur:u,unstyled:m,variant:j,keepMounted:v}=n,b=Uc(n,["className","visible","loaderProps","overlayOpacity","overlayColor","transitionDuration","exitTransitionDuration","zIndex","style","loader","radius","overlayBlur","unstyled","variant","keepMounted"]),{classes:D,cx:C,theme:A}=zc(null,{name:"LoadingOverlay",unstyled:m,variant:j}),E=`calc(${h} + 1)`;return F.createElement(da,{keepMounted:v,duration:l,exitDuration:d,mounted:o,transition:"fade"},w=>F.createElement(Me,Ft({className:C(D.root,s),style:Hc(Ft(Ft({},w),f),{zIndex:h}),ref:t},b),g?F.createElement("div",{style:{zIndex:E}},g):F.createElement(it,Ft({style:{zIndex:E}},a)),F.createElement(hs,{opacity:i,zIndex:h,radius:x,blur:u,unstyled:m,color:c||(A.colorScheme==="dark"?A.colors.dark[5]:A.white)})))});bo.displayName="@mantine/core/LoadingOverlay";var Gc=Object.defineProperty,qc=Object.defineProperties,Wc=Object.getOwnPropertyDescriptors,Er=Object.getOwnPropertySymbols,Yc=Object.prototype.hasOwnProperty,Qc=Object.prototype.propertyIsEnumerable,Pr=(e,t,n)=>t in e?Gc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ar=(e,t)=>{for(var n in t||(t={}))Yc.call(t,n)&&Pr(e,n,t[n]);if(Er)for(var n of Er(t))Qc.call(t,n)&&Pr(e,n,t[n]);return e},Xc=(e,t)=>qc(e,Wc(t));const Jc={xs:k(16),sm:k(20),md:k(26),lg:k(32),xl:k(40)},Zc=["filled","light","gradient","outline","default"];function el({theme:e,variant:t,color:n,gradient:s}){if(!Zc.includes(t))return null;const o=e.fn.variant({variant:t,color:n||e.primaryColor,gradient:s,primaryFallback:!1});return{backgroundColor:o.background,color:o.color,backgroundImage:t==="gradient"?o.background:void 0,border:`${k(t==="gradient"?0:1)} solid ${o.border}`}}var tl=Ye((e,{color:t,radius:n,gradient:s},{variant:o,size:a})=>{const i=Oe({size:a,sizes:Jc});return{root:Ar(Xc(Ar({},e.fn.fontStyles()),{display:"inline-flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",width:i,height:i,minWidth:i,minHeight:i,borderRadius:e.fn.radius(n)}),el({theme:e,variant:o,gradient:s,color:t}))}}),nl=Object.defineProperty,Qt=Object.getOwnPropertySymbols,Do=Object.prototype.hasOwnProperty,Co=Object.prototype.propertyIsEnumerable,Nr=(e,t,n)=>t in e?nl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rl=(e,t)=>{for(var n in t||(t={}))Do.call(t,n)&&Nr(e,n,t[n]);if(Qt)for(var n of Qt(t))Co.call(t,n)&&Nr(e,n,t[n]);return e},sl=(e,t)=>{var n={};for(var s in e)Do.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Qt)for(var s of Qt(e))t.indexOf(s)<0&&Co.call(e,s)&&(n[s]=e[s]);return n};const ol={size:"md",variant:"filled"},Hn=p.forwardRef((e,t)=>{const n=Ke("ThemeIcon",ol,e),{className:s,size:o,radius:a,variant:i,color:c,children:l,gradient:d,unstyled:h}=n,f=sl(n,["className","size","radius","variant","color","children","gradient","unstyled"]),{classes:g,cx:x}=tl({variant:i,radius:a,color:c,gradient:d},{name:"ThemeIcon",unstyled:h,variant:i,size:o});return F.createElement(Me,rl({className:x(g.root,s),ref:t},f),l)});Hn.displayName="@mantine/core/ThemeIcon";const al=({data:e})=>{const t=L(ua,e);return r.jsxs(r.Fragment,{children:[r.jsx(ki,{data:t,onChange:()=>{}}),r.jsx(Mi,{data:t})]})},il="deleteCharge",cl=()=>{const[{fetching:e},t]=Te(fa),n=p.useCallback(async s=>{const o=`Error deleting charge ID [${s.chargeId}]`,a=`${il}-${s.chargeId}`;R.loading("Deleting charge",{id:a});try{const i=await t(s),c=$e(i,o,a);if(c){if(c.deleteCharge===!1)throw new Error("Unsuccessful deletion");return R.success("Success",{id:a,description:"Charge was deleted"}),c.deleteCharge}}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,deleteCharge:n}},ll="regenerateLedgerRecords",dl=()=>{const[{fetching:e},t]=Te(pa),n=p.useCallback(async s=>{const o="Error regenerating ledger",a=`${ll}-${s.chargeId}`;R.loading("Regenerating Ledger",{id:a});try{const i=await t(s),c=$e(i,o,a,"regenerateLedgerRecords");if(c)return R.success("Success",{id:a,description:"Ledger records were regenerated"}),c.regenerateLedgerRecords}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,regenerateLedgerRecords:n}};function ul({chargeId:e,onChange:t,...n}){const{regenerateLedgerRecords:s}=dl();function o(){s({chargeId:e}).then(t)}return r.jsx(Ue,{content:"Regenerate Ledger",children:r.jsx(on,{onConfirm:o,title:"Are you sure you want to regenerate ledger records?",children:r.jsx(Y,{variant:"outline",size:"icon",...n,className:ys("size-7.5",n.className),children:r.jsx(Yi,{className:"size-5"})})})})}function fl(e){const{mergeSelected:t,toggleMergeSelected:n}=e,[s,o]=p.useState(t?"default":"ghost");return p.useEffect(()=>{o(t?"default":"ghost")},[t]),r.jsx(Ue,{content:"Select for merge",children:r.jsx(Y,{onClick:a=>{a.stopPropagation(),n()},variant:s,className:ys("size-7.5",t?"bg-blue-500 hover:bg-blue-500/90":""),children:r.jsx(Gi,{className:"size-5"})})})}const pl="updateMiscExpense",ml=()=>{const[{fetching:e},t]=Te(ma),n=p.useCallback(async s=>{const o=`Error updating misc expense ID [${s.id}]`,a=`${pl}-${s.id}`;R.loading("Update Misc Expense",{id:a});try{const i=await t(s),c=$e(i,o,a,"updateMiscExpense");if(c)return R.success("Success",{id:a,description:"Misc expense was updated"}),c.updateMiscExpense}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateMiscExpense:n}},gl=({onDone:e,data:t})=>{const[n,s]=p.useState(!1),o=L(ga,t),a=an({defaultValues:{amount:o.amount.raw,currency:o.amount.currency,description:o.description,valueDate:new Date(o.valueDate),invoiceDate:o.invoiceDate,creditorId:o.creditor.id,debtorId:o.debtor.id}}),{handleSubmit:i,formState:{dirtyFields:c}}=a,{updateMiscExpense:l,fetching:d}=ml(),h=p.useCallback(async g=>{s(!0),await l({id:o.id,fields:g}),e(),s(!1)},[l,e,o.id]),f=g=>{g&&Object.keys(g).length>0&&h({...g})};return n?r.jsx(it,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):r.jsx(vs,{...a,children:r.jsx("form",{onSubmit:i(f),noValidate:!0,children:r.jsxs("div",{className:"px-5 flex flex-col gap-5",children:[r.jsx(_i,{formManager:a,isInsert:!1}),r.jsx("div",{className:"flex justify-right gap-5 mt-5",children:r.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:d||Object.keys(c).length===0,children:"Accept"})})]})})})},hl="insertDocument",xl=()=>{const[{fetching:e},t]=Te(ha),n=p.useCallback(async s=>{const o=`Error inserting document to charge ID [${s.record.chargeId}]`,a=hl;R.loading("Adding document",{id:a});try{const i=await t(s),c=$e(i,o,a,"insertDocument");if(c)return R.success("Success",{id:a,description:"Document added"}),c.insertDocument}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,insertDocument:n}},yl=({chargeId:e,onChange:t,closeModal:n})=>{const s=an(),{handleSubmit:o,formState:{dirtyFields:a},setValue:i,watch:c}=s,{insertDocument:l,fetching:d}=xl(),h=g=>{if(g&&Object.keys(g).length>0){if(g.vat){if(!g.amount?.currency){R.error("Error",{description:"Couldn't figure out the currency of the document"});return}g.vat.currency=g.amount.currency}g.documentType??=va.Unprocessed,l({record:{...g,chargeId:e}}).then(()=>t?.()),n?.()}},f=c("amount.currency");return p.useEffect(()=>{i("vat.currency",f)},[i,f]),r.jsx("div",{className:"px-5 w-max h-max justify-items-center",children:r.jsx(vs,{...s,children:r.jsxs("form",{onSubmit:o(h),children:[r.jsx(xa,{cols:5,children:r.jsx(ya,{formManager:s,defaultCurrency:_t.Ils})}),r.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[r.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:d||Object.keys(a).length===0,children:"Accept"}),r.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:n,children:"Cancel"})]})]})})})},vl="insertSalaryRecordsFromFile",jl=()=>{const[{fetching:e},t]=Te(ja),n=p.useCallback(async s=>{const o=`Error uploading payroll file to charge ID [${s.chargeId}]`,a=`${vl}-${s.chargeId}`;R.loading("Uploading payroll file",{id:a});try{const i=await t(s),c=$e(i,o,a,"insertSalaryRecordsFromFile");if(c)return R.success("Success",{id:a,description:"Payroll file added"}),c.insertSalaryRecordsFromFile}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,uploadPayrollFile:n}},bl=({chargeId:e,onDone:t})=>{const{fetching:n,uploadPayrollFile:s}=jl(),[o,a]=p.useState(null),i=p.useCallback(async()=>{o&&s({file:o,chargeId:e}).then(t)},[s,t,o,e]);return r.jsxs("div",{className:"px-5 w-max h-max justify-items-center",children:[r.jsx(Ac,{icon:n&&r.jsx(it,{}),value:o,onChange:a,clearable:!0,label:"File Upload"}),r.jsx("div",{className:"flex justify-center gap-5 mt-5",children:r.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||!o,onClick:i,children:"Accept"})})]})};var Dl=new Map([["aac","audio/aac"],["abw","application/x-abiword"],["arc","application/x-freearc"],["avif","image/avif"],["avi","video/x-msvideo"],["azw","application/vnd.amazon.ebook"],["bin","application/octet-stream"],["bmp","image/bmp"],["bz","application/x-bzip"],["bz2","application/x-bzip2"],["cda","application/x-cdf"],["csh","application/x-csh"],["css","text/css"],["csv","text/csv"],["doc","application/msword"],["docx","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],["eot","application/vnd.ms-fontobject"],["epub","application/epub+zip"],["gz","application/gzip"],["gif","image/gif"],["heic","image/heic"],["heif","image/heif"],["htm","text/html"],["html","text/html"],["ico","image/vnd.microsoft.icon"],["ics","text/calendar"],["jar","application/java-archive"],["jpeg","image/jpeg"],["jpg","image/jpeg"],["js","text/javascript"],["json","application/json"],["jsonld","application/ld+json"],["mid","audio/midi"],["midi","audio/midi"],["mjs","text/javascript"],["mp3","audio/mpeg"],["mp4","video/mp4"],["mpeg","video/mpeg"],["mpkg","application/vnd.apple.installer+xml"],["odp","application/vnd.oasis.opendocument.presentation"],["ods","application/vnd.oasis.opendocument.spreadsheet"],["odt","application/vnd.oasis.opendocument.text"],["oga","audio/ogg"],["ogv","video/ogg"],["ogx","application/ogg"],["opus","audio/opus"],["otf","font/otf"],["png","image/png"],["pdf","application/pdf"],["php","application/x-httpd-php"],["ppt","application/vnd.ms-powerpoint"],["pptx","application/vnd.openxmlformats-officedocument.presentationml.presentation"],["rar","application/vnd.rar"],["rtf","application/rtf"],["sh","application/x-sh"],["svg","image/svg+xml"],["swf","application/x-shockwave-flash"],["tar","application/x-tar"],["tif","image/tiff"],["tiff","image/tiff"],["ts","video/mp2t"],["ttf","font/ttf"],["txt","text/plain"],["vsd","application/vnd.visio"],["wav","audio/wav"],["weba","audio/webm"],["webm","video/webm"],["webp","image/webp"],["woff","font/woff"],["woff2","font/woff2"],["xhtml","application/xhtml+xml"],["xls","application/vnd.ms-excel"],["xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],["xml","application/xml"],["xul","application/vnd.mozilla.xul+xml"],["zip","application/zip"],["7z","application/x-7z-compressed"],["mkv","video/x-matroska"],["mov","video/quicktime"],["msg","application/vnd.ms-outlook"]]);function It(e,t){var n=Cl(e);if(typeof n.path!="string"){var s=e.webkitRelativePath;Object.defineProperty(n,"path",{value:typeof t=="string"?t:typeof s=="string"&&s.length>0?s:e.name,writable:!1,configurable:!1,enumerable:!0})}return n}function Cl(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var s=t.split(".").pop().toLowerCase(),o=Dl.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}var Sl=[".DS_Store","Thumbs.db"];function wl(e){return ct(this,void 0,void 0,function(){return lt(this,function(t){return Xt(e)&&_l(e.dataTransfer)?[2,Pl(e.dataTransfer,e.type)]:Il(e)?[2,Ol(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,El(e)]:[2,[]]})})}function _l(e){return Xt(e)}function Il(e){return Xt(e)&&Xt(e.target)}function Xt(e){return typeof e=="object"&&e!==null}function Ol(e){return On(e.target.files).map(function(t){return It(t)})}function El(e){return ct(this,void 0,void 0,function(){var t;return lt(this,function(n){switch(n.label){case 0:return[4,Promise.all(e.map(function(s){return s.getFile()}))];case 1:return t=n.sent(),[2,t.map(function(s){return It(s)})]}})})}function Pl(e,t){return ct(this,void 0,void 0,function(){var n,s;return lt(this,function(o){switch(o.label){case 0:return e.items?(n=On(e.items).filter(function(a){return a.kind==="file"}),t!=="drop"?[2,n]:[4,Promise.all(n.map(Al))]):[3,2];case 1:return s=o.sent(),[2,Tr(So(s))];case 2:return[2,Tr(On(e.files).map(function(a){return It(a)}))]}})})}function Tr(e){return e.filter(function(t){return Sl.indexOf(t.name)===-1})}function On(e){if(e===null)return[];for(var t=[],n=0;n<e.length;n++){var s=e[n];t.push(s)}return t}function Al(e){if(typeof e.webkitGetAsEntry!="function")return $r(e);var t=e.webkitGetAsEntry();return t&&t.isDirectory?wo(t):$r(e)}function So(e){return e.reduce(function(t,n){return rr(rr([],sr(t),!1),sr(Array.isArray(n)?So(n):[n]),!1)},[])}function $r(e){var t=e.getAsFile();if(!t)return Promise.reject("".concat(e," is not a File"));var n=It(t);return Promise.resolve(n)}function Nl(e){return ct(this,void 0,void 0,function(){return lt(this,function(t){return[2,e.isDirectory?wo(e):Tl(e)]})})}function wo(e){var t=e.createReader();return new Promise(function(n,s){var o=[];function a(){var i=this;t.readEntries(function(c){return ct(i,void 0,void 0,function(){var l,d,h;return lt(this,function(f){switch(f.label){case 0:if(c.length)return[3,5];f.label=1;case 1:return f.trys.push([1,3,,4]),[4,Promise.all(o)];case 2:return l=f.sent(),n(l),[3,4];case 3:return d=f.sent(),s(d),[3,4];case 4:return[3,6];case 5:h=Promise.all(c.map(Nl)),o.push(h),a(),f.label=6;case 6:return[2]}})})},function(c){s(c)})}a()})}function Tl(e){return ct(this,void 0,void 0,function(){return lt(this,function(t){return[2,new Promise(function(n,s){e.file(function(o){var a=It(o,e.fullPath);n(a)},function(o){s(o)})})]})})}var kt={},Fr;function $l(){return Fr||(Fr=1,kt.__esModule=!0,kt.default=function(e,t){if(e&&t){var n=Array.isArray(t)?t:t.split(",");if(n.length===0)return!0;var s=e.name||"",o=(e.type||"").toLowerCase(),a=o.replace(/\/.*$/,"");return n.some(function(i){var c=i.trim().toLowerCase();return c.charAt(0)==="."?s.toLowerCase().endsWith(c):c.endsWith("/*")?a===c.replace(/\/.*$/,""):o===c})}return!0}),kt}var Fl=$l();const kl=ba(Fl);function kr(e){return zl(e)||Rl(e)||Io(e)||Ml()}function Ml(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rl(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function zl(e){if(Array.isArray(e))return En(e)}function Mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function Rr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Mr(Object(n),!0).forEach(function(s){_o(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mr(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function _o(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Dt(e,t){return Vl(e)||Bl(e,t)||Io(e,t)||Ll()}function Ll(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
3
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Io(e,t){if(e){if(typeof e=="string")return En(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return En(e,t)}}function En(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function Bl(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(l){a=!0,c=l}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function Vl(e){if(Array.isArray(e))return e}var Hl="file-invalid-type",Ul="file-too-large",Kl="file-too-small",Gl="too-many-files",ql=function(t){t=Array.isArray(t)&&t.length===1?t[0]:t;var n=Array.isArray(t)?"one of ".concat(t.join(", ")):t;return{code:Hl,message:"File type must be ".concat(n)}},zr=function(t){return{code:Ul,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},Lr=function(t){return{code:Kl,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Wl={code:Gl,message:"Too many files"};function Oo(e,t){var n=e.type==="application/x-moz-file"||kl(e,t);return[n,n?null:ql(t)]}function Eo(e,t,n){if(et(e.size))if(et(t)&&et(n)){if(e.size>n)return[!1,zr(n)];if(e.size<t)return[!1,Lr(t)]}else{if(et(t)&&e.size<t)return[!1,Lr(t)];if(et(n)&&e.size>n)return[!1,zr(n)]}return[!0,null]}function et(e){return e!=null}function Yl(e){var t=e.files,n=e.accept,s=e.minSize,o=e.maxSize,a=e.multiple,i=e.maxFiles,c=e.validator;return!a&&t.length>1||a&&i>=1&&t.length>i?!1:t.every(function(l){var d=Oo(l,n),h=Dt(d,1),f=h[0],g=Eo(l,s,o),x=Dt(g,1),u=x[0],m=c?c(l):null;return f&&u&&!m})}function Jt(e){return typeof e.isPropagationStopped=="function"?e.isPropagationStopped():typeof e.cancelBubble<"u"?e.cancelBubble:!1}function Mt(e){return e.dataTransfer?Array.prototype.some.call(e.dataTransfer.types,function(t){return t==="Files"||t==="application/x-moz-file"}):!!e.target&&!!e.target.files}function Br(e){e.preventDefault()}function Ql(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Xl(e){return e.indexOf("Edge/")!==-1}function Jl(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Ql(e)||Xl(e)}function Fe(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(s){for(var o=arguments.length,a=new Array(o>1?o-1:0),i=1;i<o;i++)a[i-1]=arguments[i];return t.some(function(c){return!Jt(s)&&c&&c.apply(void 0,[s].concat(a)),Jt(s)})}}function Zl(){return"showOpenFilePicker"in window}function ed(e){if(et(e)){var t=Object.entries(e).filter(function(n){var s=Dt(n,2),o=s[0],a=s[1],i=!0;return Po(o)||(console.warn('Skipped "'.concat(o,'" because it is not a valid MIME type. Check https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types for a list of valid MIME types.')),i=!1),(!Array.isArray(a)||!a.every(Ao))&&(console.warn('Skipped "'.concat(o,'" because an invalid file extension was provided.')),i=!1),i}).reduce(function(n,s){var o=Dt(s,2),a=o[0],i=o[1];return Rr(Rr({},n),{},_o({},a,i))},{});return[{description:"Files",accept:t}]}return e}function td(e){if(et(e))return Object.entries(e).reduce(function(t,n){var s=Dt(n,2),o=s[0],a=s[1];return[].concat(kr(t),[o],kr(a))},[]).filter(function(t){return Po(t)||Ao(t)}).join(",")}function nd(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function rd(e){return e instanceof DOMException&&(e.name==="SecurityError"||e.code===e.SECURITY_ERR)}function Po(e){return e==="audio/*"||e==="video/*"||e==="image/*"||e==="text/*"||/\w+\/[-+.\w]+/g.test(e)}function Ao(e){return/^.*\.[\w]+$/.test(e)}var sd=["children"],od=["open"],ad=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],id=["refKey","onChange","onClick"];function cd(e){return ud(e)||dd(e)||No(e)||ld()}function ld(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
4
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dd(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function ud(e){if(Array.isArray(e))return Pn(e)}function jn(e,t){return md(e)||pd(e,t)||No(e,t)||fd()}function fd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
5
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function No(e,t){if(e){if(typeof e=="string")return Pn(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Pn(e,t)}}function Pn(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,s=new Array(t);n<t;n++)s[n]=e[n];return s}function pd(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var s=[],o=!0,a=!1,i,c;try{for(n=n.call(e);!(o=(i=n.next()).done)&&(s.push(i.value),!(t&&s.length===t));o=!0);}catch(l){a=!0,c=l}finally{try{!o&&n.return!=null&&n.return()}finally{if(a)throw c}}return s}}function md(e){if(Array.isArray(e))return e}function Vr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,s)}return n}function Q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Vr(Object(n),!0).forEach(function(s){An(e,s,n[s])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Vr(Object(n)).forEach(function(s){Object.defineProperty(e,s,Object.getOwnPropertyDescriptor(n,s))})}return e}function An(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Zt(e,t){if(e==null)return{};var n=gd(e,t),s,o;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(o=0;o<a.length;o++)s=a[o],!(t.indexOf(s)>=0)&&Object.prototype.propertyIsEnumerable.call(e,s)&&(n[s]=e[s])}return n}function gd(e,t){if(e==null)return{};var n={},s=Object.keys(e),o,a;for(a=0;a<s.length;a++)o=s[a],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var Un=p.forwardRef(function(e,t){var n=e.children,s=Zt(e,sd),o=$o(s),a=o.open,i=Zt(o,od);return p.useImperativeHandle(t,function(){return{open:a}},[a]),F.createElement(p.Fragment,null,n(Q(Q({},i),{},{open:a})))});Un.displayName="Dropzone";var To={disabled:!1,getFilesFromEvent:wl,maxSize:1/0,minSize:0,multiple:!0,maxFiles:0,preventDropOnDocument:!0,noClick:!1,noKeyboard:!1,noDrag:!1,noDragEventsBubbling:!1,validator:null,useFsAccessApi:!0,autoFocus:!1};Un.defaultProps=To;Un.propTypes={children:W.func,accept:W.objectOf(W.arrayOf(W.string)),multiple:W.bool,preventDropOnDocument:W.bool,noClick:W.bool,noKeyboard:W.bool,noDrag:W.bool,noDragEventsBubbling:W.bool,minSize:W.number,maxSize:W.number,maxFiles:W.number,disabled:W.bool,getFilesFromEvent:W.func,onFileDialogCancel:W.func,onFileDialogOpen:W.func,useFsAccessApi:W.bool,autoFocus:W.bool,onDragEnter:W.func,onDragLeave:W.func,onDragOver:W.func,onDrop:W.func,onDropAccepted:W.func,onDropRejected:W.func,onError:W.func,validator:W.func};var Nn={isFocused:!1,isFileDialogActive:!1,isDragActive:!1,isDragAccept:!1,isDragReject:!1,acceptedFiles:[],fileRejections:[]};function $o(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},t=Q(Q({},To),e),n=t.accept,s=t.disabled,o=t.getFilesFromEvent,a=t.maxSize,i=t.minSize,c=t.multiple,l=t.maxFiles,d=t.onDragEnter,h=t.onDragLeave,f=t.onDragOver,g=t.onDrop,x=t.onDropAccepted,u=t.onDropRejected,m=t.onFileDialogCancel,j=t.onFileDialogOpen,v=t.useFsAccessApi,b=t.autoFocus,D=t.preventDropOnDocument,C=t.noClick,A=t.noKeyboard,E=t.noDrag,w=t.noDragEventsBubbling,O=t.onError,_=t.validator,M=p.useMemo(function(){return td(n)},[n]),P=p.useMemo(function(){return ed(n)},[n]),U=p.useMemo(function(){return typeof j=="function"?j:Hr},[j]),y=p.useMemo(function(){return typeof m=="function"?m:Hr},[m]),N=p.useRef(null),B=p.useRef(null),le=p.useReducer(hd,Nn),ae=jn(le,2),ne=ae[0],K=ae[1],z=ne.isFocused,de=ne.isFileDialogActive,ue=p.useRef(typeof window<"u"&&window.isSecureContext&&v&&Zl()),Ce=function(){!ue.current&&de&&setTimeout(function(){if(B.current){var T=B.current.files;T.length||(K({type:"closeDialog"}),y())}},300)};p.useEffect(function(){return window.addEventListener("focus",Ce,!1),function(){window.removeEventListener("focus",Ce,!1)}},[B,de,y,ue]);var G=p.useRef([]),xe=function(T){N.current&&N.current.contains(T.target)||(T.preventDefault(),G.current=[])};p.useEffect(function(){return D&&(document.addEventListener("dragover",Br,!1),document.addEventListener("drop",xe,!1)),function(){D&&(document.removeEventListener("dragover",Br),document.removeEventListener("drop",xe))}},[N,D]),p.useEffect(function(){return!s&&b&&N.current&&N.current.focus(),function(){}},[N,b,s]);var ie=p.useCallback(function(S){O?O(S):console.error(S)},[O]),Z=p.useCallback(function(S){S.preventDefault(),S.persist(),ve(S),G.current=[].concat(cd(G.current),[S.target]),Mt(S)&&Promise.resolve(o(S)).then(function(T){if(!(Jt(S)&&!w)){var J=T.length,se=J>0&&Yl({files:T,accept:M,minSize:i,maxSize:a,multiple:c,maxFiles:l,validator:_}),ge=J>0&&!se;K({isDragAccept:se,isDragReject:ge,isDragActive:!0,type:"setDraggedFiles"}),d&&d(S)}}).catch(function(T){return ie(T)})},[o,d,ie,w,M,i,a,c,l,_]),$=p.useCallback(function(S){S.preventDefault(),S.persist(),ve(S);var T=Mt(S);if(T&&S.dataTransfer)try{S.dataTransfer.dropEffect="copy"}catch{}return T&&f&&f(S),!1},[f,w]),fe=p.useCallback(function(S){S.preventDefault(),S.persist(),ve(S);var T=G.current.filter(function(se){return N.current&&N.current.contains(se)}),J=T.indexOf(S.target);J!==-1&&T.splice(J,1),G.current=T,!(T.length>0)&&(K({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Mt(S)&&h&&h(S))},[N,h,w]),ee=p.useCallback(function(S,T){var J=[],se=[];S.forEach(function(ge){var ze=Oo(ge,M),Se=jn(ze,2),Qe=Se[0],Xe=Se[1],Ge=Eo(ge,i,a),rt=jn(Ge,2),ft=rt[0],pt=rt[1],mt=_?_(ge):null;if(Qe&&ft&&!mt)J.push(ge);else{var gt=[Xe,pt];mt&&(gt=gt.concat(mt)),se.push({file:ge,errors:gt.filter(function(Et){return Et})})}}),(!c&&J.length>1||c&&l>=1&&J.length>l)&&(J.forEach(function(ge){se.push({file:ge,errors:[Wl]})}),J.splice(0)),K({acceptedFiles:J,fileRejections:se,type:"setFiles"}),g&&g(J,se,T),se.length>0&&u&&u(se,T),J.length>0&&x&&x(J,T)},[K,c,M,i,a,l,g,x,u,_]),H=p.useCallback(function(S){S.preventDefault(),S.persist(),ve(S),G.current=[],Mt(S)&&Promise.resolve(o(S)).then(function(T){Jt(S)&&!w||ee(T,S)}).catch(function(T){return ie(T)}),K({type:"reset"})},[o,ee,ie,w]),I=p.useCallback(function(){if(ue.current){K({type:"openDialog"}),U();var S={multiple:c,types:P};window.showOpenFilePicker(S).then(function(T){return o(T)}).then(function(T){ee(T,null),K({type:"closeDialog"})}).catch(function(T){nd(T)?(y(T),K({type:"closeDialog"})):rd(T)?(ue.current=!1,B.current?(B.current.value=null,B.current.click()):ie(new Error("Cannot open the file picker because the https://developer.mozilla.org/en-US/docs/Web/API/File_System_Access_API is not supported and no <input> was provided."))):ie(T)});return}B.current&&(K({type:"openDialog"}),U(),B.current.value=null,B.current.click())},[K,U,y,v,ee,ie,P,c]),V=p.useCallback(function(S){!N.current||!N.current.isEqualNode(S.target)||(S.key===" "||S.key==="Enter"||S.keyCode===32||S.keyCode===13)&&(S.preventDefault(),I())},[N,I]),q=p.useCallback(function(){K({type:"focus"})},[]),te=p.useCallback(function(){K({type:"blur"})},[]),pe=p.useCallback(function(){C||(Jl()?setTimeout(I,0):I())},[C,I]),ce=function(T){return s?null:T},ye=function(T){return A?null:ce(T)},me=function(T){return E?null:ce(T)},ve=function(T){w&&T.stopPropagation()},re=p.useMemo(function(){return function(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},T=S.refKey,J=T===void 0?"ref":T,se=S.role,ge=S.onKeyDown,ze=S.onFocus,Se=S.onBlur,Qe=S.onClick,Xe=S.onDragEnter,Ge=S.onDragOver,rt=S.onDragLeave,ft=S.onDrop,pt=Zt(S,ad);return Q(Q(An({onKeyDown:ye(Fe(ge,V)),onFocus:ye(Fe(ze,q)),onBlur:ye(Fe(Se,te)),onClick:ce(Fe(Qe,pe)),onDragEnter:me(Fe(Xe,Z)),onDragOver:me(Fe(Ge,$)),onDragLeave:me(Fe(rt,fe)),onDrop:me(Fe(ft,H)),role:typeof se=="string"&&se!==""?se:"presentation"},J,N),!s&&!A?{tabIndex:0}:{}),pt)}},[N,V,q,te,pe,Z,$,fe,H,A,E,s]),Re=p.useCallback(function(S){S.stopPropagation()},[]),ut=p.useMemo(function(){return function(){var S=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},T=S.refKey,J=T===void 0?"ref":T,se=S.onChange,ge=S.onClick,ze=Zt(S,id),Se=An({accept:M,multiple:c,type:"file",style:{display:"none"},onChange:ce(Fe(se,H)),onClick:ce(Fe(ge,Re)),tabIndex:-1},J,B);return Q(Q({},Se),ze)}},[B,n,c,H,s]);return Q(Q({},ne),{},{isFocused:z&&!s,getRootProps:re,getInputProps:ut,rootRef:N,inputRef:B,open:ce(I)})}function hd(e,t){switch(t.type){case"focus":return Q(Q({},e),{},{isFocused:!0});case"blur":return Q(Q({},e),{},{isFocused:!1});case"openDialog":return Q(Q({},Nn),{},{isFileDialogActive:!0});case"closeDialog":return Q(Q({},e),{},{isFileDialogActive:!1});case"setDraggedFiles":return Q(Q({},e),{},{isDragActive:t.isDragActive,isDragAccept:t.isDragAccept,isDragReject:t.isDragReject});case"setFiles":return Q(Q({},e),{},{acceptedFiles:t.acceptedFiles,fileRejections:t.fileRejections});case"reset":return Q({},Nn);default:return e}}function Hr(){}const[xd,yd]=js("Dropzone component was not found in tree");var Ur=Object.getOwnPropertySymbols,vd=Object.prototype.hasOwnProperty,jd=Object.prototype.propertyIsEnumerable,bd=(e,t)=>{var n={};for(var s in e)vd.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Ur)for(var s of Ur(e))t.indexOf(s)<0&&jd.call(e,s)&&(n[s]=e[s]);return n};function Kn(e){const t=n=>{const s=Ke(`Dropzone${xr(e)}`,{},n),{children:o}=s,a=bd(s,["children"]),i=yd(),c=Da(o)?o:F.createElement("span",null,o);return i[e]?p.cloneElement(c,a):null};return t.displayName=`@mantine/dropzone/${xr(e)}`,t}const Dd=Kn("accept"),Cd=Kn("reject"),Sd=Kn("idle");var wd=Object.defineProperty,_d=Object.defineProperties,Id=Object.getOwnPropertyDescriptors,Kr=Object.getOwnPropertySymbols,Od=Object.prototype.hasOwnProperty,Ed=Object.prototype.propertyIsEnumerable,Gr=(e,t,n)=>t in e?wd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,qr=(e,t)=>{for(var n in t||(t={}))Od.call(t,n)&&Gr(e,n,t[n]);if(Kr)for(var n of Kr(t))Ed.call(t,n)&&Gr(e,n,t[n]);return e},Pd=(e,t)=>_d(e,Id(t)),Ad=Ye((e,{padding:t,radius:n})=>{const s=e.fn.variant({color:"red",variant:"light"}),o=e.fn.variant({color:e.primaryColor,variant:"light"});return{root:Pd(qr(qr({},e.fn.fontStyles()),e.fn.focusStyles()),{boxSizing:"border-box",backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white,border:`${k(2)} dashed ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[4]}`,padding:Oe({size:t,sizes:e.spacing}),borderRadius:e.fn.radius(n),cursor:"pointer",userSelect:"none",transition:"background-color 150ms ease",position:"relative","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[0]},"&[data-loading]":{cursor:"default","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white}},"&[data-accept]":{backgroundColor:e.colorScheme==="dark"?o.background:e.colors[e.primaryColor][0],borderColor:e.colorScheme==="dark"?o.border:e.colors[e.primaryColor][4],"&:hover":{backgroundColor:e.colorScheme==="dark"?o.background:e.colors[e.primaryColor][0]}},"&[data-reject]":{backgroundColor:e.colorScheme==="dark"?s.background:e.colors.red[0],borderColor:e.colorScheme==="dark"?s.border:e.colors.red[4],"&:hover":{backgroundColor:e.colorScheme==="dark"?s.background:e.colors.red[0]}}}),inner:{pointerEvents:"none",userSelect:"none"}}}),Nd=Object.defineProperty,Td=Object.defineProperties,$d=Object.getOwnPropertyDescriptors,en=Object.getOwnPropertySymbols,Fo=Object.prototype.hasOwnProperty,ko=Object.prototype.propertyIsEnumerable,Wr=(e,t,n)=>t in e?Nd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ht=(e,t)=>{for(var n in t||(t={}))Fo.call(t,n)&&Wr(e,n,t[n]);if(en)for(var n of en(t))ko.call(t,n)&&Wr(e,n,t[n]);return e},bn=(e,t)=>Td(e,$d(t)),Fd=(e,t)=>{var n={};for(var s in e)Fo.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&en)for(var s of en(e))t.indexOf(s)<0&&ko.call(e,s)&&(n[s]=e[s]);return n};const kd={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,useFsAccessApi:!0};function dt(e){const t=Ke("Dropzone",kd,e),{className:n,padding:s,radius:o,disabled:a,classNames:i,styles:c,loading:l,multiple:d,maxSize:h,accept:f,children:g,onDropAny:x,onDrop:u,onReject:m,openRef:j,name:v,unstyled:b,maxFiles:D,autoFocus:C,activateOnClick:A,activateOnDrag:E,dragEventsBubbling:w,activateOnKeyboard:O,onDragEnter:_,onDragLeave:M,onDragOver:P,onFileDialogCancel:U,onFileDialogOpen:y,preventDropOnDocument:N,useFsAccessApi:B,getFilesFromEvent:le,validator:ae,variant:ne}=t,K=Fd(t,["className","padding","radius","disabled","classNames","styles","loading","multiple","maxSize","accept","children","onDropAny","onDrop","onReject","openRef","name","unstyled","maxFiles","autoFocus","activateOnClick","activateOnDrag","dragEventsBubbling","activateOnKeyboard","onDragEnter","onDragLeave","onDragOver","onFileDialogCancel","onFileDialogOpen","preventDropOnDocument","useFsAccessApi","getFilesFromEvent","validator","variant"]),{classes:z,cx:de}=Ad({radius:o,padding:s},{name:"Dropzone",classNames:i,styles:c,unstyled:b,variant:ne}),{getRootProps:ue,getInputProps:Ce,isDragAccept:G,isDragReject:xe,open:ie}=$o(ht({onDrop:x,onDropAccepted:u,onDropRejected:m,disabled:a||l,accept:Array.isArray(f)?f.reduce(($,fe)=>bn(ht({},$),{[fe]:[]}),{}):f,multiple:d,maxSize:h,maxFiles:D,autoFocus:C,noClick:!A,noDrag:!E,noDragEventsBubbling:!w,noKeyboard:!O,onDragEnter:_,onDragLeave:M,onDragOver:P,onFileDialogCancel:U,onFileDialogOpen:y,preventDropOnDocument:N,useFsAccessApi:B,validator:ae},le?{getFilesFromEvent:le}:null));gs(j,ie);const Z=!G&&!xe;return F.createElement(xd,{value:{accept:G,reject:xe,idle:Z}},F.createElement(Me,bn(ht(ht({},K),ue()),{"data-accept":G||void 0,"data-reject":xe||void 0,"data-idle":Z||void 0,"data-loading":l||void 0,className:de(z.root,n)}),F.createElement(bo,{visible:l,radius:o,unstyled:b}),F.createElement("input",bn(ht({},Ce()),{name:v})),F.createElement("div",{className:z.inner},g)))}dt.displayName="@mantine/dropzone/Dropzone";dt.Accept=Dd;dt.Reject=Cd;dt.Idle=Sd;const Mo=dt;var Md=Object.defineProperty,Rd=Object.defineProperties,zd=Object.getOwnPropertyDescriptors,Yr=Object.getOwnPropertySymbols,Ld=Object.prototype.hasOwnProperty,Bd=Object.prototype.propertyIsEnumerable,Qr=(e,t,n)=>t in e?Md(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Vd=(e,t)=>{for(var n in t||(t={}))Ld.call(t,n)&&Qr(e,n,t[n]);if(Yr)for(var n of Yr(t))Bd.call(t,n)&&Qr(e,n,t[n]);return e},Hd=(e,t)=>Rd(e,zd(t)),Ud=Ye(e=>({wrapper:Hd(Vd({},e.fn.cover(0)),{position:"fixed",backgroundColor:e.colorScheme==="dark"?e.colors.dark[7]:e.white,display:"flex",padding:e.spacing.xs,transition:"opacity 100ms ease"}),dropzone:{flex:1}})),Kd=Object.defineProperty,Gd=Object.defineProperties,qd=Object.getOwnPropertyDescriptors,tn=Object.getOwnPropertySymbols,Ro=Object.prototype.hasOwnProperty,zo=Object.prototype.propertyIsEnumerable,Xr=(e,t,n)=>t in e?Kd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Dn=(e,t)=>{for(var n in t||(t={}))Ro.call(t,n)&&Xr(e,n,t[n]);if(tn)for(var n of tn(t))zo.call(t,n)&&Xr(e,n,t[n]);return e},Cn=(e,t)=>Gd(e,qd(t)),Wd=(e,t)=>{var n={};for(var s in e)Ro.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&tn)for(var s of tn(e))t.indexOf(s)<0&&zo.call(e,s)&&(n[s]=e[s]);return n};const Yd={padding:"md",loading:!1,multiple:!0,maxSize:1/0,autoFocus:!1,activateOnClick:!0,activateOnDrag:!0,dragEventsBubbling:!0,activateOnKeyboard:!0,active:!0,zIndex:xs("max"),withinPortal:!0};function Lo(e){const t=Ke("DropzoneFullScreen",Yd,e),{classNames:n,styles:s,sx:o,className:a,style:i,unstyled:c,active:l,onDrop:d,onReject:h,zIndex:f,withinPortal:g,portalProps:x}=t,u=Wd(t,["classNames","styles","sx","className","style","unstyled","active","onDrop","onReject","zIndex","withinPortal","portalProps"]),[m,j]=F.useState(0),[v,{open:b,close:D}]=jt(!1),{classes:C,cx:A}=Ud(null,{name:"DropzoneFullScreen",classNames:n,styles:s,unstyled:c}),E=O=>{O.dataTransfer.types.includes("Files")&&(j(_=>_+1),b())},w=()=>{j(O=>O-1)};return p.useEffect(()=>{m===0&&D()},[m]),p.useEffect(()=>{if(l)return document.addEventListener("dragenter",E,!1),document.addEventListener("dragleave",w,!1),()=>{document.removeEventListener("dragenter",E,!1),document.removeEventListener("dragleave",w,!1)}},[l]),F.createElement(Ca,Cn(Dn({},x),{withinPortal:g}),F.createElement(Me,{className:A(C.wrapper,a),sx:o,style:Cn(Dn({},i),{opacity:v?1:0,pointerEvents:v?"all":"none",zIndex:f})},F.createElement(dt,Cn(Dn({},u),{classNames:n,styles:s,unstyled:c,className:C.dropzone,onDrop:O=>{d?.(O),D()},onReject:O=>{h?.(O),D()}}))))}Lo.displayName="@mantine/dropzone/DropzoneFullScreen";Mo.FullScreen=Lo;const Qd=Mo,Xd=({children:e,chargeId:t})=>{const{uploading:n,uploadMultipleDocuments:s}=Sa();function o(a){R.error("Error",{description:a,duration:5e3})}return r.jsx(Qd,{onDrop:a=>s({documents:a,chargeId:t,isSensitive:!1}),onReject:a=>o(`Rejected Files:
|
|
6
|
+
${a.map(i=>`"${i.file.name}": ${i.errors}`).join(`
|
|
7
|
+
`)}`),activateOnClick:!1,activateOnKeyboard:!1,radius:0,padding:0,maxFiles:1/0,loading:n,sx:()=>({border:0,cursor:"default",width:"100%",height:"100%",zIndex:1}),children:e})},dn=({items:e,extraClassName:t=""})=>{const n=["text-sm font-medium text-gray-900 bg-white border border-gray-200 rounded-lg",t].join(" ");return r.jsx("ul",{className:n,children:e.map((s,o)=>{const a=["w-full px-4 py-2",o===e.length-1?"rounded-b-lg":"border-b",o===0?"rounded-t-lg":"","border-gray-200",s&&typeof s=="object"&&"extraClassName"in s?s.extraClassName??"":""].join(" ");return r.jsx("li",{className:a,children:s&&typeof s=="object"&&"content"in s?s.content:s},o)})})};function Jr({columns:e=5,rows:t=5,headerHeight:n="h-10",rowHeight:s="h-8",showHeader:o=!0,columnWidths:a,...i}){const c=a||Array(e).fill("flex-1");return r.jsxs("div",{className:"space-y-2",...i,children:[o&&r.jsx("div",{className:"flex gap-2 border-b pb-2",children:c.map((l,d)=>r.jsx(or,{className:`${n} ${l}`},d))}),[...Array(t)].map((l,d)=>r.jsx("div",{className:"flex gap-2 border-b py-2",children:c.map((h,f)=>r.jsx(or,{className:`${s} ${h}`},f))},d))]})}const Jd="mergeCharges",Zd=()=>{const[{fetching:e},t]=Te(wa),n=p.useCallback(async s=>{const o=`Error merging into charge ID [${s.baseChargeID}]`,a=`${Jd}-${s.baseChargeID}`;R.loading("Merging Charges",{id:a});try{const i=await t(s),c=$e(i,o,a,"mergeCharges");if(c)return R.success("Success",{id:a,description:"Charges were merged"}),c.mergeCharges.charge}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,mergeCharges:n}};function eu({chargeIds:e,onDone:t,resetMerge:n}){const{mergeCharges:s,fetching:o}=Zd(),a=Array.from(new Set(e)),[{data:i,fetching:c}]=Ne({query:_a,variables:{chargeIds:a}}),[l,d]=p.useState(i?.chargesByIDs[0]),[h,f]=p.useState(void 0),[g,x]=p.useState(void 0),[u,m]=p.useState(void 0),[j,v]=p.useState(void 0),[b,D]=p.useState(void 0),[C,A]=p.useState(void 0),[E,w]=p.useState(void 0),[O,_]=p.useState(void 0),M=i?.chargesByIDs.length!==a.length&&"Some charges were not Found"||void 0,P=i?.chargesByIDs||[],U=p.useCallback(async()=>{if(!l){R.error("Error",{description:"No main charge selected"});return}if(a.length<2){R.error("Error",{description:"At least 2 charges are required to execute a merge"});return}let y;return h&&h.value!==l.userDescription&&(y??={},y={...y,userDescription:h.value}),g&&g.value!==l.owner.id&&(y??={},y={...y,ownerId:g.value}),b&&b.value!==l.__typename&&(y??={},y={...y,type:Ia(b.value)}),C&&C.value!==l.decreasedVAT&&(y??={},y={...y,isDecreasedVAT:C.value}),u&&u.value!==l.optionalVAT&&(y??={},y={...y,optionalVAT:u.value}),j&&j.value!==l.optionalDocuments&&(y??={},y={...y,optionalDocuments:j.value}),O&&O.value!==l.tags.map(N=>N.name).join(",")&&(y??={},y={...y,tags:O.value.split(",").filter(N=>N!=="").map(N=>({id:N}))}),E&&E.value!==l.isInvoicePaymentDifferentCurrency&&(y??={},y={...y,isInvoicePaymentDifferentCurrency:E.value}),await s({baseChargeID:l.id,chargeIdsToMerge:a.filter(N=>N!==l.id),fields:y}),n(),t()},[l,a,s,h,g,b,C,u,E,O,t,n]);return r.jsxs(r.Fragment,{children:[c&&r.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:r.jsx(Oa,{})}),!c&&M&&r.jsx("div",{className:"flex flex-col text-center w-full mb-1",children:r.jsx("h3",{className:"sm:text-2xl text-xl font-medium title-font mb-6 text-gray-900",children:M})}),!c&&!M&&r.jsxs(r.Fragment,{children:[r.jsxs("table",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:"Main"}),P.map(y=>r.jsx("td",{children:r.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-b-0 rounded-t-xl",children:r.jsx(Bi,{checked:y.id===l?.id,size:"xl",onClick:()=>{d(y),f({id:y.id,value:y.userDescription??""}),x({id:y.id,value:y.owner.id}),m({id:y.id,value:y.optionalVAT??!1}),v({id:y.id,value:y.optionalDocuments??!1}),w({id:y.id,value:y.isInvoicePaymentDifferentCurrency??!1}),D({id:y.id,value:y.__typename}),A({id:y.id,value:y.decreasedVAT??!1}),_({id:y.id,value:(y.tags.map(N=>N.name)??[]).join(",")})}})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Description"}),P.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:!y.userDescription||h?.value===y.userDescription,onClick:()=>f({id:y.id,value:y.userDescription??""}),children:r.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:h?.id===y.id?{background:"#228be633"}:{},children:y.userDescription})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Owner"}),P.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:g?.value===y.owner.id,onClick:()=>x({id:y.id,value:y.owner.id}),children:r.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:g?.id===y.id?{background:"#228be633"}:{},children:y.owner.name})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Type"}),P.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.__typename==null||y.__typename===b?.value,onClick:()=>{D({id:y.id,value:y.__typename})},children:r.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:b?.id===y.id?{background:"#228be633"}:{},children:r.jsx(Ue,{content:kn(y.__typename),children:Fn(y.__typename)})})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Is Decreased VAT"}),P.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.decreasedVAT==null||y.decreasedVAT===C?.value,onClick:()=>{A({id:y.id,value:y.decreasedVAT??!1})},children:r.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:C?.id===y.id?{background:"#228be633"}:{},children:y.decreasedVAT?r.jsx(Pt,{size:20,color:"green"}):r.jsx(At,{size:20,color:"red"})})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Optional VAT"}),P.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.optionalVAT==null||y.optionalVAT===u?.value,onClick:()=>{m({id:y.id,value:y.optionalVAT??!1})},children:r.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:u?.id===y.id?{background:"#228be633"}:{},children:y.optionalVAT?r.jsx(Pt,{size:20,color:"green"}):r.jsx(At,{size:20,color:"red"})})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Optional Documents"}),P.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.optionalDocuments==null||y.optionalDocuments===j?.value,onClick:()=>{v({id:y.id,value:y.optionalDocuments??!1})},children:r.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:j?.id===y.id?{background:"#228be633"}:{},children:y.optionalDocuments?r.jsx(Pt,{size:20,color:"green"}):r.jsx(At,{size:20,color:"red"})})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Invoice-Payment Currency Difference"}),P.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.isInvoicePaymentDifferentCurrency==null||y.isInvoicePaymentDifferentCurrency===E?.value,onClick:()=>{w({id:y.id,value:y.isInvoicePaymentDifferentCurrency??!1})},children:r.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:E?.id===y.id?{background:"#228be633"}:{},children:y.isInvoicePaymentDifferentCurrency?r.jsx(Pt,{size:20,color:"green"}):r.jsx(At,{size:20,color:"red"})})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Tags"}),P.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.tags==null||y.tags.map(N=>N.name).join(",")===O?.value,onClick:()=>{_({id:y.id,value:(y.tags.map(N=>N.name)??[]).join(",")})},children:r.jsx("div",{className:"flex items-center justify-center px-2 py-2 border-x-2",style:O?.id===y.id?{background:"#228be633"}:{},children:r.jsx(dn,{items:y.tags.map(N=>r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("div",{children:N.name}),N.namePath&&r.jsx("div",{children:N.namePath.join(" > ")})]},N.id))})})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Transactions"}),P.map(y=>r.jsx("td",{children:r.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-x-2",children:y.metadata?.transactionsCount??0})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Invoices"}),P.map(y=>r.jsx("td",{children:r.jsx("div",{className:"flex items-center justify-center mx-2 px-2 py-2 border-2 border-t-0 rounded-b-xl",children:y.metadata?.invoicesCount??0})},y.id))]})]}),r.jsxs("div",{className:"flex justify-center gap-5 mt-5",children:[r.jsx("button",{type:"button",className:" text-white bg-blue-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-blue-600 rounded-sm text-lg",disabled:c||o,onClick:U,children:"Accept"}),r.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:t,children:"Cancel"}),r.jsx("button",{type:"button",className:" text-white bg-red-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-red-600 rounded-sm text-lg",onClick:()=>{n(),t()},children:"Reset Merge"})]})]})]})}function tu(e){const[t,n]=p.useState(!1),{selected:s,resetMerge:o}=e,a=new Set(s.map(({id:f})=>f)),i=a.size>1,[c,l]=p.useState(i?"default":"outline");p.useEffect(()=>{l(i?"default":"outline")},[i]);const d=p.useCallback(()=>{n(!1),s.map(({onChange:f})=>f())},[s]),h=p.useMemo(()=>i?`Merge ${a.size} selected charges`:"Select at least two different charges to merge",[i,a.size]);return r.jsxs(cn,{open:t,onOpenChange:n,children:[r.jsx(bs,{disabled:!i,children:r.jsxs(Ea,{children:[r.jsx(Pa,{children:r.jsx(Y,{disabled:!i,variant:c,className:"size-7.5",children:r.jsx(Vi,{className:"size-5"})})}),r.jsx(Aa,{children:r.jsx("p",{children:h})})]})}),r.jsxs(ln,{className:"w-[90vw] sm:max-w-[95%] max-h-[90vh] overflow-y-auto",children:[r.jsx(Ds,{children:r.jsx(Cs,{children:"Merge Charges"})}),r.jsx(eu,{chargeIds:Array.from(a),onDone:d,resetMerge:o})]})]})}const nu=({chargeId:e,close:t,onChange:n})=>{const[{data:s,fetching:o}]=Ne({query:Na,variables:{chargeId:e},pause:!e}),a=s?.charge;return e?r.jsx(Ss,{modalSize:"fit-content",position:"bottom",title:r.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[r.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Edit Charge:"}),r.jsxs("div",{className:"flex flex-row gap-2",children:["ID: ",e,r.jsx(ws,{isLink:!0,content:`${window.location.origin}${We.CHARGES.DETAIL(e)}`})]})]}),opened:!!e,onClose:t,children:o||!a?r.jsx(it,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}):r.jsx(Ta,{charge:a,close:t,onChange:n??(()=>{})})}):null},ru=({onDone:e,data:t})=>{const[n,s]=p.useState(!1);function o(){s(!1),e?.()}return r.jsxs(cn,{open:n,onOpenChange:s,children:[r.jsx(Ue,{content:"Edit Misc Expense",children:r.jsx(bs,{asChild:!0,children:r.jsx(Y,{variant:"ghost",size:"icon",className:"size-7.5",children:r.jsx(Mn,{className:"size-5"})})})}),r.jsx(ln,{className:"sm:max-w-[425px]",children:r.jsx(gl,{onDone:o,data:t})})]})},su=({chargeId:e,close:t,onChange:n=()=>{}})=>e?r.jsx(Ss,{modalSize:"40%",position:"bottom",title:r.jsxs("div",{className:"flex flex-row mx-3 pt-3 sm:text-1xl gap-10",children:[r.jsx("h1",{className:"sm:text-2xl font-small text-gray-900",children:"Insert Document:"}),r.jsxs("div",{className:"flex flex-row gap-2",children:["Charge ID: ",e,r.jsx(ws,{isLink:!0,content:`${window.location.origin}${We.CHARGES.DETAIL(e)}`})]})]}),opened:!!e,onClose:t,children:r.jsx(yl,{chargeId:e,closeModal:t,onChange:n})}):null;function ou(e){switch(e){case"xs":return"size-8";case"sm":return"size-10";case"md":return"size-15";case"lg":return"size-25";case"xl":return"size-40";default:return"size-10"}}function au(e){switch(e){case"xs":return"text-2xs";case"sm":return"text-base";case"md":return"text-2xl";case"lg":return"text-3xl";case"xl":return"text-5xl";default:return"text-base"}}const iu=({value:e,size:t="xl"})=>{const s=(a=>{const i=Math.max(0,Math.min(100,a)),c=Math.round(155*(1-i/100)+100),l=Math.round(155*(i/100)+0);return`rgb(${c}, ${l}, 0)`})(e),o=e/100*75;return r.jsxs("div",{className:"relative "+ou(t),children:[r.jsxs("svg",{className:"rotate-[135deg] size-full",viewBox:"0 0 36 36",xmlns:"http://www.w3.org/2000/svg",children:[r.jsx("circle",{cx:"18",cy:"18",r:"16",fill:"none",className:"stroke-current text-gray-200 dark:text-neutral-700",strokeWidth:"1",strokeDasharray:"75 100",strokeLinecap:"round"}),r.jsx("circle",{cx:"18",cy:"18",r:"16",fill:"none",stroke:s,strokeWidth:"2",strokeDasharray:`${o} 100`,strokeLinecap:"round"})]}),r.jsx("div",{className:"absolute top-1/2 start-1/2 transform -translate-x-1/2 -translate-y-1/2 text-center",children:r.jsx("span",{className:"font-bold "+au(t),style:{color:s},children:e.toFixed(0)})})]})};function cu({data:e,onChange:t}){const n=L($a,e),[s,o]=p.useState(n.accountantApproval);return p.useEffect(()=>{s==null&&n.accountantApproval!=null&&o(n.accountantApproval)},[s,n.accountantApproval]),r.jsx("td",{children:r.jsx(wi,{chargeId:n.id,value:s,onChange:t})})}const lu=({data:e})=>{const t=L(Fa,e),[n,s]=p.useState(!0),[o,a]=p.useState(!0),i="validCreditCardAmount"in t?t.validCreditCardAmount:null;return p.useEffect(()=>{t.__typename==="CreditcardBankCharge"&&(a(i==null),i!=null&&s(i))},[t.__typename,i]),r.jsx("td",{children:r.jsx("div",{children:r.jsx(Be,{inline:!0,size:12,disabled:n,processing:o,color:"red",zIndex:"auto",children:r.jsx("p",{className:(t.totalAmount?.raw??0)>0?"whitespace-nowrap text-green-700":"whitespace-nowrap text-red-500",children:t.totalAmount?.formatted})})})})},du=({data:e})=>{const t=L(_s,e);return"businessTrip"in t?r.jsx("td",{children:r.jsx(bt,{to:t.businessTrip?.id?We.BUSINESS_TRIPS.DETAIL(t.businessTrip?.id):We.BUSINESS_TRIPS.ROOT,target:"_blank",rel:"noreferrer",onClick:n=>n.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.businessTrip?.name})}):r.jsx("td",{})},uu=({data:e})=>{const{counterparty:t,validationData:n,__typename:s}=L(Is,e),o=p.useMemo(()=>{switch(s){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":return!1;default:return!0}},[s]),a=p.useMemo(()=>o&&n?.missingInfo?.includes(qe.Counterparty),[o,n?.missingInfo]),{name:i,id:c}=t??{name:"Missing",id:void 0};return r.jsx("td",{children:r.jsx("div",{className:"flex flex-wrap",children:r.jsxs(Be,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:[!a&&c&&r.jsx(bt,{to:We.BUSINESSES.DETAIL(c),target:"_blank",rel:"noreferrer",onClick:l=>l.stopPropagation(),className:"inline-flex items-center font-semibold",children:i}),a&&i]})})})},fu=({data:e})=>{const t=L(ka,e),{minDebitDate:n,minEventDate:s,minDocumentsDate:o}=t,a=n||s||o;return r.jsx("td",{children:r.jsx("div",{children:a&&tt(new Date(a),"dd/MM/yy")})})},pu=({data:e,onChange:t})=>{const[n,s]=p.useState(!1),o=L(Ma,e),a=p.useMemo(()=>o?.validationData?.missingInfo?.includes(qe.Description),[o?.validationData?.missingInfo]),i=p.useMemo(()=>a&&!!o.missingInfoSuggestions?.description?.trim().length,[a,o.missingInfoSuggestions?.description]),{userDescription:c,id:l}=o,d=p.useMemo(()=>c&&c?.trim()!==""?c:o.missingInfoSuggestions?.description?o.missingInfoSuggestions.description:"Missing",[c,o.missingInfoSuggestions?.description]),{updateCharge:h,fetching:f}=Os(),g=p.useCallback(async x=>{x!==void 0&&(await h({chargeId:l,fields:{userDescription:x}}),s(!0))},[l,h]);return r.jsxs("td",{children:[r.jsxs("div",{className:"flex flex-wrap",children:[r.jsx("div",{className:"flex flex-col justify-center",children:r.jsx(Be,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:r.jsx("p",{className:i?"bg-yellow-400":void 0,children:d})})}),i&&r.jsx(Es,{onClick:x=>{x.stopPropagation(),g(o.missingInfoSuggestions.description)},disabled:f})]}),r.jsx(Ps,{chargeId:l,description:o.missingInfoSuggestions?.description??void 0,open:n,onOpenChange:s,onClose:t})]})},mu=({data:e})=>{const t=L(Ra,e),{metadata:n,validationData:s,id:o,__typename:a}=t,i=p.useMemo(()=>{switch(a){case"BusinessTripCharge":case"ConversionCharge":case"DividendCharge":case"InternalTransferCharge":case"SalaryCharge":case"MonthlyVatCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":case"CreditcardBankCharge":case"FinancialCharge":return!1;default:return!0}},[a]),c=p.useMemo(()=>a!=="FinancialCharge",[a]),l=p.useMemo(()=>c&&s?.missingInfo?.includes(qe.Transactions),[c,s?.missingInfo]),d=p.useMemo(()=>i&&s?.missingInfo?.includes(qe.Documents),[i,s?.missingInfo]),h=p.useMemo(()=>!n?.invalidLedger,[n?.invalidLedger]),f=p.useMemo(()=>n?.invalidLedger,[n?.invalidLedger]),g=p.useMemo(()=>{const x=[];return(l||n?.transactionsCount||c)&&x.push({extraClassName:n?.transactionsCount||!c?void 0:"bg-yellow-400",content:r.jsx(Be,{inline:!0,size:12,disabled:!l,color:"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Transactions: ",n?.transactionsCount??0]})},"transactions")}),x.push({content:r.jsx(Be,{inline:!0,size:12,processing:h,disabled:f==="VALID",color:f==="DIFF"?"orange":"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Ledger Records: ",n?.ledgerCount??0]})},"ledger")}),(d||n?.documentsCount)&&x.push({content:r.jsx(Be,{inline:!0,size:12,disabled:!d,color:"red",zIndex:"auto",children:r.jsxs("div",{className:"whitespace-nowrap",children:["Documents: ",n?.documentsCount??0]})},"documents"),extraClassName:!s?.missingInfo?.includes(qe.Documents)||!i?void 0:"bg-yellow-400"}),n?.miscExpensesCount&&x.push({content:r.jsxs("div",{className:"whitespace-nowrap",children:["Misc Expenses: ",n?.miscExpensesCount??0]})}),x},[n?.transactionsCount,n?.ledgerCount,n?.documentsCount,n?.miscExpensesCount,i,c,l,d,s?.missingInfo,f,h]);return r.jsx("td",{children:r.jsx(Xd,{chargeId:o,children:r.jsx(dn,{items:g})})})},gu=({data:e,onChange:t})=>{const{tags:n,id:s,validationData:o,missingInfoSuggestions:a}=L(As,e),{updateCharge:i,fetching:c}=Os(),[l,d]=p.useState(n??[]),[h,f]=p.useState(!1),g=o?.missingInfo?.includes(qe.Tags),x=g&&!!a?.tags?.length;p.useEffect(()=>{n?.length&&!l.length&&d(n)},[n,l.length]),p.useEffect(()=>{l.length===0&&x&&d(a?.tags??[])},[l.length,x,a?.tags]);const u=p.useCallback(async m=>{await i({chargeId:s,fields:{tags:m?.map(j=>({id:j.id}))}}),f(!0)},[s,i]);return r.jsxs("td",{children:[r.jsx(Be,{inline:!0,size:12,disabled:!g,color:"red",zIndex:"auto",children:r.jsx(dn,{items:l.map(m=>r.jsx(Bt,{children:r.jsxs("div",{children:[m.namePath&&r.jsx(He,{size:"xs",opacity:.65,children:`${m.namePath.join(" > ")} >`}),r.jsx(He,{size:"sm",children:m.name})]})},m.id)),extraClassName:x?"bg-yellow-400":void 0})}),x&&r.jsx(Es,{onClick:m=>{m.stopPropagation(),u(a.tags)},disabled:c}),r.jsx(Ps,{chargeId:s,tagIds:a?.tags?.map(m=>({id:m.id})),open:h,onOpenChange:f,onClose:t})]})},hu=({data:e})=>{const{validationData:t,taxCategory:n,__typename:s}=L(Ns,e),o=p.useMemo(()=>{switch(s){case"DividendCharge":case"InternalTransferCharge":case"SalaryCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":return!1;default:return!0}},[s]),a=p.useMemo(()=>t?.missingInfo?.includes(qe.TaxCategory),[t?.missingInfo]);return o?r.jsx("td",{children:r.jsx(Be,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:n?.name??"N/A"})}):r.jsx("td",{})},xu=({data:e})=>{const t=L(za,e),{__typename:n}=t,{text:s,icon:o}=p.useMemo(()=>({text:kn(n),icon:Fn(n)}),[n]);return r.jsxs("td",{children:[r.jsx("div",{children:s}),r.jsx(Hn,{radius:"xl",size:"xl",children:o})]})},yu=({data:e})=>{const{vat:t,totalAmount:n,validationData:s,__typename:o}=L(La,e),a=p.useMemo(()=>s?.missingInfo?.includes(qe.Vat),[s?.missingInfo]),i=p.useMemo(()=>!t&&n?.currency===_t.Ils,[t,n?.currency]),c=p.useMemo(()=>(t?.raw??0)>0&&(n?.raw??0)<0||(t?.raw??0)<0&&(n?.raw??0)>0,[t?.raw,n?.raw]),l=i||c;return p.useMemo(()=>{switch(o){case"BusinessTripCharge":case"DividendCharge":case"ConversionCharge":case"SalaryCharge":case"InternalTransferCharge":case"BankDepositCharge":case"ForeignSecuritiesCharge":case"CreditcardBankCharge":return!1;default:return!0}},[o])?r.jsx("td",{children:r.jsx("div",{className:l?"whitespace-nowrap text-red-500":"whitespace-nowrap text-green-700",children:r.jsx(Be,{inline:!0,size:12,disabled:!a,color:"red",zIndex:"auto",children:t?.formatted})})}):r.jsx("td",{})},vu="insertDepreciationRecord",ju=()=>{const[{fetching:e},t]=Te(Ba),n=p.useCallback(async s=>{const o="Error adding depreciation record",a=vu;R.loading("Adding depreciation record",{id:a});try{const i=await t(s),c=$e(i,o,a,"insertDepreciationRecord");if(c)return R.success("Success",{id:a,description:"Depreciation record was added"}),c.insertDepreciationRecord}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,addDepreciationRecord:n}};function Zr(e){const{chargeId:t,onAdd:n}=e,[s,{close:o,open:a}]=jt(!1);return r.jsxs(r.Fragment,{children:[r.jsx(Ue,{content:"Add Depreciation Record",children:r.jsx(Y,{variant:"outline",size:"icon",className:"size-7.5",onClick:i=>{i.stopPropagation(),a()},children:r.jsx(Va,{className:"size-5"})})}),s&&r.jsx(bu,{chargeId:t,opened:s,close:o,onAdd:n})]})}function bu({chargeId:e,opened:t,close:n,onAdd:s}){const{control:o,handleSubmit:a}=an({defaultValues:{chargeId:e}}),[i,c]=p.useState(!1),[{data:l,fetching:d}]=Ne({query:Ts}),{addDepreciationRecord:h,fetching:f}=ju(),g=u=>{h({fields:u}).then(()=>{s?.(),n()})},x=l?.depreciationCategories?.map(u=>({value:u.id,label:u.name}))??[];return p.useEffect(()=>{c(!!(d||f))},[d,f]),r.jsxs(yt,{opened:t,onClose:n,centered:!0,lockScroll:!0,children:[r.jsx(yt.Title,{children:"Add Depreciation Record"}),r.jsx(yt.Body,{children:r.jsxs("form",{onSubmit:a(g),children:[r.jsx(ke,{name:"activationDate",control:o,rules:{pattern:{value:$s,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:u,...m}})=>{const j=u?new Date(u):void 0;return r.jsx(Fs,{...m,onChange:v=>{const b=v?typeof v=="string"?v:tt(v,"yyyy-MM-dd"):void 0;b!==u&&m.onChange(b)},value:j,label:"Activation Date",popoverProps:{withinPortal:!0}})}}),r.jsx(ke,{name:"amount",control:o,render:({field:u,fieldState:m})=>r.jsx(ke,{name:"currency",control:o,render:({field:j,fieldState:v})=>r.jsx(ks,{...u,value:u.value??void 0,error:m.error?.message||v.error?.message,label:"Amount",currencyCodeProps:{...j,label:"Currency"}})})}),r.jsx(ke,{name:"categoryId",control:o,render:({field:u,fieldState:m})=>r.jsx(Vt,{...u,disabled:d,data:x,label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:m.error?.message,withinPortal:!0})}),r.jsx(ke,{name:"type",control:o,render:({field:u,fieldState:m})=>r.jsx(Vt,{...u,data:Bo,value:u.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:m.error?.message,withinPortal:!0})}),r.jsx("div",{className:"flex justify-center mt-5 gap-3",children:r.jsx("button",{type:"submit",className:"text-white bg-indigo-500 border-0 py-2 px-8 focus:outline-hidden hover:bg-indigo-600 rounded-sm text-lg",children:"Add"})})]})}),(f||i)&&r.jsx(hs,{blur:1,center:!0,children:r.jsx(it,{})})]})}const Du="updateDepreciationRecord",Cu=()=>{const[{fetching:e},t]=Te(Ha),n=p.useCallback(async s=>{const o="Error updating depreciation record",a=Du;R.loading("Updating depreciation record",{id:a});try{const i=await t(s),c=$e(i,o,a,"updateDepreciationRecord");if(c)return R.success("Success",{id:a,description:"Depreciation record was updated"}),c.updateDepreciationRecord}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateDepreciationRecord:n}},Su="deleteDepreciationRecord",wu=()=>{const[{fetching:e},t]=Te(Ua),n=p.useCallback(async s=>{const o="Error deleting depreciation record",a=`${Su}-${s.depreciationRecordId}`;R.loading("Deleting depreciation record",{id:a});try{const i=await t(s),c=$e(i,o,a);if(c)return R.success("Success",{id:a,description:"Depreciation record was deleted"}),c.deleteDepreciationRecord}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteDepreciationRecord:n}};function _u(e){const{fetching:t,deleteDepreciationRecord:n}=wu(),s=p.useCallback(()=>{n({depreciationRecordId:e.depreciationRecordId}).then(()=>{e.onDelete?.()})},[e,n]);return r.jsx(Ue,{content:"Remove Depreciation",children:r.jsx(on,{onConfirm:s,title:"Are you sure you want to delete the depreciation record?",children:r.jsx(Y,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:t,children:r.jsx(Rn,{className:"size-5"})})})})}const Iu=({data:e,onChange:t})=>{const n=L(Ga,e),[s,o]=p.useState(!1),[{data:a,fetching:i},c]=Ne({query:Ts,pause:!0}),{control:l,handleSubmit:d,formState:{dirtyFields:h}}=an({defaultValues:{id:n.id}}),{updateDepreciationRecord:f,fetching:g}=Cu(),x=m=>{const j=qa(m,h);j&&Object.keys(j).length>0&&f({fields:{...m,id:n.id}}).then(()=>{t?.(),o(!1)})},u=a?.depreciationCategories.map(m=>({value:m.id,label:m.name}));return p.useEffect(()=>{s&&!a&&c()},[s,a,c]),r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("form",{id:`form ${n.id}`,onSubmit:d(x),children:s?r.jsx(ke,{name:"amount",control:l,render:({field:m,fieldState:j})=>r.jsx(ke,{name:"currency",control:l,render:({field:v,fieldState:b})=>r.jsx(ks,{...m,defaultValue:n.amount?.raw??n.charge.totalAmount?.raw,value:m.value??void 0,error:j.error?.message||b.error?.message,label:"Amount",currencyCodeProps:{...v,label:"Currency",defaultValue:n.amount?.currency??n.charge.totalAmount?.currency}})})}):r.jsx("div",{children:n.amount?.formatted??n.charge.totalAmount?.formatted})})}),r.jsx("td",{children:r.jsx("div",{className:"flex flex-col gap-2 justify-center",children:s?r.jsx(ke,{name:"activationDate",control:l,defaultValue:n.activationDate,rules:{pattern:{value:$s,message:"Date must be im format yyyy-mm-dd"}},render:({field:{value:m,...j},fieldState:v})=>{const b=m?new Date(m):void 0;return r.jsx(Fs,{...j,form:`form ${n.id}`,onChange:D=>{const C=D?typeof D=="string"?D:tt(D,"yyyy-MM-dd"):void 0;C!==m&&j.onChange(C)},value:b,label:"Activation Date",error:v.error?.message,popoverProps:{withinPortal:!0}})}}):r.jsx("div",{children:tt(new Date(n.activationDate),"dd/MM/yy")})})}),r.jsx("td",{children:s?r.jsx(ke,{name:"categoryId",control:l,render:({field:m,fieldState:j})=>r.jsx(Vt,{...m,form:`form ${n.id}`,disabled:i,data:u??[],label:"Category",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:j.error?.message,withinPortal:!0})}):r.jsxs("div",{children:[n.category.name," (",n.category.percentage,"%)"]})}),r.jsx("td",{children:s?r.jsx(ke,{name:"type",control:l,render:({field:m,fieldState:j})=>r.jsx(Vt,{...m,form:`form ${n.id}`,data:Bo,value:m.value,label:"Type",placeholder:"Scroll to see all options",maxDropdownHeight:160,searchable:!0,error:j.error?.message,withinPortal:!0})}):r.jsx("div",{children:n.type})}),r.jsxs("td",{children:[r.jsx(Ue,{content:"Edit",children:r.jsx(Y,{disabled:g||i,variant:s?"default":"outline",size:"icon",className:"size-7.5",onClick:m=>{m.stopPropagation(),o(j=>!j)},children:r.jsx(Mn,{className:"size-5"})})}),s&&r.jsx(Ue,{content:"Confirm Changes",children:r.jsx(Y,{type:"submit",form:`form ${n.id}`,variant:"outline",size:"icon",className:"size-7.5 text-green-500",children:r.jsx(Ka,{className:"size-5"})})}),r.jsx(_u,{depreciationRecordId:n.id,onDelete:t})]})]},n.id)},Ou=({chargeId:e,onChange:t})=>{const[{data:n,fetching:s}]=Ne({query:Wa,variables:{chargeId:e}});return!s&&!n?.depreciationRecordsByCharge.length?r.jsx(Zr,{chargeId:e,onAdd:t}):s?r.jsx(zn,{className:"h-10 w-10 animate-spin mr-2 self-center"}):r.jsx("div",{className:"flex flex-col gap-2 mt-5",children:r.jsxs(no,{highlightOnHover:!0,withBorder:!0,children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Activation Date"}),r.jsx("th",{children:"Category"}),r.jsx("th",{children:"Type"}),r.jsx("th",{})]})}),r.jsxs("tbody",{children:[n?.depreciationRecordsByCharge.map(o=>r.jsx(Iu,{data:o,onChange:t},o.id)),r.jsx("tr",{children:r.jsx("td",{colSpan:5,children:r.jsx(Zr,{chargeId:e,onAdd:t})})})]})]})})},Bo=Object.entries(Ya).map(([e,t])=>({value:t,label:e}));function Eu({chargeId:e,chargeType:t,onChange:n,isIncome:s}){const{deleteCharge:o}=cl(),[a,i]=p.useState(!1),[c,{open:l,close:d}]=jt(!1),[h,f]=p.useState(!1),[g,{open:x,close:u}]=jt(!1),[m,j]=p.useState(!1),[v,b]=p.useState(!1),[D,C]=p.useState(!1),[A,E]=p.useState(!1),w=p.useCallback(()=>{i(!1)},[]),O=p.useCallback(async()=>{await o({chargeId:e}),n?.(),w()},[e,o,n,w]);return r.jsxs(r.Fragment,{children:[r.jsxs(oe,{shadow:"md",width:200,opened:a,children:[r.jsx(oe.Target,{children:r.jsx(Ri,{opened:a,onClick:_=>{_.stopPropagation(),i(M=>!M)}})}),r.jsxs(oe.Dropdown,{children:[r.jsx(oe.Label,{children:"Charge"}),r.jsx(oe.Item,{icon:r.jsx(Mn,{size:14}),onClick:()=>{b(!0),w()},children:"Edit Charge"}),r.jsx(on,{onConfirm:O,title:"Are you sure you want to delete this charge?",children:r.jsx(oe.Item,{icon:r.jsx(Rn,{size:14}),children:"Delete Charge"})}),r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Documents"}),r.jsx(oe.Item,{icon:r.jsx(pn,{size:14}),onClick:_=>{_.stopPropagation(),C(!0),w()},children:"Insert Document"}),r.jsx(oe.Item,{icon:r.jsx(hr,{size:14}),onClick:_=>{_.stopPropagation(),E(!0),w()},children:"Upload Documents"}),s&&r.jsx(oe.Item,{icon:r.jsx(pn,{size:14}),onClick:_=>{_.stopPropagation(),j(!0),w()},children:"Issue Document"}),r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Misc Expenses"}),r.jsx(oe.Item,{icon:r.jsx(pn,{size:14}),onClick:_=>{_.stopPropagation(),w(),f(!0)},children:"Add expense"}),t==="CommonCharge"&&r.jsxs(r.Fragment,{children:[r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Depreciation"}),r.jsx(oe.Item,{icon:r.jsx(Ui,{size:14}),onClick:_=>{_.stopPropagation(),l(),w()},children:"Depreciation"})]}),t==="SalaryCharge"&&r.jsxs(r.Fragment,{children:[r.jsx(oe.Divider,{}),r.jsx(oe.Label,{children:"Salaries"}),r.jsx(oe.Item,{icon:r.jsx(hr,{size:14}),onClick:_=>{_.stopPropagation(),w(),x()},children:"Payroll file upload"})]})]})]}),r.jsx(yt,{withinPortal:!0,size:"xl",centered:!0,opened:c,onClose:d,title:"Depreciation",onClick:_=>_.stopPropagation(),children:r.jsx(Ou,{chargeId:e,onChange:()=>{d(),n?.()}})}),r.jsx(cn,{open:h,onOpenChange:f,children:r.jsx(ln,{className:"sm:max-w-[425px]",onClick:_=>_.stopPropagation(),children:r.jsx(Ii,{onDone:()=>{f(!1),n?.()},chargeId:e})})}),r.jsx(yt,{centered:!0,opened:g,onClose:u,title:"Upload Payroll File",onClick:_=>_.stopPropagation(),children:r.jsx(bl,{onDone:()=>{u(),n?.()},chargeId:e})}),r.jsx(Qa,{open:A,onOpenChange:E,onChange:n,chargeId:e}),r.jsx(_n,{chargeId:e,open:m,setOpen:j,onDone:()=>n?.()}),r.jsx(nu,{chargeId:v?e:void 0,close:()=>b(!1),onChange:n}),r.jsx(su,{chargeId:D?e:void 0,onChange:n,close:()=>C(!1)})]})}function Pu(e){return Object.prototype.toString.call(e)==="[object Object]"}function es(e){return Pu(e)||Array.isArray(e)}function Au(){return!!(typeof window<"u"&&window.document&&window.document.createElement)}function Gn(e,t){const n=Object.keys(e),s=Object.keys(t);if(n.length!==s.length)return!1;const o=JSON.stringify(Object.keys(e.breakpoints||{})),a=JSON.stringify(Object.keys(t.breakpoints||{}));return o!==a?!1:n.every(i=>{const c=e[i],l=t[i];return typeof c=="function"?`${c}`==`${l}`:!es(c)||!es(l)?c===l:Gn(c,l)})}function ts(e){return e.concat().sort((t,n)=>t.name>n.name?1:-1).map(t=>t.options)}function Nu(e,t){if(e.length!==t.length)return!1;const n=ts(e),s=ts(t);return n.every((o,a)=>{const i=s[a];return Gn(o,i)})}function qn(e){return typeof e=="number"}function Tn(e){return typeof e=="string"}function un(e){return typeof e=="boolean"}function ns(e){return Object.prototype.toString.call(e)==="[object Object]"}function X(e){return Math.abs(e)}function Wn(e){return Math.sign(e)}function vt(e,t){return X(e-t)}function Tu(e,t){if(e===0||t===0||X(e)<=X(t))return 0;const n=vt(X(e),X(t));return X(n/e)}function $u(e){return Math.round(e*100)/100}function Ct(e){return St(e).map(Number)}function Ae(e){return e[Ot(e)]}function Ot(e){return Math.max(0,e.length-1)}function Yn(e,t){return t===Ot(e)}function rs(e,t=0){return Array.from(Array(e),(n,s)=>t+s)}function St(e){return Object.keys(e)}function Vo(e,t){return[e,t].reduce((n,s)=>(St(s).forEach(o=>{const a=n[o],i=s[o],c=ns(a)&&ns(i);n[o]=c?Vo(a,i):i}),n),{})}function $n(e,t){return typeof t.MouseEvent<"u"&&e instanceof t.MouseEvent}function Fu(e,t){const n={start:s,center:o,end:a};function s(){return 0}function o(l){return a(l)/2}function a(l){return t-l}function i(l,d){return Tn(e)?n[e](l):e(t,l,d)}return{measure:i}}function wt(){let e=[];function t(o,a,i,c={passive:!0}){let l;if("addEventListener"in o)o.addEventListener(a,i,c),l=()=>o.removeEventListener(a,i,c);else{const d=o;d.addListener(i),l=()=>d.removeListener(i)}return e.push(l),s}function n(){e=e.filter(o=>o())}const s={add:t,clear:n};return s}function ku(e,t,n,s){const o=wt(),a=1e3/60;let i=null,c=0,l=0;function d(){o.add(e,"visibilitychange",()=>{e.hidden&&u()})}function h(){x(),o.clear()}function f(j){if(!l)return;i||(i=j,n(),n());const v=j-i;for(i=j,c+=v;c>=a;)n(),c-=a;const b=c/a;s(b),l&&(l=t.requestAnimationFrame(f))}function g(){l||(l=t.requestAnimationFrame(f))}function x(){t.cancelAnimationFrame(l),i=null,c=0,l=0}function u(){i=null,c=0}return{init:d,destroy:h,start:g,stop:x,update:n,render:s}}function Mu(e,t){const n=t==="rtl",s=e==="y",o=s?"y":"x",a=s?"x":"y",i=!s&&n?-1:1,c=h(),l=f();function d(u){const{height:m,width:j}=u;return s?m:j}function h(){return s?"top":n?"right":"left"}function f(){return s?"bottom":n?"left":"right"}function g(u){return u*i}return{scroll:o,cross:a,startEdge:c,endEdge:l,measureSize:d,direction:g}}function nt(e=0,t=0){const n=X(e-t);function s(d){return d<e}function o(d){return d>t}function a(d){return s(d)||o(d)}function i(d){return a(d)?s(d)?e:t:d}function c(d){return n?d-n*Math.ceil((d-t)/n):d}return{length:n,max:t,min:e,constrain:i,reachedAny:a,reachedMax:o,reachedMin:s,removeOffset:c}}function Ho(e,t,n){const{constrain:s}=nt(0,e),o=e+1;let a=i(t);function i(g){return n?X((o+g)%o):s(g)}function c(){return a}function l(g){return a=i(g),f}function d(g){return h().set(c()+g)}function h(){return Ho(e,c(),n)}const f={get:c,set:l,add:d,clone:h};return f}function Ru(e,t,n,s,o,a,i,c,l,d,h,f,g,x,u,m,j,v,b){const{cross:D,direction:C}=e,A=["INPUT","SELECT","TEXTAREA"],E={passive:!1},w=wt(),O=wt(),_=nt(50,225).constrain(x.measure(20)),M={mouse:300,touch:400},P={mouse:500,touch:600},U=u?43:25;let y=!1,N=0,B=0,le=!1,ae=!1,ne=!1,K=!1;function z(I){if(!b)return;function V(te){(un(b)||b(I,te))&&ie(te)}const q=t;w.add(q,"dragstart",te=>te.preventDefault(),E).add(q,"touchmove",()=>{},E).add(q,"touchend",()=>{}).add(q,"touchstart",V).add(q,"mousedown",V).add(q,"touchcancel",$).add(q,"contextmenu",$).add(q,"click",fe,!0)}function de(){w.clear(),O.clear()}function ue(){const I=K?n:t;O.add(I,"touchmove",Z,E).add(I,"touchend",$).add(I,"mousemove",Z,E).add(I,"mouseup",$)}function Ce(I){const V=I.nodeName||"";return A.includes(V)}function G(){return(u?P:M)[K?"mouse":"touch"]}function xe(I,V){const q=f.add(Wn(I)*-1),te=h.byDistance(I,!u).distance;return u||X(I)<_?te:j&&V?te*.5:h.byIndex(q.get(),0).distance}function ie(I){const V=$n(I,s);K=V,ne=u&&V&&!I.buttons&&y,y=vt(o.get(),i.get())>=2,!(V&&I.button!==0)&&(Ce(I.target)||(le=!0,a.pointerDown(I),d.useFriction(0).useDuration(0),o.set(i),ue(),N=a.readPoint(I),B=a.readPoint(I,D),g.emit("pointerDown")))}function Z(I){if(!$n(I,s)&&I.touches.length>=2)return $(I);const q=a.readPoint(I),te=a.readPoint(I,D),pe=vt(q,N),ce=vt(te,B);if(!ae&&!K&&(!I.cancelable||(ae=pe>ce,!ae)))return $(I);const ye=a.pointerMove(I);pe>m&&(ne=!0),d.useFriction(.3).useDuration(.75),c.start(),o.add(C(ye)),I.preventDefault()}function $(I){const q=h.byDistance(0,!1).index!==f.get(),te=a.pointerUp(I)*G(),pe=xe(C(te),q),ce=Tu(te,pe),ye=U-10*ce,me=v+ce/50;ae=!1,le=!1,O.clear(),d.useDuration(ye).useFriction(me),l.distance(pe,!u),K=!1,g.emit("pointerUp")}function fe(I){ne&&(I.stopPropagation(),I.preventDefault(),ne=!1)}function ee(){return le}return{init:z,destroy:de,pointerDown:ee}}function zu(e,t){let s,o;function a(f){return f.timeStamp}function i(f,g){const u=`client${(g||e.scroll)==="x"?"X":"Y"}`;return($n(f,t)?f:f.touches[0])[u]}function c(f){return s=f,o=f,i(f)}function l(f){const g=i(f)-i(o),x=a(f)-a(s)>170;return o=f,x&&(s=f),g}function d(f){if(!s||!o)return 0;const g=i(o)-i(s),x=a(f)-a(s),u=a(f)-a(o)>170,m=g/x;return x&&!u&&X(m)>.1?m:0}return{pointerDown:c,pointerMove:l,pointerUp:d,readPoint:i}}function Lu(){function e(n){const{offsetTop:s,offsetLeft:o,offsetWidth:a,offsetHeight:i}=n;return{top:s,right:o+a,bottom:s+i,left:o,width:a,height:i}}return{measure:e}}function Bu(e){function t(s){return e*(s/100)}return{measure:t}}function Vu(e,t,n,s,o,a,i){const c=[e].concat(s);let l,d,h=[],f=!1;function g(j){return o.measureSize(i.measure(j))}function x(j){if(!a)return;d=g(e),h=s.map(g);function v(b){for(const D of b){if(f)return;const C=D.target===e,A=s.indexOf(D.target),E=C?d:h[A],w=g(C?e:s[A]);if(X(w-E)>=.5){j.reInit(),t.emit("resize");break}}}l=new ResizeObserver(b=>{(un(a)||a(j,b))&&v(b)}),n.requestAnimationFrame(()=>{c.forEach(b=>l.observe(b))})}function u(){f=!0,l&&l.disconnect()}return{init:x,destroy:u}}function Hu(e,t,n,s,o,a){let i=0,c=0,l=o,d=a,h=e.get(),f=0;function g(){const E=s.get()-e.get(),w=!l;let O=0;return w?(i=0,n.set(s),e.set(s),O=E):(n.set(e),i+=E/l,i*=d,h+=i,e.add(i),O=h-f),c=Wn(O),f=h,A}function x(){const E=s.get()-t.get();return X(E)<.001}function u(){return l}function m(){return c}function j(){return i}function v(){return D(o)}function b(){return C(a)}function D(E){return l=E,A}function C(E){return d=E,A}const A={direction:m,duration:u,velocity:j,seek:g,settled:x,useBaseFriction:b,useBaseDuration:v,useFriction:C,useDuration:D};return A}function Uu(e,t,n,s,o){const a=o.measure(10),i=o.measure(50),c=nt(.1,.99);let l=!1;function d(){return!(l||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function h(x){if(!d())return;const u=e.reachedMin(t.get())?"min":"max",m=X(e[u]-t.get()),j=n.get()-t.get(),v=c.constrain(m/i);n.subtract(j*v),!x&&X(j)<a&&(n.set(e.constrain(n.get())),s.useDuration(25).useBaseFriction())}function f(x){l=!x}return{shouldConstrain:d,constrain:h,toggleActive:f}}function Ku(e,t,n,s,o){const a=nt(-t+e,0),i=f(),c=h(),l=g();function d(u,m){return vt(u,m)<=1}function h(){const u=i[0],m=Ae(i),j=i.lastIndexOf(u),v=i.indexOf(m)+1;return nt(j,v)}function f(){return n.map((u,m)=>{const{min:j,max:v}=a,b=a.constrain(u),D=!m,C=Yn(n,m);return D?v:C||d(j,b)?j:d(v,b)?v:b}).map(u=>parseFloat(u.toFixed(3)))}function g(){if(t<=e+o)return[a.max];if(s==="keepSnaps")return i;const{min:u,max:m}=c;return i.slice(u,m)}return{snapsContained:l,scrollContainLimit:c}}function Gu(e,t,n){const s=t[0],o=n?s-e:Ae(t);return{limit:nt(o,s)}}function qu(e,t,n,s){const a=t.min+.1,i=t.max+.1,{reachedMin:c,reachedMax:l}=nt(a,i);function d(g){return g===1?l(n.get()):g===-1?c(n.get()):!1}function h(g){if(!d(g))return;const x=e*(g*-1);s.forEach(u=>u.add(x))}return{loop:h}}function Wu(e){const{max:t,length:n}=e;function s(a){const i=a-t;return n?i/-n:0}return{get:s}}function Yu(e,t,n,s,o){const{startEdge:a,endEdge:i}=e,{groupSlides:c}=o,l=f().map(t.measure),d=g(),h=x();function f(){return c(s).map(m=>Ae(m)[i]-m[0][a]).map(X)}function g(){return s.map(m=>n[a]-m[a]).map(m=>-X(m))}function x(){return c(d).map(m=>m[0]).map((m,j)=>m+l[j])}return{snaps:d,snapsAligned:h}}function Qu(e,t,n,s,o,a){const{groupSlides:i}=o,{min:c,max:l}=s,d=h();function h(){const g=i(a),x=!e||t==="keepSnaps";return n.length===1?[a]:x?g:g.slice(c,l).map((u,m,j)=>{const v=!m,b=Yn(j,m);if(v){const D=Ae(j[0])+1;return rs(D)}if(b){const D=Ot(a)-Ae(j)[0]+1;return rs(D,Ae(j)[0])}return u})}return{slideRegistry:d}}function Xu(e,t,n,s,o){const{reachedAny:a,removeOffset:i,constrain:c}=s;function l(u){return u.concat().sort((m,j)=>X(m)-X(j))[0]}function d(u){const m=e?i(u):c(u),j=t.map((b,D)=>({diff:h(b-m,0),index:D})).sort((b,D)=>X(b.diff)-X(D.diff)),{index:v}=j[0];return{index:v,distance:m}}function h(u,m){const j=[u,u+n,u-n];if(!e)return u;if(!m)return l(j);const v=j.filter(b=>Wn(b)===m);return v.length?l(v):Ae(j)-n}function f(u,m){const j=t[u]-o.get(),v=h(j,m);return{index:u,distance:v}}function g(u,m){const j=o.get()+u,{index:v,distance:b}=d(j),D=!e&&a(j);if(!m||D)return{index:v,distance:u};const C=t[v]-b,A=u+h(C,0);return{index:v,distance:A}}return{byDistance:g,byIndex:f,shortcut:h}}function Ju(e,t,n,s,o,a,i){function c(f){const g=f.distance,x=f.index!==t.get();a.add(g),g&&(s.duration()?e.start():(e.update(),e.render(1),e.update())),x&&(n.set(t.get()),t.set(f.index),i.emit("select"))}function l(f,g){const x=o.byDistance(f,g);c(x)}function d(f,g){const x=t.clone().set(f),u=o.byIndex(x.get(),g);c(u)}return{distance:l,index:d}}function Zu(e,t,n,s,o,a,i,c){const l={passive:!0,capture:!0};let d=0;function h(x){if(!c)return;function u(m){if(new Date().getTime()-d>10)return;i.emit("slideFocusStart"),e.scrollLeft=0;const b=n.findIndex(D=>D.includes(m));qn(b)&&(o.useDuration(0),s.index(b,0),i.emit("slideFocus"))}a.add(document,"keydown",f,!1),t.forEach((m,j)=>{a.add(m,"focus",v=>{(un(c)||c(x,v))&&u(j)},l)})}function f(x){x.code==="Tab"&&(d=new Date().getTime())}return{init:h}}function xt(e){let t=e;function n(){return t}function s(l){t=i(l)}function o(l){t+=i(l)}function a(l){t-=i(l)}function i(l){return qn(l)?l:l.get()}return{get:n,set:s,add:o,subtract:a}}function Uo(e,t){const n=e.scroll==="x"?i:c,s=t.style;let o=null,a=!1;function i(g){return`translate3d(${g}px,0px,0px)`}function c(g){return`translate3d(0px,${g}px,0px)`}function l(g){if(a)return;const x=$u(e.direction(g));x!==o&&(s.transform=n(x),o=x)}function d(g){a=!g}function h(){a||(s.transform="",t.getAttribute("style")||t.removeAttribute("style"))}return{clear:h,to:l,toggleActive:d}}function ef(e,t,n,s,o,a,i,c,l){const h=Ct(o),f=Ct(o).reverse(),g=v().concat(b());function x(w,O){return w.reduce((_,M)=>_-o[M],O)}function u(w,O){return w.reduce((_,M)=>x(_,O)>0?_.concat([M]):_,[])}function m(w){return a.map((O,_)=>({start:O-s[_]+.5+w,end:O+t-.5+w}))}function j(w,O,_){const M=m(O);return w.map(P=>{const U=_?0:-n,y=_?n:0,N=_?"end":"start",B=M[P][N];return{index:P,loopPoint:B,slideLocation:xt(-1),translate:Uo(e,l[P]),target:()=>c.get()>B?U:y}})}function v(){const w=i[0],O=u(f,w);return j(O,n,!1)}function b(){const w=t-i[0]-1,O=u(h,w);return j(O,-n,!0)}function D(){return g.every(({index:w})=>{const O=h.filter(_=>_!==w);return x(O,t)<=.1})}function C(){g.forEach(w=>{const{target:O,translate:_,slideLocation:M}=w,P=O();P!==M.get()&&(_.to(P),M.set(P))})}function A(){g.forEach(w=>w.translate.clear())}return{canLoop:D,clear:A,loop:C,loopPoints:g}}function tf(e,t,n){let s,o=!1;function a(l){if(!n)return;function d(h){for(const f of h)if(f.type==="childList"){l.reInit(),t.emit("slidesChanged");break}}s=new MutationObserver(h=>{o||(un(n)||n(l,h))&&d(h)}),s.observe(e,{childList:!0})}function i(){s&&s.disconnect(),o=!0}return{init:a,destroy:i}}function nf(e,t,n,s){const o={};let a=null,i=null,c,l=!1;function d(){c=new IntersectionObserver(u=>{l||(u.forEach(m=>{const j=t.indexOf(m.target);o[j]=m}),a=null,i=null,n.emit("slidesInView"))},{root:e.parentElement,threshold:s}),t.forEach(u=>c.observe(u))}function h(){c&&c.disconnect(),l=!0}function f(u){return St(o).reduce((m,j)=>{const v=parseInt(j),{isIntersecting:b}=o[v];return(u&&b||!u&&!b)&&m.push(v),m},[])}function g(u=!0){if(u&&a)return a;if(!u&&i)return i;const m=f(u);return u&&(a=m),u||(i=m),m}return{init:d,destroy:h,get:g}}function rf(e,t,n,s,o,a){const{measureSize:i,startEdge:c,endEdge:l}=e,d=n[0]&&o,h=u(),f=m(),g=n.map(i),x=j();function u(){if(!d)return 0;const b=n[0];return X(t[c]-b[c])}function m(){if(!d)return 0;const b=a.getComputedStyle(Ae(s));return parseFloat(b.getPropertyValue(`margin-${l}`))}function j(){return n.map((b,D,C)=>{const A=!D,E=Yn(C,D);return A?g[D]+h:E?g[D]+f:C[D+1][c]-b[c]}).map(X)}return{slideSizes:g,slideSizesWithGaps:x,startGap:h,endGap:f}}function sf(e,t,n,s,o,a,i,c,l){const{startEdge:d,endEdge:h,direction:f}=e,g=qn(n);function x(v,b){return Ct(v).filter(D=>D%b===0).map(D=>v.slice(D,D+b))}function u(v){return v.length?Ct(v).reduce((b,D,C)=>{const A=Ae(b)||0,E=A===0,w=D===Ot(v),O=o[d]-a[A][d],_=o[d]-a[D][h],M=!s&&E?f(i):0,P=!s&&w?f(c):0,U=X(_-P-(O+M));return C&&U>t+l&&b.push(D),w&&b.push(v.length),b},[]).map((b,D,C)=>{const A=Math.max(C[D-1]||0);return v.slice(A,b)}):[]}function m(v){return g?x(v,n):u(v)}return{groupSlides:m}}function of(e,t,n,s,o,a,i){const{align:c,axis:l,direction:d,startIndex:h,loop:f,duration:g,dragFree:x,dragThreshold:u,inViewThreshold:m,slidesToScroll:j,skipSnaps:v,containScroll:b,watchResize:D,watchSlides:C,watchDrag:A,watchFocus:E}=a,w=2,O=Lu(),_=O.measure(t),M=n.map(O.measure),P=Mu(l,d),U=P.measureSize(_),y=Bu(U),N=Fu(c,U),B=!f&&!!b,le=f||!!b,{slideSizes:ae,slideSizesWithGaps:ne,startGap:K,endGap:z}=rf(P,_,M,n,le,o),de=sf(P,U,j,f,_,M,K,z,w),{snaps:ue,snapsAligned:Ce}=Yu(P,N,_,M,de),G=-Ae(ue)+Ae(ne),{snapsContained:xe,scrollContainLimit:ie}=Ku(U,G,Ce,b,w),Z=B?xe:Ce,{limit:$}=Gu(G,Z,f),fe=Ho(Ot(Z),h,f),ee=fe.clone(),H=Ct(n),I=({dragHandler:Se,scrollBody:Qe,scrollBounds:Xe,options:{loop:Ge}})=>{Ge||Xe.constrain(Se.pointerDown()),Qe.seek()},V=({scrollBody:Se,translate:Qe,location:Xe,offsetLocation:Ge,previousLocation:rt,scrollLooper:ft,slideLooper:pt,dragHandler:mt,animation:gt,eventHandler:Et,scrollBounds:Qo,options:{loop:Jn}},Zn)=>{const er=Se.settled(),Xo=!Qo.shouldConstrain(),tr=Jn?er:er&&Xo,nr=tr&&!mt.pointerDown();nr&>.stop();const Jo=Xe.get()*Zn+rt.get()*(1-Zn);Ge.set(Jo),Jn&&(ft.loop(Se.direction()),pt.loop()),Qe.to(Ge.get()),nr&&Et.emit("settle"),tr||Et.emit("scroll")},q=ku(s,o,()=>I(ze),Se=>V(ze,Se)),te=.68,pe=Z[fe.get()],ce=xt(pe),ye=xt(pe),me=xt(pe),ve=xt(pe),re=Hu(ce,me,ye,ve,g,te),Re=Xu(f,Z,G,$,ve),ut=Ju(q,fe,ee,re,Re,ve,i),S=Wu($),T=wt(),J=nf(t,n,i,m),{slideRegistry:se}=Qu(B,b,Z,ie,de,H),ge=Zu(e,n,se,ut,re,T,i,E),ze={ownerDocument:s,ownerWindow:o,eventHandler:i,containerRect:_,slideRects:M,animation:q,axis:P,dragHandler:Ru(P,e,s,o,ve,zu(P,o),ce,q,ut,re,Re,fe,i,y,x,u,v,te,A),eventStore:T,percentOfView:y,index:fe,indexPrevious:ee,limit:$,location:ce,offsetLocation:me,previousLocation:ye,options:a,resizeHandler:Vu(t,i,o,n,P,D,O),scrollBody:re,scrollBounds:Uu($,me,ve,re,y),scrollLooper:qu(G,$,me,[ce,me,ye,ve]),scrollProgress:S,scrollSnapList:Z.map(S.get),scrollSnaps:Z,scrollTarget:Re,scrollTo:ut,slideLooper:ef(P,U,G,ae,ne,ue,Z,me,n),slideFocus:ge,slidesHandler:tf(t,i,C),slidesInView:J,slideIndexes:H,slideRegistry:se,slidesToScroll:de,target:ve,translate:Uo(P,t)};return ze}function af(){let e={},t;function n(d){t=d}function s(d){return e[d]||[]}function o(d){return s(d).forEach(h=>h(t,d)),l}function a(d,h){return e[d]=s(d).concat([h]),l}function i(d,h){return e[d]=s(d).filter(f=>f!==h),l}function c(){e={}}const l={init:n,emit:o,off:i,on:a,clear:c};return l}const cf={align:"center",axis:"x",container:null,slides:null,containScroll:"trimSnaps",direction:"ltr",slidesToScroll:1,inViewThreshold:0,breakpoints:{},dragFree:!1,dragThreshold:10,loop:!1,skipSnaps:!1,duration:25,startIndex:0,active:!0,watchDrag:!0,watchResize:!0,watchSlides:!0,watchFocus:!0};function lf(e){function t(a,i){return Vo(a,i||{})}function n(a){const i=a.breakpoints||{},c=St(i).filter(l=>e.matchMedia(l).matches).map(l=>i[l]).reduce((l,d)=>t(l,d),{});return t(a,c)}function s(a){return a.map(i=>St(i.breakpoints||{})).reduce((i,c)=>i.concat(c),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:s}}function df(e){let t=[];function n(a,i){return t=i.filter(({options:c})=>e.optionsAtMedia(c).active!==!1),t.forEach(c=>c.init(a,e)),i.reduce((c,l)=>Object.assign(c,{[l.name]:l}),{})}function s(){t=t.filter(a=>a.destroy())}return{init:n,destroy:s}}function nn(e,t,n){const s=e.ownerDocument,o=s.defaultView,a=lf(o),i=df(a),c=wt(),l=af(),{mergeOptions:d,optionsAtMedia:h,optionsMediaQueries:f}=a,{on:g,off:x,emit:u}=l,m=P;let j=!1,v,b=d(cf,nn.globalOptions),D=d(b),C=[],A,E,w;function O(){const{container:H,slides:I}=D;E=(Tn(H)?e.querySelector(H):H)||e.children[0];const q=Tn(I)?E.querySelectorAll(I):I;w=[].slice.call(q||E.children)}function _(H){const I=of(e,E,w,s,o,H,l);if(H.loop&&!I.slideLooper.canLoop()){const V=Object.assign({},H,{loop:!1});return _(V)}return I}function M(H,I){j||(b=d(b,H),D=h(b),C=I||C,O(),v=_(D),f([b,...C.map(({options:V})=>V)]).forEach(V=>c.add(V,"change",P)),D.active&&(v.translate.to(v.location.get()),v.animation.init(),v.slidesInView.init(),v.slideFocus.init(ee),v.eventHandler.init(ee),v.resizeHandler.init(ee),v.slidesHandler.init(ee),v.options.loop&&v.slideLooper.loop(),E.offsetParent&&w.length&&v.dragHandler.init(ee),A=i.init(ee,C)))}function P(H,I){const V=de();U(),M(d({startIndex:V},H),I),l.emit("reInit")}function U(){v.dragHandler.destroy(),v.eventStore.clear(),v.translate.clear(),v.slideLooper.clear(),v.resizeHandler.destroy(),v.slidesHandler.destroy(),v.slidesInView.destroy(),v.animation.destroy(),i.destroy(),c.clear()}function y(){j||(j=!0,c.clear(),U(),l.emit("destroy"),l.clear())}function N(H,I,V){!D.active||j||(v.scrollBody.useBaseFriction().useDuration(I===!0?0:D.duration),v.scrollTo.index(H,V||0))}function B(H){const I=v.index.add(1).get();N(I,H,-1)}function le(H){const I=v.index.add(-1).get();N(I,H,1)}function ae(){return v.index.add(1).get()!==de()}function ne(){return v.index.add(-1).get()!==de()}function K(){return v.scrollSnapList}function z(){return v.scrollProgress.get(v.offsetLocation.get())}function de(){return v.index.get()}function ue(){return v.indexPrevious.get()}function Ce(){return v.slidesInView.get()}function G(){return v.slidesInView.get(!1)}function xe(){return A}function ie(){return v}function Z(){return e}function $(){return E}function fe(){return w}const ee={canScrollNext:ae,canScrollPrev:ne,containerNode:$,internalEngine:ie,destroy:y,off:x,on:g,emit:u,plugins:xe,previousScrollSnap:ue,reInit:m,rootNode:Z,scrollNext:B,scrollPrev:le,scrollProgress:z,scrollSnapList:K,scrollTo:N,selectedScrollSnap:de,slideNodes:fe,slidesInView:Ce,slidesNotInView:G};return M(t,n),setTimeout(()=>l.emit("init"),0),ee}nn.globalOptions=void 0;function Qn(e={},t=[]){const n=p.useRef(e),s=p.useRef(t),[o,a]=p.useState(),[i,c]=p.useState(),l=p.useCallback(()=>{o&&o.reInit(n.current,s.current)},[o]);return p.useEffect(()=>{Gn(n.current,e)||(n.current=e,l())},[e,l]),p.useEffect(()=>{Nu(s.current,t)||(s.current=t,l())},[t,l]),p.useEffect(()=>{if(Au()&&i){nn.globalOptions=Qn.globalOptions;const d=nn(i,n.current,s.current);return a(d),()=>d.destroy()}else a(void 0)},[i,a]),[c,o]}Qn.globalOptions=void 0;const uf={context:"[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context"},[ff,pf]=js(uf.context);var mf=Object.defineProperty,gf=Object.defineProperties,hf=Object.getOwnPropertyDescriptors,ss=Object.getOwnPropertySymbols,xf=Object.prototype.hasOwnProperty,yf=Object.prototype.propertyIsEnumerable,os=(e,t,n)=>t in e?mf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sn=(e,t)=>{for(var n in t||(t={}))xf.call(t,n)&&os(e,n,t[n]);if(ss)for(var n of ss(t))yf.call(t,n)&&os(e,n,t[n]);return e},vf=(e,t)=>gf(e,hf(t)),jf=Ye((e,{controlSize:t,controlsOffset:n,orientation:s,height:o,includeGapInSize:a,breakpoints:i=[],slideGap:c})=>{const l=s==="horizontal",d=g=>{if(!a)return{};const x=Oe({size:g,sizes:e.spacing});return{[s==="horizontal"?"marginRight":"marginBottom"]:`calc(${x} * -1)`}},f=i.some(g=>typeof g.slideGap<"u"||typeof g.slideSize<"u")?Ms(e,i).reduce((g,x)=>{const u="maxWidth"in x?"max-width":"min-width",m=Oe({size:u==="max-width"?x.maxWidth:x.minWidth,sizes:e.breakpoints}),j=typeof x.slideGap>"u"?void 0:k(x.slideGap),v=Rs(m)-(u==="max-width"?1:0);return g[`@media (${u}: ${k(v)})`]=d(j),g},{}):null;return{root:{position:"relative"},viewport:{height:k(o),overflow:"hidden"},container:Sn(Sn({display:"flex",flexDirection:l?"row":"column",height:k(o)},d(c)),f),controls:{position:"absolute",zIndex:1,left:l?0:`calc(50% - ${k(t)} / 2)`,right:l?0:void 0,top:l?`calc(50% - ${k(t)} / 2)`:0,bottom:l?void 0:0,display:"flex",flexDirection:l?"row":"column",alignItems:"center",justifyContent:"space-between",paddingLeft:l?Oe({size:n,sizes:e.spacing}):void 0,paddingRight:l?Oe({size:n,sizes:e.spacing}):void 0,paddingTop:l?void 0:Oe({size:n,sizes:e.spacing}),paddingBottom:l?void 0:Oe({size:n,sizes:e.spacing}),pointerEvents:"none"},control:vf(Sn({display:"flex",justifyContent:"center",alignItems:"center",minWidth:k(t),minHeight:k(t),borderRadius:k(t),pointerEvents:"all",backgroundColor:e.white,color:e.black,boxShadow:e.shadows.md,opacity:e.colorScheme==="dark"?.65:.85,border:`${k(1)} solid ${e.colors.gray[3]}`,transition:`opacity 150ms ${e.transitionTimingFunction}`},e.fn.hover({opacity:1})),{"&:active":e.activeStyles}),indicators:{position:"absolute",bottom:l?e.spacing.md:0,top:l?void 0:0,left:l?0:void 0,right:l?0:e.spacing.md,display:"flex",flexDirection:l?"row":"column",justifyContent:"center",gap:k(8),pointerEvents:"none"},indicator:{pointerEvents:"all",width:l?k(25):k(5),height:l?k(5):k(25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),bf=Object.defineProperty,as=Object.getOwnPropertySymbols,Df=Object.prototype.hasOwnProperty,Cf=Object.prototype.propertyIsEnumerable,is=(e,t,n)=>t in e?bf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wn=(e,t)=>{for(var n in t||(t={}))Df.call(t,n)&&is(e,n,t[n]);if(as)for(var n of as(t))Cf.call(t,n)&&is(e,n,t[n]);return e},Sf=Ye((e,{size:t,gap:n,orientation:s,includeGapInSize:o,breakpoints:a=[]})=>{const i=(d,h)=>{const f=Oe({size:d,sizes:e.spacing}),g=k(h),x=o?{[s==="horizontal"?"paddingRight":"paddingBottom"]:f}:{[s==="horizontal"?"marginRight":"marginBottom"]:f};return wn({flex:`0 0 ${g}`},x)},l=a.some(d=>typeof d.slideGap<"u"||typeof d.slideSize<"u")?Ms(e,a).reduce((d,h)=>{const f="maxWidth"in h?"max-width":"min-width",g=Oe({size:f==="max-width"?h.maxWidth:h.minWidth,sizes:e.breakpoints}),x=typeof h.slideGap>"u"?n:h.slideGap,u=Rs(g)-(f==="max-width"?1:0);return d[`@media (${f}: ${k(u)})`]=i(x,h.slideSize),d},{}):null;return{slide:wn(wn({position:"relative"},i(n,t)),l)}}),wf=Object.defineProperty,rn=Object.getOwnPropertySymbols,Ko=Object.prototype.hasOwnProperty,Go=Object.prototype.propertyIsEnumerable,cs=(e,t,n)=>t in e?wf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_f=(e,t)=>{for(var n in t||(t={}))Ko.call(t,n)&&cs(e,n,t[n]);if(rn)for(var n of rn(t))Go.call(t,n)&&cs(e,n,t[n]);return e},If=(e,t)=>{var n={};for(var s in e)Ko.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&rn)for(var s of rn(e))t.indexOf(s)<0&&Go.call(e,s)&&(n[s]=e[s]);return n};const qo=p.forwardRef((e,t)=>{var n=e,{children:s,className:o,size:a,gap:i}=n,c=If(n,["children","className","size","gap"]);const l=pf(),{classes:d,cx:h}=Sf({gap:typeof i>"u"?l.slideGap:i,size:typeof a>"u"?l.slideSize:a,orientation:l.orientation,includeGapInSize:l.includeGapInSize,breakpoints:l.breakpoints},{name:"Carousel",classNames:l.classNames,styles:l.styles,unstyled:l.unstyled,variant:l.variant});return F.createElement(Me,_f({className:h(d.slide,o),ref:t},c),s)});qo.displayName="@mantine/carousel/CarouselSlide";function ls({dir:e,orientation:t,direction:n}){return n==="previous"?t==="horizontal"?90*(e==="ltr"?1:-1):-180:t==="horizontal"?90*(e==="ltr"?-1:1):0}var Of=Object.defineProperty,sn=Object.getOwnPropertySymbols,Wo=Object.prototype.hasOwnProperty,Yo=Object.prototype.propertyIsEnumerable,ds=(e,t,n)=>t in e?Of(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ef=(e,t)=>{for(var n in t||(t={}))Wo.call(t,n)&&ds(e,n,t[n]);if(sn)for(var n of sn(t))Yo.call(t,n)&&ds(e,n,t[n]);return e},Pf=(e,t)=>{var n={};for(var s in e)Wo.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&sn)for(var s of sn(e))t.indexOf(s)<0&&Yo.call(e,s)&&(n[s]=e[s]);return n};const Af={controlSize:26,controlsOffset:"sm",slideSize:"100%",slideGap:0,orientation:"horizontal",align:"center",slidesToScroll:1,includeGapInSize:!0,draggable:!0,dragFree:!1,loop:!1,speed:10,initialSlide:0,inViewThreshold:0,withControls:!0,withIndicators:!1,skipSnaps:!1,containScroll:"",withKeyboardEvents:!0},Xn=p.forwardRef((e,t)=>{const n=Ke("Carousel",Af,e),{children:s,className:o,getEmblaApi:a,onNextSlide:i,onPreviousSlide:c,onSlideChange:l,nextControlLabel:d,previousControlLabel:h,controlSize:f,controlsOffset:g,classNames:x,styles:u,unstyled:m,slideSize:j,slideGap:v,orientation:b,height:D,align:C,slidesToScroll:A,includeGapInSize:E,draggable:w,dragFree:O,loop:_,speed:M,initialSlide:P,inViewThreshold:U,withControls:y,withIndicators:N,plugins:B,nextControlIcon:le,previousControlIcon:ae,breakpoints:ne,skipSnaps:K,containScroll:z,withKeyboardEvents:de,variant:ue}=n,Ce=Pf(n,["children","className","getEmblaApi","onNextSlide","onPreviousSlide","onSlideChange","nextControlLabel","previousControlLabel","controlSize","controlsOffset","classNames","styles","unstyled","slideSize","slideGap","orientation","height","align","slidesToScroll","includeGapInSize","draggable","dragFree","loop","speed","initialSlide","inViewThreshold","withControls","withIndicators","plugins","nextControlIcon","previousControlIcon","breakpoints","skipSnaps","containScroll","withKeyboardEvents","variant"]),{classes:G,cx:xe,theme:ie}=jf({controlSize:f,controlsOffset:g,orientation:b,height:D,includeGapInSize:E,breakpoints:ne,slideGap:v},{name:"Carousel",classNames:x,styles:u,unstyled:m,variant:ue}),[Z,$]=Qn({axis:b==="horizontal"?"x":"y",direction:b==="horizontal"?ie.dir:void 0,startIndex:P,loop:_,align:C,slidesToScroll:A,draggable:w,dragFree:O,speed:M,inViewThreshold:U,skipSnaps:K,containScroll:z},B),[fe,ee]=p.useState(0),[H,I]=p.useState(0),V=p.useCallback(re=>$&&$.scrollTo(re),[$]),q=p.useCallback(()=>{if(!$)return;const re=$.selectedScrollSnap();ee(re),l?.(re)},[$,ee]),te=p.useCallback(()=>{$?.scrollPrev(),c?.()},[$]),pe=p.useCallback(()=>{$?.scrollNext(),i?.()},[$]),ce=p.useCallback(re=>{de&&(re.key==="ArrowRight"&&(re.preventDefault(),pe()),re.key==="ArrowLeft"&&(re.preventDefault(),te()))},[$]);p.useEffect(()=>{if($)return a?.($),q(),I($.scrollSnapList().length),$.on("select",q),()=>{$.off("select",q)}},[$,A]),p.useEffect(()=>{$&&($.reInit(),I($.scrollSnapList().length),ee(re=>Xa(re,0,p.Children.toArray(s).length-1)))},[p.Children.toArray(s).length,A]);const ye=$?.canScrollPrev()||!1,me=$?.canScrollNext()||!1,ve=Array(H).fill(0).map((re,Re)=>F.createElement(mn,{key:Re,"data-active":Re===fe||void 0,className:G.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>V(Re)}));return F.createElement(ff,{value:{slideGap:v,slideSize:j,embla:$,orientation:b,includeGapInSize:E,breakpoints:ne,classNames:x,styles:u,unstyled:m,variant:ue}},F.createElement(Me,Ef({className:xe(G.root,o),ref:t,onKeyDownCapture:ce},Ce),F.createElement("div",{className:G.viewport,ref:Z},F.createElement("div",{className:G.container},s)),N&&F.createElement("div",{className:G.indicators},ve),y&&F.createElement("div",{className:G.controls},F.createElement(mn,{onClick:te,className:G.control,"aria-label":h,"data-inactive":!ye||void 0,tabIndex:ye?0:-1},typeof ae<"u"?ae:F.createElement(ar,{style:{transform:`rotate(${ls({dir:ie.dir,orientation:b,direction:"previous"})}deg)`}})),F.createElement(mn,{onClick:pe,className:G.control,"aria-label":d,"data-inactive":!me||void 0,tabIndex:me?0:-1},typeof le<"u"?le:F.createElement(ar,{style:{transform:`rotate(${ls({dir:ie.dir,orientation:b,direction:"next"})}deg)`}})))))});Xn.Slide=qo;Xn.displayName="@mantine/carousel/Carousel";const us=Xn,Nf=({chargeProps:e,onChange:t})=>{const{additionalDocuments:n}=L(zs,e),[s,o]=p.useState(void 0);return r.jsx("div",{className:"container mx-auto text-gray-600 body-font",children:n?.length>0?r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"flex flex-wrap",children:r.jsx(us,{sx:{maxWidth:320},mx:"auto",align:"center",withControls:n.length>1,slideGap:0,withIndicators:!0,className:"[&>*>.mantine-Carousel-indicator]:bg-gray-500",children:n.map(a=>r.jsx(us.Slide,{children:r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("h2",{className:"text-gray-900 text-base font-medium",children:"documentType"in a?a.documentType:"Unprocessed"}),r.jsx("button",{className:"mx-10",onClick:()=>o(a.id),children:r.jsx("div",{className:"flex rounded-lg h-full bg-gray-100 p-2 m-2 flex-col",children:r.jsx(Ja,{src:a.image?.toString(),withPlaceholder:!0})})})]})},a.id))})}),r.jsx(Za,{documentId:s,onDone:()=>o(void 0),onChange:t})]}):r.jsx(In,{color:"red",children:"No Documents Related"})})},Rt=({foreignAmount:e,localAmount:t,diff:n})=>{const s=e!=null&&e.currency!==_t.Ils,o=n&&n.localAmount?.formatted!==t?.formatted,a=n&&n.foreignAmount?.formatted!==e?.formatted;return r.jsx("div",{className:"flex flex-col",children:(t||o)&&r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"flex gap-2 items-center",children:[s&&r.jsx("p",{className:a?"line-through":"",children:e.formatted}),a&&n.foreignAmount&&r.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:n.foreignAmount.formatted})]}),r.jsxs("div",{className:"flex gap-2 items-center",children:[t!=null&&r.jsx("p",{className:o?"line-through":"",children:t.formatted}),o&&n.localAmount&&r.jsx("p",{className:"border-2 border-yellow-500 rounded-md",children:n.localAmount.formatted})]})]})})},zt=({account:e,diffAccount:t})=>{const n=t&&t?.id!==e?.id;return r.jsx("div",{className:"flex flex-col whitespace-normal",children:(e||n)&&r.jsxs(r.Fragment,{children:[e&&r.jsx(bt,{to:We.BUSINESSES.DETAIL(e.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:`inline-flex items-center font-semibold ${n?"line-through":""}`,children:e.name}),n&&t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:r.jsx(bt,{to:We.BUSINESSES.DETAIL(t.id),target:"_blank",rel:"noreferrer",onClick:s=>s.stopPropagation(),className:"inline-flex items-center font-semibold",children:t.name})})]})})},fs=({date:e,diff:t})=>{const n=e?tt(new Date(e),"dd/MM/yy"):void 0,s=t?tt(new Date(t),"dd/MM/yy"):void 0,o=s&&n!==s;return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:o?"line-through":"",children:n??"Missing Data"}),o&&r.jsx("div",{className:"flex flex-col border-2 border-yellow-500 rounded-md",children:s})]})},Lt=(e,t)=>{const n=e.original[t],s=e.original.diff?.[t];return!n&&!s},ps=[{accessorKey:"invoiceDate",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Invoice Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(fs,{date:e.original.invoiceDate,diff:e.original.diff?.invoiceDate})},{accessorKey:"valueDate",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Value Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(fs,{date:e.original.valueDate,diff:e.original.diff?.valueDate})},{header:"Debit Account (Main)",columns:[{accessorKey:"debitAccount1.name",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(zt,{account:e.original.debitAccount1,diffAccount:e.original.diff?.debitAccount1})},{accessorKey:"localCurrencyDebitAmount1.raw",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Lt(e,"debitAccount1")?null:r.jsx(Rt,{foreignAmount:e.original.debitAmount1,localAmount:e.original.localCurrencyDebitAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount1,localAmount:e.original.diff.localCurrencyDebitAmount1}:void 0})}]},{header:"Credit Account (Main)",columns:[{accessorKey:"creditAccount1.name",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(zt,{account:e.original.creditAccount1,diffAccount:e.original.diff?.creditAccount1})},{accessorKey:"localCurrencyCreditAmount1.raw",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Lt(e,"creditAccount1")?null:r.jsx(Rt,{foreignAmount:e.original.creditAmount1,localAmount:e.original.localCurrencyCreditAmount1,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount1,localAmount:e.original.diff.localCurrencyCreditAmount1}:void 0})}]},{header:"Debit Account (Secondary)",columns:[{accessorKey:"debitAccount2.name",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(zt,{account:e.original.debitAccount2,diffAccount:e.original.diff?.debitAccount2})},{accessorKey:"localCurrencyDebitAmount2.raw",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Lt(e,"debitAccount2")?null:r.jsx(Rt,{foreignAmount:e.original.debitAmount2,localAmount:e.original.localCurrencyDebitAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.debitAmount2,localAmount:e.original.diff.localCurrencyDebitAmount2}:void 0})}]},{header:"Credit Account (Secondary)",columns:[{accessorKey:"creditAccount2.name",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Account",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>r.jsx(zt,{account:e.original.creditAccount2,diffAccount:e.original.diff?.creditAccount2})},{accessorKey:"localCurrencyCreditAmount2.raw",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>Lt(e,"creditAccount2")?null:r.jsx(Rt,{foreignAmount:e.original.creditAmount2,localAmount:e.original.localCurrencyCreditAmount2,diff:e.original.diff?{foreignAmount:e.original.diff.creditAmount2,localAmount:e.original.diff.localCurrencyCreditAmount2}:void 0})}]},{accessorKey:"description",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Details",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.description!==e.description;return r.jsxs("div",{className:"flex flex-col whitespace-normal",children:[r.jsx("p",{className:t?"line-through":"",children:e.description}),t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.description})]})}},{accessorKey:"reference",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Reference",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:e}})=>{const t=e.diff&&e.diff.reference!==e.reference;return r.jsxs("div",{className:"flex flex-col whitespace-normal",children:[r.jsx("p",{className:t?"line-through":"",children:e.reference}),t&&r.jsx("div",{className:"border-2 border-yellow-500 rounded-md",children:e.diff?.reference})]})}},{accessorKey:"matchingStatus",header:({column:e})=>r.jsxs(Y,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Status",e.getIsSorted()&&(e.getIsSorted()==="asc"?r.jsx(we,{className:"ml-2 h-4 w-4"}):r.jsx(je,{className:"ml-2 h-4 w-4"}))]}),cell:({row:{original:{matchingStatus:e}}})=>{if(e){const t=e==="Deleted"?"bg-red-500":e==="Diff"?"bg-yellow-500":"bg-green-500";return r.jsx(Ls,{variant:"default",className:t,children:e})}return null}}];function Tf(e){let t="";switch(e){case"New":t="bg-green-100/30";break;case"Deleted":t="bg-red-100/30";break;case"Diff":t="bg-yellow-100/30";break}return t}const $f=({ledgerRecordsData:e,ledgerDiffData:t,matches:n})=>{const[s,o]=p.useState([]),a=p.useMemo(()=>{const c=e.map(f=>L(ir,f)),l=t?.map(f=>L(ir,f)),d=c.map(f=>{const g=l?.find(x=>x.id===f.id);return{...f,matchingStatus:!n||n?.includes(f.id)?void 0:g?"Diff":"Deleted",diff:g}}),h=l?.filter(f=>f.id===ei).map(f=>({...f,matchingStatus:"New"}))??[];return d.push(...h),d},[e,t,n]),i=Bs({data:a,columns:ps,getCoreRowModel:Hs(),onSortingChange:o,getSortedRowModel:Vs(),getPaginationRowModel:ti(),state:{sorting:s},initialState:{pagination:{pageIndex:0,pageSize:100},sorting:[{id:"invoiceDate",desc:!0}]}});return r.jsxs(r.Fragment,{children:[r.jsxs(Ln,{children:[r.jsx(Bn,{children:i.getHeaderGroups().map(c=>r.jsx(Ve,{children:c.headers.map(l=>r.jsx(Pe,{className:"text-center",colSpan:l.colSpan,children:l.isPlaceholder?null:Ht(l.column.columnDef.header,l.getContext())},l.id))},c.id))}),r.jsx(Vn,{children:i.getRowModel().rows?.length?i.getRowModel().rows.map(c=>r.jsx(Ve,{"data-state":c.getIsSelected()&&"selected",className:Tf(c.original.matchingStatus),children:c.getVisibleCells().map(l=>r.jsx(De,{children:Ht(l.column.columnDef.cell,l.getContext())},l.id))},c.id)):r.jsx(Ve,{children:r.jsx(De,{colSpan:ps.length,className:"h-24 text-center",children:"No results."})})})]}),r.jsx("div",{className:"flex items-center justify-end space-x-2 py-4",children:r.jsx(ni,{currentPageIndex:i.getState().pagination.pageIndex,totalPages:i.getPageCount(),onChange:c=>i.setPageIndex(c)})})]})},Ff=({data:e})=>{const t=L(Ks,e);return t?.errorsLedger?.validate?.errors?.length?r.jsxs(Us,{shadow:"xs",p:"md",children:[r.jsx(He,{c:"red",children:"Errors:"}),r.jsx(mr,{size:"sm",withPadding:!0,children:t.errorsLedger.validate.errors.map((n,s)=>r.jsx(mr.Item,{children:r.jsx(He,{c:"red",children:n})},s))})]}):null},kf=({transactionsProps:e,onChange:t})=>{const{transactions:n}=L(Gs,e);return r.jsx(to,{transactionsProps:n,onChange:t,enableEdit:!0})},Mf="createDeposit",Rf=()=>{const[{fetching:e},t]=Te(ri),n=p.useCallback(async s=>{const o=`Error creating new deposit in currency ${s.currency}`,a=`${Mf}-${s.currency}`;R.loading("Creating deposit",{id:a});try{const i=await t(s),c=$e(i,o,a);if(c)return R.success("Deposit created",{id:a,description:`Deposit ${c.createDeposit.id} (${c.createDeposit.currency}) created successfully`}),c.createDeposit.id}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return null},[t]);return{creating:e,createDeposit:n}},zf=({chargeId:e,onChange:t})=>{const[{data:n,fetching:s}]=Ne({query:si,variables:{chargeId:e}}),[{data:o,fetching:a}]=Ne({query:oi}),{creating:i,createDeposit:c}=Rf(),{assigning:l,assignChargeToDeposit:d}=zi(),[h,f]=p.useState(void 0),[g,x]=p.useState(!1),[u,m]=p.useState("ILS"),j=p.useMemo(()=>(o?.allDeposits??[]).filter(C=>C.isOpen),[o?.allDeposits]),v=p.useCallback(async()=>{const C=await c({currency:u});C&&(await d({chargeId:e,depositId:C}),x(!1),t?.())},[c,d,u,e,t]),b=p.useCallback(async()=>{h&&(await d({chargeId:e,depositId:h}),t?.())},[d,h,e,t]);return s||a||i||l?r.jsx(zn,{className:"h-10 w-10 animate-spin"}):n?.depositByCharge?r.jsxs("div",{children:[r.jsxs("div",{className:"text-lg font-semibold mb-4",children:['Bank Deposit "',n?.depositByCharge?.id,'" Balance:'," ",n?.depositByCharge?.currentBalance.formatted]}),r.jsx("div",{className:"mb-4",children:r.jsx("span",{className:"text-sm text-gray-500",children:n?.depositByCharge?.isOpen?"Deposit is open":"Deposit is closed"})}),r.jsx(Li,{depositId:n.depositByCharge.id})]}):r.jsxs("div",{className:"space-y-4",children:[r.jsx("div",{className:"text-sm text-gray-500",children:"No bank deposit found for this charge."}),r.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsxs(cr,{value:h,onValueChange:C=>f(C),children:[r.jsx(lr,{className:"min-w-[220px]",children:r.jsx(dr,{placeholder:j.length?"Select open deposit":"No open deposits"})}),r.jsx(ur,{children:j.map(C=>r.jsxs(fr,{value:C.id,children:[C.id," (",C.currency,")"]},C.id))})]}),r.jsx(Y,{variant:"secondary",disabled:!h||l,onClick:b,children:l?"Assigning…":"Assign"})]}),r.jsx(Y,{variant:"outline",onClick:()=>x(!0),children:"Create New Deposit"})]}),r.jsx(cn,{open:g,onOpenChange:x,children:r.jsxs(ln,{children:[r.jsx(Ds,{children:r.jsx(Cs,{children:"Create Bank Deposit"})}),r.jsx("div",{className:"space-y-4",children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(ai,{htmlFor:"deposit-currency-select",children:"Currency"}),r.jsxs(cr,{value:u,onValueChange:C=>m(C),children:[r.jsx(lr,{className:"w-40",children:r.jsx(dr,{id:"deposit-currency-select"})}),r.jsx(ur,{children:Object.entries(_t).map(([C,A])=>r.jsx(fr,{value:A,children:A},C))})]})]})}),r.jsx(ii,{children:r.jsx(Y,{variant:"secondary",disabled:i,onClick:v,children:i?"Creating…":"Create"})})]})})]})};function Lf({row:e}){const[t,n]=p.useState(["transactions","documents"]),[{data:s,fetching:o}]=Ne({query:ci,variables:{chargeId:e.original.id??""},pause:!e.original.id}),a=s?.charge.transactions,i=!!a&&a.length>0,c=s?.charge.additionalDocuments,l=!!c&&c.length>0;return r.jsxs(ro,{type:"multiple",value:t,onValueChange:n,className:"space-y-4",children:[i&&r.jsxs(_e,{value:"transactions",className:"rounded-lg border-2",children:[r.jsx("div",{className:"px-2 bg-gray-600/10 rounded-t-lg",children:r.jsx(Ie,{className:"p-2",disabled:!i,children:r.jsx("h3",{className:"font-semibold text-lg",children:"Transactions"})})}),o?r.jsx(he,{children:r.jsx("div",{className:"p-2",children:r.jsx(Jr,{})})}):r.jsx(he,{children:a&&r.jsx("div",{className:"p-2",children:r.jsx(to,{transactionsProps:a})})})]}),l&&r.jsxs(_e,{value:"documents",className:"rounded-lg border-2",children:[r.jsx("div",{className:"px-2 bg-gray-600/10 rounded-t-lg",children:r.jsx(Ie,{className:"p-2",disabled:!l,children:r.jsx("h3",{className:"font-semibold text-lg",children:"Documents"})})}),o?r.jsx(he,{children:r.jsx("div",{className:"p-2",children:r.jsx(Jr,{})})}):r.jsx(he,{children:c&&r.jsx("div",{className:"p-2",children:r.jsx(qs,{documentsProps:c})})})]})]})}const Bf=({row:e})=>{const[t,n]=p.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(Ve,{children:[e.getVisibleCells().map(s=>r.jsx(De,{children:Ht(s.column.columnDef.cell,s.getContext())},s.id)),r.jsx(De,{children:r.jsx(eo,{toggleExpansion:n,isExpanded:t})})]},e.id),t&&r.jsx(Ve,{children:r.jsx(De,{colSpan:e.getVisibleCells().length+1,children:r.jsx(Lf,{row:e})})},`${e.id}-extensions`)]})},Vf=({business:e})=>e.id?r.jsx(bt,{to:We.BUSINESSES.DETAIL(e.id),target:"_blank",rel:"noreferrer",onClick:t=>t.stopPropagation(),className:"inline-flex items-center font-semibold",children:e.name}):r.jsx("div",{}),Hf=({date:e})=>r.jsx("p",{className:"text-sm font-medium",children:e?.toLocaleDateString(void 0,{timeZone:"UTC"})}),Uf=({tags:e})=>r.jsx(dn,{items:e.map(t=>r.jsx(Bt,{children:r.jsxs("div",{children:[t.namePath&&r.jsx(He,{size:"xs",opacity:.65,children:`${t.namePath.join(" > ")} >`}),r.jsx(He,{size:"sm",children:t.name})]})},t.id))}),Kf=({taxCategory:e})=>r.jsx("p",{className:"text-sm font-medium",children:e?.name}),Gf=({type:e})=>{const{text:t,icon:n}=p.useMemo(()=>({text:kn(e),icon:Fn(e)}),[e]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{children:t}),r.jsx(Hn,{radius:"xl",size:"xl",children:n})]})},ms=[{id:"select",cell:({row:e})=>r.jsx(li,{checked:e.original.isSelected,onCheckedChange:t=>(e.original.selectCharge(t?e.original.id:null),t),"aria-label":"Select charge"}),enableSorting:!1,enableHiding:!1},{accessorKey:"confidenceScore",header:({column:e})=>r.jsx(Le,{column:e,title:"Score"}),cell:({row:e})=>{const t=e.getValue("confidenceScore");return r.jsx(iu,{value:t*100,size:"sm"})}},{accessorKey:"type",header:({column:e})=>r.jsx(Le,{column:e,title:"Type"}),cell:({row:e})=>r.jsx(Gf,{type:e.getValue("type")})},{accessorKey:"date",header:({column:e})=>r.jsx(Le,{column:e,title:"Date"}),cell:({row:e})=>r.jsx(Hf,{date:e.getValue("date")})},{accessorKey:"amountRaw",header:({column:e})=>r.jsx(Le,{column:e,title:"Amount"}),cell:({row:e})=>{const t=e.original.amountFormatted;return r.jsx("p",{className:"text-sm font-medium",children:t})}},{accessorKey:"vatAmountRaw",header:({column:e})=>r.jsx(Le,{column:e,title:"VAT"}),cell:({row:e})=>{const t=e.original.vatAmountFormatted;return r.jsx("p",{className:"text-sm font-medium",children:t})}},{accessorKey:"businessName",header:({column:e})=>r.jsx(Le,{column:e,title:"Main Business"}),cell:({row:e})=>r.jsx(Vf,{business:{id:e.original.businessId,name:e.original.businessName}})},{accessorKey:"description",header:({column:e})=>r.jsx(Le,{column:e,title:"Description"}),cell:({row:e})=>{const t=e.getValue("description");return r.jsx("p",{className:"text-sm font-medium max-w-100 whitespace-normal",children:t})}},{accessorKey:"tags",header:({column:e})=>r.jsx(Le,{column:e,title:"Tags"}),cell:({row:e})=>r.jsx(Uf,{tags:e.getValue("tags")}),enableSorting:!1},{accessorKey:"taxCategoryName",header:({column:e})=>r.jsx(Le,{column:e,title:"Tax Category"}),cell:({row:e})=>r.jsx(Kf,{taxCategory:{id:e.original.taxCategoryId,name:e.original.taxCategoryName}})}];function qf(e,t,n){const s=L(gi,e),o=s.charge.minDocumentsDate||s.charge.minEventDate||s.charge.minDebitDate||void 0;return{id:s.charge.id,confidenceScore:s.confidenceScore,type:s.charge.__typename,date:o?new Date(o):void 0,amountRaw:s.charge.totalAmount?.raw,amountFormatted:s.charge.totalAmount?.formatted,vatAmountRaw:s.charge.vat?.raw,vatAmountFormatted:s.charge.vat?.formatted,businessId:s.charge.counterparty?.id,businessName:s.charge.counterparty?.name,description:s.charge.userDescription??void 0,tags:s.charge.tags.map(a=>({id:a.id,name:a.name,namePath:a.namePath??void 0})),taxCategoryId:s.charge.taxCategory?.id,taxCategoryName:s.charge.taxCategory?.name,selectCharge:t,isSelected:s.charge.id===n}}const Wf=({originChargeId:e,chargesProps:t,onChange:n})=>{const[s,o]=p.useState([{id:"confidenceScore",desc:!0},{id:"amountRaw",desc:!0}]),[a,i]=p.useState([]),[c,l]=p.useState(null),[d,h]=p.useState([{id:e,onChange:n}]);p.useEffect(()=>{h([e,...c?[c]:[]].map(x=>({id:x,onChange:n})))},[c,n,e]);const f=p.useMemo(()=>t?.map(x=>qf(x,l,c)).sort((x,u)=>u.confidenceScore-x.confidenceScore)??[],[t,c]),g=Bs({data:f,columns:ms,getCoreRowModel:Hs(),onSortingChange:o,getSortedRowModel:Vs(),onColumnFiltersChange:i,getFilteredRowModel:di(),state:{sorting:s,columnFilters:a}});return r.jsxs("div",{className:"max-w-[90vw]",children:[r.jsxs("div",{className:"flex items-center py-4 gap-4",children:[r.jsx(tu,{selected:d,resetMerge:()=>l(null)}),r.jsxs(ui,{children:[r.jsx(fi,{asChild:!0,className:"ml-auto",children:r.jsxs(Y,{variant:"outline",children:["Columns ",r.jsx(je,{})]})}),r.jsx(pi,{align:"end",children:g.getAllColumns().filter(x=>x.getCanHide()).map(x=>r.jsx(mi,{className:"capitalize",checked:x.getIsVisible(),onCheckedChange:u=>x.toggleVisibility(!!u),children:x.id},x.id))})]})]}),r.jsx("div",{className:"overflow-hidden rounded-md border",children:r.jsxs(Ln,{children:[r.jsx(Bn,{children:g.getHeaderGroups().map(x=>r.jsxs(Ve,{children:[x.headers.map(u=>r.jsx(Pe,{colSpan:u.colSpan,children:u.isPlaceholder?null:Ht(u.column.columnDef.header,u.getContext())},u.id)),r.jsx(Pe,{})]},x.id))}),r.jsx(Vn,{children:g.getRowModel().rows?.length?g.getRowModel().rows.map(x=>r.jsx(Bf,{row:x},x.id)):r.jsx(Ve,{children:r.jsx(De,{colSpan:ms.length,className:"h-24 text-center",children:"No results."})})})]})})]})},Yf=({chargeId:e,isOpened:t,onChange:n})=>{const[{data:s,fetching:o}]=Ne({query:hi,variables:{chargeId:e},pause:!t});return r.jsxs(_e,{value:"charges-matches",children:[r.jsx(Ie,{children:"Charge Matches"}),r.jsx(he,{children:o?r.jsx(zn,{className:"h-10 w-10 animate-spin"}):r.jsx(Wf,{originChargeId:e,chargesProps:s?.findChargeMatches.matches,onChange:n})})]})},Qf=({chargeProps:e})=>{const t=L(Ws,e);if(t.__typename!=="ConversionCharge")return r.jsx(r.Fragment,{});const{eventRate:n,officialRate:s}=t;return r.jsxs(gn,{justify:"center",children:[s&&r.jsx(gn.Col,{span:"content",children:r.jsx(gr,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:r.jsxs(Bt,{position:"apart",children:[r.jsx(He,{weight:500,children:"Official Conversion Rate"}),r.jsx(In,{color:"green",variant:"light",children:`${Number(s.rate)} ${ot(s.from)} => ${ot(s.to)}`})]})})}),n&&r.jsx(gn.Col,{span:"content",children:r.jsx(gr,{shadow:"sm",padding:"xs",radius:"md",withBorder:!0,children:r.jsxs(Bt,{position:"apart",children:[r.jsx(He,{weight:500,children:"Bank Conversion Rate"}),r.jsx(In,{color:"green",variant:"light",children:`${Number(n.rate)} ${ot(n.from)} => ${ot(n.to)}`})]})})})]})},Xf=({chargeProps:e})=>{const t=L(Ys,e),n=p.useMemo(()=>t.__typename==="CreditcardBankCharge"&&t.creditCardTransactions?t.creditCardTransactions.map(s=>L(xi,s)):[],[t]);return n.length?r.jsxs(Ln,{children:[r.jsx(Bn,{children:r.jsxs(Ve,{children:[r.jsx(Pe,{children:"Event Date"}),r.jsx(Pe,{children:"Debit Date"}),r.jsx(Pe,{children:"Amount"}),r.jsx(Pe,{children:"Account"}),r.jsx(Pe,{children:"Description"}),r.jsx(Pe,{children:"Reference#"}),r.jsx(Pe,{children:"Counterparty"}),r.jsx(Pe,{children:"Charge"})]})}),r.jsx(Vn,{children:n.map(s=>{const o={...s,onUpdate:()=>{},editTransaction:()=>{},enableEdit:!1,enableChargeLink:!1};return r.jsxs(Ve,{children:[r.jsx(De,{children:r.jsx(Oi,{transaction:o})}),r.jsx(De,{children:r.jsx(Ei,{transaction:o})}),r.jsx(De,{children:r.jsx(Pi,{transaction:o})}),r.jsx(De,{children:r.jsx(Ai,{transaction:o})}),r.jsx(De,{children:r.jsx(Ni,{transaction:o})}),r.jsx(De,{children:r.jsx(Ti,{transaction:o})}),r.jsx(De,{children:r.jsx($i,{transaction:o})}),r.jsx(De,{children:r.jsx(Fi,{chargeId:s.chargeId})})]},s.id)})})]}):null},Jf=({chargeProps:e})=>{const t=L(Qs,e),n=p.useMemo(()=>t.__typename!=="FinancialCharge"?[]:Object.entries(t.exchangeRates??{}).sort((s,o)=>s[0].localeCompare(o[0])),[t]);return t.__typename!=="FinancialCharge"?r.jsx(r.Fragment,{}):r.jsx("div",{className:"flex flex-row flex-wrap gap-2 px-2",children:n.map(([s,o])=>r.jsx(yi,{className:"gap-0 py-2",children:r.jsxs(vi,{className:"flex flex-col px-2",children:[r.jsx(ji,{className:"text-xl font-semibold",children:s.toLocaleUpperCase()}),r.jsxs("div",{className:"flex items-center space-x-2",children:[r.jsxs("span",{className:"whitespace-nowrap",children:[ot(s.toLocaleUpperCase()),"1="]}),r.jsxs(Ls,{variant:"default",className:"flex gap-1 rounded-lg text-md",children:[ot(_t.Ils),o]})]})]})},s))})},Zf="deleteMiscExpense",ep=()=>{const[{fetching:e},t]=Te(bi),n=p.useCallback(async s=>{const o="Error deleting misc expense",a=`${Zf}-${s.id}`;R.loading("Deleting misc expense",{id:a});try{const i=await t(s),c=$e(i,o,a);if(c)return R.success("Success",{id:a,description:"Misc expense was deleted successfully"}),c.deleteMiscExpense}catch(i){console.error(`${o}: ${i}`),R.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteMiscExpense:n}};function tp({miscExpenseId:e,onChange:t}){const{deleteMiscExpense:n}=ep();async function s(){try{await n({id:e}),t?.()}catch(o){const a="Failed to delete misc expense";console.error(`${a}: ${o}`),R.error("Error",{description:a})}}return r.jsx(on,{onConfirm:s,title:"Are you sure you want to delete this expense?",children:r.jsx(Y,{className:"size-7.5 text-red-500",variant:"ghost",children:r.jsx(Rn,{className:"size-5"})})})}const np=({miscExpensesData:e,onChange:t})=>{const n=L(Xs,e),{miscExpenses:s}=n;return r.jsxs("table",{className:"w-full h-full",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Creditor"}),r.jsx("th",{children:"Debtor"}),r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Invoice Date"}),r.jsx("th",{children:"Value Date"}),r.jsx("th",{children:"Description"}),r.jsx("th",{children:"Actions"})]})}),r.jsx("tbody",{children:s?.map(o=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("div",{children:o.creditor?.name})}),r.jsx("td",{children:r.jsx("div",{children:o.debtor?.name})}),r.jsx("td",{children:r.jsx("div",{children:o.amount?.formatted})}),r.jsx("td",{children:r.jsx("div",{children:o.invoiceDate})}),r.jsx("td",{children:r.jsx("div",{children:o.valueDate&&tt(new Date(o.valueDate),"yyyy-MM-dd")})}),r.jsx("td",{children:r.jsx("div",{children:o.description})}),r.jsxs("td",{children:[r.jsx(ru,{onDone:t,data:o}),r.jsx(tp,{miscExpenseId:o.id,onChange:t})]})]},o?.id))})]})},rp=({salaryRecordsProps:e})=>{const t=L(Js,e);if(t.__typename!=="SalaryCharge")return r.jsx(r.Fragment,{});const{salaryRecords:n}=t;return r.jsxs("table",{className:"w-full h-full",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Employee"}),r.jsx("th",{children:"Direct Salary"}),r.jsx("th",{children:"Base Salary"}),r.jsx("th",{children:"Pension"}),r.jsx("th",{children:"Training Fund"}),r.jsx("th",{children:"Social Security"}),r.jsx("th",{children:"Tax"})]})}),r.jsx("tbody",{children:n?.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx("div",{children:s.employee?.name??"Missing"})}),r.jsx("td",{children:r.jsx("div",{children:s.directAmount.formatted})}),r.jsx("td",{children:r.jsx("div",{children:s.baseAmount?.formatted})}),r.jsxs("td",{children:[r.jsx("div",{children:s.pensionFund?.name}),r.jsxs("div",{children:["Employee: ",s.pensionEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.pensionEmployerAmount?.formatted]}),r.jsxs("div",{children:["Compensation: ",s.compensationsAmount?.formatted]})]}),r.jsxs("td",{children:[r.jsx("div",{children:s.trainingFund?.name}),r.jsxs("div",{children:["Employee: ",s.trainingFundEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.trainingFundEmployerAmount?.formatted]})]}),r.jsxs("td",{children:[r.jsxs("div",{children:["Employee: ",s.socialSecurityEmployeeAmount?.formatted]}),r.jsxs("div",{children:["Employer: ",s.socialSecurityEmployerAmount?.formatted]}),r.jsxs("div",{children:["Health: ",s.healthInsuranceAmount?.formatted]})]}),r.jsx("td",{children:r.jsx("div",{children:s.incomeTaxAmount?.formatted})})]},`${s.employee?.name}-${s.baseAmount}`))})]})};function sp({chargeID:e,onChange:t=()=>{},fetching:n}){const[s,o]=p.useState([]),[a,i]=p.useState(e),[c,{toggle:l}]=jt(!1),[d,h]=p.useState(void 0),[{data:f,fetching:g},x]=Ne({query:Ee,variables:{chargeId:a}}),u=p.useCallback(()=>{x(),t()},[x,t]);p.useEffect(()=>{f?.charge&&h(f.charge)},[f]),p.useEffect(()=>{n&&x()},[n,x]),p.useEffect(()=>{e!==a&&(i(e),x())},[e,a,x]);const m=d?.__typename,j=!!d?.metadata?.ledgerCount,v=!!d?.metadata?.transactionsCount,b=!!d?.metadata?.documentsCount,D=!!d?.metadata?.receiptsCount,C=!!d?.metadata?.invoicesCount,A=m==="SalaryCharge",E=!!d?.miscExpenses?.length,w=d?.metadata?.openDocuments,O=(d?.totalAmount?.raw??0)>0&&!D,M=!(C||D)||!v;p.useEffect(()=>{v&&o(z=>z.includes("transactions")?z:[...z,"transactions"])},[v]),p.useEffect(()=>{b&&o(z=>z.includes("documents")?z:[...z,"documents"])},[b]),p.useEffect(()=>{j&&o(z=>z.includes("ledger")?z:[...z,"ledger"])},[j]),p.useEffect(()=>{A&&o(z=>z.includes("salaries")?z:[...z,"salaries"])},[A]),p.useEffect(()=>{E&&o(z=>z.includes("miscExpenses")?z:[...z,"miscExpenses"])},[E]);const P=be(Ee,zs,d),U=be(Ee,pr,d),y=be(Ee,Zs,d),N=be(Ee,Gs,d),B=be(Ee,Xs,d),le=p.useMemo(()=>m==="ConversionCharge"&&be(Ee,Ws,d),[d,m]),ae=p.useMemo(()=>m==="FinancialCharge"&&be(Ee,Qs,d),[d,m]),ne=m==="SalaryCharge"&&be(Ee,Js,d),K=p.useMemo(()=>m==="CreditcardBankCharge"&&be(Ee,Ys,d),[d,m]);return r.jsxs("div",{className:"flex flex-col gap-5",children:[g&&r.jsx(it,{className:"flex self-center my-5",color:"dark",size:"xl",variant:"dots"}),be(Ee,Ks,d)&&r.jsx(Ff,{data:d}),d&&r.jsxs("div",{className:"flex flex-row",children:[r.jsxs(ro,{className:"w-full",type:"multiple",value:s,onValueChange:o,children:[m==="ConversionCharge"&&r.jsxs(_e,{value:"conversion",children:[r.jsx(Ie,{disabled:!v,children:"Conversion Info"}),r.jsx(he,{children:le&&r.jsx(Qf,{chargeProps:d})})]}),m==="FinancialCharge"&&r.jsxs(_e,{value:"exchangeRates",children:[r.jsx(Ie,{disabled:!ae,children:"Exchange Rates"}),r.jsx(he,{children:ae&&r.jsx(Jf,{chargeProps:d})})]}),v&&r.jsxs(_e,{value:"transactions",children:[r.jsx(Ie,{disabled:!v,children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:["Transactions",O&&r.jsx(_n,{chargeId:d.id})]})}),r.jsx(he,{children:N&&r.jsx(kf,{transactionsProps:d,onChange:u})})]}),E&&r.jsxs(_e,{value:"miscExpenses",children:[r.jsx(Ie,{disabled:!E,children:"Misc Expenses"}),r.jsx(he,{children:B&&r.jsx(np,{miscExpensesData:d,onChange:u})})]}),b&&r.jsxs(_e,{value:"documents",children:[r.jsx(Ie,{disabled:!b,children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-between w-full",children:[r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start",children:[b&&r.jsx(Ue,{content:"Documents Gallery",children:r.jsx(Y,{onClick:z=>{z.stopPropagation(),l()},variant:"outline",disabled:!P,size:"icon",className:"size-7.5 text-gray-500",children:r.jsx(Di,{className:"size-5"})})}),"Documents"]}),w&&r.jsx(_n,{chargeId:d.id})]})}),r.jsx(he,{children:U&&r.jsx(qs,{documentsProps:L(pr,d)?.additionalDocuments,onChange:u})})]}),m==="SalaryCharge"&&r.jsxs(_e,{value:"salaries",children:[r.jsx(Ie,{disabled:!A,children:"Salaries"}),r.jsx(he,{children:ne&&r.jsx(rp,{salaryRecordsProps:d})})]}),d.__typename==="BusinessTripCharge"&&r.jsxs(_e,{value:"businessTrip",children:[r.jsx(Ie,{children:"Business Trip"}),r.jsx(he,{children:r.jsx(al,{data:d.businessTrip})})]}),m==="CreditcardBankCharge"&&r.jsxs(_e,{value:"creditcard",children:[r.jsx(Ie,{children:"CreditCard Transactions"}),r.jsx(he,{children:K&&r.jsx(Xf,{chargeProps:d})})]}),j&&r.jsxs(_e,{value:"ledger",children:[r.jsx(Ie,{disabled:!j,onClick:z=>{z.stopPropagation()},children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start w-full",children:[!d.metadata?.isLedgerLocked&&r.jsx(ul,{chargeId:d.id,onChange:u,variant:"outline"}),"Ledger Records"]})}),r.jsx(he,{children:y&&r.jsx(op,{data:d})})]}),m==="BankDepositCharge"&&r.jsxs(_e,{value:"bankDeposit",children:[r.jsx(Ie,{children:"Bank Deposit"}),r.jsx(he,{children:r.jsx(zf,{chargeId:d.id})})]}),M&&r.jsx(Yf,{chargeId:d.id,onChange:u,isOpened:s.includes("charges-matches")})]}),P&&r.jsx(Me,{maw:"1/6",children:r.jsx(co,{in:c,transitionDuration:500,transitionTimingFunction:"linear",children:r.jsx(Nf,{chargeProps:d,onChange:u})})})]}),!g&&!d&&r.jsx("p",{children:"Error fetching extended information for this charge"})]})}const op=({data:e})=>{const{ledger:t}=L(Zs,e);return r.jsx($f,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},ap=({toggleMergeCharge:e,isSelectedForMerge:t,data:n,isAllOpened:s})=>{const[o,a]=p.useState(!1),[i,c]=p.useState(L(Je,n)),[{data:l,fetching:d},h]=Ne({query:Ci,pause:!0,variables:{chargeId:n.id}}),f=h;p.useEffect(()=>{const u=l?.charge;u&&c(L(Je,u))},[l]),p.useEffect(()=>{c(L(Je,n))},[n]),p.useEffect(()=>{a(s)},[s]);const g=p.useMemo(()=>!!(i.metadata?.documentsCount||i.metadata?.transactionsCount||i.metadata?.ledgerCount||i.metadata?.miscExpensesCount),[i.metadata?.documentsCount,i.metadata?.transactionsCount,i.metadata?.ledgerCount,i.metadata?.miscExpensesCount]),x=(i?.totalAmount?.raw??0)>0;return r.jsxs(r.Fragment,{children:[r.jsxs("tr",{onClick:()=>{g&&(a(u=>!u),f())},children:[r.jsx(xu,{data:i}),r.jsx(fu,{data:i}),r.jsx(lu,{data:i}),r.jsx(yu,{data:i}),be(Je,Is,i)?r.jsx(uu,{data:i}):r.jsx("td",{}),r.jsx(pu,{data:i,onChange:f}),be(Je,As,i)?r.jsx(gu,{data:i,onChange:f}):r.jsx("td",{}),be(Je,Ns,i)?r.jsx(hu,{data:i}):r.jsx("td",{}),be(Je,_s,i)?r.jsx(du,{data:i}):r.jsx("td",{}),r.jsx(mu,{data:i}),r.jsx(cu,{data:i,onChange:f}),r.jsx("td",{children:r.jsx("div",{className:"flex flex-col gap-2",children:e&&r.jsx(fl,{toggleMergeSelected:()=>e(f),mergeSelected:t})})}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(Eu,{chargeId:i.id,chargeType:i.__typename,onChange:f,isIncome:x}),g&&r.jsx(eo,{toggleExpansion:a,isExpanded:o,onClickAction:()=>f()})]})})]}),g&&o&&r.jsx("tr",{children:r.jsx("td",{colSpan:13,children:r.jsx(Us,{style:{width:"100%"},withBorder:!0,shadow:"lg",children:r.jsx(sp,{chargeID:i.id,onChange:f,fetching:d})})})})]})},xp=({toggleMergeCharge:e,mergeSelectedCharges:t,data:n,isAllOpened:s})=>{const o=n?.map(a=>L(Si,a))??[];return r.jsxs(no,{striped:!0,highlightOnHover:!0,children:[r.jsx("thead",{className:"sticky top-0 z-20",children:r.jsxs("tr",{className:"px-10 py-10 title-font tracking-wider font-medium text-gray-900 text-sm bg-gray-100 rounded-tl rounded-bl",children:[r.jsx("th",{children:"Type"}),r.jsx("th",{children:"Date"}),r.jsx("th",{children:"Amount"}),r.jsx("th",{children:"Vat"}),r.jsx("th",{children:"Counterparty"}),r.jsx("th",{children:"Description"}),r.jsx("th",{children:"Tags"}),r.jsx("th",{children:"Tax Category"}),r.jsx("th",{children:"Business Trip"}),r.jsx("th",{children:"More Info"}),r.jsx("th",{children:"Accountant Approval"}),r.jsx("th",{children:"Edit"}),r.jsx("th",{children:"More Info"})]})}),r.jsx("tbody",{children:o?.map(a=>r.jsx(ap,{data:a,toggleMergeCharge:e?i=>e(a.id,i):void 0,isSelectedForMerge:t?.has(a.id)??!1,isAllOpened:s},a.id))})]})};export{xp as C,$f as L,tu as M,Hn as T,fl as a,sp as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,ah as T,R,p as k,af as B,B as C,a8 as se,r as i,D as z,aL as H,x as _,al as $,am as q,an as J,a2 as S,ao as w,ap as I,aq as L,ar as M,as as x,bJ as te,bK as ae,bL as ne,w as O,u as Q,bM as le,aJ as ie,E as re,H as ce,c as X,V as oe,bN as de,bO as Y,bP as Z,bQ as b,bR as f,bS as W,bT as g,bU as ue,bV as me,a4 as xe,bW as he,bX as ge,a6 as G,aK as je,bY as pe,bZ as fe,b_ as Ce,b$ as ve,c0 as De,c1 as Ne,c2 as E,P as ye,c3 as Se,c4 as be,c5 as we,c6 as Ie,c7 as Le,aC as Me,b as Fe,c8 as Ae}from"./index-rI994S3C.js";import{M as Re,s as Te,a as Ve}from"./modify-contract-dialog-flMl2p_T.js";import{D as m}from"./data-table-column-header-CZ1dXiU0.js";import{F as Pe}from"./funnel-Cfb9Pxmr.js";import{u as ke,a as Be}from"./use-issue-monthly-documents-D9vQpbaZ.js";import{s as Oe}from"./subMonths-DY4HlBVa.js";import"./eye-off-Buv7eciz.js";const U=({timelessDate:s})=>e.jsx("p",{className:"text-sm font-medium",children:new Date(s).toLocaleDateString(void 0,{timeZone:"UTC"})});function Ee({id:s,name:t}){return e.jsx("div",{className:"flex flex-wrap flex-col justify-center",children:e.jsx(T,{to:R.BUSINESSES.DETAIL(s),target:"_blank",rel:"noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold",children:t})})}const K=[{id:"select",header:({table:s})=>e.jsx(k,{checked:s.getIsAllPageRowsSelected()||s.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:t=>s.toggleAllPageRowsSelected(!!t),"aria-label":"Select all"}),cell:({row:s})=>e.jsx(k,{checked:s.getIsSelected(),onCheckedChange:t=>s.toggleSelected(!!t),"aria-label":"Select row"}),enableSorting:!1,enableHiding:!1},{accessorKey:"isActive",header:({column:s})=>e.jsx(m,{column:s,title:"Is Active"}),cell:({row:s})=>s.getValue("isActive")?e.jsx(B,{variant:"default",children:"Active"}):e.jsx(B,{variant:"destructive",children:"Inactive"})},{accessorKey:"client.name",header:({column:s})=>e.jsx(m,{column:s,title:"Client"}),cell:({row:s})=>e.jsx(Ee,{id:s.original.client.id,name:s.original.client.name})},{accessorKey:"startDate",header:({column:s})=>e.jsx(m,{column:s,title:"Start"}),cell:({row:s})=>e.jsx(U,{timelessDate:s.getValue("startDate")})},{accessorKey:"endDate",header:({column:s})=>e.jsx(m,{column:s,title:"End"}),cell:({row:s})=>e.jsx(U,{timelessDate:s.getValue("endDate")})},{accessorKey:"purchaseOrder",header:({column:s})=>e.jsx(m,{column:s,title:"Purchase Order"}),cell:({row:s})=>e.jsxs("div",{className:"flex flex-row gap-1 items-center",children:[s.original.msCloud&&e.jsx(T,{to:s.original.msCloud,target:"_blank",rel:"noreferrer",className:"size-8",children:e.jsx(C,{variant:"link",size:"sm",children:e.jsx(se,{className:"size-4"})})}),e.jsx("span",{className:"text-sm font-medium",children:s.getValue("purchaseOrder")})]})},{accessorKey:"product",header:({column:s})=>e.jsx(m,{column:s,title:"Product"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("product")})},{accessorKey:"plan",header:({column:s})=>e.jsx(m,{column:s,title:"Subscription Plan"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("plan")})},{accessorKey:"billingCycle",header:({column:s})=>e.jsx(m,{column:s,title:"Billing Cycle"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("billingCycle")})},{accessorKey:"amount.raw",header:({column:s})=>e.jsx(m,{column:s,title:"Amount"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.original.amount.formatted})},{accessorKey:"operationsLimit",header:({column:s})=>e.jsx(m,{column:s,title:"Operations Limit"}),cell:({row:s})=>{const t=s.getValue("operationsLimit");return t?e.jsx("p",{className:"text-sm font-medium",children:t.toString()}):null}},{accessorKey:"edit",header:"",cell:({row:s})=>e.jsx(Re,{clientId:s.original.client.id,contractId:s.original.id}),enableSorting:!1}];function Ue({table:s}){const[t,r]=i.useState(!1);return e.jsxs(z,{open:t,onOpenChange:r,children:[e.jsx(H,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"outline",children:e.jsx(Pe,{className:"size-4"})})}),e.jsxs(_,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs($,{children:[e.jsx(q,{children:"Filter Contracts"}),e.jsx(J,{children:"Filter contracts based on various criteria"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Product Type"}),e.jsxs(w,{onValueChange:a=>s.getColumn("product")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("product")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(te).map(a=>e.jsx(x,{value:a,children:a},a))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Billing Cycle"}),e.jsxs(w,{onValueChange:a=>s.getColumn("billingCycle")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("billingCycle")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(ae).map(a=>e.jsx(x,{value:a,children:Te(a)},a))]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Subscription Plan"}),e.jsxs(w,{onValueChange:a=>s.getColumn("plan")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("plan")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(ne).map(a=>e.jsx(x,{value:a,children:Ve(a)},a))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Is Active"}),e.jsxs(w,{onValueChange:a=>s.getColumn("isActive")?.setFilterValue(a==="NULL"?void 0:a==="active"),value:Ke(s.getColumn("isActive")?.getFilterValue()),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),e.jsx(x,{value:"active",children:"Active"}),e.jsx(x,{value:"inactive",children:"Inactive"})]})]})]})]})]})]})]})}function Ke(s){return s===void 0?"NULL":s?"active":"inactive"}const ze=({contractIds:s})=>{const[t,r]=i.useState(!1),[a,v]=i.useState(O(Oe(new Date,1),"yyyy-MM-dd")),[h,D]=i.useState([]),{issueDocuments:j}=ke(),[{data:N,fetching:y},c]=Q({query:le,variables:{issueMonth:a,contractIds:s},pause:!t});i.useEffect(()=>{N?.periodicalDocumentDraftsByContracts&&D(N.periodicalDocumentDraftsByContracts.map(u=>ie(G(je,u))))},[N,D]),i.useEffect(()=>{t&&c()},[t,c]);const n=re({values:{drafts:h}}),l=i.useCallback(async u=>{await j({generateDocumentsInfo:u.drafts}),r(!1)},[j]),{fields:d,remove:F,update:ee}=ce({control:n.control,name:"drafts"}),V=n.watch("drafts"),P=i.useMemo(()=>d.map((u,o)=>({...u,...V[o],id:u.id})),[d,V]);return e.jsxs(z,{open:t,onOpenChange:r,children:[e.jsx(H,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"outline",disabled:s.length===0,children:"Issue Documents"})}),e.jsxs(_,{className:"min-w-[90vw] w-full max-h-[90vh] overflow-y-auto",children:[e.jsxs($,{children:[e.jsx(q,{children:"Issue Documents for Contracts"}),e.jsx(J,{children:"Review and issue monthly documents for the selected contracts"})]}),y?e.jsx(X,{}):e.jsx(oe,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(l),className:"min-w-5xl w-full",children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(S,{children:"Issue Month:"}),e.jsx(de,{value:new Date(a),onChange:u=>{const o=new Date(u.getFullYear(),u.getMonth(),15);v(O(o,"yyyy-MM-dd"))},popoverProps:{withinPortal:!1}})]}),e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(b,{children:[e.jsx(f,{children:"Name"}),e.jsx(f,{children:"Document"}),e.jsx(f,{children:"Amount"}),e.jsx(f,{children:"Remark"}),e.jsx(f,{children:"Recipients"}),e.jsx(f,{})]})}),e.jsx(W,{children:P.map(({id:u,...o},A)=>e.jsxs(b,{children:[e.jsx(g,{children:e.jsx(T,{to:o.client?.id?R.BUSINESSES.DETAIL(o.client?.id):R.BUSINESSES.ALL,target:"_blank",rel:"noreferrer",onClick:p=>p.stopPropagation(),className:"inline-flex items-center font-semibold",children:o.client?.name})}),e.jsx(g,{children:o.type}),e.jsxs(g,{children:[o.income?.[0]?.price," ",o.income?.[0]?.currency]}),e.jsx(g,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:o.remarks})}),e.jsx(g,{children:e.jsx("div",{className:"flex flex-col",children:o.client?.emails?.map(p=>e.jsx("span",{className:"text-sm text-gray-500",children:p},p))})}),e.jsx(g,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,type:"button",children:e.jsx(C,{className:"size-7.5",variant:"secondary",onClick:()=>F(A),children:e.jsx(xe,{size:16})})}),e.jsx(he,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(Be,{draft:o,onApprove:p=>{n.setValue(`drafts.${A}`,p,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),ee(A,{...p})}})]})})]},u))})]}),e.jsx("div",{className:"flex justify-between items-center mt-4",children:e.jsx(ge,{onConfirm:n.handleSubmit(l),title:`Are you sure you want to issue ${P.length} documents?`,children:e.jsx(C,{children:"Issue"})})})]})})]})]})};function He(s){const t=G(Le,s);return{id:t.id,isActive:t.isActive,client:{id:t.client.id,name:t.client.originalBusiness.name},purchaseOrder:t.purchaseOrders[0],startDate:t.startDate,endDate:t.endDate,amount:{raw:t.amount.raw,formatted:t.amount.formatted},billingCycle:t.billingCycle,product:t.product??void 0,plan:t.plan??void 0,operationsLimit:t.operationsLimit,msCloud:t.msCloud?.toString()??void 0}}const _e=({data:s})=>{const[t,r]=i.useState([{id:"endDate",desc:!0},{id:"amount.raw",desc:!0}]),[a,v]=i.useState({}),[h,D]=i.useState([]),[j,N]=i.useState([]),y=i.useMemo(()=>s.map(n=>He(n)),[s]),c=pe({data:y,columns:K,getCoreRowModel:Ie(),onSortingChange:r,getSortedRowModel:we(),getPaginationRowModel:be(),onRowSelectionChange:v,onColumnFiltersChange:D,getFilteredRowModel:Se(),state:{sorting:t,rowSelection:a,columnFilters:h},initialState:{pagination:{pageIndex:0,pageSize:50}}});return i.useEffect(()=>{const n=Object.entries(a).filter(([,d])=>!!d).map(([d])=>Number(d)),l=Array.from(new Set(y.filter((d,F)=>n.includes(F)).map(d=>d.id)));(j.length!==l.length||!j.every(d=>l.includes(d)))&&N(l)},[a,y,j,h]),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsx(Ue,{table:c}),e.jsxs(fe,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(C,{variant:"outline",children:["Columns ",e.jsx(ve,{})]})}),e.jsx(De,{align:"end",children:c.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(Ne,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:l=>n.toggleVisibility(!!l),children:n.id},n.id))})]}),e.jsx("div",{className:"ml-auto",children:e.jsx(ze,{contractIds:j,className:"ml-auto"})})]}),e.jsx("div",{className:"overflow-hidden rounded-md border",children:e.jsxs(Y,{children:[e.jsx(Z,{children:c.getHeaderGroups().map(n=>e.jsx(b,{children:n.headers.map(l=>e.jsx(f,{colSpan:l.colSpan,children:l.isPlaceholder?null:E(l.column.columnDef.header,l.getContext())},l.id))},n.id))}),e.jsx(W,{children:c.getRowModel().rows?.length?c.getRowModel().rows.map(n=>e.jsx(b,{children:n.getVisibleCells().map(l=>e.jsx(g,{children:E(l.column.columnDef.cell,l.getContext())},l.id))},n.id)):e.jsx(b,{children:e.jsx(g,{colSpan:K.length,className:"h-24 text-center",children:"No results."})})})]})}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 py-4",children:[e.jsxs("div",{className:"text-muted-foreground flex-1 text-sm",children:[c.getFilteredSelectedRowModel().rows.length," of"," ",c.getFilteredRowModel().rows.length," row(s) selected."]}),e.jsx(ye,{className:"w-fit mx-0",currentPageIndex:c.getState().pagination.pageIndex,totalPages:c.getPageCount(),onChange:n=>c.setPageIndex(n)})]})]})},We=()=>{const{userContext:s}=i.useContext(Me),t=s?.context.adminBusinessId;let r;try{r=Fe()}catch{}const[{data:a,fetching:v}]=Q({query:Ae,pause:!t||!!r,variables:{adminId:t??""}}),h=r||a;return!r&&v&&!h?.contractsByAdmin?e.jsx(X,{}):!t||!h?.contractsByAdmin?e.jsx("div",{children:"Contracts not found"}):e.jsx(_e,{data:h.contractsByAdmin})};export{We as ContractsScreen};
|
|
1
|
+
import{j as e,ah as T,R,p as k,af as B,B as C,a8 as se,r as i,D as z,aL as H,x as _,al as $,am as q,an as J,a2 as S,ao as w,ap as I,aq as L,ar as M,as as x,bJ as te,bK as ae,bL as ne,w as O,u as Q,bM as le,aJ as ie,E as re,H as ce,c as X,V as oe,bN as de,bO as Y,bP as Z,bQ as b,bR as f,bS as W,bT as g,bU as ue,bV as me,a4 as xe,bW as he,bX as ge,a6 as G,aK as je,bY as pe,bZ as fe,b_ as Ce,b$ as ve,c0 as De,c1 as Ne,c2 as E,P as ye,c3 as Se,c4 as be,c5 as we,c6 as Ie,c7 as Le,aC as Me,b as Fe,c8 as Ae}from"./index-D1_HHRLX.js";import{M as Re,s as Te,a as Ve}from"./modify-contract-dialog-BBPR_IL8.js";import{D as m}from"./data-table-column-header--gzXkv5r.js";import{F as Pe}from"./funnel-0IvwyZBf.js";import{u as ke,a as Be}from"./use-issue-monthly-documents-CdxtNiuP.js";import{s as Oe}from"./subMonths-nC9-M0qS.js";import"./eye-off-DWYC0Eax.js";const U=({timelessDate:s})=>e.jsx("p",{className:"text-sm font-medium",children:new Date(s).toLocaleDateString(void 0,{timeZone:"UTC"})});function Ee({id:s,name:t}){return e.jsx("div",{className:"flex flex-wrap flex-col justify-center",children:e.jsx(T,{to:R.BUSINESSES.DETAIL(s),target:"_blank",rel:"noreferrer",onClick:r=>r.stopPropagation(),className:"inline-flex items-center font-semibold",children:t})})}const K=[{id:"select",header:({table:s})=>e.jsx(k,{checked:s.getIsAllPageRowsSelected()||s.getIsSomePageRowsSelected()&&"indeterminate",onCheckedChange:t=>s.toggleAllPageRowsSelected(!!t),"aria-label":"Select all"}),cell:({row:s})=>e.jsx(k,{checked:s.getIsSelected(),onCheckedChange:t=>s.toggleSelected(!!t),"aria-label":"Select row"}),enableSorting:!1,enableHiding:!1},{accessorKey:"isActive",header:({column:s})=>e.jsx(m,{column:s,title:"Is Active"}),cell:({row:s})=>s.getValue("isActive")?e.jsx(B,{variant:"default",children:"Active"}):e.jsx(B,{variant:"destructive",children:"Inactive"})},{accessorKey:"client.name",header:({column:s})=>e.jsx(m,{column:s,title:"Client"}),cell:({row:s})=>e.jsx(Ee,{id:s.original.client.id,name:s.original.client.name})},{accessorKey:"startDate",header:({column:s})=>e.jsx(m,{column:s,title:"Start"}),cell:({row:s})=>e.jsx(U,{timelessDate:s.getValue("startDate")})},{accessorKey:"endDate",header:({column:s})=>e.jsx(m,{column:s,title:"End"}),cell:({row:s})=>e.jsx(U,{timelessDate:s.getValue("endDate")})},{accessorKey:"purchaseOrder",header:({column:s})=>e.jsx(m,{column:s,title:"Purchase Order"}),cell:({row:s})=>e.jsxs("div",{className:"flex flex-row gap-1 items-center",children:[s.original.msCloud&&e.jsx(T,{to:s.original.msCloud,target:"_blank",rel:"noreferrer",className:"size-8",children:e.jsx(C,{variant:"link",size:"sm",children:e.jsx(se,{className:"size-4"})})}),e.jsx("span",{className:"text-sm font-medium",children:s.getValue("purchaseOrder")})]})},{accessorKey:"product",header:({column:s})=>e.jsx(m,{column:s,title:"Product"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("product")})},{accessorKey:"plan",header:({column:s})=>e.jsx(m,{column:s,title:"Subscription Plan"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("plan")})},{accessorKey:"billingCycle",header:({column:s})=>e.jsx(m,{column:s,title:"Billing Cycle"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.getValue("billingCycle")})},{accessorKey:"amount.raw",header:({column:s})=>e.jsx(m,{column:s,title:"Amount"}),cell:({row:s})=>e.jsx("p",{className:"text-sm font-medium",children:s.original.amount.formatted})},{accessorKey:"operationsLimit",header:({column:s})=>e.jsx(m,{column:s,title:"Operations Limit"}),cell:({row:s})=>{const t=s.getValue("operationsLimit");return t?e.jsx("p",{className:"text-sm font-medium",children:t.toString()}):null}},{accessorKey:"edit",header:"",cell:({row:s})=>e.jsx(Re,{clientId:s.original.client.id,contractId:s.original.id}),enableSorting:!1}];function Ue({table:s}){const[t,r]=i.useState(!1);return e.jsxs(z,{open:t,onOpenChange:r,children:[e.jsx(H,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"outline",children:e.jsx(Pe,{className:"size-4"})})}),e.jsxs(_,{className:"max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsxs($,{children:[e.jsx(q,{children:"Filter Contracts"}),e.jsx(J,{children:"Filter contracts based on various criteria"})]}),e.jsxs("div",{className:"grid gap-4 py-4",children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Product Type"}),e.jsxs(w,{onValueChange:a=>s.getColumn("product")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("product")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(te).map(a=>e.jsx(x,{value:a,children:a},a))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Billing Cycle"}),e.jsxs(w,{onValueChange:a=>s.getColumn("billingCycle")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("billingCycle")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(ae).map(a=>e.jsx(x,{value:a,children:Te(a)},a))]})]})]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Subscription Plan"}),e.jsxs(w,{onValueChange:a=>s.getColumn("plan")?.setFilterValue(a==="NULL"?void 0:a),value:s.getColumn("plan")?.getFilterValue(),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),Object.values(ne).map(a=>e.jsx(x,{value:a,children:Ve(a)},a))]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(S,{children:"Is Active"}),e.jsxs(w,{onValueChange:a=>s.getColumn("isActive")?.setFilterValue(a==="NULL"?void 0:a==="active"),value:Ke(s.getColumn("isActive")?.getFilterValue()),children:[e.jsx(I,{className:"w-full",children:e.jsx(L,{})}),e.jsxs(M,{children:[e.jsx(x,{value:"NULL",className:"font-light text-xs",children:"(None)"}),e.jsx(x,{value:"active",children:"Active"}),e.jsx(x,{value:"inactive",children:"Inactive"})]})]})]})]})]})]})]})}function Ke(s){return s===void 0?"NULL":s?"active":"inactive"}const ze=({contractIds:s})=>{const[t,r]=i.useState(!1),[a,v]=i.useState(O(Oe(new Date,1),"yyyy-MM-dd")),[h,D]=i.useState([]),{issueDocuments:j}=ke(),[{data:N,fetching:y},c]=Q({query:le,variables:{issueMonth:a,contractIds:s},pause:!t});i.useEffect(()=>{N?.periodicalDocumentDraftsByContracts&&D(N.periodicalDocumentDraftsByContracts.map(u=>ie(G(je,u))))},[N,D]),i.useEffect(()=>{t&&c()},[t,c]);const n=re({values:{drafts:h}}),l=i.useCallback(async u=>{await j({generateDocumentsInfo:u.drafts}),r(!1)},[j]),{fields:d,remove:F,update:ee}=ce({control:n.control,name:"drafts"}),V=n.watch("drafts"),P=i.useMemo(()=>d.map((u,o)=>({...u,...V[o],id:u.id})),[d,V]);return e.jsxs(z,{open:t,onOpenChange:r,children:[e.jsx(H,{asChild:!0,children:e.jsx(C,{size:"sm",variant:"outline",disabled:s.length===0,children:"Issue Documents"})}),e.jsxs(_,{className:"min-w-[90vw] w-full max-h-[90vh] overflow-y-auto",children:[e.jsxs($,{children:[e.jsx(q,{children:"Issue Documents for Contracts"}),e.jsx(J,{children:"Review and issue monthly documents for the selected contracts"})]}),y?e.jsx(X,{}):e.jsx(oe,{...n,children:e.jsxs("form",{onSubmit:n.handleSubmit(l),className:"min-w-5xl w-full",children:[e.jsxs("div",{className:"flex gap-2 items-center mb-4",children:[e.jsx(S,{children:"Issue Month:"}),e.jsx(de,{value:new Date(a),onChange:u=>{const o=new Date(u.getFullYear(),u.getMonth(),15);v(O(o,"yyyy-MM-dd"))},popoverProps:{withinPortal:!1}})]}),e.jsxs(Y,{children:[e.jsx(Z,{children:e.jsxs(b,{children:[e.jsx(f,{children:"Name"}),e.jsx(f,{children:"Document"}),e.jsx(f,{children:"Amount"}),e.jsx(f,{children:"Remark"}),e.jsx(f,{children:"Recipients"}),e.jsx(f,{})]})}),e.jsx(W,{children:P.map(({id:u,...o},A)=>e.jsxs(b,{children:[e.jsx(g,{children:e.jsx(T,{to:o.client?.id?R.BUSINESSES.DETAIL(o.client?.id):R.BUSINESSES.ALL,target:"_blank",rel:"noreferrer",onClick:p=>p.stopPropagation(),className:"inline-flex items-center font-semibold",children:o.client?.name})}),e.jsx(g,{children:o.type}),e.jsxs(g,{children:[o.income?.[0]?.price," ",o.income?.[0]?.currency]}),e.jsx(g,{children:e.jsx("span",{className:"text-sm text-gray-500 whitespace-normal max-w-50",children:o.remarks})}),e.jsx(g,{children:e.jsx("div",{className:"flex flex-col",children:o.client?.emails?.map(p=>e.jsx("span",{className:"text-sm text-gray-500",children:p},p))})}),e.jsx(g,{children:e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs(ue,{children:[e.jsx(me,{asChild:!0,type:"button",children:e.jsx(C,{className:"size-7.5",variant:"secondary",onClick:()=>F(A),children:e.jsx(xe,{size:16})})}),e.jsx(he,{children:e.jsx("p",{children:"Remove document"})})]}),e.jsx(Be,{draft:o,onApprove:p=>{n.setValue(`drafts.${A}`,p,{shouldDirty:!0,shouldTouch:!0,shouldValidate:!0}),ee(A,{...p})}})]})})]},u))})]}),e.jsx("div",{className:"flex justify-between items-center mt-4",children:e.jsx(ge,{onConfirm:n.handleSubmit(l),title:`Are you sure you want to issue ${P.length} documents?`,children:e.jsx(C,{children:"Issue"})})})]})})]})]})};function He(s){const t=G(Le,s);return{id:t.id,isActive:t.isActive,client:{id:t.client.id,name:t.client.originalBusiness.name},purchaseOrder:t.purchaseOrders[0],startDate:t.startDate,endDate:t.endDate,amount:{raw:t.amount.raw,formatted:t.amount.formatted},billingCycle:t.billingCycle,product:t.product??void 0,plan:t.plan??void 0,operationsLimit:t.operationsLimit,msCloud:t.msCloud?.toString()??void 0}}const _e=({data:s})=>{const[t,r]=i.useState([{id:"endDate",desc:!0},{id:"amount.raw",desc:!0}]),[a,v]=i.useState({}),[h,D]=i.useState([]),[j,N]=i.useState([]),y=i.useMemo(()=>s.map(n=>He(n)),[s]),c=pe({data:y,columns:K,getCoreRowModel:Ie(),onSortingChange:r,getSortedRowModel:we(),getPaginationRowModel:be(),onRowSelectionChange:v,onColumnFiltersChange:D,getFilteredRowModel:Se(),state:{sorting:t,rowSelection:a,columnFilters:h},initialState:{pagination:{pageIndex:0,pageSize:50}}});return i.useEffect(()=>{const n=Object.entries(a).filter(([,d])=>!!d).map(([d])=>Number(d)),l=Array.from(new Set(y.filter((d,F)=>n.includes(F)).map(d=>d.id)));(j.length!==l.length||!j.every(d=>l.includes(d)))&&N(l)},[a,y,j,h]),e.jsxs("div",{className:"w-full",children:[e.jsxs("div",{className:"flex items-center py-4 gap-4",children:[e.jsx(Ue,{table:c}),e.jsxs(fe,{children:[e.jsx(Ce,{asChild:!0,children:e.jsxs(C,{variant:"outline",children:["Columns ",e.jsx(ve,{})]})}),e.jsx(De,{align:"end",children:c.getAllColumns().filter(n=>n.getCanHide()).map(n=>e.jsx(Ne,{className:"capitalize",checked:n.getIsVisible(),onCheckedChange:l=>n.toggleVisibility(!!l),children:n.id},n.id))})]}),e.jsx("div",{className:"ml-auto",children:e.jsx(ze,{contractIds:j,className:"ml-auto"})})]}),e.jsx("div",{className:"overflow-hidden rounded-md border",children:e.jsxs(Y,{children:[e.jsx(Z,{children:c.getHeaderGroups().map(n=>e.jsx(b,{children:n.headers.map(l=>e.jsx(f,{colSpan:l.colSpan,children:l.isPlaceholder?null:E(l.column.columnDef.header,l.getContext())},l.id))},n.id))}),e.jsx(W,{children:c.getRowModel().rows?.length?c.getRowModel().rows.map(n=>e.jsx(b,{children:n.getVisibleCells().map(l=>e.jsx(g,{children:E(l.column.columnDef.cell,l.getContext())},l.id))},n.id)):e.jsx(b,{children:e.jsx(g,{colSpan:K.length,className:"h-24 text-center",children:"No results."})})})]})}),e.jsxs("div",{className:"flex items-center justify-end space-x-2 py-4",children:[e.jsxs("div",{className:"text-muted-foreground flex-1 text-sm",children:[c.getFilteredSelectedRowModel().rows.length," of"," ",c.getFilteredRowModel().rows.length," row(s) selected."]}),e.jsx(ye,{className:"w-fit mx-0",currentPageIndex:c.getState().pagination.pageIndex,totalPages:c.getPageCount(),onChange:n=>c.setPageIndex(n)})]})]})},We=()=>{const{userContext:s}=i.useContext(Me),t=s?.context.adminBusinessId;let r;try{r=Fe()}catch{}const[{data:a,fetching:v}]=Q({query:Ae,pause:!t||!!r,variables:{adminId:t??""}}),h=r||a;return!r&&v&&!h?.contractsByAdmin?e.jsx(X,{}):!t||!h?.contractsByAdmin?e.jsx("div",{children:"Contracts not found"}):e.jsx(_e,{data:h.contractsByAdmin})};export{We as ContractsScreen};
|
package/dist/assets/{data-table-column-header-CZ1dXiU0.js → data-table-column-header--gzXkv5r.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as o,j as e,m as a,bZ as c,b_ as h,B as p,c0 as x,dU as n,dT as l}from"./index-
|
|
1
|
+
import{v as o,j as e,m as a,bZ as c,b_ as h,B as p,c0 as x,dU as n,dT as l}from"./index-D1_HHRLX.js";import{E as g}from"./eye-off-DWYC0Eax.js";const j=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],d=o("arrow-down",j);const w=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],i=o("arrow-up",w);const m=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],u=o("chevrons-up-down",m);function k({column:s,title:r,className:t}){return s.getCanSort()?e.jsx("div",{className:a("flex items-center gap-2",t),children:e.jsxs(c,{children:[e.jsx(h,{asChild:!0,children:e.jsxs(p,{variant:"ghost",size:"sm",className:"data-[state=open]:bg-accent -ml-3 h-8",children:[e.jsx("span",{children:r}),s.getIsSorted()==="desc"?e.jsx(d,{}):s.getIsSorted()==="asc"?e.jsx(i,{}):e.jsx(u,{})]})}),e.jsxs(x,{align:"start",children:[e.jsxs(n,{onClick:()=>s.toggleSorting(!1),children:[e.jsx(i,{}),"Asc"]}),e.jsxs(n,{onClick:()=>s.toggleSorting(!0),children:[e.jsx(d,{}),"Desc"]}),e.jsx(l,{}),e.jsxs(n,{onClick:()=>s.toggleVisibility(!1),children:[e.jsx(g,{}),"Hide"]})]})]})}):e.jsx("div",{className:a(t),children:r})}export{k as D};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as t,j as e,ao as i,ap as c,aq as o,ar as l,as as r,B as n,gX as x,gh as d}from"./index-
|
|
1
|
+
import{v as t,j as e,ao as i,ap as c,aq as o,ar as l,as as r,B as n,gX as x,gh as d}from"./index-D1_HHRLX.js";const g=[["path",{d:"m11 17-5-5 5-5",key:"13zhaf"}],["path",{d:"m18 17-5-5 5-5",key:"h8a8et"}]],h=t("chevrons-left",g);const p=[["path",{d:"m6 17 5-5-5-5",key:"xnjwq"}],["path",{d:"m13 17 5-5-5-5",key:"17xmmf"}]],m=t("chevrons-right",p);function u({table:s}){return e.jsxs("div",{className:"flex items-center space-x-6 lg:space-x-8",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Rows per page"}),e.jsxs(i,{value:String(s.getState().pagination.pageSize),onValueChange:a=>{s.setPageSize(Number(a))},children:[e.jsx(c,{className:"h-8 w-[70px]",children:e.jsx(o,{placeholder:s.getState().pagination.pageSize})}),e.jsx(l,{side:"top",children:[10,20,30,40,50,100].map(a=>e.jsx(r,{value:String(a),children:a},a))})]})]}),e.jsxs("div",{className:"flex w-[100px] items-center justify-center text-sm font-medium",children:["Page ",s.getState().pagination.pageIndex+1," of ",s.getPageCount()]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsxs(n,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(0),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"Go to first page"}),e.jsx(h,{})]}),e.jsxs(n,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.previousPage(),disabled:!s.getCanPreviousPage(),children:[e.jsx("span",{className:"sr-only",children:"Go to previous page"}),e.jsx(x,{})]}),e.jsxs(n,{variant:"outline",className:"h-8 w-8 p-0",onClick:()=>s.nextPage(),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"Go to next page"}),e.jsx(d,{})]}),e.jsxs(n,{variant:"outline",className:"hidden h-8 w-8 p-0 lg:flex",onClick:()=>s.setPageIndex(s.getPageCount()-1),disabled:!s.getCanNextPage(),children:[e.jsx("span",{className:"sr-only",children:"Go to last page"}),e.jsx(m,{})]})]})]})}export{u as D};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as E,j as t,w as K,r as l,af as N,B as p,dI as y,b$ as D,g as U,ic as q,t as b,i as H,u as $,fE as z,D as V,aL as _,x as G,al as P,am as Q,a2 as W,ao as J,ap as Y,aq as X,ar as Z,as as ee,au as te,aC as se,id as ae,a6 as ne,ay as x,bY as re,c5 as oe,c6 as ce,L as ie,bO as le,bP as de,bQ as T,bR as ue,c2 as A,bS as ge,bT as F,ie as me}from"./index-
|
|
1
|
+
import{v as E,j as t,w as K,r as l,af as N,B as p,dI as y,b$ as D,g as U,ic as q,t as b,i as H,u as $,fE as z,D as V,aL as _,x as G,al as P,am as Q,a2 as W,ao as J,ap as Y,aq as X,ar as Z,as as ee,au as te,aC as se,id as ae,a6 as ne,ay as x,bY as re,c5 as oe,c6 as ce,L as ie,bO as le,bP as de,bQ as T,bR as ue,c2 as A,bS as ge,bT as F,ie as me}from"./index-D1_HHRLX.js";const he=[["path",{d:"M12 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5",key:"x6cv4u"}],["path",{d:"m16 19 3 3 3-3",key:"1ibux0"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M6 12h.01",key:"c2rlol"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],R=E("banknote-arrow-down",he);const xe=[["path",{d:"M12 18H4a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5",key:"x6cv4u"}],["path",{d:"M18 12h.01",key:"yjnet6"}],["path",{d:"M19 22v-6",key:"qhmiwi"}],["path",{d:"m22 19-3-3-3 3",key:"rn6bg2"}],["path",{d:"M6 12h.01",key:"c2rlol"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]],fe=E("banknote-arrow-up",xe);function pe({transaction:e}){return t.jsx("div",{className:"flex flex-col justify-center",children:e.eventDate?K(new Date(e.eventDate),"dd/MM/yyyy"):"-"})}function je({transaction:e}){const{isInterest:a,amount:n}=e,r=l.useMemo(()=>Number(n.raw)<0,[n.raw]);return t.jsx("div",{className:"flex items-center gap-2",children:a?t.jsxs(t.Fragment,{children:[t.jsx(R,{className:"size-4 text-red-600"}),t.jsx(N,{variant:"outline",className:"bg-red-50 text-red-700",children:"Interest"})]}):r?t.jsxs(t.Fragment,{children:[t.jsx(fe,{className:"size-4 text-green-600"}),t.jsx(N,{variant:"outline",className:"bg-green-50 text-green-700",children:"Deposit"})]}):t.jsxs(t.Fragment,{children:[t.jsx(R,{className:"size-4 text-red-600"}),t.jsx(N,{variant:"outline",className:"bg-red-50 text-red-700",children:"Withdrawal"})]})})}function ye({transaction:e}){const n=Number(e.amount.raw)<0?"text-green-700":"text-red-500";return t.jsx("div",{className:`flex flex-col justify-center font-mono ${n}`,children:e.amount.formatted})}function De({transaction:e}){const a=l.useMemo(()=>{const{currency:n}=e.amount;return new Intl.NumberFormat("en-US",{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e.cumulativeBalance)},[e.cumulativeBalance,e.amount]);return t.jsx("div",{className:"flex flex-col justify-center font-mono font-semibold",children:a})}function Ce({transaction:e}){const a=l.useMemo(()=>{const{currency:n}=e.amount;return new Intl.NumberFormat("en-US",{style:"currency",currency:n,minimumFractionDigits:2,maximumFractionDigits:2}).format(e.totalInterest)},[e.totalInterest,e.amount]);return t.jsx("div",{className:"flex flex-col justify-center font-mono font-semibold",children:a})}function ve({transaction:e}){const a=l.useMemo(()=>new Intl.NumberFormat("en-US",{style:"currency",currency:e.localCurrency,minimumFractionDigits:2,maximumFractionDigits:2}).format(e.localAmount),[e.localAmount,e.localCurrency]);return t.jsx("div",{className:"flex flex-col justify-center font-mono text-muted-foreground",children:a})}function Ie({transaction:e}){const a=l.useMemo(()=>new Intl.NumberFormat("en-US",{style:"currency",currency:e.localCurrency,minimumFractionDigits:2,maximumFractionDigits:2}).format(e.localCumulativeBalance),[e.localCumulativeBalance,e.localCurrency]);return t.jsx("div",{className:"flex flex-col justify-center font-mono font-semibold text-muted-foreground",children:a})}const L=[{id:"date",accessorKey:"eventDate",sortingFn:e=>e.original.eventDate?new Date(e.original.eventDate).getTime():0,header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Date",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(pe,{transaction:e.original})},{id:"indicator",accessorKey:"amount.raw",header:"Type",cell:({row:e})=>t.jsx(je,{transaction:e.original})},{id:"amount",accessorKey:"amount.raw",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Origin Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(ye,{transaction:e.original})},{id:"cumulativeBalance",accessorKey:"cumulativeBalance",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Origin Balance",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(De,{transaction:e.original})},{id:"totalInterest",accessorKey:"totalInterest",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Interest",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(Ce,{transaction:e.original})},{id:"localAmount",accessorKey:"localAmount",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Local Amount",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(ve,{transaction:e.original})},{id:"localCumulativeBalance",accessorKey:"localCumulativeBalance",header:({column:e})=>t.jsxs(p,{variant:"ghost",onClick:()=>e.toggleSorting(e.getIsSorted()==="asc"),children:["Local Balance",e.getIsSorted()&&(e.getIsSorted()==="asc"?t.jsx(y,{className:"ml-2 h-4 w-4"}):t.jsx(D,{className:"ml-2 h-4 w-4"}))]}),cell:({row:e})=>t.jsx(Ie,{transaction:e.original})}],we="assignChargeToDeposit",Se=()=>{const[{fetching:e},a]=U(q),n=l.useCallback(async r=>{const h=`Error assigning charge ${r.chargeId} to deposit ${r.depositId}`,o=`${we}-${r.chargeId}`;b.loading("Assigning to deposit",{id:o});try{const c=await a(r),u=H(c,h,o);u&&b.success("Success",{id:o,description:`Charge assigned to deposit ${u.assignChargeToDeposit.id}`})}catch(c){console.error(`${h}: ${c}`),b.error("Error",{id:o,description:h,duration:1e5,closeButton:!0})}},[a]);return{assigning:e,assignChargeToDeposit:n}};function Ne({depositId:e,chargeId:a,refetch:n}){const[r,h]=l.useState(!1),[o,c]=l.useState(void 0),[{data:u}]=$({query:z,pause:!r}),{assigning:g,assignChargeToDeposit:d}=Se(),f=l.useMemo(()=>(u?.allDeposits??[]).filter(s=>s.isOpen&&s.id!==e),[u?.allDeposits,e]),m=l.useCallback(async()=>{o&&(await d({chargeId:a,depositId:o}),h(!1),c(void 0),n?.())},[d,o,n,a]);return l.useEffect(()=>{r&&c(void 0)},[r]),t.jsxs(V,{open:r,onOpenChange:h,children:[t.jsx(_,{children:t.jsx(p,{variant:"ghost",size:"sm",children:"Reassign"})}),t.jsxs(G,{children:[t.jsx(P,{children:t.jsx(Q,{children:"Reassign Transaction"})}),t.jsx("div",{className:"space-y-4",children:t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(W,{htmlFor:"target-deposit-select",children:"Target Deposit"}),t.jsxs(J,{value:o,onValueChange:s=>c(s),children:[t.jsx(Y,{className:"min-w-[220px]",children:t.jsx(X,{id:"target-deposit-select",placeholder:f.length?"Select deposit":"No open deposits"})}),t.jsx(Z,{children:f.map(s=>t.jsxs(ee,{value:s.id,children:[s.id," (",s.currency,")"]},s.id))})]})]})}),t.jsx(te,{children:t.jsx(p,{variant:"secondary",disabled:!o||g,onClick:m,children:g?"Reassigning…":"Reassign"})})]})]})}function be(e,a){const{getId:n,getChargeId:r,getAmount:h}=a,o=new Map;for(const u of e){const g=r(u);if(!g)continue;const d=o.get(g)??[];d.push(u),o.has(g)||o.set(g,d)}const c=new Set;for(const[,u]of o)if(u.length>1){const g=[...u].sort((d,f)=>Math.abs(h(f))-Math.abs(h(d)));for(let d=1;d<g.length;d++)c.add(n(g[d]))}return c}const Te={[x.Eur]:"eur",[x.Gbp]:"gbp",[x.Cad]:"cad",[x.Jpy]:"jpy",[x.Aud]:"aud",[x.Sek]:"sek",[x.Usd]:"usd"};function ke({depositId:e,enableReassign:a=!1,refetch:n}){const{userContext:r}=l.useContext(se),[h,o]=l.useState([{id:"date",desc:!1}]),[{data:c,fetching:u}]=$({query:ae,variables:{depositId:e}}),g=l.useMemo(()=>{if(!c?.deposit?.transactions)return[];const m=c.deposit.transactions.map(i=>ne(me,i)),s=be(m,{getId:i=>i.id,getChargeId:i=>i.chargeId,getAmount:i=>Number(i.amount.raw??0)}),S=[...m].sort((i,C)=>{const v=i.eventDate?new Date(i.eventDate).getTime():0,I=C.eventDate?new Date(C.eventDate).getTime():0;return v-I});let w=0,j=0,M=0;return S.map(i=>{let C=null;const v=Te[i.amount.currency];v&&(C=i.debitExchangeRates?.[v]??i.eventExchangeRates?.[v]??null);const I=Number(i.amount.raw),k=I*(C??1),O=r?.context.defaultLocalCurrency??x.Ils,B=s.has(i.id);return B?j+=I:(w+=I,M+=k),{...i,cumulativeBalance:w,localCumulativeBalance:M,localAmount:k,localCurrency:O,totalInterest:j,isInterest:B}})},[c?.deposit,r]),d=l.useMemo(()=>{const m=r?.context.defaultLocalCurrency??x.Ils,S=!!c?.deposit?.currency&&c.deposit.currency===m?L.filter(j=>j.id!=="amount"&&j.id!=="cumulativeBalance"):L,w=a?[{id:"actions",header:"Actions",cell:({row:j})=>t.jsx(Ne,{depositId:e,chargeId:j.original.chargeId,refetch:n})}]:[];return[...S,...w]},[a,e,n,c?.deposit?.currency,r?.context.defaultLocalCurrency]),f=re({data:g,columns:d,getCoreRowModel:ce(),onSortingChange:o,getSortedRowModel:oe(),state:{sorting:h}});return u?t.jsx("div",{className:"flex h-64 w-full items-center justify-center",children:t.jsx(ie,{className:"size-10 animate-spin"})}):t.jsxs(le,{children:[t.jsx(de,{children:f.getHeaderGroups().map(m=>t.jsx(T,{children:m.headers.map(s=>t.jsx(ue,{colSpan:s.colSpan,children:s.isPlaceholder?null:A(s.column.columnDef.header,s.getContext())},s.id))},m.id))}),t.jsx(ge,{children:f.getRowModel().rows?.length?f.getRowModel().rows.map(m=>t.jsx(T,{children:m.getVisibleCells().map(s=>t.jsx(F,{children:A(s.column.columnDef.cell,s.getContext())},s.id))},m.id)):t.jsx(T,{children:t.jsx(F,{colSpan:d.length,className:"h-24 text-center",children:"No transactions in this deposit."})})})]})}export{ke as D,Se as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r,j as t,bU as i,bV as d,B as p,h6 as h,bW as x}from"./index-
|
|
1
|
+
import{r,j as t,bU as i,bV as d,B as p,h6 as h,bW as x}from"./index-D1_HHRLX.js";function u(n,s){const e=new Uint8Array([239,187,191]),c=new Blob([e,n],{type:"text/csv;charset=UTF-8"}),a=URL.createObjectURL(c),o=document.createElement("a");o.href=a,o.download=`${s}.csv`,document.body.appendChild(o),o.click(),document.body.removeChild(o)}const m=({createFileVariables:n,buttonProps:s,buttonContent:e,label:c})=>{const a=r.useCallback(()=>{n().then(({fileContent:o,fileName:l})=>{u(o,l)})},[n]);return t.jsxs(i,{children:[t.jsx(d,{children:t.jsx(p,{variant:"outline",className:"p-2",...s,onClick:a,children:e||t.jsx(h,{size:20})})}),t.jsx(x,{children:t.jsx("p",{children:c||"Download CSV"})})]})};export{m as D};
|