import{c as b,j as t,a4 as f,b as p,a2 as j,g as v,aq as k,cF as N,B as x,dw as m}from"./index-CfKY7XrC.js";function A(a,e){const{orgContext:s,hasOrgContext:g}=p(),{isLoading:n}=j(`/${a}`,s),{isAuthenticated:i}=v(),{isMember:u,isLoading:o}=k(),r=i&&u,{data:l=[],isLoading:d}=N({enabled:r}),c=r?!g||n||d||o:n||o;return{agent:l.find(h=>h.agentId===e)??null,isLoading:c}}function $({owner:a,agentId:e,children:s,showBack:g,backLabel:n,backTo:i,loadingLabel:u,title:o}){const r=b(),{agent:l,isLoading:d}=A(a,e);if(d||!l)return t.jsx(f,{label:u,variant:"panel"});const c=()=>{r({to:i,params:i==="/$owner/agents/$agentId/$tab"?{owner:a,agentId:e,tab:"platforms"}:{owner:a,agentId:e}})};return t.jsx("div",{className:"mx-auto w-full max-w-4xl pb-8",children:o?t.jsxs(t.Fragment,{children:[t.jsx(B,{title:o,onBack:c,backLabel:n}),s]}):g?t.jsx(L,{onBack:c,backLabel:n,children:s}):s})}function L({onBack:a,backLabel:e,children:s}){return t.jsxs("div",{className:"relative",children:[t.jsx(x,{type:"button",variant:"ghost",size:"icon",className:"absolute right-full top-0 mr-1 size-8 text-muted-foreground hover:text-foreground","aria-label":`Back to ${e}`,onClick:a,children:t.jsx(m,{className:"h-4 w-4"})}),s]})}function B({title:a,onBack:e,backLabel:s}){return t.jsx("div",{className:"sticky top-0 z-10 mb-2 bg-background py-2",children:t.jsxs("div",{className:"flex items-center justify-center gap-1",children:[t.jsx(x,{type:"button",variant:"ghost",size:"icon",className:"size-8 shrink-0 text-muted-foreground hover:text-foreground","aria-label":`Back to ${s}`,onClick:e,children:t.jsx(m,{className:"h-4 w-4"})}),t.jsx("span",{className:"truncate text-base font-semibold",children:a})]})})}export{B as A,L as W,$ as a};
