import{j as n,d as s,aa as R}from"./index-3c1b2661.js";const A=({filteredNames:t,itemName:o,parentName:u,selectedNames:l,setSelectedNames:a,processingNames:b,rows:i,headers:x,...d})=>{const h=l.length===t.length&&l.length>0,m=l.length>0,p=()=>{a(t)},r=()=>{a(i.map(e=>e.name??""))},C=()=>{a([])},k=[{content:n.jsxs(n.Fragment,{children:[n.jsx(s.CheckboxInput,{label:n.jsx("div",{className:"u-off-screen",children:"Select all"}),labelClassName:"multiselect-checkbox",checked:h,indeterminate:m&&!h,onChange:m?C:r}),n.jsx(s.ContextualMenu,{className:"select-context-menu",position:"left",title:"Multiselect",toggleAppearance:"base",toggleClassName:"has-icon u-no-margin--bottom",toggleLabel:n.jsx(s.Icon,{name:"chevron-down"}),toggleProps:{"aria-label":"multiselect rows"},links:[{children:`Select all ${o}s on this page`,onClick:r},{children:`Select all ${u} ${o}s`,onClick:p}]})]}),className:"select select-header","aria-label":"select"},...x??[]],j=i.map(e=>{const c=l.includes(e.name??""),g=b.includes(e.name??""),S=()=>{const f=c?l.filter(M=>M!==e.name):[...l,e.name??""];a(f)};return e.columns=[{content:n.jsx(s.CheckboxInput,{label:n.jsxs("div",{className:"u-off-screen",children:["Select ",e.name??"row"]}),labelClassName:"u-no-margin--bottom",checked:c,onChange:S,disabled:g||!e.name}),role:"rowheader",className:"select"},...e.columns??[]],e.className=R(e.className,{"selected-row":c,"processing-row":g}),e.key=e.name,e});return n.jsx(s.MainTable,{expanding:!0,headers:k,rows:[...j],...d})};export{A as S};
