import{j as e,r as i}from"./@radix-CFOkMR_E.js";import{P as m,A as d,b as x,z as c,h as o,r as u,D as p,S as l,o as h,ax as f}from"./index-DK1ynKjA.js";import{s as j}from"./index-C_CrU4vI.js";import{C as g,R as S}from"./CopyButton-DVwLkafa.js";import{S as N}from"./plus-DOeLmm7C.js";import{a as b}from"./@tanstack-DYiOyJUL.js";import{S as k,P as y}from"./Pagination-DEbVUupy.js";import{D as v}from"./DisplayDate-DYgIjlDF.js";import{I as P}from"./InlineAvatar-CbJtYr0t.js";import{c as w,L as C}from"./@react-router-CO-OsFwI.js";import"./@reactflow-DJfzkHO1.js";import"./url-DuQMeqYA.js";import"./copy-BXNk6BjL.js";import"./index-rK_Wuy2W.js";import"./chevron-right-double-BiEMg7rd.js";function A(){return e.jsx(m,{children:e.jsx("h1",{className:"text-display-xs font-semibold",children:"Stacks"})})}function D(){return[{id:"name",header:"Stack",accessorFn:s=>({name:s.name,id:s.id}),cell:({getValue:s})=>{const{name:t,id:a}=s();return e.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[e.jsx(d,{type:"square",size:"md",children:e.jsx(x,{size:"md",children:t[0]})}),e.jsxs("div",{children:[e.jsx("div",{className:"flex items-center gap-1",children:e.jsx("h2",{className:"text-text-md font-semibold",children:t})}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("p",{className:"text-text-xs text-theme-text-secondary",children:a.split("-")[0]}),e.jsx(g,{copyText:a})]})]})]})}},{id:"created",header:"Created at",accessorFn:s=>{var t;return(t=s.body)==null?void 0:t.created},cell:({getValue:s})=>e.jsx("p",{className:"text-text-sm text-theme-text-secondary",children:e.jsx(v,{dateString:s()})})},{id:"author",header:"Author",accessorFn:s=>{var t;return{author:(t=s.body)==null?void 0:t.user}},cell:({getValue:s})=>{const{author:t}=s();return t?e.jsx(P,{username:t.name}):null}}]}const n=1,E=c.object({page:c.coerce.number().min(n).optional().default(n).catch(n),name:c.string().optional(),operator:c.enum(["and","or"]).optional()});function F(){const[s]=w(),{page:t,name:a,operator:r}=E.parse({page:s.get("page")||void 0,name:s.get("name")||void 0});return{page:t,name:a,logical_operator:r}}function z(){const s=F(),{refetch:t,data:a}=b({...j.stackList({...s,sort_by:"desc:updated"}),throwOnError:!0});return e.jsx("section",{className:"p-5",children:e.jsxs("div",{className:"flex flex-col gap-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(k,{searchParams:s}),e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs(o,{intent:"primary",emphasis:"subtle",size:"md",onClick:()=>t(),children:[e.jsx(S,{className:"h-5 w-5 fill-theme-text-brand"}),"Refresh"]}),e.jsx(o,{size:"md",asChild:!0,children:e.jsxs(C,{to:u.stacks.create.index,children:[e.jsx(N,{className:"h-5 w-5 shrink-0 fill-white"}),e.jsx("span",{children:"New Stack"})]})})]})]}),e.jsxs("div",{className:"flex flex-col items-center gap-5",children:[e.jsx("div",{className:"w-full",children:a?e.jsx(p,{columns:D(),data:a.items}):e.jsx(l,{className:"h-[500px] w-full"})}),a?a.total_pages>1&&e.jsx(y,{searchParams:s,paginate:a}):e.jsx(l,{className:"h-[36px] w-[300px]"})]})]})})}function V(){const{setCurrentBreadcrumbData:s}=h(),{setTourState:t,tourState:{tourActive:a}}=f();return i.useEffect(()=>{a&&t(r=>({...r,run:!0,stepIndex:r.stepIndex}))},[a]),i.useEffect(()=>{s({segment:"stacks",data:null})},[]),e.jsxs("div",{children:[e.jsx(A,{}),e.jsx(z,{})]})}export{V as default};
