import{a as fe,r as z,e as R,u as Q,x as se,A as ye,f as Z,d as Y,g as be,fm as oe,c as a,D as Ce,h as E,m as L,ab as _e,s as $e,a_ as ce,a$ as ge,bj as O,z as H,j as y,ce as q,p as h,H as B,f6 as me,cu as he,bf as ve,ac as W,fn as Se,aJ as xe,cc as ke,c_ as de,f5 as pe,fo as Te,fp as Ie,fq as Ne,bp as we,bG as De,bH as Pe,br as Me,J as ae,fr as Ke,fs as Ee,ba as P,bb as U,ft as Be,fu as Fe,eM as Ae,fv as Oe,bs as w,bz as Qe,fw as je,af as Ve,ad as ne,ew as ze,fx as Re,bv as Le,O as He,Z as Ge,T as qe,k as Ue,a2 as We,a3 as Je,a4 as te}from"./bundle.3e24044b.js";import{E as Ze,A as X,T as J,u as Xe,a as ue,b as Ye}from"./bundle.13ba6025.js";import{u as et,a as tt}from"./bundle.b5612618.js";import{I as at}from"./bundle.97e03994.js";import{c as nt,b as st}from"./bundle.b776fbbe.js";import{I as K}from"./bundle.756326ba.js";import{P as A}from"./bundle.51e1486d.js";import{S as ot}from"./bundle.f295bcc9.js";/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function le(e){return fe(["/api/v1/invoices",e],()=>z("GET",R("/api/v1/invoices?client_status=:client_status&filter=:filter&client_id=:client_id&filter_deleted_clients=:without_deleted_clients&per_page=:per_page&page=:page&include=:include",{per_page:e.perPage??"100",page:e.currentPage??"1",client_status:e.clientStatus??"all",client_id:e.clientId??"",filter:e.filter??"",without_deleted_clients:e.withoutDeletedClients||!0,include:e.include||""})).then(n=>n.data.data),{enabled:e.enabled??!0,staleTime:1/0})}function lt(){const{t:e}=Q(),n=se(),o=ye(),{dateFormat:s}=Z(),i=Y(),t=be(),r=et(),{data:v}=le({perPage:1e3}),{data:k}=oe({perPage:1e3}),b=m=>{var l;return((l=v==null?void 0:v.find(C=>C.id===m))==null?void 0:l.number)||""},S=m=>{var l;return((l=k==null?void 0:k.find(C=>C.id===m))==null?void 0:l.number)||""};return[{id:"status",label:e("status"),format:(m,l)=>a(Ce,{to:E("/transactions/:id/edit",{id:l.id}),renderSpan:t("bank_transaction",l),children:a(Ze,{transaction:l})})},{id:"deposit",label:e("deposit"),format:(m,l)=>{var C;if(l.base_type===X.Credit)return i(l.amount,(C=n==null?void 0:n.settings)==null?void 0:C.country_id,l.currency_id)}},{id:"withdrawal",label:e("withdrawal"),format:(m,l)=>{var C;if(l.base_type===X.Debit)return i(l.amount,(C=n==null?void 0:n.settings)==null?void 0:C.country_id,l.currency_id)}},{id:"date",label:e("date"),format:m=>L(m,s)},{id:"description",label:e("description"),format:m=>a(_e,{width:"auto",tooltipElement:a("div",{className:"w-full max-h-48 overflow-auto whitespace-normal break-all",children:a("article",{className:$e("prose prose-sm",{"prose-invert":o.dark_mode}),dangerouslySetInnerHTML:{__html:ce(r(m))}})}),children:a("span",{children:ge(ce(r(m))).slice(0,50)})})},{id:"invoice_ids",label:e("invoices"),format:m=>m&&a("div",{className:"flex space-x-2",children:m.toString().split(",").map(l=>a(O,{to:E("/invoices/:id/edit",{id:l}),children:b(l)},l))})},{id:"expense_id",label:e("expense"),format:m=>m&&a("div",{className:"flex space-x-2",children:m.toString().split(",").map(l=>a(O,{to:E("/expenses/:id/edit",{id:l}),children:S(l)},l))})}]}function rt(e){const[n]=Q(),o=H(),s=(i,t)=>{e.setSearchParams(r=>({...r,[i]:t}))};return a("div",{className:"absolute w-full top-full left-0 mt-1 text-center z-10",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:y("div",{className:"flex flex-col items-center pt-3 pb-6 space-y-3",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderBottom:`1px solid ${o.$5}`},children:[y("div",{className:"flex justify-evenly w-full",style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},children:[a(q,{changeOverride:!0,style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},width:"12rem",label:`${n("min")} ${n("amount")}`,value:e.searchParams.minAmount,onValueChange:i=>s("minAmount",isNaN(Number(i))?0:Number(i))}),a(q,{changeOverride:!0,style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},width:"12rem",label:`${n("max")} ${n("amount")}`,value:e.searchParams.maxAmount,onValueChange:i=>s("maxAmount",isNaN(Number(i))?0:Number(i))})]}),y("div",{className:"flex justify-evenly w-full",children:[a(q,{style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},className:"w-full",width:"12rem",label:n("start"),type:"date",value:e.searchParams.startDate,onValueChange:i=>s("startDate",i||"")}),a(q,{changeOverride:!0,style:{color:o.$3,colorScheme:o.$0,backgroundColor:o.$1,borderColor:o.$4},className:"w-full",width:"12rem",label:n("end"),type:"date",value:e.searchParams.endDate,onValueChange:i=>s("endDate",i||"")})]})]})})}function it(e){const n=e.dataKey==="invoices",o=e.dataKey==="payments",s=e.dataKey==="expenses",[i,t]=h.useState(!1),[r,v]=h.useState(!1),k=(S,f)=>{e.setSearchParams(m=>({...m,[S]:f}))},b=H();return y(B,{children:[a(me,{initiallyVisible:i,setVisible:t,setSelectedIds:e.setSelectedIds,onChange:()=>{}}),a(he,{initiallyVisibleModal:r,setVisible:v,setSelectedIds:e.setSelectedIds,onChange:()=>{}}),y("div",{className:"flex items-center pr-3",children:[a(q,{changeOverride:!0,style:{color:b.$3,colorScheme:b.$0,backgroundColor:b.$1,borderColor:b.$4},placeholder:ve(`search_${e.dataKey}`,{count:""}),value:e.searchParams.searchTerm,onValueChange:S=>k("searchTerm",S)}),n||o||s?a(B,{children:a(W,{element:Se,className:"ml-3 cursor-pointer",size:28,onClick:()=>e.setIsFilterModalOpened(S=>!S)})}):a(B,{children:a(W,{element:xe,className:"ml-3 cursor-pointer",size:28,onClick:()=>e.dataKey==="vendors"?v(!0):t(!0)})}),e.isFilterModalOpened&&a(rt,{searchParams:e.searchParams,setSearchParams:e.setSearchParams})]})]})}/** * Invoice Ninja (https://invoiceninja.com). * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */const ct={[K.Cancelled]:"cancelled",[K.Unpaid]:"unpaid",[K.PastDue]:"past_due",[K.Draft]:"draft",[K.Sent]:"sent",[K.Partial]:"partial",[K.Paid]:"paid",[K.Cancelled]:"cancelled",[K.Reversed]:"reversed"};/** * Invoice Ninja (https://invoiceninja.com). * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */const dt={[A.PartiallyUnapplied]:"partially_unapplied",[A.Unapplied]:"unapplied",[A.Pending]:"pending",[A.Cancelled]:"cancelled",[A.Failed]:"failed",[A.Completed]:"completed",[A.PartiallyRefunded]:"partially_refunded",[A.Refunded]:"refunded"};function ut(e){const n=Y(),{dateFormat:o}=Z(),s=H();return y("li",{style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},className:"flex justify-between w-full cursor-pointer p-4 border-b last:border-b-0",onClick:()=>e.selectItem(e.resourceItem.id,e.resourceItem.clientId),children:[y("div",{className:"flex items-center",children:[a(ke,{style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},checked:e.isItemChecked,onClick:()=>e.selectItem(e.resourceItem.id)}),y("div",{className:"flex flex-col items-start",style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},children:[a("span",{className:"text-sm",children:e.resourceItem.name}),a("span",{className:"text-sm",children:e.resourceItem.number})]})]}),y("div",{className:"flex items-center flex-grow pr-3",style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},children:[y("div",{className:"flex flex-col flex-grow pl-8 pr-3",style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},children:[a("span",{className:"text-sm",style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},children:e.resourceItem.clientName}),a("span",{className:"text-sm",style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},children:L(e.resourceItem.date||"",o)})]}),typeof e.resourceItem.amount=="number"&&a("span",{className:"text-sm",style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},children:n(e.resourceItem.amount||0,e.resourceItem.country_id,e.resourceItem.currency_id)})]}),a("div",{className:"flex items-center",style:{color:s.$3,colorScheme:s.$0,backgroundColor:s.$1,borderColor:s.$4},children:e.resourceItem.statusId?y(B,{children:[e.dataKey==="invoices"&&a(de,{for:ct,code:e.resourceItem.statusId}),e.dataKey==="payments"&&a(de,{for:dt,code:e.resourceItem.statusId})]}):a(B,{children:e.dataKey==="expenses"&&a(pe,{entity:e.resourceItem})})})]},e.resourceItem.id)}function G(e){const[n,o]=h.useState({searchTerm:"",minAmount:0,maxAmount:0,startDate:"",endDate:""}),s=e.dataKey==="invoices",i=e.dataKey==="vendors",t=e.dataKey==="categories",r=e.dataKey==="payments",v=e.dataKey==="expenses",[k,b]=h.useState(),{data:S}=Te({enabled:s}),{data:f}=le({include:"client",clientStatus:"unpaid",filter:n.searchTerm,clientId:k,enabled:s}),{data:m}=Ie({filter:n.searchTerm,enabled:i}),{data:l}=Ne({filter:n.searchTerm,enabled:t}),{data:C}=nt({include:"client",filter:n.searchTerm,enabled:r,matchTransactions:!0}),{data:T}=oe({include:"client",filter:n.searchTerm,enabled:v,matchTransactions:!0}),[D,g]=h.useState(),[x,I]=h.useState(),[j,V]=h.useState(!1),N=_=>{var u,p;return!!((p=(u=e.selectedIds)==null?void 0:u.find(M=>M===_))!=null&&p.length)},F=(_,u)=>{var re,ie;b(u);const p=(re=e.selectedIds)==null?void 0:re.find(ee=>_===ee);let M;p!=null&&p.length?(M=(ie=e.selectedIds)==null?void 0:ie.filter(ee=>ee!==_),e.setSelectedIds(M)):(M=[...e.selectedIds||[],_],e.setSelectedIds(M))},d=_=>{var u;return(u=x==null?void 0:x.find(({id:p})=>p===_))==null?void 0:u.display_name},c=_=>_==null?void 0:_.map(u=>{var p,M;return{id:u.id,number:u.number,name:u.name,clientName:d(u.client_id),statusId:u.status_id,amount:u.amount,date:u.date,clientId:u.client_id,should_be_invoiced:u.should_be_invoiced,invoice_id:u.invoice_id,payment_date:u.payment_date,transaction_reference:u.transaction_reference,payment_type_id:u.payment_type_id,country_id:u.country_id||((p=u.client)==null?void 0:p.country_id),currency_id:u.currency_id||((M=u.client)==null?void 0:M.settings.currency_id)}});h.useEffect(()=>{I(S),g(c(s?f:i?m:t?l:r?C:T))},[e.dataKey,f,m,l,S,C,T]),h.useEffect(()=>{var _;s&&!((_=e.selectedIds)!=null&&_.length)&&b("")},[e.selectedIds]);const $=H();return y("div",{className:"flex flex-col flex-1 w-full",style:{color:$.$3,colorScheme:$.$0,backgroundColor:$.$1,borderColor:$.$4},children:[a("div",{style:{color:$.$3,colorScheme:$.$0,backgroundColor:$.$1,borderColor:$.$4},className:`flex justify-center px-5 py-3 relative border-b border-t ${e.className}`,children:a(it,{dataKey:e.dataKey,searchParams:n,setIsFilterModalOpened:V,isFilterModalOpened:j,setSearchParams:o,setSelectedIds:e.setSelectedIds})}),a("ul",{style:{height:s?400:200,color:$.$3,colorScheme:$.$0,backgroundColor:$.$1,borderColor:$.$4},className:"flex flex-col grow justify-start overflow-y-auto",children:D==null?void 0:D.map(_=>{var u;return(N(_.id)||!((u=e.selectedIds)!=null&&u.length)||s||v)&&a(ut,{isItemChecked:N(_.id),resourceItem:_,selectItem:F,dataKey:e.dataKey},_.id)})})]})}function mt(e){const[n]=Q(),o=we(),{transactionRule:s}=e,i=De(Pe),[t,r]=h.useState(!1),[v,k]=h.useState(!0),[b,S]=h.useState([]),[f,m]=h.useState([]),[l,C]=h.useState([]),[T,D]=h.useState([]),[g,x]=h.useState([]),I=[e.isCreditTransactionType?n("create_payment"):n("create_expense"),e.isCreditTransactionType?n("link_payment"):n("link_expense")],j=c=>{c.preventDefault(),!(!b.length||t)&&(r(!0),P.processing(),z("POST",R("/api/v1/bank_transactions/match"),{transactions:[{id:e.transactionDetails.transaction_id,invoice_ids:b.join(",")}]}).then(()=>{o.invalidateQueries([i]),U(["invoices","bank_transactions"]),P.success("converted_transaction")}).finally(()=>r(!1)))},V=c=>{c.preventDefault(),!(!T.length||t)&&(r(!0),P.processing(),z("POST",R("/api/v1/bank_transactions/match"),{transactions:[{id:e.transactionDetails.transaction_id,payment_id:T.join(",")}]}).then(()=>{o.invalidateQueries([i]),U(["invoices","payments","bank_transactions"]),P.success("linked_transaction")}).finally(()=>r(!1)))},N=c=>{c.preventDefault(),!(!f.length&&!l.length||t)&&(r(!0),P.processing(),z("POST",R("/api/v1/bank_transactions/match"),{transactions:[{id:e.transactionDetails.transaction_id,vendor_id:f.join(","),ninja_category_id:l.join(",")}]}).then(()=>{o.invalidateQueries([i]),U(["bank_transactions","expenses"]),P.success("converted_transaction")}).finally(()=>r(!1)))},F=c=>{c.preventDefault(),!(!g.length||t)&&(r(!0),P.processing(),z("POST",R("/api/v1/bank_transactions/match"),{transactions:[{id:e.transactionDetails.transaction_id,expense_id:g.join(",")}]}).then(()=>{o.invalidateQueries([i]),U(["expenses","bank_transactions"]),P.success("linked_transaction")}).finally(()=>r(!1)))};h.useEffect(()=>{k(e.transactionDetails.status_id===J.Converted)},[e.transactionDetails.status_id,e.isCreditTransactionType,f,b,l,T,g]),h.useEffect(()=>()=>{k(!0)},[]),h.useEffect(()=>{if(s){const{category_id:c,vendor_id:$}=s;c&&C([c]),$&&m([$])}},[s]);const d=H();return a("div",{className:"flex flex-col flex-1",children:a("div",{className:"flex flex-col flex-1",children:!v&&y(Me,{className:"flex flex-col flex-1 border-t border-gray-200",tabs:I,height:"full",width:"full",children:[y("div",{children:[e.isCreditTransactionType?a(G,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"invoices",setSelectedIds:S,selectedIds:b}):y(B,{children:[a(G,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"vendors",setSelectedIds:m,selectedIds:f}),a(G,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"categories",setSelectedIds:C,selectedIds:l})]}),a("div",{className:"px-3 py-3 w-full border-t border-gray-200",children:y(ae,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},className:"w-full",onClick:e.isCreditTransactionType?j:N,disableWithoutIcon:!0,disabled:t||e.isCreditTransactionType&&!b.length&&!T.length||!e.isCreditTransactionType&&!f.length&&!l.length&&!g.length,children:[a(Ke,{fontSize:22}),a("span",{children:e.isCreditTransactionType?n("create_payment"):n("create_expense")})]})})]}),y("div",{children:[e.isCreditTransactionType?a(G,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"payments",setSelectedIds:D,selectedIds:T}):a(G,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},transactionDetails:e.transactionDetails,dataKey:"expenses",setSelectedIds:x,selectedIds:g}),a("div",{className:"px-3 py-3 w-full border-t border-gray-200",children:y(ae,{style:{color:d.$3,colorScheme:d.$0,backgroundColor:d.$1,borderColor:d.$4},className:"w-full",onClick:e.isCreditTransactionType?V:F,disableWithoutIcon:!0,disabled:t||e.isCreditTransactionType&&!b.length&&!T.length||!e.isCreditTransactionType&&!f.length&&!l.length&&!g.length,children:[a(Ee,{fontSize:22}),a("span",{children:e.isCreditTransactionType?n("link_payment"):n("link_expense")})]})})]})]})})})}function ht(e){const[n]=Q(),o=se(),s=Y(),{dateFormat:i}=Z(),{data:t}=Xe({id:e.transactionId,enabled:!!e.transactionId}),{data:r}=Be({id:(t==null?void 0:t.bank_integration_id)||"",enabled:!!t}),v=J.Matched===(t==null?void 0:t.status_id),{data:k}=Fe({id:(t==null?void 0:t.bank_transaction_rule_id)||"",enabled:!!t&&v}),[b,S]=h.useState(),[f,m]=h.useState(),[l,C]=h.useState(),[T,D]=h.useState(),g=(t==null?void 0:t.base_type)===X.Credit,x=J.Converted!==(t==null?void 0:t.status_id),I=t&&!x&&!!e.transactionId,{data:j}=le({enabled:g&&I}),{data:V}=st({id:(t==null?void 0:t.payment_id)||"",enabled:g&&I}),{data:N}=Ae({id:(t==null?void 0:t.vendor_id)||"",enabled:!g&&I}),{data:F}=oe({enabled:!g&&I}),{data:d}=Oe({id:(t==null?void 0:t.ninja_category_id)||"",enabled:!g&&I});h.useEffect(()=>{if(t){const $=j==null?void 0:j.filter(({id:u})=>{var p;return(p=t.invoice_ids)==null?void 0:p.includes(u)});S($);const _=F==null?void 0:F.filter(({id:u})=>{var p;return(p=t.expense_id)==null?void 0:p.includes(u)});D(_),C(d==null?void 0:d.data.data),m(V)}},[t,d,V,e.transactionId,F]);const c=H();return y("div",{className:"flex flex-col flex-1 border-b",style:{color:c.$3,colorScheme:c.$0,backgroundColor:c.$1,borderColor:c.$4},children:[y("div",{children:[a(w,{leftSide:n("type"),children:n(g?ue.Deposit:ue.Withdrawal)}),a(w,{leftSide:n("amount"),children:s((t==null?void 0:t.amount)||0,o==null?void 0:o.settings.country_id,t==null?void 0:t.currency_id)}),a(w,{leftSide:n("date"),children:L((t==null?void 0:t.date)||"",i)}),a(w,{leftSide:n("bank_account"),className:"cursor-pointer",children:a(O,{style:{color:c.$3,colorScheme:c.$0,backgroundColor:c.$1,borderColor:c.$4},to:E("/settings/bank_accounts/:id/details",{id:r==null?void 0:r.id}),children:r==null?void 0:r.bank_account_name})}),(t==null?void 0:t.participant)&&a(w,{leftSide:n("participant"),children:t.participant}),(t==null?void 0:t.participant_name)&&a(w,{leftSide:n("participant_name"),children:t.participant_name})]}),x?a(mt,{transactionDetails:{base_type:(t==null?void 0:t.base_type)||"",transaction_id:(t==null?void 0:t.id)||"",status_id:(t==null?void 0:t.status_id)||""},isCreditTransactionType:g,transactionRule:k}):y(B,{children:[b==null?void 0:b.map(({id:$,number:_})=>a(w,{leftSide:n("invoice"),className:"cursor-pointer",children:a(O,{style:{color:c.$3,colorScheme:c.$0,backgroundColor:c.$1,borderColor:c.$4},to:E("/invoices/:id/edit",{id:$}),children:_})},$)),(t==null?void 0:t.payment_id)&&a(w,{leftSide:n("payment"),className:"cursor-pointer",children:a(O,{style:{color:c.$3,colorScheme:c.$0},to:E("/payments/:id/edit",{id:f==null?void 0:f.id}),children:f==null?void 0:f.number})}),(t==null?void 0:t.vendor_id)&&a(w,{leftSide:n("vendor"),className:"cursor-pointer",children:a(O,{style:{color:c.$3,colorScheme:c.$0,backgroundColor:c.$1,borderColor:c.$4},to:E("/vendors/:id",{id:N==null?void 0:N.id}),children:N==null?void 0:N.name})}),(t==null?void 0:t.ninja_category_id)&&a(w,{leftSide:n("category"),className:"cursor-pointer",children:a(O,{style:{color:c.$3,colorScheme:c.$0},to:E("/settings/expense_categories/:id/edit",{id:l==null?void 0:l.id}),children:l==null?void 0:l.name})}),T==null?void 0:T.map(({id:$,number:_,date:u})=>a(w,{leftSide:n("expense"),className:"cursor-pointer",children:a(O,{style:{color:c.$3,colorScheme:c.$0},to:E("/expenses/:id/edit",{id:$}),children:_||L(u,i)})},$))]})]})}/** * Invoice Ninja (https://invoiceninja.com). * * @link https://github.com/invoiceninja/invoiceninja source repository * * @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com) * * @license https://www.elastic.co/licensing/elastic-license */function ft(){const[e]=Q(),n=Qe(),{data:o}=je({perPage:1e3}),s=[{label:e("unmatched"),value:"unmatched",color:"white",backgroundColor:n.$1||"#6B7280",dropdownKey:"0"},{label:e("matched"),value:"matched",color:"white",backgroundColor:n.$2||"#1D4ED8",dropdownKey:"0"},{label:e("converted"),value:"converted",color:"white",backgroundColor:n.$3||"#22C55E",dropdownKey:"0"},{label:e("deposits"),value:"deposits",color:"white",backgroundColor:n.$4||"#e6b05c",dropdownKey:"0"},{label:e("withdrawals"),value:"withdrawals",color:"white",backgroundColor:n.$5||"#93C5FD",dropdownKey:"0"}];return o==null||o.forEach(i=>{s.push({label:i.bank_account_name,value:i.id,color:"white",backgroundColor:"#6B7280",queryKey:"bank_integration_ids",dropdownKey:"1",placeHolder:"bank_account"})}),s}function yt(e){const[n]=Q(),{transactions:o,setSelected:s}=e,i=se(),t=Y(),{dateFormat:r}=Z(),[v,k]=h.useState(!1),[b,S]=h.useState(!1),[f,m]=h.useState(""),[l,C]=h.useState(""),T=()=>o.every(({base_type:x,status_id:I})=>x===X.Debit&&I!==J.Converted),D=()=>{m(""),s([]),k(!1),C("")},g=()=>{P.processing(),S(!0);const x=o.map(I=>({id:I.id,vendor_id:f,ninja_category_id:l}));z("POST",R("/api/v1/bank_transactions/match"),{transactions:x}).then(()=>{U(["bank_transactions","expenses"]),P.success("converted_transaction"),D()}).finally(()=>S(!1))};return T()?y(B,{children:[y(Ve,{title:n("create_expense"),visible:v,onClose:D,overflowVisible:!0,children:[y("div",{className:"flex flex-col space-y-3",children:[y("span",{className:"text-base font-medium",children:[n("transactions"),":"]}),a("div",{className:"flex flex-col px-10",children:o.map((x,I)=>y("div",{className:"flex justify-evenly",children:[a("span",{className:"flex-1",children:L(x.date,r)}),a("span",{className:"ml-16 flex-1",children:t(x.amount,i==null?void 0:i.settings.country_id,x.currency_id)})]},I))})]}),a(he,{inputLabel:n("vendor"),value:f,onChange:x=>m(x.id),onClearButtonClick:()=>m("")}),a(me,{inputLabel:n("expense_category"),value:l,onChange:x=>C(x.id),onClearButtonClick:()=>C("")}),a(ae,{behavior:"button",onClick:g,disableWithoutIcon:!0,disabled:!f&&!l||b,children:n("create_expense")})]}),a(ne,{onClick:()=>k(!0),icon:a(W,{element:ze}),children:n("create_expense")})]}):null}const bt=()=>{const[e]=Q(),n=Ye(),o=t=>t.every(({status_id:r})=>J.Matched===r),s=t=>t.every(({payment_id:r})=>r);return[({selectedIds:t,selectedResources:r,setSelected:v})=>r&&s(r)&&a(ne,{onClick:()=>{n(t,"unlink"),v([])},icon:a(W,{element:Re}),children:e("unlink")}),({selectedResources:t,setSelected:r})=>t&&a(yt,{setSelected:r,transactions:t}),({selectedIds:t,selectedResources:r,setSelected:v})=>r&&o(r)&&a(ne,{onClick:()=>{n(t,"convert_matched"),v([])},icon:a(W,{element:Le}),children:e("convert")})]};function pt(){He("transactions");const[e]=Q(),n=Ge(),o=[{name:e("transactions"),href:"/transactions"}],s=tt(),i=ft(),t=lt(),r=bt(),{dateFormat:v}=Z(),[k,b]=h.useState(),[S,f]=h.useState(""),m=l=>{if(f(l.id),l.description){let C=l.description;l.description.length>35&&(C=C.slice(0,35).concat("...")),b(C)}else b(L(l.date,v))};return y(B,{children:[a(ot,{title:k,visible:!!S,onClose:()=>f(""),size:"large",children:a(ht,{transactionId:S,setTransactionId:f})}),a(qe,{title:e("transactions"),breadcrumbs:o,docsLink:"en/transactions/",children:a(Ue,{resource:"transaction",endpoint:"/api/v1/bank_transactions?sort=id|desc",bulkRoute:"/api/v1/bank_transactions/bulk",columns:t,linkToCreate:"/transactions/create",linkToEdit:"/transactions/:id/edit",onTableRowClick:m,customActions:s,customFilters:i,customBulkActions:r,customFilterPlaceholder:"status",rightSide:a(We,{type:"component",guards:[Je(te("create_bank_transaction"),te("edit_bank_transaction"))],component:a(at,{route:"/transactions/import"})}),withResourcefulActions:!0,linkToCreateGuards:[te("create_bank_transaction")],hideEditableOptions:!n("edit_bank_transaction")})})]})}export{pt as default};