UNPKG

miniflare

Version:

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

1 lines • 30.2 kB
import{c as e,s as t,z as n}from"./useRouterState-DkU0JPAO.js";import{Bt as r,Ht as i,Rt as a,r as o,s}from"./button-cdxnqcgzwko8ooha-DW4HgSd6.js";import{t as c}from"./ArrowClockwise.es-Cy5-iE5C.js";import{t as l}from"./CaretDown.es-Bia_8FMa.js";import{a as u,c as d,d as f,f as p,i as m,l as h,n as g,o as _,p as v,r as ee,s as y,t as te,u as b}from"./types-DtYWWlE_.js";import{t as x}from"./Copy.es-Bz99FhyZ.js";import{t as S}from"./ListBullets.es-CjgHN86n.js";import{n as C,t as w}from"./Spinner.es-CSKgxcOR.js";import{t as T}from"./Plus.es-BJdTPWhL.js";import{n as ne,t as E}from"./dialog-oqh8l3l3zutpibxx-6QAIfPjB.js";import{t as D}from"./dropdown-ncwhcd912vmone8k-BMBcB-5m.js";import{t as O}from"./Breadcrumbs-D11-yw8F.js";import{Ct as k,Dt as re,Mt as A,Nt as j,Rt as ie,Tt as ae,at as oe,i as M,jt as N,xt as P}from"./index-CkemaNd1.js";var F=n(t(),1),I=new Map([[`bold`,F.createElement(F.Fragment,null,F.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`,F.createElement(F.Fragment,null,F.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`}),F.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`,F.createElement(F.Fragment,null,F.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`,F.createElement(F.Fragment,null,F.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`,F.createElement(F.Fragment,null,F.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`,F.createElement(F.Fragment,null,F.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`}))]]),L=new Map([[`bold`,F.createElement(F.Fragment,null,F.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`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M240,128l-48,40H64L16,128,64,88H192Z`,opacity:`0.2`}),F.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`,F.createElement(F.Fragment,null,F.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`,F.createElement(F.Fragment,null,F.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`,F.createElement(F.Fragment,null,F.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`,F.createElement(F.Fragment,null,F.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`}))]]),R=F.forwardRef((e,t)=>F.createElement(r,{ref:t,...e,weights:I}));R.displayName=`BellIcon`;var z=F.forwardRef((e,t)=>F.createElement(r,{ref:t,...e,weights:L}));z.displayName=`CodeIcon`;var B=e();function V({text:e,label:t=`Copy`}){let[n,r]=(0,F.useState)(!1);function i(){navigator.clipboard.writeText(e).then(()=>{r(!0),setTimeout(()=>r(!1),2e3)})}return(0,B.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,B.jsx)(j,{size:14,className:`text-kumo-success`}):(0,B.jsx)(x,{size:14})})}function H({content:e}){return(0,B.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 U({status:e}){switch(e){case`complete`:return(0,B.jsx)(s,{content:`Complete`,children:(0,B.jsx)(v,{size:20,weight:`fill`,className:`text-kumo-link`})});case`errored`:return(0,B.jsx)(s,{content:`Errored`,children:(0,B.jsx)(d,{size:20,weight:`fill`,className:`text-kumo-danger`})});case`terminated`:return(0,B.jsx)(s,{content:`Terminated`,children:(0,B.jsx)(h,{size:20,weight:`fill`,className:`text-kumo-subtle`})});case`paused`:case`waitingForPause`:return(0,B.jsx)(s,{content:`Paused`,children:(0,B.jsx)(b,{size:20,weight:`fill`,className:`text-kumo-subtle`})});case`running`:return(0,B.jsx)(s,{content:`Running`,children:(0,B.jsx)(a,{size:20})});case`waiting`:return(0,B.jsx)(s,{content:`Waiting`,children:(0,B.jsx)(w,{size:20,weight:`bold`,className:`text-kumo-subtle`})});default:return(0,B.jsx)(s,{content:e,children:(0,B.jsx)(p,{size:20,weight:`bold`,className:`text-kumo-subtle`})})}}function W(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 G(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 K({value:e}){if(!e)return(0,B.jsx)(`span`,{className:`text-sm text-kumo-subtle`,children:`—`});let t=W(e),n=G(e),r=y(e);return(0,B.jsx)(s,{content:(0,B.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,B.jsx)(`div`,{children:n}),(0,B.jsx)(`div`,{className:`text-kumo-subtle`,children:r})]}),children:(0,B.jsx)(`span`,{className:`text-sm whitespace-nowrap text-kumo-subtle`,children:t})})}function q({success:e,finished:t,hasError:n,subtle:r}){return e===!1||n?r?(0,B.jsx)(`div`,{className:`flex size-5 items-center justify-center rounded bg-kumo-fill`,children:(0,B.jsx)(`span`,{className:`text-xs font-bold text-kumo-default`,children:`!`})}):(0,B.jsx)(`div`,{className:`flex size-5 items-center justify-center rounded bg-kumo-badge-red`,children:(0,B.jsx)(`span`,{className:`text-xs font-bold text-white`,children:`!`})}):e===!0||t===!0?r?(0,B.jsx)(`div`,{className:`flex size-5 items-center justify-center rounded bg-kumo-fill`,children:(0,B.jsx)(j,{size:12,weight:`bold`,className:`text-white`})}):(0,B.jsx)(`div`,{className:`flex size-5 items-center justify-center rounded bg-kumo-badge-teal`,children:(0,B.jsx)(j,{size:12,weight:`bold`,className:`text-white`})}):(0,B.jsx)(`span`,{children:(0,B.jsx)(a,{size:18})})}var J={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 Y(e){return`${e.type}-${e.name}`}function X(e){return(e??`Unknown step`).replace(/-\d+$/,``)}var se=(0,F.memo)(function({step:e,isExpanded:t,onToggleExpanded:n,onRestartFromStep:r}){let i=e.type===`step`||e.type===`waitForEvent`&&(e.error||e.output!=null||e.finished);return(0,B.jsxs)(`div`,{className:`border-b border-kumo-fill p-1 last:border-b-0`,children:[(0,B.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 ${i?`cursor-pointer hover:bg-kumo-fill`:``}`,onClick:i?n:void 0,children:[(0,B.jsx)(q,{success:e.success,finished:e.finished,hasError:!!e.error}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2 overflow-hidden`,children:[e.type&&e.type!==`step`&&(0,B.jsx)(`span`,{className:`shrink-0 rounded px-1.5 py-0.5 text-sm ${J[e.type]??J.step}`,children:e.type===`waitForEvent`?`wait for event`:e.type}),(0,B.jsx)(`span`,{className:`truncate text-sm text-kumo-default`,children:X(e.name)})]}),(0,B.jsx)(K,{value:e.start}),(0,B.jsx)(K,{value:e.end}),(0,B.jsx)(`span`,{className:`text-sm text-kumo-subtle`,children:u(e.start,e.end)}),(0,B.jsx)(`div`,{className:`flex items-center justify-center`,children:r&&(0,B.jsx)(s,{content:`Restart from this step`,asChild:!0,children:(0,B.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:t=>{t.stopPropagation(),r(e)},type:`button`,children:(0,B.jsx)(c,{size:14})})})}),(0,B.jsx)(`div`,{className:`flex items-center justify-center`,children:i?(0,B.jsx)(T,{size:14,className:`text-kumo-subtle transition-transform ${t?`rotate-45`:``}`}):(0,B.jsx)(`div`,{className:`w-6`})})]}),t&&i&&(0,B.jsxs)(`div`,{className:`-mx-1 -mb-1`,children:[(0,B.jsx)(`div`,{className:`mt-1 h-2 rounded-t-lg border-t border-kumo-fill`}),(0,B.jsxs)(`div`,{className:`px-4 pt-3 pb-4`,children:[e.type===`step`&&(0,B.jsx)(ce,{step:e}),e.type===`waitForEvent`&&(0,B.jsx)(le,{step:e})]})]})]})});function Z({label:e,content:t}){return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h5`,{className:`mb-2 text-sm font-medium text-kumo-default`,children:e}),(0,B.jsxs)(`div`,{className:`relative overflow-hidden rounded-lg border border-kumo-fill bg-kumo-base`,children:[(0,B.jsx)(H,{content:t}),(0,B.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,B.jsx)(V,{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,r=e.success===!0&&e.output!==void 0?_(e.output):null,i=n?`Error`:`Output`,a=n??r??`N/A`,o=e.config?_(e.config):null;return(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsxs)(`div`,{className:o?`grid grid-cols-1 gap-4 md:grid-cols-2`:``,children:[(0,B.jsx)(Z,{label:i,content:a}),o&&(0,B.jsx)(Z,{label:`Config`,content:o})]}),e.attempts&&e.attempts.length>0&&(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`hr`,{className:`mb-4 border-dashed border-kumo-fill`}),(0,B.jsx)(`h5`,{className:`mb-2 text-sm font-medium text-kumo-default`,children:`Attempts`}),(0,B.jsx)(`div`,{children:[...e.attempts].reverse().map((e,t,n)=>{let r=n.length-t,i=n[t+1],a=i&&i.end&&e.start?new Date(e.start).getTime()-new Date(i.end).getTime():null,o=t===n.length-1;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`rounded-md bg-kumo-base py-2 pr-3 text-sm`,children:(0,B.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 pt-0.5`,children:[(0,B.jsxs)(`span`,{className:`font-mono text-kumo-subtle`,children:[`#`,r]}),(0,B.jsx)(q,{success:e.success,subtle:!0})]}),(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.error?(0,B.jsx)(`span`,{className:`font-medium text-kumo-default`,children:e.error.name}):e.success?(0,B.jsx)(`span`,{className:`text-kumo-subtle`,children:`Success`}):(0,B.jsx)(`span`,{className:`text-kumo-subtle`,children:`Running`}),(0,B.jsx)(`span`,{className:`flex-1 border-t border-dashed border-kumo-fill`}),(0,B.jsx)(`span`,{className:`shrink-0 text-kumo-subtle`,children:u(e.start,e.end)})]}),e.error?.message&&(0,B.jsx)(`p`,{className:`mt-1 text-xs text-kumo-subtle`,children:e.error.message})]})]})}),!o&&a!==null&&a>0&&(0,B.jsxs)(`div`,{className:`flex items-center py-1 pl-7`,children:[(0,B.jsx)(`div`,{className:`flex h-10 w-5 items-center justify-center`,children:(0,B.jsx)(`div`,{className:`h-full border-l border-dashed border-kumo-fill`})}),(0,B.jsx)(`span`,{className:`ml-2 text-sm text-kumo-subtle`,children:u(i?.end,e.start)})]})]},t)})})]})]})}function le({step:e}){let t=e.finished&&!e.error,n=!!e.error;return(0,B.jsxs)(`div`,{className:t&&n?`grid grid-cols-1 gap-4 md:grid-cols-2`:`space-y-4`,children:[t&&(0,B.jsx)(Z,{label:`Event Payload`,content:_(e.output)}),n&&(0,B.jsx)(Z,{label:e.error?.name??`Error`,content:e.error?.message??`Unknown error`})]})}var ue={pause:b,resume:C,terminate:h,restart:c},Q=(0,F.memo)(function({status:e,stepCount:t,start:n,end:r}){return(0,B.jsxs)(`div`,{className:`grid grid-cols-1 overflow-hidden rounded-lg border border-kumo-fill bg-kumo-base md:grid-cols-3`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 md:px-5`,children:[(0,B.jsx)(`span`,{className:`text-sm text-kumo-subtle md:text-base`,children:`Status`}),(0,B.jsx)(m,{status:e})]}),(0,B.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,B.jsx)(`span`,{className:`text-sm text-kumo-subtle md:text-base`,children:`Steps Completed`}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-kumo-default md:text-base`,children:t})]}),(0,B.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,B.jsx)(`span`,{className:`text-sm text-kumo-subtle md:text-base`,children:`Duration`}),(0,B.jsx)(`span`,{className:`text-sm font-medium text-kumo-default md:text-base`,children:u(n,r)})]})]})}),de=(0,F.memo)(function({params:e,output:t}){return(0,B.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-kumo-fill bg-kumo-tint`,children:[(0,B.jsxs)(`div`,{className:`hidden md:grid md:grid-cols-2 md:divide-x md:divide-kumo-fill`,children:[(0,B.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,B.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:`Input params`})}),(0,B.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,B.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:`Output`})})]}),(0,B.jsx)(`div`,{className:`hidden rounded-t-lg border-t border-kumo-fill bg-kumo-base md:block`,children:(0,B.jsxs)(`div`,{className:`grid grid-cols-2 divide-x divide-kumo-fill`,children:[(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(H,{content:_(e)}),(0,B.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,B.jsx)(V,{text:_(e),label:`Copy params`})})]}),(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(H,{content:_(t)}),(0,B.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,B.jsx)(V,{text:_(t),label:`Copy output`})})]})]})}),(0,B.jsxs)(`div`,{className:`md:hidden`,children:[(0,B.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,B.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:`Input params`})}),(0,B.jsx)(`div`,{className:`rounded-t-lg border-t border-kumo-fill bg-kumo-base`,children:(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(H,{content:_(e)}),(0,B.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,B.jsx)(V,{text:_(e),label:`Copy params`})})]})}),(0,B.jsx)(`div`,{className:`border-t border-kumo-fill px-4 py-2.5`,children:(0,B.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:`Output`})}),(0,B.jsx)(`div`,{className:`border-t border-kumo-fill bg-kumo-base`,children:(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(H,{content:_(t)}),(0,B.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,B.jsx)(V,{text:_(t),label:`Copy output`})})]})})]})]})}),fe=(0,F.memo)(function({error:e}){return(0,B.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-kumo-fill bg-kumo-tint`,children:[(0,B.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,B.jsx)(`span`,{className:`text-sm font-medium text-kumo-default`,children:e.name??`Error`})}),(0,B.jsxs)(`div`,{className:`relative rounded-t-lg border-t border-kumo-fill bg-kumo-base`,children:[(0,B.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,B.jsx)(`div`,{className:`absolute top-1.5 right-1.5`,children:(0,B.jsx)(V,{text:`${e.name??`Error`}: ${e.message??``}`,label:`Copy error`})})]})]})}),$=[{value:`all`,label:`All`,icon:S},{value:`step`,label:`Do`,icon:z},{value:`sleep`,label:`Sleep`,icon:N},{value:`waitForEvent`,label:`Wait for Event`,icon:R}],pe=(0,F.memo)(function({steps:e,onRestartFromStep:t}){let n=e??[],[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(`all`),[s,c]=(0,F.useState)(()=>new Set),u=(0,F.useCallback)(e=>{c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),d=[...n].reverse().filter(e=>{if(a!==`all`&&e.type!==a)return!1;if(r.trim()){let t=r.trim().toLowerCase();return X(e.name).toLowerCase().includes(t)}return!0}),f=$.find(e=>e.value===a)??$[0],p=f.icon;return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`mb-3`,children:(0,B.jsx)(`h4`,{className:`text-lg font-semibold text-kumo-default`,children:`Step History`})}),n.length>0&&(0,B.jsxs)(`div`,{className:`mb-3 flex flex-col gap-2 sm:flex-row sm:items-center`,children:[(0,B.jsxs)(`div`,{className:`relative flex-1`,children:[(0,B.jsx)(A,{size:14,className:`absolute top-1/2 left-3 -translate-y-1/2 text-kumo-subtle`}),(0,B.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=>i(e.target.value),placeholder:`Search steps...`,type:`text`,value:r})]}),(0,B.jsxs)(D,{children:[(0,B.jsx)(D.Trigger,{render:(0,B.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,B.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(p,{size:14,className:`text-kumo-subtle`}),f.label]}),(0,B.jsx)(l,{size:14,className:`text-kumo-subtle`})]})}),(0,B.jsx)(D.Content,{align:`end`,className:`w-44 bg-kumo-base`,side:`bottom`,children:$.map(({value:e,label:t,icon:n})=>(0,B.jsxs)(D.Item,{className:`flex cursor-pointer items-center gap-2 rounded-md transition-colors hover:bg-kumo-fill`,onClick:()=>o(e),children:[(0,B.jsx)(n,{size:14,className:`text-kumo-subtle`}),t]},e))})]})]}),(0,B.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-kumo-fill bg-kumo-base`,children:(0,B.jsx)(`div`,{className:`min-w-150`,children:n.length===0?(0,B.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-kumo-subtle`,children:`No steps recorded yet`}):d.length===0?(0,B.jsx)(`div`,{className:`px-4 py-8 text-center text-sm text-kumo-subtle`,children:`No steps match your search`}):d.map(e=>{let n=Y(e);return(0,B.jsx)(se,{step:e,isExpanded:s.has(n),onToggleExpanded:()=>u(n),onRestartFromStep:t},n)})})})]})});function me(){let e=M.useParams(),t=M.useLoaderData(),n=ie(),[r,a]=(0,F.useState)(t.details),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(!1),[p,m]=(0,F.useState)(!1),[h,_]=(0,F.useState)(!1),[v,y]=(0,F.useState)(null),[b,x]=(0,F.useState)(!1),[S,C]=(0,F.useState)(``),[w,T]=(0,F.useState)(``),[D,A]=(0,F.useState)(!1),[j,N]=(0,F.useState)(null),[I,L]=(0,F.useState)(!1),R=(0,F.useRef)(JSON.stringify(t.details));(0,F.useEffect)(()=>{let e=JSON.stringify(t.details);e!==R.current&&(R.current=e,a(t.details))},[t]);let z=r.status??`unknown`,V=e.instanceId,H=r.steps??[],W=te(z),G=(0,F.useCallback)(async()=>{try{let t=(await ae({path:{instance_id:V,workflow_name:e.workflowName}})).data?.result;if(t){let e=JSON.stringify(t);e!==R.current&&(R.current=e,a(t))}}catch{}},[V,e.workflowName]),K=ee(z);(0,F.useEffect)(()=>{if(K)return;let e=!0;async function t(){for(;e&&(await new Promise(e=>setTimeout(e,1e3)),e);)await G()}return t(),()=>{e=!1}},[G,K]);let q=(0,F.useCallback)(async t=>{l(t),y(null);try{await P({path:{workflow_name:e.workflowName,instance_id:V},body:{action:t}}),await G()}catch(e){y(e instanceof Error?e.message:`Failed to ${t}`)}finally{l(null)}},[e.workflowName,V,G]),J=(0,F.useCallback)(e=>{N(e)},[]),Y=(0,F.useCallback)(async()=>{if(j){L(!0),y(null);try{await P({path:{workflow_name:e.workflowName,instance_id:V},body:{action:`restart`,from:g(j)}}),await G()}catch(e){y(e instanceof Error?e.message:`Failed to restart from step`)}finally{N(null),L(!1)}}},[j,e.workflowName,V,G]);return(0,B.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,B.jsx)(O,{icon:oe,items:[(0,B.jsx)(i,{className:`flex items-center gap-1.5`,params:{workflowName:e.workflowName},to:`/workflows/$workflowName`,children:e.workflowName},`wf`),(0,B.jsx)(`span`,{className:`flex items-center gap-1.5 font-mono text-xs`,children:V},`id`)],title:`Workflows`}),(0,B.jsxs)(`div`,{className:`flex-1 overflow-auto`,children:[(0,B.jsx)(`div`,{className:`px-4 pt-6 sm:px-6 lg:px-12 xl:px-20 2xl:px-32`,children:(0,B.jsx)(`div`,{children:(0,B.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2 pb-6 sm:gap-3`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 sm:gap-3`,children:[(0,B.jsx)(`h1`,{className:`shrink-0 text-xl font-semibold text-kumo-default sm:text-2xl`,children:e.workflowName}),(0,B.jsx)(s,{content:u?`Copied!`:`Copy instance ID`,asChild:!0,children:(0,B.jsxs)(`button`,{className:`min-w-0 cursor-pointer truncate font-mono text-base transition-colors sm:text-2xl ${u?`text-kumo-default`:`text-kumo-subtle hover:text-kumo-default`}`,onClick:()=>{navigator.clipboard.writeText(V),d(!0),setTimeout(()=>d(!1),1e3)},children:[`#`,V]})}),(0,B.jsx)(U,{status:z})]}),(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-1.5 sm:gap-2`,children:[W.map(e=>{let t=ue[e];return(0,B.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:c!==null,onClick:()=>void q(e),children:[(0,B.jsx)(t,{size:14,weight:e===`restart`?`regular`:`fill`,className:c===e?`animate-spin`:``}),e.charAt(0).toUpperCase()+e.slice(1)]},e)}),z!==`complete`&&z!==`errored`&&z!==`terminated`&&(0,B.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:c!==null,onClick:()=>x(!0),title:`Send Event`,children:(0,B.jsx)(f,{size:14})}),(0,B.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:c!==null,onClick:()=>m(!0),title:`Delete`,children:(0,B.jsx)(ne,{size:14})})]})]})})}),(0,B.jsxs)(`div`,{className:`relative`,children:[(0,B.jsx)(`hr`,{className:`absolute top-1/2 w-full border-kumo-fill`}),(0,B.jsx)(`div`,{className:`relative px-4 sm:px-6 lg:px-12 xl:px-20 2xl:px-32`,children:(0,B.jsx)(Q,{status:z,stepCount:H.length,start:r.start,end:r.end})})]}),(0,B.jsx)(E.Root,{open:p,onOpenChange:m,children:(0,B.jsxs)(E,{size:`lg`,className:`w-lg`,children:[(0,B.jsx)(`div`,{className:`border-b border-kumo-fill px-6 py-4`,children:(0,B.jsx)(E.Title,{className:`text-lg font-semibold text-kumo-default`,children:`Delete this instance?`})}),(0,B.jsxs)(`div`,{className:`px-6 py-5`,children:[(0,B.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,B.jsxs)(`div`,{className:`mt-3 rounded-lg border border-kumo-fill bg-kumo-elevated px-4 py-3`,children:[(0,B.jsx)(`span`,{className:`text-xs text-kumo-subtle`,children:`Instance ID`}),(0,B.jsx)(`p`,{className:`mt-0.5 font-mono text-sm text-kumo-default`,children:V})]})]}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-kumo-fill px-6 py-4`,children:[(0,B.jsx)(o,{variant:`secondary`,onClick:()=>m(!1),disabled:h,children:`Cancel`}),(0,B.jsx)(o,{variant:`destructive`,disabled:h,loading:h,onClick:()=>{_(!0),k({path:{workflow_name:e.workflowName,instance_id:V}}).then(()=>{m(!1),n({to:`/workflows/$workflowName`,params:{workflowName:e.workflowName},search:e=>e})}).finally(()=>_(!1))},children:`Delete Instance`})]})]})}),(0,B.jsx)(E.Root,{open:b,onOpenChange:e=>{x(e),e||(C(``),T(``))},children:(0,B.jsxs)(E,{size:`lg`,className:`w-lg`,children:[(0,B.jsx)(`div`,{className:`border-b border-kumo-fill px-6 py-4`,children:(0,B.jsx)(E.Title,{className:`text-lg font-semibold text-kumo-default`,children:`Send Event`})}),(0,B.jsxs)(`div`,{className:`space-y-4 px-6 py-5`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-kumo-default`,children:`Event Type`}),(0,B.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:S})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`label`,{className:`mb-2 block text-sm font-medium text-kumo-default`,children:[`Payload`,` `,(0,B.jsx)(`span`,{className:`font-normal text-kumo-subtle`,children:`(optional)`})]}),(0,B.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,B.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-kumo-fill px-6 py-4`,children:[(0,B.jsx)(o,{variant:`secondary`,onClick:()=>x(!1),disabled:D,children:`Cancel`}),(0,B.jsx)(o,{variant:`primary`,disabled:!S.trim()||D,loading:D,onClick:()=>{let t;if(w.trim())try{t=JSON.parse(w)}catch{return}A(!0),re({path:{workflow_name:e.workflowName,instance_id:V,event_type:S.trim()},body:t}).then(()=>{x(!1),C(``),T(``),G()}).finally(()=>A(!1))},children:`Send`})]})]})}),(0,B.jsx)(E.Root,{open:j!==null,onOpenChange:e=>{!e&&!I&&N(null)},children:(0,B.jsxs)(E,{size:`lg`,className:`w-lg`,children:[(0,B.jsx)(`div`,{className:`border-b border-kumo-fill px-6 py-4`,children:(0,B.jsx)(E.Title,{className:`text-lg font-semibold text-kumo-default`,children:`Restart from this step?`})}),(0,B.jsx)(`div`,{className:`px-6 py-5`,children:(0,B.jsxs)(`p`,{className:`text-sm text-kumo-subtle`,children:[`This will rerun the instance from`,` `,(0,B.jsx)(`span`,{className:`font-medium text-kumo-default`,children:X(j?.name)}),`. Saved state for this step and later steps will be cleared, while earlier completed steps are kept.`]})}),(0,B.jsxs)(`div`,{className:`flex justify-end gap-2 border-t border-kumo-fill px-6 py-4`,children:[(0,B.jsx)(o,{variant:`secondary`,onClick:()=>N(null),disabled:I,children:`Cancel`}),(0,B.jsx)(o,{variant:`primary`,disabled:I,loading:I,onClick:()=>void Y(),children:`Restart from step`})]})]})}),(0,B.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:[v&&(0,B.jsx)(`div`,{className:`rounded-lg border border-kumo-danger/20 bg-kumo-danger/8 p-4 text-sm text-kumo-danger`,children:v}),(0,B.jsx)(de,{params:r.params,output:r.output}),r.error&&(0,B.jsx)(fe,{error:r.error}),(0,B.jsx)(pe,{steps:r.steps,onRestartFromStep:J})]})]})]})}export{me as component};