import{r as f,aJ as e}from"./@ui-core-DKdciH1Z.js";import{C as h,o as u,q as j,A as y,h as b,v as g,c as N,k as C,r as c,ac as v,ai as k,s as w}from"./index-D7KLAbvI.js";import{b as O,a as S}from"./CollapsibleCard-3zV5aMxC.js";import{C as I}from"./ComponentIcon-BOKrWHiD.js";import{L as d}from"./@react-router-DaIuhn3X.js";import{N as A}from"./NestedCollapsible-k41ntPyA.js";import{s as r}from"./constants-Dj_C1ZPH.js";function T({children:s,stackName:t}){const[l,a]=f.useState(!0);return e.jsxs(h,{open:l,onOpenChange:a,children:[e.jsx(u,{className:"flex h-9 items-center p-0",children:e.jsxs(j,{className:"flex w-full items-center gap-2 px-5 py-3",children:[e.jsx(O,{open:l}),e.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[e.jsx(y,{type:"square",size:"md",children:e.jsx(b,{size:"md",children:t[0]||"S"})}),e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"text-text-sm text-theme-text-tertiary",children:"Stack"}),e.jsx("p",{className:"text-text-lg",children:t})]})]})]})}),e.jsx(g,{className:N("space-y-3 border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3"),children:s})]})}function z({component:s,objectConfig:t}){const l=`${s.body?.type}.${s.body?.flavor_name}`,a=t?.[l]??void 0;return!v(a)||Object.keys(a).length===0?e.jsx(d,{to:c.components.detail(s.id),children:e.jsxs(C,{className:"flex w-full items-center gap-[10px] bg-theme-surface-secondary px-5 py-3 text-left",children:[e.jsx("div",{className:"size-5 shrink-0"}),e.jsx(p,{componentLogoUrl:s.body?.logo_url??void 0,componentName:s.name,componentType:s.body?.type??"orchestrator"})]})}):e.jsx(A,{intent:"secondary",contentClassName:"pl-[60px]",className:"w-full",isInitialOpen:!0,title:void 0,headerChildren:e.jsxs("div",{className:"relative flex w-full items-center justify-between gap-3 text-left",children:[e.jsx(p,{componentLogoUrl:s.body?.logo_url??void 0,componentName:s.name,componentType:s.body?.type??"orchestrator",children:e.jsx("div",{className:"z-10 opacity-100 transition-opacity duration-200 lg:opacity-0 lg:group-hover:opacity-100",children:e.jsx(S,{copyText:JSON.stringify(a)})})}),e.jsx(d,{className:"absolute inset-0",to:c.components.detail(s.id)})]}),data:a})}function p({componentLogoUrl:s,componentName:t,componentType:l,children:a}){return e.jsxs("div",{className:"grid w-full max-w-full grid-cols-3 items-center gap-2",children:[e.jsx("div",{className:"col-span-1 truncate text-theme-text-secondary",children:k(l)}),e.jsxs("div",{className:"col-span-2 flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 overflow-hidden",children:[s?e.jsx("img",{width:32,height:32,alt:`${t} logo`,src:w(s)}):e.jsx(I,{type:l}),e.jsx("p",{className:"truncate",children:t})]}),a]})]})}function B(s){return s.sort((t,l)=>{const a=t.body?.type??"",n=l.body?.type??"",i=r.indexOf(a),o=r.indexOf(n),m=i===-1?r.length:i,x=o===-1?r.length:o;return m-x})}function L({stack:s,objectConfig:t}){const l=B(Object.values(s.metadata?.components||{}).flat());return e.jsx("ul",{className:"space-y-5",children:l.map(a=>e.jsx("li",{className:"w-full",children:e.jsx(z,{component:a,objectConfig:t})},a.id))})}function U({stack:s,objectConfig:t}){return e.jsx(T,{stackName:s.name,children:e.jsx(L,{stack:s,objectConfig:t})})}export{U as S};
