import{r as c,j as e,D as h}from"./vendor-tanstack-BVzzyDEt.js";import{a3 as j,O as b,P as v,S,d as A,e as C,f as N,h as T,I as x,D as g,B as k,a as E,b as D,E as I,m as M,n as V,o as L,p as B,br as p,bs as w,bt as R}from"./index-BJkJ93Lr.js";import{u as _}from"./use-local-storage-BIDUVcfc.js";import{A as G}from"./artifact-card-Cy3v2Lds.js";import{T as P,a as f}from"./toggle-group-B18EYoB-.js";import{u as Q}from"./use-debounce-callback-K3TIomWn.js";import"./vendor-react-Bce9NwRC.js";import"./vendor-radix-CTAic6HB.js";import"./vendor-recharts-Mwm2qLZp.js";import"./vendor-forms-BN3tpxM2.js";import"./vendor-date-2jFo9aCm.js";import"./lazy-markdown-CwRqR_1U.js";const F=[{value:"all",label:"All Types"},{value:"markdown",label:"Markdown"},{value:"progress",label:"Progress"},{value:"image",label:"Image"},{value:"table",label:"Table"}],H=({filters:t,onFilterChange:s,totalCount:i,displayMode:o,setDisplayMode:r})=>{const l=c.useCallback(a=>{s([...t.filter(u=>u.id!=="name"),{id:"name",label:"Name",value:a}])},[t,s]),d=c.useCallback(a=>{s([...t.filter(u=>u.id!=="type"),{id:"type",label:"Type",value:a}])},[t,s]),m=c.useMemo(()=>t.find(a=>a.id==="type")?.value,[t]),n=c.useMemo(()=>t.find(a=>a.id==="name")?.value,[t]);return e.jsxs("div",{"data-testid":"artifact-filter",className:"flex justify-between items-center",children:[e.jsx("div",{children:e.jsxs(j,{variant:"body",className:"text-sm text-muted-foreground",children:[i," ",b(i,"artifact")]})}),e.jsxs("div",{className:"flex gap-4",children:[e.jsx(v,{"data-testid":"search-input",defaultValue:n,placeholder:"Search artifacts",onChange:a=>l(a.target.value)}),e.jsxs("div",{className:"flex gap-4",children:[e.jsxs(S,{"data-testid":"type-select",value:m,onValueChange:d,children:[e.jsx(A,{"aria-label":"Artifact type",children:e.jsx(C,{placeholder:"Type"})}),e.jsx(N,{children:F.map(({value:a,label:u})=>e.jsx(T,{value:a,children:u},a))})]}),e.jsx("div",{children:e.jsxs(P,{type:"single",defaultValue:o,onValueChange:a=>r(a),children:[e.jsx(f,{"data-testid":"grid-layout",value:"grid",children:e.jsx(x,{id:"LayoutGrid"})}),e.jsx(f,{"data-testid":"list-layout",value:"list",children:e.jsx(x,{id:"AlignJustify"})})]})})]})]})]})},O=()=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(q,{}),e.jsx(g,{id:"artifacts-guide",label:"Documentation"})]}),q=()=>e.jsx("div",{className:"flex items-center ",children:e.jsx(k,{children:e.jsx(E,{children:e.jsx(D,{className:"text-xl font-bold text-foreground",children:"Artifacts"})})})}),z=()=>e.jsxs(I,{children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsx(M,{id:"Image"})}),e.jsx(V,{children:"Create an artifact to get started"}),e.jsx(L,{children:"Artifacts are byproducts of your runs; they can be anything from a markdown string to a table."}),e.jsx(B,{children:e.jsx(g,{id:"artifacts-guide"})})]}),J=({filters:t,onFilterChange:s,artifactsList:i,artifactsCount:o})=>{const[r,l]=_("artifacts-grid-style","grid"),d=c.useMemo(()=>r==="grid"?"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4":"grid-cols-1",[r]),m=c.useMemo(()=>i.reduce((n,a)=>(n.find(u=>u.key===a.key)||n.push(a),n),[]),[i]);return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(O,{}),e.jsx(H,{filters:t,onFilterChange:s,totalCount:o,setDisplayMode:l,displayMode:r}),m.length===0?e.jsx(z,{}):e.jsx("div",{className:d,children:m.map(n=>e.jsx(G,{artifact:n},n.id))})]})},y=t=>({artifacts:{operator:"and_",type:{any_:t?.type&&t?.type!=="all"?[t.type]:void 0},key:{like_:t?.name??""}},sort:"CREATED_DESC",offset:0}),K=()=>{const t=p.useSearch(),s=p.useNavigate(),i=c.useMemo(()=>[{id:"type",label:"Type",value:t.type??"all"},{id:"name",label:"Name",value:t.name}],[t.type,t.name]),o=Q(c.useCallback(r=>{r&&s({to:".",search:()=>r.filter(l=>l.value).reduce((l,d)=>(d.value&&(l[d.id]=d.value),l),{}),replace:!0})},[s]),400);return{filters:i,onFilterChange:o}};function le(){const t=p.useSearch(),{filters:s,onFilterChange:i}=K(),[{data:o},{data:r}]=h({queries:[w(y(t)),R(y(t))]});return e.jsx(J,{filters:s,onFilterChange:i,artifactsCount:o,artifactsList:r})}export{le as component};
//# sourceMappingURL=index-C-IgUQuQ.js.map
