import{aE as m,j as e,ao as g,aF as u,aG as h,B as x,y as d,aH as f,aI as p,c as j,aa as w,ah as N,ae as y,aJ as v,aK as C}from"./index-CfKY7XrC.js";import{F as b}from"./facet-chips-DrGR5YyE.js";import{S as k}from"./section-mark-F5ZGiWj1.js";function A(){const{owner:t}=m.useParams(),{entity_id:s}=m.useSearch();return e.jsx(g,{owner:t,tabSegment:"connectors",title:"Connectors",headless:!0,children:o=>e.jsx(L,{ownerSlug:o.ownerSlug,organizationId:o.organizationId,isWorkspaceLoading:o.isWorkspaceLoading,entityId:s?Number(s):void 0})})}function L({ownerSlug:t,organizationId:s,isWorkspaceLoading:o,entityId:c}){const{data:r=[],isLoading:l}=u(s??"",{entityId:c}),i=o||l,n=!i&&r.length>0;return e.jsxs("div",{className:"flex flex-1 flex-col gap-6 px-4 py-6 lg:px-6",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{middle:e.jsx(h,{className:"h-3.5 w-3.5"})}),e.jsx("h1",{className:"text-3xl font-semibold leading-tight",children:"Connectors"})]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Connect the tools your agents watch, chat through, and act on."})]}),n?e.jsx(x,{asChild:!0,children:e.jsxs(d,{to:"/$owner/connectors/create",params:{owner:t},children:[e.jsx(f,{className:"mr-2 h-4 w-4"}),"Add connection"]})}):null]}),c!=null&&e.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border bg-muted/50 px-3 py-2 text-sm",children:[e.jsx(p,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-muted-foreground",children:"Showing connectors linked to one entity"}),e.jsx(x,{asChild:!0,variant:"ghost",size:"sm",className:"ml-auto h-6",children:e.jsx(d,{to:"/$owner/connectors",params:{owner:t},search:{},children:"Show all"})})]}),e.jsx(_,{ownerSlug:t,organizationId:s,isContentLoading:i,groups:r})]})}function _({ownerSlug:t,organizationId:s,isContentLoading:o,groups:c}){const r=j(),{data:l=[]}=w(s??""),i=new Map(l.map(n=>[n.key,n]));return o?e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:Array.from({length:3}).map((n,a)=>e.jsx(N,{className:"h-[88px] w-full rounded-lg"},a))}):c.length===0?e.jsx(y,{icon:h,title:"Create your first connection",description:"Connect a tool to start watching, chatting through, and acting on it.",actionLabel:"Add connection",onAction:()=>r({to:"/$owner/connectors/create",params:{owner:t}})}):e.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 lg:grid-cols-3",children:c.map(n=>{const a=v(n.connector_key,i,{name:n.connector_name??n.connector_key,faviconDomain:n.favicon_domain});return e.jsxs(d,{to:"/$owner/connectors/$connectorKey",params:{owner:t,connectorKey:n.connector_key},className:"flex h-full flex-col gap-2 rounded-lg bg-card p-3 text-left text-muted-foreground transition-colors hover:bg-accent/50 hover:text-foreground",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C,{icon:a.icon,name:a.name,faviconDomain:a.faviconDomain,className:"h-7 w-7 rounded-md text-[10px]"}),e.jsx("span",{className:"truncate text-sm font-medium",children:a.name})]}),e.jsx(b,{facets:n.facets}),e.jsxs("div",{className:"mt-auto text-xs text-muted-foreground",children:[n.connection_count," ",n.connection_count===1?"connection":"connections"]})]},n.connector_key)})})}export{A as component};
