import{r as w,j as e,bz as v,k as x,bp as h,bA as g,bn as j,x as C,M as D}from"./index-CHfgriyV.js";function P({items:o,defaultSelected:a,onApply:i}){const[s,d]=w.useState(a),p=(r,c)=>{d(n=>({...n,[r]:c}))},S=()=>{i(s)},f=()=>{const r=Object.fromEntries(o.map(c=>[c.id,null]));d(r)},t=r=>{r&&d(a)},b=Object.values(a).filter(Boolean).length,I=Object.values(s).filter(Boolean).length,y=b?`${b} applied ${b>1?"filters":"filter"}`:"No filters applied";return e.jsxs(v,{onOpenChange:t,children:[e.jsx(x,{"aria-label":"Open filters",leftIcon:"filter",size:"md",variant:"secondary",children:"Filter"}),e.jsx(h,{isDismissable:!0,"aria-label":"Filters",children:e.jsxs(h.Dialog,{children:[e.jsx(h.Header,{title:"Filters",description:y}),e.jsx(h.Content,{className:"flex flex-col gap-4",children:o.map(({options:r,isMulti:c,...n})=>{const u=`Filter by ${n.label?.toLowerCase()}`;return c?e.jsx(g,{label:n.label,value:s[String(n.id)]||[],onChange:l=>p(String(n.id),l.length?l.map(String):null),"aria-label":u,placeholder:u,className:"w-80",children:e.jsx(g.ListBox,{children:r.map(l=>e.jsx(g.Item,{...l},l.id))})},n.id):e.jsx(j,{...n,isInvalid:n.isInvalid&&!!s[String(n.id)],"aria-label":u,placeholder:u,className:"w-80",value:s[String(n.id)],onChange:l=>p(String(n.id),l?[String(l)]:null),children:e.jsx(j.ListBox,{children:r.map(l=>e.jsx(j.Item,{...l},l.id))})},n.id)})}),e.jsxs(h.Footer,{className:"flex justify-between",children:[e.jsx(x,{onPress:f,variant:"tertiary",isDisabled:!I,children:"Reset filters"}),e.jsx(x,{onPress:S,slot:"close",children:"Apply"})]})]})})]})}function m({snapshotId:o,paths:a}){const[i,s]=w.useState(!1),{api:d,repository:p}=C();return{downloadSnapshot:async()=>{s(!0);const f=await d.downloadSnapshotVFS({repository:p,snapshot:o,paths:a}),t=document.createElement("a");t.style.display="none",t.target="_blank",t.rel="noopener noreferrer",t.href=f.url,document.body.appendChild(t),t.click(),document.body.removeChild(t),s(!1)},isPending:i}}function B({snapshotId:o,paths:a,...i}){const{downloadSnapshot:s,isPending:d}=m({snapshotId:o,paths:a});return e.jsx(x,{onPress:s,isPending:d,leftIcon:"download",...i})}function L({snapshotId:o,paths:a}){const{downloadSnapshot:i}=m({snapshotId:o,paths:a});return e.jsx(D.Item,{label:"Download",onPress:i,leftIcon:"download"})}export{L as D,P as F,B as a};
