UNPKG

miniflare

Version:

Fun, full-featured, fully-local simulator for Cloudflare Workers

1 lines • 32.4 kB
import{t as e}from"./ArrowClockwise.es-D3ltv0_F.js";import{n as t,t as n}from"./Plus.es-xLjXVsFy.js";import{a as r,c as i,d as a,f as o,i as s,l as c,n as l,o as u,p as d,r as f,s as p,t as ee,u as m}from"./types-Xf_TaJtQ.js";import{t as h}from"./Copy.es-D_-QRTV1.js";import{n as g,t as _}from"./Spinner.es-C_n6HP-q.js";import{n as te,t as v}from"./dialog-oqh8l3l3zutpibxx-5_bvLLm7.js";import{t as y}from"./dropdown-ncwhcd912vmone8k-B21iHmGo.js";import{t as ne}from"./Breadcrumbs-CEo9kTmA.js";import{An as b,Bn as re,Ct as ie,Gn as x,Hn as S,In as C,Jn as w,Kn as T,Mn as E,On as D,Ot as O,Tt as k,_t as A,i as j,jn as M,rt as N,xt as P,yt as F}from"./index-BPLH0X4i.js";var I=w(x(),1),L=new Map([[`bold`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M225.29,165.93C216.61,151,212,129.57,212,104a84,84,0,0,0-168,0c0,25.58-4.59,47-13.27,61.93A20.08,20.08,0,0,0,30.66,186,19.77,19.77,0,0,0,48,196H84.18a44,44,0,0,0,87.64,0H208a19.77,19.77,0,0,0,17.31-10A20.08,20.08,0,0,0,225.29,165.93ZM128,212a20,20,0,0,1-19.6-16h39.2A20,20,0,0,1,128,212ZM54.66,172C63.51,154,68,131.14,68,104a60,60,0,0,1,120,0c0,27.13,4.48,50,13.33,68Z`}))],[`duotone`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M208,192H48a8,8,0,0,1-6.88-12C47.71,168.6,56,139.81,56,104a72,72,0,0,1,144,0c0,35.82,8.3,64.6,14.9,76A8,8,0,0,1,208,192Z`,opacity:`0.2`}),I.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z`}))],[`fill`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216Z`}))],[`light`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M220.07,176.94C214.41,167.2,206,139.73,206,104a78,78,0,1,0-156,0c0,35.74-8.42,63.2-14.08,72.94A14,14,0,0,0,48,198H90.48a38,38,0,0,0,75,0H208a14,14,0,0,0,12.06-21.06ZM128,218a26,26,0,0,1-25.29-20h50.58A26,26,0,0,1,128,218Zm81.71-33a1.9,1.9,0,0,1-1.7,1H48a1.9,1.9,0,0,1-1.7-1,2,2,0,0,1,0-2C53.87,170,62,139.69,62,104a66,66,0,1,1,132,0c0,35.68,8.14,65.95,15.71,79A2,2,0,0,1,209.71,185Z`}))],[`regular`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M221.8,175.94C216.25,166.38,208,139.33,208,104a80,80,0,1,0-160,0c0,35.34-8.26,62.38-13.81,71.94A16,16,0,0,0,48,200H88.81a40,40,0,0,0,78.38,0H208a16,16,0,0,0,13.8-24.06ZM128,216a24,24,0,0,1-22.62-16h45.24A24,24,0,0,1,128,216ZM48,184c7.7-13.24,16-43.92,16-80a64,64,0,1,1,128,0c0,36.05,8.28,66.73,16,80Z`}))],[`thin`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M218.35,178C212.58,168,204,140.13,204,104a76,76,0,1,0-152,0c0,36.13-8.59,64-14.36,73.95A12,12,0,0,0,48,196H92.23a36,36,0,0,0,71.54,0H208A12,12,0,0,0,218.35,178ZM128,220a28,28,0,0,1-27.71-24h55.42A28,28,0,0,1,128,220Zm83.45-34a3.91,3.91,0,0,1-3.44,2H48a3.91,3.91,0,0,1-3.44-2,4,4,0,0,1,0-4C52,169.17,60,139.32,60,104a68,68,0,1,1,136,0c0,35.31,8,65.17,15.44,78A4,4,0,0,1,211.45,186Z`}))]]),R=new Map([[`bold`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M71.68,97.22,34.74,128l36.94,30.78a12,12,0,1,1-15.36,18.44l-48-40a12,12,0,0,1,0-18.44l48-40A12,12,0,0,1,71.68,97.22Zm176,21.56-48-40a12,12,0,1,0-15.36,18.44L221.26,128l-36.94,30.78a12,12,0,1,0,15.36,18.44l48-40a12,12,0,0,0,0-18.44ZM164.1,28.72a12,12,0,0,0-15.38,7.18l-64,176a12,12,0,0,0,7.18,15.37A11.79,11.79,0,0,0,96,228a12,12,0,0,0,11.28-7.9l64-176A12,12,0,0,0,164.1,28.72Z`}))],[`duotone`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M240,128l-48,40H64L16,128,64,88H192Z`,opacity:`0.2`}),I.createElement(`path`,{d:`M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z`}))],[`fill`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM92.8,145.6a8,8,0,1,1-9.6,12.8l-32-24a8,8,0,0,1,0-12.8l32-24a8,8,0,0,1,9.6,12.8L69.33,128Zm58.89-71.4-32,112a8,8,0,1,1-15.38-4.4l32-112a8,8,0,0,1,15.38,4.4Zm53.11,60.2-32,24a8,8,0,0,1-9.6-12.8L186.67,128,163.2,110.4a8,8,0,1,1,9.6-12.8l32,24a8,8,0,0,1,0,12.8Z`}))],[`light`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M67.84,92.61,25.37,128l42.47,35.39a6,6,0,1,1-7.68,9.22l-48-40a6,6,0,0,1,0-9.22l48-40a6,6,0,0,1,7.68,9.22Zm176,30.78-48-40a6,6,0,1,0-7.68,9.22L230.63,128l-42.47,35.39a6,6,0,1,0,7.68,9.22l48-40a6,6,0,0,0,0-9.22Zm-81.79-89A6,6,0,0,0,154.36,38l-64,176A6,6,0,0,0,94,221.64a6.15,6.15,0,0,0,2,.36,6,6,0,0,0,5.64-3.95l64-176A6,6,0,0,0,162.05,34.36Z`}))],[`regular`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M69.12,94.15,28.5,128l40.62,33.85a8,8,0,1,1-10.24,12.29l-48-40a8,8,0,0,1,0-12.29l48-40a8,8,0,0,1,10.24,12.3Zm176,27.7-48-40a8,8,0,1,0-10.24,12.3L227.5,128l-40.62,33.85a8,8,0,1,0,10.24,12.29l48-40a8,8,0,0,0,0-12.29ZM162.73,32.48a8,8,0,0,0-10.25,4.79l-64,176a8,8,0,0,0,4.79,10.26A8.14,8.14,0,0,0,96,224a8,8,0,0,0,7.52-5.27l64-176A8,8,0,0,0,162.73,32.48Z`}))],[`thin`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M66.56,91.07,22.25,128l44.31,36.93A4,4,0,0,1,64,172a3.94,3.94,0,0,1-2.56-.93l-48-40a4,4,0,0,1,0-6.14l48-40a4,4,0,0,1,5.12,6.14Zm176,33.86-48-40a4,4,0,1,0-5.12,6.14L233.75,128l-44.31,36.93a4,4,0,1,0,5.12,6.14l48-40a4,4,0,0,0,0-6.14ZM161.37,36.24a4,4,0,0,0-5.13,2.39l-64,176a4,4,0,0,0,2.39,5.13A4.12,4.12,0,0,0,96,220a4,4,0,0,0,3.76-2.63l64-176A4,4,0,0,0,161.37,36.24Z`}))]]),z=new Map([[`bold`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M76,64A12,12,0,0,1,88,52H216a12,12,0,0,1,0,24H88A12,12,0,0,1,76,64Zm140,52H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24Zm0,64H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24ZM44,112a16,16,0,1,0,16,16A16,16,0,0,0,44,112Zm0-64A16,16,0,1,0,60,64,16,16,0,0,0,44,48Zm0,128a16,16,0,1,0,16,16A16,16,0,0,0,44,176Z`}))],[`duotone`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M216,64V192H88V64Z`,opacity:`0.2`}),I.createElement(`path`,{d:`M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,1,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,1,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z`}))],[`fill`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM68,188a12,12,0,1,1,12-12A12,12,0,0,1,68,188Zm0-48a12,12,0,1,1,12-12A12,12,0,0,1,68,140Zm0-48A12,12,0,1,1,80,80,12,12,0,0,1,68,92Zm124,92H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Zm0-48H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Zm0-48H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Z`}))],[`light`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M82,64a6,6,0,0,1,6-6H216a6,6,0,0,1,0,12H88A6,6,0,0,1,82,64Zm134,58H88a6,6,0,0,0,0,12H216a6,6,0,0,0,0-12Zm0,64H88a6,6,0,0,0,0,12H216a6,6,0,0,0,0-12ZM44,54A10,10,0,1,0,54,64,10,10,0,0,0,44,54Zm0,128a10,10,0,1,0,10,10A10,10,0,0,0,44,182Zm0-64a10,10,0,1,0,10,10A10,10,0,0,0,44,118Z`}))],[`regular`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z`}))],[`thin`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M84,64a4,4,0,0,1,4-4H216a4,4,0,0,1,0,8H88A4,4,0,0,1,84,64Zm132,60H88a4,4,0,0,0,0,8H216a4,4,0,0,0,0-8Zm0,64H88a4,4,0,0,0,0,8H216a4,4,0,0,0,0-8ZM44,120a8,8,0,1,0,8,8A8,8,0,0,0,44,120Zm0-64a8,8,0,1,0,8,8A8,8,0,0,0,44,56Zm0,128a8,8,0,1,0,8,8A8,8,0,0,0,44,184Z`}))]]),B=I.forwardRef((e,t)=>I.createElement(C,{ref:t,...e,weights:L}));B.displayName=`BellIcon`;var V=I.forwardRef((e,t)=>I.createElement(C,{ref:t,...e,weights:R}));V.displayName=`CodeIcon`;var H=I.forwardRef((e,t)=>I.createElement(C,{ref:t,...e,weights:z}));H.displayName=`ListBulletsIcon`;var U=T();function W({text:e,label:t=`Copy`}){let[n,r]=(0,I.useState)(!1);function i(){navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})}return(0,U.jsx)(`button`,{className:`inline-flex size-7 cursor-pointer items-center justify-center rounded-md text-kumo-subtle transition-colors hover:bg-kumo-fill`,onClick:i,title:t,children:n?(0,U.jsx)(E,{size:14,className:`text-kumo-success`}):(0,U.jsx)(h,{size:14})})}function G({content:e}){return(0,U.jsx)(`pre`,{className:`max-h-64 overflow-y-auto px-4 py-3 font-mono text-xs wrap-break-word whitespace-pre-wrap text-kumo-default`,children:e})}function ae({status:e}){switch(e){case`complete`:return(0,U.jsx)(O,{content:`Complete`,children:(0,U.jsx)(d,{size:20,weight:`fill`,className:`text-kumo-link`})});case`errored`:return(0,U.jsx)(O,{content:`Errored`,children:(0,U.jsx)(i,{size:20,weight:`fill`,className:`text-kumo-danger`})});case`terminated`:return(0,U.jsx)(O,{content:`Terminated`,children:(0,U.jsx)(c,{size:20,weight:`fill`,className:`text-kumo-subtle`})});case`paused`:case`waitingForPause`:return(0,U.jsx)(O,{content:`Paused`,children:(0,U.jsx)(m,{size:20,weight:`fill`,className:`text-kumo-subtle`})});case`running`:return(0,U.jsx)(O,{content:`Running`,children:(0,U.jsx)(D,{size:20})});case`waiting`:return(0,U.jsx)(O,{content:`Waiting`,children:(0,U.jsx)(_,{size:20,weight:`bold`,className:`text-kumo-subtle`})});default:return(0,U.jsx)(O,{content:e,children:(0,U.jsx)(o,{size:20,weight:`bold`,className:`text-kumo-subtle`})})}}function K(e){try{let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}catch{return e}}function q(e){try{return new Date(e).toLocaleString(`en-US`,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!0,timeZoneName:`short`})}catch{return e}}function J({value:e}){if(!e)return(0,U.jsx)(`span`,{className:`text-sm text-kumo-subtle`,children:`—`});let t=K(e),n=q(e),r=p(e);return(0,U.jsx)(O,{content:(0,U.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,U.jsx)(`div`,{children:n}),(0,U.jsx)(`div`,{className:`text-kumo-subtle`,children:r})]}),children:(0,U.jsx)(`span`,{className:`text-sm whitespace-nowrap text-kumo-subtle`,children:t})})}function Y({success:e,finished:t,hasError:n,subtle:r}){return e===!1||n?r?(0,U.jsx)(`div`,{className:`flex size-5 items-center justify-center rounded bg-kumo-fill`,children:(0,U.jsx)(`span`,{className:`text-xs font-bold text-kumo-default`,children:`!`})}):(0,U.jsx)(`div`,{className:`flex size-5 items-center justify-center rounded bg-kumo-badge-red`,children:(0,U.jsx)(`span`,{className:`text-xs font-bold text-white`,children:`!`})}):e===!0||t===!0?r?(0,U.jsx)(`div`,{className:`flex size-5 items-center justify-center rounded bg-kumo-fill`,children:(0,U.jsx)(E,{size:12,weight:`bold`,className:`text-white`})}):(0,U.jsx)(`div`,{className:`flex size-5 items-center justify-center rounded bg-kumo-badge-teal`,children:(0,U.jsx)(E,{size:12,weight:`bold`,className:`text-white`})}):(0,U.jsx)(`span`,{children:(0,U.jsx)(D,{size:18})})}var X={step:`bg-kumo-tint text-kumo-subtle`,sleep:`bg-kumo-overlay text-kumo-subtle`,waitForEvent:`bg-kumo-badge-purple/10 text-kumo-badge-purple`};function oe(e){return`${e.type}-${e.name}`}function Z(e){return(e??`Unknown step`).replace(/-\d+$/,``)}var se=(0,I.memo)(function({step:t,isExpanded:i,onToggleExpanded:a,onRestartFromStep:o}){let s=t.type===`step`||t.type===`waitForEvent`&&(t.error||t.output!=null||t.finished);return(0,U.jsxs)(`div`,{className:`border-b border-kumo-fill p-1 last:border-b-0`,children:[(0,U.jsxs)(`div`,{className:`grid h-10 grid-cols-[20px_1fr_160px_160px_80px_28px_24px] items-center gap-3 rounded-lg px-2 transition-colors ${s?`cursor-pointer hover:bg-kumo-fill`:``}`,onClick:s?a:void 0,children:[(0,U.jsx)(Y,{success:t.success,finished:t.finished,hasError:!!t.error}),(0,U.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[t.type&&t.type!==`step`&&(0,U.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 text-sm ${X[t.type]??X.step}`,children:t.type===`waitForEvent`?`wait for event`:t.type}),(0,U.jsx)(`span`,{className:`truncate text-sm text-kumo-default`,children:Z(t.name)})]}),(0,U.jsx)(J,{value:t.start}),(0,U.jsx)(J,{value:t.end}),(0,U.jsx)(`span`,{className:`text-sm text-kumo-subtle`,children:r(t.start,t.end)}),(0,U.jsx)(`div`,{className:`flex items-center justify-center`,children:o&&(0,U.jsx)(O,{content:`Restart from this step`,asChild:!0,children:(0,U.jsx)(`button`,{"aria-label":`Restart from this step`,className:`inline-flex size-7 cursor-pointer items-center justify-center rounded-md border border-kumo-fill bg-kumo-base text-kumo-default transition-colors hover:bg-kumo-fill disabled:cursor-not-allowed disabled:opacity-40`,onClick:e=>{e.stopPropagation(),o(t)},type:`button`,children:(0,U.jsx)(e,{size:14})})})}),(0,U.jsx)(`div`,{className:`flex items-center justify-center`,children:s?(0,U.jsx)(n,{size:14,className:`text-kumo-subtle transition-transform ${i?`rotate-45`:``}`}):(0,U.jsx)(`div`,{className:`w-6`})})]}),i&&s&&(0,U.jsxs)(`div`,{className:`-mx-1 -mb-1`,children:[(0,U.jsx)(`div`,{className:`mt-1 h-2 rounded-t-lg border-t border-kumo-fill`}),(0,U.jsxs)(`div`,{className:`px-4 pt-3 pb-4`,children:[t.type===`step`&&(0,U.jsx)(ce,{step:t}),t.type===`waitForEvent`&&(0,U.jsx)(le,{step:t})]})]})]})});function Q({label:e,content:t}){return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h5`,{className:`mb-2 text-sm font-medium text-kumo-default`,children:e}),(0,U.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-kumo-fill bg-kumo-base`,children:[(0,U.jsx)(G,{content:t}),(0,U.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,U.jsx)(W,{text:t,label:`Copy ${e.toLowerCase()}`})})]})]})}function ce({step:e}){let t=e.success===!1&&e.attempts?[...e.attempts].reverse().find(e=>e.error):null,n=t?.error?`${t.error.name}: ${t.error.message}`:null,i=e.success===!0&&e.output!==void 0?u(e.output):null,a=n?`Error`:`Output`,o=n??i??`N/A`,s=e.config?u(e.config):null;return(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsxs)(`div`,{className:s?`grid grid-cols-1 gap-4 md:grid-cols-2`:``,children:[(0,U.jsx)(Q,{label:a,content:o}),s&&(0,U.jsx)(Q,{label:`Config`,content:s})]}),e.attempts&&e.attempts.length>0&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`hr`,{className:`mb-4 border-dashed border-kumo-fill`}),(0,U.jsx)(`h5`,{className:`mb-2 text-sm font-medium text-kumo-default`,children:`Attempts`}),(0,U.jsx)(`div`,{children:[...e.attempts].reverse().map((e,t,n)=>{let i=n.length-t,a=n[t+1],o=a&&a.end&&e.start?new Date(e.start).getTime()-new Date(a.end).getTime():null,s=t===n.length-1;return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`rounded-md bg-kumo-base py-2 pr-3 text-sm`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 pt-0.5`,children:[(0,U.jsxs)(`span`,{className:`font-mono text-kumo-subtle`,children:[`#`,i]}),(0,U.jsx)(Y,{success:e.success,subtle:!0})]}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.error?(0,U.jsx)(`span`,{className:`font-medium text-kumo-default`,children:e.error.name}):e.success?(0,U.jsx)(`span`,{className:`text-kumo-subtle`,children:`Success`}):(0,U.jsx)(`span`,{className:`text-kumo-subtle`,children:`Running`}),(0,U.jsx)(`span`,{className:`flex-1 border-t border-dashed border-kumo-fill`}),(0,U.jsx)(`span`,{className:`shrink-0 text-kumo-subtle`,children:r(e.start,e.end)})]}),e.error?.message&&(0,U.jsx)(`p`,{className:`mt-1 text-xs text-kumo-subtle`,children:e.error.message})]})]})}),!s&&o!==null&&o>0&&(0,U.jsxs)(`div`,{className:`flex items-center py-1 pl-7`,children:[(0,U.jsx)(`div`,{className:`flex h-10 w-5 items-center justify-center`,children:(0,U.jsx)(`div`,{className:`h-full border-l border-dashed border-kumo-fill`})}),(0,U.jsx)(`span`,{className:`ml-2 text-sm text-kumo-subtle`,children:r(a?.end,e.start)})]})]},t)})})]})]})}function le({step:e}){let t=e.finished&&!e.error,n=!!e.error;return(0,U.jsxs)(`div`,{className:t&&n?`grid grid-cols-1 gap-4 md:grid-cols-2`:`space-y-4`,children:[t&&(0,U.jsx)(Q,{label:`Event Payload`,content:u(e.output)}),n&&(0,U.jsx)(Q,{label:e.error?.name??`Error`,content:e.error?.message??`Unknown error`})]})}var ue={pause:m,resume:g,terminate:c,restart:e},de=(0,I.memo)(function({status:e,stepCount:t,start:n,end:i}){return(0,U.jsxs)(`div`,{className:`grid grid-cols-1 overflow-hidden rounded-lg border border-kumo-fill bg-kumo-base md:grid-cols-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 md:px-5`,children:[(0,U.jsx)(`span`,{className:`text-sm text-kumo-subtle md:text-base`,children:`Status`}),(0,U.jsx)(s,{status:e})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-t border-kumo-fill px-3 py-2 md:border-t-0 md:border-l md:px-5`,children:[(0,U.jsx)(`span`,{className:`text-sm text-kumo-subtle md:text-base`,children:`Steps Completed`}),(0,U.jsx)(`span`,{className:`text-sm font-medium text-kumo-default md:text-base`,children:t})]}),(0,U.jsxs)(`div`,{className:`flex items-center justify-between border-t border-kumo-fill px-3 py-2 md:border-t-0 md:border-l md:px-5`,children:[(0,U.jsx)(`span`,{className:`text-sm text-kumo-subtle md:text-base`,children:`Duration`}),(0,U.jsx)(`span`,{className:`text-sm font-medium text-kumo-default md:text-base`,children:r(n,i)})]})]})}),fe=(0,I.memo)(function({params:e,output:t}){return(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-kumo-fill bg-kumo-tint`,children:[(0,U.jsxs)(`div`,{className:`hidden md:grid md:grid-cols-2 md:divide-x md:divide-kumo-fill`,children:[(0,U.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,U.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:`Input params`})}),(0,U.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,U.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:`Output`})})]}),(0,U.jsx)(`div`,{className:`hidden rounded-t-lg border-t border-kumo-fill bg-kumo-base md:block`,children:(0,U.jsxs)(`div`,{className:`grid grid-cols-2 divide-x divide-kumo-fill`,children:[(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(G,{content:u(e)}),(0,U.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,U.jsx)(W,{text:u(e),label:`Copy params`})})]}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(G,{content:u(t)}),(0,U.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,U.jsx)(W,{text:u(t),label:`Copy output`})})]})]})}),(0,U.jsxs)(`div`,{className:`md:hidden`,children:[(0,U.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,U.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:`Input params`})}),(0,U.jsx)(`div`,{className:`rounded-t-lg border-t border-kumo-fill bg-kumo-base`,children:(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(G,{content:u(e)}),(0,U.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,U.jsx)(W,{text:u(e),label:`Copy params`})})]})}),(0,U.jsx)(`div`,{className:`border-t border-kumo-fill px-4 py-2.5`,children:(0,U.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:`Output`})}),(0,U.jsx)(`div`,{className:`border-t border-kumo-fill bg-kumo-base`,children:(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(G,{content:u(t)}),(0,U.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,U.jsx)(W,{text:u(t),label:`Copy output`})})]})})]})]})}),pe=(0,I.memo)(function({error:e}){return(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-kumo-fill bg-kumo-tint`,children:[(0,U.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,U.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:e.name??`Error`})}),(0,U.jsxs)(`div`,{className:`relative rounded-t-lg border-t border-kumo-fill bg-kumo-base`,children:[(0,U.jsx)(`pre`,{className:`max-h-64 overflow-y-auto px-4 py-3 font-mono text-sm wrap-break-word whitespace-pre-wrap text-kumo-subtle`,children:e.message??`Unknown error`}),(0,U.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,U.jsx)(W,{text:`${e.name??`Error`}: ${e.message??``}`,label:`Copy error`})})]})]})}),$=[{value:`all`,label:`All`,icon:H},{value:`step`,label:`Do`,icon:V},{value:`sleep`,label:`Sleep`,icon:b},{value:`waitForEvent`,label:`Wait for Event`,icon:B}],me=(0,I.memo)(function({steps:e,onRestartFromStep:n}){let r=e??[],[i,a]=(0,I.useState)(``),[o,s]=(0,I.useState)(`all`),[c,l]=(0,I.useState)(()=>new Set),u=(0,I.useCallback)(e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),d=[...r].reverse().filter(e=>{if(o!==`all`&&e.type!==o)return!1;if(i.trim()){let t=i.trim().toLowerCase();return Z(e.name).toLowerCase().includes(t)}return!0}),f=$.find(e=>e.value===o)??$[0],p=f.icon;return(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`mb-3`,children:(0,U.jsx)(`h4`,{className:`text-lg font-semibold text-kumo-default`,children:`Step History`})}),r.length>0&&(0,U.jsxs)(`div`,{className:`mb-3 flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,U.jsxs)(`div`,{className:`relative flex-1`,children:[(0,U.jsx)(M,{size:14,className:`absolute top-1/2 left-3 -translate-y-1/2 text-kumo-subtle`}),(0,U.jsx)(`input`,{className:`focus-visible:ring-kumo-ring h-9 w-full rounded-lg border border-kumo-fill bg-kumo-base pr-3 pl-9 text-sm text-kumo-default placeholder:text-kumo-subtle focus:border-kumo-brand focus:outline-none focus-visible:ring-2`,onChange:e=>a(e.target.value),placeholder:`Search steps...`,type:`text`,value:i})]}),(0,U.jsxs)(y,{children:[(0,U.jsx)(y.Trigger,{render:(0,U.jsxs)(`button`,{className:`inline-flex h-9 w-full cursor-pointer items-center justify-between rounded-lg border border-kumo-fill bg-kumo-base px-3 text-sm text-kumo-default transition-colors hover:bg-kumo-fill sm:w-44`,children:[(0,U.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(p,{size:14,className:`text-kumo-subtle`}),f.label]}),(0,U.jsx)(t,{size:14,className:`text-kumo-subtle`})]})}),(0,U.jsx)(y.Content,{align:`end`,className:`w-44 bg-kumo-base`,side:`bottom`,children:$.map(({value:e,label:t,icon:n})=>(0,U.jsxs)(y.Item,{className:`flex cursor-pointer items-center gap-2 rounded-md transition-colors hover:bg-kumo-fill`,onClick:()=>s(e),children:[(0,U.jsx)(n,{size:14,className:`text-kumo-subtle`}),t]},e))})]})]}),(0,U.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-kumo-fill bg-kumo-base`,children:(0,U.jsx)(`div`,{className:`min-w-150`,children:r.length===0?(0,U.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-kumo-subtle`,children:`No steps recorded yet`}):d.length===0?(0,U.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-kumo-subtle`,children:`No steps match your search`}):d.map(e=>{let t=oe(e);return(0,U.jsx)(se,{step:e,isExpanded:c.has(t),onToggleExpanded:()=>u(t),onRestartFromStep:n},t)})})})]})});function he(){let e=j.useParams(),t=j.useLoaderData(),n=S(),[r,i]=(0,I.useState)(t.details),[o,s]=(0,I.useState)(null),[c,u]=(0,I.useState)(!1),[d,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(null),[y,b]=(0,I.useState)(!1),[x,C]=(0,I.useState)(``),[w,T]=(0,I.useState)(``),[E,D]=(0,I.useState)(!1),[M,L]=(0,I.useState)(null),[R,z]=(0,I.useState)(!1),B=(0,I.useRef)(JSON.stringify(t.details));(0,I.useEffect)(()=>{let e=JSON.stringify(t.details);e!==B.current&&(B.current=e,i(t.details))},[t]);let V=r.status??`unknown`,H=e.instanceId,W=r.steps??[],G=ee(V),K=(0,I.useCallback)(async()=>{try{let t=(await P({path:{instance_id:H,workflow_name:e.workflowName}})).data?.result;if(t){let e=JSON.stringify(t);e!==B.current&&(B.current=e,i(t))}}catch{}},[H,e.workflowName]),q=f(V);(0,I.useEffect)(()=>{if(q)return;let e=!0;async function t(){for(;e&&(await new Promise(e=>setTimeout(e,1e3)),e);)await K()}return t(),()=>{e=!1}},[K,q]);let J=(0,I.useCallback)(async t=>{s(t),_(null);try{await A({path:{workflow_name:e.workflowName,instance_id:H},body:{action:t}}),await K()}catch(e){_(e instanceof Error?e.message:`Failed to ${t}`)}finally{s(null)}},[e.workflowName,H,K]),Y=(0,I.useCallback)(e=>{L(e)},[]),X=(0,I.useCallback)(async()=>{if(M){z(!0),_(null);try{await A({path:{workflow_name:e.workflowName,instance_id:H},body:{action:`restart`,from:l(M)}}),await K()}catch(e){_(e instanceof Error?e.message:`Failed to restart from step`)}finally{L(null),z(!1)}}},[M,e.workflowName,H,K]);return(0,U.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,U.jsx)(ne,{icon:N,items:[(0,U.jsx)(re,{className:`flex items-center gap-1.5`,params:{workflowName:e.workflowName},to:`/workflows/$workflowName`,children:e.workflowName},`wf`),(0,U.jsx)(`span`,{className:`flex items-center gap-1.5 font-mono text-xs`,children:H},`id`)],title:`Workflows`}),(0,U.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[(0,U.jsx)(`div`,{className:`px-4 pt-6 sm:px-6 lg:px-12 xl:px-20 2xl:px-32`,children:(0,U.jsx)(`div`,{children:(0,U.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2 pb-6 sm:gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 sm:gap-3`,children:[(0,U.jsx)(`h1`,{className:`shrink-0 text-xl font-semibold text-kumo-default sm:text-2xl`,children:e.workflowName}),(0,U.jsx)(O,{content:c?`Copied!`:`Copy instance ID`,asChild:!0,children:(0,U.jsxs)(`button`,{className:`min-w-0 cursor-pointer truncate font-mono text-base transition-colors sm:text-2xl ${c?`text-kumo-default`:`text-kumo-subtle hover:text-kumo-default`}`,onClick:()=>{navigator.clipboard.writeText(H),u(!0),setTimeout(()=>u(!1),1e3)},children:[`#`,H]})}),(0,U.jsx)(ae,{status:V})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 sm:gap-2`,children:[G.map(e=>{let t=ue[e];return(0,U.jsxs)(`button`,{className:`inline-flex h-9 cursor-pointer items-center gap-1.5 rounded-lg border px-3 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-40 ${e===`terminate`?`border-kumo-fill bg-kumo-base text-kumo-danger hover:bg-kumo-badge-red/10`:`border-kumo-fill bg-kumo-base text-kumo-default hover:bg-kumo-fill`}`,disabled:o!==null,onClick:()=>void J(e),children:[(0,U.jsx)(t,{size:14,weight:e===`restart`?`regular`:`fill`,className:o===e?`animate-spin`:``}),e.charAt(0).toUpperCase()+e.slice(1)]},e)}),V!==`complete`&&V!==`errored`&&V!==`terminated`&&(0,U.jsx)(`button`,{className:`inline-flex size-9 cursor-pointer items-center justify-center rounded-lg border border-kumo-fill bg-kumo-base text-kumo-default transition-colors hover:bg-kumo-fill disabled:cursor-not-allowed disabled:opacity-40`,disabled:o!==null,onClick:()=>b(!0),title:`Send Event`,children:(0,U.jsx)(a,{size:14})}),(0,U.jsx)(`button`,{className:`inline-flex size-9 cursor-pointer items-center justify-center rounded-lg border border-kumo-fill bg-kumo-base text-kumo-danger transition-colors hover:bg-kumo-badge-red/10 disabled:cursor-not-allowed disabled:opacity-40`,disabled:o!==null,onClick:()=>p(!0),title:`Delete`,children:(0,U.jsx)(te,{size:14})})]})]})})}),(0,U.jsxs)(`div`,{className:`relative`,children:[(0,U.jsx)(`hr`,{className:`absolute top-1/2 w-full border-kumo-fill`}),(0,U.jsx)(`div`,{className:`relative px-4 sm:px-6 lg:px-12 xl:px-20 2xl:px-32`,children:(0,U.jsx)(de,{status:V,stepCount:W.length,start:r.start,end:r.end})})]}),(0,U.jsx)(v.Root,{open:d,onOpenChange:p,children:(0,U.jsxs)(v,{size:`lg`,className:`w-lg`,children:[(0,U.jsx)(`div`,{className:`border-b border-kumo-fill px-6 py-4`,children:(0,U.jsx)(v.Title,{className:`text-lg font-semibold text-kumo-default`,children:`Delete this instance?`})}),(0,U.jsxs)(`div`,{className:`px-6 py-5`,children:[(0,U.jsx)(`p`,{className:`text-sm text-kumo-subtle`,children:`This will permanently delete the instance and its persistence data. This action cannot be undone.`}),(0,U.jsxs)(`div`,{className:`mt-3 rounded-lg border border-kumo-fill bg-kumo-elevated px-4 py-3`,children:[(0,U.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:`Instance ID`}),(0,U.jsx)(`p`,{className:`mt-0.5 font-mono text-sm text-kumo-default`,children:H})]})]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-kumo-fill px-6 py-4`,children:[(0,U.jsx)(k,{variant:`secondary`,onClick:()=>p(!1),disabled:m,children:`Cancel`}),(0,U.jsx)(k,{variant:`destructive`,disabled:m,loading:m,onClick:()=>{h(!0),F({path:{workflow_name:e.workflowName,instance_id:H}}).then(()=>{p(!1),n({to:`/workflows/$workflowName`,params:{workflowName:e.workflowName},search:e=>e})}).finally(()=>h(!1))},children:`Delete Instance`})]})]})}),(0,U.jsx)(v.Root,{open:y,onOpenChange:e=>{b(e),e||(C(``),T(``))},children:(0,U.jsxs)(v,{size:`lg`,className:`w-lg`,children:[(0,U.jsx)(`div`,{className:`border-b border-kumo-fill px-6 py-4`,children:(0,U.jsx)(v.Title,{className:`text-lg font-semibold text-kumo-default`,children:`Send Event`})}),(0,U.jsxs)(`div`,{className:`space-y-4 px-6 py-5`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-kumo-default`,children:`Event Type`}),(0,U.jsx)(`input`,{className:`focus-visible:ring-kumo-ring w-full rounded-lg border border-kumo-fill bg-kumo-base px-3 py-2.5 text-sm text-kumo-default placeholder:text-kumo-subtle focus:border-kumo-brand focus:outline-none focus-visible:ring-2`,onChange:e=>C(e.target.value),placeholder:`my-event`,type:`text`,value:x})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`label`,{className:`mb-2 block text-sm font-medium text-kumo-default`,children:[`Payload`,` `,(0,U.jsx)(`span`,{className:`font-normal text-kumo-subtle`,children:`(optional)`})]}),(0,U.jsx)(`textarea`,{className:`focus-visible:ring-kumo-ring w-full resize-y rounded-lg border border-kumo-fill bg-kumo-base px-3 py-2.5 font-mono text-sm text-kumo-default placeholder:text-kumo-subtle focus:border-kumo-brand focus:outline-none focus-visible:ring-2`,onChange:e=>T(e.target.value),placeholder:`{"key": "value"}`,rows:4,value:w})]})]}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-kumo-fill px-6 py-4`,children:[(0,U.jsx)(k,{variant:`secondary`,onClick:()=>b(!1),disabled:E,children:`Cancel`}),(0,U.jsx)(k,{variant:`primary`,disabled:!x.trim()||E,loading:E,onClick:()=>{let t;if(w.trim())try{t=JSON.parse(w)}catch{return}D(!0),ie({path:{workflow_name:e.workflowName,instance_id:H,event_type:x.trim()},body:t}).then(()=>{b(!1),C(``),T(``),K()}).finally(()=>D(!1))},children:`Send`})]})]})}),(0,U.jsx)(v.Root,{open:M!==null,onOpenChange:e=>{!e&&!R&&L(null)},children:(0,U.jsxs)(v,{size:`lg`,className:`w-lg`,children:[(0,U.jsx)(`div`,{className:`border-b border-kumo-fill px-6 py-4`,children:(0,U.jsx)(v.Title,{className:`text-lg font-semibold text-kumo-default`,children:`Restart from this step?`})}),(0,U.jsx)(`div`,{className:`px-6 py-5`,children:(0,U.jsxs)(`p`,{className:`text-sm text-kumo-subtle`,children:[`This will rerun the instance from`,` `,(0,U.jsx)(`span`,{className:`font-medium text-kumo-default`,children:Z(M?.name)}),`. Saved state for this step and later steps will be cleared, while earlier completed steps are kept.`]})}),(0,U.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-kumo-fill px-6 py-4`,children:[(0,U.jsx)(k,{variant:`secondary`,onClick:()=>L(null),disabled:R,children:`Cancel`}),(0,U.jsx)(k,{variant:`primary`,disabled:R,loading:R,onClick:()=>void X(),children:`Restart from step`})]})]})}),(0,U.jsxs)(`div`,{className:`space-y-6 px-4 py-6 sm:space-y-8 sm:px-6 lg:px-12 xl:px-20 2xl:px-32`,children:[g&&(0,U.jsx)(`div`,{className:`rounded-lg border border-kumo-danger/20 bg-kumo-danger/8 p-4 text-sm text-kumo-danger`,children:g}),(0,U.jsx)(fe,{params:r.params,output:r.output}),r.error&&(0,U.jsx)(pe,{error:r.error}),(0,U.jsx)(me,{steps:r.steps,onRestartFromStep:Y})]})]})]})}export{he as component};