import{j as e}from"./@radix-DAoBbclx.js";import{C as f,o as y,q as j,A as b,h as g,t as N,c as v,r as x,k as C,aD as k,aI as w,s as O}from"./index-DnCFURX3.js";import{a as S}from"./@monaco-editor-Di1Jq_O0.js";import{b as I,a as A}from"./CollapsibleCard-CehR97tz.js";import{C as T}from"./ComponentIcon-BOGF3ktm.js";import{L as h}from"./@react-router-BTai9D5g.js";import{N as z}from"./KeyValue-B_OUMPK3.js";import{s as m}from"./constants-BUlqx9qT.js";function B({children:s,stackName:t}){const[l,a]=S.useState(!0);return e.jsxs(f,{open:l,onOpenChange:a,children:[e.jsx(y,{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(I,{open:l}),e.jsxs("div",{className:"group/copybutton flex items-center gap-2",children:[e.jsx(b,{type:"square",size:"md",children:e.jsx(g,{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(N,{className:v("space-y-3 border-t border-theme-border-moderate bg-theme-surface-primary px-5 py-3"),children:s})]})}function L({component:s,objectConfig:t}){var n,i,d,p,o,c;const l=`${(n=s.body)==null?void 0:n.type}.${(i=s.body)==null?void 0:i.flavor_name}`,a=(t==null?void 0:t[l])??void 0;return!k(a)||Object.keys(a).length===0?e.jsx(h,{to:x.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(u,{componentLogoUrl:((d=s.body)==null?void 0:d.logo_url)??void 0,componentName:s.name,componentType:((p=s.body)==null?void 0:p.type)??"orchestrator"})]})}):e.jsx(z,{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(u,{componentLogoUrl:((o=s.body)==null?void 0:o.logo_url)??void 0,componentName:s.name,componentType:((c=s.body)==null?void 0:c.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(A,{copyText:JSON.stringify(a)})})}),e.jsx(h,{className:"absolute inset-0",to:x.components.detail(s.id)})]}),data:a})}function u({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:w(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:O(s)}):e.jsx(T,{type:l}),e.jsx("p",{className:"truncate",children:t})]}),a]})]})}function _(s){return s.sort((t,l)=>{var o,c;const a=((o=t.body)==null?void 0:o.type)??"",r=((c=l.body)==null?void 0:c.type)??"",n=m.indexOf(a),i=m.indexOf(r),d=n===-1?m.length:n,p=i===-1?m.length:i;return d-p})}function $({stack:s,objectConfig:t}){var a;const l=_(Object.values(((a=s.metadata)==null?void 0:a.components)||{}).flat());return e.jsx("ul",{className:"space-y-5",children:l.map(r=>e.jsx("li",{className:"w-full",children:e.jsx(L,{component:r,objectConfig:t})},r.id))})}function M({stack:s,objectConfig:t}){return e.jsx(B,{stackName:s.name,children:e.jsx($,{stack:s,objectConfig:t})})}export{M as S};
