import{r as l,j as e,w as z,v as B,M as F,L as q,S as G,x as J,O as Q,y as X,i as Y,z as _,A as ee,B as te}from"./index-BmZS3y7B.js";import{c as C,u as se,T as W,a as P,b as I,r as re,t as H,B as A,L as ne,d as R,e as oe,S as ae,f as ie}from"./mermaid-3ZIDBTTL-CCXSRVd3.js";var ce=(t,r,s,n,a,i,u,h)=>{let o=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(t)?t:[t]).forEach(x=>{let k=x==="class",S=k&&i?a.map(b=>i[b]||b):a;k?(o.classList.remove(...S),o.classList.add(i&&i[f]?i[f]:f)):o.setAttribute(x,f)}),v(f)}function v(f){h&&c.includes(f)&&(o.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(n)d(n);else try{let f=localStorage.getItem(r)||s,x=u&&f==="system"?m():f;d(x)}catch{}},O=["light","dark"],K="(prefers-color-scheme: dark)",le=typeof window>"u",$=l.createContext(void 0),de={setTheme:t=>{},themes:[]},T=()=>{var t;return(t=l.useContext($))!=null?t:de},ue=t=>l.useContext($)?l.createElement(l.Fragment,null,t.children):l.createElement(me,{...t}),he=["light","dark"],me=({forcedTheme:t,disableTransitionOnChange:r=!1,enableSystem:s=!0,enableColorScheme:n=!0,storageKey:a="theme",themes:i=he,defaultTheme:u=s?"system":"light",attribute:h="data-theme",value:o,children:c,nonce:d,scriptProps:v})=>{let[m,f]=l.useState(()=>pe(a,u)),[x,k]=l.useState(()=>m==="system"?E():m),S=o?Object.values(o):i,b=l.useCallback(p=>{let g=p;if(!g)return;p==="system"&&s&&(g=E());let j=o?o[g]:g,V=r?ge(d):null,w=document.documentElement,M=y=>{y==="class"?(w.classList.remove(...S),j&&w.classList.add(j)):y.startsWith("data-")&&(j?w.setAttribute(y,j):w.removeAttribute(y))};if(Array.isArray(h)?h.forEach(M):M(h),n){let y=O.includes(u)?u:null,U=O.includes(g)?g:y;w.style.colorScheme=U}V==null||V()},[d]),L=l.useCallback(p=>{let g=typeof p=="function"?p(m):p;f(g);try{localStorage.setItem(a,g)}catch{}},[m]),N=l.useCallback(p=>{let g=E(p);k(g),m==="system"&&s&&!t&&b("system")},[m,t]);l.useEffect(()=>{let p=window.matchMedia(K);return p.addListener(N),N(p),()=>p.removeListener(N)},[N]),l.useEffect(()=>{let p=g=>{g.key===a&&(g.newValue?f(g.newValue):L(u))};return window.addEventListener("storage",p),()=>window.removeEventListener("storage",p)},[L]),l.useEffect(()=>{b(t??m)},[t,m]);let D=l.useMemo(()=>({theme:m,setTheme:L,forcedTheme:t,resolvedTheme:m==="system"?x:m,themes:s?[...i,"system"]:i,systemTheme:s?x:void 0}),[m,L,t,x,s,i]);return l.createElement($.Provider,{value:D},l.createElement(fe,{forcedTheme:t,storageKey:a,attribute:h,enableSystem:s,enableColorScheme:n,defaultTheme:u,value:o,themes:i,nonce:d,scriptProps:v}),c)},fe=l.memo(({forcedTheme:t,storageKey:r,attribute:s,enableSystem:n,enableColorScheme:a,defaultTheme:i,value:u,themes:h,nonce:o,scriptProps:c})=>{let d=JSON.stringify([s,r,i,t,h,u,n,a]).slice(1,-1);return l.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?o:"",dangerouslySetInnerHTML:{__html:`(${ce.toString()})(${d})`}})}),pe=(t,r)=>{if(le)return;let s;try{s=localStorage.getItem(t)||void 0}catch{}return s||r},ge=t=>{let r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(r),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(r)},1)}},E=t=>(t||(t=window.matchMedia(K)),t.matches?"dark":"light");/**
 * @license lucide-react v0.575.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const xe=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ve=C("activity",xe);/**
 * @license lucide-react v0.575.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ye=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],be=C("arrow-up-right",ye);/**
 * @license lucide-react v0.575.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const je=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],we=C("monitor",je);/**
 * @license lucide-react v0.575.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ce=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],ke=C("moon",Ce);/**
 * @license lucide-react v0.575.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Le=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Ne=C("sun",Le);function Z(t){return t==null?void 0:t["local.shortName"]}function He(t,r){return(t==="local"||t==="@workflow/world-local")&&Z(r)==="packages/web"}function Se(t){const r=t.WORKFLOW_VERCEL_ENV||"production",s=t.WORKFLOW_VERCEL_TEAM,n=t.WORKFLOW_VERCEL_PROJECT,a=s&&n?`${s}/${n}`:n||s||"Unknown";return`Connected to Vercel ${r} (${a})`}function Ee(t){const r=t==null?void 0:t["derived.WORKFLOW_POSTGRES_URL.hostname"],s=t==null?void 0:t["derived.WORKFLOW_POSTGRES_URL.database"];return r?`Connected to Postgres (${r}${s?`/${s}`:""})`:"Connected to Postgres"}function $e(t){const{backendDisplayName:r,backendId:s,displayInfo:n,publicEnv:a}=t;switch(s){case"local":case"@workflow/world-local":return`Local Dev: ${Z(n)||"Unknown"}`;case"vercel":case"@workflow/world-vercel":return Se(a);case"postgres":case"@workflow/world-postgres":return Ee(n);default:return`Connected to: ${r}`}}function Te(t){return e.jsx("div",{className:"grid grid-cols-[auto,1fr] gap-x-4 gap-y-1",children:t.map(({key:r,value:s})=>e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:r}),e.jsx("div",{className:"font-mono text-xs text-foreground break-all",children:s})]},r))})}function Ve(){const{serverConfig:t}=se(),r=$e(t),{backendId:s}=t,n=He(s,t.displayInfo),a=Object.entries(t.publicEnv).sort(([o],[c])=>o.localeCompare(c)),i=[...t.sensitiveEnvKeys].sort(),u=a.length>0||i.length>0||n,h=e.jsx("div",{className:"text-md whitespace-nowrap",children:e.jsx("span",{className:"font-medium",children:r})});return u?e.jsxs(W,{children:[e.jsx(P,{asChild:!0,children:h}),e.jsx(I,{children:e.jsxs("div",{className:"flex flex-col gap-2 max-w-[640px]",children:[n&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Local data directory looks misconfigured"}),e.jsxs("div",{className:"text-muted-foreground",children:["This UI appears to be pointing at ",e.jsx("code",{children:"packages/web"}),". Configure the local data directory / working directory and restart the web UI. See"," ",e.jsx("a",{className:"underline",href:"https://useworkflow.dev/docs/observability",target:"_blank",rel:"noopener noreferrer",children:"docs"}),"."]})]}),Te([...a.map(([o,c])=>({key:o,value:c})),...i.map(o=>({key:o,value:"*****"}))])]})})]}):h}function Me(){const[t,r]=l.useState(!1),s=l.useMemo(()=>({}),[]),n=l.useCallback(async()=>{r(!0);const a=["workflow","step"],i=[];try{for(const o of a){const c=await re(s,o,{timeout:3e4});c.success&&i.push({endpoint:o,result:c.data})}const u=i.every(o=>o.result.healthy),h=i.some(o=>o.result.healthy);if(u){const o=i.reduce((c,d)=>c+(d.result.latencyMs??0),0);H.success("All endpoints healthy",{description:`Workflow and Step endpoints are responding (${o}ms total)`})}else if(h){const o=i.filter(d=>d.result.healthy),c=i.filter(d=>!d.result.healthy);H.warning("Partial health check success",{description:`${o.map(d=>d.endpoint).join(", ")} OK; ${c.map(d=>`${d.endpoint}: ${d.result.error||"failed"}`).join(", ")}`})}else{const o=i.map(c=>`${c.endpoint}: ${c.result.error||"failed"}`).join("; ");H.error("Health check failed",{description:o})}}catch(u){const h=u instanceof Error?u.message:String(u);H.error("Health check error",{description:h})}finally{r(!1)}},[s]);return e.jsxs(W,{children:[e.jsx(P,{asChild:!0,children:e.jsxs(A,{variant:"ghost",size:"sm",onClick:n,disabled:t,className:"gap-1.5",children:[t?e.jsx(ne,{className:"h-4 w-4 animate-spin"}):e.jsx(ve,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:t?"Checking...":"Health Check"})]})}),e.jsx(I,{children:e.jsxs("p",{children:["Run a queue-based health check on workflow and step endpoints.",e.jsx("br",{}),"This bypasses Deployment Protection."]})})]})}function Re({value:t,onValueChange:r,options:s,className:n}){return e.jsx("div",{className:R("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",n),children:s.map(a=>e.jsxs("button",{type:"button",onClick:()=>r(a.value),className:R("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t===a.value?"bg-background text-foreground shadow":"hover:bg-background/50"),children:[a.icon,a.label&&e.jsx("span",{className:"ml-2",children:a.label})]},a.value))})}function Oe(){const{theme:t,setTheme:r}=T(),s=t||"system";return e.jsx(Re,{value:s,onValueChange:n=>r(n),options:[{value:"system",icon:e.jsx(we,{className:"h-4 w-4"})},{value:"light",icon:e.jsx(Ne,{className:"h-4 w-4"})},{value:"dark",icon:e.jsx(ke,{className:"h-4 w-4"})}],className:"h-8"})}function _e(){return e.jsx(A,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs("a",{href:"https://useworkflow.dev/docs/observability",target:"_blank",rel:"noopener noreferrer",className:"gap-1",children:[e.jsx("span",{children:"Docs"}),e.jsx(be,{className:"h-4 w-4"})]})})}const We=({...t})=>{const{theme:r="system"}=T();return e.jsx(oe,{theme:r,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",error:"group-[.toaster]:bg-destructive group-[.toaster]:text-destructive-foreground group-[.toaster]:border-destructive",success:"group-[.toaster]:bg-green-600 group-[.toaster]:text-white group-[.toaster]:border-green-600"}},...t})};function Pe({className:t}={}){return e.jsxs("svg",{viewBox:"0 0 1792 240",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t||"h-6 w-auto",role:"img","aria-label":"Workflow Logo",children:[e.jsx("title",{children:"Workflow Logo"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M753.933 55.627C806.249 55.627 840.685 91.718 840.685 147.345C840.685 202.971 806.249 239.062 753.933 239.062C701.286 239.062 666.851 202.971 666.851 147.345C666.851 91.7181 701.286 55.6271 753.933 55.627ZM753.933 90.0625C726.451 90.0626 710.889 111.254 710.889 147.345C710.889 183.436 726.451 204.627 753.933 204.627C781.084 204.627 796.978 183.436 796.978 147.345C796.978 111.254 781.084 90.0625 753.933 90.0625Z",className:"fill-foreground"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1445.65 55.627C1497.96 55.627 1532.4 91.718 1532.4 147.345C1532.4 202.971 1497.96 239.062 1445.65 239.062C1393 239.062 1358.56 202.971 1358.56 147.345C1358.56 91.718 1393 55.627 1445.65 55.627ZM1445.65 90.0625C1418.16 90.0625 1402.6 111.254 1402.6 147.345C1402.6 183.436 1418.16 204.627 1445.65 204.627C1472.8 204.627 1488.69 183.436 1488.69 147.345C1488.69 111.254 1472.8 90.0626 1445.65 90.0625Z",className:"fill-foreground"}),e.jsx("path",{d:"M902.473 94.0361C909.095 70.8584 922.34 59.5997 944.855 59.5996H961.079V92.3799H944.524C916.38 92.38 904.128 106.949 904.128 135.094V235.089H861.746V59.5996H901.48L902.473 94.0361Z",className:"fill-foreground"}),e.jsx("path",{d:"M1019.25 138.735L1091.11 59.5996H1143.09L1074.55 132.113L1146.4 235.089H1098.72L1046.74 157.609L1019.25 187.078V235.089H976.872V0H1019.25V138.735Z",className:"fill-foreground"}),e.jsx("path",{d:"M1263.63 32.7803H1235.82C1224.89 32.7803 1217.28 41.3893 1217.28 54.9648V59.5996H1260.98V92.3799H1217.28V235.089H1174.56V92.3799H1149.4V59.5996H1174.56V54.9648C1174.56 19.5359 1191.78 0 1230.85 0H1263.63V32.7803Z",className:"fill-foreground"}),e.jsx("path",{d:"M1322.58 189.396C1322.58 197.673 1327.22 202.309 1335.5 202.31H1348.74V235.089H1324.57C1298.08 235.089 1280.2 218.534 1280.2 191.052V0H1322.58V189.396Z",className:"fill-foreground"}),e.jsx("path",{d:"M1604.59 186.416L1641.02 59.5996H1677.77L1713.86 186.416L1749.95 59.5996H1791.34L1737.7 235.089H1694.32L1659.56 116.883L1624.79 235.089H1581.42L1527.77 59.5996H1568.83L1604.59 186.416Z",className:"fill-foreground"}),e.jsx("path",{d:"M472.173 174.847L514.895 0.671875H554.66L598.038 174.847L640.432 0.671875H685.454L623.015 234H575.692L534.942 77.5713L493.863 234H446.869L384.1 0.671875H429.122L472.173 174.847Z",className:"fill-foreground"}),e.jsx("path",{d:"M125.776 0C120.929 1.64945e-05 117 3.9291 117 8.77539V61.4248C117 66.2711 120.929 70.2002 125.776 70.2002H160.875L161.253 70.2051C169.032 70.4023 175.301 76.6734 175.495 84.4531L175.5 84.8252V143.325C175.5 148.171 179.429 152.101 184.276 152.101H219.375L219.753 152.105C227.53 152.303 233.798 158.571 233.995 166.348L234 166.726V225.225C234 230.071 237.929 234 242.776 234H295.425C300.271 234 304.2 230.071 304.2 225.225V172.575C304.2 167.729 300.271 163.8 295.425 163.8H260.25C252.334 163.76 245.905 157.43 245.705 149.553L245.7 149.176V90.6758C245.7 85.8295 241.771 81.9004 236.925 81.9004H201.825C193.874 81.9004 187.405 75.5551 187.205 67.6523L187.2 67.2754V8.77539C187.2 3.9291 183.271 1.64951e-05 178.425 0H125.776Z",className:"fill-foreground"}),e.jsx("path",{d:"M67.2755 81.9004C62.4293 81.9004 58.5002 85.8295 58.5002 90.6758V143.325C58.5004 148.171 62.4294 152.101 67.2755 152.101H102.375L102.753 152.105C110.53 152.303 116.798 158.571 116.995 166.348L117 166.726V225.225C117 230.071 120.929 234 125.776 234H178.425C183.271 234 187.2 230.071 187.2 225.225V172.575C187.2 167.729 183.271 163.8 178.425 163.8H143.25C135.334 163.76 128.905 157.43 128.705 149.553L128.7 149.176V90.6758C128.7 85.8295 124.771 81.9004 119.925 81.9004H67.2755Z",className:"fill-foreground"}),e.jsx("path",{d:"M8.77454 163.8C3.92844 163.8 0.00012207 167.729 0.00012207 172.575V225.225C0.00012207 230.071 3.92844 234 8.77454 234H61.4249C66.2712 234 70.2003 230.071 70.2003 225.225V172.575C70.2003 167.729 66.2712 163.8 61.4249 163.8H8.77454Z",className:"fill-foreground"})]})}function Ue({children:t}){return e.jsxs("html",{lang:"en",suppressHydrationWarning:!0,children:[e.jsxs("head",{children:[e.jsx("meta",{charSet:"utf-8"}),e.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),e.jsx("link",{rel:"icon",href:"/favicon.ico"}),e.jsx("title",{children:"Workflow Observability UI"}),e.jsx("meta",{name:"description",content:"Web interface for inspecting flow runs, steps, streams, and events"}),e.jsx(F,{}),e.jsx(q,{})]}),e.jsxs("body",{className:"antialiased",children:[t,e.jsx(G,{}),e.jsx(J,{})]})]})}function Ie(t){const{runId:r,stepId:s,hookId:n}=t;return s?`/run/${r}?sidebar=step&stepId=${s}`:n?`/run/${r}?sidebar=hook&hookId=${n}`:`/run/${r}`}function Ae(t){const{resource:r,id:s,runId:n}=t;switch(r){case"run":return`/run/${s}`;case"step":return n?`/run/${n}?sidebar=step&stepId=${s}`:null;case"stream":return n?`/run/${n}?sidebar=stream&streamId=${s}`:null;case"event":return n?`/run/${n}?sidebar=event&eventId=${s}`:null;case"hook":return n?`/run/${n}?sidebar=hook&hookId=${s}`:`/?sidebar=hook&hookId=${s}`;default:return null}}function Ke({children:t}){const r=ee(),[s]=te(),{setTheme:n}=T(),a=s.get("id"),i=s.get("runId"),u=s.get("stepId"),h=s.get("hookId"),o=s.get("resource"),c=s.get("theme"),d=l.useRef(!1);return l.useEffect(()=>{c&&(c==="light"||c==="dark"||c==="system")&&n(c)},[c,n]),l.useEffect(()=>{const v=window.location.pathname;if(v.startsWith("/run/")){d.current=!0;return}if(!(v!=="/"&&d.current)){if(o){if(!a)return;const m=Ae({resource:o,id:a,runId:i});m?(d.current=!0,r(m)):console.warn(`Can't deep-link to ${o} ${a}.`);return}if(i){d.current=!0,r(Ie({runId:i,stepId:u,hookId:h}));return}}},[o,a,i,u,h,r]),e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsxs(ie,{delayDuration:0,children:[e.jsx("div",{className:"sticky top-0 z-50 bg-background border-b px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(_,{to:"/",children:e.jsx("h1",{className:"flex items-center gap-2",title:"Workflow Observability",children:e.jsx(Pe,{})})}),e.jsx("div",{className:"h-6 w-px bg-border","aria-hidden":"true"}),e.jsx(Ve,{})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(Me,{}),e.jsx("div",{className:"h-6 w-px bg-border","aria-hidden":"true"}),e.jsx(Oe,{}),e.jsx(_e,{})]})]})}),e.jsx("div",{className:"flex-1 px-6 pt-6",children:t})]}),e.jsx(We,{})]})}const ze=z(function({loaderData:r}){return e.jsx(ue,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,storageKey:"workflow-theme",children:e.jsx(ae,{serverConfig:r.serverConfig,children:e.jsx(Ke,{children:e.jsx(Q,{})})})})}),Be=B(function(){const r=X(),s=Y(r)&&r.status===404;return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-4xl font-bold mb-4",children:s?"404":"Error"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:s?"This page does not exist.":"Something went wrong."}),e.jsx(_,{to:"/",className:"text-primary underline",children:"Go to dashboard"})]})})});export{Be as ErrorBoundary,Ue as Layout,ze as default};
