import{u as k,aA as x,cC as _,eH as j,j as t,b8 as l,I as m,bl as h,bf as v,F as C,bT as f,ac as I,eI as g,eJ as A,eF as B,ae as T,k as y,aG as p,eK as S,aH as E,aI as F}from"./bundle.CHKSNOJF.js";import{D as O}from"./DataTableColumnsPicker-Cp4QPk4h.js";import{I as G}from"./ImportButton-CAP92Rev.js";import"./Import-DLbAH8Kx.js";const H=()=>{const[e]=k(),n=x(),r=f(),c=_(),u=j(),a=o=>o.flatMap(({documents:s})=>s.map(({id:d})=>d)),i=o=>o.some(({documents:s})=>s.length),P=o=>o.every(({is_deleted:s})=>!s),b=o=>o.every(({is_deleted:s})=>!s),w=o=>o.every(({is_deleted:s})=>!s),D=(o,s)=>{const d=a(o);r(d,"download"),s([])};return[({selectedResources:o,setSelected:s})=>b(o)&&n("create_invoice")&&t.jsx(l,{onClick:()=>{c(o),s([])},icon:t.jsx(m,{element:h}),children:e("new_invoice")}),({selectedResources:o,setSelected:s})=>w(o)&&n("create_purchase_order")&&t.jsx(l,{onClick:()=>{u(o),s([])},icon:t.jsx(m,{element:h}),children:e("new_purchase_order")}),({selectedResources:o,setSelected:s})=>P(o)&&t.jsx(l,{onClick:()=>i(o)?D(o,s):C.error("no_documents_to_download"),icon:t.jsx(m,{element:v}),children:e("documents")})]};function J(){I("products");const[e]=k(),n=x(),r=[{name:e("products"),href:"/products"}],c=g(),u=A(),a=B(),i=H();return t.jsx(T,{title:e("products"),breadcrumbs:r,docsLink:"en/products",children:t.jsx(y,{resource:"product",columns:u,endpoint:"/api/v1/products?include=company&sort=id|desc",bulkRoute:"/api/v1/products/bulk",linkToCreate:"/products/create",linkToEdit:"/products/:id/edit",withResourcefulActions:!0,customActions:a,customBulkActions:i,rightSide:t.jsxs("div",{className:"flex items-center space-x-2",children:[t.jsx(O,{table:"product",columns:c,defaultColumns:S}),t.jsx(E,{type:"component",guards:[F(p("create_product"),p("edit_product"))],component:t.jsx(G,{route:"/products/import"})})]}),linkToCreateGuards:[p("create_product")],hideEditableOptions:!n("edit_product"),enableSavingFilterPreference:!0,dateRangeColumns:[{column:"created_at",queryParameterKey:"created_between"}],enableSavingLatestDataForNavigation:!0})})}export{J as default};
