UNPKG

@accounter/client

Version:
1 lines • 96.2 kB
import{s as e}from"./dist-BBBZL-zT.js";import{i as t,o as n,t as r}from"./utils-C9b7NsUD.js";import{$i as i,Aa as a,Dn as o,Fn as s,Gn as c,Hn as l,In as u,Jn as d,Kt as f,Mn as p,O as m,Qt as h,Xt as g,Yt as _,Zi as v,Zn as y,Zt as b,_o as x,an as S,cn as C,dn as w,ea as ee,ei as T,fn as E,gn as D,go as O,h as te,hn as ne,hr as k,in as re,jo as ie,ln as A,mn as ae,mr as oe,nr as se,on as ce,pn as j,qr as M,qt as N,r as P,ra as F,rn as le,rt as I,sn as ue,t as de,tn as fe,un as pe,vi as me}from"./error-handling-DBz7h-2r.js";import{a as he,s as L,t as R}from"./routes-g2AjKuLo.js";import{a as ge,c as _e,d as ve,dt as ye,f as be,ft as z,gt as xe,ht as Se,i as Ce,mt as B,n as we,o as Te,r as Ee,s as De,t as Oe,u as ke}from"./select-D_LnCowF.js";import{$ as Ae,Ar as je,Br as Me,Cn as Ne,Dn as Pe,En as Fe,Ft as Ie,Ht as Le,It as Re,Jt as ze,Kt as Be,Lt as Ve,Mt as He,Nt as Ue,O as We,Or as Ge,Q as Ke,Qn as qe,Rt as Je,Sn as Ye,Sr as Xe,Tn as Ze,Wt as Qe,Xt as $e,Yr as et,Yt as tt,Zn as nt,Zr as rt,_t as it,an as at,ar as ot,at as st,bn as V,br as ct,bt as lt,cn as ut,er as dt,et as ft,ft as pt,gn as mt,gt as ht,hn as gt,it as _t,kr as vt,l as yt,lr as bt,m as xt,mt as St,n as Ct,nr as wt,on as Tt,ot as Et,pn as Dt,pt as Ot,r as kt,rt as At,sn as jt,t as Mt,tt as Nt,v as Pt,wn as Ft,x as It,xn as Lt,yn as Rt,zr as zt,zt as Bt}from"./common-3l1_jDFS.js";import{n as Vt,t as Ht}from"./bank-deposits-C_842xdV.js";import{c as Ut,h as Wt,l as Gt,m as Kt,u as qt,x as Jt}from"./separator-CH02FkEe.js";import{c as Yt,t as H}from"./button-DATCl8sW.js";import{i as U,n as W,r as G,t as Xt}from"./accordion-BTjkCjsR.js";import{n as Zt,o as Qt,t as $t}from"./card-D1mbhL3p.js";import{A as en,C as tn,D as nn,E as rn,G as K,S as an,T as on,W as sn,Y as cn,_ as q,a as ln,c as un,f as dn,g as J,h as fn,i as pn,it as mn,k as hn,m as gn,n as _n,o as vn,p as yn,q as Y,r as X,s as bn,t as xn,u as Sn,w as Cn,x as wn}from"./table-CZ9XLwX9.js";import{t as Tn}from"./Card-BUij8DOU.js";import{a as En,c as Dn,i as On,n as kn,o as An,r as jn,s as Mn,t as Nn}from"./transactions-table-BwYVZjyw.js";var Pn=xe(`arrow-down-wide-narrow`,[[`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`}]]),Fn=xe(`file-plus-corner`,[[`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`}]]),Z=e(n()),In=e(ie()),Ln=Object.defineProperty,Rn=Object.defineProperties,zn=Object.getOwnPropertyDescriptors,Bn=Object.getOwnPropertySymbols,Vn=Object.prototype.hasOwnProperty,Hn=Object.prototype.propertyIsEnumerable,Un=(e,t,n)=>t in e?Ln(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Wn=(e,t)=>{for(var n in t||={})Vn.call(t,n)&&Un(e,n,t[n]);if(Bn)for(var n of Bn(t))Hn.call(t,n)&&Un(e,n,t[n]);return e},Gn=(e,t)=>Rn(e,zn(t)),Kn=(e,t)=>{var n={};for(var r in e)Vn.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Bn)for(var r of Bn(e))t.indexOf(r)<0&&Hn.call(e,r)&&(n[r]=e[r]);return n};function qn(e){if(!e||typeof e==`string`)return 0;let t=e/36;return Math.round((4+15*t**.25+t/5)*10)}function Jn(e){return e?.current?e.current.scrollHeight:`auto`}var Yn=typeof window<`u`&&window.requestAnimationFrame;function Xn({transitionDuration:e,transitionTimingFunction:t=`ease`,onTransitionEnd:n=()=>{},opened:r}){let i=(0,Z.useRef)(null),a={display:`none`,height:0,overflow:`hidden`},[o,s]=(0,Z.useState)(r?{}:a),c=e=>{(0,In.flushSync)(()=>s(e))},l=e=>{c(t=>Wn(Wn({},t),e))};function u(n){return{transition:`height ${e||qn(n)}ms ${t}`}}rn(()=>{Yn(r?()=>{l({willChange:`height`,display:`block`,overflow:`hidden`}),Yn(()=>{let e=Jn(i);l(Gn(Wn({},u(e)),{height:e}))})}:()=>{let e=Jn(i);l(Gn(Wn({},u(e)),{willChange:`height`,height:e})),Yn(()=>l({height:0,overflow:`hidden`}))})},[r]);let d=e=>{if(!(e.target!==i.current||e.propertyName!==`height`))if(r){let e=Jn(i);e===o.height?c({}):l({height:e}),n()}else o.height===0&&(c(a),n())};function f(e={}){var t=e,{style:n={},refKey:a=`ref`}=t,s=Kn(t,[`style`,`refKey`]);let c=s[a];return Gn(Wn({"aria-hidden":!r},s),{[a]:wt(i,c),onTransitionEnd:d,style:Wn(Wn({boxSizing:`border-box`},n),o)})}return f}var Zn=Object.defineProperty,Qn=Object.getOwnPropertySymbols,$n=Object.prototype.hasOwnProperty,er=Object.prototype.propertyIsEnumerable,tr=(e,t,n)=>t in e?Zn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nr=(e,t)=>{for(var n in t||={})$n.call(t,n)&&tr(e,n,t[n]);if(Qn)for(var n of Qn(t))er.call(t,n)&&tr(e,n,t[n]);return e},rr=(e,t)=>{var n={};for(var r in e)$n.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Qn)for(var r of Qn(e))t.indexOf(r)<0&&er.call(e,r)&&(n[r]=e[r]);return n},ir={transitionDuration:200,transitionTimingFunction:`ease`,animateOpacity:!0},ar=(0,Z.forwardRef)((e,t)=>{let n=hn(`Collapse`,ir,e),{children:r,in:i,transitionDuration:a,transitionTimingFunction:o,style:s,onTransitionEnd:c,animateOpacity:l}=n,u=rr(n,[`children`,`in`,`transitionDuration`,`transitionTimingFunction`,`style`,`onTransitionEnd`,`animateOpacity`]),d=en(),f=dt(),p=d.respectReducedMotion&&f?0:a,{systemStyles:m,rest:h}=on(u),g=Xn({opened:i,transitionDuration:p,transitionTimingFunction:o,onTransitionEnd:c});return p===0?i?Z.createElement(Cn,nr({},h),r):null:Z.createElement(Cn,nr({},g(nr(nr({style:s,ref:t},h),m))),Z.createElement(`div`,{style:{opacity:i||!l?1:0,transition:l?`opacity ${p}ms ${o}`:`none`}},r))});ar.displayName=`@mantine/core/Collapse`;var or=Object.defineProperty,sr=Object.defineProperties,cr=Object.getOwnPropertyDescriptors,lr=Object.getOwnPropertySymbols,ur=Object.prototype.hasOwnProperty,dr=Object.prototype.propertyIsEnumerable,fr=(e,t,n)=>t in e?or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,pr=(e,t)=>{for(var n in t||={})ur.call(t,n)&&fr(e,n,t[n]);if(lr)for(var n of lr(t))dr.call(t,n)&&fr(e,n,t[n]);return e},mr=(e,t)=>sr(e,cr(t)),hr=[`light`,`filled`,`outline`,`dot`,`gradient`],gr={xs:{fontSize:Y(9),height:Y(16)},sm:{fontSize:Y(10),height:Y(18)},md:{fontSize:Y(11),height:Y(20)},lg:{fontSize:Y(13),height:Y(26)},xl:{fontSize:Y(16),height:Y(32)}},_r={xs:Y(4),sm:Y(4),md:Y(6),lg:Y(8),xl:Y(10)};function vr({theme:e,variant:t,color:n,size:r,gradient:i}){if(!hr.includes(t))return null;if(t===`dot`){let t=K({size:r,sizes:_r});return{backgroundColor:`transparent`,color:e.colorScheme===`dark`?e.colors.dark[0]:e.colors.gray[7],border:`${Y(1)} solid ${e.colorScheme===`dark`?e.colors.dark[3]:e.colors.gray[3]}`,paddingLeft:`calc(${K({size:r,sizes:e.spacing})} / 1.5 - ${t} / 2)`,"&::before":{content:`""`,display:`block`,width:t,height:t,borderRadius:t,backgroundColor:e.fn.themeColor(n,e.colorScheme===`dark`?4:e.fn.primaryShade(`light`),!0),marginRight:t}}}let a=e.fn.variant({color:n,variant:t,gradient:i});return{background:a.background,color:a.color,border:`${Y(t===`gradient`?0:1)} solid ${a.border}`}}var yr=nn((e,{color:t,radius:n,gradient:r,fullWidth:i},{variant:a,size:o})=>{let{fontSize:s,height:c}=o in gr?gr[o]:gr.md;return{leftSection:{marginRight:`calc(${e.spacing.xs} / 2)`},rightSection:{marginLeft:`calc(${e.spacing.xs} / 2)`},inner:{whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`},root:pr(mr(pr(pr({},e.fn.focusStyles()),e.fn.fontStyles()),{fontSize:s,height:c,WebkitTapHighlightColor:`transparent`,lineHeight:`calc(${c} - ${Y(2)})`,textDecoration:`none`,padding:`0 calc(${K({size:o,sizes:e.spacing})} / 1.5)`,boxSizing:`border-box`,display:i?`flex`:`inline-flex`,alignItems:`center`,justifyContent:`center`,width:i?`100%`:`auto`,textTransform:`uppercase`,borderRadius:e.fn.radius(n),fontWeight:700,letterSpacing:Y(.25),cursor:`inherit`,textOverflow:`ellipsis`,overflow:`hidden`}),vr({theme:e,variant:a,color:t,size:o,gradient:r}))}}),br=Object.defineProperty,xr=Object.getOwnPropertySymbols,Sr=Object.prototype.hasOwnProperty,Cr=Object.prototype.propertyIsEnumerable,wr=(e,t,n)=>t in e?br(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tr=(e,t)=>{for(var n in t||={})Sr.call(t,n)&&wr(e,n,t[n]);if(xr)for(var n of xr(t))Cr.call(t,n)&&wr(e,n,t[n]);return e},Er=(e,t)=>{var n={};for(var r in e)Sr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&xr)for(var r of xr(e))t.indexOf(r)<0&&Cr.call(e,r)&&(n[r]=e[r]);return n},Dr={variant:`light`,size:`md`,radius:`xl`},Or=(0,Z.forwardRef)((e,t)=>{let n=hn(`Badge`,Dr,e),{className:r,color:i,variant:a,fullWidth:o,children:s,size:c,leftSection:l,rightSection:u,radius:d,gradient:f,classNames:p,styles:m,unstyled:h}=n,g=Er(n,[`className`,`color`,`variant`,`fullWidth`,`children`,`size`,`leftSection`,`rightSection`,`radius`,`gradient`,`classNames`,`styles`,`unstyled`]),{classes:_,cx:v}=yr({fullWidth:o,color:i,radius:d,gradient:f},{classNames:p,styles:m,name:`Badge`,unstyled:h,variant:a,size:c});return Z.createElement(Cn,Tr({className:v(_.root,r),ref:t},g),l&&Z.createElement(`span`,{className:_.leftSection},l),Z.createElement(`span`,{className:_.inner},s),u&&Z.createElement(`span`,{className:_.rightSection},u))});Or.displayName=`@mantine/core/Badge`;var kr=cn(Or),Ar=Object.defineProperty,jr=Object.defineProperties,Mr=Object.getOwnPropertyDescriptors,Nr=Object.getOwnPropertySymbols,Pr=Object.prototype.hasOwnProperty,Fr=Object.prototype.propertyIsEnumerable,Ir=(e,t,n)=>t in e?Ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Lr=(e,t)=>{for(var n in t||={})Pr.call(t,n)&&Ir(e,n,t[n]);if(Nr)for(var n of Nr(t))Fr.call(t,n)&&Ir(e,n,t[n]);return e},Rr=(e,t)=>jr(e,Mr(t)),zr={xs:Y(16),sm:Y(20),md:Y(26),lg:Y(32),xl:Y(40)},Br=[`filled`,`light`,`gradient`,`outline`,`default`];function Vr({theme:e,variant:t,color:n,gradient:r}){if(!Br.includes(t))return null;let i=e.fn.variant({variant:t,color:n||e.primaryColor,gradient:r,primaryFallback:!1});return{backgroundColor:i.background,color:i.color,backgroundImage:t===`gradient`?i.background:void 0,border:`${Y(t===`gradient`?0:1)} solid ${i.border}`}}var Hr=nn((e,{color:t,radius:n,gradient:r},{variant:i,size:a})=>{let o=K({size:a,sizes:zr});return{root:Lr(Rr(Lr({},e.fn.fontStyles()),{display:`inline-flex`,alignItems:`center`,justifyContent:`center`,boxSizing:`border-box`,width:o,height:o,minWidth:o,minHeight:o,borderRadius:e.fn.radius(n)}),Vr({theme:e,variant:i,gradient:r,color:t}))}}),Ur=Object.defineProperty,Wr=Object.getOwnPropertySymbols,Gr=Object.prototype.hasOwnProperty,Kr=Object.prototype.propertyIsEnumerable,qr=(e,t,n)=>t in e?Ur(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Jr=(e,t)=>{for(var n in t||={})Gr.call(t,n)&&qr(e,n,t[n]);if(Wr)for(var n of Wr(t))Kr.call(t,n)&&qr(e,n,t[n]);return e},Yr=(e,t)=>{var n={};for(var r in e)Gr.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Wr)for(var r of Wr(e))t.indexOf(r)<0&&Kr.call(e,r)&&(n[r]=e[r]);return n},Xr={size:`md`,variant:`filled`},Zr=(0,Z.forwardRef)((e,t)=>{let n=hn(`ThemeIcon`,Xr,e),{className:r,size:i,radius:a,variant:o,color:s,children:c,gradient:l,unstyled:u}=n,d=Yr(n,[`className`,`size`,`radius`,`variant`,`color`,`children`,`gradient`,`unstyled`]),{classes:f,cx:p}=Hr({variant:o,radius:a,color:s,gradient:l},{name:`ThemeIcon`,unstyled:u,variant:o,size:i});return Z.createElement(Cn,Jr({className:p(f.root,r),ref:t},d),c)});Zr.displayName=`@mantine/core/ThemeIcon`;var Q=t();function Qr({data:e,onChange:t}){let n=J(le,e),[r,i]=(0,Z.useState)(n.accountantApproval);return(0,Z.useEffect)(()=>{r==null&&n.accountantApproval!=null&&i(n.accountantApproval)},[r,n.accountantApproval]),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(Et,{chargeId:n.id,value:r,onChange:t})})}var $r=({data:e})=>{let t=J(re,e),[n,r]=(0,Z.useState)(!0),[i,a]=(0,Z.useState)(!0),o=`validCreditCardAmount`in t?t.validCreditCardAmount:null;return(0,Z.useEffect)(()=>{t.__typename===`CreditcardBankCharge`&&(a(o==null),o!=null&&r(o))},[t.__typename,o]),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Ye,{inline:!0,size:12,disabled:n,processing:i,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(`p`,{className:(t.totalAmount?.raw??0)>0?`whitespace-nowrap text-green-700`:`whitespace-nowrap text-red-500`,children:t.totalAmount?.formatted})})})})},ei=({data:e})=>{let t=J(S,e);return`businessTrip`in t?(0,Q.jsx)(`td`,{children:(0,Q.jsx)(L,{to:t.businessTrip?.id?R.BUSINESS_TRIPS.DETAIL(t.businessTrip?.id):R.BUSINESS_TRIPS.ROOT,target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:t.businessTrip?.name})}):(0,Q.jsx)(`td`,{})},ti=({data:e})=>{let{counterparty:t,validationData:n,__typename:r}=J(C,e),i=![`BusinessTripCharge`,`DividendCharge`,`ConversionCharge`,`SalaryCharge`,`InternalTransferCharge`].includes(r)&&n?.missingInfo?.includes(T.Counterparty),{name:a,id:o}=t??{name:`Missing`,id:void 0};return(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex flex-wrap`,children:(0,Q.jsxs)(Ye,{inline:!0,size:12,disabled:!i,color:`red`,zIndex:`auto`,children:[!i&&o&&(0,Q.jsx)(L,{to:R.BUSINESSES.DETAIL(o),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:a}),i&&a]})})})},ni=({data:e})=>{let{minDebitDate:t,minEventDate:n,minDocumentsDate:r}=J(ce,e),i=t||n||r;return(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:i&&mn(new Date(i),`dd/MM/yy`)})})},ri=({data:e,onChange:t})=>{let[n,r]=(0,Z.useState)(!1),i=J(ue,e),a=i.validationData?.missingInfo?.includes(T.Description),o=a&&!!i.missingInfoSuggestions?.description?.trim().length,{userDescription:s,id:c}=i,l=s&&s?.trim()!==``?s:i.missingInfoSuggestions?.description?i.missingInfoSuggestions.description:`Missing`,{updateCharge:u,fetching:d}=Bt(),f=(0,Z.useCallback)(async e=>{e!==void 0&&(await u({chargeId:c,fields:{userDescription:e}}),r(!0))},[c,u]);return(0,Q.jsxs)(`td`,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap`,children:[(0,Q.jsx)(`div`,{className:`flex flex-col justify-center`,children:(0,Q.jsx)(Ye,{inline:!0,size:12,disabled:!a,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(`p`,{className:o?`bg-yellow-400`:void 0,children:l})})}),o&&(0,Q.jsx)(Tt,{onClick:e=>{e.stopPropagation(),f(i.missingInfoSuggestions.description)},disabled:d})]}),(0,Q.jsx)(yt,{chargeId:c,description:i.missingInfoSuggestions?.description??void 0,open:n,onOpenChange:r,onClose:t})]})},ii=({data:e})=>{let{metadata:t,validationData:n,id:r,__typename:i}=J(w,e),a=(0,Z.useMemo)(()=>{switch(i){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}},[i]),o=(0,Z.useMemo)(()=>{switch(i){case`FinancialCharge`:return!1;default:return!0}},[i]),s=(0,Z.useMemo)(()=>o&&n?.missingInfo?.includes(T.Transactions),[o,n?.missingInfo]),c=(0,Z.useMemo)(()=>a&&n?.missingInfo?.includes(T.Documents),[a,n?.missingInfo]),l=(0,Z.useMemo)(()=>!t?.invalidLedger,[t?.invalidLedger]),u=(0,Z.useMemo)(()=>t?.invalidLedger,[t?.invalidLedger]);return(0,Q.jsx)(`td`,{children:(0,Q.jsx)(pt,{chargeId:r,children:(0,Q.jsx)(st,{items:(0,Z.useMemo)(()=>{let e=[];return(s||t?.transactionsCount||o)&&e.push({extraClassName:t?.transactionsCount||!o?void 0:`bg-yellow-400`,content:(0,Q.jsx)(Ye,{inline:!0,size:12,disabled:!s,color:`red`,zIndex:`auto`,children:(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[`Transactions: `,t?.transactionsCount??0]})},`transactions`)}),e.push({content:(0,Q.jsx)(Ye,{inline:!0,size:12,processing:l,disabled:u===`VALID`,color:u===`DIFF`?`orange`:`red`,zIndex:`auto`,children:(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[`Ledger Records: `,t?.ledgerCount??0]})},`ledger`)}),(c||t?.documentsCount)&&e.push({content:(0,Q.jsx)(Ye,{inline:!0,size:12,disabled:!c,color:`red`,zIndex:`auto`,children:(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[`Documents: `,t?.documentsCount??0]})},`documents`),extraClassName:!n?.missingInfo?.includes(T.Documents)||!a?void 0:`bg-yellow-400`}),t?.miscExpensesCount&&e.push({content:(0,Q.jsxs)(`div`,{className:`whitespace-nowrap`,children:[`Misc Expenses: `,t?.miscExpensesCount??0]})}),e},[t?.transactionsCount,t?.ledgerCount,t?.documentsCount,t?.miscExpensesCount,a,o,s,c,n?.missingInfo,u,l])})})})},ai=({data:e,onChange:t})=>{let{tags:n,id:r,validationData:i,missingInfoSuggestions:a}=J(j,e),{updateCharge:o,fetching:s}=Bt(),[c,l]=(0,Z.useState)(n??[]),[u,d]=(0,Z.useState)(!1),f=i?.missingInfo?.includes(T.Tags),p=f&&!!a?.tags?.length;(0,Z.useEffect)(()=>{n?.length&&!c.length&&l(n)},[n,c.length]),(0,Z.useEffect)(()=>{c.length===0&&p&&l(a?.tags??[])},[c.length,p,a?.tags]);let m=(0,Z.useCallback)(async e=>{await o({chargeId:r,fields:{tags:e?.map(e=>({id:e.id}))}}),d(!0)},[r,o,d]);return(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(Ye,{inline:!0,size:12,disabled:!f,color:`red`,zIndex:`auto`,children:(0,Q.jsx)(st,{items:c.map(e=>(0,Q.jsx)(Ne,{children:(0,Q.jsxs)(`div`,{children:[e.namePath&&(0,Q.jsx)(an,{size:`xs`,opacity:.65,children:`${e.namePath.join(` > `)} >`}),(0,Q.jsx)(an,{size:`sm`,children:e.name})]})},e.id)),extraClassName:p?`bg-yellow-400`:void 0})}),p&&(0,Q.jsx)(Tt,{onClick:e=>{e.stopPropagation(),m(a.tags)},disabled:s}),(0,Q.jsx)(yt,{chargeId:r,tagIds:a?.tags?.map(e=>({id:e.id})),open:u,onOpenChange:d,onClose:t})]})},oi=({data:e})=>{let{validationData:t,taxCategory:n,__typename:r}=J(ae,e),i=(0,Z.useMemo)(()=>{switch(r){case`DividendCharge`:case`InternalTransferCharge`:case`SalaryCharge`:case`BankDepositCharge`:case`ForeignSecuritiesCharge`:return!1;default:return!0}},[r]),a=(0,Z.useMemo)(()=>t?.missingInfo?.includes(T.TaxCategory),[t?.missingInfo]);return i?(0,Q.jsx)(`td`,{children:(0,Q.jsx)(Ye,{inline:!0,size:12,disabled:!a,color:`red`,zIndex:`auto`,children:n?.name??`N/A`})}):(0,Q.jsx)(`td`,{})},si=({data:e})=>{let{__typename:t}=J(ne,e),{text:n,icon:r}=(0,Z.useMemo)(()=>({text:je(t),icon:vt(t)}),[t]);return(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(`div`,{children:n}),(0,Q.jsx)(Zr,{radius:`xl`,size:`xl`,children:r})]})},ci=({data:e})=>{let{vat:t,totalAmount:n,validationData:r,__typename:i}=J(D,e),a=(0,Z.useMemo)(()=>r?.missingInfo?.includes(T.Vat),[r?.missingInfo]),o=(0,Z.useMemo)(()=>!t&&n?.currency===u.Ils,[t,n?.currency]),s=(0,Z.useMemo)(()=>(t?.raw??0)>0&&(n?.raw??0)<0||(t?.raw??0)<0&&(n?.raw??0)>0,[t?.raw,n?.raw]),c=o||s;return(0,Z.useMemo)(()=>{switch(i){case`BusinessTripCharge`:case`DividendCharge`:case`ConversionCharge`:case`SalaryCharge`:case`InternalTransferCharge`:case`BankDepositCharge`:case`ForeignSecuritiesCharge`:case`CreditcardBankCharge`:return!1;default:return!0}},[i])?(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:c?`whitespace-nowrap text-red-500`:`whitespace-nowrap text-green-700`,children:(0,Q.jsx)(Ye,{inline:!0,size:12,disabled:!a,color:`red`,zIndex:`auto`,children:t?.formatted})})}):(0,Q.jsx)(`td`,{})},li=`insertDepreciationRecord`,ui=()=>{let[{fetching:e},t]=O(te);return{fetching:e,addDepreciationRecord:(0,Z.useCallback)(async e=>{let n=`Error adding depreciation record`,r=li;P.loading(`Adding depreciation record`,{id:r});try{let i=de(await t(e),n,r,`insertDepreciationRecord`);if(i)return P.success(`Success`,{id:r,description:`Depreciation record was added`}),i.insertDepreciationRecord}catch(e){console.error(`${n}: ${e}`),P.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function di(e){let{chargeId:t,onAdd:n}=e,[r,i]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(ht,{content:`Add Depreciation Record`,children:(0,Q.jsx)(H,{variant:`outline`,size:`icon`,className:`size-7.5`,onClick:e=>{e.stopPropagation(),i(!0)},children:(0,Q.jsx)(Jt,{className:`size-5`})})}),r&&(0,Q.jsx)(fi,{chargeId:t,opened:r,close:()=>i(!1),onAdd:n})]})}function fi({chargeId:e,opened:t,close:n,onAdd:r}){let i=Qe({defaultValues:{chargeId:e}}),{control:a,handleSubmit:o}=i,[s,c]=(0,Z.useState)(!1),[{data:l,fetching:u}]=x({query:m}),{addDepreciationRecord:d,fetching:f}=ui(),p=e=>{d({fields:e}).then(()=>{r?.(),n()})},h=l?.depreciationCategories?.map(e=>({value:e.id,label:e.name}))??[];return(0,Z.useEffect)(()=>{c(!!(u||f))},[u,f]),(0,Q.jsxs)(Rt,{opened:t,onClose:n,centered:!0,lockScroll:!0,children:[(0,Q.jsx)(Rt.Title,{children:`Add Depreciation Record`}),(0,Q.jsx)(Rt.Body,{children:(0,Q.jsx)(He,{...i,children:(0,Q.jsxs)(`form`,{onSubmit:o(p),children:[(0,Q.jsx)(Ie,{name:`activationDate`,control:a,rules:{pattern:{value:Ge,message:`Date must be in format yyyy-mm-dd`}},render:({field:e,fieldState:t})=>(0,Q.jsxs)(Re,{className:`h-min`,children:[(0,Q.jsx)(Ve,{htmlFor:`activation-date`,children:`Activation Date`}),(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ot,{id:`activation-date`,value:e.value??void 0,onChange:t=>{t!==e.value&&e.onChange(t)},"aria-invalid":!!t.error})}),(0,Q.jsx)(Je,{})]})}),(0,Q.jsx)(Le,{name:`amount`,control:a,render:({field:e,fieldState:t})=>(0,Q.jsx)(Le,{name:`currency`,control:a,render:({field:n,fieldState:r})=>(0,Q.jsx)(St,{...e,value:e.value??void 0,error:t.error?.message||r.error?.message,label:`Amount`,currencyCodeProps:{...n,label:`Currency`}})})}),(0,Q.jsx)(Le,{name:`categoryId`,control:a,render:({field:e,fieldState:t})=>(0,Q.jsx)(mt,{...e,disabled:u,data:h,label:`Category`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message,withinPortal:!0})}),(0,Q.jsx)(Le,{name:`type`,control:a,render:({field:e,fieldState:t})=>(0,Q.jsx)(mt,{...e,data:bi,value:e.value,label:`Type`,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message,withinPortal:!0})}),(0,Q.jsx)(`div`,{className:`flex justify-center mt-5 gap-3`,children:(0,Q.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||s)&&(0,Q.jsx)(Ze,{blur:1,center:!0,children:(0,Q.jsx)(tn,{})})]})}var pi=`updateDepreciationRecord`,mi=()=>{let[{fetching:e},t]=O(a);return{fetching:e,updateDepreciationRecord:(0,Z.useCallback)(async e=>{let n=`Error updating depreciation record`,r=pi;P.loading(`Updating depreciation record`,{id:r});try{let i=de(await t(e),n,r,`updateDepreciationRecord`);if(i)return P.success(`Success`,{id:r,description:`Depreciation record was updated`}),i.updateDepreciationRecord}catch(e){console.error(`${n}: ${e}`),P.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}},hi=`deleteDepreciationRecord`,gi=()=>{let[{fetching:e},t]=O(l);return{fetching:e,deleteDepreciationRecord:(0,Z.useCallback)(async e=>{let n=`Error deleting depreciation record`,r=`${hi}-${e.depreciationRecordId}`;P.loading(`Deleting depreciation record`,{id:r});try{let i=de(await t(e),n,r);if(i)return P.success(`Success`,{id:r,description:`Depreciation record was deleted`}),i.deleteDepreciationRecord}catch(e){console.error(`${n}: ${e}`),P.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function _i(e){let{fetching:t,deleteDepreciationRecord:n}=gi();return(0,Q.jsx)(ht,{content:`Remove Depreciation`,children:(0,Q.jsx)(Nt,{onConfirm:(0,Z.useCallback)(()=>{n({depreciationRecordId:e.depreciationRecordId}).then(()=>{e.onDelete?.()})},[e,n]),title:`Are you sure you want to delete the depreciation record?`,children:(0,Q.jsx)(H,{variant:`outline`,size:`icon`,className:`size-7.5 text-red-500`,disabled:t,children:(0,Q.jsx)(zt,{className:`size-5`})})})})}var vi=({data:e,onChange:t})=>{let n=J(d,e),[r,i]=(0,Z.useState)(!1),[{data:a,fetching:o},s]=x({query:m,pause:!0}),c=Qe({defaultValues:{id:n.id}}),{control:l,handleSubmit:u,formState:{dirtyFields:f}}=c,{updateDepreciationRecord:p,fetching:h}=mi(),g=e=>{let r=he(e,f);r&&Object.keys(r).length>0&&p({fields:{...e,id:n.id}}).then(()=>{t?.(),i(!1)})},_=a?.depreciationCategories.map(e=>({value:e.id,label:e.name}));return(0,Z.useEffect)(()=>{r&&!a&&s()},[r,a,s]),(0,Q.jsx)(He,{...c,children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`form`,{id:`form ${n.id}`,onSubmit:u(g),children:r?(0,Q.jsx)(Ie,{name:`amount`,control:l,render:({field:e,fieldState:t})=>(0,Q.jsx)(Ie,{name:`currency`,control:l,render:({field:r,fieldState:i})=>(0,Q.jsx)(St,{...e,defaultValue:n.amount?.raw??n.charge.totalAmount?.raw,value:e.value??void 0,error:t.error?.message||i.error?.message,label:`Amount`,currencyCodeProps:{...r,label:`Currency`,defaultValue:n.amount?.currency??n.charge.totalAmount?.currency}})})}):(0,Q.jsx)(`div`,{children:n.amount?.formatted??n.charge.totalAmount?.formatted})})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 justify-center`,children:r?(0,Q.jsx)(Ie,{name:`activationDate`,control:l,defaultValue:n.activationDate,rules:{pattern:{value:Ge,message:`Date must be in format yyyy-mm-dd`}},render:({field:e,fieldState:t})=>(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Ve,{htmlFor:`activation-date-${n.id}`,children:`Activation Date`}),(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ot,{id:`activation-date-${n.id}`,form:`form ${n.id}`,value:e.value??void 0,onChange:t=>{t!==e.value&&e.onChange(t)},"aria-invalid":!!t.error})}),(0,Q.jsx)(Je,{})]})}):(0,Q.jsx)(`div`,{children:mn(new Date(n.activationDate),`dd/MM/yy`)})})}),(0,Q.jsx)(`td`,{children:r?(0,Q.jsx)(Ie,{name:`categoryId`,control:l,render:({field:e,fieldState:t})=>(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Ve,{children:`Category`}),(0,Q.jsx)(Ue,{children:(0,Q.jsx)(mt,{...e,form:`form ${n.id}`,disabled:o,data:_??[],placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message,withinPortal:!0})}),(0,Q.jsx)(Je,{})]})}):(0,Q.jsxs)(`div`,{children:[n.category.name,` (`,n.category.percentage,`%)`]})}),(0,Q.jsx)(`td`,{children:r?(0,Q.jsx)(Ie,{name:`type`,control:l,render:({field:e,fieldState:t})=>(0,Q.jsxs)(Re,{children:[(0,Q.jsx)(Ve,{children:`Type`}),(0,Q.jsx)(Ue,{children:(0,Q.jsx)(mt,{...e,form:`form ${n.id}`,data:bi,value:e.value,placeholder:`Scroll to see all options`,maxDropdownHeight:160,searchable:!0,error:t.error?.message,withinPortal:!0})}),(0,Q.jsx)(Je,{})]})}):(0,Q.jsx)(`div`,{children:n.type})}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(ht,{content:`Edit`,children:(0,Q.jsx)(H,{disabled:h||o,variant:r?`default`:`outline`,size:`icon`,className:`size-7.5`,onClick:e=>{e.stopPropagation(),i(e=>!e)},children:(0,Q.jsx)(Me,{className:`size-5`})})}),r&&(0,Q.jsx)(ht,{content:`Confirm Changes`,children:(0,Q.jsx)(H,{type:`submit`,form:`form ${n.id}`,variant:`outline`,size:`icon`,className:`size-7.5 text-green-500`,children:(0,Q.jsx)(Se,{className:`size-5`})})}),(0,Q.jsx)(_i,{depreciationRecordId:n.id,onDelete:t})]})]},n.id)})},yi=({chargeId:e,onChange:t})=>{let[{data:n,fetching:r}]=x({query:f,variables:{chargeId:e}});return!r&&!n?.depreciationRecordsByCharge.length?(0,Q.jsx)(di,{chargeId:e,onAdd:t}):r?(0,Q.jsx)(ye,{className:`h-10 w-10 animate-spin mr-2 self-center`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2 mt-5`,children:(0,Q.jsxs)(Dt,{highlightOnHover:!0,withBorder:!0,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Amount`}),(0,Q.jsx)(`th`,{children:`Activation Date`}),(0,Q.jsx)(`th`,{children:`Category`}),(0,Q.jsx)(`th`,{children:`Type`}),(0,Q.jsx)(`th`,{})]})}),(0,Q.jsxs)(`tbody`,{children:[n?.depreciationRecordsByCharge.map(e=>(0,Q.jsx)(vi,{data:e,onChange:t},e.id)),(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:5,children:(0,Q.jsx)(di,{chargeId:e,onAdd:t})})})]})]})})},bi=Object.entries(y).map(([e,t])=>({value:t,label:e}));function xi({chargeId:e,chargeType:t,onChange:n,isIncome:r}){let{deleteCharge:i}=at(),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),l=(0,Z.useCallback)(()=>c(!1),[]),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(!1),m=(0,Z.useCallback)(()=>p(!1),[]),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(!1),[x,S]=(0,Z.useState)(!1),C=(0,Z.useCallback)(()=>{o(!1)},[]),w=(0,Z.useCallback)(async()=>{await i({chargeId:e}),n?.(),C()},[e,i,n,C]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(V,{shadow:`md`,width:200,opened:a,children:[(0,Q.jsx)(V.Target,{children:(0,Q.jsx)(Pe,{opened:a,onClick:e=>{e.stopPropagation(),o(e=>!e)}})}),(0,Q.jsxs)(V.Dropdown,{children:[(0,Q.jsx)(V.Label,{children:`Charge`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Me,{size:14}),onClick:()=>{v(!0),C()},children:`Edit Charge`}),(0,Q.jsx)(Nt,{onConfirm:w,title:`Are you sure you want to delete this charge?`,children:(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(zt,{size:14}),children:`Delete Charge`})}),(0,Q.jsx)(V.Divider,{}),(0,Q.jsx)(V.Label,{children:`Documents`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(et,{size:14}),onClick:e=>{e.stopPropagation(),b(!0),C()},children:`Insert Document`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Fn,{size:14}),onClick:e=>{e.stopPropagation(),S(!0),C()},children:`Upload Documents`}),r&&(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(et,{size:14}),onClick:e=>{e.stopPropagation(),g(!0),C()},children:`Issue Document`}),(0,Q.jsx)(V.Divider,{}),(0,Q.jsx)(V.Label,{children:`Misc Expenses`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(et,{size:14}),onClick:e=>{e.stopPropagation(),C(),d(!0)},children:`Add expense`}),t===`CommonCharge`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V.Divider,{}),(0,Q.jsx)(V.Label,{children:`Depreciation`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Pn,{size:14}),onClick:e=>{e.stopPropagation(),c(!0),C()},children:`Depreciation`})]}),t===`SalaryCharge`&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(V.Divider,{}),(0,Q.jsx)(V.Label,{children:`Salaries`}),(0,Q.jsx)(V.Item,{icon:(0,Q.jsx)(Fn,{size:14}),onClick:e=>{e.stopPropagation(),C(),p(!0)},children:`Payroll file upload`})]})]})]}),(0,Q.jsx)(Rt,{withinPortal:!0,size:`xl`,centered:!0,opened:s,onClose:l,title:`Depreciation`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(yi,{chargeId:e,onChange:()=>{l(),n?.()}})}),(0,Q.jsx)(De,{open:u,onOpenChange:d,children:(0,Q.jsx)(_e,{className:`sm:max-w-[425px]`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(lt,{onDone:()=>{d(!1),n?.()},chargeId:e})})}),(0,Q.jsx)(Rt,{centered:!0,opened:f,onClose:m,title:`Upload Payroll File`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(it,{onDone:()=>{m(),n?.()},chargeId:e})}),(0,Q.jsx)(kt,{open:x,onOpenChange:S,onChange:n,chargeId:e}),(0,Q.jsx)(xt,{chargeId:e,open:h,setOpen:g,onDone:()=>n?.()}),(0,Q.jsx)(ft,{chargeId:_?e:void 0,close:()=>v(!1),onChange:()=>{v(!1),n?.()}}),(0,Q.jsx)(We,{chargeId:y?e:void 0,onChange:n,close:()=>b(!1)})]})}function Si(e){return Object.prototype.toString.call(e)===`[object Object]`}function Ci(e){return Si(e)||Array.isArray(e)}function wi(){return!!(typeof window<`u`&&window.document&&window.document.createElement)}function Ti(e,t){let n=Object.keys(e),r=Object.keys(t);return n.length!==r.length||JSON.stringify(Object.keys(e.breakpoints||{}))!==JSON.stringify(Object.keys(t.breakpoints||{}))?!1:n.every(n=>{let r=e[n],i=t[n];return typeof r==`function`?`${r}`==`${i}`:!Ci(r)||!Ci(i)?r===i:Ti(r,i)})}function Ei(e){return e.concat().sort((e,t)=>e.name>t.name?1:-1).map(e=>e.options)}function Di(e,t){if(e.length!==t.length)return!1;let n=Ei(e),r=Ei(t);return n.every((e,t)=>{let n=r[t];return Ti(e,n)})}function Oi(e){return typeof e==`number`}function ki(e){return typeof e==`string`}function Ai(e){return typeof e==`boolean`}function ji(e){return Object.prototype.toString.call(e)===`[object Object]`}function $(e){return Math.abs(e)}function Mi(e){return Math.sign(e)}function Ni(e,t){return $(e-t)}function Pi(e,t){return e===0||t===0||$(e)<=$(t)?0:$(Ni($(e),$(t))/e)}function Fi(e){return Math.round(e*100)/100}function Ii(e){return Vi(e).map(Number)}function Li(e){return e[Ri(e)]}function Ri(e){return Math.max(0,e.length-1)}function zi(e,t){return t===Ri(e)}function Bi(e,t=0){return Array.from(Array(e),(e,n)=>t+n)}function Vi(e){return Object.keys(e)}function Hi(e,t){return[e,t].reduce((e,t)=>(Vi(t).forEach(n=>{let r=e[n],i=t[n];e[n]=ji(r)&&ji(i)?Hi(r,i):i}),e),{})}function Ui(e,t){return t.MouseEvent!==void 0&&e instanceof t.MouseEvent}function Wi(e,t){let n={start:r,center:i,end:a};function r(){return 0}function i(e){return a(e)/2}function a(e){return t-e}function o(r,i){return ki(e)?n[e](r):e(t,r,i)}return{measure:o}}function Gi(){let e=[];function t(t,n,i,a={passive:!0}){let o;if(`addEventListener`in t)t.addEventListener(n,i,a),o=()=>t.removeEventListener(n,i,a);else{let e=t;e.addListener(i),o=()=>e.removeListener(i)}return e.push(o),r}function n(){e=e.filter(e=>e())}let r={add:t,clear:n};return r}function Ki(e,t,n,r){let i=Gi(),a=1e3/60,o=null,s=0,c=0;function l(){i.add(e,`visibilitychange`,()=>{e.hidden&&m()})}function u(){p(),i.clear()}function d(e){if(!c)return;o||(o=e,n(),n());let i=e-o;for(o=e,s+=i;s>=a;)n(),s-=a;r(s/a),c&&=t.requestAnimationFrame(d)}function f(){c||=t.requestAnimationFrame(d)}function p(){t.cancelAnimationFrame(c),o=null,s=0,c=0}function m(){o=null,s=0}return{init:l,destroy:u,start:f,stop:p,update:n,render:r}}function qi(e,t){let n=t===`rtl`,r=e===`y`,i=r?`y`:`x`,a=r?`x`:`y`,o=!r&&n?-1:1,s=u(),c=d();function l(e){let{height:t,width:n}=e;return r?t:n}function u(){return r?`top`:n?`right`:`left`}function d(){return r?`bottom`:n?`left`:`right`}function f(e){return e*o}return{scroll:i,cross:a,startEdge:s,endEdge:c,measureSize:l,direction:f}}function Ji(e=0,t=0){let n=$(e-t);function r(t){return t<e}function i(e){return e>t}function a(e){return r(e)||i(e)}function o(n){return a(n)?r(n)?e:t:n}function s(e){return n?e-n*Math.ceil((e-t)/n):e}return{length:n,max:t,min:e,constrain:o,reachedAny:a,reachedMax:i,reachedMin:r,removeOffset:s}}function Yi(e,t,n){let{constrain:r}=Ji(0,e),i=e+1,a=o(t);function o(e){return n?$((i+e)%i):r(e)}function s(){return a}function c(e){return a=o(e),d}function l(e){return u().set(s()+e)}function u(){return Yi(e,s(),n)}let d={get:s,set:c,add:l,clone:u};return d}function Xi(e,t,n,r,i,a,o,s,c,l,u,d,f,p,m,h,g,_,v){let{cross:y,direction:b}=e,x=[`INPUT`,`SELECT`,`TEXTAREA`],S={passive:!1},C=Gi(),w=Gi(),ee=Ji(50,225).constrain(p.measure(20)),T={mouse:300,touch:400},E={mouse:500,touch:600},D=m?43:25,O=!1,te=0,ne=0,k=!1,re=!1,ie=!1,A=!1;function ae(e){if(!v)return;function n(t){(Ai(v)||v(e,t))&&N(t)}let r=t;C.add(r,`dragstart`,e=>e.preventDefault(),S).add(r,`touchmove`,()=>void 0,S).add(r,`touchend`,()=>void 0).add(r,`touchstart`,n).add(r,`mousedown`,n).add(r,`touchcancel`,F).add(r,`contextmenu`,F).add(r,`click`,le,!0)}function oe(){C.clear(),w.clear()}function se(){let e=A?n:t;w.add(e,`touchmove`,P,S).add(e,`touchend`,F).add(e,`mousemove`,P,S).add(e,`mouseup`,F)}function ce(e){let t=e.nodeName||``;return x.includes(t)}function j(){return(m?E:T)[A?`mouse`:`touch`]}function M(e,t){let n=d.add(Mi(e)*-1),r=u.byDistance(e,!m).distance;return m||$(e)<ee?r:g&&t?r*.5:u.byIndex(n.get(),0).distance}function N(e){let t=Ui(e,r);A=t,ie=m&&t&&!e.buttons&&O,O=Ni(i.get(),o.get())>=2,!(t&&e.button!==0)&&(ce(e.target)||(k=!0,a.pointerDown(e),l.useFriction(0).useDuration(0),i.set(o),se(),te=a.readPoint(e),ne=a.readPoint(e,y),f.emit(`pointerDown`)))}function P(e){if(!Ui(e,r)&&e.touches.length>=2)return F(e);let t=a.readPoint(e),n=a.readPoint(e,y),o=Ni(t,te),c=Ni(n,ne);if(!re&&!A&&(!e.cancelable||(re=o>c,!re)))return F(e);let u=a.pointerMove(e);o>h&&(ie=!0),l.useFriction(.3).useDuration(.75),s.start(),i.add(b(u)),e.preventDefault()}function F(e){let t=u.byDistance(0,!1).index!==d.get(),n=a.pointerUp(e)*j(),r=M(b(n),t),i=Pi(n,r),o=D-10*i,s=_+i/50;re=!1,k=!1,w.clear(),l.useDuration(o).useFriction(s),c.distance(r,!m),A=!1,f.emit(`pointerUp`)}function le(e){ie&&=(e.stopPropagation(),e.preventDefault(),!1)}function I(){return k}return{init:ae,destroy:oe,pointerDown:I}}function Zi(e,t){let n,r;function i(e){return e.timeStamp}function a(n,r){let i=`client${(r||e.scroll)===`x`?`X`:`Y`}`;return(Ui(n,t)?n:n.touches[0])[i]}function o(e){return n=e,r=e,a(e)}function s(e){let t=a(e)-a(r),o=i(e)-i(n)>170;return r=e,o&&(n=e),t}function c(e){if(!n||!r)return 0;let t=a(r)-a(n),o=i(e)-i(n),s=i(e)-i(r)>170,c=t/o;return o&&!s&&$(c)>.1?c:0}return{pointerDown:o,pointerMove:s,pointerUp:c,readPoint:a}}function Qi(){function e(e){let{offsetTop:t,offsetLeft:n,offsetWidth:r,offsetHeight:i}=e;return{top:t,right:n+r,bottom:t+i,left:n,width:r,height:i}}return{measure:e}}function $i(e){function t(t){return t/100*e}return{measure:t}}function ea(e,t,n,r,i,a,o){let s=[e].concat(r),c,l,u=[],d=!1;function f(e){return i.measureSize(o.measure(e))}function p(i){if(!a)return;l=f(e),u=r.map(f);function o(n){for(let a of n){if(d)return;let n=a.target===e,o=r.indexOf(a.target),s=n?l:u[o];if($(f(n?e:r[o])-s)>=.5){i.reInit(),t.emit(`resize`);break}}}c=new ResizeObserver(e=>{(Ai(a)||a(i,e))&&o(e)}),n.requestAnimationFrame(()=>{s.forEach(e=>c.observe(e))})}function m(){d=!0,c&&c.disconnect()}return{init:p,destroy:m}}function ta(e,t,n,r,i,a){let o=0,s=0,c=i,l=a,u=e.get(),d=0;function f(){let t=r.get()-e.get(),i=!c,a=0;return i?(o=0,n.set(r),e.set(r),a=t):(n.set(e),o+=t/c,o*=l,u+=o,e.add(o),a=u-d),s=Mi(a),d=u,x}function p(){return $(r.get()-t.get())<.001}function m(){return c}function h(){return s}function g(){return o}function _(){return y(i)}function v(){return b(a)}function y(e){return c=e,x}function b(e){return l=e,x}let x={direction:h,duration:m,velocity:g,seek:f,settled:p,useBaseFriction:v,useBaseDuration:_,useFriction:b,useDuration:y};return x}function na(e,t,n,r,i){let a=i.measure(10),o=i.measure(50),s=Ji(.1,.99),c=!1;function l(){return!(c||!e.reachedAny(n.get())||!e.reachedAny(t.get()))}function u(i){if(!l())return;let c=$(e[e.reachedMin(t.get())?`min`:`max`]-t.get()),u=n.get()-t.get(),d=s.constrain(c/o);n.subtract(u*d),!i&&$(u)<a&&(n.set(e.constrain(n.get())),r.useDuration(25).useBaseFriction())}function d(e){c=!e}return{shouldConstrain:l,constrain:u,toggleActive:d}}function ra(e,t,n,r,i){let a=Ji(-t+e,0),o=d(),s=u(),c=f();function l(e,t){return Ni(e,t)<=1}function u(){let e=o[0],t=Li(o);return Ji(o.lastIndexOf(e),o.indexOf(t)+1)}function d(){return n.map((e,t)=>{let{min:r,max:i}=a,o=a.constrain(e),s=!t,c=zi(n,t);return s?i:c||l(r,o)?r:l(i,o)?i:o}).map(e=>parseFloat(e.toFixed(3)))}function f(){if(t<=e+i)return[a.max];if(r===`keepSnaps`)return o;let{min:n,max:c}=s;return o.slice(n,c)}return{snapsContained:c,scrollContainLimit:s}}function ia(e,t,n){let r=t[0];return{limit:Ji(n?r-e:Li(t),r)}}function aa(e,t,n,r){let i=.1,{reachedMin:a,reachedMax:o}=Ji(t.min+i,t.max+i);function s(e){return e===1?o(n.get()):e===-1?a(n.get()):!1}function c(t){if(!s(t))return;let n=t*-1*e;r.forEach(e=>e.add(n))}return{loop:c}}function oa(e){let{max:t,length:n}=e;function r(e){let r=e-t;return n?r/-n:0}return{get:r}}function sa(e,t,n,r,i){let{startEdge:a,endEdge:o}=e,{groupSlides:s}=i,c=d().map(t.measure),l=f(),u=p();function d(){return s(r).map(e=>Li(e)[o]-e[0][a]).map($)}function f(){return r.map(e=>n[a]-e[a]).map(e=>-$(e))}function p(){return s(l).map(e=>e[0]).map((e,t)=>e+c[t])}return{snaps:l,snapsAligned:u}}function ca(e,t,n,r,i,a){let{groupSlides:o}=i,{min:s,max:c}=r,l=u();function u(){let r=o(a),i=!e||t===`keepSnaps`;return n.length===1?[a]:i?r:r.slice(s,c).map((e,t,n)=>{let r=!t,i=zi(n,t);return r?Bi(Li(n[0])+1):i?Bi(Ri(a)-Li(n)[0]+1,Li(n)[0]):e})}return{slideRegistry:l}}function la(e,t,n,r,i){let{reachedAny:a,removeOffset:o,constrain:s}=r;function c(e){return e.concat().sort((e,t)=>$(e)-$(t))[0]}function l(n){let r=e?o(n):s(n),{index:i}=t.map((e,t)=>({diff:u(e-r,0),index:t})).sort((e,t)=>$(e.diff)-$(t.diff))[0];return{index:i,distance:r}}function u(t,r){let i=[t,t+n,t-n];if(!e)return t;if(!r)return c(i);let a=i.filter(e=>Mi(e)===r);return a.length?c(a):Li(i)-n}function d(e,n){return{index:e,distance:u(t[e]-i.get(),n)}}function f(n,r){let o=i.get()+n,{index:s,distance:c}=l(o),d=!e&&a(o);return!r||d?{index:s,distance:n}:{index:s,distance:n+u(t[s]-c,0)}}return{byDistance:f,byIndex:d,shortcut:u}}function ua(e,t,n,r,i,a,o){function s(i){let s=i.distance,c=i.index!==t.get();a.add(s),s&&(r.duration()?e.start():(e.update(),e.render(1),e.update())),c&&(n.set(t.get()),t.set(i.index),o.emit(`select`))}function c(e,t){s(i.byDistance(e,t))}function l(e,n){let r=t.clone().set(e);s(i.byIndex(r.get(),n))}return{distance:c,index:l}}function da(e,t,n,r,i,a,o,s){let c={passive:!0,capture:!0},l=0;function u(u){if(!s)return;function f(t){if(new Date().getTime()-l>10)return;o.emit(`slideFocusStart`),e.scrollLeft=0;let a=n.findIndex(e=>e.includes(t));Oi(a)&&(i.useDuration(0),r.index(a,0),o.emit(`slideFocus`))}a.add(document,`keydown`,d,!1),t.forEach((e,t)=>{a.add(e,`focus`,e=>{(Ai(s)||s(u,e))&&f(t)},c)})}function d(e){e.code===`Tab`&&(l=new Date().getTime())}return{init:u}}function fa(e){let t=e;function n(){return t}function r(e){t=o(e)}function i(e){t+=o(e)}function a(e){t-=o(e)}function o(e){return Oi(e)?e:e.get()}return{get:n,set:r,add:i,subtract:a}}function pa(e,t){let n=e.scroll===`x`?o:s,r=t.style,i=null,a=!1;function o(e){return`translate3d(${e}px,0px,0px)`}function s(e){return`translate3d(0px,${e}px,0px)`}function c(t){if(a)return;let o=Fi(e.direction(t));o!==i&&(r.transform=n(o),i=o)}function l(e){a=!e}function u(){a||(r.transform=``,t.getAttribute(`style`)||t.removeAttribute(`style`))}return{clear:u,to:c,toggleActive:l}}function ma(e,t,n,r,i,a,o,s,c){let l=.5,u=Ii(i),d=Ii(i).reverse(),f=_().concat(v());function p(e,t){return e.reduce((e,t)=>e-i[t],t)}function m(e,t){return e.reduce((e,n)=>p(e,t)>0?e.concat([n]):e,[])}function h(e){return a.map((n,i)=>({start:n-r[i]+l+e,end:n+t-l+e}))}function g(t,r,i){let a=h(r);return t.map(t=>{let r=i?0:-n,o=i?n:0,l=i?`end`:`start`,u=a[t][l];return{index:t,loopPoint:u,slideLocation:fa(-1),translate:pa(e,c[t]),target:()=>s.get()>u?r:o}})}function _(){let e=o[0];return g(m(d,e),n,!1)}function v(){return g(m(u,t-o[0]-1),-n,!0)}function y(){return f.every(({index:e})=>p(u.filter(t=>t!==e),t)<=.1)}function b(){f.forEach(e=>{let{target:t,translate:n,slideLocation:r}=e,i=t();i!==r.get()&&(n.to(i),r.set(i))})}function x(){f.forEach(e=>e.translate.clear())}return{canLoop:y,clear:x,loop:b,loopPoints:f}}function ha(e,t,n){let r,i=!1;function a(a){if(!n)return;function o(e){for(let n of e)if(n.type===`childList`){a.reInit(),t.emit(`slidesChanged`);break}}r=new MutationObserver(e=>{i||(Ai(n)||n(a,e))&&o(e)}),r.observe(e,{childList:!0})}function o(){r&&r.disconnect(),i=!0}return{init:a,destroy:o}}function ga(e,t,n,r){let i={},a=null,o=null,s,c=!1;function l(){s=new IntersectionObserver(e=>{c||(e.forEach(e=>{let n=t.indexOf(e.target);i[n]=e}),a=null,o=null,n.emit(`slidesInView`))},{root:e.parentElement,threshold:r}),t.forEach(e=>s.observe(e))}function u(){s&&s.disconnect(),c=!0}function d(e){return Vi(i).reduce((t,n)=>{let r=parseInt(n),{isIntersecting:a}=i[r];return(e&&a||!e&&!a)&&t.push(r),t},[])}function f(e=!0){if(e&&a)return a;if(!e&&o)return o;let t=d(e);return e&&(a=t),e||(o=t),t}return{init:l,destroy:u,get:f}}function _a(e,t,n,r,i,a){let{measureSize:o,startEdge:s,endEdge:c}=e,l=n[0]&&i,u=m(),d=h(),f=n.map(o),p=g();function m(){if(!l)return 0;let e=n[0];return $(t[s]-e[s])}function h(){if(!l)return 0;let e=a.getComputedStyle(Li(r));return parseFloat(e.getPropertyValue(`margin-${c}`))}function g(){return n.map((e,t,n)=>{let r=!t,i=zi(n,t);return r?f[t]+u:i?f[t]+d:n[t+1][s]-e[s]}).map($)}return{slideSizes:f,slideSizesWithGaps:p,startGap:u,endGap:d}}function va(e,t,n,r,i,a,o,s,c){let{startEdge:l,endEdge:u,direction:d}=e,f=Oi(n);function p(e,t){return Ii(e).filter(e=>e%t===0).map(n=>e.slice(n,n+t))}function m(e){return e.length?Ii(e).reduce((n,f,p)=>{let m=Li(n)||0,h=m===0,g=f===Ri(e),_=i[l]-a[m][l],v=i[l]-a[f][u],y=!r&&h?d(o):0,b=$(v-(!r&&g?d(s):0)-(_+y));return p&&b>t+c&&n.push(f),g&&n.push(e.length),n},[]).map((t,n,r)=>{let i=Math.max(r[n-1]||0);return e.slice(i,t)}):[]}function h(e){return f?p(e,n):m(e)}return{groupSlides:h}}function ya(e,t,n,r,i,a,o){let{align:s,axis:c,direction:l,startIndex:u,loop:d,duration:f,dragFree:p,dragThreshold:m,inViewThreshold:h,slidesToScroll:g,skipSnaps:_,containScroll:v,watchResize:y,watchSlides:b,watchDrag:x,watchFocus:S}=a,C=Qi(),w=C.measure(t),ee=n.map(C.measure),T=qi(c,l),E=T.measureSize(w),D=$i(E),O=Wi(s,E),te=!d&&!!v,{slideSizes:ne,slideSizesWithGaps:k,startGap:re,endGap:ie}=_a(T,w,ee,n,d||!!v,i),A=va(T,E,g,d,w,ee,re,ie,2),{snaps:ae,snapsAligned:oe}=sa(T,O,w,ee,A),se=-Li(ae)+Li(k),{snapsContained:ce,scrollContainLimit:j}=ra(E,se,oe,v,2),M=te?ce:oe,{limit:N}=ia(se,M,d),P=Yi(Ri(M),u,d),F=P.clone(),le=Ii(n),I=({dragHandler:e,scrollBody:t,scrollBounds:n,options:{loop:r}})=>{r||n.constrain(e.pointerDown()),t.seek()},ue=({scrollBody:e,translate:t,location:n,offsetLocation:r,previousLocation:i,scrollLooper:a,slideLooper:o,dragHandler:s,animation:c,eventHandler:l,scrollBounds:u,options:{loop:d}},f)=>{let p=e.settled(),m=!u.shouldConstrain(),h=d?p:p&&m,g=h&&!s.pointerDown();g&&c.stop();let _=n.get()*f+i.get()*(1-f);r.set(_),d&&(a.loop(e.direction()),o.loop()),t.to(r.get()),g&&l.emit(`settle`),h||l.emit(`scroll`)},de=Ki(r,i,()=>I(Ce),e=>ue(Ce,e)),fe=.68,pe=M[P.get()],me=fa(pe),he=fa(pe),L=fa(pe),R=fa(pe),ge=ta(me,L,he,R,f,fe),_e=la(d,M,se,N,R),ve=ua(de,P,F,ge,_e,R,o),ye=oa(N),be=Gi(),z=ga(t,n,o,h),{slideRegistry:xe}=ca(te,v,M,j,A,le),Se=da(e,n,xe,ve,ge,be,o,S),Ce={ownerDocument:r,ownerWindow:i,eventHandler:o,containerRect:w,slideRects:ee,animation:de,axis:T,dragHandler:Xi(T,e,r,i,R,Zi(T,i),me,de,ve,ge,_e,P,o,D,p,m,_,fe,x),eventStore:be,percentOfView:D,index:P,indexPrevious:F,limit:N,location:me,offsetLocation:L,previousLocation:he,options:a,resizeHandler:ea(t,o,i,n,T,y,C),scrollBody:ge,scrollBounds:na(N,L,R,ge,D),scrollLooper:aa(se,N,L,[me,L,he,R]),scrollProgress:ye,scrollSnapList:M.map(ye.get),scrollSnaps:M,scrollTarget:_e,scrollTo:ve,slideLooper:ma(T,E,se,ne,k,ae,M,L,n),slideFocus:Se,slidesHandler:ha(t,o,b),slidesInView:z,slideIndexes:le,slideRegistry:xe,slidesToScroll:A,target:R,translate:pa(T,t)};return Ce}function ba(){let e={},t;function n(e){t=e}function r(t){return e[t]||[]}function i(e){return r(e).forEach(n=>n(t,e)),c}function a(t,n){return e[t]=r(t).concat([n]),c}function o(t,n){return e[t]=r(t).filter(e=>e!==n),c}function s(){e={}}let c={init:n,emit:i,off:o,on:a,clear:s};return c}var xa={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 Sa(e){function t(e,t){return Hi(e,t||{})}function n(n){let r=n.breakpoints||{};return t(n,Vi(r).filter(t=>e.matchMedia(t).matches).map(e=>r[e]).reduce((e,n)=>t(e,n),{}))}function r(t){return t.map(e=>Vi(e.breakpoints||{})).reduce((e,t)=>e.concat(t),[]).map(e.matchMedia)}return{mergeOptions:t,optionsAtMedia:n,optionsMediaQueries:r}}function Ca(e){let t=[];function n(n,r){return t=r.filter(({options:t})=>e.optionsAtMedia(t).active!==!1),t.forEach(t=>t.init(n,e)),r.reduce((e,t)=>Object.assign(e,{[t.name]:t}),{})}function r(){t=t.filter(e=>e.destroy())}return{init:n,destroy:r}}function wa(e,t,n){let r=e.ownerDocument,i=r.defaultView,a=Sa(i),o=Ca(a),s=Gi(),c=ba(),{mergeOptions:l,optionsAtMedia:u,optionsMediaQueries:d}=a,{on:f,off:p,emit:m}=c,h=E,g=!1,_,v=l(xa,wa.globalOptions),y=l(v),b=[],x,S,C;function w(){let{container:t,slides:n}=y;S=(ki(t)?e.querySelector(t):t)||e.children[0];let r=ki(n)?S.querySelectorAll(n):n;C=[].slice.call(r||S.children)}function ee(t){let n=ya(e,S,C,r,i,t,c);return t.loop&&!n.slideLooper.canLoop()?ee(Object.assign({},t,{loop:!1})):n}function T(e,t){g||(v=l(v,e),y=u(v),b=t||b,w(),_=ee(y),d([v,...b.map(({options:e})=>e)]).forEach(e=>s.add(e,`change`,E)),y.active&&(_.translate.to(_.location.get()),_.animation.init(),_.slidesInView.init(),_.slideFocus.init(I),_.eventHandler.init(I),_.resizeHandler.init(I),_.slidesHandler.init(I),_.options.loop&&_.slideLooper.loop(),S.offsetParent&&C.length&&_.dragHandler.init(I),x=o.init(I,b)))}function E(e,t){let n=oe();D(),T(l({startIndex:n},e),t),c.emit(`reInit`)}function D(){_.dragHandler.destroy(),_.eventStore.clear(),_.translate.clear(),_.slideLooper.clear(),_.resizeHandler.destroy(),_.slidesHandler.destroy(),_.slidesInView.destroy(),_.animation.destroy(),o.destroy(),s.clear()}function O(){g||(g=!0,s.clear(),D(),c.emit(`destroy`),c.clear())}function te(e,t,n){!y.active||g||(_.scrollBody.useBaseFriction().useDuration(t===!0?0:y.duration),_.scrollTo.index(e,n||0))}function ne(e){te(_.index.add(1).get(),e,-1)}function k(e){te(_.index.add(-1).get(),e,1)}function re(){return _.index.add(1).get()!==oe()}function ie(){return _.index.add(-1).get()!==oe()}function A(){return _.scrollSnapList}function ae(){return _.scrollProgress.get(_.offsetLocation.get())}function oe(){return _.index.get()}function se(){return _.indexPrevious.get()}function ce(){return _.slidesInView.get()}function j(){return _.slidesInView.get(!1)}function M(){return x}function N(){return _}function P(){return e}function F(){return S}function le(){return C}let I={canScrollNext:re,canScrollPrev:ie,containerNode:F,internalEngine:N,destroy:O,off:p,on:f,emit:m,plugins:M,previousScrollSnap:se,reInit:h,rootNode:P,scrollNext:ne,scrollPrev:k,scrollProgress:ae,scrollSnapList:A,scrollTo:te,selectedScrollSnap:oe,slideNodes:le,slidesInView:ce,slidesNotInView:j};return T(t,n),setTimeout(()=>c.emit(`init`),0),I}wa.globalOptions=void 0;function Ta(e={},t=[]){let n=(0,Z.useRef)(e),r=(0,Z.useRef)(t),[i,a]=(0,Z.useState)(),[o,s]=(0,Z.useState)(),c=(0,Z.useCallback)(()=>{i&&i.reInit(n.current,r.current)},[i]);return(0,Z.useEffect)(()=>{Ti(n.current,e)||(n.current=e,c())},[e,c]),(0,Z.useEffect)(()=>{Di(r.current,t)||(r.current=t,c())},[t,c]),(0,Z.useEffect)(()=>{if(wi()&&o){wa.globalOptions=Ta.globalOptions;let e=wa(o,n.current,r.current);return a(e),()=>e.destroy()}else a(void 0)},[o,a]),[s,i]}Ta.globalOptions=void 0;var[Ea,Da]=bt({context:`[@mantine/carousel] Carousel.Slide was rendered outside of Carousel context`}.context),Oa=Object.defineProperty,ka=Object.defineProperties,Aa=Object.getOwnPropertyDescriptors,ja=Object.getOwnPropertySymbols,Ma=Object.prototype.hasOwnProperty,Na=Object.prototype.propertyIsEnumerable,Pa=(e,t,n)=>t in e?Oa(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fa=(e,t)=>{for(var n in t||={})Ma.call(t,n)&&Pa(e,n,t[n]);if(ja)for(var n of ja(t))Na.call(t,n)&&Pa(e,n,t[n]);return e},Ia=(e,t)=>ka(e,Aa(t)),La=nn((e,{controlSize:t,controlsOffset:n,orientation:r,height:i,includeGapInSize:a,breakpoints:o=[],slideGap:s})=>{let c=r===`horizontal`,l=t=>{if(!a)return{};let n=K({size:t,sizes:e.spacing});return{[r===`horizontal`?`marginRight`:`marginBottom`]:`calc(${n} * -1)`}},u=o.some(e=>e.slideGap!==void 0||e.slideSize!==void 0)?gt(e,o).reduce((t,n)=>{let r=`maxWidth`in n?`max-width`:`min-width`,i=K({size:r===`max-width`?n.maxWidth:n.minWidth,sizes:e.breakpoints}),a=n.slideGap===void 0?void 0:Y(n.slideGap),o=sn(i)-+(r===`max-width`);return t[`@media (${r}: ${Y(o)})`]=l(a),t},{}):null;return{root:{position:`relative`},viewport:{height:Y(i),overflow:`hidden`},container:Fa(Fa({display:`flex`,flexDirection:c?`row`:`column`,height:Y(i)},l(s)),u),controls:{position:`absolute`,zIndex:1,left:c?0:`calc(50% - ${Y(t)} / 2)`,right:c?0:void 0,top:c?`calc(50% - ${Y(t)} / 2)`:0,bottom:c?void 0:0,display:`flex`,flexDirection:c?`row`:`column`,alignItems:`center`,justifyContent:`space-between`,paddingLeft:c?K({size:n,sizes:e.spacing}):void 0,paddingRight:c?K({size:n,sizes:e.spacing}):void 0,paddingTop:c?void 0:K({size:n,sizes:e.spacing}),paddingBottom:c?void 0:K({size:n,sizes:e.spacing}),pointerEvents:`none`},control:Ia(Fa({display:`flex`,justifyContent:`center`,alignItems:`center`,minWidth:Y(t),minHeight:Y(t),borderRadius:Y(t),pointerEvents:`all`,backgroundColor:e.white,color:e.black,boxShadow:e.shadows.md,opacity:e.colorScheme===`dark`?.65:.85,border:`${Y(1)} solid ${e.colors.gray[3]}`,transition:`opacity 150ms ${e.transitionTimingFunction}`},e.fn.hover({opacity:1})),{"&:active":e.activeStyles}),indicators:{position:`absolute`,bottom:c?e.spacing.md:0,top:c?void 0:0,left:c?0:void 0,right:c?0:e.spacing.md,display:`flex`,flexDirection:c?`row`:`column`,justifyContent:`center`,gap:Y(8),pointerEvents:`none`},indicator:{pointerEvents:`all`,width:Y(c?25:5),height:Y(c?5:25),borderRadius:e.radius.xl,backgroundColor:e.white,boxShadow:e.shadows.sm,opacity:.6,transition:`opacity 150ms ${e.transitionTimingFunction}`,"&[data-active]":{opacity:1}}}}),Ra=Object.defineProperty,za=Object.getOwnPropertySymbols,Ba=Object.prototype.hasOwnProperty,Va=Object.prototype.propertyIsEnumerable,Ha=(e,t,n)=>t in e?Ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ua=(e,t)=>{for(var n in t||={})Ba.call(t,n)&&Ha(e,n,t[n]);if(za)for(var n of za(t))Va.call(t,n)&&Ha(e,n,t[n]);return e},Wa=nn((e,{size:t,gap:n,orientation:r,includeGapInSize:i,breakpoints:a=[]})=>{let o=(t,n)=>{let a=K({size:t,sizes:e.spacing}),o=Y(n),s=i?{[r===`horizontal`?`paddingRight`:`paddingBottom`]:a}:{[r===`horizontal`?`marginRight`:`marginBottom`]:a};return Ua({flex:`0 0 ${o}`},s)},s=a.some(e=>e.slideGap!==void 0||e.slideSize!==void 0)?gt(e,a).reduce((t,r)=>{let i=`maxWidth`in r?`max-width`:`min-width`,a=K({size:i===`max-width`?r.maxWidth:r.minWidth,sizes:e.breakpoints}),s=r.slideGap===void 0?n:r.slideGap,c=sn(a)-+(i===`max-width`);return t[`@media (${i}: ${Y(c)})`]=o(s,r.slideSize),t},{}):null;return{slide:Ua(Ua({position:`relative`},o(n,t)),s)}}),Ga=Object.defineProperty,Ka=Object.getOwnPropertySymbols,qa=Object.prototype.hasOwnProperty,Ja=Object.prototype.propertyIsEnumerable,Ya=(e,t,n)=>t in e?Ga(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xa=(e,t)=>{for(var n in t||={})qa.call(t,n)&&Ya(e,n,t[n]);if(Ka)for(var n of Ka(t))Ja.call(t,n)&&Ya(e,n,t[n]);return e},Za=(e,t)=>{var n={};for(var r in e)qa.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&Ka)for(var r of Ka(e))t.indexOf(r)<0&&Ja.call(e,r)&&(n[r]=e[r]);return n},Qa=(0,Z.forwardRef)((e,t)=>{var n=e,{children:r,className:i,size:a,gap:o}=n,s=Za(n,[`children`,`className`,`size`,`gap`]);let c=Da(),{classes:l,cx:u}=Wa({gap:o===void 0?c.slideGap:o,size:a===void 0?c.slideSize:a,orientation:c.orientation,includeGapInSize:c.includeGapInSize,breakpoints:c.breakpoints},{name:`Carousel`,classNames:c.classNames,styles:c.styles,unstyled:c.unstyled,variant:c.variant});return Z.createElement(Cn,Xa({className:u(l.slide,i),ref:t},s),r)});Qa.displayName=`@mantine/carousel/CarouselSlide`;function $a({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 eo=Object.defineProperty,to=Object.getOwnPropertySymbols,no=Object.prototype.hasOwnProperty,ro=Object.prototype.propertyIsEnumerable,io=(e,t,n)=>t in e?eo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ao=(e,t)=>{for(var n in t||={})no.call(t,n)&&io(e,n,t[n]);if(to)for(var n of to(t))ro.call(t,n)&&io(e,n,t[n]);return e},oo=(e,t)=>{var n={};for(var r in e)no.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&to)for(var r of to(e))t.indexOf(r)<0&&ro.call(e,r)&&(n[r]=e[r]);return n},so={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},co=(0,Z.forwardRef)((e,t)=>{let n=hn(`Carousel`,so,e),{children:r,className:i,getEmblaApi:a,onNextSlide:o,onPreviousSlide:s,onSlideChange:c,nextControlLabel:l,previousControlLabel:u,controlSize:d,controlsOffset:f,classNames:p,styles:m,unstyled:h,slideSize:g,slideGap:_,orientation:v,height:y,align:b,slidesToScroll:x,includeGapInSize:S,draggable:C,dragFree:w,loop:ee,speed:T,initialSlide:E,inViewThreshold:D,withControls:O,withIndicators:te,plugins:ne,nextControlIcon:k,previousControlIcon:re,breakpoints:ie,skipSnaps:A,containScroll:ae,withKeyboardEvents:oe,variant:se}=n,ce=oo(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`.split(`.`)),{classes:j,cx:M,theme:N}=La({controlSize:d,controlsOffset:f,orientation:v,height:y,includeGapInSize:S,breakpoints:ie,slideGap:_},{name:`Carousel`,classNames:p,styles:m,unstyled:h,variant:se}),[P,F]=Ta({axis:v===`horizontal`?`x`:`y`,direction:v===`horizontal`?N.dir:void 0,startIndex:E,loop:ee,align:b,slidesToScroll:x,draggable:C,dragFree:w,speed:T,inViewThreshold:D,skipSnaps:A,containScroll:ae},ne),[le,I]=(0,Z.useState)(0),[ue,de]=(0,Z.useState)(0),fe=(0,Z.useCallback)(e=>F&&F.scrollTo(e),[F]),pe=(0,Z.useCallback)(()=>{if(!F)return;let e=F.selectedScrollSnap();I(e),c?.(e)},[F,I]),me=(0,Z.useCallback)(()=>{F?.scrollPrev(),s?.()},[F]),he=(0,Z.useCallback)(()=>{F?.scrollNext(),o?.()},[F]),L=(0,Z.useCallback)(e=>{oe&&(e.key===`ArrowRight`&&(e.preventDefault(),he()),e.key===`ArrowLeft`&&(e.preventDefault(),me()))},[F]);(0,Z.useEffect)(()=>{if(F)return a?.(F),pe(),de(F.scrollSnapList().length),F.on(`select`,pe),()=>{F.off(`select`,pe)}},[F,x]),(0,Z.useEffect)(()=>{F&&(F.reInit(),de(F.scrollSnapList().length),I(e=>ot(e,0,Z.Children.toArray(r).length-1)))},[Z.Children.toArray(r).length,x]);let R=F?.canScrollPrev()||!1,ge=F?.canScrollNext()||!1,_e=Array(ue).fill(0).map((e,t)=>Z.createElement(qe,{key:t,"data-active":t===le||void 0,className:j.indicator,"aria-hidden":!0,tabIndex:-1,onClick:()=>fe(t)}));return Z.createElement(Ea,{value:{slideGap:_,slideSize:g,embla:F,orientation:v,includeGapInSize:S,breakpoints:ie,classNames:p,styles:m,unstyled:h,variant:se}},Z.createElement(Cn,ao({className:M(j.root,i),ref:t,onKeyDownCapture:L},ce),Z.createElement(`div`,{className:j.viewport,ref:P},Z.createElement(`div`,{className:j.container},r)),te&&Z.createElement(`div`,{className:j.indicators},_e),O&&Z.createElement(`div`,{className:j.controls},Z.createElement(qe,{onClick:me,className:j.control,"aria-label":u,"data-inactive":!R||void 0,tabIndex:R?0:-1},re===void 0?Z.createElement(nt,{style:{transform:`rotate(${$a({dir:N.dir,orientation:v,direction:`previous`})}deg)`}}):re),Z.createElement(qe,{onClick:he,className:j.control,"aria-label":l,"data-inactive":!ge||void 0,tabIndex:ge?0:-1},k===void 0?Z.createElement(nt,{style:{transform:`rotate(${$a({dir:N.dir,orientation:v,direction:`next`})}deg)`}}):k))))});co.Slide=Qa,co.displayName=`@mantine/carousel/Carousel`;var lo=co,uo=({chargeProps:e,onChange:t})=>{let{additionalDocuments:n}=J(se,e),[r,i]=(0,Z.useState)(void 0);return(0,Q.jsx)(`div`,{className:`container mx-auto text-gray-600 body-font`,children:n?.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`flex flex-wrap`,children:(0,Q.jsx)(lo,{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(e=>(0,Q.jsx)(lo.Slide,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col items-center`,children:[(0,Q.jsx)(`h2`,{className:`text-gray-900 text-base font-medium`,children:`documentType`in e?e.documentType:`Unprocessed`}),(0,Q.jsx)(`button`,{className:`mx-10`,onClick:()=>i(e.id),children:(0,Q.jsx)(`div`,{className:`flex rounded-lg h-full bg-gray-100 p-2 m-2 flex-col`,children:(0,Q.jsx)(wn,{src:e.image?.toString(),withPlaceholder:!0})})})]})},e.id))})}),(0,Q.jsx)(Ae,{documentId:r,onDone:()=>i(void 0),onChange:t})]}):(0,Q.jsx)(kr,{color:`red`,children:`No Documents Related`})})},fo=({foreignAmount:e,localAmount:t,diff:n})=>{let r=e!=null&&e.currency!==u.Ils,i=n&&n.localAmount?.formatted!==t?.formatted,a=n&&n.foreignAmount?.formatted!==e?.formatted;return(0,Q.jsx)(`div`,{className:`flex flex-col`,children:(t||i)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`flex gap-2  items-center`,children:[r&&(0,Q.jsx)(`p`,{className:a?`line-through`:``,children:e.formatted}),a&&n.foreignAmount&&(0,Q.jsx)(`p`,{className:`border-2 border-yellow-500 rounded-md`,children:n.foreignAmount.formatted})]}),(0,Q.jsxs)(`div`,{className:`flex gap-2  items-center`,children:[t!=null&&(0,Q.jsx)(`p`,{className:i?`line-through`:``,children:t.formatted}),i&&n.localAmount&&(0,Q.jsx)(`p`,{className:`border-2 border-yellow-500 rounded-md`,children:n.localAmount.formatted})]})]})})},po=({account:e,diffAccount:t})=>{let n=t&&t?.id!==e?.id;return(0,Q.jsx)(`div`,{className:`flex flex-col whitespace-normal`,children:(e||n)&&(0,Q.jsxs)(Q.Fragment,{children:[e&&(0,Q.jsx)(L,{to:R.BUSINESSES.DETAIL(e.id),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold ${n?`line-through`:``}`,children:e.name}),n&&t&&(0,Q.jsx)(`div`,{className:`border-2 border-yellow-500 rounded-md`,children:(0,Q.jsx)(L,{to:R.BUSINESSES.DETAIL(t.id),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:t.name})})]})})},mo=({date:e,diff:t})=>{let n=e?mn(new Date(e),`dd/MM/yy`):void 0,r=t?mn(new Date(t),`dd/MM/yy`):void 0,i=r&&n!==r;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:i?`line-through`:``,children:n??`Missing Data`}),i&&(0,Q.jsx)(`div`,{className:`flex flex-col border-2 border-yellow-500 rounded-md`,children:r})]})},ho=(e,t)=>{let n=e.original[t],r=e.original.diff?.[t];return!n&&!r},go=[{accessorKey:`invoiceDate`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Invoice Date`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(mo,{date:e.original.invoiceDate,diff:e.original.diff?.invoiceDate})},{accessorKey:`valueDate`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Value Date`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(mo,{date:e.original.valueDate,diff:e.original.diff?.valueDate})},{header:`Debit Account (Main)`,columns:[{accessorKey:`debitAccount1.name`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Account`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(po,{account:e.original.debitAccount1,diffAccount:e.original.diff?.debitAccount1})},{accessorKey:`localCurrencyDebitAmount1.raw`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>ho(e,`debitAccount1`)?null:(0,Q.jsx)(fo,{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})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Account`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(po,{account:e.original.creditAccount1,diffAccount:e.original.diff?.creditAccount1})},{accessorKey:`localCurrencyCreditAmount1.raw`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>ho(e,`creditAccount1`)?null:(0,Q.jsx)(fo,{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})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Account`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(po,{account:e.original.debitAccount2,diffAccount:e.original.diff?.debitAccount2})},{accessorKey:`localCurrencyDebitAmount2.raw`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>ho(e,`debitAccount2`)?null:(0,Q.jsx)(fo,{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})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Account`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>(0,Q.jsx)(po,{account:e.original.creditAccount2,diffAccount:e.original.diff?.creditAccount2})},{accessorKey:`localCurrencyCreditAmount2.raw`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Amount`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:e})=>ho(e,`creditAccount2`)?null:(0,Q.jsx)(fo,{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})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Details`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:{original:e}})=>{let t=e.diff&&e.diff.description!==e.description;return(0,Q.jsxs)(`div`,{className:`flex flex-col whitespace-normal`,children:[(0,Q.jsx)(`p`,{className:t?`line-through`:``,children:e.description}),t&&(0,Q.jsx)(`div`,{className:`border-2 border-yellow-500 rounded-md`,children:e.diff?.description})]})}},{accessorKey:`reference`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Reference`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:{original:e}})=>{let t=e.diff&&e.diff.reference!==e.reference;return(0,Q.jsxs)(`div`,{className:`flex flex-col whitespace-normal`,children:[(0,Q.jsx)(`p`,{className:t?`line-through`:``,children:e.reference}),t&&(0,Q.jsx)(`div`,{className:`border-2 border-yellow-500 rounded-md`,children:e.diff?.reference})]})}},{accessorKey:`matchingStatus`,header:({column:e})=>(0,Q.jsxs)(H,{variant:`ghost`,onClick:()=>e.toggleSorting(e.getIsSorted()===`asc`),children:[`Status`,e.getIsSorted()&&(e.getIsSorted()===`asc`?(0,Q.jsx)(z,{className:`ml-2 h-4 w-4`}):(0,Q.jsx)(B,{className:`ml-2 h-4 w-4`}))]}),cell:({row:{original:{matchingStatus:e}}})=>e?(0,Q.jsx)(fn,{variant:`default`,className:e===`Deleted`?`bg-red-500`:e===`Diff`?`bg-yellow-500`:`bg-green-500`,children:e}):null}];function _o(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}var vo=({ledgerRecordsData:e,ledgerDiffData:t,matches:n})=>{let[r,i]=(0,Z.useState)([]),a=un({data:(0,Z.useMemo)(()=>{let r=e.map(e=>J(M,e)),i=t?.map(e=>J(M,e)),a=r.map(e=>{let t=i?.find(t=>t.id===e.id);return{...e,matchingStatus:!n||n?.includes(e.id)?void 0:t?`Diff`:`Deleted`,diff:t}}),o=i?.filter(e=>e.id===`00000000-0000-0000-0000-000000000000`).map(e=>({...e,matchingStatus:`New`}))??[];return a.push(...o),a},[e,t,n]),columns:go,getCoreRowModel:Sn(),onSortingChange:i,getSortedRowModel:gn(),getPaginationRowModel:yn(),state:{sorting:r},initialState:{pagination:{pageIndex:0,pageSize:100},sorting:[{id:`invoiceDate`,desc:!0}]}});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(xn,{children:[(0,Q.jsx)(ln,{children:a.getHeaderGroups().map(e=>(0,Q.jsx)(vn,{children:e.headers.map(e=>(0,Q.jsx)(pn,{className:`text-center`,colSpan:e.colSpan,children:e.isPlaceholder?null:bn(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,Q.jsx)(_n,{children:a.getRowModel().rows?.length?a.getRowModel().rows.map(e=>(0,Q.jsx)(vn,{"data-state":e.getIsSelected()&&`selected`,className:_o(e.original.matchingStatus),children:e.getVisibleCells().map(e=>(0,Q.jsx)(X,{children:bn(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,Q.jsx)(vn,{children:(0,Q.jsx)(X,{colSpan:go.length,className:`h-24 text-center`,children:`No results.`})})})]}),(0,Q.jsx)(`div`,{className:`flex items-center justify-end space-x-2 py-4`,children:(0,Q.jsx)(Ct,{currentPageIndex:a.getState().pagination.pageIndex,totalPages:a.getPageCount(),onChange:e=>a.setPageIndex(e)})})]})},yo=({data:e})=>{let t=J(A,e);return t?.errorsLedger?.validate?.errors?.length?(0,Q.jsxs)(Fe,{shadow:`xs`,p:`md`,children:[(0,Q.jsx)(an,{c:`red`,children:`Errors:`}),(0,Q.jsx)(Lt,{size:`sm`,withPadding:!0,children:t.errorsLedger.validate.errors.map((e,t)=>(0,Q.jsx)(Lt.Item,{children:(0,Q.jsx)(an,{c:`red`,children:e})},t))})]}):null},bo=({transactionsProps:e,onChange:t})=>{let{transactions:n}=J(fe,e);return(0,Q.jsx)(Nn,{transactionsProps:n,onChange:t,enableEdit:!0})},xo=Yt(`relative w-full rounded-lg border border-gray-200 px-4 py-3 text-sm [&>svg+div]:translate-y-[-3px] [&>svg]:absolute [&>svg]:left-4 [&>svg]:top-4 [&>svg]:text-gray-950 [&>svg~*]:pl-7 dark:border-gray-800 dark:[&>svg]:text-gray-50`,{variants:{variant:{default:`bg-white text-gray-950 dark:bg-gray-950 dark:text-gray-50`,destructive:`border-red-500/50 text-red-500 dark:border-red-500 [&>svg]:text-red-500 dark:border-red-900/50 dark:text-red-900 dark:dark:border-red-900 dark:[&>svg]:text-red-900`}},defaultVariants:{variant:`default`}}),So=Z.forwardRef(({className:e,variant:t,...n},i)=>(0,Q.jsx)(`div`,{ref:i,role:`alert`,className:r(xo({variant:t}),e),...n}));So.displayName=`Alert`;var Co=Z.forwardRef(({className:e,children:t,...n},i)=>(0,Q.jsx)(`h5`,{ref:i,className:r(`mb-1 font-medium leading-none tracking-tight`,e),...n,children:t}));Co.displayName=`AlertTitle`;var wo=Z.forwardRef(({className:e,...t},n)=>(0,Q.jsx)(`div`,{ref:n,className:r(`text-sm [&_p]:leading-relaxed`,e),...t}));wo.displayName=`AlertDescription`;var To=`createDepositFromCharge`,Eo=()=>{let[{fetching:e},t]=O(p);return{creating:e,createDepositFromCharge:(0,Z.useCallback)(async e=>{let n=`Error creating deposit "${e.name}" from charge`,r=`${To}-${e.chargeId}`;P.loading(`Creating deposit`,{id:r});try{let i=de(await t(e),n,r);if(i)return P.success(`Deposit created`,{id:r,description:`Deposit "${i.createDepositFromCharge.name}" (${i.createDepositFromCharge.currency}) created successfully`}),i.createDepositFromCharge.id}catch(e){console.error(`${n}: ${e}`),P.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}return null},[t])}},Do=e=>{let[{data:t,fetching:n,error:r}]=x({query:me,variables:{chargeId:e}});return{fetching:n,error:r,deposits:t?.relevantDepositsForCharge.deposits??[],conflictError:t?.relevantDepositsForCharge.error??null}},Oo=({chargeId:e,onChange:t})=>{let[{data:n,fetching:r}]=x({query:I,variables:{chargeId:e}}),{fetching:i,deposits:a,conflictError:o}=Do(e),{creating:s,createDepositFromCharge:c}=Eo(),{assigning:l,assignChargeToDeposit:u}=Vt(),[d,f]=(0,Z.useState)(void 0),[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(``),_=(0,Z.useCallback)(async()=>{await c({chargeId:e,name:h})&&(m(!1),g(``),t?.())},[c,h,e,t]),v=(0,Z.useCallback)(async n=>{await u({chargeId:e,depositId:n}),t?.()},[u,e,t]),y=r||i||s||l,b=(0,Q.jsx)(De,{open:p,onOpenChange:m,children:(0,Q.jsxs)(_e,{children:[(0,Q.jsx)(ve,{children:(0,Q.jsx)(be,{children:`Create Bank Deposit`})}),(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Te,{htmlFor:`deposit-name-input`,children:`Deposit Name`}),(0,Q.jsx)(Wt,{id:`deposit-name-input`,value:h,onChange:e=>g(e.target.value),placeholder:`e.g. Savings Deposit 2026`})]})}),(0,Q.jsx)(ke,{children:(0,Q.jsx)(H,{variant:`secondary`,disabled:s||!h.trim(),onClick:_,children:s?`Creating…`:`Create`})})]})});if(y)return(0,Q.jsx)(ye,{className:`h-10 w-10 animate-spin`});if(n?.depositByCharge){let e=n.depositByCharge;return(0,Q.jsxs)(`div`,{children:[(0,Q.jsxs)(`div`,{className:`text-lg font-semibold mb-4`,children:[`Bank Deposit "`,e.name,`" Balance: `,e.metadata.currentBalance.formatted]}),(0,Q.jsx)(`div`,{className:`mb-4`,children:(0,Q.jsx)(`span`,{className:`text-sm text-gray-500`,children:e.isOpen?`Deposit is open`:`Deposit is closed`})}),(0,Q.jsx)(Ht,{depositId:e.id})]})}if(o)return(0,Q.jsx)(`div`,{className:`space-y-4`,children:(0,Q.jsx)(So,{variant:`destructive`,children:(0,Q.jsx)(wo,{children:o})})});if(a.length===1){let e=a[0];return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`text-sm text-gray-500`,children:`Suggested deposit:`}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(`span`,{className:`font-medium`,children:[e.name,` (`,e.currency,`)`]}),(0,Q.jsx)(H,{variant:`secondary`,disabled:l,onClick:()=>v(e.id),children:l?`Assigning…`:`Assign`})]}),(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>m(!0),children:`Create New Deposit Instead`}),b]})}return(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[(0,Q.jsx)(`div`,{className:`text-sm text-gray-500`,children:a.length===0?`No matching open deposits found.`:`Select an open deposit to assign this charge to:`}),a.length>1&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(Oe,{value:d,onValueChange:f,children:[(0,Q.jsx)(Ce,{className:`min-w-[220px]`,children:(0,Q.jsx)(ge,{placeholder:`Select deposit`})}),(0,Q.jsx)(we,{children:a.map(e=>(0,Q.jsxs)(Ee,{value:e.id,children:[e.name,` (`,e.currency,`)`]},e.id))})]}),(0,Q.jsx)(H,{variant:`secondary`,disabled:!d||l,onClick:()=>d&&v(d),children:l?`Assigning…`:`Assign`})]}),(0,Q.jsx)(H,{variant:`outline`,onClick:()=>m(!0),children:`Create New Deposit`}),b]})};function ko({row:e}){let[t,n]=(0,Z.useState)([`transactions`,`documents`]),[{data:r,fetching:i}]=x({query:N,variables:{chargeId:e.original.id??``},pause:!e.original.id}),a=r?.charge.transactions,o=!!a&&a.length>0,s=r?.charge.additionalDocuments,c=!!s&&s.length>0;return(0,Q.jsxs)(Xt,{type:`multiple`,value:t,onValueChange:n,className:`space-y-4`,children:[o&&(0,Q.jsxs)(G,{value:`transactions`,className:`rounded-lg border-2`,children:[(0,Q.jsx)(`div`,{className:`px-2 bg-gray-600/10 rounded-t-lg`,children:(0,Q.jsx)(U,{className:`p-2`,disabled:!o,children:(0,Q.jsx)(`h3`,{className:`font-semibold text-lg`,children:`Transactions`})})}),i?(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(_t,{})})}):(0,Q.jsx)(W,{children:a&&(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(Nn,{transactionsProps:a})})})]}),c&&(0,Q.jsxs)(G,{value:`documents`,className:`rounded-lg border-2`,children:[(0,Q.jsx)(`div`,{className:`px-2 bg-gray-600/10 rounded-t-lg`,children:(0,Q.jsx)(U,{className:`p-2`,disabled:!c,children:(0,Q.jsx)(`h3`,{className:`font-semibold text-lg`,children:`Documents`})})}),i?(0,Q.jsx)(W,{children:(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(_t,{})})}):(0,Q.jsx)(W,{children:s&&(0,Q.jsx)(`div`,{className:`p-2`,children:(0,Q.jsx)(Pt,{documentsProps:s})})})]})]})}var Ao=({row:e})=>{let[t,n]=(0,Z.useState)(!1);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(vn,{children:[e.getVisibleCells().map(e=>(0,Q.jsx)(X,{children:bn(e.column.columnDef.cell,e.getContext())},e.id)),(0,Q.jsx)(X,{children:(0,Q.jsx)(tt,{toggleExpansion:n,isExpanded:t})})]},e.id),t&&(0,Q.jsx)(vn,{children:(0,Q.jsx)(X,{colSpan:e.getVisibleCells().length+1,children:(0,Q.jsx)(ko,{row:e})})},`${e.id}-extensions`)]})},jo=({business:e})=>e.id?(0,Q.jsx)(L,{to:R.BUSINESSES.DETAIL(e.id),target:`_blank`,rel:`noreferrer`,onClick:e=>e.stopPropagation(),className:`inline-flex items-center font-semibold`,children:e.name}):(0,Q.jsx)(`div`,{}),Mo=({date:e})=>(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e?ct(e):``}),No=({tags:e})=>(0,Q.jsx)(st,{items:e.map(e=>(0,Q.jsx)(Ne,{children:(0,Q.jsxs)(`div`,{children:[e.namePath&&(0,Q.jsx)(an,{size:`xs`,opacity:.65,children:`${e.namePath.join(` > `)} >`}),(0,Q.jsx)(an,{size:`sm`,children:e.name})]})},e.id))}),Po=({taxCategory:e})=>(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:e?.name}),Fo=({type:e})=>{let{text:t,icon:n}=(0,Z.useMemo)(()=>({text:je(e),icon:vt(e)}),[e]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{children:t}),(0,Q.jsx)(Zr,{radius:`xl`,size:`xl`,children:n})]})},Io=[{id:`select`,cell:({row:e})=>(0,Q.jsx)(It,{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})=>(0,Q.jsx)(Be,{column:e,title:`Score`}),cell:({row:e})=>(0,Q.jsx)(Mt,{value:e.getValue(`confidenceScore`)*100,size:`sm`})},{accessorKey:`type`,header:({column:e})=>(0,Q.jsx)(Be,{column:e,title:`Type`}),cell:({row:e})=>(0,Q.jsx)(Fo,{type:e.getValue(`type`)})},{accessorKey:`date`,header:({column:e})=>(0,Q.jsx)(Be,{column:e,title:`Date`}),cell:({row:e})=>(0,Q.jsx)(Mo,{date:e.getValue(`date`)})},{accessorKey:`amountRaw`,header:({column:e})=>(0,Q.jsx)(Be,{column:e,title:`Amount`}),cell:({row:e})=>{let t=e.original.amountFormatted;return(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:t})}},{accessorKey:`vatAmountRaw`,header:({column:e})=>(0,Q.jsx)(Be,{column:e,title:`VAT`}),cell:({row:e})=>{let t=e.original.vatAmountFormatted;return(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:t})}},{accessorKey:`businessName`,header:({column:e})=>(0,Q.jsx)(Be,{column:e,title:`Main Business`}),cell:({row:e})=>(0,Q.jsx)(jo,{business:{id:e.original.businessId,name:e.original.businessName}})},{accessorKey:`description`,header:({column:e})=>(0,Q.jsx)(Be,{column:e,title:`Description`}),cell:({row:e})=>(0,Q.jsx)(`p`,{className:`text-sm font-medium max-w-100 whitespace-normal`,children:e.getValue(`description`)})},{accessorKey:`tags`,header:({column:e})=>(0,Q.jsx)(Be,{column:e,title:`Tags`}),cell:({row:e})=>(0,Q.jsx)(No,{tags:e.getValue(`tags`)}),enableSorting:!1},{accessorKey:`taxCategoryName`,header:({column:e})=>(0,Q.jsx)(Be,{column:e,title:`Tax Category`}),cell:({row:e})=>(0,Q.jsx)(Po,{taxCategory:{id:e.original.taxCategoryId,name:e.original.taxCategoryName}})}];function Lo(e,t,n){let r=J(h,e),i=r.charge.minDocumentsDate||r.charge.minEventDate||r.charge.minDebitDate||void 0;return{id:r.charge.id,confidenceScore:r.confidenceScore,type:r.charge.__typename,date:i?new Date(i):void 0,amountRaw:r.charge.totalAmount?.raw,amountFormatted:r.charge.totalAmount?.formatted,vatAmountRaw:r.charge.vat?.raw,vatAmountFormatted:r.charge.vat?.formatted,businessId:r.charge.counterparty?.id,businessName:r.charge.counterparty?.name,description:r.charge.userDescription??void 0,tags:r.charge.tags.map(e=>({id:e.id,name:e.name,namePath:e.namePath??void 0})),taxCategoryId:r.charge.taxCategory?.id,taxCategoryName:r.charge.taxCategory?.name,selectCharge:t,isSelected:r.charge.id===n}}var Ro=({originChargeId:e,chargesProps:t,onChange:n})=>{let[r,i]=(0,Z.useState)([{id:`confidenceScore`,desc:!0},{id:`amountRaw`,desc:!0}]),[a,o]=(0,Z.useState)([]),[s,c]=(0,Z.useState)(null),[l,u]=(0,Z.useState)([{id:e,onChange:n}]);(0,Z.useEffect)(()=>{u([e,...s?[s]:[]].map(e=>({id:e,onChange:n})))},[s,n,e]);let d=un({data:(0,Z.useMemo)(()=>t?.map(e=>Lo(e,c,s)).sort((e,t)=>t.confidenceScore-e.confidenceScore)??[],[t,s]),columns:Io,getCoreRowModel:Sn(),onSortingChange:i,getSortedRowModel:gn(),onColumnFiltersChange:o,getFilteredRowModel:dn(),state:{sorting:r,columnFilters:a}});return(0,Q.jsxs)(`div`,{className:`max-w-[90vw]`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center py-4 gap-4`,children:[(0,Q.jsx)(At,{selected:l,resetMerge:()=>c(null)}),(0,Q.jsxs)(Ut,{children:[(0,Q.jsx)(Kt,{asChild:!0,className:`ml-auto`,children:(0,Q.jsxs)(H,{variant:`outline`,children:[`Columns `,(0,Q.jsx)(B,{})]})}),(0,Q.jsx)(qt,{align:`end`,children:d.getAllColumns().filter(e=>e.getCanHide()).map(e=>(0,Q.jsx)(Gt,{className:`capitalize`,checked:e.getIsVisible(),onCheckedChange:t=>e.toggleVisibility(!!t),children:e.id},e.id))})]})]}),(0,Q.jsx)(`div`,{className:`overflow-hidden rounded-md border`,children:(0,Q.jsxs)(xn,{children:[(0,Q.jsx)(ln,{children:d.getHeaderGroups().map(e=>(0,Q.jsxs)(vn,{children:[e.headers.map(e=>(0,Q.jsx)(pn,{colSpan:e.colSpan,children:e.isPlaceholder?null:bn(e.column.columnDef.header,e.getContext())},e.id)),(0,Q.jsx)(pn,{})]},e.id))}),(0,Q.jsx)(_n,{children:d.getRowModel().rows?.length?d.getRowModel().rows.map(e=>(0,Q.jsx)(Ao,{row:e},e.id)):(0,Q.jsx)(vn,{children:(0,Q.jsx)(X,{colSpan:Io.length,className:`h-24 text-center`,children:`No results.`})})})]})})]})},zo=({chargeId:e,isOpened:t,onChange:n})=>{let[{data:r,fetching:i}]=x({query:b,variables:{chargeId:e},pause:!t});return(0,Q.jsxs)(G,{value:`charges-matches`,children:[(0,Q.jsx)(U,{children:`Charge Matches`}),(0,Q.jsx)(W,{children:i?(0,Q.jsx)(ye,{className:`h-10 w-10 animate-spin`}):(0,Q.jsx)(Ro,{originChargeId:e,chargesProps:r?.findChargeMatches.matches,onChange:n})})]})},Bo=({chargeProps:e})=>{let t=J(o,e);if(t.__typename!==`ConversionCharge`)return(0,Q.jsx)(Q.Fragment,{});let{eventRate:n,officialRate:r}=t;return(0,Q.jsxs)(Ft,{justify:`center`,children:[r&&(0,Q.jsx)(Ft.Col,{span:`content`,children:(0,Q.jsx)(Tn,{shadow:`sm`,padding:`xs`,radius:`md`,withBorder:!0,children:(0,Q.jsxs)(Ne,{position:`apart`,children:[(0,Q.jsx)(an,{weight:500,children:`Official Conversion Rate`}),(0,Q.jsx)(kr,{color:`green`,variant:`light`,children:`${Number(r.rate)} ${Xe(r.from)} => ${Xe(r.to)}`})]})})}),n&&(0,Q.jsx)(Ft.Col,{span:`content`,children:(0,Q.jsx)(Tn,{shadow:`sm`,padding:`xs`,radius:`md`,withBorder:!0,children:(0,Q.jsxs)(Ne,{position:`apart`,children:[(0,Q.jsx)(an,{weight:500,children:`Bank Conversion Rate`}),(0,Q.jsx)(kr,{color:`green`,variant:`light`,children:`${Number(n.rate)} ${Xe(n.from)} => ${Xe(n.to)}`})]})})})]})},Vo=({chargeProps:e})=>{let t=J(s,e),n=(0,Z.useMemo)(()=>t.__typename===`CreditcardBankCharge`&&t.creditCardTransactions?t.creditCardTransactions.map(e=>J(F,e)):[],[t]);return n.length?(0,Q.jsxs)(xn,{children:[(0,Q.jsx)(ln,{children:(0,Q.jsxs)(vn,{children:[(0,Q.jsx)(pn,{children:`Event Date`}),(0,Q.jsx)(pn,{children:`Debit Date`}),(0,Q.jsx)(pn,{children:`Amount`}),(0,Q.jsx)(pn,{children:`Account`}),(0,Q.jsx)(pn,{children:`Description`}),(0,Q.jsx)(pn,{children:`Reference#`}),(0,Q.jsx)(pn,{children:`Counterparty`}),(0,Q.jsx)(pn,{children:`Charge`})]})}),(0,Q.jsx)(_n,{children:n.map(e=>{let t={...e,onUpdate:()=>void 0,editTransaction:()=>void 0,enableEdit:!1,enableChargeLink:!1};return(0,Q.jsxs)(vn,{children:[(0,Q.jsx)(X,{children:(0,Q.jsx)(Mn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(Dn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(An,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(En,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(On,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(jn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(kn,{transaction:t})}),(0,Q.jsx)(X,{children:(0,Q.jsx)(jt,{chargeId:e.chargeId})})]},e.id)})})]}):null},Ho=({chargeProps:e})=>{let t=J(oe,e),n=(0,Z.useMemo)(()=>t.__typename===`FinancialCharge`?Object.entries(t.exchangeRates??{}).sort((e,t)=>e[0].localeCompare(t[0])):[],[t]);return t.__typename===`FinancialCharge`?(0,Q.jsx)(`div`,{className:`flex flex-row flex-wrap gap-2 px-2`,children:n.map(([e,t])=>(0,Q.jsx)($t,{className:`gap-0 py-2`,children:(0,Q.jsxs)(Zt,{className:`flex flex-col px-2`,children:[(0,Q.jsx)(Qt,{className:`text-xl font-semibold`,children:e.toLocaleUpperCase()}),(0,Q.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,Q.jsxs)(`span`,{className:`whitespace-nowrap`,children:[Xe(e.toLocaleUpperCase()),`1=`]}),(0,Q.jsxs)(fn,{variant:`default`,className:`flex gap-1 rounded-lg text-md`,children:[Xe(u.Ils),t]})]})]})},e))}):(0,Q.jsx)(Q.Fragment,{})},Uo=`deleteMiscExpense`,Wo=()=>{let[{fetching:e},t]=O(c);return{fetching:e,deleteMiscExpense:(0,Z.useCallback)(async e=>{let n=`Error deleting misc expense`,r=`${Uo}-${e.id}`;P.loading(`Deleting misc expense`,{id:r});try{let i=de(await t(e),n,r);if(i)return P.success(`Success`,{id:r,description:`Misc expense was deleted successfully`}),i.deleteMiscExpense}catch(e){console.error(`${n}: ${e}`),P.error(`Error`,{id:r,description:n,duration:1e5,closeButton:!0})}},[t])}};function Go({miscExpenseId:e,onChange:t}){let{deleteMiscExpense:n}=Wo();async function r(){try{await n({id:e}),t?.()}catch(e){let t=`Failed to delete misc expense`;console.error(`${t}: ${e}`),P.error(`Error`,{description:t})}}return(0,Q.jsx)(Nt,{onConfirm:r,title:`Are you sure you want to delete this expense?`,children:(0,Q.jsx)(H,{className:`size-7.5 text-red-500`,variant:`ghost`,children:(0,Q.jsx)(zt,{className:`size-5`})})})}var Ko=({miscExpensesData:e,onChange:t})=>{let{miscExpenses:n}=J(i,e);return(0,Q.jsxs)(`table`,{className:`w-full h-full`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Creditor`}),(0,Q.jsx)(`th`,{children:`Debtor`}),(0,Q.jsx)(`th`,{children:`Amount`}),(0,Q.jsx)(`th`,{children:`Invoice Date`}),(0,Q.jsx)(`th`,{children:`Value Date`}),(0,Q.jsx)(`th`,{children:`Description`}),(0,Q.jsx)(`th`,{children:`Actions`})]})}),(0,Q.jsx)(`tbody`,{children:n?.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.creditor?.name})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.debtor?.name})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.amount?.formatted})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.invoiceDate})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.valueDate&&mn(new Date(e.valueDate),`yyyy-MM-dd`)})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.description})}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(Ke,{onDone:t,data:e}),(0,Q.jsx)(Go,{miscExpenseId:e.id,onChange:t})]})]},e?.id))})]})},qo=({salaryRecordsProps:e})=>{let t=J(ee,e);if(t.__typename!==`SalaryCharge`)return(0,Q.jsx)(Q.Fragment,{});let{salaryRecords:n}=t;return(0,Q.jsxs)(`table`,{className:`w-full h-full`,children:[(0,Q.jsx)(`thead`,{children:(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`th`,{children:`Employee`}),(0,Q.jsx)(`th`,{children:`Direct Salary`}),(0,Q.jsx)(`th`,{children:`Base Salary`}),(0,Q.jsx)(`th`,{children:`Pension`}),(0,Q.jsx)(`th`,{children:`Training Fund`}),(0,Q.jsx)(`th`,{children:`Social Security`}),(0,Q.jsx)(`th`,{children:`Tax`})]})}),(0,Q.jsx)(`tbody`,{children:n?.map(e=>(0,Q.jsxs)(`tr`,{children:[(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.employee?.name??`Missing`})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.directAmount.formatted})}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.baseAmount?.formatted})}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(`div`,{children:e.pensionFund?.name}),(0,Q.jsxs)(`div`,{children:[`Employee: `,e.pensionEmployeeAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Employer: `,e.pensionEmployerAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Compensation: `,e.compensationsAmount?.formatted]})]}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsx)(`div`,{children:e.trainingFund?.name}),(0,Q.jsxs)(`div`,{children:[`Employee: `,e.trainingFundEmployeeAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Employer: `,e.trainingFundEmployerAmount?.formatted]})]}),(0,Q.jsxs)(`td`,{children:[(0,Q.jsxs)(`div`,{children:[`Employee: `,e.socialSecurityEmployeeAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Employer: `,e.socialSecurityEmployerAmount?.formatted]}),(0,Q.jsxs)(`div`,{children:[`Health: `,e.healthInsuranceAmount?.formatted]})]}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{children:e.incomeTaxAmount?.formatted})})]},`${e.employee?.name}-${e.baseAmount}`))})]})};function Jo({chargeID:e,onChange:t=()=>void 0,fetching:n}){let[r,a]=(0,Z.useState)([]),[c,l]=(0,Z.useState)(e),[u,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(void 0),[{data:m,fetching:h},_]=x({query:k,variables:{chargeId:c}}),y=(0,Z.useCallback)(()=>{_(),t()},[_,t]);(0,Z.useEffect)(()=>{m?.charge&&p(m.charge)},[m]),(0,Z.useEffect)(()=>{n&&_()},[n,_]),(0,Z.useEffect)(()=>{e!==c&&(l(e),_())},[e,c,_]);let b=f?.__typename,S=!!f?.metadata?.ledgerCount,C=!!f?.metadata?.transactionsCount,w=!!f?.metadata?.documentsCount,T=!!f?.metadata?.receiptsCount,E=!!f?.metadata?.invoicesCount,D=b===`SalaryCharge`,O=!!f?.miscExpenses?.length,te=f?.metadata?.openDocuments,ne=(f?.totalAmount?.raw??0)>0&&!T,re=!(E||T)||!C;(0,Z.useEffect)(()=>{C&&a(e=>e.includes(`transactions`)?e:[...e,`transactions`])},[C]),(0,Z.useEffect)(()=>{w&&a(e=>e.includes(`documents`)?e:[...e,`documents`])},[w]),(0,Z.useEffect)(()=>{S&&a(e=>e.includes(`ledger`)?e:[...e,`ledger`])},[S]),(0,Z.useEffect)(()=>{D&&a(e=>e.includes(`salaries`)?e:[...e,`salaries`])},[D]),(0,Z.useEffect)(()=>{O&&a(e=>e.includes(`miscExpenses`)?e:[...e,`miscExpenses`])},[O]);let ie=q(k,se,f),ae=q(k,v,f),ce=q(k,g,f),j=q(k,fe,f),M=q(k,i,f),N=(0,Z.useMemo)(()=>b===`ConversionCharge`&&q(k,o,f),[f,b]),P=(0,Z.useMemo)(()=>b===`FinancialCharge`&&q(k,oe,f),[f,b]),F=b===`SalaryCharge`&&q(k,ee,f),le=(0,Z.useMemo)(()=>b===`CreditcardBankCharge`&&q(k,s,f),[f,b]);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[h&&(0,Q.jsx)(tn,{className:`flex self-center my-5`,color:`dark`,size:`xl`,variant:`dots`}),q(k,A,f)&&(0,Q.jsx)(yo,{data:f}),f&&(0,Q.jsxs)(`div`,{className:`flex flex-row`,children:[(0,Q.jsxs)(Xt,{className:`w-full`,type:`multiple`,value:r,onValueChange:a,children:[b===`ConversionCharge`&&(0,Q.jsxs)(G,{value:`conversion`,children:[(0,Q.jsx)(U,{disabled:!C,children:`Conversion Info`}),(0,Q.jsx)(W,{children:N&&(0,Q.jsx)(Bo,{chargeProps:f})})]}),b===`FinancialCharge`&&(0,Q.jsxs)(G,{value:`exchangeRates`,children:[(0,Q.jsx)(U,{disabled:!P,children:`Exchange Rates`}),(0,Q.jsx)(W,{children:P&&(0,Q.jsx)(Ho,{chargeProps:f})})]}),C&&(0,Q.jsxs)(G,{value:`transactions`,children:[(0,Q.jsx)(U,{disabled:!C,children:(0,Q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 justify-between w-full`,children:[`Transactions`,ne&&(0,Q.jsx)(xt,{chargeId:f.id})]})}),(0,Q.jsx)(W,{children:j&&(0,Q.jsx)(bo,{transactionsProps:f,onChange:y})})]}),O&&(0,Q.jsxs)(G,{value:`miscExpenses`,children:[(0,Q.jsx)(U,{disabled:!O,children:`Misc Expenses`}),(0,Q.jsx)(W,{children:M&&(0,Q.jsx)(Ko,{miscExpensesData:f,onChange:y})})]}),w&&(0,Q.jsxs)(G,{value:`documents`,children:[(0,Q.jsx)(U,{disabled:!w,children:(0,Q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 justify-between w-full`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 justify-start`,children:[w&&(0,Q.jsx)(ht,{content:`Documents Gallery`,children:(0,Q.jsx)(H,{onClick:e=>{e.stopPropagation(),d(e=>!e)},variant:`outline`,disabled:!ie,size:`icon`,className:`size-7.5 text-gray-500`,children:(0,Q.jsx)(rt,{className:`size-5`})})}),`Documents`]}),te&&(0,Q.jsx)(xt,{chargeId:f.id})]})}),(0,Q.jsx)(W,{children:ae&&(0,Q.jsx)(Pt,{documentsProps:J(v,f)?.additionalDocuments,onChange:y})})]}),b===`SalaryCharge`&&(0,Q.jsxs)(G,{value:`salaries`,children:[(0,Q.jsx)(U,{disabled:!D,children:`Salaries`}),(0,Q.jsx)(W,{children:F&&(0,Q.jsx)(qo,{salaryRecordsProps:f})})]}),f.__typename===`BusinessTripCharge`&&(0,Q.jsxs)(G,{value:`businessTrip`,children:[(0,Q.jsx)(U,{children:`Business Trip`}),(0,Q.jsx)(W,{children:(0,Q.jsx)(ut,{data:f.businessTrip})})]}),b===`CreditcardBankCharge`&&(0,Q.jsxs)(G,{value:`creditcard`,children:[(0,Q.jsx)(U,{children:`CreditCard Transactions`}),(0,Q.jsx)(W,{children:le&&(0,Q.jsx)(Vo,{chargeProps:f})})]}),S&&(0,Q.jsxs)(G,{value:`ledger`,children:[(0,Q.jsx)(U,{disabled:!S,onClick:e=>{e.stopPropagation()},children:(0,Q.jsxs)(`div`,{className:`flex flex-row items-center gap-2 justify-start w-full`,children:[!f.metadata?.isLedgerLocked&&(0,Q.jsx)($e,{chargeId:f.id,onChange:y,variant:`outline`}),`Ledger Records`]})}),(0,Q.jsx)(W,{children:ce&&(0,Q.jsx)(Yo,{data:f})})]}),b===`BankDepositCharge`&&(0,Q.jsxs)(G,{value:`bankDeposit`,children:[(0,Q.jsx)(U,{children:`Bank Deposit`}),(0,Q.jsx)(W,{children:(0,Q.jsx)(Oo,{chargeId:f.id})})]}),re&&(0,Q.jsx)(zo,{chargeId:f.id,onChange:y,isOpened:r.includes(`charges-matches`)})]}),ie&&(0,Q.jsx)(Cn,{maw:`1/6`,children:(0,Q.jsx)(ar,{in:u,transitionDuration:500,transitionTimingFunction:`linear`,children:(0,Q.jsx)(uo,{chargeProps:f,onChange:y})})})]}),!h&&!f&&(0,Q.jsx)(`p`,{children:`Error fetching extended information for this charge`})]})}var Yo=({data:e})=>{let{ledger:t}=J(g,e);return(0,Q.jsx)(vo,{ledgerRecordsData:t.records,ledgerDiffData:t.validate?.differences,matches:t.validate?.matches})},Xo=({toggleMergeCharge:e,isSelectedForMerge:t,data:n,isAllOpened:r})=>{let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(J(E,n)),[{data:c,fetching:l},u]=x({query:_,pause:!0,variables:{chargeId:n.id}}),d=u;(0,Z.useEffect)(()=>{let e=c?.charge;e&&s(J(E,e))},[c]),(0,Z.useEffect)(()=>{s(J(E,n))},[n]),(0,Z.useEffect)(()=>{a(r)},[r]);let f=(0,Z.useMemo)(()=>!!(o.metadata?.documentsCount||o.metadata?.transactionsCount||o.metadata?.ledgerCount||o.metadata?.miscExpensesCount),[o.metadata?.documentsCount,o.metadata?.transactionsCount,o.metadata?.ledgerCount,o.metadata?.miscExpensesCount]),p=(o?.totalAmount?.raw??0)>0;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`tr`,{onClick:()=>{f&&(a(e=>!e),d())},children:[(0,Q.jsx)(si,{data:o}),(0,Q.jsx)(ni,{data:o}),(0,Q.jsx)($r,{data:o}),(0,Q.jsx)(ci,{data:o}),q(E,C,o)?(0,Q.jsx)(ti,{data:o}):(0,Q.jsx)(`td`,{}),(0,Q.jsx)(ri,{data:o,onChange:d}),q(E,j,o)?(0,Q.jsx)(ai,{data:o,onChange:d}):(0,Q.jsx)(`td`,{}),q(E,ae,o)?(0,Q.jsx)(oi,{data:o}):(0,Q.jsx)(`td`,{}),q(E,S,o)?(0,Q.jsx)(ei,{data:o}):(0,Q.jsx)(`td`,{}),(0,Q.jsx)(ii,{data:o}),(0,Q.jsx)(Qr,{data:o,onChange:d}),(0,Q.jsx)(`td`,{children:(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:e&&(0,Q.jsx)(ze,{toggleMergeSelected:()=>e(d),mergeSelected:t})})}),(0,Q.jsx)(`td`,{children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(xi,{chargeId:o.id,chargeType:o.__typename,onChange:d,isIncome:p}),f&&(0,Q.jsx)(tt,{toggleExpansion:a,isExpanded:i,onClickAction:()=>d()})]})})]}),f&&i&&(0,Q.jsx)(`tr`,{children:(0,Q.jsx)(`td`,{colSpan:13,children:(0,Q.jsx)(Fe,{style:{width:`100%`},withBorder:!0,shadow:`lg`,children:(0,Q.jsx)(Jo,{chargeID:o.id,onChange:d,fetching:l})})})})]})},Zo=({toggleMergeCharge:e,mergeSelectedCharges:t,data:n,isAllOpened:r})=>{let i=n?.map(e=>J(pe,e))??[];return(0,Q.jsxs)(Dt,{striped:!0,highlightOnHover:!0,children:[(0,Q.jsx)(`thead`,{className:`sticky top-0 z-20`,children:(0,Q.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:[(0,Q.jsx)(`th`,{children:`Type`}),(0,Q.jsx)(`th`,{children:`Date`}),(0,Q.jsx)(`th`,{children:`Amount`}),(0,Q.jsx)(`th`,{children:`Vat`}),(0,Q.jsx)(`th`,{children:`Counterparty`}),(0,Q.jsx)(`th`,{children:`Description`}),(0,Q.jsx)(`th`,{children:`Tags`}),(0,Q.jsx)(`th`,{children:`Tax Category`}),(0,Q.jsx)(`th`,{children:`Business Trip`}),(0,Q.jsx)(`th`,{children:`More Info`}),(0,Q.jsx)(`th`,{children:`Accountant Approval`}),(0,Q.jsx)(`th`,{children:`Edit`}),(0,Q.jsx)(`th`,{children:`More Info`})]})}),(0,Q.jsx)(`tbody`,{children:i?.map(n=>(0,Q.jsx)(Xo,{data:n,toggleMergeCharge:e?t=>e(n.id,t):void 0,isSelectedForMerge:t?.has(n.id)??!1,isAllOpened:r},n.id))})]})};export{Co as a,ar as c,wo as i,Jo as n,vo as o,So as r,Zr as s,Zo as t};