@accounter/client
Version:
Accounter client application
8 lines • 147 kB
JavaScript
import{v as at,a8 as We,r as p,ep as Zo,eq as ea,di as ta,bz as Ke,er as na,es as ra,et as sa,aH as $,bA as Me,by as Qe,eu as F,ev as Ee,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,a5 as L,eF as ua,g as Te,eG as fa,t as M,i as $e,eH as pa,T as Ue,bX as on,B as W,m as ys,eI as ma,z as an,Q as vs,eJ as ga,eK as ha,eL as xa,eM as ya,av 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,aV as or,eW as wa,u as Ne,eX as _a,eY as Ia,c as Ea,eZ as Fn,e_ as kn,D as cn,aN as bs,bU as Oa,bV as Pa,bW as Aa,w as ln,am as Ds,an as Cs,e$ as Na,f0 as Ss,f1 as Ta,f2 as ws,R as Ye,ag as Mn,f3 as $a,bC as Be,f4 as Fa,ah as bt,f5 as _s,f6 as Is,f7 as qe,f8 as ka,f9 as Es,fa as Os,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,a2 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,ap as cr,aq as lr,ar as dr,as as ur,at as fr,a1 as ai,ax 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,H as yi,V as vi,N as ji,fM as Qs,fN as bi,fO as Xs,fP as Js,fQ as Oe,fR as be,fS as Di,fT as pr,fU as Zs,fV as Ze,fW as Ci,fX as Si}from"./index-CDv8MTrU.js";import{T as eo}from"./toggle-expansion-button-D_sqNCfP.js";import{U as wi}from"./update-accountant-status-BkPOJv2s.js";import{M as _i,P as q,I as Ii,T as to,a as Ei,D as Oi,A as Pi,b as Ai,c as Ni,S as Ti,d as $i,C as Fi}from"./index-BSXv5S5U.js";import{T as no}from"./Table-CnwiwZMD.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-DNGSbjeZ.js";import{A as ro,a as _e,b as Ie,c as he}from"./accordion-CRFl4b_U.js";import{u as zi,D as Li}from"./deposits-transactions-table-41MroH8q.js";import{C as Bi,M as Vi}from"./Checkbox-DzoVLGuy.js";import{D as Le}from"./data-table-column-header-DF5fndn9.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 Ji(e){return We(e,"yyyy-MM-dd")}function xr(e){return typeof e!="string"?"":e.charAt(0).toUpperCase()+e.slice(1)}var Zi=Object.defineProperty,ec=Object.defineProperties,tc=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertySymbols,so=Object.prototype.hasOwnProperty,oo=Object.prototype.propertyIsEnumerable,yr=(e,t,n)=>t in e?Zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,et=(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)=>ec(e,tc(t)),nc=(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 rc(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 sc({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=>et(et({},m),u))};function f(u){return{transition:`height ${e||rc(u)}ms ${t}`}}Zo(()=>{Nt(s?()=>{h({willChange:"height",display:"block",overflow:"hidden"}),Nt(()=>{const u=xn(o);h(hn(et({},f(u)),{height:u}))})}:()=>{const u=xn(o);h(hn(et({},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=nc(m,["style","refKey"]);const D=b[v];return hn(et({"aria-hidden":!s},b),{[v]:ea(o,D),onTransitionEnd:g,style:et(et({boxSizing:"border-box"},j),c)})}return x}var oc=Object.defineProperty,Kt=Object.getOwnPropertySymbols,ao=Object.prototype.hasOwnProperty,io=Object.prototype.propertyIsEnumerable,vr=(e,t,n)=>t in e?oc(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},ac=(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 ic={transitionDuration:200,transitionTimingFunction:"ease",animateOpacity:!0},co=p.forwardRef((e,t)=>{const n=Ke("Collapse",ic,e),{children:s,in:o,transitionDuration:a,transitionTimingFunction:i,style:c,onTransitionEnd:l,animateOpacity:d}=n,h=ac(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=sc({opened:o,transitionDuration:u,transitionTimingFunction:i,onTransitionEnd:l});return u===0?o?$.createElement(Me,Tt({},j),s):null:$.createElement(Me,Tt({},v(Tt(Tt({style:c,ref:t},j),m))),$.createElement("div",{style:{opacity:o||!d?1:0,transition:d?`opacity ${u}ms ${i}`:"none"}},s))});co.displayName="@mantine/core/Collapse";var cc=Object.defineProperty,lc=Object.defineProperties,dc=Object.getOwnPropertyDescriptors,jr=Object.getOwnPropertySymbols,uc=Object.prototype.hasOwnProperty,fc=Object.prototype.propertyIsEnumerable,br=(e,t,n)=>t in e?cc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,yn=(e,t)=>{for(var n in t||(t={}))uc.call(t,n)&&br(e,n,t[n]);if(jr)for(var n of jr(t))fc.call(t,n)&&br(e,n,t[n]);return e},pc=(e,t)=>lc(e,dc(t));const mc=["light","filled","outline","dot","gradient"],vn={xs:{fontSize:F(9),height:F(16)},sm:{fontSize:F(10),height:F(18)},md:{fontSize:F(11),height:F(20)},lg:{fontSize:F(13),height:F(26)},xl:{fontSize:F(16),height:F(32)}},gc={xs:F(4),sm:F(4),md:F(6),lg:F(8),xl:F(10)};function hc({theme:e,variant:t,color:n,size:s,gradient:o}){if(!mc.includes(t))return null;if(t==="dot"){const i=Ee({size:s,sizes:gc});return{backgroundColor:"transparent",color:e.colorScheme==="dark"?e.colors.dark[0]:e.colors.gray[7],border:`${F(1)} solid ${e.colorScheme==="dark"?e.colors.dark[3]:e.colors.gray[3]}`,paddingLeft:`calc(${Ee({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:`${F(t==="gradient"?0:1)} solid ${a.border}`}}var xc=Qe((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(pc(yn(yn({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:c,height:l,WebkitTapHighlightColor:"transparent",lineHeight:`calc(${l} - ${F(2)})`,textDecoration:"none",padding:`0 calc(${Ee({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:F(.25),cursor:"inherit",textOverflow:"ellipsis",overflow:"hidden"}),hc({theme:e,variant:a,color:t,size:i,gradient:s}))}}),yc=Object.defineProperty,Gt=Object.getOwnPropertySymbols,lo=Object.prototype.hasOwnProperty,uo=Object.prototype.propertyIsEnumerable,Dr=(e,t,n)=>t in e?yc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vc=(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},jc=(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 bc={variant:"light",size:"md",radius:"xl"},fo=p.forwardRef((e,t)=>{const n=Ke("Badge",bc,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=jc(n,["className","color","variant","fullWidth","children","size","leftSection","rightSection","radius","gradient","classNames","styles","unstyled"]),{classes:v,cx:b}=xc({fullWidth:i,color:o,radius:f,gradient:g},{classNames:x,styles:u,name:"Badge",unstyled:m,variant:a,size:l});return $.createElement(Me,vc({className:b(v.root,s),ref:t},j),d&&$.createElement("span",{className:v.leftSection},d),$.createElement("span",{className:v.inner},c),h&&$.createElement("span",{className:v.rightSection},h))});fo.displayName="@mantine/core/Badge";const In=oa(fo);var Dc=Object.defineProperty,qt=Object.getOwnPropertySymbols,po=Object.prototype.hasOwnProperty,mo=Object.prototype.propertyIsEnumerable,Cr=(e,t,n)=>t in e?Dc(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},Cc=(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 Sc={multiple:!1},go=p.forwardRef((e,t)=>{const n=Ke("FileButton",Sc,e),{onChange:s,children:o,multiple:a,accept:i,name:c,form:l,resetRef:d,disabled:h,capture:f,inputProps:g}=n,x=Cc(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=""}),$.createElement($.Fragment,null,o(Sr({onClick:m},x)),$.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 wc=Qe(()=>({placeholder:{},input:{cursor:"pointer"}})),_c=Object.defineProperty,Ic=Object.defineProperties,Ec=Object.getOwnPropertyDescriptors,Wt=Object.getOwnPropertySymbols,ho=Object.prototype.hasOwnProperty,xo=Object.prototype.propertyIsEnumerable,wr=(e,t,n)=>t in e?_c(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)=>Ic(e,Ec(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 Pc=({value:e})=>$.createElement(He,{sx:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},Array.isArray(e)?e.map(t=>t.name).join(", "):e?.name),Ac={size:"sm",valueComponent:Pc},yo=p.forwardRef((e,t)=>{const n=ia("FileInput",Ac,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:P,fileInputProps:E}=n,_=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:S,cx:k}=wc(null,{name:"FileInput",classNames:x,styles:u,unstyled:m}),[y,T]=ca({value:i,defaultValue:c,onChange:l,finalValue:d?[]:null}),Y=Array.isArray(y)?y.length!==0:y!==null,z=v||(b&&Y&&!C?$.createElement(la,$t(st({},D),{variant:"transparent",onClick:()=>T(d?[]:null),size:s.size,unstyled:m})):null);return p.useEffect(()=>{(Array.isArray(y)&&y.length===0||y===null)&&O.current()},[y]),$.createElement(fn.Wrapper,$t(st({},o),{__staticSelector:"FileInput"}),$.createElement(go,{onChange:T,multiple:d,accept:h,name:f,form:g,resetRef:O,disabled:C,capture:P,inputProps:E},B=>$.createElement(fn,$t(st(st(st({multiline:!0},B),s),_),{component:"button",type:"button",ref:t,__staticSelector:"FileInput",rightSection:z,classNames:$t(st({},x),{input:k(S.input,x?.input)})}),Y?$.createElement(j,{value:y}):$.createElement(fn.Placeholder,{className:S.placeholder},a))))});yo.displayName="@mantine/core/FileInput";const Nc=yo;var Tc=Object.defineProperty,$c=Object.defineProperties,Fc=Object.getOwnPropertyDescriptors,_r=Object.getOwnPropertySymbols,kc=Object.prototype.hasOwnProperty,Mc=Object.prototype.propertyIsEnumerable,Ir=(e,t,n)=>t in e?Tc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Rc=(e,t)=>{for(var n in t||(t={}))kc.call(t,n)&&Ir(e,n,t[n]);if(_r)for(var n of _r(t))Mc.call(t,n)&&Ir(e,n,t[n]);return e},zc=(e,t)=>$c(e,Fc(t)),Lc=Qe(e=>({root:zc(Rc({},e.fn.cover()),{display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"})})),Bc=Object.defineProperty,Vc=Object.defineProperties,Hc=Object.getOwnPropertyDescriptors,Yt=Object.getOwnPropertySymbols,vo=Object.prototype.hasOwnProperty,jo=Object.prototype.propertyIsEnumerable,Er=(e,t,n)=>t in e?Bc(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)&&Er(e,n,t[n]);if(Yt)for(var n of Yt(t))jo.call(t,n)&&Er(e,n,t[n]);return e},Uc=(e,t)=>Vc(e,Hc(t)),Kc=(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 Gc={overlayOpacity:.75,transitionDuration:0,radius:0,zIndex:xs("overlay")},bo=p.forwardRef((e,t)=>{const n=Ke("LoadingOverlay",Gc,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=Kc(n,["className","visible","loaderProps","overlayOpacity","overlayColor","transitionDuration","exitTransitionDuration","zIndex","style","loader","radius","overlayBlur","unstyled","variant","keepMounted"]),{classes:D,cx:C,theme:P}=Lc(null,{name:"LoadingOverlay",unstyled:m,variant:j}),E=`calc(${h} + 1)`;return $.createElement(da,{keepMounted:v,duration:l,exitDuration:d,mounted:o,transition:"fade"},_=>$.createElement(Me,Ft({className:C(D.root,s),style:Uc(Ft(Ft({},_),f),{zIndex:h}),ref:t},b),g?$.createElement("div",{style:{zIndex:E}},g):$.createElement(it,Ft({style:{zIndex:E}},a)),$.createElement(hs,{opacity:i,zIndex:h,radius:x,blur:u,unstyled:m,color:c||(P.colorScheme==="dark"?P.colors.dark[5]:P.white)})))});bo.displayName="@mantine/core/LoadingOverlay";var qc=Object.defineProperty,Wc=Object.defineProperties,Yc=Object.getOwnPropertyDescriptors,Or=Object.getOwnPropertySymbols,Qc=Object.prototype.hasOwnProperty,Xc=Object.prototype.propertyIsEnumerable,Pr=(e,t,n)=>t in e?qc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ar=(e,t)=>{for(var n in t||(t={}))Qc.call(t,n)&&Pr(e,n,t[n]);if(Or)for(var n of Or(t))Xc.call(t,n)&&Pr(e,n,t[n]);return e},Jc=(e,t)=>Wc(e,Yc(t));const Zc={xs:F(16),sm:F(20),md:F(26),lg:F(32),xl:F(40)},el=["filled","light","gradient","outline","default"];function tl({theme:e,variant:t,color:n,gradient:s}){if(!el.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:`${F(t==="gradient"?0:1)} solid ${o.border}`}}var nl=Qe((e,{color:t,radius:n,gradient:s},{variant:o,size:a})=>{const i=Ee({size:a,sizes:Zc});return{root:Ar(Jc(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)}),tl({theme:e,variant:o,gradient:s,color:t}))}}),rl=Object.defineProperty,Qt=Object.getOwnPropertySymbols,Do=Object.prototype.hasOwnProperty,Co=Object.prototype.propertyIsEnumerable,Nr=(e,t,n)=>t in e?rl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,sl=(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},ol=(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 al={size:"md",variant:"filled"},Hn=p.forwardRef((e,t)=>{const n=Ke("ThemeIcon",al,e),{className:s,size:o,radius:a,variant:i,color:c,children:l,gradient:d,unstyled:h}=n,f=ol(n,["className","size","radius","variant","color","children","gradient","unstyled"]),{classes:g,cx:x}=nl({variant:i,radius:a,color:c,gradient:d},{name:"ThemeIcon",unstyled:h,variant:i,size:o});return $.createElement(Me,sl({className:x(g.root,s),ref:t},f),l)});Hn.displayName="@mantine/core/ThemeIcon";const il=({data:e})=>{const t=L(ua,e);return r.jsxs(r.Fragment,{children:[r.jsx(ki,{data:t,onChange:()=>{}}),r.jsx(Mi,{data:t})]})},cl="deleteCharge",ll=()=>{const[{fetching:e},t]=Te(fa),n=p.useCallback(async s=>{const o=`Error deleting charge ID [${s.chargeId}]`,a=`${cl}-${s.chargeId}`;M.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 M.success("Success",{id:a,description:"Charge was deleted"}),c.deleteCharge}}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,deleteCharge:n}},dl="regenerateLedgerRecords",ul=()=>{const[{fetching:e},t]=Te(pa),n=p.useCallback(async s=>{const o="Error regenerating ledger",a=`${dl}-${s.chargeId}`;M.loading("Regenerating Ledger",{id:a});try{const i=await t(s),c=$e(i,o,a,"regenerateLedgerRecords");if(c)return M.success("Success",{id:a,description:"Ledger records were regenerated"}),c.regenerateLedgerRecords}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,regenerateLedgerRecords:n}};function fl({chargeId:e,onChange:t,...n}){const{regenerateLedgerRecords:s}=ul();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(W,{variant:"outline",size:"icon",...n,className:ys("size-7.5",n.className),children:r.jsx(Yi,{className:"size-5"})})})})}function pl(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(W,{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 ml="updateMiscExpense",gl=()=>{const[{fetching:e},t]=Te(ma),n=p.useCallback(async s=>{const o=`Error updating misc expense ID [${s.id}]`,a=`${ml}-${s.id}`;M.loading("Update Misc Expense",{id:a});try{const i=await t(s),c=$e(i,o,a,"updateMiscExpense");if(c)return M.success("Success",{id:a,description:"Misc expense was updated"}),c.updateMiscExpense}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateMiscExpense:n}},hl=({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}=gl(),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"})})]})})})},xl="insertDocument",yl=()=>{const[{fetching:e},t]=Te(ha),n=p.useCallback(async s=>{const o=`Error inserting document to charge ID [${s.record.chargeId}]`,a=xl;M.loading("Adding document",{id:a});try{const i=await t(s),c=$e(i,o,a,"insertDocument");if(c)return M.success("Success",{id:a,description:"Document added"}),c.insertDocument}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,insertDocument:n}},vl=({chargeId:e,onChange:t,closeModal:n})=>{const s=an(),{handleSubmit:o,formState:{dirtyFields:a},setValue:i,watch:c}=s,{insertDocument:l,fetching:d}=yl(),h=g=>{if(g&&Object.keys(g).length>0){if(g.vat){if(!g.amount?.currency){M.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"})]})]})})})},jl="insertSalaryRecordsFromFile",bl=()=>{const[{fetching:e},t]=Te(ja),n=p.useCallback(async s=>{const o=`Error uploading payroll file to charge ID [${s.chargeId}]`,a=`${jl}-${s.chargeId}`;M.loading("Uploading payroll file",{id:a});try{const i=await t(s),c=$e(i,o,a,"insertSalaryRecordsFromFile");if(c)return M.success("Success",{id:a,description:"Payroll file added"}),c.insertSalaryRecordsFromFile}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return!1},[t]);return{fetching:e,uploadPayrollFile:n}},Dl=({chargeId:e,onDone:t})=>{const{fetching:n,uploadPayrollFile:s}=bl(),[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(Nc,{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 Cl=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=Sl(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 Sl(e){var t=e.name,n=t&&t.lastIndexOf(".")!==-1;if(n&&!e.type){var s=t.split(".").pop().toLowerCase(),o=Cl.get(s);o&&Object.defineProperty(e,"type",{value:o,writable:!1,configurable:!1,enumerable:!0})}return e}var wl=[".DS_Store","Thumbs.db"];function _l(e){return ct(this,void 0,void 0,function(){return lt(this,function(t){return Xt(e)&&Il(e.dataTransfer)?[2,Al(e.dataTransfer,e.type)]:El(e)?[2,Ol(e)]:Array.isArray(e)&&e.every(function(n){return"getFile"in n&&typeof n.getFile=="function"})?[2,Pl(e)]:[2,[]]})})}function Il(e){return Xt(e)}function El(e){return Xt(e)&&Xt(e.target)}function Xt(e){return typeof e=="object"&&e!==null}function Ol(e){return En(e.target.files).map(function(t){return It(t)})}function Pl(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 Al(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=En(e.items).filter(function(a){return a.kind==="file"}),t!=="drop"?[2,n]:[4,Promise.all(n.map(Nl))]):[3,2];case 1:return s=o.sent(),[2,Tr(So(s))];case 2:return[2,Tr(En(e.files).map(function(a){return It(a)}))]}})})}function Tr(e){return e.filter(function(t){return wl.indexOf(t.name)===-1})}function En(e){if(e===null)return[];for(var t=[],n=0;n<e.length;n++){var s=e[n];t.push(s)}return t}function Nl(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 Tl(e){return ct(this,void 0,void 0,function(){return lt(this,function(t){return[2,e.isDirectory?wo(e):$l(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(Tl)),o.push(h),a(),f.label=6;case 6:return[2]}})})},function(c){s(c)})}a()})}function $l(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 Fl(){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 kl=Fl();const Ml=ba(kl);function kr(e){return Ll(e)||zl(e)||Io(e)||Rl()}function Rl(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function zl(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Ll(e){if(Array.isArray(e))return On(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 Hl(e)||Vl(e,t)||Io(e,t)||Bl()}function Bl(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
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 On(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 On(e,t)}}function On(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 Vl(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 Hl(e){if(Array.isArray(e))return e}var Ul="file-invalid-type",Kl="file-too-large",Gl="file-too-small",ql="too-many-files",Wl=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:Ul,message:"File type must be ".concat(n)}},zr=function(t){return{code:Kl,message:"File is larger than ".concat(t," ").concat(t===1?"byte":"bytes")}},Lr=function(t){return{code:Gl,message:"File is smaller than ".concat(t," ").concat(t===1?"byte":"bytes")}},Yl={code:ql,message:"Too many files"};function Eo(e,t){var n=e.type==="application/x-moz-file"||Ml(e,t);return[n,n?null:Wl(t)]}function Oo(e,t,n){if(tt(e.size))if(tt(t)&&tt(n)){if(e.size>n)return[!1,zr(n)];if(e.size<t)return[!1,Lr(t)]}else{if(tt(t)&&e.size<t)return[!1,Lr(t)];if(tt(n)&&e.size>n)return[!1,zr(n)]}return[!0,null]}function tt(e){return e!=null}function Ql(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=Eo(l,n),h=Dt(d,1),f=h[0],g=Oo(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 Xl(e){return e.indexOf("MSIE")!==-1||e.indexOf("Trident/")!==-1}function Jl(e){return e.indexOf("Edge/")!==-1}function Zl(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:window.navigator.userAgent;return Xl(e)||Jl(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 ed(){return"showOpenFilePicker"in window}function td(e){if(tt(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 nd(e){if(tt(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 rd(e){return e instanceof DOMException&&(e.name==="AbortError"||e.code===e.ABORT_ERR)}function sd(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 od=["children"],ad=["open"],id=["refKey","role","onKeyDown","onFocus","onBlur","onClick","onDragEnter","onDragOver","onDragLeave","onDrop"],cd=["refKey","onChange","onClick"];function ld(e){return fd(e)||ud(e)||No(e)||dd()}function dd(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ud(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function fd(e){if(Array.isArray(e))return Pn(e)}function jn(e,t){return gd(e)||md(e,t)||No(e,t)||pd()}function pd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
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 md(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 gd(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=hd(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 hd(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,od),o=$o(s),a=o.open,i=Zt(o,ad);return p.useImperativeHandle(t,function(){return{open:a}},[a]),$.createElement(p.Fragment,null,n(Q(Q({},i),{},{open:a})))});Un.displayName="Dropzone";var To={disabled:!1,getFilesFromEvent:_l,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:q.func,accept:q.objectOf(q.arrayOf(q.string)),multiple:q.bool,preventDropOnDocument:q.bool,noClick:q.bool,noKeyboard:q.bool,noDrag:q.bool,noDragEventsBubbling:q.bool,minSize:q.number,maxSize:q.number,maxFiles:q.number,disabled:q.bool,getFilesFromEvent:q.func,onFileDialogCancel:q.func,onFileDialogOpen:q.func,useFsAccessApi:q.bool,autoFocus:q.bool,onDragEnter:q.func,onDragLeave:q.func,onDragOver:q.func,onDrop:q.func,onDropAccepted:q.func,onDropRejected:q.func,onError:q.func,validator:q.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,P=t.noKeyboard,E=t.noDrag,_=t.noDragEventsBubbling,O=t.onError,S=t.validator,k=p.useMemo(function(){return nd(n)},[n]),y=p.useMemo(function(){return td(n)},[n]),T=p.useMemo(function(){return typeof j=="function"?j:Hr},[j]),Y=p.useMemo(function(){return typeof m=="function"?m:Hr},[m]),z=p.useRef(null),B=p.useRef(null),le=p.useReducer(xd,Nn),ae=jn(le,2),ne=ae[0],U=ae[1],R=ne.isFocused,de=ne.isFileDialogActive,ue=p.useRef(typeof window<"u"&&window.isSecureContext&&v&&ed()),Ce=function(){!ue.current&&de&&setTimeout(function(){if(B.current){var A=B.current.files;A.length||(U({type:"closeDialog"}),Y())}},300)};p.useEffect(function(){return window.addEventListener("focus",Ce,!1),function(){window.removeEventListener("focus",Ce,!1)}},[B,de,Y,ue]);var K=p.useRef([]),xe=function(A){z.current&&z.current.contains(A.target)||(A.preventDefault(),K.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))}},[z,D]),p.useEffect(function(){return!s&&b&&z.current&&z.current.focus(),function(){}},[z,b,s]);var ie=p.useCallback(function(w){O?O(w):console.error(w)},[O]),Z=p.useCallback(function(w){w.preventDefault(),w.persist(),ve(w),K.current=[].concat(ld(K.current),[w.target]),Mt(w)&&Promise.resolve(o(w)).then(function(A){if(!(Jt(w)&&!_)){var J=A.length,se=J>0&&Ql({files:A,accept:k,minSize:i,maxSize:a,multiple:c,maxFiles:l,validator:S}),ge=J>0&&!se;U({isDragAccept:se,isDragReject:ge,isDragActive:!0,type:"setDraggedFiles"}),d&&d(w)}}).catch(function(A){return ie(A)})},[o,d,ie,_,k,i,a,c,l,S]),N=p.useCallback(function(w){w.preventDefault(),w.persist(),ve(w);var A=Mt(w);if(A&&w.dataTransfer)try{w.dataTransfer.dropEffect="copy"}catch{}return A&&f&&f(w),!1},[f,_]),fe=p.useCallback(function(w){w.preventDefault(),w.persist(),ve(w);var A=K.current.filter(function(se){return z.current&&z.current.contains(se)}),J=A.indexOf(w.target);J!==-1&&A.splice(J,1),K.current=A,!(A.length>0)&&(U({type:"setDraggedFiles",isDragActive:!1,isDragAccept:!1,isDragReject:!1}),Mt(w)&&h&&h(w))},[z,h,_]),ee=p.useCallback(function(w,A){var J=[],se=[];w.forEach(function(ge){var ze=Eo(ge,k),Se=jn(ze,2),Xe=Se[0],Je=Se[1],Ge=Oo(ge,i,a),rt=jn(Ge,2),ft=rt[0],pt=rt[1],mt=S?S(ge):null;if(Xe&&ft&&!mt)J.push(ge);else{var gt=[Je,pt];mt&&(gt=gt.concat(mt)),se.push({file:ge,errors:gt.filter(function(Ot){return Ot})})}}),(!c&&J.length>1||c&&l>=1&&J.length>l)&&(J.forEach(function(ge){se.push({file:ge,errors:[Yl]})}),J.splice(0)),U({acceptedFiles:J,fileRejections:se,type:"setFiles"}),g&&g(J,se,A),se.length>0&&u&&u(se,A),J.length>0&&x&&x(J,A)},[U,c,k,i,a,l,g,x,u,S]),H=p.useCallback(function(w){w.preventDefault(),w.persist(),ve(w),K.current=[],Mt(w)&&Promise.resolve(o(w)).then(function(A){Jt(w)&&!_||ee(A,w)}).catch(function(A){return ie(A)}),U({type:"reset"})},[o,ee,ie,_]),I=p.useCallback(function(){if(ue.current){U({type:"openDialog"}),T();var w={multiple:c,types:y};window.showOpenFilePicker(w).then(function(A){return o(A)}).then(function(A){ee(A,null),U({type:"closeDialog"})}).catch(function(A){rd(A)?(Y(A),U({type:"closeDialog"})):sd(A)?(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(A)});return}B.current&&(U({type:"openDialog"}),T(),B.current.value=null,B.current.click())},[U,T,Y,v,ee,ie,y,c]),V=p.useCallback(function(w){!z.current||!z.current.isEqualNode(w.target)||(w.key===" "||w.key==="Enter"||w.keyCode===32||w.keyCode===13)&&(w.preventDefault(),I())},[z,I]),G=p.useCallback(function(){U({type:"focus"})},[]),te=p.useCallback(function(){U({type:"blur"})},[]),pe=p.useCallback(function(){C||(Zl()?setTimeout(I,0):I())},[C,I]),ce=function(A){return s?null:A},ye=function(A){return P?null:ce(A)},me=function(A){return E?null:ce(A)},ve=function(A){_&&A.stopPropagation()},re=p.useMemo(function(){return function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=w.refKey,J=A===void 0?"ref":A,se=w.role,ge=w.onKeyDown,ze=w.onFocus,Se=w.onBlur,Xe=w.onClick,Je=w.onDragEnter,Ge=w.onDragOver,rt=w.onDragLeave,ft=w.onDrop,pt=Zt(w,id);return Q(Q(An({onKeyDown:ye(Fe(ge,V)),onFocus:ye(Fe(ze,G)),onBlur:ye(Fe(Se,te)),onClick:ce(Fe(Xe,pe)),onDragEnter:me(Fe(Je,Z)),onDragOver:me(Fe(Ge,N)),onDragLeave:me(Fe(rt,fe)),onDrop:me(Fe(ft,H)),role:typeof se=="string"&&se!==""?se:"presentation"},J,z),!s&&!P?{tabIndex:0}:{}),pt)}},[z,V,G,te,pe,Z,N,fe,H,P,E,s]),Re=p.useCallback(function(w){w.stopPropagation()},[]),ut=p.useMemo(function(){return function(){var w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},A=w.refKey,J=A===void 0?"ref":A,se=w.onChange,ge=w.onClick,ze=Zt(w,cd),Se=An({accept:k,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:R&&!s,getRootProps:re,getInputProps:ut,rootRef:z,inputRef:B,open:ce(I)})}function xd(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[yd,vd]=js("Dropzone component was not found in tree");var Ur=Object.getOwnPropertySymbols,jd=Object.prototype.hasOwnProperty,bd=Object.prototype.propertyIsEnumerable,Dd=(e,t)=>{var n={};for(var s in e)jd.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&&bd.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=Dd(s,["children"]),i=vd(),c=Da(o)?o:$.createElement("span",null,o);return i[e]?p.cloneElement(c,a):null};return t.displayName=`@mantine/dropzone/${xr(e)}`,t}const Cd=Kn("accept"),Sd=Kn("reject"),wd=Kn("idle");var _d=Object.defineProperty,Id=Object.defineProperties,Ed=Object.getOwnPropertyDescriptors,Kr=Object.getOwnPropertySymbols,Od=Object.prototype.hasOwnProperty,Pd=Object.prototype.propertyIsEnumerable,Gr=(e,t,n)=>t in e?_d(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))Pd.call(t,n)&&Gr(e,n,t[n]);return e},Ad=(e,t)=>Id(e,Ed(t)),Nd=Qe((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:Ad(qr(qr({},e.fn.fontStyles()),e.fn.focusStyles()),{boxSizing:"border-box",backgroundColor:e.colorScheme==="dark"?e.colors.dark[6]:e.white,border:`${F(2)} dashed ${e.colorScheme==="dark"?e.colors.dark[4]:e.colors.gray[4]}`,padding:Ee({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"}}}),Td=Object.defineProperty,$d=Object.defineProperties,Fd=Object.getOwnPropertyDescriptors,en=Object.getOwnPropertySymbols,Fo=Object.prototype.hasOwnProperty,ko=Object.prototype.propertyIsEnumerable,Wr=(e,t,n)=>t in e?Td(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)=>$d(e,Fd(t)),kd=(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 Md={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",Md,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:P,activateOnDrag:E,dragEventsBubbling:_,activateOnKeyboard:O,onDragEnter:S,onDragLeave:k,onDragOver:y,onFileDialogCancel:T,onFileDialogOpen:Y,preventDropOnDocument:z,useFsAccessApi:B,getFilesFromEvent:le,validator:ae,variant:ne}=t,U=kd(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:R,cx:de}=Nd({radius:o,padding:s},{name:"Dropzone",classNames:i,styles:c,unstyled:b,variant:ne}),{getRootProps:ue,getInputProps:Ce,isDragAccept:K,isDragReject:xe,open:ie}=$o(ht({onDrop:x,onDropAccepted:u,onDropRejected:m,disabled:a||l,accept:Array.isArray(f)?f.reduce((N,fe)=>bn(ht({},N),{[fe]:[]}),{}):f,multiple:d,maxSize:h,maxFiles:D,autoFocus:C,noClick:!P,noDrag:!E,noDragEventsBubbling:!_,noKeyboard:!O,onDragEnter:S,onDragLeave:k,onDragOver:y,onFileDialogCancel:T,onFileDialogOpen:Y,preventDropOnDocument:z,useFsAccessApi:B,validator:ae},le?{getFilesFromEvent:le}:null));gs(j,ie);const Z=!K&&!xe;return $.createElement(yd,{value:{accept:K,reject:xe,idle:Z}},$.createElement(Me,bn(ht(ht({},U),ue()),{"data-accept":K||void 0,"data-reject":xe||void 0,"data-idle":Z||void 0,"data-loading":l||void 0,className:de(R.root,n)}),$.createElement(bo,{visible:l,radius:o,unstyled:b}),$.createElement("input",bn(ht({},Ce()),{name:v})),$.createElement("div",{className:R.inner},g)))}dt.displayName="@mantine/dropzone/Dropzone";dt.Accept=Cd;dt.Reject=Sd;dt.Idle=wd;const Mo=dt;var Rd=Object.defineProperty,zd=Object.defineProperties,Ld=Object.getOwnPropertyDescriptors,Yr=Object.getOwnPropertySymbols,Bd=Object.prototype.hasOwnProperty,Vd=Object.prototype.propertyIsEnumerable,Qr=(e,t,n)=>t in e?Rd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Hd=(e,t)=>{for(var n in t||(t={}))Bd.call(t,n)&&Qr(e,n,t[n]);if(Yr)for(var n of Yr(t))Vd.call(t,n)&&Qr(e,n,t[n]);return e},Ud=(e,t)=>zd(e,Ld(t)),Kd=Qe(e=>({wrapper:Ud(Hd({},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}})),Gd=Object.defineProperty,qd=Object.defineProperties,Wd=Object.getOwnPropertyDescriptors,tn=Object.getOwnPropertySymbols,Ro=Object.prototype.hasOwnProperty,zo=Object.prototype.propertyIsEnumerable,Xr=(e,t,n)=>t in e?Gd(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)=>qd(e,Wd(t)),Yd=(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 Qd={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",Qd,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=Yd(t,["classNames","styles","sx","className","style","unstyled","active","onDrop","onReject","zIndex","withinPortal","portalProps"]),[m,j]=$.useState(0),[v,{open:b,close:D}]=jt(!1),{classes:C,cx:P}=Kd(null,{name:"DropzoneFullScreen",classNames:n,styles:s,unstyled:c}),E=O=>{O.dataTransfer.types.includes("Files")&&(j(S=>S+1),b())},_=()=>{j(O=>O-1)};return p.useEffect(()=>{m===0&&D()},[m]),p.useEffect(()=>{if(l)return document.addEventListener("dragenter",E,!1),document.addEventListener("dragleave",_,!1),()=>{document.removeEventListener("dragenter",E,!1),document.removeEventListener("dragleave",_,!1)}},[l]),$.createElement(Ca,Cn(Dn({},x),{withinPortal:g}),$.createElement(Me,{className:P(C.wrapper,a),sx:o,style:Cn(Dn({},i),{opacity:v?1:0,pointerEvents:v?"all":"none",zIndex: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 Xd=Mo,Jd=({children:e,chargeId:t})=>{const{uploading:n,uploadMultipleDocuments:s}=Sa();function o(a){M.error("Error",{description:a,duration:5e3})}return r.jsx(Xd,{onDrop:a=>s({documents:a,chargeId:t,isSensitive:!1}),onReject:a=>o(`Rejected Files:
${a.map(i=>`"${i.file.name}": ${i.errors}`).join(`
`)}`),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 Zd="mergeCharges",eu=()=>{const[{fetching:e},t]=Te(wa),n=p.useCallback(async s=>{const o=`Error merging into charge ID [${s.baseChargeID}]`,a=`${Zd}-${s.baseChargeID}`;M.loading("Merging Charges",{id:a});try{const i=await t(s),c=$e(i,o,a,"mergeCharges");if(c)return M.success("Success",{id:a,description:"Charges were merged"}),c.mergeCharges.charge}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,mergeCharges:n}};function tu({chargeIds:e,onDone:t,resetMerge:n}){const{mergeCharges:s,fetching:o}=eu(),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,P]=p.useState(void 0),[E,_]=p.useState(void 0),O=i?.chargesByIDs.length!==a.length&&"Some charges were not Found"||void 0,S=i?.chargesByIDs||[],k=p.useCallback(async()=>{if(!l){M.error("Error",{description:"No main charge selected"});return}if(a.length<2){M.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}),j&&j.value!==l.__typename&&(y??={},y={...y,type:Ia(j.value)}),b&&b.value!==l.decreasedVAT&&(y??={},y={...y,isDecreasedVAT:b.value}),g&&g.value!==l.optionalVAT&&(y??={},y={...y,optionalVAT:g.value}),u&&u.value!==l.optionalDocuments&&(y??={},y={...y,optionalDocuments:u.value}),E&&E.value!==l.tags.map(T=>T.name).join(",")&&(y??={},y={...y,tags:E.value.split(",").filter(T=>T!=="").map(T=>({id:T}))}),C&&C.value!==l.isInvoicePaymentDifferentCurrency&&(y??={},y={...y,isInvoicePaymentDifferentCurrency:C.value}),await s({baseChargeID:l.id,chargeIdsToMerge:a.filter(T=>T!==l.id),fields:y}),n(),t()},[l,a,s,h,u,j,b,g,C,E,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(Ea,{})}),!c&&O&&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:O})}),!c&&!O&&r.jsxs(r.Fragment,{children:[r.jsxs("table",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:"Main"}),S.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.optionalVAT??!1}),m({id:y.id,value:y.optionalDocuments??!1}),P({id:y.id,value:y.isInvoicePaymentDifferentCurrency??!1}),v({id:y.id,value:y.__typename}),D({id:y.id,value:y.decreasedVAT??!1}),_({id:y.id,value:(y.tags.map(T=>T.name)??[]).join(",")})}})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Description"}),S.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:"Type"}),S.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.__typename==null||y.__typename===j?.value,onClick:()=>{v({id:y.id,value:y.__typename})},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:r.jsx(Ue,{content:kn(y.__typename),children:Fn(y.__typename)})})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Is Decreased VAT"}),S.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.decreasedVAT==null||y.decreasedVAT===b?.value,onClick:()=>{D({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:b?.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"}),S.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.optionalVAT==null||y.optionalVAT===g?.value,onClick:()=>{x({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:g?.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"}),S.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.optionalDocuments==null||y.optionalDocuments===u?.value,onClick:()=>{m({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:u?.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"}),S.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.isInvoicePaymentDifferentCurrency==null||y.isInvoicePaymentDifferentCurrency===C?.value,onClick:()=>{P({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:C?.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"}),S.map(y=>r.jsx("td",{children:r.jsx("button",{className:"w-full px-2",disabled:y.tags==null||y.tags.map(T=>T.name).join(",")===E?.value,onClick:()=>{_({id:y.id,value:(y.tags.map(T=>T.name)??[]).join(",")})},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:r.jsx(dn,{items:y.tags.map(T=>r.jsxs("div",{className:"flex flex-col items-center",children:[r.jsx("div",{children:T.name}),T.namePath&&r.jsx("div",{children:T.namePath.join(" > ")})]},T.id))})})})},y.id))]}),r.jsxs("tr",{children:[r.jsx("th",{children:"Transactions"}),S.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"}),S.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:k,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 nu(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(Oa,{children:[r.jsx(Pa,{children:r.jsx(W,{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(tu,{chargeIds:Array.from(a),onDone:d,resetMerge:o})]})]})}const ru=({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}${Ye.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},su=({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(W,{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(hl,{onDone:o,data:t})})]})},ou=({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}${Ye.CHARGES.DETAIL(e)}`})]})]}),opened:!!e,onClose:t,children:r.jsx(vl,{chargeId:e,closeModal:t,onChange:n})}):null;function au(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 iu(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 cu=({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 "+au(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 "+iu(t),style:{color:s},children:e.toFixed(0)})})]})};function lu({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 du=({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})})})})},uu=({data:e})=>{const t=L(_s,e);return"businessTrip"in t?r.jsx("td",{children:r.jsx(bt,{to:t.businessTrip?.id?Ye.BUSINESS_TRIPS.DETAIL(t.businessTrip?.id):Ye.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",{})},fu=({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:Ye.BUSINESSES.DETAIL(c),target:"_blank",rel:"noreferrer",onClick:l=>l.stopPropagation(),className:"inline-flex items-center font-semibold",children:i}),a&&i]})})})},pu=({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&&We(new Date(a),"dd/MM/yy")})})},mu=({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}=Es(),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(Os,{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})]})},gu=({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(Jd,{chargeId:o,children:r.jsx(dn,{items:g})})})},hu=({data:e,onChange:t})=>{const{tags:n,id:s,validationData:o,missingInfoSuggestions:a}=L(As,e),{updateCharge:i,fetching:c}=Es(),[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(Os,{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})]})},xu=({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",{})},yu=({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})]})},vu=({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",{})},ju="insertDepreciationRecord",bu=()=>{const[{fetching:e},t]=Te(Ba),n=p.useCallback(async s=>{const o="Error adding depreciation record",a=ju;M.loading("Adding depreciation record",{id:a});try{const i=await t(s),c=$e(i,o,a,"insertDepreciationRecord");if(c)return M.success("Success",{id:a,description:"Depreciation record was added"}),c.insertDepreciationRecord}catch(i){console.error(`${o}: ${i}`),M.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(W,{variant:"outline",size:"icon",className:"size-7.5",onClick:i=>{i.stopPropagation(),a()},children:r.jsx(Va,{className:"size-5"})})}),s&&r.jsx(Du,{chargeId:t,opened:s,close:o,onAdd:n})]})}function Du({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}=bu(),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:We(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 Cu="updateDepreciationRecord",Su=()=>{const[{fetching:e},t]=Te(Ha),n=p.useCallback(async s=>{const o="Error updating depreciation record",a=Cu;M.loading("Updating depreciation record",{id:a});try{const i=await t(s),c=$e(i,o,a,"updateDepreciationRecord");if(c)return M.success("Success",{id:a,description:"Depreciation record was updated"}),c.updateDepreciationRecord}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,updateDepreciationRecord:n}},wu="deleteDepreciationRecord",_u=()=>{const[{fetching:e},t]=Te(Ua),n=p.useCallback(async s=>{const o="Error deleting depreciation record",a=`${wu}-${s.depreciationRecordId}`;M.loading("Deleting depreciation record",{id:a});try{const i=await t(s),c=$e(i,o,a);if(c)return M.success("Success",{id:a,description:"Depreciation record was deleted"}),c.deleteDepreciationRecord}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteDepreciationRecord:n}};function Iu(e){const{fetching:t,deleteDepreciationRecord:n}=_u(),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(W,{variant:"outline",size:"icon",className:"size-7.5 text-red-500",disabled:t,children:r.jsx(Rn,{className:"size-5"})})})})}const Eu=({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}=Su(),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:We(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:We(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(W,{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(W,{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(Iu,{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(Eu,{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 Pu({chargeId:e,chargeType:t,onChange:n,isIncome:s}){const{deleteCharge:o}=ll(),[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),[P,E]=p.useState(!1),_=p.useCallback(()=>{i(!1)},[]),O=p.useCallback(async()=>{await o({chargeId:e}),n?.(),_()},[e,o,n,_]);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:S=>{S.stopPropagation(),i(k=>!k)}})}),r.jsxs(oe.Dropdown,{children:[r.jsx(oe.Label,{children:"Charge"}),r.jsx(oe.Item,{icon:r.jsx(Mn,{size:14}),onClick:()=>{b(!0),_()},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:S=>{S.stopPropagation(),C(!0),_()},children:"Insert Document"}),r.jsx(oe.Item,{icon:r.jsx(hr,{size:14}),onClick:S=>{S.stopPropagation(),E(!0),_()},children:"Upload Documents"}),s&&r.jsx(oe.Item,{icon:r.jsx(pn,{size:14}),onClick:S=>{S.stopPropagation(),j(!0),_()},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:S=>{S.stopPropagation(),_(),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:S=>{S.stopPropagation(),l(),_()},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:S=>{S.stopPropagation(),_(),x()},children:"Payroll file upload"})]})]})]}),r.jsx(yt,{withinPortal:!0,size:"xl",centered:!0,opened:c,onClose:d,title:"Depreciation",onClick:S=>S.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:S=>S.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:S=>S.stopPropagation(),children:r.jsx(Dl,{onDone:()=>{u(),n?.()},chargeId:e})}),r.jsx(Qa,{open:P,onOpenChange:E,onChange:n,chargeId:e}),r.jsx(_n,{chargeId:e,open:m,setOpen:j,onDone:()=>n?.()}),r.jsx(ru,{chargeId:v?e:void 0,close:()=>b(!1),onChange:()=>{b(!1),n?.()}}),r.jsx(ou,{chargeId:D?e:void 0,onChange:n,close:()=>C(!1)})]})}function Au(e){return Object.prototype.toString.call(e)==="[object Object]"}function es(e){return Au(e)||Array.isArray(e)}function Nu(){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 Tu(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 $u(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 Fu(e){return Math.round(e*100)/100}function Ct(e){return St(e).map(Number)}function Ae(e){return e[Et(e)]}function Et(e){return Math.max(0,e.length-1)}function Yn(e,t){return t===Et(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 ku(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 Mu(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 Ru(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 zu(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,P=["INPUT","SELECT","TEXTAREA"],E={passive:!1},_=wt(),O=wt(),S=nt(50,225).constrain(x.measure(20)),k={mouse:300,touch:400},y={mouse:500,touch:600},T=u?43:25;let Y=!1,z=0,B=0,le=!1,ae=!1,ne=!1,U=!1;function R(I){if(!b)return;function V(te){(un(b)||b(I,te))&&ie(te)}const G=t;_.add(G,"dragstart",te=>te.preventDefault(),E).add(G,"touchmove",()=>{},E).add(G,"touchend",()=>{}).add(G,"touchstart",V).add(G,"mousedown",V).add(G,"touchcancel",N).add(G,"contextmenu",N).add(G,"click",fe,!0)}function de(){_.clear(),O.clear()}function ue(){const I=U?n:t;O.add(I,"touchmove",Z,E).add(I,"touchend",N).add(I,"mousemove",Z,E).add(I,"mouseup",N)}function Ce(I){const V=I.nodeName||"";return P.includes(V)}function K(){return(u?y:k)[U?"mouse":"touch"]}function xe(I,V){const G=f.add(Wn(I)*-1),te=h.byDistance(I,!u).distance;return u||X(I)<S?te:j&&V?te*.5:h.byIndex(G.get(),0).distance}function ie(I){const V=$n(I,s);U=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(),z=a.readPoint(I),B=a.readPoint(I,D),g.emit("pointerDown")))}function Z(I){if(!$n(I,s)&&I.touches.length>=2)return N(I);const G=a.readPoint(I),te=a.readPoint(I,D),pe=vt(G,z),ce=vt(te,B);if(!ae&&!U&&(!I.cancelable||(ae=pe>ce,!ae)))return N(I);const ye=a.pointerMove(I);pe>m&&(ne=!0),d.useFriction(.3).useDuration(.75),c.start(),o.add(C(ye)),I.preventDefault()}function N(I){const G=h.byDistance(0,!1).index!==f.get(),te=a.pointerUp(I)*K(),pe=xe(C(te),G),ce=$u(te,pe),ye=T-10*ce,me=v+ce/50;ae=!1,le=!1,O.clear(),d.useDuration(ye).useFriction(me),l.distance(pe,!u),U=!1,g.emit("pointerUp")}function fe(I){ne&&(I.stopPropagation(),I.preventDefault(),ne=!1)}function ee(){return le}return{init:R,destroy:de,pointerDown:ee}}function Lu(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 Bu(){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 Vu(e){function t(s){return e*(s/100)}return{measure:t}}function Hu(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,P=s.indexOf(D.target),E=C?d:h[P],_=g(C?e:s[P]);if(X(_-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 Uu(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(),_=!l;let O=0;return _?(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,P}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,P}function C(E){return d=E,P}const P={direction:m,duration:u,velocity:j,seek:g,settled:x,useBaseFriction:b,useBaseDuration:v,useFriction:C,useDuration:D};return P}function Ku(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 Gu(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 qu(e,t,n){const s=t[0],o=n?s-e:Ae(t);return{limit:nt(o,s)}}function Wu(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 Yu(e){const{max:t,length:n}=e;function s(a){const i=a-t;return n?i/-n:0}return{get:s}}function Qu(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 Xu(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=Et(a)-Ae(j)[0]+1;return rs(D,Ae(j)[0])}return u})}return{slideRegistry:d}}function Ju(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,P=u+h(C,0);return{index:v,distance:P}}return{byDistance:g,byIndex:f,shortcut:h}}function Zu(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 ef(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=Fu(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 tf(e,t,n,s,o,a,i,c,l){const h=Ct(o),f=Ct(o).reverse(),g=v().concat(b());function x(_,O){return _.reduce((S,k)=>S-o[k],O)}function u(_,O){return _.reduce((S,k)=>x(S,O)>0?S.concat([k]):S,[])}function m(_){return a.map((O,S)=>({start:O-s[S]+.5+_,end:O+t-.5+_}))}function j(_,O,S){const k=m(O);return _.map(y=>{const T=S?0:-n,Y=S?n:0,z=S?"end":"start",B=k[y][z];return{index:y,loopPoint:B,slideLocation:xt(-1),translate:Uo(e,l[y]),target:()=>c.get()>B?T:Y}})}function v(){const _=i[0],O=u(f,_);return j(O,n,!1)}function b(){const _=t-i[0]-1,O=u(h,_);return j(O,-n,!0)}function D(){return g.every(({index:_})=>{const O=h.filter(S=>S!==_);return x(O,t)<=.1})}function C(){g.forEach(_=>{const{target:O,translate:S,slideLocation:k}=_,y=O();y!==k.get()&&(S.to(y),k.set(y))})}function P(){g.forEach(_=>_.translate.clear())}return{canLoop:D,clear:P,loop:C,loopPoints:g}}function nf(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 rf(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 sf(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 P=!D,E=Yn(C,D);return P?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 of(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 P=Ae(b)||0,E=P===0,_=D===Et(v),O=o[d]-a[P][d],S=o[d]-a[D][h],k=!s&&E?f(i):0,y=!s&&_?f(c):0,T=X(S-y-(O+k));return C&&T>t+l&&b.push(D),_&&b.push(v.length),b},[]).map((b,D,C)=>{const P=Math.max(C[D-1]||0);return v.slice(P,b)}):[]}function m(v){return g?x(v,n):u(v)}return{groupSlides:m}}function af(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:P,watchFocus:E}=a,_=2,O=Bu(),S=O.measure(t),k=n.map(O.measure),y=Ru(l,d),T=y.measureSize(S),Y=Vu(T),z=ku(c,T),B=!f&&!!b,le=f||!!b,{slideSizes:ae,slideSizesWithGaps:ne,startGap:U,endGap:R}=sf(y,S,k,n,le,o),de=of(y,T,j,f,S,k,U,R,_),{snaps:ue,snapsAligned:Ce}=Qu(y,z,S,k,de),K=-Ae(ue)+Ae(ne),{snapsContained:xe,scrollContainLimit:ie}=Gu(T,K,Ce,b,_),Z=B?xe:Ce,{limit:N}=qu(K,Z,f),fe=Ho(Et(Z),h,f),ee=fe.clone(),H=Ct(n),I=({dragHandler:Se,scrollBody:Xe,scrollBounds:Je,options:{loop:Ge}})=>{Ge||Je.constrain(Se.pointerDown()),Xe.seek()},V=({scrollBody:Se,translate:Xe,location:Je,offsetLocation:Ge,previousLocation:rt,scrollLooper:ft,slideLooper:pt,dragHandler:mt,animation:gt,eventHandler:Ot,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=Je.get()*Zn+rt.get()*(1-Zn);Ge.set(Jo),Jn&&(ft.loop(Se.direction()),pt.loop()),Xe.to(Ge.get()),nr&&Ot.emit("settle"),tr||Ot.emit("scroll")},G=Mu(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=Uu(ce,me,ye,ve,g,te),Re=Ju(f,Z,K,N,ve),ut=Zu(G,fe,ee,re,Re,ve,i),w=Yu(N),A=wt(),J=rf(t,n,i,m),{slideRegistry:se}=Xu(B,b,Z,ie,de,H),ge=ef(e,n,se,ut,re,A,i,E),ze={ownerDocument:s,ownerWindow:o,eventHandler:i,containerRect:S,slideRects:k,animation:G,axis:y,dragHandler:zu(y,e,s,o,ve,Lu(y,o),ce,G,ut,re,Re,fe,i,Y,x,u,v,te,P),eventStore:A,percentOfView:Y,index:fe,indexPrevious:ee,limit:N,location:ce,offsetLocation:me,previousLocation:ye,options:a,resizeHandler:Hu(t,i,o,n,y,D,O),scrollBody:re,scrollBounds:Ku(N,me,ve,re,Y),scrollLooper:Wu(K,N,me,[ce,me,ye,ve]),scrollProgress:w,scrollSnapList:Z.map(w.get),scrollSnaps:Z,scrollTarget:Re,scrollTo:ut,slideLooper:tf(y,T,K,ae,ne,ue,Z,me,n),slideFocus:ge,slidesHandler:nf(t,i,C),slidesInView:J,slideIndexes:H,slideRegistry:se,slidesToScroll:de,target:ve,translate:Uo(y,t)};return ze}function cf(){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 lf={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 df(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 uf(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=df(o),i=uf(a),c=wt(),l=cf(),{mergeOptions:d,optionsAtMedia:h,optionsMediaQueries:f}=a,{on:g,off:x,emit:u}=l,m=y;let j=!1,v,b=d(lf,nn.globalOptions),D=d(b),C=[],P,E,_;function O(){const{container:H,slides:I}=D;E=(Tn(H)?e.querySelector(H):H)||e.children[0];const G=Tn(I)?E.querySelectorAll(I):I;_=[].slice.call(G||E.children)}function S(H){const I=af(e,E,_,s,o,H,l);if(H.loop&&!I.slideLooper.canLoop()){const V=Object.assign({},H,{loop:!1});return S(V)}return I}function k(H,I){j||(b=d(b,H),D=h(b),C=I||C,O(),v=S(D),f([b,...C.map(({options:V})=>V)]).forEach(V=>c.add(V,"change",y)),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&&_.length&&v.dragHandler.init(ee),P=i.init(ee,C)))}function y(H,I){const V=de();T(),k(d({startIndex:V},H),I),l.emit("reInit")}function T(){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(),T(),l.emit("destroy"),l.clear())}function z(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();z(I,H,-1)}function le(H){const I=v.index.add(-1).get();z(I,H,1)}function ae(){return v.index.add(1).get()!==de()}function ne(){return v.index.add(-1).get()!==de()}function U(){return v.scrollSnapList}function R(){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 K(){return v.slidesInView.get(!1)}function xe(){return P}function ie(){return v}function Z(){return e}function N(){return E}function fe(){return _}const ee={canScrollNext:ae,canScrollPrev:ne,containerNode:N,internalEngine:ie,destroy:Y,off:x,on:g,emit:u,plugins:xe,previousScrollSnap:ue,reInit:m,rootNode:Z,scrollNext:B,scrollPrev:le,scrollProgress:R,scrollSnapList:U,scrollTo:z,selectedScrollSnap:de,slideNodes:fe,slidesInView:Ce,slidesNotInView:K};return k(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(()=>{Tu(s.current,t)||(s.current=t,l())},[t,l]),p.useEffect(()=>{if(Nu()&&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 ff={context:"[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context"},[pf,mf]=js(ff.context);var gf=Object.defineProperty,hf=Object.defineProperties,xf=Object.getOwnPropertyDescriptors,ss=Object.getOwnPropertySymbols,yf=Object.prototype.hasOwnProperty,vf=Object.prototype.propertyIsEnumerable,os=(e,t,n)=>t in e?gf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Sn=(e,t)=>{for(var n in t||(t={}))yf.call(t,n)&&os(e,n,t[n]);if(ss)for(var n of ss(t))vf.call(t,n)&&os(e,n,t[n]);return e},jf=(e,t)=>hf(e,xf(t)),bf=Qe((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=Ee({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=Ee({size:u==="max-width"?x.maxWidth:x.minWidth,sizes:e.breakpoints}),j=typeof x.slideGap>"u"?void 0:F(x.slideGap),v=Rs(m)-(u==="max-width"?1:0);return g[`@media (${u}: ${F(v)})`]=d(j),g},{}):null;return{root:{position:"relative"},viewport:{height:F(o),overflow:"hidden"},container:Sn(Sn({display:"flex",flexDirection:l?"row":"column",height:F(o)},d(c)),f),controls:{position:"absolute",zIndex:1,left:l?0:`calc(50% - ${F(t)} / 2)`,right:l?0:void 0,top:l?`calc(50% - ${F(t)} / 2)`:0,bottom:l?void 0:0,display:"flex",flexDirection:l?"row":"column",alignItems:"center",justifyContent:"space-between",paddingLeft:l?Ee({size:n,sizes:e.spacing}):void 0,paddingRight:l?Ee({size:n,sizes:e.spacing}):void 0,paddingTop:l?void 0:Ee({size:n,sizes:e.spacing}),paddingBottom:l?void 0:Ee({size:n,sizes:e.spacing}),pointerEvents:"none"},control:jf(Sn({display:"flex",justifyContent:"center",alignItems:"center",minWidth:F(t),minHeight:F(t),borderRadius:F(t),pointerEvents:"all",backgroundColor:e.white,color:e.black,boxShadow:e.shadows.md,opacity:e.colorScheme==="dark"?.65:.85,border:`${F(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:F(8),pointerEvents:"none"},indicator:{pointerEvents:"all",width:l?F(25):F(5),height:l?F(5):F(25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),Df=Object.defineProperty,as=Object.getOwnPropertySymbols,Cf=Object.prototype.hasOwnProperty,Sf=Object.prototype.propertyIsEnumerable,is=(e,t,n)=>t in e?Df(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,wn=(e,t)=>{for(var n in t||(t={}))Cf.call(t,n)&&is(e,n,t[n]);if(as)for(var n of as(t))Sf.call(t,n)&&is(e,n,t[n]);return e},wf=Qe((e,{size:t,gap:n,orientation:s,includeGapInSize:o,breakpoints:a=[]})=>{const i=(d,h)=>{const f=Ee({size:d,sizes:e.spacing}),g=F(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=Ee({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}: ${F(u)})`]=i(x,h.slideSize),d},{}):null;return{slide:wn(wn({position:"relative"},i(n,t)),l)}}),_f=Object.defineProperty,rn=Object.getOwnPropertySymbols,Ko=Object.prototype.hasOwnProperty,Go=Object.prototype.propertyIsEnumerable,cs=(e,t,n)=>t in e?_f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,If=(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},Ef=(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=Ef(n,["children","className","size","gap"]);const l=mf(),{classes:d,cx:h}=wf({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 $.createElement(Me,If({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,Pf=(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},Af=(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 Nf={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",Nf,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:P,includeGapInSize:E,draggable:_,dragFree:O,loop:S,speed:k,initialSlide:y,inViewThreshold:T,withControls:Y,withIndicators:z,plugins:B,nextControlIcon:le,previousControlIcon:ae,breakpoints:ne,skipSnaps:U,containScroll:R,withKeyboardEvents:de,variant:ue}=n,Ce=Af(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:K,cx:xe,theme:ie}=bf({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,N]=Qn({axis:b==="horizontal"?"x":"y",direction:b==="horizontal"?ie.dir:void 0,startIndex:y,loop:S,align:C,slidesToScroll:P,draggable:_,dragFree:O,speed:k,inViewThreshold:T,skipSnaps:U,containScroll:R},B),[fe,ee]=p.useState(0),[H,I]=p.useState(0),V=p.useCallback(re=>N&&N.scrollTo(re),[N]),G=p.useCallback(()=>{if(!N)return;const re=N.selectedScrollSnap();ee(re),l?.(re)},[N,ee]),te=p.useCallback(()=>{N?.scrollPrev(),c?.()},[N]),pe=p.useCallback(()=>{N?.scrollNext(),i?.()},[N]),ce=p.useCallback(re=>{de&&(re.key==="ArrowRight"&&(re.preventDefault(),pe()),re.key==="ArrowLeft"&&(re.preventDefault(),te()))},[N]);p.useEffect(()=>{if(N)return a?.(N),G(),I(N.scrollSnapList().length),N.on("select",G),()=>{N.off("select",G)}},[N,P]),p.useEffect(()=>{N&&(N.reInit(),I(N.scrollSnapList().length),ee(re=>Xa(re,0,p.Children.toArray(s).length-1)))},[p.Children.toArray(s).length,P]);const ye=N?.canScrollPrev()||!1,me=N?.canScrollNext()||!1,ve=Array(H).fill(0).map((re,Re)=>$.createElement(mn,{key:Re,"data-active":Re===fe||void 0,className:K.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>V(Re)}));return $.createElement(pf,{value:{slideGap:v,slideSize:j,embla:N,orientation:b,includeGapInSize:E,breakpoints:ne,classNames:x,styles:u,unstyled:m,variant:ue}},$.createElement(Me,Pf({className:xe(K.root,o),ref:t,onKeyDownCapture:ce},Ce),$.createElement("div",{className:K.viewport,ref:Z},$.createElement("div",{className:K.container},s)),z&&$.createElement("div",{className:K.indicators},ve),Y&&$.createElement("div",{className:K.controls},$.createElement(mn,{onClick:te,className:K.control,"aria-label":h,"data-inactive":!ye||void 0,tabIndex:ye?0:-1},typeof ae<"u"?ae:$.createElement(ar,{style:{transform:`rotate(${ls({dir:ie.dir,orientation:b,direction:"previous"})}deg)`}})),$.createElement(mn,{onClick:pe,className:K.control,"aria-label":d,"data-inactive":!me||void 0,tabIndex:me?0:-1},typeof le<"u"?le:$.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,Tf=({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:Ye.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:Ye.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?We(new Date(e),"dd/MM/yy"):void 0,s=t?We(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(W,{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(W,{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(W,{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(W,{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(W,{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(W,{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(W,{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(W,{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(W,{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(W,{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(W,{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(W,{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(W,{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 $f(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 Ff=({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:$f(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)})})]})},kf=({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},Mf=({transactionsProps:e,onChange:t})=>{const{transactions:n}=L(Gs,e);return r.jsx(to,{transactionsProps:n,onChange:t,enableEdit:!0})},Rf="createDeposit",zf=()=>{const[{fetching:e},t]=Te(ri),n=p.useCallback(async s=>{const o=`Error creating new deposit in currency ${s.currency}`,a=`${Rf}-${s.currency}`;M.loading("Creating deposit",{id:a});try{const i=await t(s),c=$e(i,o,a);if(c)return M.success("Deposit created",{id:a,description:`Deposit ${c.createDeposit.id} (${c.createDeposit.currency}) created successfully`}),c.createDeposit.id}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}return null},[t]);return{creating:e,createDeposit:n}},Lf=({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}=zf(),{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(W,{variant:"secondary",disabled:!h||l,onClick:b,children:l?"Assigning…":"Assign"})]}),r.jsx(W,{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,P])=>r.jsx(fr,{value:P,children:P},C))})]})]})}),r.jsx(ii,{children:r.jsx(W,{variant:"secondary",disabled:i,onClick:v,children:i?"Creating…":"Create"})})]})})]})};function Bf({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 Vf=({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(Bf,{row:e})})},`${e.id}-extensions`)]})},Hf=({business:e})=>e.id?r.jsx(bt,{to:Ye.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",{}),Uf=({date:e})=>r.jsx("p",{className:"text-sm font-medium",children:e?Ji(e):""}),Kf=({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))}),Gf=({taxCategory:e})=>r.jsx("p",{className:"text-sm font-medium",children:e?.name}),qf=({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(cu,{value:t*100,size:"sm"})}},{accessorKey:"type",header:({column:e})=>r.jsx(Le,{column:e,title:"Type"}),cell:({row:e})=>r.jsx(qf,{type:e.getValue("type")})},{accessorKey:"date",header:({column:e})=>r.jsx(Le,{column:e,title:"Date"}),cell:({row:e})=>r.jsx(Uf,{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(Hf,{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(Kf,{tags:e.getValue("tags")}),enableSorting:!1},{accessorKey:"taxCategoryName",header:({column:e})=>r.jsx(Le,{column:e,title:"Tax Category"}),cell:({row:e})=>r.jsx(Gf,{taxCategory:{id:e.original.taxCategoryId,name:e.original.taxCategoryName}})}];function Wf(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 Yf=({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=>Wf(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(nu,{selected:d,resetMerge:()=>l(null)}),r.jsxs(ui,{children:[r.jsx(fi,{asChild:!0,className:"ml-auto",children:r.jsxs(W,{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(Vf,{row:x},x.id)):r.jsx(Ve,{children:r.jsx(De,{colSpan:ms.length,className:"h-24 text-center",children:"No results."})})})]})})]})},Qf=({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(Yf,{originChargeId:e,chargesProps:s?.findChargeMatches.matches,onChange:n})})]})},Xf=({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)}`})]})})})]})},Jf=({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(Ei,{transaction:o})}),r.jsx(De,{children:r.jsx(Oi,{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},Zf=({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))})},ep="deleteMiscExpense",tp=()=>{const[{fetching:e},t]=Te(bi),n=p.useCallback(async s=>{const o="Error deleting misc expense",a=`${ep}-${s.id}`;M.loading("Deleting misc expense",{id:a});try{const i=await t(s),c=$e(i,o,a);if(c)return M.success("Success",{id:a,description:"Misc expense was deleted successfully"}),c.deleteMiscExpense}catch(i){console.error(`${o}: ${i}`),M.error("Error",{id:a,description:o,duration:1e5,closeButton:!0})}},[t]);return{fetching:e,deleteMiscExpense:n}};function np({miscExpenseId:e,onChange:t}){const{deleteMiscExpense:n}=tp();async function s(){try{await n({id:e}),t?.()}catch(o){const a="Failed to delete misc expense";console.error(`${a}: ${o}`),M.error("Error",{description:a})}}return r.jsx(on,{onConfirm:s,title:"Are you sure you want to delete this expense?",children:r.jsx(W,{className:"size-7.5 text-red-500",variant:"ghost",children:r.jsx(Rn,{className:"size-5"})})})}const rp=({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&&We(new Date(o.valueDate),"yyyy-MM-dd")})}),r.jsx("td",{children:r.jsx("div",{children:o.description})}),r.jsxs("td",{children:[r.jsx(su,{onDone:t,data:o}),r.jsx(np,{miscExpenseId:o.id,onChange:t})]})]},o?.id))})]})},sp=({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 op({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:Oe,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,P=m==="SalaryCharge",E=!!d?.miscExpenses?.length,_=d?.metadata?.openDocuments,O=(d?.totalAmount?.raw??0)>0&&!D,k=!(C||D)||!v;p.useEffect(()=>{v&&o(R=>R.includes("transactions")?R:[...R,"transactions"])},[v]),p.useEffect(()=>{b&&o(R=>R.includes("documents")?R:[...R,"documents"])},[b]),p.useEffect(()=>{j&&o(R=>R.includes("ledger")?R:[...R,"ledger"])},[j]),p.useEffect(()=>{P&&o(R=>R.includes("salaries")?R:[...R,"salaries"])},[P]),p.useEffect(()=>{E&&o(R=>R.includes("miscExpenses")?R:[...R,"miscExpenses"])},[E]);const y=be(Oe,zs,d),T=be(Oe,pr,d),Y=be(Oe,Zs,d),z=be(Oe,Gs,d),B=be(Oe,Xs,d),le=p.useMemo(()=>m==="ConversionCharge"&&be(Oe,Ws,d),[d,m]),ae=p.useMemo(()=>m==="FinancialCharge"&&be(Oe,Qs,d),[d,m]),ne=m==="SalaryCharge"&&be(Oe,Js,d),U=p.useMemo(()=>m==="CreditcardBankCharge"&&be(Oe,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(Oe,Ks,d)&&r.jsx(kf,{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(Xf,{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(Zf,{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:z&&r.jsx(Mf,{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(rp,{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(W,{onClick:R=>{R.stopPropagation(),l()},variant:"outline",disabled:!y,size:"icon",className:"size-7.5 text-gray-500",children:r.jsx(Di,{className:"size-5"})})}),"Documents"]}),_&&r.jsx(_n,{chargeId:d.id})]})}),r.jsx(he,{children:T&&r.jsx(qs,{documentsProps:L(pr,d)?.additionalDocuments,onChange:u})})]}),m==="SalaryCharge"&&r.jsxs(_e,{value:"salaries",children:[r.jsx(Ie,{disabled:!P,children:"Salaries"}),r.jsx(he,{children:ne&&r.jsx(sp,{salaryRecordsProps:d})})]}),d.__typename==="BusinessTripCharge"&&r.jsxs(_e,{value:"businessTrip",children:[r.jsx(Ie,{children:"Business Trip"}),r.jsx(he,{children:r.jsx(il,{data:d.businessTrip})})]}),m==="CreditcardBankCharge"&&r.jsxs(_e,{value:"creditcard",children:[r.jsx(Ie,{children:"CreditCard Transactions"}),r.jsx(he,{children:U&&r.jsx(Jf,{chargeProps:d})})]}),j&&r.jsxs(_e,{value:"ledger",children:[r.jsx(Ie,{disabled:!j,onClick:R=>{R.stopPropagation()},children:r.jsxs("div",{className:"flex flex-row items-center gap-2 justify-start w-full",children:[!d.metadata?.isLedgerLocked&&r.jsx(fl,{chargeId:d.id,onChange:u,variant:"outline"}),"Ledger Records"]})}),r.jsx(he,{children:Y&&r.jsx(ap,{data:d})})]}),m==="BankDepositCharge"&&r.jsxs(_e,{value:"bankDeposit",children:[r.jsx(Ie,{children:"Bank Deposit"}),r.jsx(he,{children:r.jsx(Lf,{chargeId:d.id})})]}),k&&r.jsx(Qf,{chargeId:d.id,onChange:u,isOpened:s.includes("charges-matches")})]}),y&&r.jsx(Me,{maw:"1/6",children:r.jsx(co,{in:c,transitionDuration:500,transitionTimingFunction:"linear",children:r.jsx(Tf,{chargeProps:d,onChange:u})})})]}),!g&&!d&&r.jsx("p",{children:"Error fetching extended information for this charge"})]})}const ap=({data:e})=>{const{ledger:t}=L(Zs,e);return r.jsx(Ff,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},ip=({toggleMergeCharge:e,isSelectedForMerge:t,data:n,isAllOpened:s})=>{const[o,a]=p.useState(!1),[i,c]=p.useState(L(Ze,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(Ze,u))},[l]),p.useEffect(()=>{c(L(Ze,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(yu,{data:i}),r.jsx(pu,{data:i}),r.jsx(du,{data:i}),r.jsx(vu,{data:i}),be(Ze,Is,i)?r.jsx(fu,{data:i}):r.jsx("td",{}),r.jsx(mu,{data:i,onChange:f}),be(Ze,As,i)?r.jsx(hu,{data:i,onChange:f}):r.jsx("td",{}),be(Ze,Ns,i)?r.jsx(xu,{data:i}):r.jsx("td",{}),be(Ze,_s,i)?r.jsx(uu,{data:i}):r.jsx("td",{}),r.jsx(gu,{data:i}),r.jsx(lu,{data:i,onChange:f}),r.jsx("td",{children:r.jsx("div",{className:"flex flex-col gap-2",children:e&&r.jsx(pl,{toggleMergeSelected:()=>e(f),mergeSelected:t})})}),r.jsx("td",{children:r.jsxs("div",{className:"flex flex-col gap-2",children:[r.jsx(Pu,{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(op,{chargeID:i.id,onChange:f,fetching:d})})})})]})},yp=({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(ip,{data:a,toggleMergeCharge:e?i=>e(a.id,i):void 0,isSelectedForMerge:t?.has(a.id)??!1,isAllOpened:s},a.id))})]})};export{yp as C,Ff as L,nu as M,Hn as T,pl as a,op as b,Ji as f};