import{cV as S,ce as P,a as b,y as L,j as e,C as T,cX as w,cd as o,S as D}from"./bundle.CHKSNOJF.js";import{C as F}from"./ClientSelector-BbBNOaqF.js";import{u as k,I as N,a as R}from"./useProductColumns-DDQWs8XU.js";import{e as U}from"./hooks-9RDJr6hd.js";import{C as V,a as B}from"./CreditFooter-B8d4FsNo.js";import"./UserUnsubscribedTooltip-CmrNR5P-.js";import"./ClientActionButtons-q9eajqVG.js";import"./InvoiceViewer-DkbHIsNq.js";import"./CreditStatus-WHg8w3rC.js";import"./useInvoiceColumns-CGbyIb88.js";import"./InvoiceStatus-1S0ZEgN9.js";import"./invoice-status-C0SI5VYC.js";function K(){const s=S(),{credit:i,isDefaultFooter:r,isDefaultTerms:c,errors:a,client:l,invoiceSum:d,setIsDefaultFooter:m,setIsDefaultTerms:C}=s,[p]=P(),h=b(),u=L(),g=k(),{handleChange:n,handleInvitationChange:x,handleLineItemChange:f,handleLineItemPropertyChange:y,handleCreateLineItem:I,handleDeleteLineItem:j,handleContactCanSignChange:v}=U({client:l});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-12 gap-4",children:[e.jsx(T,{className:"col-span-12 xl:col-span-4 h-max shadow-sm",withContainer:!0,style:{borderColor:h.$24},children:e.jsx(F,{resource:i,onChange:t=>n("client_id",t),onLocationChange:t=>n("location_id",t),onClearButtonClick:()=>{n("client_id",""),n("location_id","")},onContactCheckboxChange:x,onContactCanSignCheckboxChange:v,errorMessage:a?.errors.client_id,disableWithSpinner:p.get("action")==="create"})}),e.jsx(V,{handleChange:n,errors:a}),e.jsx("div",{className:"col-span-12",children:i?e.jsx(w,{type:"product",resource:i,items:i.line_items.filter(t=>[o.Product,o.UnpaidFee,o.PaidFee,o.LateFee].includes(t.type_id)),columns:g,relationType:"client_id",onLineItemChange:f,onSort:t=>n("line_items",t),onLineItemPropertyChange:y,onCreateItemClick:I,onDeleteRowClick:j}):e.jsx(D,{})}),e.jsx(B,{handleChange:n,errors:a,isDefaultFooter:r,isDefaultTerms:c,setIsDefaultFooter:m,setIsDefaultTerms:C}),i&&e.jsx(N,{relationType:"client_id",resource:i,invoiceSum:d,onChange:(t,_)=>n(t,_)})]}),u?.show_pdf_preview&&e.jsx("div",{className:"my-4",children:i&&e.jsx(R,{for:"create",resource:i,entity:"credit",relationType:"client_id",endpoint:"/api/v1/live_preview?entity=:entity",observable:!0,initiallyVisible:!1})})]})}export{K as default};
