1import{am as He,$ as Qe,A as q,j as e,i as Je,I as he,a0 as fe,as as Ze,h as oe,B as A,at as Re,M as _e,p as Fe,m as en,n as nn,q as ke,o as tn,aj as an,T as sn,au as on,C as ce,t as rn,D as ln,k as cn,av as dn,ak as mn,af as un,d as pn}from"./index.D89Ptodw.js";import{r as p,f as fn,L as _n}from"./router.CrG4uXDR.js";import{C as hn}from"./Can.DICIOakJ.js";import{T as gn}from"./Table.BD9xeMR9.js";import{E as we}from"./ExportDropdown.B59T4IB-.js";import{S as xn}from"./SelectionBar.5rvukuN_.js";import{P as L}from"./charts.Xucaesy1.js";import{I as yn}from"./InstitutionLogo.BPJtk7sx.js";import{C as ge}from"./CurrencyInput.29OeOaKN.js";import{P as bn,p as Cn,c as jn,a as Pn}from"./paymentMethods.M7OriZLd.js";import{d as vn}from"./downloadFile.B6ivEmo6.js";import{o as Fn,b as de,n as Dn,u as En}from"./forms.DxV8EmvE.js";import{u as Q}from"./i18n.B5PADymj.js";import{E as Nn}from"./ExpenseForm.URdh-365.js";import{s as me,D as Mn}from"./DateRangePicker.BQpw0xj3.js";import{u as Sn,t as ue,P as Rn}from"./usePeriodFilter.gXHZFzdK.js";import{e as X}from"./useEntryOptions.C4tKQxWE.js";import{u as kn}from"./useCategoriesByType.C3UYTJUR.js";import{D as Ae,a as Ce,E as wn,u as An,b as Tn,c as In,O as Ln}from"./OccurrenceBadge.C0G9VBXH.js";import{e as pe}from"./endOfMonth.BMHN-Plw.js";import{p as Te}from"./parseISO.BuU9gaic.js";import{R as Bn}from"./RecurrentExpenseDeleteModal.Bp2mo2Mk.js";import{I as On}from"./ImportEntityModal.DP7DOsrb.js";import{e as je,E as Pe}from"./eventBus.a_hYFyd8.js";import{a as Vn}from"./useActiveAccounts.BaDOLXPP.js";import"./http.DWSTd2rM.js";import"./Pagination.DK1pH-iI.js";import"./Checkbox.ByB3bz6y.js";import"./Dropdown.DKfOXgYp.js";import"./accountOptions.CaVhY7sp.js";import"./FileInput.CUAyDLvG.js";import"./Toggle.BgKaWwTp.js";import"./QuickAccountModal.B83b9gY2.js";import"./InstitutionSelect.spqkkiNQ.js";import"./accountsService.DNsJ4FYX.js";import"./NoAccountsHint.KIwB9TGS.js";import"./useRecurrenceCount.DyNB7edz.js";import"./S3DirectUploadInput.Z-gJ29ST.js";import"./addMonths.BI0O3eJb.js";import"./endOfDay.Dh_Tc5XE.js";import"./expenseSchema.4S9jKmeb.js";import"./useProviderOptions.DqIBekKV.js";import"./useInfiniteQuery.BbqtQv1s.js";import"./pagination.C9o52mBX.js";import"./useIdempotencyKey.CZVjbl3z.js";import"./importService.DuSIbONN.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};n.SENTRY_RELEASE={id:"99974e3139a959f25517126c07ed286661dfae1f"};var a=new n.Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="d30dc1d6-7db1-48d4-a928-9ca872d8d6df",n._sentryDebugIdIdentifier="sentry-dbid-d30dc1d6-7db1-48d4-a928-9ca872d8d6df")}catch{}})();const $n="ConfirmPaymentForm-module__form___ZixCr",Gn="ConfirmPaymentForm-module__formContent___Ml8Bj",qn="ConfirmPaymentForm-module__expenseInfo___DQsf9",Un="ConfirmPaymentForm-module__expenseTitle___WxaK1",zn="ConfirmPaymentForm-module__amountsGrid___00GQg",Kn="ConfirmPaymentForm-module__amountCard___N7Mbw",Wn="ConfirmPaymentForm-module__totalCard___5r-0J",Xn="ConfirmPaymentForm-module__paidCard___D8XXS",Yn="ConfirmPaymentForm-module__pendingCard___TVNP3",Hn="ConfirmPaymentForm-module__amountLabel___MC6-O",Qn="ConfirmPaymentForm-module__amountValue___1B0gw",Jn="ConfirmPaymentForm-module__detailsGrid___-ZVt-",Zn="ConfirmPaymentForm-module__infoRow___6haU2",et="ConfirmPaymentForm-module__infoLabel___NXKaE",nt="ConfirmPaymentForm-module__infoValue___b35T0",tt="ConfirmPaymentForm-module__totalAmount___2Iop5",at="ConfirmPaymentForm-module__paidAmount___fH9Cl",st="ConfirmPaymentForm-module__pendingAmount___NVJ-t",ot="ConfirmPaymentForm-module__notesBlock___Eok8H",rt="ConfirmPaymentForm-module__notesText___5DpgE",it="ConfirmPaymentForm-module__attachmentsBlock___mK5cV",lt="ConfirmPaymentForm-module__attachmentsList___EWV8-",ct="ConfirmPaymentForm-module__attachmentItem___Hf3Ht",dt="ConfirmPaymentForm-module__attachmentName___TG-BF",mt="ConfirmPaymentForm-module__attachmentDownload___Kgz8m",ut="ConfirmPaymentForm-module__formGroup___AhcWX",pt="ConfirmPaymentForm-module__accountBalance___cVSgT",ft="ConfirmPaymentForm-module__infoIcon___sfdcs",_t="C
1onfirmPaymentForm-module__actions___UVFHd",s={form:$n,formContent:Gn,expenseInfo:qn,expenseTitle:Un,amountsGrid:zn,amountCard:Kn,totalCard:Wn,paidCard:Xn,pendingCard:Yn,amountLabel:Hn,amountValue:Qn,detailsGrid:Jn,infoRow:Zn,infoLabel:et,infoValue:nt,totalAmount:tt,paidAmount:at,pendingAmount:st,notesBlock:ot,notesText:rt,attachmentsBlock:it,attachmentsList:lt,attachmentItem:ct,attachmentName:dt,attachmentDownload:mt,formGroup:ut,accountBalance:pt,infoIcon:ft,actions:_t},ht=(n,a,o)=>Fn({account_id:de().min(1,{error:n("confirmPaymentForm.errors.accountRequired")}).refine(m=>a.some(f=>f.id.toString()===m),{error:n("confirmPaymentForm.errors.accountNotFound")}),payment_method:de().min(1,{error:n("confirmPaymentForm.errors.paymentMethodRequired")}).refine(m=>bn.includes(m),{error:n("confirmPaymentForm.errors.invalidPaymentMethod")}),payment_date:de().min(1,{error:n("confirmPaymentForm.errors.paymentDateRequired")}).refine(m=>!isNaN(new Date(m).getTime()),{error:n("confirmPaymentForm.errors.invalidDate")}).refine(m=>{const f=new Date(m),h=new Date;return h.setHours(23,59,59,999),f<=h},{error:n("confirmPaymentForm.errors.futureDate")}),paid_amount:Dn({error:n("confirmPaymentForm.errors.amountMustBeNumber")}).positive({error:n("confirmPaymentForm.errors.amountMustBePositive")}).max(parseFloat(o?.pending_amount||0),{error:n("confirmPaymentForm.errors.amountExceedsPending",{pending:o?.pending_amount_formatted||"0"})}).refine(m=>Math.round(m*100)/100===m,{error:n("confirmPaymentForm.errors.maxTwoDecimals")}),notes:de().max(1e3,{error:n("confirmPaymentForm.errors.notesTooLong")}).optional().default("")});function gt({expense:n,accounts:a}){const{t:o}=Q("finances"),m=ht(o,a,n),{register:f,handleSubmit:h,watch:i,setValue:_,formState:{errors:x}}=En({resolver:Qe(m),defaultValues:{account_id:n?.account_id?.toString()||n?.account?.id?.toString()||"",payment_method:n?.payment_method||"",payment_date:He(new Date,"yyyy-MM-dd"),paid_amount:parseFloat(n?.pending_amount||0)||"",notes:""}}),r=Cn(o,"confirmPaymentForm.paymentMethods"),j=i("account_id"),D=p.useMemo(()=>j?a.find(t=>t.id.toString()===j.toString()):null,[j,a]),C=i("paid_amount");p.useMemo(()=>{const t=parseFloat(n?.amount||0),N=parseFloat(n?.paid_amount||0),k=parseFloat(C||0);return Math.max(0,t-N-k)},[n?.amount,n?.paid_amount,C]);function g(){return parseFloat(n?.amount||0)-parseFloat(n?.paid_amount||0)}function v(){return{description:n?.title||n?.description,totalAmount:parseFloat(n?.amount||0),paidAmount:parseFloat(n?.paid_amount||0),pendingAmount:parseFloat(n?.pending_amount||0),issueDate:n?.issue_date,dueDate:n?.due_date,competenceDate:n?.competence_date,paymentDate:n?.payment_date,hasPartialPayment:parseFloat(n?.paid_amount||0)>0,provider:n?.provider?.name||n?.provider_name,category:n?.category?.name||n?.category_name,subcategory:n?.subcategory?.name||n?.subcategory_name,subsubcategory:n?.subsubcategory?.name||n?.subsubcategory_name,account:n?.account?.name||n?.account_name,paymentMethod:n?.payment_method,status:n?.status,occurrence:n?.occurrence,installments:n?.installments,recurrenceEndDate:n?.recurrence_end_date,notes:n?.notes,attachments:Array.isArray(n?.attachments)?n.attachments:[]}}function R(t){return N=>{t(N)}}return{register:f,handleSubmit:h,watch:i,setValue:_,errors:x,paymentMethods:r,selectedAccount:D,getPendingAmount:g,getExpenseInfo:v,handleFormSubmit:R}}function ve({expense:n,accounts:a,onSubmit:o,onCancel:m,isLoading:f=!1,readOnly:h=!1}){const{t:i}=Q("finances"),{register:_,handleSubmit:x,errors:r,watch:j,setValue:D,paymentMethods:C,selectedAccount:g,getExpenseInfo:v,handleFormSubmit:R}=gt({expense:n,accounts:a}),t=v(),N=a.map(d=>{const c=d.balance?.formatted?d.balance.formatted:q.formatCurrency(d.balance?.raw??d.balance??0);return{value:String(d.id),label:`${d.name} â ${c}`,icon:d.institution?e.jsx(yn,{name:d.institution,domain:d.financial_institution?.domain,size:20}):void 0}}),k=C.map(d=>({value:d.id,label:d.name}));return e.jsxs("form",{onSubmit:x(R(o)),className:s.form,children:[e.jsxs("div",{className:s.formContent,children:[e.jsxs("div",{className:s.expenseInfo,children:[e.jsx("h3",{className:s.expenseTitle,children:t.description}),e.jsxs("div",{className:s.amountsGrid,children:[e.jsxs("div",{className:`${s.amountC
1ard} ${s.totalCard}`,children:[e.jsx("span",{className:s.amountLabel,children:i("confirmPaymentForm.totalAmount")}),e.jsx("span",{className:`${s.amountValue} ${s.totalAmount}`,children:q.formatCurrency(t.totalAmount)})]}),t.hasPartialPayment&&e.jsxs("div",{className:`${s.amountCard} ${s.paidCard}`,children:[e.jsx("span",{className:s.amountLabel,children:i("confirmPaymentForm.amountPaid")}),e.jsx("span",{className:`${s.amountValue} ${s.paidAmount}`,children:q.formatCurrency(t.paidAmount)})]}),e.jsxs("div",{className:`${s.amountCard} ${s.pendingCard}`,children:[e.jsx("span",{className:s.amountLabel,children:i("confirmPaymentForm.pendingAmount")}),e.jsx("span",{className:`${s.amountValue} ${s.pendingAmount}`,children:q.formatCurrency(t.pendingAmount)})]})]}),e.jsxs("div",{className:s.detailsGrid,children:[t.provider&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.provider","Fornecedor"),":"]}),e.jsx("span",{className:s.infoValue,children:t.provider})]}),t.category&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.category","Categoria"),":"]}),e.jsxs("span",{className:s.infoValue,children:[t.category,t.subcategory?` / ${t.subcategory}`:"",t.subsubcategory?` / ${t.subsubcategory}`:""]})]}),t.account&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.linkedAccount","Conta vinculada"),":"]}),e.jsx("span",{className:s.infoValue,children:t.account})]}),t.paymentMethod&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.originalPaymentMethod","Forma original"),":"]}),e.jsx("span",{className:s.infoValue,children:i(`confirmPaymentForm.paymentMethods.${jn(t.paymentMethod)}`,t.paymentMethod)})]}),t.status&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.status","Status"),":"]}),e.jsx("span",{className:s.infoValue,children:i(`expenseForm.status.${t.status}`,t.status)})]}),t.occurrence&&t.occurrence!=="single"&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.occurrence","Recorrência"),":"]}),e.jsxs("span",{className:s.infoValue,children:[i(`expenseForm.occurrenceTypes.${t.occurrence}`,t.occurrence),t.installments?` (${t.installments}x)`:""]})]}),t.issueDate&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.issueDate","Emissão"),":"]}),e.jsx("span",{className:s.infoValue,children:q.formatDate(t.issueDate)})]}),e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.dueDate"),":"]}),e.jsx("span",{className:s.infoValue,children:t.dueDate?q.formatDate(t.dueDate):"-"})]}),t.competenceDate&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.competenceDate","Competência"),":"]}),e.jsx("span",{className:s.infoValue,children:q.formatDate(t.competenceDate)})]}),t.paymentDate&&e.jsxs("div",{className:s.infoRow,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.paymentDate"),":"]}),e.jsx("span",{className:s.infoValue,children:q.formatDate(t.paymentDate)})]})]}),t.notes&&e.jsxs("div",{className:s.notesBlock,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.originalNotes","Observações"),":"]}),e.jsx("p",{className:s.notesText,children:t.notes})]}),t.attachments.length>0&&e.jsxs("div",{className:s.attachmentsBlock,children:[e.jsxs("span",{className:s.infoLabel,children:[i("confirmPaymentForm.attachments","Anexos")," (",t.attachments.length,")"]}),e.jsx("ul",{className:s.attachmentsList,children:t.attachments.map((d,c)=>e.jsxs("li",{className:s.attachmentItem,children:[e.jsx("span",{className:s.attachmentName,children:d.original_name||d.name||`arquivo-${c+1}`}),d.url&&e.jsx("button",{type:"button",className:s.attachmentDownload,onClick:()=>vn(d.url,d.original_name||d.name),title:i("confirmPaymentForm.download","Baixar"),children:e.jsx(Je,{})})]},d.path||d.url||c))})]})]}),e.jsx("div",{className:s.formGroup,children:e.jsx(ge,{label:i("confirmPaymentForm.paidAmount"),placeholder:i("confirmPaymentForm.amountPlaceholder"),value:j("paid_amount"),onValueChange:d=>{D("paid_amount",d)},name:"paid_amount",disabled:h,error:r.paid_amount?.message})}),e.jsx("div",{className:s.formGroup,children:e.jsx(he,{type:"date",label:i("confirmPaymentForm.paymentDate"),error:r.payment_date?.message,disabled:h,..._("payment_date")})}),!h&&e.jsxs("div",{className:s.formGroup,children:[e.jsx(fe,{label:i("confirmPaymentForm.paymentAccount"),placeholder:i("confirmPaymentForm.selectAccount"),options:N,disabled:h,error:r.account_id?.message,value:j("account_id"),onChange:d=>D("account_id",d,{shouldValidate:!0})}),g&&e.jsxs("div",{className:s.accountBalance,children:[e.jsx(Ze,{size:14,className:s.infoIcon}),e.jsxs("span",{children:[i("confirmPaymentForm.balance"),": ",g.balance?.formatted||q.formatCurrency(g.balance?.raw||
10)]})]})]}),!h&&e.jsx("div",{className:s.formGroup,children:e.jsx(oe,{label:i("confirmPaymentForm.paymentMethod"),placeholder:i("confirmPaymentForm.selectPaymentMethod"),options:k,disabled:h,error:r.payment_method?.message,value:j("payment_method"),onChange:d=>D("payment_method",d,{shouldValidate:!0})})}),e.jsx("div",{className:s.formGroup,children:e.jsx(he,{label:i("confirmPaymentForm.notes"),placeholder:i("confirmPaymentForm.notesPlaceholder"),multiline:!0,disabled:h,..._("notes")})})]}),e.jsxs("div",{className:s.actions,children:[e.jsx(A,{type:"button",variant:"secondary",onClick:m,children:i(h?"confirmPaymentForm.close":"confirmPaymentForm.cancel")}),!h&&e.jsx(A,{type:"submit",loading:f,children:i("confirmPaymentForm.confirmPayment")})]})]})}ve.propTypes={expense:L.object.isRequired,accounts:L.array.isRequired,onSubmit:L.func.isRequired,onCancel:L.func.isRequired,isLoading:L.bool,readOnly:L.bool};const xt="ExpenseFilters-module__container___AuGP2",yt="ExpenseFilters-module__header___dLMsP",bt="ExpenseFilters-module__searchInput___22c-5",Ct="ExpenseFilters-module__filterButton___BmeCY",jt="ExpenseFilters-module__form___a6bug",Pt="ExpenseFilters-module__grid___l-Xci",vt="ExpenseFilters-module__fieldGroup___hx8i5",Ft="ExpenseFilters-module__actions___noPeI",$={container:xt,header:yt,searchInput:bt,filterButton:Ct,form:jt,grid:Pt,fieldGroup:vt,actions:Ft},Dt={from:"due_date_from",to:"due_date_to"},ee=n=>q.toISODate(n);function Et(n,a){if(typeof window>"u")return{startDate:n,endDate:a};const o=new URLSearchParams(window.location.search),m=o.get("due_date_from"),f=o.get("due_date_to");if(!m||!f)return{startDate:n,endDate:a};const h=Te(m),i=Te(f);return!Re(h)||!Re(i)?{startDate:n,endDate:a}:{startDate:h,endDate:i}}function Nt(){const{t:n}=Q("finances"),[a,o]=p.useState(!1),m=new Date,f=me(m),h=pe(m),i=Et(f,h),[_,x]=p.useState(i),{value:r,applyPeriod:j,applyRange:D,setSearchActive:C}=Sn({paramNames:Dt}),[g,v]=p.useState({due_date_from:ee(i.startDate),due_date_to:ee(i.endDate),amount_min:"",amount_max:"",category_id:"",subcategory_id:"",subsubcategory_id:"",status:"",search:"",date_basis:Ae.DUE}),{categories:R}=kn("expense",{enabled:a}),[t,N]=p.useState([{value:"",label:n("expenseFilters.allStatuses")}]),[k,d]=p.useState(!1),c=p.useRef(null),B=p.useRef(g);B.current=g;const z=async()=>{if(!k)try{const P=await X.getStatusOptions(),F=[{value:"",label:n("expenseFilters.allStatuses")},...P.map(M=>({value:M.value,label:M.label}))];N(F),d(!0)}catch{}},Y=P=>{const{name:F,value:M}=P.target;v(S=>F==="category_id"?{...S,category_id:M,subcategory_id:"",subsubcategory_id:""}:F==="subcategory_id"?{...S,subcategory_id:M,subsubcategory_id:""}:{...S,[F]:M})},T=(P,F)=>{v(M=>({...M,[P]:F}))},I=p.useCallback(({startDate:P,endDate:F,isComplete:M=!0})=>{if(x({startDate:P,endDate:F}),!M)return;const S=D(ee(P),ee(F));v(K=>({...K,...S}))},[D]),U=p.useCallback(P=>F=>{const M=j(F),S={...B.current,...M};v(S),x({startDate:ue(F.from)||me(new Date),endDate:ue(F.to)||pe(new Date)}),P(Ce(S,S.date_basis))},[j]),Z=P=>F=>{F.preventDefault(),P(Ce(g,g.date_basis))},H=P=>()=>{const F=me(new Date),M=pe(new Date);D(ee(F),ee(M));const S={due_date_from:ee(F),due_date_to:ee(M),amount_min:"",amount_max:"",category_id:"",subcategory_id:"",subsubcategory_id:"",status:"",search:"",date_basis:Ae.DUE};v(S),x({startDate:F,endDate:M}),P(S)},b=()=>{o(!a),!a&&!k&&z()},O=P=>F=>{const M=F.target.value,S=M.trim().length>0;v(J=>({...J,search:M}));const K=C(S);S||x({startDate:ue(K.from)||me(new Date),endDate:ue(K.to)||pe(new Date)}),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{const J={...B.current,search:M};J.due_date_from=S?"":K.from||"",J.due_date_to=S?"":K.to||"",P(Ce(J,J.date_basis))},400)},V=R.find(P=>String(P.id)===String(g.category_id))?.subcategories||[],te=V.find(P=>String(P.id)===String(g.subcategory_id))?.subcategories||[];return{expanded:a,filters:g,categories:R,subcategories:V,subsubcategories:te,statusOptions:t,dateBasisOptions:wn.map(P=>({value:P,label:n(`expenseFilters.dateBasis.${P}`)})),dateRange:_,period:r,handleChange:Y,handleCurrencyChange:T,handleDateRangeChange:I,handlePeriodChange:U,handleSubmit:Z,handleClear:H,toggleExpanded:b,handleSearch:O}}function Ie({onApplyFilters:n,headerActions:a=null}){const{t:o}=Q("finances"),{expanded:m,filters:f,categories:h,subcategories:i,subsubcategories:_,statusOptions:x,dateBasisOptions:r,dateRange:j,period:D,handleChange:C,handleCurrencyChange:g,handleDateRangeChange:v,handlePeriodChange:R,handleSubmit:t,handleClear:N,toggleExpanded:k,handleSearch:d}=Nt();return e.jsxs("div",{className:$.container,children:[e.jsxs("div",{className:$.header,children:[e.jsx(he,{placeholder:o("expenseFilters.searchPlaceholder"),className:$.searchInput,value:f.search,onChange:d(n),noMargin:!0}),e.jsx(Rn,{value:D,onChange:R(n)}),e.jsx(A,{variant:"secondary",onClick:k,className:$.filterButton,children:o(m?"expenseFilters.hideFilters":"expenseFilters.showFilters")}),a]}),m&&e.jsxs("form",{onSubmit:t(n),className:$.form,children:[e.jsxs("div",{className:$.grid,children:[e.jsx("div",{className:$.fieldGroup,children:e.jsx(oe,{label:o("expenseFilters.dateBasisLabel"),options:r,value:f.date_basis,onChange:c=>C({target:{name:"date_basis",value:c}})})}),e.jsx("div",{className:$.fieldGroup,children:e.jsx(Mn,{label:o("expenseFilters.period"),startDate:j.startDate,endD
1ate:j.endDate,onChange:v,size:"md",months:1,direction:"horizontal",showFooter:!1})}),e.jsx("div",{className:$.fieldGroup,children:e.jsx(ge,{label:o("expenseFilters.minAmount"),name:"amount_min",value:f.amount_min,onValueChange:c=>g("amount_min",c),placeholder:"0,00",disablePrefix:!0})}),e.jsx("div",{className:$.fieldGroup,children:e.jsx(ge,{label:o("expenseFilters.maxAmount"),name:"amount_max",value:f.amount_max,onValueChange:c=>g("amount_max",c),placeholder:"0,00",disablePrefix:!0})}),e.jsx("div",{className:$.fieldGroup,children:e.jsx(fe,{label:o("expenseFilters.category"),placeholder:o("expenseFilters.allCategories"),searchPlaceholder:o("common:searchPlaceholder","Digite para buscar"),emptyMessage:o("common:noResults","Nenhum resultado encontrado"),options:h.map(c=>({value:String(c.id),label:c.name})),value:f.category_id?String(f.category_id):"",onChange:c=>C({target:{name:"category_id",value:c||""}}),clearable:!0})}),e.jsx("div",{className:$.fieldGroup,children:e.jsx(fe,{label:o("expenseForm.fields.subcategory"),placeholder:o("expenseForm.placeholders.selectSubcategory"),searchPlaceholder:o("common:searchPlaceholder","Digite para buscar"),emptyMessage:o("common:noResults","Nenhum resultado encontrado"),options:i.map(c=>({value:String(c.id),label:c.name})),value:f.subcategory_id?String(f.subcategory_id):"",onChange:c=>C({target:{name:"subcategory_id",value:c||""}}),disabled:!f.category_id,clearable:!0})}),e.jsx("div",{className:$.fieldGroup,children:e.jsx(fe,{label:o("expenseForm.fields.subsubcategory"),placeholder:o("expenseForm.placeholders.selectSubsubcategory"),searchPlaceholder:o("common:searchPlaceholder","Digite para buscar"),emptyMessage:o("common:noResults","Nenhum resultado encontrado"),options:_.map(c=>({value:String(c.id),label:c.name})),value:f.subsubcategory_id?String(f.subsubcategory_id):"",onChange:c=>C({target:{name:"subsubcategory_id",value:c||""}}),disabled:!f.subcategory_id,clearable:!0})}),e.jsx("div",{className:$.fieldGroup,children:e.jsx(oe,{label:o("expenseFilters.status"),options:x,value:f.status,onChange:c=>C({target:{name:"status",value:c}})})})]}),e.jsxs("div",{className:$.actions,children:[e.jsx(A,{type:"button",variant:"secondary",onClick:N(n),children:o("expenseFilters.clearFilters")}),e.jsx(A,{type:"submit",children:o("expenseFilters.applyFilters")})]})]})]})}Ie.propTypes={onApplyFilters:L.func.isRequired,headerActions:L.node};function Le({isOpen:n,onClose:a,basePath:o="/personal/expenses"}){return e.jsx(On,{isOpen:n,onClose:a,entityType:"expenses",categoryType:"expense",providerType:"supplier",basePath:o})}Le.propTypes={isOpen:L.bool.isRequired,onClose:L.func.isRequired,basePath:L.string};const Mt=()=>new Date().toISOString().slice(0,10);function St(n,a=[]){const[o,m]=p.useState([]);p.useEffect(()=>{m(n.map(r=>({id:r.id,title:r.title,pendingAmount:Number(r.pending_amount??r.amount??0),paid_amount:Number(r.pending_amount??r.amount??0),payment_date:r.due_date?.slice(0,10)||Mt(),account_id:r.account_id||"",payment_method:r.payment_method||""})))},[n]);const f=(r,j,D)=>{m(C=>C.map(g=>g.id===r?{...g,[j]:D}:g))},h=p.useMemo(()=>Object.fromEntries(a.map(r=>[r.id,r])),[a]),i=o.filter(r=>!(r.paid_amount>0)||r.paid_amount>r.pendingAmount+.001),_=o.map(r=>({id:r.id,paid_amount:Number(r.paid_amount),payment_date:r.payment_date,...r.account_id?{account_id:Number(r.account_id)}:{},...r.payment_method?{payment_method:r.payment_method}:{}})),x=o.reduce((r,j)=>r+Number(j.paid_amount||0),0);return{rows:o,updateRow:f,items:_,total:x,failureByRow:h,hasInvalidRow:i.length>0}}const Rt="BulkPaymentModal-module__tableWrapper___wkxiU",kt="BulkPaymentModal-module__table___wfjjJ",wt="BulkPaymentModal-module__title___AkwtE",At="BulkPaymentModal-module__failedRow___1sW8c",Tt="BulkPaymentModal-module__failureReason___HCAOM",It="BulkPaymentModal-module__numeric___LEy11",Lt="BulkPaymentModal-module__total___w6VyI",ne={tableWrapper:Rt,table:kt,title:wt,failedRow:At,failureReason:Tt,numeric:It,total:Lt};function De({isOpen:n,expenses:a,accounts:o,failures:m,isLoading:f,onSubmit:h,onClose:i}){const{t:_}
1=Q(["pages","finances","common"]),{rows:x,updateRow:r,items:j,total:D,failureByRow:C,hasInvalidRow:g}=St(a,m),v=o.map(t=>({value:t.id,label:t.name})),R=Pn(_,"finances:confirmPaymentForm.paymentMethods");return e.jsxs(_e,{isOpen:n,onClose:i,title:_("pages:finances.expenses.bulk.payTitle"),size:"xxlarge",actions:e.jsxs(e.Fragment,{children:[e.jsx(A,{variant:"secondary",onClick:i,disabled:f,children:_("common:actions.cancel")}),e.jsx(A,{variant:"primary",onClick:()=>h(j),disabled:f||g||x.length===0,loading:f,children:_("pages:finances.expenses.bulk.confirmPay",{count:x.length})})]}),children:[e.jsx("div",{className:ne.tableWrapper,children:e.jsxs("table",{className:ne.table,children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:_("pages:finances.expenses.table.title")}),e.jsx("th",{children:_("pages:finances.expenses.table.pendingAmount")}),e.jsx("th",{children:_("pages:finances.expenses.bulk.amountToPay")}),e.jsx("th",{children:_("pages:finances.expenses.bulk.paymentDate")}),e.jsx("th",{children:_("pages:finances.expenses.bulk.account")}),e.jsx("th",{children:_("pages:finances.expenses.bulk.paymentMethod")})]})}),e.jsx("tbody",{children:x.map(t=>{const N=C[t.id],k=t.paid_amount>t.pendingAmount+.001;return e.jsxs("tr",{className:N?ne.failedRow:"",children:[e.jsxs("td",{children:[e.jsx("span",{className:ne.title,children:t.title}),N&&e.jsx("span",{className:ne.failureReason,children:N.message})]}),e.jsx("td",{className:ne.numeric,children:q.formatCurrency(t.pendingAmount)}),e.jsx("td",{children:e.jsx(ge,{value:t.paid_amount,onValueChange:d=>r(t.id,"paid_amount",d),error:k?_("pages:finances.expenses.bulk.amountExceeds"):void 0,noMargin:!0,"aria-label":`${_("pages:finances.expenses.bulk.amountToPay")} ${t.title}`})}),e.jsx("td",{children:e.jsx(he,{type:"date",value:t.payment_date,onChange:d=>r(t.id,"payment_date",d.target.value),noMargin:!0,"aria-label":`${_("pages:finances.expenses.bulk.paymentDate")} ${t.title}`})}),e.jsx("td",{children:e.jsx(oe,{options:v,value:t.account_id,onChange:d=>r(t.id,"account_id",d),placeholder:_("pages:finances.expenses.bulk.account")})}),e.jsx("td",{children:e.jsx(oe,{options:R,value:t.payment_method,onChange:d=>r(t.id,"payment_method",d),placeholder:_("pages:finances.expenses.bulk.paymentMethod")})})]},t.id)})})]})}),e.jsxs("p",{className:ne.total,children:[_("pages:finances.expenses.bulk.total"),": ",e.jsx("strong",{children:q.formatCurrency(D)})]})]})}
1De.propTypes={isOpen:L.bool.isRequired,expenses:L.array.isRequired,accounts:L.array,failures:L.array,isLoading:L.bool,onSubmit:L.func.isRequired,onClose:L.func.isRequired};De.defaultProps={accounts:[],failures:[],isLoading:!1};function Bt(){const{t:n}=Q(["pages","finances"]),{showSuccess:a,showError:o,showInfo:m}=Fe(),f=en(),h=p.useRef(crypto.randomUUID()),[i,_]=p.useState(!1),[x,r]=p.useState(!1),[j,D]=p.useState(!1),[C,g]=p.useState(null),[v,R]=p.useState(null),{filters:t,page:N,perPage:k,handleApplyFilters:d,handleChangePage:c,handleChangePerPage:B}=An(),[z,Y]=p.useState(!1),{accounts:T}=Vn({enabled:i||x}),I=Tn({reverse:l=>X.reopenExpense(l),onDone:()=>b(),successMessage:n("finances.expenses.notifications.reverseSuccess"),errorMessage:n("finances.expenses.notifications.reverseError"),onReversed:l=>je.emit(Pe.EXPENSE_DELETED,{expense:l})}),U=nn({queryKey:ke.expenses.list(t,N,k),queryFn:()=>X.getExpenses(t,N,k),placeholderData:tn}),Z=p.useMemo(()=>U.data?.expenses??[],[U.data]),H={page:N,perPage:k,total:U.data?.meta?.total??0,lastPage:U.data?.meta?.last_page??1};p.useEffect(()=>{U.isError&&o(n("finances.expenses.notifications.loadError"))},[U.isError]);const b=()=>f.invalidateQueries({queryKey:ke.expenses.all}),O=l=>q.formatCurrency(l),V=l=>({paid:n("finances.expenses.table.paid"),pending:n("finances.expenses.table.pending"),partial:n("finances.expenses.table.partial"),overdue:n("finances.expenses.table.overdue")})[l]||l,te=async l=>{if(l.status==="paid"){m(n("finances.expenses.notifications.paymentAlreadyMadeMessage"));return}if(parseFloat(l.pending_amount||0)<=0){m(n("finances.expenses.notifications.noAmountPendingMessage"));return}h.current=crypto.randomUUID(),g(l),_(!0)},P=()=>{_(!1),g(null)},F=l=>{g(l),r(!0)},M=()=>{r(!1),g(null)},S=l=>{R(l),D(!0)},K=()=>{D(!1),R(null)},J=async l=>{try{const W=await X.confirmPayment(C.id,{paid_amount:l.paid_amount,payment_date:l.payment_date,account_id:l.account_id,payment_method:l.payment_method,notes:l.notes},h.current);a(W.message||n("finances.expenses.notifications.paymentSuccess")),P(),b(),je.emit(Pe.EXPENSE_PAID,{expense:C,account_id:l.account_id,amount:l.paid_amount})}catch(W){if(W.response?.data?.errors){const ie=W.response.data.errors;Object.keys(ie).forEach(le=>{ie[le].forEach(be=>{o(`${le}: ${be}`)})})}else o(W.response?.data?.message||n("finances.expenses.notifications.error"))}},xe=async()=>{Y(!0);try{const l=await X.deleteExpense(v.id);K(),b(),a(l.message||n("finances.expenses.notifications.deleteSuccess")),v.status==="paid"&&je.emit(Pe.EXPENSE_DELETED,{expense:v})}catch(l){o(l.response?.data?.message||n("finances.expenses.notifications.error"))}finally{Y(!1)}},ye=l=>!l.credit_card_statement_id&&(l.status==="paid"||parseFloat(l.paid_amount||0)>0),re=()=>[{key:"description",title:n("finances.expenses.table.title"),width:"22%",render:l=>({title:l.title||"-",category:l.has_items?n("finances:itemsEditor.itemsCount",{count:l.items_count}):l.category?.name||"-"})},{key:"provider",title:n("finances.expenses.table.provider"),render:l=>({name:l.provider?.name||l.provider||"-",tradeName:l.provider?.trade_name||null})},{key:"amount",title:n("finances.expenses.table.amount"),align:"right",render:l=>({value:l.amount_formatted||O(l.amount||0),className:"negativeBalance"})},{key:"pending_amount",title:n("finances.expenses.table.pendingAmount"),align:"right",render:l=>{const W=parseFloat(l.pending_amount||0);return W>0?{value:l.pending_amount_formatted||O(W),className:"pendingAmount"}:{value:"-",className:""}}},{key:"due_date",title:n("finances.expenses.table.dueDate"),render:l=>l.due_date_formatted||"-"},{key:"status",title:n("finances.expenses.table.status"),render:l=>({status:l.status,text:l.status_label||l.status})},{key:"payment_date",title:n("finances.expenses.table.paymentDate"),align:"center",render:l=>l.payment_date_formatted||"-"}];return{showPaymentModal:i,showViewPaymentModal:x,showDeleteModal:j,currentExpense:C,expenseToDelete:v,expenseToReverse:I.target,expenses:Z,filters:t,pagination:H,isLoading:U.isLoading,isDeleteLoading:z,isReverseLoading:I.isLoading,accounts:T,handleOpenPaymentModal:te,handleClosePaymentModal:P,handleOpenViewPaymentModal:F,handleCloseViewPaymentModal:M,handleOpenDeleteModal:S,handleCloseDeleteModal:K,handleConfirmPayment:J,handleDeleteConfirm:xe,handleOpenReverseModal:I.open,handleCloseReverseModal:I.close,handleReverseConfirm:I.confirm,canReverse:ye,handleApplyFilters:d,handleChangePage:c,handleChangePerPage:B,formatCurrency:O,getStatusText:V,getTableColumns:re,fetchExpenses:b}}function Ot({expenses:n,resetKey:a,onDone:o}){const{t:m}=Q("pages"),{showSuccess:f,showError:h,showInfo:i}=Fe(),_=In(a),[x,r]=p.useState(!1),[j,D]=p.useState(!1),[C,g]=p.useState(!1),[v,R]=p.useState([]),[t,N]=p.useState(!1),k=p.useRef(crypto.randomUUID()),d=n.filter(b=>_.selectedIds.includes(b.id)),c=b=>
1b.status!=="canceled"&&Number(b.pending_amount??0)>0,B=()=>{R([]),r(!0)},z=()=>{r(!1),R([])},Y=(b,{onFullSuccess:O})=>{if(k.current=crypto.randomUUID(),o?.(),b.failed.length===0){f(b.message),_.clear(),O?.();return}i(b.message),R(b.failed),_.setSelectedIds(b.failed.map(V=>V.id))},T=async(b,{onFullSuccess:O}={})=>{N(!0);try{const V=await b(k.current);Y(V,{onFullSuccess:O})}catch(V){h(V.response?.data?.message||m("finances.expenses.notifications.error"))}finally{N(!1)}},I=b=>T(O=>X.bulkPay(b,O),{onFullSuccess:z}),U=()=>T(b=>X.bulkDelete(_.selectedIds,b),{onFullSuccess:()=>D(!1)}),Z=()=>T(b=>X.bulkCancel(_.selectedIds,b),{onFullSuccess:()=>g(!1)}),H=d.reduce((b,O)=>b+Number(O.pending_amount??0),0);return{..._,selectedExpenses:d,isRowSelectable:c,total:H,failures:v,isSubmitting:t,showPayModal:x,openPayModal:B,closePayModal:z,showDeleteModal:j,setShowDeleteModal:D,showCancelModal:C,setShowCancelModal:g,payBulk:I,deleteBulk:U,cancelBulk:Z}}function Vt(){const{t:n}=Q("finances"),[a,o]=p.useState(!1),[m,f]=p.useState(null),[h,i]=p.useState(!1),[_,x]=p.useState(null),[r,j]=p.useState(null),[D,C]=p.useState(!1),g=p.useCallback(async c=>{if(c)try{C(!0),x(null);const B=await X.checkRecurrence(c.id);if(B.is_recurrent||B.is_generated_by_recurrence)f(c),j(B),o(!0);else return!1;return!0}catch{return x(n("recurrentExpenseDeleteModal.errors.checkRecurrence")),!1}finally{C(!1)}},[n]),v=p.useCallback(()=>{o(!1),f(null),j(null),x(null),i(!1)},[]),R=p.useCallback(async(c,B)=>{if(!m)return;const{deleteOption:z,fromDate:Y}=c;if(!z){x(n("recurrentExpenseDeleteModal.errors.selectOption"));return}if(z==="from_date"&&!Y){x(n("recurrentExpenseDeleteModal.errors.selectDateForOption"));return}try{i(!0),x(null);const T=await X.deleteRecurringExpense(m.id,{deleteOption:z,fromDate:Y});return B&&typeof B=="function"&&await B(T),v(),T}catch(T){let I=n("recurrentExpenseDeleteModal.errors.deleteRecurring");throw T.response?.data?.message?I=T.response.data.message:T.message&&(I=T.message),x(I),T}finally{i(!1)}},[m,v,n]),t=p.useCallback(c=>c&&(c.is_recurrent===!0||c.is_generated_by_recurrence===!0||c.occurrence&&c.occurrence!=="single"),[]),N=p.useCallback(()=>{x(null)},[]),k=p.useCallback(()=>!m||!r?"":r.is_recurrent?n("recurrentExpenseDeleteModal.descriptions.recurrentExpense",{label:m.occurrence_label||"N/A"}):r.is_generated_by_recurrence?n("recurrentExpenseDeleteModal.descriptions.generatedByRecurrence",{label:m.occurrence_label||"N/A"}):n("recurrentExpenseDeleteModal.descriptions.singleExpense"),[m,r,n]),d=p.useCallback(()=>r?{total:r.related_expenses_count||0,pending:r.pending_expenses_count||0,paid:r.paid_expenses_count||0}:{total:0,pending:0,paid:0},[r]);return{isOpen:a,selectedExpense:m,isLoading:h,error:_,isCheckingRecurrence:D,recurrenceInfo:r,openModal:g,closeModal:v,confirmDelete:R,canUseRecurrentDeleteModal:t,clearError:N,getRecurrenceDescription:k,getRelatedExpensesStats:d}}const $t="Expenses-module__header___Q3uOa",Gt="Expenses-module__headerActions___tA-1I",qt="Expenses-module__subtitle___M2Eiv",Ut="Expenses-module__status___FSfB1",zt="Expenses-module__paid___lsnxY",Kt="Expenses-module__pending___SUQN7",Wt="Expenses-module__partial___KGag2",Xt="Expenses-module__overdue___vlATY",Yt="Expenses-module__canceled___myL5g",Ht="Expenses-module__statementPending___S6m3q",Qt="Expenses-module__statementPaid___75JsN",Jt="Expenses-module__statementLink___FxIdZ",Zt="Expenses-module__rowTitle___cwKaW",ea="Expenses-module__categoryText___vtpAF",na="Expenses-module__actions___XcyW7",ta="Expenses-module__ioGroup___QCuDU",aa="Expenses-module__pagination___IKhBA",sa="Expenses-module__paginationInfo___MNhqX",oa="Expenses-module__paginationControls___aavLL",ra="Expenses-module__perPage___Ad2gM",G={header:$t,headerActions:Gt,subtitle:qt,status:Ut,paid:zt,pending:Kt,partial:Wt,overdue:Xt,canceled:Yt,statementPending:Ht,statementPaid:Qt,statementLink:Jt,rowTitle:Zt,categoryText:ea,actions:na,ioGroup:ta,pagination:aa,paginationInfo:sa,paginationControls:oa,perPage:ra};function ia(n,a){if(!n?.credit_card_statement_id)return null;const o=n.credit_card_statement;return o?.is_paid?{text:a("finances.expenses.table.paidViaStatement"),variant:"statementPaid"}:{text:o?.due_date_formatted?a("finances.expenses.table.inStatement",{date:o.due_date_formatted}):a("finances.expenses.table.inStatementNoDate"),variant:"statementPending"}}function la(n,a){const o=n?.credit_card_statement?.account_id||n?.account?.id;return o?`${a?.startsWith("/business")?"/business":"/personal"}/accounts/${o}/statements`:null}
1function ns({basePath:n="/personal/expenses"}){const{t:a}=Q("pages"),{t:o}=Q("common"),{t:m}=Q("imports"),f=fn(),h=an("crud-financial"),{showSuccess:i,showError:_}=Fe(),[x,r]=p.useState(!1),[j,D]=p.useState(!1),[C,g]=p.useState(null),{isOpen:v,selectedExpense:R,isLoading:t,error:N,openModal:k,closeModal:d,confirmDelete:c,canUseRecurrentDeleteModal:B}=Vt(),{showPaymentModal:z,showViewPaymentModal:Y,showDeleteModal:T,currentExpense:I,expenseToDelete:U,expenses:Z,pagination:H,isLoading:b,isDeleteLoading:O,accounts:V,filters:te,handleOpenPaymentModal:P,handleClosePaymentModal:F,handleOpenViewPaymentModal:M,handleCloseViewPaymentModal:S,handleOpenDeleteModal:K,handleCloseDeleteModal:J,handleConfirmPayment:xe,handleDeleteConfirm:ye,expenseToReverse:re,isReverseLoading:l,handleOpenReverseModal:W,handleCloseReverseModal:ie,handleReverseConfirm:le,canReverse:be,handleApplyFilters:Be,handleChangePage:Oe,getTableColumns:Ve,fetchExpenses:se}=Bt(),E=Ot({expenses:Z,resetKey:`${H.page}|${JSON.stringify(te)}`,onDone:se}),Ee=async(u,y=[])=>{if(!x){r(!0);try{await X.exportExpenses(te,u,y),i(o("exportDropdown.success"))}catch(w){w?.response?.status===403?_(o("exportDropdown.requiresPro")):_(o("exportDropdown.error"))}finally{r(!1)}}},$e=u=>Ee(u),Ge=u=>Ee(u,E.selectedIds),qe=async u=>{B(u)&&await k(u)||K(u)},Ue=async()=>{typeof se=="function"&&await se()},ze=Ve().map(u=>u.key==="description"?{...u,render:y=>{const w=u.render(y);return e.jsxs("div",{children:[e.jsxs("div",{className:G.rowTitle,children:[w.title,e.jsx(Ln,{installment:y.installment,isRecurring:y.is_recurrent||y.is_generated_by_recurrence})]}),e.jsx("div",{className:G.categoryText,children:w.category})]})}}:u.key==="provider"?{...u,render:y=>{const w=u.render(y);return e.jsxs("div",{children:[e.jsx("div",{className:G.rowTitle,children:w.name}),w.tradeName&&e.jsx("div",{className:G.categoryText,children:w.tradeName})]})}}:u.key==="status"?{...u,render:y=>{const w=u.render(y),ae=ia(y,a);if(ae){const Me=e.jsx("span",{className:`${G.status} ${G[ae.variant]}`,children:ae.text}),Se=la(y,n);return Se?e.jsx(_n,{to:Se,className:G.statementLink,onClick:Ye=>Ye.stopPropagation(),title:a("finances.expenses.table.openStatement"),children:Me}):Me}const Ne=y.status==="pending"&&y.is_overdue,We=Ne?"overdue":w.status,Xe=Ne?a("finances.expenses.table.overdue"):w.text;return e.jsx("span",{className:`${G.status} ${G[We]}`,children:Xe})}}:u.key==="amount"?{...u,render:y=>{const w=u.render(y);return e.jsx("span",{className:w.className,children:w.value})}}:u.key==="pending_amount"?{...u,render:y=>{const w=u.render(y);return e.jsx("span",{className:w.className,children:w.value})}}:u),Ke=u=>e.jsxs("div",{className:G.actions,children:[e.jsx(A,{variant:"secondary",size:"small",onClick:async y=>{y.stopPropagation(),g(u);try{const w=await X.getExpense(u.id);w&&g(ae=>ae?.id===u.id?w:ae)}catch{}},title:a("finances.expenses.actions.view"),children:e.jsx(rn,{})}),h&&!u.credit_card_statement_id&&u.status!=="paid"&&parseFloat(u.pending_amount||0)>0&&e.jsx(A,{variant:"secondary",size:"small",onClick:y=>{y.stopPropagation(),P(u)},title:a("finances.expenses.actions.payNow"),children:e.jsx(ln,{})}),(u.status==="paid"||u.status==="partial")&&e.jsx(A,{variant:"secondary",size:"small",onClick:y=>{y.stopPropagation(),M(u)},title:a("finances.expenses.actions.viewPayment"),children:e.jsx(cn,{})}),h&&be(u)&&e.jsx(A,{variant:"secondary",size:"small",onClick:y=>{y.stopPropagation(),W(u)},title:a("finances.expenses.actions.reversePayment"),children:e.jsx(dn,{})}),h&&e.jsx(A,{variant:"secondary",size:"small",onClick:y=>{y.stopPropagation(),f(`${n}/${u.id}/edit`)},title:a("finances.expenses.actions.edit"),children:e.jsx(mn,{})}),h&&e.jsx(A,{variant:"secondary",size:"small",onClick:y=>{y.stopPropagation(),f(`${n}/new?duplicate=${u.id}`)},title:a("finances.expenses.actions.duplicate"),children:e.jsx(un,{})}),h&&e.jsx(A,{variant:"danger",size:"small",onClick:y=>{y.stopPropagation(),qe(u)},title:a("finances.expenses.actions.delete"),children:e.jsx(pn,{})})]});return e.jsxs("div",{children:[e.jsx(sn,{}),e.jsxs("header",{className:G.header,children:[e.jsxs("div",{children:[e.jsx("h1",{children:a("finances.expenses.title")}),e.jsx("p",{className:G.subtitle,children:a("finances.expenses.subtitle")})]}),e.jsx(hn,{action:"crud-financial",children:e.jsxs("div",{className:G.headerActions,children:[e.jsx(A,{variant:"secondary",onClick:()=>f(`${n}/batch`),children:a("finances.expenses.batchButton")}),e.jsx(A,{onClick:()=>f(`${n}/new`),children:a("finances.expenses.newExpense")})]})})]}),e.jsx(Ie,{onApplyFilters:Be,headerActions:e.jsxs("div",{className:G.ioGroup,children:[h&&e.jsxs(A,{variant:"secondary",onClick:()=>D(!0),type:"button",children:[e.jsx(on,{})," ",m("expenses.button")]}),e.jsx(we,{onExport:$e,loading:x})]})}),e.jsx(gn,{columns:ze,data:Z,actions:Ke,isLoading:b,emptyMessage:a("finances.expenses.table.emptyMessage"),pagination:{currentPage:H.page,totalPages:H.lastPage,totalItems:H.total,itemsPerPage:H.perPage},onPageChange:Oe,selectable:h,selectedIds:E.selectedIds,onSelectionChange:E.setSelectedIds,isRowSelectable:E.isRowSelectable}),h&&e.jsxs(xn,{selectedCount:E.selectedCount,summary:q.formatCurrency(E.total),onClear:E.clear,children:[e.jsx(A,{size:"sm",onClick:E.openPayModal,children:a("finances.expenses.bulk.pay")}),e.jsx(A,{size:"sm",variant:"secondary",onClick:()=>E.setShowCancelModal(!0),children:a("finances.expenses.bulk.cancel")}),e.jsx(A,{size:"sm",variant:"danger",onClick:()=>E.setShowDeleteModal(!0),children:a("finances.expenses.bulk.delete")}),e.jsx(we,{onExport:Ge,loading:x,align:"right"})]}),e.jsx(De,{isOpen:E.showPayModal,expenses:E.selectedExpenses,accounts:V,failures:E.failures,isLoading:E.isSubmitting,onSubmit:E.payBulk,onClose:E.closePayModal}),e.jsx(ce,{isOpen:E.showDeleteModal,onClose:()=>E.setShowDeleteModal(!1),onConfirm:E.deleteBulk,title:a("finances.expenses.bulk.deleteTitle"),message:a("finances.expenses.bulk.deleteMessage",{count:E.selectedCount}),confirmText:a("finances.expenses.bulk.delete"),confirmVariant:"danger",isLoading:E.isSubmitting}),e.jsx(ce,{isOpen:E.showCancelModal,onClose:()=>E.setShowCancelModal(!1),onConfirm:E.cancelBulk,title:a("finances.expenses.bulk.cancelTitle"),message:a("finances.expenses.bulk.cancelMessage",{count:E.selectedCount}),confirmText:a("finances.expenses.bulk.cancel"),isLoading:E.isSubmitting}),e.jsx(_e,{isOpen:z,onClose:F,title:a("finances.expenses.paymentModal.title"),size:"xlarge",children:I&&e.jsx(ve,{expense:I,accounts:V,onSubmit:xe,onCancel:F,isLoading:b})}),e.jsx(_e,{isOpen:Y,onClose:S,title:a("finances.expenses.viewPaymentModal.title"),size:"xlarge",children:I&&e.jsx(ve,{expense:I,accounts:V,onSubmit:()=>{},onCancel:S,isLoading:!1,readOnly:!0})}),e.jsx(_e,{isOpen:!!C,onClose:()=>g(null),title:a("finances.expenses.viewModal.title"),size:"xlarge",children:C&&e.jsx(Nn,{expense:C,accounts:V,readOnly:!0,onSubmit:()=>{},onCancel:()=>g(null)})}),e.jsx(ce,{isOpen:T,onClose:J,onConfirm:ye,title:a("finances.expenses.deleteModal.title"),message:a("finances.expenses.deleteModal.message",{title:U?.title||""}),confirmText:a("finances.expenses.deleteModal.confirmText"),confirmVariant:"danger",isLoading:O}),e.jsx(ce,{isOpen:!!re,onClose:ie,onConfirm:le,title:a("finances.expenses.reverseModal.title"),message:a("finances.expenses.reverseModal.message",{title:re?.title||""}),confirmText:a("finances.expenses.reverseModal.confirmText"),confirmVariant:"warning",isLoading:l}),e.jsx(Bn,{isOpen:v,onClose:d,onConfirm:u=>c(u,Ue),expense:R,isLoading:t,error:N}),e.jsx(Le,{isOpen:j,onClose:()=>{D(!1),typeof se=="function"&&se()},basePath:n})]})}export{ns as default}; 2//# sourceMappingURL=index.CYvKuvy0.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.