import{E as e,O as t,t as n,y as r}from"./jsx-runtime-DLhMyTcm.js";import{t as i}from"./button-DxvPbmBs.js";import{J as a,et as o}from"./index-B9ptohSA.js";import{t as s}from"./use-document-meta-Bjf8eIPh.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./table-CCNPbiUy.js";import{n as g,r as _}from"./dist-CavaMUP-.js";var v=n();async function y({request:e}){let t=new URL(e.url).searchParams.get(`name`)??``,n=new URLSearchParams;t&&n.set(`name`,t);let i=n.toString(),a=await r.get(`/workflows${i?`?${i}`:``}`);return{workflows:await Promise.all(a.data.map(e=>r.get(`/workflows/${e}`).then(e=>e.data)))}}function b(){let{workflows:n}=e(),r=t(),[y,b]=_(`name`,g.withDefault(``).withOptions({shallow:!1,limitUrlUpdates:o(300),history:`replace`}));return s({title:`Workflows`,description:`Registered workflow handlers in the engine.`}),(0,v.jsx)(l,{title:`Workflows`,description:`Registered workflow handlers in the engine.`,children:(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-end`,children:[(0,v.jsxs)(`div`,{className:`flex-1`,children:[(0,v.jsx)(`label`,{htmlFor:`filter-name`,className:`text-sm font-medium`,children:`Workflow Name`}),(0,v.jsx)(a,{id:`filter-name`,placeholder:`Filter by workflow name...`,value:y,onChange:e=>b(e.target.value||null),className:`mt-1`})]}),y&&(0,v.jsx)(i,{onClick:()=>b(null),variant:`outline`,children:`Remove all filters`})]}),n.length===0?(0,v.jsx)(`div`,{className:`text-center py-16 text-muted-foreground border rounded-lg bg-muted/20`,children:`No workflows registered.`}):(0,v.jsx)(`div`,{className:`rounded-lg border`,children:(0,v.jsxs)(h,{children:[(0,v.jsx)(c,{children:(0,v.jsxs)(f,{children:[(0,v.jsx)(u,{children:`Name`}),(0,v.jsx)(u,{children:`Description`}),(0,v.jsx)(u,{children:`Sub-workflows`})]})}),(0,v.jsx)(d,{children:n.map(e=>(0,v.jsxs)(f,{className:`cursor-pointer hover:bg-muted/50`,onClick:()=>r(`/workflows/${e.name}`),children:[(0,v.jsx)(p,{className:`font-medium`,children:e.name}),(0,v.jsx)(p,{className:`text-sm text-muted-foreground max-w-md truncate`,children:e.description||`-`}),(0,v.jsx)(p,{children:e.sub_workflows.length>0?(0,v.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.sub_workflows.map(e=>(0,v.jsx)(m,{variant:`outline`,className:`text-xs`,children:e.name},e.name))}):(0,v.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`-`})})]},e.name))})]})})]})})}export{b as Component,y as loader};