awaitly-visualizer 7.0.1 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +201 -0
- package/dist/devtools.cjs +6 -6
- package/dist/devtools.cjs.map +1 -1
- package/dist/devtools.js +5 -5
- package/dist/devtools.js.map +1 -1
- package/dist/index.browser.cjs +13 -13
- package/dist/index.browser.cjs.map +1 -1
- package/dist/index.browser.js +13 -13
- package/dist/index.browser.js.map +1 -1
- package/dist/index.cjs +1005 -33
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +135 -1
- package/dist/index.d.ts +135 -1
- package/dist/index.js +1005 -33
- package/dist/index.js.map +1 -1
- package/index.js +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
function A(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1).replace(/\.0$/,"")}s`;let t=Math.floor(e/6e4),r=Math.round(e%6e4/1e3);return r>=60&&(t+=1,r=0),r===0?`${t}m`:`${t}m ${r}s`}function Re(){return`node_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Tt(e){for(let t of e)if((t.type==="parallel"||t.type==="race"||t.type==="sequence")&&!t.id.startsWith("detected_")||t.type==="decision")return!0;return!1}function Ie(e,t={}){if(Tt(e))return e;let{minOverlapMs:r=0,maxGapMs:o=5}=t,i=[],n=[];for(let c=0;c<e.length;c++){let l=e[c];l.type==="step"&&l.startTs!==void 0?i.push({node:l,startTs:l.startTs,endTs:l.endTs??l.startTs+(l.durationMs??0),originalIndex:c}):n.push({node:l,originalIndex:c})}if(i.length<=1)return e;i.sort((c,l)=>c.startTs-l.startTs);let s=[],a=[i[0]];for(let c=1;c<i.length;c++){let l=i[c],p=Math.min(...a.map(E=>E.startTs)),h=Math.max(...a.map(E=>E.endTs)),f=l.startTs<=p+o,b=l.startTs<h;if(!f&&!b){s.push(a),a=[l];continue}let k=b?Math.min(l.endTs,h)-l.startTs:0;f||k>=r?a.push(l):(s.push(a),a=[l])}s.push(a);let u=[];for(let c of s){let l=Math.min(...c.map(p=>p.originalIndex));if(c.length===1)u.push({node:c[0].node,position:l});else{let p=c.map(k=>k.node),h=Math.min(...c.map(k=>k.startTs)),f=Math.max(...c.map(k=>k.endTs)),b={type:"parallel",id:`detected_parallel_${h}`,name:`${p.length} parallel steps`,state:Mt(p),mode:"all",children:p,startTs:h,endTs:f,durationMs:f-h};u.push({node:b,position:l})}}for(let{node:c,originalIndex:l}of n)u.push({node:c,position:l});return u.sort((c,l)=>c.position-l.position),u.map(c=>c.node)}function Mt(e){return e.some(n=>n.state==="error")?"error":e.some(n=>n.state==="running")?"running":e.some(n=>n.state==="pending")?"pending":(e.every(n=>n.state==="success"||n.state==="cached"),"success")}function Ot(e={}){return{detect:t=>Ie(t,e)}}function de(e={}){let{detectParallel:t=!0,parallelDetection:r,enableSnapshots:o=!1,maxSnapshots:i=1e3}=e,n=o,s=Re(),a,u,c,l="pending",p,h,f=new Map,b=[],k=[],E=new Map,D=[],T=Date.now(),N=T,v={onAfterStep:new Map},x,g=[],y=0;function $(d){return d.stepId??d.stepKey??d.name??Re()}function C(d){if(b.length>0){b[b.length-1].children.push(d),N=Date.now();return}if(k.length>0){let w=k[k.length-1];for(let m of w.branches.values())if(m.taken){m.children.push(d),N=Date.now();return}w.pendingChildren.push(d),N=Date.now();return}D.push(d),N=Date.now()}function M(d){if(!n)return;let w=te(),m=new Map;for(let[W,J]of f)m.set(W,{id:J.id,name:J.name,key:J.key,startTs:J.startTs,retryCount:J.retryCount,timedOut:J.timedOut,timeoutMs:J.timeoutMs});let U={id:`snapshot_${y}`,eventIndex:y,event:structuredClone(d),ir:structuredClone(w),timestamp:Date.now(),activeSteps:m};g.push(U),g.length>i&&g.shift(),y++}function L(d){switch(d.type){case"workflow_start":{D=[],c=void 0,h=void 0,p=void 0,f.clear(),b.length=0,k.length=0,E.clear(),a=d.workflowId,u=d.ts,l="running",T=Date.now(),N=T,x!==void 0&&x!==d.workflowId&&(v.shouldRun=void 0,v.onBeforeStart=void 0),x=d.workflowId,v.onAfterStep=new Map;break}case"workflow_success":l="success",c=d.ts,h=d.durationMs,N=Date.now();break;case"workflow_error":l="error",c=d.ts,p=d.error,h=d.durationMs,N=Date.now();break;case"workflow_cancelled":l="aborted",c=d.ts,h=d.durationMs,N=Date.now();break;case"step_start":{let w=$(d);f.set(w,{id:w,name:d.name,key:d.stepKey,startTs:d.ts,retryCount:0,timedOut:!1}),N=Date.now();break}case"step_success":{let w=$(d),m=f.get(w);if(m){let U={type:"step",id:m.id,name:m.name,key:m.key,state:"success",startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,...m.retryCount>0&&{retryCount:m.retryCount},...m.timedOut&&{timedOut:!0,timeoutMs:m.timeoutMs}};C(U),f.delete(w)}break}case"step_error":{let w=$(d),m=f.get(w);if(m){let U={type:"step",id:m.id,name:m.name,key:m.key,state:"error",startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,error:d.error,...m.retryCount>0&&{retryCount:m.retryCount},...m.timedOut&&{timedOut:!0,timeoutMs:m.timeoutMs}};C(U),f.delete(w)}break}case"step_aborted":{let w=$(d),m=f.get(w);if(m){let U={type:"step",id:m.id,name:m.name,key:m.key,state:"aborted",startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,...m.retryCount>0&&{retryCount:m.retryCount},...m.timedOut&&{timedOut:!0,timeoutMs:m.timeoutMs}};C(U),f.delete(w)}break}case"step_cache_hit":{let m={type:"step",id:$(d),name:d.name,key:d.stepKey,state:"cached",startTs:d.ts,endTs:d.ts,durationMs:0};C(m);break}case"step_cache_miss":break;case"step_complete":break;case"step_timeout":{let w=$(d),m=f.get(w);m&&(m.timedOut=!0,m.timeoutMs=d.timeoutMs),N=Date.now();break}case"step_retry":{let w=$(d),m=f.get(w);m&&(m.retryCount=(d.attempt??1)-1),N=Date.now();break}case"step_retries_exhausted":N=Date.now();break;case"step_skipped":{let m={type:"step",id:$(d),name:d.name,key:d.stepKey,state:"skipped",startTs:d.ts,endTs:d.ts,durationMs:0};C(m);break}case"hook_should_run":{let w={type:"shouldRun",state:"success",ts:d.ts,durationMs:d.durationMs,context:{result:d.result,skipped:d.skipped}};v.shouldRun=w,x=d.workflowId,N=Date.now();break}case"hook_should_run_error":{let w={type:"shouldRun",state:"error",ts:d.ts,durationMs:d.durationMs,error:d.error};v.shouldRun=w,x=d.workflowId,N=Date.now();break}case"hook_before_start":{let w={type:"onBeforeStart",state:"success",ts:d.ts,durationMs:d.durationMs,context:{result:d.result,skipped:d.skipped}};v.onBeforeStart=w,x=d.workflowId,N=Date.now();break}case"hook_before_start_error":{let w={type:"onBeforeStart",state:"error",ts:d.ts,durationMs:d.durationMs,error:d.error};v.onBeforeStart=w,x=d.workflowId,N=Date.now();break}case"hook_after_step":{let w={type:"onAfterStep",state:"success",ts:d.ts,durationMs:d.durationMs,context:{stepKey:d.stepKey}};v.onAfterStep.set(d.stepKey,w),N=Date.now();break}case"hook_after_step_error":{let w={type:"onAfterStep",state:"error",ts:d.ts,durationMs:d.durationMs,error:d.error,context:{stepKey:d.stepKey}};v.onAfterStep.set(d.stepKey,w),N=Date.now();break}case"stream_created":{let w=`${d.workflowId}:${d.namespace}`;E.set(w,{id:Re(),namespace:d.namespace,startTs:d.ts,writeCount:0,readCount:0,streamState:"active",backpressureOccurred:!1,finalPosition:0}),N=Date.now();break}case"stream_write":{let w=`${d.workflowId}:${d.namespace}`,m=E.get(w);m&&(m.writeCount++,m.finalPosition=Math.max(m.finalPosition,d.position)),N=Date.now();break}case"stream_read":{let w=`${d.workflowId}:${d.namespace}`,m=E.get(w);m&&m.readCount++,N=Date.now();break}case"stream_close":{let w=`${d.workflowId}:${d.namespace}`,m=E.get(w);if(m){m.streamState="closed",m.finalPosition=d.finalPosition;let U={type:"stream",id:m.id,namespace:m.namespace,state:"success",startTs:m.startTs,endTs:d.ts,durationMs:d.ts-m.startTs,writeCount:m.writeCount,readCount:m.readCount,finalPosition:d.finalPosition,streamState:"closed",backpressureOccurred:m.backpressureOccurred};C(U),E.delete(w)}N=Date.now();break}case"stream_error":{let w=`${d.workflowId}:${d.namespace}`,m=E.get(w);if(m){m.streamState="error";let U={type:"stream",id:m.id,namespace:m.namespace,state:"error",error:d.error,startTs:m.startTs,endTs:d.ts,durationMs:d.ts-m.startTs,writeCount:m.writeCount,readCount:m.readCount,finalPosition:d.position,streamState:"error",backpressureOccurred:m.backpressureOccurred};C(U),E.delete(w)}N=Date.now();break}case"stream_backpressure":{let w=`${d.workflowId}:${d.namespace}`,m=E.get(w);m&&(m.backpressureOccurred=!0),N=Date.now();break}}M(d)}function O(d){if(d.type==="scope_start")b.push({id:d.scopeId,name:d.name,type:d.scopeType,startTs:d.ts,children:[]}),N=Date.now();else if(d.type==="scope_end"){let w=b.findIndex(W=>W.id===d.scopeId);if(w===-1)return;for(;b.length>w+1;){let W=b.pop(),J=W.type==="race"?{type:"race",id:W.id,name:W.name,state:R(W.children),startTs:W.startTs,endTs:d.ts,children:W.children}:{type:"parallel",id:W.id,name:W.name,state:R(W.children),startTs:W.startTs,endTs:d.ts,children:W.children,mode:W.type==="allSettled"?"allSettled":"all"};b[b.length-1].children.push(J)}let[m]=b.splice(w,1),U=m.type==="race"?{type:"race",id:m.id,name:m.name,state:R(m.children),startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,children:m.children,winnerId:d.winnerId}:{type:"parallel",id:m.id,name:m.name,state:R(m.children),startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,children:m.children,mode:m.type==="allSettled"?"allSettled":"all"};C(U)}}function S(d){if(d.type==="decision_start")k.push({id:d.decisionId,name:d.name,condition:d.condition,decisionValue:d.decisionValue,startTs:d.ts,branches:new Map,pendingChildren:[]}),N=Date.now();else if(d.type==="decision_branch"){let w=k.find(m=>m.id===d.decisionId);if(w){let m=d.branchLabel,U=w.branches.get(m);if(U)U.taken=d.taken,d.taken&&w.pendingChildren.length>0&&(U.children.unshift(...w.pendingChildren),w.pendingChildren=[]);else{let W=d.taken?[...w.pendingChildren]:[];d.taken&&(w.pendingChildren=[]),w.branches.set(m,{label:d.branchLabel,condition:d.condition,taken:d.taken,children:W})}N=Date.now()}}else if(d.type==="decision_end"){let w=k.findIndex(m=>m.id===d.decisionId);if(w!==-1){let[m]=k.splice(w,1),U=k.splice(w),W=Array.from(m.branches.values());W.length===0&&m.pendingChildren.length>0&&(W=[{label:"default",taken:!0,children:[...m.pendingChildren]}]);let J=W.find(Se=>Se.taken)?.label,Nt={type:"decision",id:m.id,name:m.name,state:R(W.flatMap(Se=>Se.taken?Se.children:[])),startTs:m.startTs,endTs:d.ts,durationMs:d.durationMs,condition:m.condition,decisionValue:m.decisionValue,branchTaken:d.branchTaken??J,branches:W};C(Nt),k.push(...U),N=Date.now()}}}function R(d){return d.length===0?"success":d.some(W=>W.state==="error")?"error":d.every(W=>W.state==="success"||W.state==="cached")?"success":d.some(W=>W.state==="running")?"running":"pending"}function Y(){let d=[...D];for(let[,w]of f)d.push({type:"step",id:w.id,name:w.name,key:w.key,state:"running",startTs:w.startTs,...w.retryCount>0&&{retryCount:w.retryCount},...w.timedOut&&{timedOut:!0,timeoutMs:w.timeoutMs}});for(let[,w]of E)d.push({type:"stream",id:w.id,namespace:w.namespace,state:"running",startTs:w.startTs,writeCount:w.writeCount,readCount:w.readCount,finalPosition:w.finalPosition,streamState:w.streamState,backpressureOccurred:w.backpressureOccurred});return d}function te(){let d=Y();t&&(d=Ie(d,r));let w={type:"workflow",id:a??s,workflowId:a??s,state:l,startTs:u,endTs:c,durationMs:h,children:d,error:p},m=v.shouldRun!==void 0||v.onBeforeStart!==void 0||v.onAfterStep.size>0;return{root:w,metadata:{createdAt:T,lastUpdatedAt:N},...m&&{hooks:v}}}function re(){a=void 0,u=void 0,c=void 0,l="pending",p=void 0,h=void 0,f.clear(),b.length=0,k.length=0,E.clear(),D=[],T=Date.now(),N=T,v={onAfterStep:new Map},x=void 0,g.length=0,y=0}function we(){return[...g]}function It(d){return g[d]}function Et(d){return g[d]?.ir}function $t(){g.length=0,y=0}return{handleEvent:L,handleScopeEvent:O,handleDecisionEvent:S,getIR:te,reset:re,getSnapshots:we,getSnapshotAt:It,getIRAt:Et,clearSnapshots:$t,get hasActiveSteps(){return f.size>0},get state(){return l},get snapshotCount(){return g.length},get snapshotsEnabled(){return n},setSnapshotsEnabled(d){n=d}}}import{ok as At,err as Ut}from"awaitly";function j(e){return e.type==="step"}function et(e){return e.type==="sequence"}function V(e){return e.type==="parallel"}function F(e){return e.type==="race"}function X(e){return e.type==="decision"}function ne(e){return e.type==="stream"}function mn(e){return"children"in e||e.type==="decision"&&"branches"in e}var Ue="\x1B[0m",Dt="\x1B[1m",rt="\x1B[2m",Ct="\x1B[31m",Lt="\x1B[32m",_t="\x1B[33m",Wt="\x1B[34m",tt="\x1B[90m",Bt="\x1B[37m";function q(e,t){return t?`${t}${e}${Ue}`:e}function be(e){return`${Dt}${e}${Ue}`}function _(e){return`${rt}${e}${Ue}`}var z={pending:Bt,running:_t,success:Lt,error:Ct,aborted:tt,cached:Wt,skipped:rt+tt};function Pt(e){switch(e){case"pending":return"\u25CB";case"running":return"\u27F3";case"success":return"\u2713";case"error":return"\u2717";case"aborted":return"\u2298";case"cached":return"\u21BA";case"skipped":return"\u2298"}}function ye(e,t){let r=Pt(e);return q(r,t[e])}function Ee(e,t,r){return q(e,r[t])}function ee(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}var I={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",teeRight:"\u251C",teeLeft:"\u2524",teeDown:"\u252C",teeUp:"\u2534",cross:"\u253C"},pe={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},Ht="\x1B[0m";function Ft(e){return e<.2?pe.cold:e<.4?pe.cool:e<.6?pe.neutral:e<.8?pe.warm:e<.95?pe.hot:pe.critical}function nt(e,t){let r=Ft(t);return r?`${r}${e}${Ht}`:e}function zt(e){try{return At(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let i=Number(o);return Number.isSafeInteger(i)?i:o.toString()}))}catch{return Ut("STRINGIFY_ERROR")}}function ot(e){let t=zt(e);return t.ok?t.value:"[unserializable]"}var it="\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function Fe(e,t=10){if(e.length===0)return"";let r=e.slice(-t),o=Math.min(...r),n=Math.max(...r)-o||1;return r.map(s=>{let a=(s-o)/n,u=Math.floor(a*(it.length-1));return it[u]}).join("")}function He(e,t){let r=ee(e).length,o=Math.max(0,t-r);return e+" ".repeat(o)}function Kt(e,t){if(!t)return I.horizontal.repeat(e);let r=` ${t} `,o=ee(r).length,i=e-o;if(i<4)return I.horizontal.repeat(e);let n=2,s=i-n;return I.horizontal.repeat(n)+r+I.horizontal.repeat(s)}function st(e,t,r){let o=e.state==="success"?q("\u2699",r.success):q("\u26A0",r.error),i=e.durationMs!==void 0?_(` [${A(e.durationMs)}]`):"",n="";e.type==="shouldRun"&&e.context?.skipped?n=_(" \u2192 workflow skipped"):e.type==="shouldRun"&&e.context?.result===!0?n=_(" \u2192 proceed"):e.type==="onBeforeStart"&&e.context?.skipped?n=_(" \u2192 workflow skipped"):e.type==="onAfterStep"&&e.context?.stepKey&&(n=_(` (${e.context.stepKey})`));let s=e.state==="error"&&e.error?_(` error: ${String(e.error)}`):"";return`${o} ${_(t)}${n}${i}${s}`}function jt(e,t){let r=[];return e.shouldRun&&r.push(st(e.shouldRun,"shouldRun",t)),e.onBeforeStart&&r.push(st(e.onBeforeStart,"onBeforeStart",t)),r.length>0&&r.push(_("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),r}function ie(){return{name:"ascii",supportsLive:!0,render(e,t){let r={...z,...t.colors},o=Math.max(t.terminalWidth??60,5),i=o-4,n=[],s=e.root.name??"workflow",a=be(s);if(n.push(`${I.topLeft}${Kt(o-2,a)}${I.topRight}`),n.push(`${I.vertical}${" ".repeat(o-2)}${I.vertical}`),e.hooks){let c=jt(e.hooks,r);for(let l of c)n.push(`${I.vertical} ${He(l,i)}${I.vertical}`)}let u=$e(e.root.children,t,r,0,e.hooks);for(let c of u)n.push(`${I.vertical} ${He(c,i)}${I.vertical}`);if(n.push(`${I.vertical}${" ".repeat(o-2)}${I.vertical}`),e.root.durationMs!==void 0&&t.showTimings){let c=e.root.state==="success"?"Completed":e.root.state==="aborted"?"Cancelled":"Failed",p=`${Ee(c,e.root.state,r)} in ${A(e.root.durationMs)}`;n.push(`${I.vertical} ${He(p,i)}${I.vertical}`),n.push(`${I.vertical}${" ".repeat(o-2)}${I.vertical}`)}return n.push(`${I.bottomLeft}${I.horizontal.repeat(o-2)}${I.bottomRight}`),n.join(`
|
|
2
|
-
`)}}}function $e(e,t,r,o,i){let n=[];for(let s of e)j(s)?n.push(ze(s,t,r,i)):V(s)?n.push(...Gt(s,t,r,o,i)):F(s)?n.push(...Yt(s,t,r,o,i)):X(s)?n.push(...Jt(s,t,r,o,i)):ne(s)&&n.push(Vt(s,t,r));return n}function ze(e,t,r,o){let i=ye(e.state,r),n=e.name??e.key??"step",s=t,a=s.showHeatmap&&s.heatmapData?s.heatmapData.heat.get(e.key??"")??s.heatmapData.heat.get(e.name??"")??s.heatmapData.heat.get(e.id):void 0,u;a!==void 0?u=nt(n,a):u=Ee(n,e.state,r);let c=`${i} ${u}`;if(t.showKeys&&e.key&&e.name&&(c+=_(` [key: ${e.key}]`)),e.input!==void 0){let p=typeof e.input=="string"?e.input:ot(e.input).slice(0,30);c+=_(` [in: ${p}${p.length>=30?"...":""}]`)}if(e.output!==void 0&&e.state==="success"){let p=typeof e.output=="string"?e.output:ot(e.output).slice(0,30);c+=_(` [out: ${p}${p.length>=30?"...":""}]`)}if(t.showTimings&&e.durationMs!==void 0){let p=A(e.durationMs),h=a!==void 0?nt(`[${p}]`,a):_(`[${p}]`);c+=` ${h}`}if(s.showSparklines&&s.timingHistory){let p=s.timingHistory.get(e.key??"")??s.timingHistory.get(e.name??"")??s.timingHistory.get(e.id);p&&p.length>1&&(c+=` ${_(Fe(p))}`)}if(e.retryCount!==void 0&&e.retryCount>0&&(c+=_(` [${e.retryCount} ${e.retryCount===1?"retry":"retries"}]`)),e.timedOut){let p=e.timeoutMs!==void 0?` ${e.timeoutMs}ms`:"";c+=_(` [timeout${p}]`)}let l=e.key??e.id;if(o&&l&&o.onAfterStep.has(l)){let p=o.onAfterStep.get(l),h=p.state==="success"?q("\u2699",r.success):q("\u26A0",r.error),f=p.durationMs!==void 0?_(` ${A(p.durationMs)}`):"";c+=` ${h}${f}`}return c}function Vt(e,t,r){let o=e.streamState==="active"?q("\u27F3",r.running):e.streamState==="closed"?q("\u2713",r.success):q("\u2717",r.error),i=`stream:${e.namespace}`,n=Ee(i,e.state,r),s=_(`[W:${e.writeCount} R:${e.readCount}]`),a=`${o} ${n} ${s}`;return t.showTimings&&e.durationMs!==void 0&&(a+=` ${_(`[${A(e.durationMs)}]`)}`),e.backpressureOccurred&&(a+=_(" [backpressure]")),e.streamState==="closed"&&(a+=_(` pos:${e.finalPosition}`)),a}function Gt(e,t,r,o,i){let n=[],s=" ".repeat(o),a=ye(e.state,r),u=e.name??"parallel",c=e.mode==="allSettled"?" (allSettled)":"";if(n.push(`${s}${I.teeRight}${I.teeDown}${I.horizontal} ${a} ${be(u)}${c}`),e.children.length===0)n.push(`${s}${I.vertical} ${_("(operations not individually tracked)")}`),n.push(`${s}${I.vertical} ${_("(wrap each operation with step() to see individual steps)")}`);else for(let l=0;l<e.children.length;l++){let p=e.children[l],f=l===e.children.length-1?`${s}${I.vertical} ${I.bottomLeft}`:`${s}${I.vertical} ${I.teeRight}`;if(j(p))n.push(`${f} ${ze(p,t,r,i)}`);else{let b=$e([p],t,r,o+1,i);for(let k of b)n.push(`${s}${I.vertical} ${k}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${s}${I.bottomLeft}${I.horizontal}${I.horizontal} ${_(`[${A(e.durationMs)}]`)}`),n}function Yt(e,t,r,o,i){let n=[],s=" ".repeat(o),a=ye(e.state,r),u=e.name??"race";if(n.push(`${s}${I.teeRight}\u26A1 ${a} ${be(u)}`),e.children.length===0)n.push(`${s}${I.vertical} ${_("(operations not individually tracked)")}`),n.push(`${s}${I.vertical} ${_("(wrap each operation with step() to see individual steps)")}`);else for(let c=0;c<e.children.length;c++){let l=e.children[c],h=c===e.children.length-1?`${s}${I.vertical} ${I.bottomLeft}`:`${s}${I.vertical} ${I.teeRight}`,b=e.winnerId&&l.id===e.winnerId?_(" (winner)"):"";if(j(l))n.push(`${h} ${ze(l,t,r,i)}${b}`);else{let k=$e([l],t,r,o+1,i);for(let E of k)n.push(`${s}${I.vertical} ${E}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${s}${I.bottomLeft}${I.horizontal}${I.horizontal} ${_(`[${A(e.durationMs)}]`)}`),n}function Jt(e,t,r,o,i){let n=[],s=" ".repeat(o),a=ye(e.state,r),u=e.name??"decision",c=e.condition?_(` (${e.condition})`):"",l=e.decisionValue!==void 0?_(` = ${String(e.decisionValue)}`):"",p=e.branchTaken!==void 0?_(` \u2192 ${String(e.branchTaken)}`):"";n.push(`${s}${I.teeRight}${I.teeDown}${I.horizontal} ${a} ${be(u)}${c}${l}${p}`);for(let h=0;h<e.branches.length;h++){let f=e.branches[h],k=h===e.branches.length-1?`${s}${I.vertical} ${I.bottomLeft}`:`${s}${I.vertical} ${I.teeRight}`,E=f.taken?"\u2713":"\u2298",D=f.taken?r.success:r.skipped,T=q(`${E} ${f.label}`,D),N=f.condition?_(` (${f.condition})`):"";if(n.push(`${k} ${T}${N}`),f.children.length>0){let v=$e(f.children,t,r,o+1,i);for(let x of v)n.push(`${s}${I.vertical} ${x}`)}else f.taken||n.push(`${s}${I.vertical} ${_("(skipped)")}`)}return t.showTimings&&e.durationMs!==void 0&&n.push(`${s}${I.bottomLeft}${I.horizontal}${I.horizontal} ${_(`[${A(e.durationMs)}]`)}`),n}import{ok as qt,err as Zt}from"awaitly";function Ke(e){let t=[];for(let r of e)if(t.push(r),"children"in r&&Array.isArray(r.children)&&t.push(...Ke(r.children)),"branches"in r)for(let o of r.branches)t.push(...Ke(o.children));return t}function Ne(e,t){if(e.length===0)return 0;let r=Math.floor(e.length*t);return e[Math.min(r,e.length-1)]}function ke(e){return e<.2?"cold":e<.4?"cool":e<.6?"neutral":e<.8?"warm":e<.95?"hot":"critical"}function Xt(){let e=new Map,t=new Map,r=new Map,o=new Map,i=[];function n(v){return v.stepKey??v.stepId??v.name??"unknown"}function s(v){let x=new Map;for(let g of v)switch(g.type){case"step_start":{let y=n(g);x.set(y,{retried:!1,timedOut:!1});break}case"step_retry":{let y=n(g),$=x.get(y);$&&($.retried=!0);break}case"step_timeout":{let y=n(g),$=x.get(y);$&&($.timedOut=!0);break}case"step_success":{let y=n(g),$=x.get(y),C=e.get(y)??[];C.push(g.durationMs),e.set(y,C);let M=t.get(y)??{retried:0,total:0};M.total++,$?.retried&&M.retried++,t.set(y,M);let L=o.get(y)??{timedOut:0,total:0};L.total++,$?.timedOut&&L.timedOut++,o.set(y,L);let O=r.get(y)??{errors:0,total:0};O.total++,r.set(y,O),x.delete(y);break}case"step_error":{let y=n(g),$=x.get(y),C=e.get(y)??[];C.push(g.durationMs),e.set(y,C);let M=t.get(y)??{retried:0,total:0};M.total++,$?.retried&&M.retried++,t.set(y,M);let L=o.get(y)??{timedOut:0,total:0};L.total++,$?.timedOut&&L.timedOut++,o.set(y,L);let O=r.get(y)??{errors:0,total:0};O.total++,O.errors++,r.set(y,O),x.delete(y);break}}}function a(v){s(v.events)}function u(v){i.push(v)}function c(v){i.length>0&&(s(i),i=[])}function l(v){let x=e.get(v);if(!x||x.length===0)return;let g=[...x].sort((S,R)=>S-R),$=g.reduce((S,R)=>S+R,0)/g.length,C=g.reduce((S,R)=>S+(R-$)**2,0)/g.length,M=t.get(v)??{retried:0,total:1},L=r.get(v)??{errors:0,total:1},O=o.get(v)??{timedOut:0,total:1};return{nodeId:v,avgDurationMs:$,minDurationMs:g[0],maxDurationMs:g[g.length-1],stdDevMs:Math.sqrt(C),samples:g.length,retryRate:M.total>0?M.retried/M.total:0,timeoutRate:O.total>0?O.timedOut/O.total:0,errorRate:L.total>0?L.errors/L.total:0,percentiles:{p50:Ne(g,.5),p90:Ne(g,.9),p95:Ne(g,.95),p99:Ne(g,.99)}}}function p(v){return l(v)}function h(v,x="duration"){let g=new Map,y=Ke(v.root.children),$=[];for(let R of y){let Y=("key"in R?R.key:void 0)??R.id??R.name,te=l(Y);if(te){let re;switch(x){case"duration":re=te.avgDurationMs;break;case"retryRate":re=te.retryRate;break;case"errorRate":re=te.errorRate;break}$.push({id:R.id,value:re})}}if($.length===0)return{heat:g,metric:x,stats:{min:0,max:0,mean:0,threshold:0}};let C=$.map(R=>R.value),M=Math.min(...C),L=Math.max(...C),O=C.reduce((R,Y)=>R+Y,0)/C.length,S=L-M||1;for(let{id:R,value:Y}of $)g.set(R,(Y-M)/S);return{heat:g,metric:x,stats:{min:M,max:L,mean:O,threshold:O+(L-O)*.5}}}function f(){let v=new Map;for(let x of e.keys()){let g=l(x);g&&v.set(x,g)}return v}function b(v=10){return[...f().values()].sort((g,y)=>y.avgDurationMs-g.avgDurationMs).slice(0,v)}function k(v=10){return[...f().values()].filter(g=>g.errorRate>0).sort((g,y)=>y.errorRate-g.errorRate).slice(0,v)}function E(v=10){return[...f().values()].filter(g=>g.retryRate>0).sort((g,y)=>y.retryRate-g.retryRate).slice(0,v)}function D(){return JSON.stringify({timingData:Object.fromEntries(e),retryData:Object.fromEntries(t),errorData:Object.fromEntries(r),timeoutData:Object.fromEntries(o)})}function T(v){let x=JSON.parse(v);e.clear(),t.clear(),r.clear(),o.clear();for(let[g,y]of Object.entries(x.timingData??{}))e.set(g,y);for(let[g,y]of Object.entries(x.retryData??{}))t.set(g,y);for(let[g,y]of Object.entries(x.errorData??{}))r.set(g,y);for(let[g,y]of Object.entries(x.timeoutData??{}))o.set(g,y)}function N(){e.clear(),t.clear(),r.clear(),o.clear(),i=[]}return{addRun:a,addEvent:u,finalizeRun:c,getNodePerformance:p,getHeatmap:h,getSlowestNodes:b,getErrorProneNodes:k,getRetryProneNodes:E,getAllPerformance:f,exportData:D,importData:T,clear:N}}function Qt(){return[" classDef pending fill:#f3f4f6,stroke:#9ca3af,stroke-width:2px,color:#374151"," classDef running fill:#fef3c7,stroke:#f59e0b,stroke-width:3px,color:#92400e"," classDef success fill:#d1fae5,stroke:#10b981,stroke-width:3px,color:#065f46"," classDef error fill:#fee2e2,stroke:#ef4444,stroke-width:3px,color:#991b1b"," classDef aborted fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#4b5563,stroke-dasharray: 5 5"," classDef cached fill:#dbeafe,stroke:#3b82f6,stroke-width:3px,color:#1e40af"," classDef skipped fill:#f9fafb,stroke:#d1d5db,stroke-width:2px,color:#6b7280,stroke-dasharray: 5 5"," classDef stream fill:#ede9fe,stroke:#8b5cf6,stroke-width:3px,color:#5b21b6"," classDef streamActive fill:#ddd6fe,stroke:#7c3aed,stroke-width:3px,color:#4c1d95"," classDef streamError fill:#fce7f3,stroke:#db2777,stroke-width:3px,color:#9d174d"]}function er(){return[" classDef heat_cold fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af"," classDef heat_cool fill:#ccfbf1,stroke:#14b8a6,stroke-width:2px,color:#0f766e"," classDef heat_neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#374151"," classDef heat_warm fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#92400e"," classDef heat_hot fill:#fed7aa,stroke:#f97316,stroke-width:3px,color:#c2410c"," classDef heat_critical fill:#fecaca,stroke:#ef4444,stroke-width:3px,color:#b91c1c"]}function tr(e){return`heat_${e}`}function rr(){return[" classDef hook_success fill:#e0f2fe,stroke:#0284c7,stroke-width:2px,color:#0c4a6e"," classDef hook_error fill:#fef2f2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d"]}function nr(e){try{return qt(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let i=Number(o);return Number.isSafeInteger(i)?i:o.toString()}))}catch{return Zt("STRINGIFY_ERROR")}}function at(e){let t=nr(e);return t.ok?t.value:"[unserializable]"}function or(e,t,r){let o;if(e.shouldRun){let i="hook_shouldRun",n=e.shouldRun.state==="success"?"hook_success":"hook_error",s=e.shouldRun.state==="success"?"\u2699":"\u26A0",a=r.showTimings&&e.shouldRun.durationMs!==void 0?` ${A(e.shouldRun.durationMs)}`:"",u=e.shouldRun.context?.skipped?"\\nskipped workflow":e.shouldRun.context?.result===!0?"\\nproceed":"";t.push(` ${i}[["${s} shouldRun${u}${a}"]]:::${n}`),o=i}if(e.onBeforeStart){let i="hook_beforeStart",n=e.onBeforeStart.state==="success"?"hook_success":"hook_error",s=e.onBeforeStart.state==="success"?"\u2699":"\u26A0",a=r.showTimings&&e.onBeforeStart.durationMs!==void 0?` ${A(e.onBeforeStart.durationMs)}`:"",u=e.onBeforeStart.context?.skipped?"\\nskipped workflow":"";t.push(` ${i}[["${s} onBeforeStart${u}${a}"]]:::${n}`),o&&t.push(` ${o} --> ${i}`),o=i}return{lastHookId:o}}var ct=0,Te=new Set,Me=new Set;function fe(e="node"){return`${e}_${++ct}`}function ir(){ct=0,Te.clear(),Me.clear()}function K(e){return e.replace(/"/g,"#quot;").replace(/</g,"<").replace(/>/g,">").trim()}function dt(e){return K(e).replace(/[{}[\]()]/g,"")}function se(){return{name:"mermaid",supportsLive:!1,render(e,t){ir();let r=[],o=t;r.push("flowchart TD");let i;e.hooks&&(i=or(e.hooks,r,t).lastHookId);let n="start";r.push(` ${n}(("\u25B6 Start"))`),i&&r.push(` ${i} --> ${n}`);let s=n;for(let u of e.root.children){let c=Oe(u,t,r,o,e.hooks);r.push(` ${s} --> ${c.entryId}`),s=c.exitId}if(["success","error","aborted"].includes(e.root.state)){let u="finish",c=e.root.state==="success"?"\u2713":e.root.state==="error"?"\u2717":"\u2298",l=e.root.state==="success"?"Done":e.root.state==="error"?"Failed":"Cancelled",p=`(("${c} ${l}"))`,h=e.root.state==="success"?":::success":e.root.state==="error"?":::error":":::aborted";r.push(` ${u}${p}${h}`),r.push(` ${s} --> ${u}`)}return r.push(""),r.push(...Qt()),o.showHeatmap&&r.push(...er()),e.hooks&&r.push(...rr()),r.join(`
|
|
3
|
-
`)}}}function
|
|
4
|
-
`)}var Z=11,Q=2,me=2,De=3;function Ve(e,t){if(e.length<=t)return[e];let r=e.split(" "),o=[],i="";for(let n of r)i?i.length+1+n.length<=t?i+=" "+n:(o.push(i),i=n):i=n;if(i&&o.push(i),o.length===0)for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}function ft(e){switch(e){case"success":return"\u2713";case"error":return"\u2717";case"running":return"\u27F3";case"pending":return"\u25CB";case"aborted":case"skipped":return"\u2298";case"cached":return"\u21BA";default:return"\u25CB"}}function gr(e,t,r){let o=t.showStartEnd??!0,i=t,n=Math.floor(r/2),s=[],a=0;if(o){let c=Ce("start","start",["\u25B6 Start"],"success",n,a);s.push(c),a=c.bottomY+me}for(let c of e.root.children){let l=Le(c,n,a,r-4,t,i);s.push(l.node),a=l.bottomY+me}if(o&&["success","error","aborted"].includes(e.root.state)){let c=e.root.state==="success"?"\u2713 Done":e.root.state==="error"?"\u2717 Failed":"\u2298 Cancelled",l=Ce("end","end",[c],e.root.state,n,a);s.push(l),a=l.bottomY}return{nodes:s,totalHeight:a+2}}function Ce(e,t,r,o,i,n){let s=Math.max(...r.map(l=>ee(l).length)),a=Math.max(Z,s+Q*2),u=r.length+2,c=i-Math.floor(a/2);return{id:e,type:t,label:r,state:o,x:c,y:n,width:a,height:u,centerX:i,bottomY:n+u-1}}function Le(e,t,r,o,i,n){if(j(e))return wr(e,t,r,o,i,n);if(V(e)||F(e))return yr(e,t,r,o,i,n);if(X(e))return kr(e,t,r,o,i,n);if(ne(e))return br(e,t,r,o,i,n);let s=Ce(e.id,"step",["?"],e.state,t,r);return{node:s,bottomY:s.bottomY}}function wr(e,t,r,o,i,n){let s=e.name??e.key??"step",a=ft(e.state),u=[],c=`${a} ${s}`;i.showKeys&&e.key&&e.name&&(c+=` [${e.key}]`);let l=Math.min(o-Q*2,40);if(u.push(...Ve(c,l)),i.showTimings&&e.durationMs!==void 0&&u.push(`[${A(e.durationMs)}]`),e.retryCount&&e.retryCount>0&&u.push(`${e.retryCount}x retry`),e.timedOut&&u.push("timeout"),n?.showSparklines&&n.timingHistory){let D=n.timingHistory.get(e.key??"")??n.timingHistory.get(e.name??"")??n.timingHistory.get(e.id);D&&D.length>1&&u.push(Fe(D,8))}let p=Math.max(...u.map(D=>ee(D).length)),h=Math.max(Z,p+Q*2),f=u.length+2,b=t-Math.floor(h/2),k;if(n?.showHeatmap&&n.heatmapData){let D=e.key??e.name??e.id;k=n.heatmapData.heat.get(e.id)??n.heatmapData.heat.get(D)}let E={id:e.id,type:"step",label:u,state:e.state,x:b,y:r,width:h,height:f,centerX:t,bottomY:r+f-1,metadata:k!==void 0?{heat:k}:void 0};return{node:E,bottomY:E.bottomY}}function br(e,t,r,o,i,n){let s=`stream:${e.namespace}`,a=e.streamState==="active"?"\u27F3":e.streamState==="closed"?"\u2713":"\u2717",u=[],c=`${a} ${s}`,l=Math.min(o-Q*2,40);u.push(...Ve(c,l)),u.push(`W:${e.writeCount} R:${e.readCount}`),i.showTimings&&e.durationMs!==void 0&&u.push(`[${A(e.durationMs)}]`),e.backpressureOccurred&&u.push("backpressure");let p=Math.max(...u.map(E=>ee(E).length)),h=Math.max(Z,p+Q*2),f=u.length+2,b=t-Math.floor(h/2),k={id:e.id,type:"stream",label:u,state:e.state,x:b,y:r,width:h,height:f,centerX:t,bottomY:r+f-1,metadata:{streamState:e.streamState,backpressureOccurred:e.backpressureOccurred}};return{node:k,bottomY:k.bottomY}}function yr(e,t,r,o,i,n){let s=F(e),a=e.name??(s?"race":"parallel"),c=`${s?"\u26A1":"\u2AD8"} ${a}`;if(e.children.length===0){let y=[c,"(not tracked)"],$=Ce(e.id,s?"race":"parallel",y,e.state,t,r);return{node:$,bottomY:$.bottomY}}let l=Math.floor((o-De*(e.children.length-1))/e.children.length),p=[];for(let y of e.children){let $=je(y,Math.max(l,Z),i,n);p.push($.width)}let h=p.reduce((y,$)=>y+$,0)+De*(e.children.length-1),f=h>o&&e.children.length>1,b=Math.max(Z,c.length+Q*2),k=3,E=t-Math.floor(b/2),D=r;D+=k,D+=1,D+=1;let T=[];if(f)for(let y=0;y<e.children.length;y++){let $=e.children[y],C=Le($,t,D,o,i,n);s&&F(e)&&e.winnerId===$.id&&(C.node.metadata={...C.node.metadata,isWinner:!0}),T.push(C.node),D=C.bottomY+me}else{let y=t-Math.floor(h/2);for(let $=0;$<e.children.length;$++){let C=e.children[$],M=y+Math.floor(p[$]/2),L=Le(C,M,D,p[$],i,n);s&&F(e)&&e.winnerId===C.id&&(L.node.metadata={...L.node.metadata,isWinner:!0}),T.push(L.node),y+=p[$]+De}}let N=Math.max(...T.map(y=>y.bottomY)),x=!f&&T.length>1?N+2:N;return{node:{id:e.id,type:s?"race":"parallel",label:[c],state:e.state,x:E,y:r,width:b,height:k,centerX:t,bottomY:x,children:T,metadata:{verticalLayout:f}},bottomY:x}}function kr(e,t,r,o,i,n){let s=e.name??"decision",a=e.condition?` (${e.condition.slice(0,20)})`:"",u=`\u25C7 ${s}${a}`,c=Math.min(o-Q*2,40),l=Ve(u,c),p=Math.max(...l.map(x=>ee(x).length)),h=Math.max(Z,p+Q*2),f=l.length+2,b=t-Math.floor(h/2),k=e.branches.find(x=>x.taken),E=k&&k.children.length>0?k:e.branches.find(x=>x.children.length>0);if(!E||E.children.length===0){let x={id:e.id,type:"decision",label:l,state:e.state,x:b,y:r,width:h,height:f,centerX:t,bottomY:r+f-1};return{node:x,bottomY:x.bottomY}}let D=r+f+me,T=[];for(let x of E.children){let g=Le(x,t,D,o,i,n);T.push(g.node),D=g.bottomY+me}let N=T.length>0?T[T.length-1].bottomY:r+f-1;return{node:{id:e.id,type:"decision",label:l,state:e.state,x:b,y:r,width:h,height:f,centerX:t,bottomY:N,children:T},bottomY:N}}function je(e,t,r,o){if(j(e)){let i=e.name??e.key??"step",n=ft(e.state),s=1;r.showTimings&&e.durationMs!==void 0&&s++,e.retryCount&&e.retryCount>0&&s++,e.timedOut&&s++,o?.showSparklines&&(o.timingHistory?.has(e.key??"")||o.timingHistory?.has(e.name??"")||o.timingHistory?.has(e.id))&&s++;let a=`${n} ${i}`;r.showKeys&&e.key&&e.name&&(a+=` [${e.key}]`);let u=Math.min(t,Math.max(Z,a.length+Q*2)),c=s+2;return{width:u,height:c}}if(V(e)||F(e)){if(e.children.length===0)return{width:Z+4,height:4};let i=Math.floor(t/e.children.length),n=0,s=0;for(let a of e.children){let u=je(a,i,r,o);n+=u.width,s=Math.max(s,u.height)}return n+=De*(e.children.length-1),{width:Math.max(n,Z),height:5+s+2}}if(X(e)){let i=e.branches.find(s=>s.taken),n=0;if(i)for(let s of i.children){let a=je(s,t,r,o);n+=a.height+me}return{width:Math.min(t,30),height:3+n}}if(ne(e)){let i=`stream:${e.namespace}`,n=2;r.showTimings&&e.durationMs!==void 0&&n++,e.backpressureOccurred&&n++;let s=Math.min(t,Math.max(Z,i.length+Q*2+4)),a=n+2;return{width:s,height:a}}return{width:Z,height:3}}function vr(e,t,r){let o={...z,...r.colors};for(let i=0;i<t.length;i++){let n=t[i],s=i===t.length-1;if(_e(e,n,o),!s){let a=t[i+1],u=n.centerX,c=n.bottomY+1,l=a.centerX,p=a.y-1;oe(e,u,c,p-1),le(e,l,p)}}}function _e(e,t,r){let o=t.type!=="start",i=t.type!=="end"&&(!t.children||t.children.length===0);mr(e,t.x,t.y,t.width,t.height),o&&P(e,t.centerX,t.y,B.teeUp),(i||t.children&&t.children.length>0)&&P(e,t.centerX,t.y+t.height-1,B.teeDown);let n=t.width-Q*2,s=Ir(t,r);for(let a=0;a<t.label.length;a++){let u=t.label[a],c=t.x+1+Math.floor((n-ee(u).length)/2),l=t.y+1+a;lt(e,c,l,u,s)}t.metadata?.isWinner&<(e,t.x+t.width-2,t.y,"\u{1F3C6}"),t.children&&t.children.length>0&&(t.type==="parallel"||t.type==="race"?xr(e,t,r):Sr(e,t,r))}function xr(e,t,r){let o=t.children;if(o.length===0)return;let i=t.y+t.height,n=t.centerX;if(t.metadata?.verticalLayout===!0){let a=o[0];oe(e,n,i,a.y-2),le(e,a.centerX,a.y-1);for(let u=0;u<o.length;u++){let c=o[u];if(_e(e,c,r),u<o.length-1){let l=o[u+1];oe(e,c.centerX,c.bottomY+1,l.y-2),le(e,l.centerX,l.y-1)}}return}if(o.length===1)oe(e,n,i,o[0].y-2),le(e,o[0].centerX,o[0].y-1);else{let a=o.map(l=>l.centerX),u=Math.min(...a),c=Math.max(...a);oe(e,n,i,i+1),ut(e,i+1,u,c),P(e,n,i+1,B.teeUp);for(let l of o){let p=l.centerX;p===u?P(e,p,i+1,B.topLeft):p===c?P(e,p,i+1,B.topRight):p!==n&&P(e,p,i+1,B.teeDown),oe(e,p,i+2,l.y-2),le(e,p,l.y-1)}}for(let a of o)_e(e,a,r);if(o.length>1){let a=o.map(f=>f.bottomY),u=Math.max(...a),c=u+1,l=o.map(f=>f.centerX),p=Math.min(...l),h=Math.max(...l);for(let f of o)f.bottomY<u&&oe(e,f.centerX,f.bottomY+1,c-1);ut(e,c,p,h);for(let f of o){let b=f.centerX;b===p?P(e,b,c,B.bottomLeft):b===h?P(e,b,c,B.bottomRight):P(e,b,c,B.teeUp)}P(e,t.centerX,c,B.teeDown),P(e,t.centerX,c+1,B.vertical)}}function Sr(e,t,r){let o=t.children;if(o.length===0)return;let i=t.y+t.height,n=o[0];oe(e,t.centerX,i,n.y-2),le(e,n.centerX,n.y-1);for(let s=0;s<o.length;s++){let a=o[s];if(_e(e,a,r),s<o.length-1){let u=o[s+1];oe(e,a.centerX,a.bottomY+1,u.y-2),le(e,u.centerX,u.y-1)}}}var Rr={active:"\x1B[36m",closed:"\x1B[32m",error:"\x1B[31m"};function Ir(e,t){if(e.metadata?.heat!==void 0){let r=ke(e.metadata.heat);return ur[r]||void 0}return e.type==="stream"&&e.metadata?.streamState?Rr[e.metadata.streamState]||void 0:t[e.state]||void 0}function he(){return{name:"flowchart",supportsLive:!1,render(e,t){let r=t.terminalWidth??80,{nodes:o,totalHeight:i}=gr(e,t,r),n=fr(r,i);return vr(n,o,t),hr(n)}}}function Er(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function $r(e){let t=[];function r(o){for(let i of o)if(j(i))t.push(i);else if(et(i))r(i.children);else if(V(i)||F(i))r(i.children);else if(X(i))for(let n of i.branches)n.taken&&r(n.children)}return r(e),t}function Nr(e){let t={id:e.id,name:e.name??e.key??e.id,state:e.state};return e.key&&(t.key=e.key),e.durationMs!==void 0&&(t.durationMs=e.durationMs),e.startTs!==void 0&&(t.startTs=e.startTs),e.endTs!==void 0&&(t.endTs=e.endTs),e.retryCount!==void 0&&e.retryCount>0&&(t.retryCount=e.retryCount),e.timedOut&&(t.timedOut=!0,e.timeoutMs!==void 0&&(t.timeoutMs=e.timeoutMs)),e.error!==void 0&&(t.error=typeof e.error=="string"?e.error:String(e.error)),t}function Tr(e){let t=0,r=0,o=0,i=0,n=0,s;for(let a of e)a.state==="success"&&t++,a.state==="error"&&r++,a.state==="cached"&&o++,a.state==="skipped"&&i++,a.retryCount!==void 0&&(n+=a.retryCount),a.durationMs!==void 0&&(!s||a.durationMs>s.durationMs)&&(s={name:a.name??a.key??a.id,durationMs:a.durationMs});return{totalSteps:e.length,successCount:t,errorCount:r,cacheHits:o,skippedCount:i,totalRetries:n,slowestStep:s}}function Mr(e){let t={};if(e.shouldRun&&(t.shouldRun={result:e.shouldRun.context?.result,durationMs:e.shouldRun.durationMs},e.shouldRun.error!==void 0&&e.shouldRun.error!==null&&(t.shouldRun.error=String(e.shouldRun.error))),e.onBeforeStart&&(t.onBeforeStart={durationMs:e.onBeforeStart.durationMs},e.onBeforeStart.error!==void 0&&e.onBeforeStart.error!==null&&(t.onBeforeStart.error=String(e.onBeforeStart.error))),e.onAfterStep.size>0){t.onAfterStep=[];for(let[r,o]of e.onAfterStep){let i={stepKey:r};o.durationMs!==void 0&&(i.durationMs=o.durationMs),o.error!==void 0&&o.error!==null&&(i.error=String(o.error)),t.onAfterStep.push(i)}}return t}function Or(e,t){let r=e.root,o=$r(r.children),i=t.includeDiagram??!0,n=t.stripAnsiColors??!0,s={workflow:{id:r.workflowId,name:r.name,state:r.state,durationMs:r.durationMs,startedAt:r.startTs,completedAt:r.endTs},steps:o.map(Nr),summary:Tr(o)};if(e.hooks){let a=Mr(e.hooks);Object.keys(a).length>0&&(s.hooks=a)}if(i){let c=((t.diagramFormat??"ascii")==="flowchart"?he():ie()).render(e,t);n&&(c=Er(c)),s.diagram=c}return s}function We(){return{name:"logger",supportsLive:!1,render(e,t){let o=Or(e,t);return JSON.stringify(o)}}}import{ok as Ae,err as ve}from"awaitly";import Dr from"pako";var Cr=typeof globalThis<"u"&&"Buffer"in globalThis&&typeof globalThis.Buffer=="function";function Lr(e){let t;if(Cr)t=globalThis.Buffer.from(e).toString("base64");else{let r="";for(let o=0;o<e.length;o++)r+=String.fromCharCode(e[o]);t=btoa(r)}return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Be(e){let r=new TextEncoder().encode(e),o=Dr.deflate(r);return Lr(o)}var mt="https://kroki.io";function Ge(e,t,r,o={}){let i=o.baseUrl??mt,n=Be(r);return`${i}/${e}/${t}/${n}`}function ue(e,t="svg",r={}){let o=se(),i={showTimings:!0,showKeys:!1,terminalWidth:80,colors:z},n=o.render(e,i);return Ge("mermaid",t,n,r)}function _r(e,t={}){return ue(e,"svg",t)}function Wr(e,t={}){return ue(e,"png",t)}function Br(e={}){let t=e.baseUrl??mt;return{toUrl(r,o){return ue(r,o,{baseUrl:t})},toSvgUrl(r){return ue(r,"svg",{baseUrl:t})},toPngUrl(r){return ue(r,"png",{baseUrl:t})},toPdfUrl(r){return ue(r,"pdf",{baseUrl:t})},getBaseUrl(){return t}}}var ht="https://mermaid.ink";function gt(e){return`pako:${Be(e)}`}function Pr(e){if("provider"in e){let t=e;return{theme:t.mermaidTheme,bgColor:t.background,scale:t.scale,fit:t.fit,width:t.width,height:t.height,paper:t.paper,imageType:"png"}}return e}function Ar(e,t){let r=[];return t.bgColor&&r.push(`bgColor=${encodeURIComponent(t.bgColor)}`),t.theme&&r.push(`theme=${t.theme}`),t.width!==void 0&&r.push(`width=${t.width}`),t.height!==void 0&&r.push(`height=${t.height}`),t.scale!==void 0&&(t.width!==void 0||t.height!==void 0)&&r.push(`scale=${t.scale}`),e==="img"&&t.imageType&&t.imageType!=="jpeg"&&r.push(`type=${t.imageType}`),e==="pdf"&&(t.fit&&r.push("fit"),t.paper&&!t.fit&&r.push(`paper=${t.paper}`),t.landscape&&!t.fit&&r.push("landscape")),r.length>0?`?${r.join("&")}`:""}function Pe(e,t,r={}){let o=Pr(r),i=o.baseUrl??ht,n=gt(t),s=Ar(e,o);return`${i}/${e}/${n}${s}`}function G(e,t="svg",r={}){let o=se(),i={showTimings:!0,showKeys:!1,terminalWidth:80,colors:z},n=o.render(e,i);return Pe(t,n,r)}function Ur(e,t={}){return G(e,"svg",t)}function Hr(e,t={}){return G(e,"img",{...t,imageType:"png"})}function Fr(e,t={}){return G(e,"img",{...t,imageType:"jpeg"})}function zr(e,t={}){return G(e,"img",{...t,imageType:"webp"})}function Kr(e,t={}){return G(e,"pdf",t)}function jr(e={}){let t=e.baseUrl??ht;return{toUrl(r,o){return G(r,o,e)},toSvgUrl(r){return G(r,"svg",e)},toPngUrl(r){return G(r,"img",{...e,imageType:"png"})},toJpegUrl(r){return G(r,"img",{...e,imageType:"jpeg"})},toWebpUrl(r){return G(r,"img",{...e,imageType:"webp"})},toPdfUrl(r){return G(r,"pdf",e)},getBaseUrl(){return t},getOptions(){return{...e}}}}function Vr(e,t,r){return e==="mermaid-ink"&&t==="mermaid"?Ae(void 0):e==="kroki"&&t==="mermaid"?r==="pdf"?ve("UNSUPPORTED_FORMAT"):Ae(void 0):ve("UNSUPPORTED_FORMAT")}function Gr(e){switch(e){case"mermaid":return"mermaid";case"graphviz":return"graphviz";case"plantuml":return"plantuml"}}function Yr(e){switch(e){case"svg":return"svg";case"png":return"img";case"pdf":return"pdf"}}function xe(e,t,r,o={}){switch(e.kind){case"mermaid":break;case"graphviz":case"plantuml":return ve("UNSUPPORTED_DIAGRAM_KIND");default:{let n=e;return ve("UNSUPPORTED_DIAGRAM_KIND")}}let i=Vr(r.provider,e.kind,t);if(!i.ok)return i;switch(r.provider){case"kroki":return Ae(Ge(Gr(e.kind),t,e.source,r));case"mermaid-ink":return Ae(Pe(Yr(t),e.source,r));default:{let n=r;return ve("UNKNOWN_PROVIDER")}}}function wt(e){let t={bg:"#ffffff",bgSecondary:"#f8f9fa",text:"#212529",textMuted:"#6c757d",border:"#dee2e6",primary:"#0d6efd",success:"#198754",error:"#dc3545",warning:"#ffc107",info:"#0dcaf0",muted:"#6c757d",nodePending:"#e9ecef",nodeRunning:"#fff3cd",nodeSuccess:"#d1e7dd",nodeError:"#f8d7da",nodeAborted:"#e9ecef",nodeCached:"#cfe2ff",nodeSkipped:"#f8f9fa",heatCold:"#0d6efd",heatCool:"#0dcaf0",heatNeutral:"#6c757d",heatWarm:"#ffc107",heatHot:"#fd7e14",heatCritical:"#dc3545"},r={bg:"#212529",bgSecondary:"#343a40",text:"#f8f9fa",textMuted:"#adb5bd",border:"#495057",primary:"#0d6efd",success:"#198754",error:"#dc3545",warning:"#ffc107",info:"#0dcaf0",muted:"#6c757d",nodePending:"#495057",nodeRunning:"#664d03",nodeSuccess:"#0f5132",nodeError:"#842029",nodeAborted:"#495057",nodeCached:"#084298",nodeSkipped:"#343a40",heatCold:"#0d6efd",heatCool:"#0dcaf0",heatNeutral:"#6c757d",heatWarm:"#ffc107",heatHot:"#fd7e14",heatCritical:"#dc3545"},o=n=>`
|
|
1
|
+
function H(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFixed(1).replace(/\.0$/,"")}s`;let t=Math.floor(e/6e4),r=Math.round(e%6e4/1e3);return r>=60&&(t+=1,r=0),r===0?`${t}m`:`${t}m ${r}s`}function Re(){return`node_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function Nt(e){for(let t of e)if((t.type==="parallel"||t.type==="race"||t.type==="sequence")&&!t.id.startsWith("detected_")||t.type==="decision")return!0;return!1}function Ee(e,t={}){if(Nt(e))return e;let{minOverlapMs:r=0,maxGapMs:o=5}=t,a=[],n=[];for(let d=0;d<e.length;d++){let l=e[d];l.type==="step"&&l.startTs!==void 0?a.push({node:l,startTs:l.startTs,endTs:l.endTs??l.startTs+(l.durationMs??0),originalIndex:d}):n.push({node:l,originalIndex:d})}if(a.length<=1)return e;a.sort((d,l)=>d.startTs-l.startTs);let i=[],s=[a[0]];for(let d=1;d<a.length;d++){let l=a[d],p=Math.min(...s.map(M=>M.startTs)),f=Math.max(...s.map(M=>M.endTs)),m=l.startTs<=p+o,w=l.startTs<f;if(!m&&!w){i.push(s),s=[l];continue}let k=w?Math.min(l.endTs,f)-l.startTs:0;m||k>=r?s.push(l):(i.push(s),s=[l])}i.push(s);let u=[];for(let d of i){let l=Math.min(...d.map(p=>p.originalIndex));if(d.length===1)u.push({node:d[0].node,position:l});else{let p=d.map(k=>k.node),f=Math.min(...d.map(k=>k.startTs)),m=Math.max(...d.map(k=>k.endTs)),w={type:"parallel",id:`detected_parallel_${f}`,name:`${p.length} parallel steps`,state:Ot(p),mode:"all",children:p,startTs:f,endTs:m,durationMs:m-f};u.push({node:w,position:l})}}for(let{node:d,originalIndex:l}of n)u.push({node:d,position:l});return u.sort((d,l)=>d.position-l.position),u.map(d=>d.node)}function Ot(e){return e.some(n=>n.state==="error")?"error":e.some(n=>n.state==="running")?"running":e.some(n=>n.state==="pending")?"pending":(e.every(n=>n.state==="success"||n.state==="cached"),"success")}function Dt(e={}){return{detect:t=>Ee(t,e)}}function ce(e={}){let{detectParallel:t=!0,parallelDetection:r,enableSnapshots:o=!1,maxSnapshots:a=1e3}=e,n=o,i=Re(),s,u,d,l="pending",p,f,m=new Map,w=[],k=[],M=new Map,$=[],T=Date.now(),I=T,S={onAfterStep:new Map},x,g=[],y=0;function E(c){return c.stepId??c.stepKey??c.name??Re()}function C(c){if(w.length>0){w[w.length-1].children.push(c),I=Date.now();return}if(k.length>0){let b=k[k.length-1];for(let h of b.branches.values())if(h.taken){h.children.push(c),I=Date.now();return}b.pendingChildren.push(c),I=Date.now();return}$.push(c),I=Date.now()}function N(c){if(!n)return;let b=J(),h=new Map;for(let[W,q]of m)h.set(W,{id:q.id,name:q.name,key:q.key,startTs:q.startTs,retryCount:q.retryCount,timedOut:q.timedOut,timeoutMs:q.timeoutMs});let F={id:`snapshot_${y}`,eventIndex:y,event:structuredClone(c),ir:structuredClone(b),timestamp:Date.now(),activeSteps:h};g.push(F),g.length>a&&g.shift(),y++}function L(c){switch(c.type){case"workflow_start":{$=[],d=void 0,f=void 0,p=void 0,m.clear(),w.length=0,k.length=0,M.clear(),s=c.workflowId,u=c.ts,l="running",T=Date.now(),I=T,x!==void 0&&x!==c.workflowId&&(S.shouldRun=void 0,S.onBeforeStart=void 0),x=c.workflowId,S.onAfterStep=new Map;break}case"workflow_success":l="success",d=c.ts,f=c.durationMs,I=Date.now();break;case"workflow_error":l="error",d=c.ts,p=c.error,f=c.durationMs,I=Date.now();break;case"workflow_cancelled":l="aborted",d=c.ts,f=c.durationMs,I=Date.now();break;case"step_start":{let b=E(c);m.set(b,{id:b,name:c.name,key:c.stepKey,startTs:c.ts,retryCount:0,timedOut:!1}),I=Date.now();break}case"step_success":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"success",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_error":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"error",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,error:c.error,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_aborted":{let b=E(c),h=m.get(b);if(h){let F={type:"step",id:h.id,name:h.name,key:h.key,state:"aborted",startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,...h.retryCount>0&&{retryCount:h.retryCount},...h.timedOut&&{timedOut:!0,timeoutMs:h.timeoutMs}};C(F),m.delete(b)}break}case"step_cache_hit":{let h={type:"step",id:E(c),name:c.name,key:c.stepKey,state:"cached",startTs:c.ts,endTs:c.ts,durationMs:0};C(h);break}case"step_cache_miss":break;case"step_complete":break;case"step_timeout":{let b=E(c),h=m.get(b);h&&(h.timedOut=!0,h.timeoutMs=c.timeoutMs),I=Date.now();break}case"step_retry":{let b=E(c),h=m.get(b);h&&(h.retryCount=(c.attempt??1)-1),I=Date.now();break}case"step_retries_exhausted":I=Date.now();break;case"step_skipped":{let h={type:"step",id:E(c),name:c.name,key:c.stepKey,state:"skipped",startTs:c.ts,endTs:c.ts,durationMs:0};C(h);break}case"hook_should_run":{let b={type:"shouldRun",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};S.shouldRun=b,x=c.workflowId,I=Date.now();break}case"hook_should_run_error":{let b={type:"shouldRun",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error};S.shouldRun=b,x=c.workflowId,I=Date.now();break}case"hook_before_start":{let b={type:"onBeforeStart",state:"success",ts:c.ts,durationMs:c.durationMs,context:{result:c.result,skipped:c.skipped}};S.onBeforeStart=b,x=c.workflowId,I=Date.now();break}case"hook_before_start_error":{let b={type:"onBeforeStart",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error};S.onBeforeStart=b,x=c.workflowId,I=Date.now();break}case"hook_after_step":{let b={type:"onAfterStep",state:"success",ts:c.ts,durationMs:c.durationMs,context:{stepKey:c.stepKey}};S.onAfterStep.set(c.stepKey,b),I=Date.now();break}case"hook_after_step_error":{let b={type:"onAfterStep",state:"error",ts:c.ts,durationMs:c.durationMs,error:c.error,context:{stepKey:c.stepKey}};S.onAfterStep.set(c.stepKey,b),I=Date.now();break}case"stream_created":{let b=`${c.workflowId}:${c.namespace}`;M.set(b,{id:Re(),namespace:c.namespace,startTs:c.ts,writeCount:0,readCount:0,streamState:"active",backpressureOccurred:!1,finalPosition:0}),I=Date.now();break}case"stream_write":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);h&&(h.writeCount++,h.finalPosition=Math.max(h.finalPosition,c.position)),I=Date.now();break}case"stream_read":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);h&&h.readCount++,I=Date.now();break}case"stream_close":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);if(h){h.streamState="closed",h.finalPosition=c.finalPosition;let F={type:"stream",id:h.id,namespace:h.namespace,state:"success",startTs:h.startTs,endTs:c.ts,durationMs:c.ts-h.startTs,writeCount:h.writeCount,readCount:h.readCount,finalPosition:c.finalPosition,streamState:"closed",backpressureOccurred:h.backpressureOccurred};C(F),M.delete(b)}I=Date.now();break}case"stream_error":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);if(h){h.streamState="error";let F={type:"stream",id:h.id,namespace:h.namespace,state:"error",error:c.error,startTs:h.startTs,endTs:c.ts,durationMs:c.ts-h.startTs,writeCount:h.writeCount,readCount:h.readCount,finalPosition:c.position,streamState:"error",backpressureOccurred:h.backpressureOccurred};C(F),M.delete(b)}I=Date.now();break}case"stream_backpressure":{let b=`${c.workflowId}:${c.namespace}`,h=M.get(b);h&&(h.backpressureOccurred=!0),I=Date.now();break}}N(c)}function P(c){if(c.type==="scope_start")w.push({id:c.scopeId,name:c.name,type:c.scopeType,startTs:c.ts,children:[]}),I=Date.now();else if(c.type==="scope_end"){let b=w.findIndex(W=>W.id===c.scopeId);if(b===-1)return;for(;w.length>b+1;){let W=w.pop(),q=W.type==="race"?{type:"race",id:W.id,name:W.name,state:v(W.children),startTs:W.startTs,endTs:c.ts,children:W.children}:{type:"parallel",id:W.id,name:W.name,state:v(W.children),startTs:W.startTs,endTs:c.ts,children:W.children,mode:W.type==="allSettled"?"allSettled":"all"};w[w.length-1].children.push(q)}let[h]=w.splice(b,1),F=h.type==="race"?{type:"race",id:h.id,name:h.name,state:v(h.children),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,children:h.children,winnerId:c.winnerId}:{type:"parallel",id:h.id,name:h.name,state:v(h.children),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,children:h.children,mode:h.type==="allSettled"?"allSettled":"all"};C(F)}}function D(c){if(c.type==="decision_start")k.push({id:c.decisionId,name:c.name,condition:c.condition,decisionValue:c.decisionValue,startTs:c.ts,branches:new Map,pendingChildren:[]}),I=Date.now();else if(c.type==="decision_branch"){let b=k.find(h=>h.id===c.decisionId);if(b){let h=c.branchLabel,F=b.branches.get(h);if(F)F.taken=c.taken,c.taken&&b.pendingChildren.length>0&&(F.children.unshift(...b.pendingChildren),b.pendingChildren=[]);else{let W=c.taken?[...b.pendingChildren]:[];c.taken&&(b.pendingChildren=[]),b.branches.set(h,{label:c.branchLabel,condition:c.condition,taken:c.taken,children:W})}I=Date.now()}}else if(c.type==="decision_end"){let b=k.findIndex(h=>h.id===c.decisionId);if(b!==-1){let[h]=k.splice(b,1),F=k.splice(b),W=Array.from(h.branches.values());W.length===0&&h.pendingChildren.length>0&&(W=[{label:"default",taken:!0,children:[...h.pendingChildren]}]);let q=W.find(Ie=>Ie.taken)?.label,Tt={type:"decision",id:h.id,name:h.name,state:v(W.flatMap(Ie=>Ie.taken?Ie.children:[])),startTs:h.startTs,endTs:c.ts,durationMs:c.durationMs,condition:h.condition,decisionValue:h.decisionValue,branchTaken:c.branchTaken??q,branches:W};C(Tt),k.push(...F),I=Date.now()}}}function v(c){return c.length===0?"success":c.some(W=>W.state==="error")?"error":c.every(W=>W.state==="success"||W.state==="cached")?"success":c.some(W=>W.state==="running")?"running":"pending"}function O(){let c=[...$];for(let[,b]of m)c.push({type:"step",id:b.id,name:b.name,key:b.key,state:"running",startTs:b.startTs,...b.retryCount>0&&{retryCount:b.retryCount},...b.timedOut&&{timedOut:!0,timeoutMs:b.timeoutMs}});for(let[,b]of M)c.push({type:"stream",id:b.id,namespace:b.namespace,state:"running",startTs:b.startTs,writeCount:b.writeCount,readCount:b.readCount,finalPosition:b.finalPosition,streamState:b.streamState,backpressureOccurred:b.backpressureOccurred});return c}function J(){let c=O();t&&(c=Ee(c,r));let b={type:"workflow",id:s??i,workflowId:s??i,state:l,startTs:u,endTs:d,durationMs:f,children:c,error:p},h=S.shouldRun!==void 0||S.onBeforeStart!==void 0||S.onAfterStep.size>0;return{root:b,metadata:{createdAt:T,lastUpdatedAt:I},...h&&{hooks:S}}}function re(){s=void 0,u=void 0,d=void 0,l="pending",p=void 0,f=void 0,m.clear(),w.length=0,k.length=0,M.clear(),$=[],T=Date.now(),I=T,S={onAfterStep:new Map},x=void 0,g.length=0,y=0}function tt(){return[...g]}function be(c){return g[c]}function $t(c){return g[c]?.ir}function Mt(){g.length=0,y=0}return{handleEvent:L,handleScopeEvent:P,handleDecisionEvent:D,getIR:J,reset:re,getSnapshots:tt,getSnapshotAt:be,getIRAt:$t,clearSnapshots:Mt,get hasActiveSteps(){return m.size>0},get state(){return l},get snapshotCount(){return g.length},get snapshotsEnabled(){return n},setSnapshotsEnabled(c){n=c}}}import{ok as Ht,err as Ft}from"awaitly";function V(e){return e.type==="step"}function rt(e){return e.type==="sequence"}function G(e){return e.type==="parallel"}function z(e){return e.type==="race"}function X(e){return e.type==="decision"}function ne(e){return e.type==="stream"}function wn(e){return"children"in e||e.type==="decision"&&"branches"in e}var Fe="\x1B[0m",Ct="\x1B[1m",ot="\x1B[2m",Lt="\x1B[31m",_t="\x1B[32m",Wt="\x1B[33m",Bt="\x1B[34m",nt="\x1B[90m",At="\x1B[37m";function Z(e,t){return t?`${t}${e}${Fe}`:e}function we(e){return`${Ct}${e}${Fe}`}function _(e){return`${ot}${e}${Fe}`}var K={pending:At,running:Wt,success:_t,error:Lt,aborted:nt,cached:Bt,skipped:ot+nt};function Pt(e){switch(e){case"pending":return"\u25CB";case"running":return"\u27F3";case"success":return"\u2713";case"error":return"\u2717";case"aborted":return"\u2298";case"cached":return"\u21BA";case"skipped":return"\u2298"}}function ye(e,t){let r=Pt(e);return Z(r,t[e])}function $e(e,t,r){return Z(e,r[t])}function te(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}var R={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",teeRight:"\u251C",teeLeft:"\u2524",teeDown:"\u252C",teeUp:"\u2534",cross:"\u253C"},pe={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},Ut="\x1B[0m";function zt(e){return e<.2?pe.cold:e<.4?pe.cool:e<.6?pe.neutral:e<.8?pe.warm:e<.95?pe.hot:pe.critical}function at(e,t){let r=zt(t);return r?`${r}${e}${Ut}`:e}function Kt(e){try{return Ht(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let a=Number(o);return Number.isSafeInteger(a)?a:o.toString()}))}catch{return Ft("STRINGIFY_ERROR")}}function it(e){let t=Kt(e);return t.ok?t.value:"[unserializable]"}var st="\u2581\u2582\u2583\u2584\u2585\u2586\u2587\u2588";function ze(e,t=10){if(e.length===0)return"";let r=e.slice(-t),o=Math.min(...r),n=Math.max(...r)-o||1;return r.map(i=>{let s=(i-o)/n,u=Math.floor(s*(st.length-1));return st[u]}).join("")}function Ue(e,t){let r=te(e).length,o=Math.max(0,t-r);return e+" ".repeat(o)}function jt(e,t){if(!t)return R.horizontal.repeat(e);let r=` ${t} `,o=te(r).length,a=e-o;if(a<4)return R.horizontal.repeat(e);let n=2,i=a-n;return R.horizontal.repeat(n)+r+R.horizontal.repeat(i)}function dt(e,t,r){let o=e.state==="success"?Z("\u2699",r.success):Z("\u26A0",r.error),a=e.durationMs!==void 0?_(` [${H(e.durationMs)}]`):"",n="";e.type==="shouldRun"&&e.context?.skipped?n=_(" \u2192 workflow skipped"):e.type==="shouldRun"&&e.context?.result===!0?n=_(" \u2192 proceed"):e.type==="onBeforeStart"&&e.context?.skipped?n=_(" \u2192 workflow skipped"):e.type==="onAfterStep"&&e.context?.stepKey&&(n=_(` (${e.context.stepKey})`));let i=e.state==="error"&&e.error?_(` error: ${String(e.error)}`):"";return`${o} ${_(t)}${n}${a}${i}`}function Vt(e,t){let r=[];return e.shouldRun&&r.push(dt(e.shouldRun,"shouldRun",t)),e.onBeforeStart&&r.push(dt(e.onBeforeStart,"onBeforeStart",t)),r.length>0&&r.push(_("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),r}function ae(){return{name:"ascii",supportsLive:!0,render(e,t){let r={...K,...t.colors},o=Math.max(t.terminalWidth??60,5),a=o-4,n=[],i=e.root.name??"workflow",s=we(i);if(n.push(`${R.topLeft}${jt(o-2,s)}${R.topRight}`),n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.hooks){let d=Vt(e.hooks,r);for(let l of d)n.push(`${R.vertical} ${Ue(l,a)}${R.vertical}`)}let u=Me(e.root.children,t,r,0,e.hooks);for(let d of u)n.push(`${R.vertical} ${Ue(d,a)}${R.vertical}`);if(n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`),e.root.durationMs!==void 0&&t.showTimings){let d=e.root.state==="success"?"Completed":e.root.state==="aborted"?"Cancelled":"Failed",p=`${$e(d,e.root.state,r)} in ${H(e.root.durationMs)}`;n.push(`${R.vertical} ${Ue(p,a)}${R.vertical}`),n.push(`${R.vertical}${" ".repeat(o-2)}${R.vertical}`)}return n.push(`${R.bottomLeft}${R.horizontal.repeat(o-2)}${R.bottomRight}`),n.join(`
|
|
2
|
+
`)}}}function Me(e,t,r,o,a){let n=[];for(let i of e)V(i)?n.push(Ke(i,t,r,a)):G(i)?n.push(...Yt(i,t,r,o,a)):z(i)?n.push(...Jt(i,t,r,o,a)):X(i)?n.push(...qt(i,t,r,o,a)):ne(i)&&n.push(Gt(i,t,r));return n}function Ke(e,t,r,o){let a=ye(e.state,r),n=e.name??e.key??"step",i=t,s=i.showHeatmap&&i.heatmapData?i.heatmapData.heat.get(e.key??"")??i.heatmapData.heat.get(e.name??"")??i.heatmapData.heat.get(e.id):void 0,u;s!==void 0?u=at(n,s):u=$e(n,e.state,r);let d=`${a} ${u}`;if(t.showKeys&&e.key&&e.name&&(d+=_(` [key: ${e.key}]`)),e.input!==void 0){let p=typeof e.input=="string"?e.input:it(e.input).slice(0,30);d+=_(` [in: ${p}${p.length>=30?"...":""}]`)}if(e.output!==void 0&&e.state==="success"){let p=typeof e.output=="string"?e.output:it(e.output).slice(0,30);d+=_(` [out: ${p}${p.length>=30?"...":""}]`)}if(t.showTimings&&e.durationMs!==void 0){let p=H(e.durationMs),f=s!==void 0?at(`[${p}]`,s):_(`[${p}]`);d+=` ${f}`}if(i.showSparklines&&i.timingHistory){let p=i.timingHistory.get(e.key??"")??i.timingHistory.get(e.name??"")??i.timingHistory.get(e.id);p&&p.length>1&&(d+=` ${_(ze(p))}`)}if(e.retryCount!==void 0&&e.retryCount>0&&(d+=_(` [${e.retryCount} ${e.retryCount===1?"retry":"retries"}]`)),e.timedOut){let p=e.timeoutMs!==void 0?` ${e.timeoutMs}ms`:"";d+=_(` [timeout${p}]`)}let l=e.key??e.id;if(o&&l&&o.onAfterStep.has(l)){let p=o.onAfterStep.get(l),f=p.state==="success"?Z("\u2699",r.success):Z("\u26A0",r.error),m=p.durationMs!==void 0?_(` ${H(p.durationMs)}`):"";d+=` ${f}${m}`}return d}function Gt(e,t,r){let o=e.streamState==="active"?Z("\u27F3",r.running):e.streamState==="closed"?Z("\u2713",r.success):Z("\u2717",r.error),a=`stream:${e.namespace}`,n=$e(a,e.state,r),i=_(`[W:${e.writeCount} R:${e.readCount}]`),s=`${o} ${n} ${i}`;return t.showTimings&&e.durationMs!==void 0&&(s+=` ${_(`[${H(e.durationMs)}]`)}`),e.backpressureOccurred&&(s+=_(" [backpressure]")),e.streamState==="closed"&&(s+=_(` pos:${e.finalPosition}`)),s}function Yt(e,t,r,o,a){let n=[],i=" ".repeat(o),s=ye(e.state,r),u=e.name??"parallel",d=e.mode==="allSettled"?" (allSettled)":"";if(n.push(`${i}${R.teeRight}${R.teeDown}${R.horizontal} ${s} ${we(u)}${d}`),e.children.length===0)n.push(`${i}${R.vertical} ${_("(operations not individually tracked)")}`),n.push(`${i}${R.vertical} ${_("(wrap each operation with step() to see individual steps)")}`);else for(let l=0;l<e.children.length;l++){let p=e.children[l],m=l===e.children.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`;if(V(p))n.push(`${m} ${Ke(p,t,r,a)}`);else{let w=Me([p],t,r,o+1,a);for(let k of w)n.push(`${i}${R.vertical} ${k}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}function Jt(e,t,r,o,a){let n=[],i=" ".repeat(o),s=ye(e.state,r),u=e.name??"race";if(n.push(`${i}${R.teeRight}\u26A1 ${s} ${we(u)}`),e.children.length===0)n.push(`${i}${R.vertical} ${_("(operations not individually tracked)")}`),n.push(`${i}${R.vertical} ${_("(wrap each operation with step() to see individual steps)")}`);else for(let d=0;d<e.children.length;d++){let l=e.children[d],f=d===e.children.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`,w=e.winnerId&&l.id===e.winnerId?_(" (winner)"):"";if(V(l))n.push(`${f} ${Ke(l,t,r,a)}${w}`);else{let k=Me([l],t,r,o+1,a);for(let M of k)n.push(`${i}${R.vertical} ${M}`)}}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}function qt(e,t,r,o,a){let n=[],i=" ".repeat(o),s=ye(e.state,r),u=e.name??"decision",d=e.condition?_(` (${e.condition})`):"",l=e.decisionValue!==void 0?_(` = ${String(e.decisionValue)}`):"",p=e.branchTaken!==void 0?_(` \u2192 ${String(e.branchTaken)}`):"";n.push(`${i}${R.teeRight}${R.teeDown}${R.horizontal} ${s} ${we(u)}${d}${l}${p}`);for(let f=0;f<e.branches.length;f++){let m=e.branches[f],k=f===e.branches.length-1?`${i}${R.vertical} ${R.bottomLeft}`:`${i}${R.vertical} ${R.teeRight}`,M=m.taken?"\u2713":"\u2298",$=m.taken?r.success:r.skipped,T=Z(`${M} ${m.label}`,$),I=m.condition?_(` (${m.condition})`):"";if(n.push(`${k} ${T}${I}`),m.children.length>0){let S=Me(m.children,t,r,o+1,a);for(let x of S)n.push(`${i}${R.vertical} ${x}`)}else m.taken||n.push(`${i}${R.vertical} ${_("(skipped)")}`)}return t.showTimings&&e.durationMs!==void 0&&n.push(`${i}${R.bottomLeft}${R.horizontal}${R.horizontal} ${_(`[${H(e.durationMs)}]`)}`),n}import{ok as Zt,err as Qt}from"awaitly";function je(e){let t=[];for(let r of e)if(t.push(r),"children"in r&&Array.isArray(r.children)&&t.push(...je(r.children)),"branches"in r)for(let o of r.branches)t.push(...je(o.children));return t}function Te(e,t){if(e.length===0)return 0;let r=Math.floor(e.length*t);return e[Math.min(r,e.length-1)]}function ve(e){return e<.2?"cold":e<.4?"cool":e<.6?"neutral":e<.8?"warm":e<.95?"hot":"critical"}function Xt(){let e=new Map,t=new Map,r=new Map,o=new Map,a=[];function n(S){return S.stepKey??S.stepId??S.name??"unknown"}function i(S){let x=new Map;for(let g of S)switch(g.type){case"step_start":{let y=n(g);x.set(y,{retried:!1,timedOut:!1});break}case"step_retry":{let y=n(g),E=x.get(y);E&&(E.retried=!0);break}case"step_timeout":{let y=n(g),E=x.get(y);E&&(E.timedOut=!0);break}case"step_success":{let y=n(g),E=x.get(y),C=e.get(y)??[];C.push(g.durationMs),e.set(y,C);let N=t.get(y)??{retried:0,total:0};N.total++,E?.retried&&N.retried++,t.set(y,N);let L=o.get(y)??{timedOut:0,total:0};L.total++,E?.timedOut&&L.timedOut++,o.set(y,L);let P=r.get(y)??{errors:0,total:0};P.total++,r.set(y,P),x.delete(y);break}case"step_error":{let y=n(g),E=x.get(y),C=e.get(y)??[];C.push(g.durationMs),e.set(y,C);let N=t.get(y)??{retried:0,total:0};N.total++,E?.retried&&N.retried++,t.set(y,N);let L=o.get(y)??{timedOut:0,total:0};L.total++,E?.timedOut&&L.timedOut++,o.set(y,L);let P=r.get(y)??{errors:0,total:0};P.total++,P.errors++,r.set(y,P),x.delete(y);break}}}function s(S){i(S.events)}function u(S){a.push(S)}function d(S){a.length>0&&(i(a),a=[])}function l(S){let x=e.get(S);if(!x||x.length===0)return;let g=[...x].sort((D,v)=>D-v),E=g.reduce((D,v)=>D+v,0)/g.length,C=g.reduce((D,v)=>D+(v-E)**2,0)/g.length,N=t.get(S)??{retried:0,total:1},L=r.get(S)??{errors:0,total:1},P=o.get(S)??{timedOut:0,total:1};return{nodeId:S,avgDurationMs:E,minDurationMs:g[0],maxDurationMs:g[g.length-1],stdDevMs:Math.sqrt(C),samples:g.length,retryRate:N.total>0?N.retried/N.total:0,timeoutRate:P.total>0?P.timedOut/P.total:0,errorRate:L.total>0?L.errors/L.total:0,percentiles:{p50:Te(g,.5),p90:Te(g,.9),p95:Te(g,.95),p99:Te(g,.99)}}}function p(S){return l(S)}function f(S,x="duration"){let g=new Map,y=je(S.root.children),E=[];for(let v of y){let O=("key"in v?v.key:void 0)??v.id??v.name,J=l(O);if(J){let re;switch(x){case"duration":re=J.avgDurationMs;break;case"retryRate":re=J.retryRate;break;case"errorRate":re=J.errorRate;break}E.push({id:v.id,value:re})}}if(E.length===0)return{heat:g,metric:x,stats:{min:0,max:0,mean:0,threshold:0}};let C=E.map(v=>v.value),N=Math.min(...C),L=Math.max(...C),P=C.reduce((v,O)=>v+O,0)/C.length,D=L-N||1;for(let{id:v,value:O}of E)g.set(v,(O-N)/D);return{heat:g,metric:x,stats:{min:N,max:L,mean:P,threshold:P+(L-P)*.5}}}function m(){let S=new Map;for(let x of e.keys()){let g=l(x);g&&S.set(x,g)}return S}function w(S=10){return[...m().values()].sort((g,y)=>y.avgDurationMs-g.avgDurationMs).slice(0,S)}function k(S=10){return[...m().values()].filter(g=>g.errorRate>0).sort((g,y)=>y.errorRate-g.errorRate).slice(0,S)}function M(S=10){return[...m().values()].filter(g=>g.retryRate>0).sort((g,y)=>y.retryRate-g.retryRate).slice(0,S)}function $(){return JSON.stringify({timingData:Object.fromEntries(e),retryData:Object.fromEntries(t),errorData:Object.fromEntries(r),timeoutData:Object.fromEntries(o)})}function T(S){let x=JSON.parse(S);e.clear(),t.clear(),r.clear(),o.clear();for(let[g,y]of Object.entries(x.timingData??{}))e.set(g,y);for(let[g,y]of Object.entries(x.retryData??{}))t.set(g,y);for(let[g,y]of Object.entries(x.errorData??{}))r.set(g,y);for(let[g,y]of Object.entries(x.timeoutData??{}))o.set(g,y)}function I(){e.clear(),t.clear(),r.clear(),o.clear(),a=[]}return{addRun:s,addEvent:u,finalizeRun:d,getNodePerformance:p,getHeatmap:f,getSlowestNodes:w,getErrorProneNodes:k,getRetryProneNodes:M,getAllPerformance:m,exportData:$,importData:T,clear:I}}function er(){return[" classDef pending fill:#f3f4f6,stroke:#9ca3af,stroke-width:2px,color:#374151"," classDef running fill:#fef3c7,stroke:#f59e0b,stroke-width:3px,color:#92400e"," classDef success fill:#d1fae5,stroke:#10b981,stroke-width:3px,color:#065f46"," classDef error fill:#fee2e2,stroke:#ef4444,stroke-width:3px,color:#991b1b"," classDef aborted fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#4b5563,stroke-dasharray: 5 5"," classDef cached fill:#dbeafe,stroke:#3b82f6,stroke-width:3px,color:#1e40af"," classDef skipped fill:#f9fafb,stroke:#d1d5db,stroke-width:2px,color:#6b7280,stroke-dasharray: 5 5"," classDef stream fill:#ede9fe,stroke:#8b5cf6,stroke-width:3px,color:#5b21b6"," classDef streamActive fill:#ddd6fe,stroke:#7c3aed,stroke-width:3px,color:#4c1d95"," classDef streamError fill:#fce7f3,stroke:#db2777,stroke-width:3px,color:#9d174d"]}function tr(){return[" classDef heat_cold fill:#dbeafe,stroke:#3b82f6,stroke-width:2px,color:#1e40af"," classDef heat_cool fill:#ccfbf1,stroke:#14b8a6,stroke-width:2px,color:#0f766e"," classDef heat_neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#374151"," classDef heat_warm fill:#fef3c7,stroke:#f59e0b,stroke-width:2px,color:#92400e"," classDef heat_hot fill:#fed7aa,stroke:#f97316,stroke-width:3px,color:#c2410c"," classDef heat_critical fill:#fecaca,stroke:#ef4444,stroke-width:3px,color:#b91c1c"]}function rr(e){return`heat_${e}`}function nr(){return[" classDef hook_success fill:#e0f2fe,stroke:#0284c7,stroke-width:2px,color:#0c4a6e"," classDef hook_error fill:#fef2f2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d"]}function or(e){try{return Zt(JSON.stringify(e,(r,o)=>{if(typeof o!="bigint")return o;let a=Number(o);return Number.isSafeInteger(a)?a:o.toString()}))}catch{return Qt("STRINGIFY_ERROR")}}function ct(e){let t=or(e);return t.ok?t.value:"[unserializable]"}function ar(e,t,r){let o;if(e.shouldRun){let a="hook_shouldRun",n=e.shouldRun.state==="success"?"hook_success":"hook_error",i=e.shouldRun.state==="success"?"\u2699":"\u26A0",s=r.showTimings&&e.shouldRun.durationMs!==void 0?` ${H(e.shouldRun.durationMs)}`:"",u=e.shouldRun.context?.skipped?"\\nskipped workflow":e.shouldRun.context?.result===!0?"\\nproceed":"";t.push(` ${a}[["${i} shouldRun${u}${s}"]]:::${n}`),o=a}if(e.onBeforeStart){let a="hook_beforeStart",n=e.onBeforeStart.state==="success"?"hook_success":"hook_error",i=e.onBeforeStart.state==="success"?"\u2699":"\u26A0",s=r.showTimings&&e.onBeforeStart.durationMs!==void 0?` ${H(e.onBeforeStart.durationMs)}`:"",u=e.onBeforeStart.context?.skipped?"\\nskipped workflow":"";t.push(` ${a}[["${i} onBeforeStart${u}${s}"]]:::${n}`),o&&t.push(` ${o} --> ${a}`),o=a}return{lastHookId:o}}var lt=0,Ne=new Set,Oe=new Set;function me(e="node"){return`${e}_${++lt}`}function ir(){lt=0,Ne.clear(),Oe.clear()}function j(e){return e.replace(/"/g,"#quot;").replace(/</g,"<").replace(/>/g,">").trim()}function ut(e){return j(e).replace(/[{}[\]()]/g,"")}function ie(){return{name:"mermaid",supportsLive:!1,render(e,t){ir();let r=[],o=t;r.push("flowchart TD");let a;e.hooks&&(a=ar(e.hooks,r,t).lastHookId);let n="start";r.push(` ${n}(("\u25B6 Start"))`),a&&r.push(` ${a} --> ${n}`);let i=n;for(let u of e.root.children){let d=De(u,t,r,o,e.hooks);r.push(` ${i} --> ${d.entryId}`),i=d.exitId}if(["success","error","aborted"].includes(e.root.state)){let u="finish",d=e.root.state==="success"?"\u2713":e.root.state==="error"?"\u2717":"\u2298",l=e.root.state==="success"?"Done":e.root.state==="error"?"Failed":"Cancelled",p=`(("${d} ${l}"))`,f=e.root.state==="success"?":::success":e.root.state==="error"?":::error":":::aborted";r.push(` ${u}${p}${f}`),r.push(` ${i} --> ${u}`)}return r.push(""),r.push(...er()),o.showHeatmap&&r.push(...tr()),e.hooks&&r.push(...nr()),r.join(`
|
|
3
|
+
`)}}}function De(e,t,r,o,a){if(V(e))return sr(e,t,r,o,a);if(G(e))return dr(e,t,r,o,a);if(z(e))return cr(e,t,r,o,a);if(X(e))return lr(e,t,r,o,a);if(ne(e))return ur(e,t,r);let n=me("unknown");return r.push(` ${n}["Unknown Node"]`),{entryId:n,exitId:n}}function sr(e,t,r,o,a){let n=t,i=n.showRetryEdges??!0,s=n.showErrorEdges??!0,u=n.showTimeoutEdges??!0,d=e.key?`step_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:me("step");if(Oe.has(d)){let g=2;for(;Oe.has(`${d}_${g}`);)g++;d=`${d}_${g}`}Oe.add(d);let l=e.name??e.key??"Step",p=t.showKeys&&e.key&&e.name?`${l} [${e.key}]`:l,f=j(p),m=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"",w="";switch(e.state){case"success":w="\u2713 ";break;case"error":w="\u2717 ";break;case"cached":w="\u{1F4BE} ";break;case"running":w="\u23F3 ";break;case"skipped":w="\u2298 ";break}let k="";if(e.input!==void 0){let g=typeof e.input=="string"?j(e.input):j(ct(e.input).slice(0,20));k+=`\\nin: ${g}`}if(e.output!==void 0&&e.state==="success"){let g=typeof e.output=="string"?j(e.output):j(ct(e.output).slice(0,20));k+=`\\nout: ${g}`}let M="",$=e.key??e.id;if(a&&$&&a.onAfterStep.has($)){let g=a.onAfterStep.get($),y=g.state==="success"?"\u2699":"\u26A0",E=t.showTimings&&g.durationMs!==void 0?` ${H(g.durationMs)}`:"";M=`\\n${y} hook${E}`}let T=(w+f+k+M+m).trim(),I,S=o?.showHeatmap&&o.heatmapData?o.heatmapData.heat.get(e.key??"")??o.heatmapData.heat.get(e.name??"")??o.heatmapData.heat.get(e.id):void 0;if(S!==void 0){let g=ve(S);I=rr(g)}else I=e.state;let x;switch(e.state){case"error":x=`{{"${T}"}}`;break;case"cached":x=`[("${T}")]`;break;case"skipped":x=`["${T}"]`;break;default:x=`["${T}"]`}if(r.push(` ${d}${x}:::${I}`),i&&e.retryCount!==void 0&&e.retryCount>0){let g=`\u21BB ${e.retryCount} retr${e.retryCount===1?"y":"ies"}`;r.push(` ${d} -.->|"${g}"| ${d}`)}if(s&&e.state==="error"&&e.error!==void 0){let g=`ERR_${d}`,y=j(String(e.error)).slice(0,30);r.push(` ${g}{{"${y}"}}`),r.push(` ${d} -->|error| ${g}`),r.push(` style ${g} fill:#fee2e2,stroke:#dc2626`)}if(u&&e.timedOut){let g=`TO_${d}`,y=e.timeoutMs!==void 0?`${e.timeoutMs}ms`:"";r.push(` ${g}{{"\u23F1 Timeout ${y}"}}`),r.push(` ${d} -.->|timeout| ${g}`),r.push(` style ${g} fill:#fef3c7,stroke:#f59e0b`)}return{entryId:d,exitId:d}}function dr(e,t,r,o,a){let n=me("parallel"),i=`${n}_fork`,s=`${n}_join`,u=ut(e.name??"Parallel"),d=e.mode==="allSettled"?" (allSettled)":"";if(e.children.length===0){let f=n,m=j(`${u}${d}`),w="operations not individually tracked",k=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"";return r.push(` ${f}["${m}${k}\\n${w}"]:::${e.state}`),{entryId:f,exitId:f}}r.push(` subgraph ${n}["${u}${d}"]`),r.push(" direction TB"),r.push(` ${i}{"\u26A1 Fork"}`);let l=[];for(let f of e.children){let m=De(f,t,r,o,a);r.push(` ${i} --> ${m.entryId}`),l.push(m.exitId)}r.push(` ${s}{"\u2713 Join"}`);for(let f of l)r.push(` ${f} --> ${s}`);r.push(" end");let p=e.state;return r.push(` class ${n} ${p}`),{entryId:i,exitId:s}}function cr(e,t,r,o,a){let n=me("race"),i=`${n}_start`,s=`${n}_end`,u=ut(e.name??"Race");if(e.children.length===0){let f=n,m=j(u),w="operations not individually tracked",k=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"";return r.push(` ${f}["\u26A1 ${m}${k}\\n${w}"]:::${e.state}`),{entryId:f,exitId:f}}r.push(` subgraph ${n}["\u26A1 ${u}"]`),r.push(" direction TB"),r.push(` ${i}(("\u{1F3C1} Start"))`);let d=[],l;for(let f of e.children){let m=De(f,t,r,o,a),w=e.winnerId===f.id;r.push(` ${i} --> ${m.entryId}`),w&&(l=m.exitId),d.push({exitId:m.exitId,isWinner:w})}r.push(` ${s}(("\u2713 First"))`);for(let{exitId:f,isWinner:m}of d)m&&l?r.push(` ${f} ==>|\u{1F3C6} Winner| ${s}`):e.winnerId?r.push(` ${f} -. cancelled .-> ${s}`):r.push(` ${f} --> ${s}`);r.push(" end");let p=e.state;return r.push(` class ${n} ${p}`),{entryId:i,exitId:s}}function lr(e,t,r,o,a){let n=e.key?`decision_${e.key.replace(/[^a-zA-Z0-9]/g,"_")}`:me("decision");if(Ne.has(n)){let f=2;for(;Ne.has(`${n}_${f}`);)f++;n=`${n}_${f}`}Ne.add(n);let i=j(e.condition??"condition"),s=e.decisionValue!==void 0?` = ${j(String(e.decisionValue)).slice(0,30)}`:"",u=`${i}${s}`.trim();r.push(` ${n}{"${u}"}`);let d=[],l,p=new Set;for(let f of e.branches){let m=`${n}_${f.label.replace(/[^a-zA-Z0-9]/g,"_")}`;if(p.has(m)){let T=2;for(;p.has(`${m}_${T}`);)T++;m=`${m}_${T}`}p.add(m);let w=j(f.label),k=f.taken?`${w} \u2713`:`${w} skipped`,M=f.taken?":::success":":::skipped";r.push(` ${m}["${k}"]${M}`);let $=f.condition?`|${j(f.condition).replace(/\|/g,"")}|`:"";if(r.push(` ${n} -->${$} ${m}`),f.children.length>0){let T=m;for(let I of f.children){let S=De(I,t,r,o,a);r.push(` ${T} --> ${S.entryId}`),T=S.exitId}d.push(T),f.taken&&(l=T)}else d.push(m),f.taken&&(l=m)}return l?{entryId:n,exitId:l}:{entryId:n,exitId:n}}function ur(e,t,r){let o=`stream_${e.namespace.replace(/[^a-zA-Z0-9]/g,"_")}_${me("")}`,a=`W:${e.writeCount} R:${e.readCount}`,n="";switch(e.streamState){case"active":n="\u27F3 ";break;case"closed":n="\u2713 ";break;case"error":n="\u2717 ";break}let i=t.showTimings&&e.durationMs!==void 0?` ${H(e.durationMs)}`:"",s=e.backpressureOccurred?"\\nbackpressure":"",u=`${n}stream:${j(e.namespace)}\\n${a}${s}${i}`,d;return e.streamState==="error"?d="streamError":e.streamState==="active"?d="streamActive":d="stream",r.push(` ${o}{{"${u}"}}:::${d}`),{entryId:o,exitId:o}}var B={topLeft:"\u250C",topRight:"\u2510",bottomLeft:"\u2514",bottomRight:"\u2518",horizontal:"\u2500",vertical:"\u2502",teeDown:"\u252C",teeUp:"\u2534",teeRight:"\u251C",teeLeft:"\u2524",cross:"\u253C",arrowDown:"\u25BC",arrowUp:"\u25B2"},pr={cold:"\x1B[34m",cool:"\x1B[36m",neutral:"",warm:"\x1B[33m",hot:"\x1B[31m",critical:"\x1B[41m"},mr="\x1B[0m";function fr(e,t){let r=[],o=[];for(let a=0;a<t;a++)r.push(Array(e).fill(" ")),o.push(Array(e).fill(void 0));return{cells:r,colors:o,width:e,height:t}}function A(e,t,r,o,a){t>=0&&t<e.width&&r>=0&&r<e.height&&(e.cells[r][t]=o,a&&(e.colors[r][t]=a))}function ft(e,t,r){return t>=0&&t<e.width&&r>=0&&r<e.height?e.cells[r][t]:" "}function hr(e,t,r,o,a){A(e,t,r,B.topLeft);for(let n=1;n<o-1;n++)A(e,t+n,r,B.horizontal);A(e,t+o-1,r,B.topRight);for(let n=1;n<a-1;n++)A(e,t,r+n,B.vertical),A(e,t+o-1,r+n,B.vertical);A(e,t,r+a-1,B.bottomLeft);for(let n=1;n<o-1;n++)A(e,t+n,r+a-1,B.horizontal);A(e,t+o-1,r+a-1,B.bottomRight)}function pt(e,t,r,o,a){let n=te(o).split("");for(let i=0;i<n.length;i++)A(e,t+i,r,n[i],a)}function oe(e,t,r,o){let a=Math.min(r,o),n=Math.max(r,o);for(let i=a;i<=n;i++){let s=ft(e,t,i);s===B.horizontal?A(e,t,i,B.cross):(s===" "||s===B.vertical)&&A(e,t,i,B.vertical)}}function mt(e,t,r,o){let a=Math.min(r,o),n=Math.max(r,o);for(let i=a;i<=n;i++){let s=ft(e,i,t);s===B.vertical?A(e,i,t,B.cross):(s===" "||s===B.horizontal)&&A(e,i,t,B.horizontal)}}function le(e,t,r){A(e,t,r,B.arrowDown)}function gr(e){let t=[];for(let r=0;r<e.height;r++){let o="";for(let a=0;a<e.width;a++){let n=e.colors[r][a],i=e.cells[r][a];n?o+=n+i+mr:o+=i}t.push(o.trimEnd())}for(;t.length>0&&t[t.length-1]==="";)t.pop();return t.join(`
|
|
4
|
+
`)}var Q=11,ee=2,fe=2,Ce=3;function Ge(e,t){if(e.length<=t)return[e];let r=e.split(" "),o=[],a="";for(let n of r)a?a.length+1+n.length<=t?a+=" "+n:(o.push(a),a=n):a=n;if(a&&o.push(a),o.length===0)for(let n=0;n<e.length;n+=t)o.push(e.slice(n,n+t));return o}function ht(e){switch(e){case"success":return"\u2713";case"error":return"\u2717";case"running":return"\u27F3";case"pending":return"\u25CB";case"aborted":case"skipped":return"\u2298";case"cached":return"\u21BA";default:return"\u25CB"}}function br(e,t,r){let o=t.showStartEnd??!0,a=t,n=Math.floor(r/2),i=[],s=0;if(o){let d=Le("start","start",["\u25B6 Start"],"success",n,s);i.push(d),s=d.bottomY+fe}for(let d of e.root.children){let l=_e(d,n,s,r-4,t,a);i.push(l.node),s=l.bottomY+fe}if(o&&["success","error","aborted"].includes(e.root.state)){let d=e.root.state==="success"?"\u2713 Done":e.root.state==="error"?"\u2717 Failed":"\u2298 Cancelled",l=Le("end","end",[d],e.root.state,n,s);i.push(l),s=l.bottomY}return{nodes:i,totalHeight:s+2}}function Le(e,t,r,o,a,n){let i=Math.max(...r.map(l=>te(l).length)),s=Math.max(Q,i+ee*2),u=r.length+2,d=a-Math.floor(s/2);return{id:e,type:t,label:r,state:o,x:d,y:n,width:s,height:u,centerX:a,bottomY:n+u-1}}function _e(e,t,r,o,a,n){if(V(e))return wr(e,t,r,o,a,n);if(G(e)||z(e))return vr(e,t,r,o,a,n);if(X(e))return kr(e,t,r,o,a,n);if(ne(e))return yr(e,t,r,o,a,n);let i=Le(e.id,"step",["?"],e.state,t,r);return{node:i,bottomY:i.bottomY}}function wr(e,t,r,o,a,n){let i=e.name??e.key??"step",s=ht(e.state),u=[],d=`${s} ${i}`;a.showKeys&&e.key&&e.name&&(d+=` [${e.key}]`);let l=Math.min(o-ee*2,40);if(u.push(...Ge(d,l)),a.showTimings&&e.durationMs!==void 0&&u.push(`[${H(e.durationMs)}]`),e.retryCount&&e.retryCount>0&&u.push(`${e.retryCount}x retry`),e.timedOut&&u.push("timeout"),n?.showSparklines&&n.timingHistory){let $=n.timingHistory.get(e.key??"")??n.timingHistory.get(e.name??"")??n.timingHistory.get(e.id);$&&$.length>1&&u.push(ze($,8))}let p=Math.max(...u.map($=>te($).length)),f=Math.max(Q,p+ee*2),m=u.length+2,w=t-Math.floor(f/2),k;if(n?.showHeatmap&&n.heatmapData){let $=e.key??e.name??e.id;k=n.heatmapData.heat.get(e.id)??n.heatmapData.heat.get($)}let M={id:e.id,type:"step",label:u,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1,metadata:k!==void 0?{heat:k}:void 0};return{node:M,bottomY:M.bottomY}}function yr(e,t,r,o,a,n){let i=`stream:${e.namespace}`,s=e.streamState==="active"?"\u27F3":e.streamState==="closed"?"\u2713":"\u2717",u=[],d=`${s} ${i}`,l=Math.min(o-ee*2,40);u.push(...Ge(d,l)),u.push(`W:${e.writeCount} R:${e.readCount}`),a.showTimings&&e.durationMs!==void 0&&u.push(`[${H(e.durationMs)}]`),e.backpressureOccurred&&u.push("backpressure");let p=Math.max(...u.map(M=>te(M).length)),f=Math.max(Q,p+ee*2),m=u.length+2,w=t-Math.floor(f/2),k={id:e.id,type:"stream",label:u,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1,metadata:{streamState:e.streamState,backpressureOccurred:e.backpressureOccurred}};return{node:k,bottomY:k.bottomY}}function vr(e,t,r,o,a,n){let i=z(e),s=e.name??(i?"race":"parallel"),d=`${i?"\u26A1":"\u2AD8"} ${s}`;if(e.children.length===0){let y=[d,"(not tracked)"],E=Le(e.id,i?"race":"parallel",y,e.state,t,r);return{node:E,bottomY:E.bottomY}}let l=Math.floor((o-Ce*(e.children.length-1))/e.children.length),p=[];for(let y of e.children){let E=Ve(y,Math.max(l,Q),a,n);p.push(E.width)}let f=p.reduce((y,E)=>y+E,0)+Ce*(e.children.length-1),m=f>o&&e.children.length>1,w=Math.max(Q,d.length+ee*2),k=3,M=t-Math.floor(w/2),$=r;$+=k,$+=1,$+=1;let T=[];if(m)for(let y=0;y<e.children.length;y++){let E=e.children[y],C=_e(E,t,$,o,a,n);i&&z(e)&&e.winnerId===E.id&&(C.node.metadata={...C.node.metadata,isWinner:!0}),T.push(C.node),$=C.bottomY+fe}else{let y=t-Math.floor(f/2);for(let E=0;E<e.children.length;E++){let C=e.children[E],N=y+Math.floor(p[E]/2),L=_e(C,N,$,p[E],a,n);i&&z(e)&&e.winnerId===C.id&&(L.node.metadata={...L.node.metadata,isWinner:!0}),T.push(L.node),y+=p[E]+Ce}}let I=Math.max(...T.map(y=>y.bottomY)),x=!m&&T.length>1?I+2:I;return{node:{id:e.id,type:i?"race":"parallel",label:[d],state:e.state,x:M,y:r,width:w,height:k,centerX:t,bottomY:x,children:T,metadata:{verticalLayout:m}},bottomY:x}}function kr(e,t,r,o,a,n){let i=e.name??"decision",s=e.condition?` (${e.condition.slice(0,20)})`:"",u=`\u25C7 ${i}${s}`,d=Math.min(o-ee*2,40),l=Ge(u,d),p=Math.max(...l.map(x=>te(x).length)),f=Math.max(Q,p+ee*2),m=l.length+2,w=t-Math.floor(f/2),k=e.branches.find(x=>x.taken),M=k&&k.children.length>0?k:e.branches.find(x=>x.children.length>0);if(!M||M.children.length===0){let x={id:e.id,type:"decision",label:l,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:r+m-1};return{node:x,bottomY:x.bottomY}}let $=r+m+fe,T=[];for(let x of M.children){let g=_e(x,t,$,o,a,n);T.push(g.node),$=g.bottomY+fe}let I=T.length>0?T[T.length-1].bottomY:r+m-1;return{node:{id:e.id,type:"decision",label:l,state:e.state,x:w,y:r,width:f,height:m,centerX:t,bottomY:I,children:T},bottomY:I}}function Ve(e,t,r,o){if(V(e)){let a=e.name??e.key??"step",n=ht(e.state),i=1;r.showTimings&&e.durationMs!==void 0&&i++,e.retryCount&&e.retryCount>0&&i++,e.timedOut&&i++,o?.showSparklines&&(o.timingHistory?.has(e.key??"")||o.timingHistory?.has(e.name??"")||o.timingHistory?.has(e.id))&&i++;let s=`${n} ${a}`;r.showKeys&&e.key&&e.name&&(s+=` [${e.key}]`);let u=Math.min(t,Math.max(Q,s.length+ee*2)),d=i+2;return{width:u,height:d}}if(G(e)||z(e)){if(e.children.length===0)return{width:Q+4,height:4};let a=Math.floor(t/e.children.length),n=0,i=0;for(let s of e.children){let u=Ve(s,a,r,o);n+=u.width,i=Math.max(i,u.height)}return n+=Ce*(e.children.length-1),{width:Math.max(n,Q),height:5+i+2}}if(X(e)){let a=e.branches.find(i=>i.taken),n=0;if(a)for(let i of a.children){let s=Ve(i,t,r,o);n+=s.height+fe}return{width:Math.min(t,30),height:3+n}}if(ne(e)){let a=`stream:${e.namespace}`,n=2;r.showTimings&&e.durationMs!==void 0&&n++,e.backpressureOccurred&&n++;let i=Math.min(t,Math.max(Q,a.length+ee*2+4)),s=n+2;return{width:i,height:s}}return{width:Q,height:3}}function xr(e,t,r){let o={...K,...r.colors};for(let a=0;a<t.length;a++){let n=t[a],i=a===t.length-1;if(We(e,n,o),!i){let s=t[a+1],u=n.centerX,d=n.bottomY+1,l=s.centerX,p=s.y-1;oe(e,u,d,p-1),le(e,l,p)}}}function We(e,t,r){let o=t.type!=="start",a=t.type!=="end"&&(!t.children||t.children.length===0);hr(e,t.x,t.y,t.width,t.height),o&&A(e,t.centerX,t.y,B.teeUp),(a||t.children&&t.children.length>0)&&A(e,t.centerX,t.y+t.height-1,B.teeDown);let n=t.width-ee*2,i=Er(t,r);for(let s=0;s<t.label.length;s++){let u=t.label[s],d=t.x+1+Math.floor((n-te(u).length)/2),l=t.y+1+s;pt(e,d,l,u,i)}t.metadata?.isWinner&&pt(e,t.x+t.width-2,t.y,"\u{1F3C6}"),t.children&&t.children.length>0&&(t.type==="parallel"||t.type==="race"?Sr(e,t,r):Ir(e,t,r))}function Sr(e,t,r){let o=t.children;if(o.length===0)return;let a=t.y+t.height,n=t.centerX;if(t.metadata?.verticalLayout===!0){let s=o[0];oe(e,n,a,s.y-2),le(e,s.centerX,s.y-1);for(let u=0;u<o.length;u++){let d=o[u];if(We(e,d,r),u<o.length-1){let l=o[u+1];oe(e,d.centerX,d.bottomY+1,l.y-2),le(e,l.centerX,l.y-1)}}return}if(o.length===1)oe(e,n,a,o[0].y-2),le(e,o[0].centerX,o[0].y-1);else{let s=o.map(l=>l.centerX),u=Math.min(...s),d=Math.max(...s);oe(e,n,a,a+1),mt(e,a+1,u,d),A(e,n,a+1,B.teeUp);for(let l of o){let p=l.centerX;p===u?A(e,p,a+1,B.topLeft):p===d?A(e,p,a+1,B.topRight):p!==n&&A(e,p,a+1,B.teeDown),oe(e,p,a+2,l.y-2),le(e,p,l.y-1)}}for(let s of o)We(e,s,r);if(o.length>1){let s=o.map(m=>m.bottomY),u=Math.max(...s),d=u+1,l=o.map(m=>m.centerX),p=Math.min(...l),f=Math.max(...l);for(let m of o)m.bottomY<u&&oe(e,m.centerX,m.bottomY+1,d-1);mt(e,d,p,f);for(let m of o){let w=m.centerX;w===p?A(e,w,d,B.bottomLeft):w===f?A(e,w,d,B.bottomRight):A(e,w,d,B.teeUp)}A(e,t.centerX,d,B.teeDown),A(e,t.centerX,d+1,B.vertical)}}function Ir(e,t,r){let o=t.children;if(o.length===0)return;let a=t.y+t.height,n=o[0];oe(e,t.centerX,a,n.y-2),le(e,n.centerX,n.y-1);for(let i=0;i<o.length;i++){let s=o[i];if(We(e,s,r),i<o.length-1){let u=o[i+1];oe(e,s.centerX,s.bottomY+1,u.y-2),le(e,u.centerX,u.y-1)}}}var Rr={active:"\x1B[36m",closed:"\x1B[32m",error:"\x1B[31m"};function Er(e,t){if(e.metadata?.heat!==void 0){let r=ve(e.metadata.heat);return pr[r]||void 0}return e.type==="stream"&&e.metadata?.streamState?Rr[e.metadata.streamState]||void 0:t[e.state]||void 0}function he(){return{name:"flowchart",supportsLive:!1,render(e,t){let r=t.terminalWidth??80,{nodes:o,totalHeight:a}=br(e,t,r),n=fr(r,a);return xr(n,o,t),gr(n)}}}function $r(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Mr(e){let t=[];function r(o){for(let a of o)if(V(a))t.push(a);else if(rt(a))r(a.children);else if(G(a)||z(a))r(a.children);else if(X(a))for(let n of a.branches)n.taken&&r(n.children)}return r(e),t}function Tr(e){let t={id:e.id,name:e.name??e.key??e.id,state:e.state};return e.key&&(t.key=e.key),e.durationMs!==void 0&&(t.durationMs=e.durationMs),e.startTs!==void 0&&(t.startTs=e.startTs),e.endTs!==void 0&&(t.endTs=e.endTs),e.retryCount!==void 0&&e.retryCount>0&&(t.retryCount=e.retryCount),e.timedOut&&(t.timedOut=!0,e.timeoutMs!==void 0&&(t.timeoutMs=e.timeoutMs)),e.error!==void 0&&(t.error=typeof e.error=="string"?e.error:String(e.error)),t}function Nr(e){let t=0,r=0,o=0,a=0,n=0,i;for(let s of e)s.state==="success"&&t++,s.state==="error"&&r++,s.state==="cached"&&o++,s.state==="skipped"&&a++,s.retryCount!==void 0&&(n+=s.retryCount),s.durationMs!==void 0&&(!i||s.durationMs>i.durationMs)&&(i={name:s.name??s.key??s.id,durationMs:s.durationMs});return{totalSteps:e.length,successCount:t,errorCount:r,cacheHits:o,skippedCount:a,totalRetries:n,slowestStep:i}}function Or(e){let t={};if(e.shouldRun&&(t.shouldRun={result:e.shouldRun.context?.result,durationMs:e.shouldRun.durationMs},e.shouldRun.error!==void 0&&e.shouldRun.error!==null&&(t.shouldRun.error=String(e.shouldRun.error))),e.onBeforeStart&&(t.onBeforeStart={durationMs:e.onBeforeStart.durationMs},e.onBeforeStart.error!==void 0&&e.onBeforeStart.error!==null&&(t.onBeforeStart.error=String(e.onBeforeStart.error))),e.onAfterStep.size>0){t.onAfterStep=[];for(let[r,o]of e.onAfterStep){let a={stepKey:r};o.durationMs!==void 0&&(a.durationMs=o.durationMs),o.error!==void 0&&o.error!==null&&(a.error=String(o.error)),t.onAfterStep.push(a)}}return t}function Dr(e,t){let r=e.root,o=Mr(r.children),a=t.includeDiagram??!0,n=t.stripAnsiColors??!0,i={workflow:{id:r.workflowId,name:r.name,state:r.state,durationMs:r.durationMs,startedAt:r.startTs,completedAt:r.endTs},steps:o.map(Tr),summary:Nr(o)};if(e.hooks){let s=Or(e.hooks);Object.keys(s).length>0&&(i.hooks=s)}if(a){let d=((t.diagramFormat??"ascii")==="flowchart"?he():ae()).render(e,t);n&&(d=$r(d)),i.diagram=d}return i}function Be(){return{name:"logger",supportsLive:!1,render(e,t){let o=Dr(e,t);return JSON.stringify(o)}}}import{ok as He,err as ke}from"awaitly";import Cr from"pako";var Lr=typeof globalThis<"u"&&"Buffer"in globalThis&&typeof globalThis.Buffer=="function";function _r(e){let t;if(Lr)t=globalThis.Buffer.from(e).toString("base64");else{let r="";for(let o=0;o<e.length;o++)r+=String.fromCharCode(e[o]);t=btoa(r)}return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function Ae(e){let r=new TextEncoder().encode(e),o=Cr.deflate(r);return _r(o)}var gt="https://kroki.io";function Ye(e,t,r,o={}){let a=o.baseUrl??gt,n=Ae(r);return`${a}/${e}/${t}/${n}`}function ue(e,t="svg",r={}){let o=ie(),a={showTimings:!0,showKeys:!1,terminalWidth:80,colors:K},n=o.render(e,a);return Ye("mermaid",t,n,r)}function Wr(e,t={}){return ue(e,"svg",t)}function Br(e,t={}){return ue(e,"png",t)}function Ar(e={}){let t=e.baseUrl??gt;return{toUrl(r,o){return ue(r,o,{baseUrl:t})},toSvgUrl(r){return ue(r,"svg",{baseUrl:t})},toPngUrl(r){return ue(r,"png",{baseUrl:t})},toPdfUrl(r){return ue(r,"pdf",{baseUrl:t})},getBaseUrl(){return t}}}var bt="https://mermaid.ink";function wt(e){return`pako:${Ae(e)}`}function Pr(e){if("provider"in e){let t=e;return{theme:t.mermaidTheme,bgColor:t.background,scale:t.scale,fit:t.fit,width:t.width,height:t.height,paper:t.paper,imageType:"png"}}return e}function Hr(e,t){let r=[];return t.bgColor&&r.push(`bgColor=${encodeURIComponent(t.bgColor)}`),t.theme&&r.push(`theme=${t.theme}`),t.width!==void 0&&r.push(`width=${t.width}`),t.height!==void 0&&r.push(`height=${t.height}`),t.scale!==void 0&&(t.width!==void 0||t.height!==void 0)&&r.push(`scale=${t.scale}`),e==="img"&&t.imageType&&t.imageType!=="jpeg"&&r.push(`type=${t.imageType}`),e==="pdf"&&(t.fit&&r.push("fit"),t.paper&&!t.fit&&r.push(`paper=${t.paper}`),t.landscape&&!t.fit&&r.push("landscape")),r.length>0?`?${r.join("&")}`:""}function Pe(e,t,r={}){let o=Pr(r),a=o.baseUrl??bt,n=wt(t),i=Hr(e,o);return`${a}/${e}/${n}${i}`}function Y(e,t="svg",r={}){let o=ie(),a={showTimings:!0,showKeys:!1,terminalWidth:80,colors:K},n=o.render(e,a);return Pe(t,n,r)}function Fr(e,t={}){return Y(e,"svg",t)}function Ur(e,t={}){return Y(e,"img",{...t,imageType:"png"})}function zr(e,t={}){return Y(e,"img",{...t,imageType:"jpeg"})}function Kr(e,t={}){return Y(e,"img",{...t,imageType:"webp"})}function jr(e,t={}){return Y(e,"pdf",t)}function Vr(e={}){let t=e.baseUrl??bt;return{toUrl(r,o){return Y(r,o,e)},toSvgUrl(r){return Y(r,"svg",e)},toPngUrl(r){return Y(r,"img",{...e,imageType:"png"})},toJpegUrl(r){return Y(r,"img",{...e,imageType:"jpeg"})},toWebpUrl(r){return Y(r,"img",{...e,imageType:"webp"})},toPdfUrl(r){return Y(r,"pdf",e)},getBaseUrl(){return t},getOptions(){return{...e}}}}function Gr(e,t,r){return e==="mermaid-ink"&&t==="mermaid"?He(void 0):e==="kroki"&&t==="mermaid"?r==="pdf"?ke("UNSUPPORTED_FORMAT"):He(void 0):ke("UNSUPPORTED_FORMAT")}function Yr(e){switch(e){case"mermaid":return"mermaid";case"graphviz":return"graphviz";case"plantuml":return"plantuml"}}function Jr(e){switch(e){case"svg":return"svg";case"png":return"img";case"pdf":return"pdf"}}function xe(e,t,r,o={}){switch(e.kind){case"mermaid":break;case"graphviz":case"plantuml":return ke("UNSUPPORTED_DIAGRAM_KIND");default:{let n=e;return ke("UNSUPPORTED_DIAGRAM_KIND")}}let a=Gr(r.provider,e.kind,t);if(!a.ok)return a;switch(r.provider){case"kroki":return He(Ye(Yr(e.kind),t,e.source,r));case"mermaid-ink":return He(Pe(Jr(t),e.source,r));default:{let n=r;return ke("UNKNOWN_PROVIDER")}}}function yt(e){let t={bg:"#ffffff",bgSecondary:"#f8f9fa",text:"#212529",textMuted:"#6c757d",border:"#dee2e6",primary:"#0d6efd",success:"#198754",error:"#dc3545",warning:"#ffc107",info:"#0dcaf0",muted:"#6c757d",nodePending:"#e9ecef",nodeRunning:"#fff3cd",nodeSuccess:"#d1e7dd",nodeError:"#f8d7da",nodeAborted:"#e9ecef",nodeCached:"#cfe2ff",nodeSkipped:"#f8f9fa",heatCold:"#0d6efd",heatCool:"#0dcaf0",heatNeutral:"#6c757d",heatWarm:"#ffc107",heatHot:"#fd7e14",heatCritical:"#dc3545"},r={bg:"#212529",bgSecondary:"#343a40",text:"#f8f9fa",textMuted:"#adb5bd",border:"#495057",primary:"#0d6efd",success:"#198754",error:"#dc3545",warning:"#ffc107",info:"#0dcaf0",muted:"#6c757d",nodePending:"#495057",nodeRunning:"#664d03",nodeSuccess:"#0f5132",nodeError:"#842029",nodeAborted:"#495057",nodeCached:"#084298",nodeSkipped:"#343a40",heatCold:"#0d6efd",heatCool:"#0dcaf0",heatNeutral:"#6c757d",heatWarm:"#ffc107",heatHot:"#fd7e14",heatCritical:"#dc3545"},o=n=>`
|
|
5
5
|
--bg: ${n.bg};
|
|
6
6
|
--bg-secondary: ${n.bgSecondary};
|
|
7
7
|
--text: ${n.text};
|
|
@@ -26,7 +26,7 @@ function A(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFi
|
|
|
26
26
|
--heat-warm: ${n.heatWarm};
|
|
27
27
|
--heat-hot: ${n.heatHot};
|
|
28
28
|
--heat-critical: ${n.heatCritical};
|
|
29
|
-
`,
|
|
29
|
+
`,a;return e==="auto"?a=`
|
|
30
30
|
:root {
|
|
31
31
|
${o(t)}
|
|
32
32
|
}
|
|
@@ -35,16 +35,16 @@ function A(e){if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${(e/1e3).toFi
|
|
|
35
35
|
${o(r)}
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
`:e==="dark"?
|
|
38
|
+
`:e==="dark"?a=`
|
|
39
39
|
:root {
|
|
40
40
|
${o(r)}
|
|
41
41
|
}
|
|
42
|
-
`:
|
|
42
|
+
`:a=`
|
|
43
43
|
:root {
|
|
44
44
|
${o(t)}
|
|
45
45
|
}
|
|
46
46
|
`,`
|
|
47
|
-
${
|
|
47
|
+
${a}
|
|
48
48
|
|
|
49
49
|
* {
|
|
50
50
|
box-sizing: border-box;
|
|
@@ -606,7 +606,7 @@ body {
|
|
|
606
606
|
max-height: 95vh;
|
|
607
607
|
}
|
|
608
608
|
}
|
|
609
|
-
`}function
|
|
609
|
+
`}function vt(e){return`
|
|
610
610
|
(function() {
|
|
611
611
|
'use strict';
|
|
612
612
|
|
|
@@ -1475,41 +1475,41 @@ body {
|
|
|
1475
1475
|
return min + 'm ' + sec + 's';
|
|
1476
1476
|
}
|
|
1477
1477
|
})();
|
|
1478
|
-
`}var
|
|
1479
|
-
<g class="wv-node wv-node--${e.state}" data-node-id="${
|
|
1478
|
+
`}var se=160,ge=50,Je=40,qr=30,U=20;function Xr(e,t="TB",r){let o=t==="TB"||t==="BT",a=t==="RL"||t==="BT",n=[],i=U,s=U,u=0,d=0;for(let f of e){let m=qe(f,i,s,o,r);n.push(m.node),o?(s+=m.height+qr,u=Math.max(u,m.width),d=s):(i+=m.width+Je,d=Math.max(d,m.height),u=i)}let l=u+U,p=d+U;if(a)for(let f of n)xt(f,l,p,o);return{nodes:n,width:l,height:p}}function xt(e,t,r,o){if(o?e.y=r-e.y-e.height:e.x=t-e.x-e.width,e.children)for(let a of e.children)xt(a,t,r,o)}function qe(e,t,r,o,a){if(V(e)){let n=e.name??e.key??"step",i=a?.showKeys&&e.key&&e.name?`${n} [key: ${e.key}]`:n;return{node:{id:e.id,name:i,type:"step",state:e.state,x:t,y:r,width:se,height:ge,durationMs:e.durationMs},width:se,height:ge}}if(ne(e)){let n=e.streamState==="active"?`stream:${e.namespace} \u27F3`:e.streamState==="error"?`stream:${e.namespace} \u2717`:`stream:${e.namespace} \u2713`;return{node:{id:e.id,name:n,type:"stream",state:e.state,x:t,y:r,width:se,height:ge,durationMs:e.durationMs},width:se,height:ge}}if(G(e)||z(e)){let n=G(e)?"parallel":"race",i=e.name??n,s=[],u=t+U,d=r+U+20,l=0;for(let w of e.children){let k=qe(w,u,d,!0,a);s.push(k.node),u+=k.width+Je,l=Math.max(l,k.height)}let p=u-t-U,f=Math.max(p+U,se+U*2),m=l+U*2+20;return{node:{id:e.id,name:i,type:n,state:e.state,x:t,y:r,width:f,height:m,durationMs:e.durationMs,children:s,containerType:n,containerLabel:n==="parallel"?"PARALLEL":"RACE"},width:f,height:m}}if(X(e)){let n=e.name??"decision",i=[],s=t+U,u=r+U+20,d=0;for(let f of e.branches)for(let m of f.children){let w=qe(m,s,u,!0,a);i.push(w.node),s+=w.width+Je,d=Math.max(d,w.height)}let l=Math.max(s-t,se+U*2),p=d+U*2+20;return{node:{id:e.id,name:n,type:"decision",state:e.state,x:t,y:r,width:l,height:p,durationMs:e.durationMs,children:i,containerType:"decision",containerLabel:"DECISION"},width:l,height:p}}return{node:{id:e.id,name:e.name??"unknown",type:e.type,state:e.state,x:t,y:r,width:se,height:ge},width:se,height:ge}}function St(e,t){return e.containerType?Qr(e,t):Zr(e,t)}function Zr(e,t){let o=t&&e.durationMs!==void 0?H(e.durationMs):"";return`
|
|
1479
|
+
<g class="wv-node wv-node--${e.state}" data-node-id="${Rt(e.id)}" transform="translate(${e.x}, ${e.y})">
|
|
1480
1480
|
<rect width="${e.width}" height="${e.height}" rx="8" ry="8" />
|
|
1481
|
-
<text x="${e.width/2}" y="${e.height/2-(o?4:0)}">${
|
|
1481
|
+
<text x="${e.width/2}" y="${e.height/2-(o?4:0)}">${Ze(tn(e.name,e.name.includes("[key:")?40:20))}</text>
|
|
1482
1482
|
${o?`<text class="wv-node-timing" x="${e.width/2}" y="${e.height/2+12}">${o}</text>`:""}
|
|
1483
1483
|
</g>
|
|
1484
|
-
`}function
|
|
1484
|
+
`}function Qr(e,t){let o=e.children?.map(a=>St(a,t)).join(`
|
|
1485
1485
|
`)??"";return`
|
|
1486
|
-
<g class="wv-container wv-container--${e.containerType}" data-node-id="${
|
|
1486
|
+
<g class="wv-container wv-container--${e.containerType}" data-node-id="${Rt(e.id)}" transform="translate(${e.x}, ${e.y})">
|
|
1487
1487
|
<rect width="${e.width}" height="${e.height}" rx="12" ry="12" />
|
|
1488
|
-
<text class="wv-container-label" x="${
|
|
1488
|
+
<text class="wv-container-label" x="${U}" y="16">${e.containerLabel}</text>
|
|
1489
1489
|
<g transform="translate(${-e.x}, ${-e.y})">
|
|
1490
1490
|
${o}
|
|
1491
1491
|
</g>
|
|
1492
1492
|
</g>
|
|
1493
|
-
`}function Xe(e,t){for(let r of e){if(r.id===t)return r;if("children"in r&&r.children){let o=Xe(r.children,t);if(o)return o}if("branches"in r&&r.branches)for(let o of r.branches){let
|
|
1494
|
-
<path class="wv-edge" d="M ${u} ${
|
|
1493
|
+
`}function Xe(e,t){for(let r of e){if(r.id===t)return r;if("children"in r&&r.children){let o=Xe(r.children,t);if(o)return o}if("branches"in r&&r.branches)for(let o of r.branches){let a=Xe(o.children,t);if(a)return a}}}function en(e,t){let r=[];function o(n,i){if(Math.abs(n.y-i.y)<n.height){let u=n.x+n.width,d=n.y+n.height/2,l=i.x,p=i.y+i.height/2;r.push(`
|
|
1494
|
+
<path class="wv-edge" d="M ${u} ${d} L ${l-8} ${p}" />
|
|
1495
1495
|
<polygon class="wv-edge-arrow" points="${l-8},${p-4} ${l-8},${p+4} ${l},${p}" />
|
|
1496
|
-
`)}else{let u=n.x+n.width/2,
|
|
1497
|
-
<path class="wv-edge" d="M ${u} ${
|
|
1496
|
+
`)}else{let u=n.x+n.width/2,d=n.y+n.height,l=i.x+i.width/2,p=i.y;r.push(`
|
|
1497
|
+
<path class="wv-edge" d="M ${u} ${d} L ${l} ${p-8}" />
|
|
1498
1498
|
<polygon class="wv-edge-arrow" points="${l-4},${p-8} ${l+4},${p-8} ${l},${p}" />
|
|
1499
|
-
`)}}function
|
|
1500
|
-
`)}function
|
|
1501
|
-
`),
|
|
1499
|
+
`)}}function a(n){for(let i=0;i<n.length-1;i++)o(n[i],n[i+1]);for(let i of n)if(i.children&&i.children.length>0)if(i.containerType==="decision"){let s=Xe(t.root.children,i.id);if(s&&s.type==="decision"&&s.branches){let u=0;for(let d of s.branches){let l=d.children.length;l>0&&o(i,i.children[u]);for(let p=0;p<l-1;p++)o(i.children[u+p],i.children[u+p+1]);u+=l}}}else if(i.containerType==="parallel"||i.containerType==="race")for(let s of i.children)s.children&&s.children.length>0&&a([s]);else a(i.children)}return a(e),r.join(`
|
|
1500
|
+
`)}function It(e,t){let r=Xr(e.root.children,t.layout,t),o=Math.max(r.width,400),a=Math.max(r.height,300),n=r.nodes.map(l=>St(l,t.showTimings)).join(`
|
|
1501
|
+
`),i=en(r.nodes,e),s=e.root.name??"Workflow",u=yt(t.theme),d=vt({wsUrl:t.wsUrl,interactive:t.interactive,timeTravel:t.timeTravel,heatmap:t.heatmap});return`<!DOCTYPE html>
|
|
1502
1502
|
<html lang="en">
|
|
1503
1503
|
<head>
|
|
1504
1504
|
<meta charset="UTF-8">
|
|
1505
1505
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1506
|
-
<title>${
|
|
1506
|
+
<title>${Ze(s)} - Workflow Visualizer</title>
|
|
1507
1507
|
<style>${u}</style>
|
|
1508
1508
|
</head>
|
|
1509
1509
|
<body>
|
|
1510
1510
|
<div class="workflow-visualizer">
|
|
1511
1511
|
<header class="wv-header">
|
|
1512
|
-
<h1>${
|
|
1512
|
+
<h1>${Ze(s)}</h1>
|
|
1513
1513
|
<div class="wv-controls">
|
|
1514
1514
|
${t.interactive?`
|
|
1515
1515
|
<button id="load-json-btn" class="wv-btn" title="Load workflow state from JSON">Load JSON</button>
|
|
@@ -1533,9 +1533,9 @@ body {
|
|
|
1533
1533
|
|
|
1534
1534
|
<div class="wv-main">
|
|
1535
1535
|
<div id="diagram" class="wv-diagram">
|
|
1536
|
-
<svg viewBox="0 0 ${o} ${
|
|
1536
|
+
<svg viewBox="0 0 ${o} ${a}" preserveAspectRatio="xMidYMid meet">
|
|
1537
1537
|
<g class="wv-root">
|
|
1538
|
-
${
|
|
1538
|
+
${i}
|
|
1539
1539
|
${n}
|
|
1540
1540
|
</g>
|
|
1541
1541
|
</svg>
|
|
@@ -1599,7 +1599,7 @@ body {
|
|
|
1599
1599
|
<script>
|
|
1600
1600
|
// Check if we have a saved IR in sessionStorage (from Load JSON)
|
|
1601
1601
|
(function() {
|
|
1602
|
-
let initialIR = ${
|
|
1602
|
+
let initialIR = ${kt(rn(e))};
|
|
1603
1603
|
try {
|
|
1604
1604
|
const savedIR = sessionStorage.getItem('workflow_ir');
|
|
1605
1605
|
if (savedIR) {
|
|
@@ -1668,13 +1668,985 @@ body {
|
|
|
1668
1668
|
|
|
1669
1669
|
window.__WORKFLOW_DATA__ = buildWorkflowDataFromIR(irObj);
|
|
1670
1670
|
|
|
1671
|
-
${t.heatmapData?`window.__PERFORMANCE_DATA__ = ${
|
|
1671
|
+
${t.heatmapData?`window.__PERFORMANCE_DATA__ = ${kt({heat:Object.fromEntries(t.heatmapData.heat),metric:t.heatmapData.metric,stats:t.heatmapData.stats})};`:""}
|
|
1672
1672
|
})();
|
|
1673
1673
|
</script>
|
|
1674
|
-
<script>${
|
|
1674
|
+
<script>${d}</script>
|
|
1675
1675
|
</body>
|
|
1676
|
-
</html>`}function
|
|
1677
|
-
`),
|
|
1678
|
-
`).length)}function
|
|
1679
|
-
`)
|
|
1676
|
+
</html>`}function Ze(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function Rt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function tn(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}function rn(e){if(!e.hooks)return e;let t=e.hooks.onAfterStep instanceof Map?Object.fromEntries(e.hooks.onAfterStep):e.hooks.onAfterStep;return{...e,hooks:{...e.hooks,onAfterStep:t}}}function kt(e){let t=new WeakSet;return JSON.stringify(e,(o,a)=>{if(typeof a=="bigint")return a.toString();if(o==="error"&&a!==void 0&&a!==null)return String(a);if(typeof a=="object"&&a!==null){if(t.has(a))return"[Circular]";t.add(a)}return a}).replace(/</g,"\\u003c").replace(/>/g,"\\u003e").replace(/&/g,"\\u0026").replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}var Et={interactive:!0,timeTravel:!0,heatmap:!0,animationDuration:200,theme:"auto",layout:"TB"};function nn(){return{name:"html",supportsLive:!0,render(e,t){let r={...t,...Et,...t};return It(e,r)}}}function on(e,t={}){let r={showTimings:!0,showKeys:!1,colors:{pending:"#6c757d",running:"#ffc107",success:"#198754",error:"#dc3545",aborted:"#6c757d",cached:"#0dcaf0",skipped:"#adb5bd"},...Et,...t};return It(e,r)}var de={clearToEnd:"\x1B[J",cursorUp:e=>`\x1B[${e}A`,cursorToStart:"\x1B[G",hideCursor:"\x1B[?25l",showCursor:"\x1B[?25h",saveCursor:"\x1B[s",restoreCursor:"\x1B[u"};function an(e={}){let{workflowName:t,detectParallel:r=!0,showTimings:o=!0,showKeys:a=!1,colors:n,stream:i=process.stdout,updateInterval:s=100}=e,u=ce({detectParallel:r}),d=ae(),l,p={showTimings:o,showKeys:a,terminalWidth:i.columns??80,colors:{...K,...n}},f=!1,m="",w=0,k=null,M=!1;function $(D){i.writable&&i.write(D)}function T(){if(!f)return;let D=y(),v=d.render(D,p);v!==m&&(w>0&&($(de.cursorUp(w)),$(de.cursorToStart),$(de.clearToEnd)),$(v),$(`
|
|
1677
|
+
`),m=v,w=v.split(`
|
|
1678
|
+
`).length)}function I(){f&&(M=!0,k===null&&(k=setTimeout(()=>{k=null,M&&(M=!1,T())},s)))}function S(D){if(D.type==="scope_start"||D.type==="scope_end"){x(D);return}u.handleEvent(D),"workflowName"in D&&typeof D.workflowName=="string"&&(l=D.workflowName),f&&(D.type==="workflow_start"||D.type==="workflow_success"||D.type==="workflow_error"?T():I())}function x(D){u.handleScopeEvent(D),f&&I()}function g(D){u.handleDecisionEvent(D),f&&I()}function y(){let D=u.getIR(),v=t??l??D.root.name;return v&&(D.root.name=v),D}function E(){return d.render(y(),p)}function C(){f||(f=!0,m="",w=0,$(de.hideCursor),T())}function N(){if(!f)return;f=!1,k!==null&&(clearTimeout(k),k=null);let D=y(),v=d.render(D,p);w>0&&($(de.cursorUp(w)),$(de.cursorToStart),$(de.clearToEnd)),$(v),$(`
|
|
1679
|
+
`),$(de.showCursor)}function L(){k!==null&&(clearTimeout(k),k=null),M=!1,T()}function P(){u.reset(),m="",w=0}return{handleEvent:S,handleScopeEvent:x,handleDecisionEvent:g,getIR:y,render:E,start:C,stop:N,refresh:L,reset:P}}function Qe(e,t={}){let{condition:r,value:o,name:a,workflowId:n=crypto.randomUUID(),emit:i}=t,s=Date.now(),u,d=[];function l(f,m,w){d.push({label:f,condition:w,taken:m}),m&&(u=f),i?.({type:"decision_branch",workflowId:n,decisionId:e,branchLabel:f,condition:w,taken:m,ts:Date.now()})}function p(){let f=Date.now()-s;i?.({type:"decision_end",workflowId:n,decisionId:e,branchTaken:u,ts:Date.now(),durationMs:f})}return i?.({type:"decision_start",workflowId:n,decisionId:e,condition:r,decisionValue:o,name:a,ts:s}),{takeBranch:l,end:p,getBranchTaken:()=>u,getBranches:()=>[...d]}}function sn(e,t,r={}){let o=Qe(e,{...r,condition:r.condition??String(t),value:r.value??t}),a=!1;return{...o,condition:t,then:()=>{a||(a=!0,o.takeBranch("if",!0),o.takeBranch("else",!1))},else:()=>{a||(a=!0,o.takeBranch("if",!1),o.takeBranch("else",!0))}}}function dn(e,t,r={}){let o=Qe(e,{...r,condition:r.condition??`switch(${String(t)})`,value:t});return{...o,value:t,case:(a,n)=>{o.takeBranch(`case '${a}'`,n,`value === '${a}'`)},default:a=>{o.takeBranch("default",a)}}}function cn(e={}){let{maxSnapshots:t=1e3,autoRecord:r=!0,builderOptions:o={}}=e,a=ce({detectParallel:!1,...o,enableSnapshots:r,maxSnapshots:t}),n={snapshots:[],currentIndex:-1,isPlaying:!1,playbackSpeed:1,isRecording:r},i=new Set,s=null;function u(){let N=S();for(let L of i)L(N)}function d(){n.snapshots=a.getSnapshots(),n.isRecording&&n.snapshots.length>0&&(n.currentIndex=n.snapshots.length-1)}function l(N){a.handleEvent(N),n.isRecording&&(d(),u())}function p(N){let L=a.getSnapshots();if(!(N<0||N>=L.length))return n.currentIndex=N,n.snapshots=L,u(),L[N].ir}function f(){return p(n.currentIndex+1)}function m(){return p(n.currentIndex-1)}function w(N=1){let L=a.getSnapshots();if(L.length===0)return;n.currentIndex===-1&&(n.currentIndex=0,n.snapshots=L),n.playbackSpeed=N,n.isPlaying=!0,u();let P=()=>{if(!n.isPlaying)return;let D=a.getSnapshots();if(n.currentIndex<D.length-1){let v=D[n.currentIndex],re=(D[n.currentIndex+1].timestamp-v.timestamp)/n.playbackSpeed;s=setTimeout(()=>{f(),P()},Math.max(16,re))}else k()};P()}function k(){n.isPlaying=!1,s&&(clearTimeout(s),s=null),u()}function M(){let N=a.getSnapshots();return n.currentIndex>=0&&n.currentIndex<N.length?N[n.currentIndex].ir:a.getIR()}function $(N){return a.getIRAt(N)}function T(){return a.getSnapshots()}function I(N){return a.getSnapshotAt(N)}function S(){return{snapshots:a.getSnapshots(),currentIndex:n.currentIndex,isPlaying:n.isPlaying,playbackSpeed:n.playbackSpeed,isRecording:n.isRecording}}function x(N){return i.add(N),()=>i.delete(N)}function g(){n.isRecording=!0,a.setSnapshotsEnabled(!0),d(),u()}function y(){n.isRecording=!1,a.setSnapshotsEnabled(!1),u()}function E(){k(),a.reset(),a.setSnapshotsEnabled(r),n={snapshots:[],currentIndex:-1,isPlaying:!1,playbackSpeed:1,isRecording:r},u()}function C(){return a}return{handleEvent:l,seek:p,stepForward:f,stepBackward:m,play:w,pause:k,getCurrentIR:M,getIRAt:$,getSnapshots:T,getSnapshotAt:I,getState:S,onStateChange:x,startRecording:g,stopRecording:y,reset:E,getBuilder:C}}function ln(e,t,r={}){let{title:o=t.workflowName,theme:a,mermaidCdnUrl:n="https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.min.js"}=r,i=JSON.stringify(t,null,2);return`<!DOCTYPE html>
|
|
1680
|
+
<html lang="en">
|
|
1681
|
+
<head>
|
|
1682
|
+
<meta charset="UTF-8">
|
|
1683
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
1684
|
+
<title>${Se(o)} \u2014 Workflow Diagram</title>
|
|
1685
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
1686
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
1687
|
+
<link href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=DM+Sans:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
1688
|
+
<script src="${n}"></script>
|
|
1689
|
+
<style>
|
|
1690
|
+
${un()}
|
|
1691
|
+
</style>
|
|
1692
|
+
</head>
|
|
1693
|
+
<body>
|
|
1694
|
+
<header>
|
|
1695
|
+
<div class="header-left">
|
|
1696
|
+
<h1>${Se(o)}</h1>
|
|
1697
|
+
${t.description?`<p class="description">${Se(t.description)}</p>`:""}
|
|
1698
|
+
</div>
|
|
1699
|
+
<div class="header-right">
|
|
1700
|
+
<span class="badge">${t.stats.totalSteps} steps</span>
|
|
1701
|
+
${t.stats.conditionalCount>0?`<span class="badge">${t.stats.conditionalCount} conditions</span>`:""}
|
|
1702
|
+
${t.stats.parallelCount>0?`<span class="badge">${t.stats.parallelCount} parallel</span>`:""}
|
|
1703
|
+
<span class="badge file">${Se(t.filePath)}</span>
|
|
1704
|
+
<div class="theme-picker">
|
|
1705
|
+
<button id="theme-btn" aria-label="Change theme" title="Change theme">
|
|
1706
|
+
<svg width="16" height="16" viewBox="0 0 16 16" fill="none"><circle cx="8" cy="8" r="6" stroke="currentColor" stroke-width="1.5"/><path d="M8 2a6 6 0 0 1 0 12V2z" fill="currentColor"/></svg>
|
|
1707
|
+
</button>
|
|
1708
|
+
<div id="theme-menu" class="theme-menu" hidden>
|
|
1709
|
+
<div class="theme-menu-section">
|
|
1710
|
+
<span class="theme-menu-label">Dark</span>
|
|
1711
|
+
<button data-theme="midnight" class="theme-swatch"><span class="swatch" style="background:linear-gradient(135deg,#0f1117,#1a1d2e)"></span>Midnight</button>
|
|
1712
|
+
<button data-theme="ocean" class="theme-swatch"><span class="swatch" style="background:linear-gradient(135deg,#0a1628,#0f2847)"></span>Ocean</button>
|
|
1713
|
+
<button data-theme="ember" class="theme-swatch"><span class="swatch" style="background:linear-gradient(135deg,#1a0f0f,#2a1515)"></span>Ember</button>
|
|
1714
|
+
<button data-theme="forest" class="theme-swatch"><span class="swatch" style="background:linear-gradient(135deg,#0c1a0f,#132a18)"></span>Forest</button>
|
|
1715
|
+
</div>
|
|
1716
|
+
<div class="theme-menu-section">
|
|
1717
|
+
<span class="theme-menu-label">Light</span>
|
|
1718
|
+
<button data-theme="daylight" class="theme-swatch"><span class="swatch" style="background:linear-gradient(135deg,#f8f9fb,#eef1f6)"></span>Daylight</button>
|
|
1719
|
+
<button data-theme="paper" class="theme-swatch"><span class="swatch" style="background:linear-gradient(135deg,#faf8f5,#f0ebe4)"></span>Paper</button>
|
|
1720
|
+
</div>
|
|
1721
|
+
</div>
|
|
1722
|
+
</div>
|
|
1723
|
+
</div>
|
|
1724
|
+
</header>
|
|
1725
|
+
<main>
|
|
1726
|
+
<div id="diagram">
|
|
1727
|
+
<pre class="mermaid">
|
|
1728
|
+
${e}
|
|
1729
|
+
</pre>
|
|
1730
|
+
</div>
|
|
1731
|
+
<aside id="inspector">
|
|
1732
|
+
<div class="inspector-placeholder">
|
|
1733
|
+
<p>Click a node to inspect</p>
|
|
1734
|
+
<p class="hint">Hover over nodes to highlight</p>
|
|
1735
|
+
</div>
|
|
1736
|
+
</aside>
|
|
1737
|
+
</main>
|
|
1738
|
+
<script>
|
|
1739
|
+
const WORKFLOW_DATA = ${i};
|
|
1740
|
+
const INITIAL_THEME = ${a?`"${a}"`:"null"};
|
|
1741
|
+
${pn()}
|
|
1742
|
+
</script>
|
|
1743
|
+
</body>
|
|
1744
|
+
</html>`}function un(){return`
|
|
1745
|
+
/* ================================================================
|
|
1746
|
+
Theme Definitions \u2014 CSS custom properties per theme
|
|
1747
|
+
================================================================ */
|
|
1748
|
+
|
|
1749
|
+
/* Midnight \u2014 default dark */
|
|
1750
|
+
[data-theme="midnight"] {
|
|
1751
|
+
--bg: #0f1117; --bg-secondary: #161921; --bg-elevated: #1c1f2b;
|
|
1752
|
+
--fg: #d4d7e0; --fg-muted: #6b7084; --fg-dim: #464b5e;
|
|
1753
|
+
--border: #262a3a; --border-subtle: #1e2230;
|
|
1754
|
+
--accent: #7b9dea; --accent-dim: rgba(123,157,234,0.12); --accent-glow: rgba(123,157,234,0.25);
|
|
1755
|
+
--node-bg: #1e2235; --node-border: #363d55; --node-text: #c8ccda;
|
|
1756
|
+
--node-step-bg: #1c2640; --node-step-border: #2e4470; --node-step-text: #8ab4f8;
|
|
1757
|
+
--node-decision-bg: #2a1c3d; --node-decision-border: #4a3068; --node-decision-text: #c4a5e8;
|
|
1758
|
+
--node-start-bg: #152e1f; --node-start-border: #245a38; --node-start-text: #6fcf97;
|
|
1759
|
+
--node-end-bg: #2e1520; --node-end-border: #5a2438; --node-end-text: #ef8fa8;
|
|
1760
|
+
--node-parallel-bg: #1a2e2a; --node-parallel-border: #2a5a4a; --node-parallel-text: #6fd4b0;
|
|
1761
|
+
--node-saga-bg: #1e1a2e; --node-saga-border: #3a2e5a; --node-saga-text: #a8a0d4;
|
|
1762
|
+
--edge-color: #3d4460; --edge-label-bg: #1a1d2e; --edge-label-text: #8890a8;
|
|
1763
|
+
--scrollbar-track: #161921; --scrollbar-thumb: #2e3348;
|
|
1764
|
+
--mermaid-theme: dark;
|
|
1765
|
+
}
|
|
1766
|
+
|
|
1767
|
+
/* Ocean \u2014 deep blue dark */
|
|
1768
|
+
[data-theme="ocean"] {
|
|
1769
|
+
--bg: #0a1628; --bg-secondary: #0f1e35; --bg-elevated: #142742;
|
|
1770
|
+
--fg: #c8d8ee; --fg-muted: #5a7a9e; --fg-dim: #3d5a7a;
|
|
1771
|
+
--border: #1a3452; --border-subtle: #152a42;
|
|
1772
|
+
--accent: #4da6e8; --accent-dim: rgba(77,166,232,0.12); --accent-glow: rgba(77,166,232,0.25);
|
|
1773
|
+
--node-bg: #122240; --node-border: #1e3a60; --node-text: #a8c8e8;
|
|
1774
|
+
--node-step-bg: #0f2848; --node-step-border: #1a4070; --node-step-text: #6abaef;
|
|
1775
|
+
--node-decision-bg: #1a1840; --node-decision-border: #2e2a68; --node-decision-text: #9a8ae8;
|
|
1776
|
+
--node-start-bg: #0a2a20; --node-start-border: #1a5040; --node-start-text: #4ad4a0;
|
|
1777
|
+
--node-end-bg: #2a1020; --node-end-border: #4a1a38; --node-end-text: #e86a90;
|
|
1778
|
+
--node-parallel-bg: #0a2830; --node-parallel-border: #1a4a58; --node-parallel-text: #4ad4cc;
|
|
1779
|
+
--node-saga-bg: #141030; --node-saga-border: #282060; --node-saga-text: #8a80d4;
|
|
1780
|
+
--edge-color: #2a4a6a; --edge-label-bg: #0f1e35; --edge-label-text: #6a8aaa;
|
|
1781
|
+
--scrollbar-track: #0f1e35; --scrollbar-thumb: #1a3a5a;
|
|
1782
|
+
--mermaid-theme: dark;
|
|
1783
|
+
}
|
|
1784
|
+
|
|
1785
|
+
/* Ember \u2014 warm dark */
|
|
1786
|
+
[data-theme="ember"] {
|
|
1787
|
+
--bg: #1a0f0f; --bg-secondary: #221414; --bg-elevated: #2e1a1a;
|
|
1788
|
+
--fg: #e0d0c8; --fg-muted: #8a6a5e; --fg-dim: #5e4238;
|
|
1789
|
+
--border: #3a2222; --border-subtle: #2e1a1a;
|
|
1790
|
+
--accent: #e8845a; --accent-dim: rgba(232,132,90,0.12); --accent-glow: rgba(232,132,90,0.25);
|
|
1791
|
+
--node-bg: #2a1818; --node-border: #4a2828; --node-text: #d4b8a8;
|
|
1792
|
+
--node-step-bg: #2e1a12; --node-step-border: #5a3020; --node-step-text: #e8a878;
|
|
1793
|
+
--node-decision-bg: #2a1a28; --node-decision-border: #4a2848; --node-decision-text: #d0a0cc;
|
|
1794
|
+
--node-start-bg: #1a2a14; --node-start-border: #2a4a20; --node-start-text: #88c870;
|
|
1795
|
+
--node-end-bg: #2e1218; --node-end-border: #5a1a28; --node-end-text: #e8687a;
|
|
1796
|
+
--node-parallel-bg: #221a10; --node-parallel-border: #4a3818; --node-parallel-text: #d4b468;
|
|
1797
|
+
--node-saga-bg: #221218; --node-saga-border: #3a1a28; --node-saga-text: #c0808a;
|
|
1798
|
+
--edge-color: #4a3030; --edge-label-bg: #221414; --edge-label-text: #9a7868;
|
|
1799
|
+
--scrollbar-track: #221414; --scrollbar-thumb: #3a2828;
|
|
1800
|
+
--mermaid-theme: dark;
|
|
1801
|
+
}
|
|
1802
|
+
|
|
1803
|
+
/* Forest \u2014 earthy dark */
|
|
1804
|
+
[data-theme="forest"] {
|
|
1805
|
+
--bg: #0c1a0f; --bg-secondary: #111f14; --bg-elevated: #18281a;
|
|
1806
|
+
--fg: #c8d8c8; --fg-muted: #5e7a5e; --fg-dim: #3e5a3e;
|
|
1807
|
+
--border: #1e3a20; --border-subtle: #182e1a;
|
|
1808
|
+
--accent: #5ac87a; --accent-dim: rgba(90,200,122,0.12); --accent-glow: rgba(90,200,122,0.25);
|
|
1809
|
+
--node-bg: #142818; --node-border: #204a28; --node-text: #a8c8a8;
|
|
1810
|
+
--node-step-bg: #122a18; --node-step-border: #1a4a28; --node-step-text: #68c888;
|
|
1811
|
+
--node-decision-bg: #1a1a28; --node-decision-border: #2a2a48; --node-decision-text: #a0a0d8;
|
|
1812
|
+
--node-start-bg: #102a18; --node-start-border: #185a30; --node-start-text: #58d890;
|
|
1813
|
+
--node-end-bg: #2a1418; --node-end-border: #4a2028; --node-end-text: #d87080;
|
|
1814
|
+
--node-parallel-bg: #0e2820; --node-parallel-border: #1a4a38; --node-parallel-text: #58c8a8;
|
|
1815
|
+
--node-saga-bg: #181828; --node-saga-border: #282848; --node-saga-text: #9898c0;
|
|
1816
|
+
--edge-color: #2a4a30; --edge-label-bg: #111f14; --edge-label-text: #6a8a6a;
|
|
1817
|
+
--scrollbar-track: #111f14; --scrollbar-thumb: #204a28;
|
|
1818
|
+
--mermaid-theme: dark;
|
|
1819
|
+
}
|
|
1820
|
+
|
|
1821
|
+
/* Daylight \u2014 clean light */
|
|
1822
|
+
[data-theme="daylight"] {
|
|
1823
|
+
--bg: #f8f9fb; --bg-secondary: #ffffff; --bg-elevated: #ffffff;
|
|
1824
|
+
--fg: #1a2030; --fg-muted: #6a7488; --fg-dim: #9aa4b4;
|
|
1825
|
+
--border: #dde1ea; --border-subtle: #e8ecf2;
|
|
1826
|
+
--accent: #3a6fd8; --accent-dim: rgba(58,111,216,0.08); --accent-glow: rgba(58,111,216,0.15);
|
|
1827
|
+
--node-bg: #ffffff; --node-border: #c8d0e0; --node-text: #2a3448;
|
|
1828
|
+
--node-step-bg: #eaf2ff; --node-step-border: #a0c0ea; --node-step-text: #1a4080;
|
|
1829
|
+
--node-decision-bg: #f4eaff; --node-decision-border: #c0a0e0; --node-decision-text: #4a1a80;
|
|
1830
|
+
--node-start-bg: #e8f8ee; --node-start-border: #80c898; --node-start-text: #1a5030;
|
|
1831
|
+
--node-end-bg: #ffeaee; --node-end-border: #e098a8; --node-end-text: #801a30;
|
|
1832
|
+
--node-parallel-bg: #eaf8f4; --node-parallel-border: #80c8b0; --node-parallel-text: #1a5040;
|
|
1833
|
+
--node-saga-bg: #eeeaff; --node-saga-border: #a898d8; --node-saga-text: #30184a;
|
|
1834
|
+
--edge-color: #b0b8c8; --edge-label-bg: #f0f2f5; --edge-label-text: #5a6478;
|
|
1835
|
+
--scrollbar-track: #f0f2f5; --scrollbar-thumb: #c8cdd8;
|
|
1836
|
+
--mermaid-theme: default;
|
|
1837
|
+
}
|
|
1838
|
+
|
|
1839
|
+
/* Paper \u2014 warm light */
|
|
1840
|
+
[data-theme="paper"] {
|
|
1841
|
+
--bg: #faf8f5; --bg-secondary: #fffefa; --bg-elevated: #fffefa;
|
|
1842
|
+
--fg: #2a2218; --fg-muted: #7a6e5e; --fg-dim: #a89a88;
|
|
1843
|
+
--border: #e0d8cc; --border-subtle: #e8e2d8;
|
|
1844
|
+
--accent: #b07830; --accent-dim: rgba(176,120,48,0.08); --accent-glow: rgba(176,120,48,0.15);
|
|
1845
|
+
--node-bg: #fffefa; --node-border: #d8ceb8; --node-text: #3a3020;
|
|
1846
|
+
--node-step-bg: #faf4e8; --node-step-border: #d0b880; --node-step-text: #5a4010;
|
|
1847
|
+
--node-decision-bg: #f8eefa; --node-decision-border: #c8a0d0; --node-decision-text: #5a1868;
|
|
1848
|
+
--node-start-bg: #f0f8ea; --node-start-border: #98c880; --node-start-text: #2a5018;
|
|
1849
|
+
--node-end-bg: #faf0e8; --node-end-border: #d8a880; --node-end-text: #6a3010;
|
|
1850
|
+
--node-parallel-bg: #eaf8f0; --node-parallel-border: #88c8a0; --node-parallel-text: #1a4830;
|
|
1851
|
+
--node-saga-bg: #f0eaf8; --node-saga-border: #a888c8; --node-saga-text: #381850;
|
|
1852
|
+
--edge-color: #c0b4a0; --edge-label-bg: #f4f0e8; --edge-label-text: #6a5e48;
|
|
1853
|
+
--scrollbar-track: #f0ebe0; --scrollbar-thumb: #c8bea8;
|
|
1854
|
+
--mermaid-theme: default;
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
/* ================================================================
|
|
1858
|
+
Base Layout & Typography
|
|
1859
|
+
================================================================ */
|
|
1860
|
+
|
|
1861
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
1862
|
+
|
|
1863
|
+
body {
|
|
1864
|
+
font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
|
|
1865
|
+
background: var(--bg);
|
|
1866
|
+
color: var(--fg);
|
|
1867
|
+
height: 100vh;
|
|
1868
|
+
overflow: hidden;
|
|
1869
|
+
transition: background 0.3s ease, color 0.3s ease;
|
|
1870
|
+
}
|
|
1871
|
+
|
|
1872
|
+
header {
|
|
1873
|
+
display: flex;
|
|
1874
|
+
justify-content: space-between;
|
|
1875
|
+
align-items: center;
|
|
1876
|
+
padding: 10px 20px;
|
|
1877
|
+
background: var(--bg-secondary);
|
|
1878
|
+
border-bottom: 1px solid var(--border);
|
|
1879
|
+
min-height: 44px;
|
|
1880
|
+
transition: background 0.3s ease, border-color 0.3s ease;
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
.header-left h1 {
|
|
1884
|
+
font-family: 'JetBrains Mono', 'SF Mono', monospace;
|
|
1885
|
+
font-size: 14px;
|
|
1886
|
+
font-weight: 600;
|
|
1887
|
+
letter-spacing: -0.02em;
|
|
1888
|
+
color: var(--fg);
|
|
1889
|
+
}
|
|
1890
|
+
.header-left .description {
|
|
1891
|
+
font-size: 12px;
|
|
1892
|
+
color: var(--fg-muted);
|
|
1893
|
+
margin-top: 2px;
|
|
1894
|
+
}
|
|
1895
|
+
|
|
1896
|
+
.header-right {
|
|
1897
|
+
display: flex;
|
|
1898
|
+
gap: 6px;
|
|
1899
|
+
align-items: center;
|
|
1900
|
+
}
|
|
1901
|
+
|
|
1902
|
+
.badge {
|
|
1903
|
+
font-family: 'JetBrains Mono', monospace;
|
|
1904
|
+
font-size: 10px;
|
|
1905
|
+
font-weight: 500;
|
|
1906
|
+
padding: 3px 8px;
|
|
1907
|
+
border-radius: 4px;
|
|
1908
|
+
background: var(--accent-dim);
|
|
1909
|
+
color: var(--accent);
|
|
1910
|
+
letter-spacing: 0.01em;
|
|
1911
|
+
transition: background 0.3s ease, color 0.3s ease;
|
|
1912
|
+
}
|
|
1913
|
+
.badge.file {
|
|
1914
|
+
max-width: 260px;
|
|
1915
|
+
overflow: hidden;
|
|
1916
|
+
text-overflow: ellipsis;
|
|
1917
|
+
white-space: nowrap;
|
|
1918
|
+
color: var(--fg-muted);
|
|
1919
|
+
background: transparent;
|
|
1920
|
+
border: 1px solid var(--border);
|
|
1921
|
+
}
|
|
1922
|
+
|
|
1923
|
+
/* ================================================================
|
|
1924
|
+
Theme Picker
|
|
1925
|
+
================================================================ */
|
|
1926
|
+
|
|
1927
|
+
.theme-picker {
|
|
1928
|
+
position: relative;
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
#theme-btn {
|
|
1932
|
+
display: flex;
|
|
1933
|
+
align-items: center;
|
|
1934
|
+
justify-content: center;
|
|
1935
|
+
width: 32px;
|
|
1936
|
+
height: 32px;
|
|
1937
|
+
border-radius: 6px;
|
|
1938
|
+
border: 1px solid var(--border);
|
|
1939
|
+
background: var(--bg-elevated);
|
|
1940
|
+
color: var(--fg-muted);
|
|
1941
|
+
cursor: pointer;
|
|
1942
|
+
transition: all 0.15s ease;
|
|
1943
|
+
}
|
|
1944
|
+
#theme-btn:hover {
|
|
1945
|
+
border-color: var(--accent);
|
|
1946
|
+
color: var(--accent);
|
|
1947
|
+
background: var(--accent-dim);
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1950
|
+
.theme-menu {
|
|
1951
|
+
position: absolute;
|
|
1952
|
+
top: 38px;
|
|
1953
|
+
right: 0;
|
|
1954
|
+
background: var(--bg-elevated);
|
|
1955
|
+
border: 1px solid var(--border);
|
|
1956
|
+
border-radius: 8px;
|
|
1957
|
+
padding: 6px;
|
|
1958
|
+
min-width: 160px;
|
|
1959
|
+
box-shadow: 0 8px 24px rgba(0,0,0,0.3);
|
|
1960
|
+
z-index: 1000;
|
|
1961
|
+
animation: menuIn 0.15s ease;
|
|
1962
|
+
}
|
|
1963
|
+
.theme-menu[hidden] { display: none; }
|
|
1964
|
+
|
|
1965
|
+
@keyframes menuIn {
|
|
1966
|
+
from { opacity: 0; transform: translateY(-4px); }
|
|
1967
|
+
to { opacity: 1; transform: translateY(0); }
|
|
1968
|
+
}
|
|
1969
|
+
|
|
1970
|
+
.theme-menu-section { padding: 4px 0; }
|
|
1971
|
+
.theme-menu-section + .theme-menu-section { border-top: 1px solid var(--border-subtle); margin-top: 4px; padding-top: 8px; }
|
|
1972
|
+
|
|
1973
|
+
.theme-menu-label {
|
|
1974
|
+
display: block;
|
|
1975
|
+
font-family: 'JetBrains Mono', monospace;
|
|
1976
|
+
font-size: 9px;
|
|
1977
|
+
font-weight: 600;
|
|
1978
|
+
text-transform: uppercase;
|
|
1979
|
+
letter-spacing: 0.08em;
|
|
1980
|
+
color: var(--fg-dim);
|
|
1981
|
+
padding: 2px 8px 4px;
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
.theme-swatch {
|
|
1985
|
+
display: flex;
|
|
1986
|
+
align-items: center;
|
|
1987
|
+
gap: 8px;
|
|
1988
|
+
width: 100%;
|
|
1989
|
+
padding: 5px 8px;
|
|
1990
|
+
border: none;
|
|
1991
|
+
border-radius: 5px;
|
|
1992
|
+
background: transparent;
|
|
1993
|
+
color: var(--fg);
|
|
1994
|
+
font-family: 'DM Sans', sans-serif;
|
|
1995
|
+
font-size: 12px;
|
|
1996
|
+
cursor: pointer;
|
|
1997
|
+
transition: background 0.1s ease;
|
|
1998
|
+
}
|
|
1999
|
+
.theme-swatch:hover { background: var(--accent-dim); }
|
|
2000
|
+
.theme-swatch.active { background: var(--accent-dim); color: var(--accent); font-weight: 600; }
|
|
2001
|
+
|
|
2002
|
+
.swatch {
|
|
2003
|
+
display: inline-block;
|
|
2004
|
+
width: 14px;
|
|
2005
|
+
height: 14px;
|
|
2006
|
+
border-radius: 3px;
|
|
2007
|
+
border: 1px solid var(--border);
|
|
2008
|
+
flex-shrink: 0;
|
|
2009
|
+
}
|
|
2010
|
+
|
|
2011
|
+
/* ================================================================
|
|
2012
|
+
Main Layout
|
|
2013
|
+
================================================================ */
|
|
2014
|
+
|
|
2015
|
+
main {
|
|
2016
|
+
display: flex;
|
|
2017
|
+
height: calc(100vh - 44px);
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
#diagram {
|
|
2021
|
+
flex: 1;
|
|
2022
|
+
overflow: auto;
|
|
2023
|
+
padding: 32px;
|
|
2024
|
+
display: flex;
|
|
2025
|
+
justify-content: center;
|
|
2026
|
+
align-items: flex-start;
|
|
2027
|
+
background: var(--bg);
|
|
2028
|
+
transition: background 0.3s ease;
|
|
2029
|
+
}
|
|
2030
|
+
|
|
2031
|
+
#diagram svg {
|
|
2032
|
+
max-width: 100%;
|
|
2033
|
+
height: auto;
|
|
2034
|
+
}
|
|
2035
|
+
|
|
2036
|
+
/* ================================================================
|
|
2037
|
+
Mermaid SVG Overrides \u2014 force node colors per theme
|
|
2038
|
+
================================================================ */
|
|
2039
|
+
|
|
2040
|
+
/* All node shapes: override Mermaid's embedded pastel classDef fills */
|
|
2041
|
+
#diagram .node rect,
|
|
2042
|
+
#diagram .node polygon,
|
|
2043
|
+
#diagram .node circle,
|
|
2044
|
+
#diagram .node .basic {
|
|
2045
|
+
fill: var(--node-bg) !important;
|
|
2046
|
+
stroke: var(--node-border) !important;
|
|
2047
|
+
stroke-width: 1.5px !important;
|
|
2048
|
+
transition: fill 0.3s ease, stroke 0.3s ease;
|
|
2049
|
+
}
|
|
2050
|
+
|
|
2051
|
+
/* Node text */
|
|
2052
|
+
#diagram .node .nodeLabel,
|
|
2053
|
+
#diagram .node .label {
|
|
2054
|
+
color: var(--node-text) !important;
|
|
2055
|
+
fill: var(--node-text) !important;
|
|
2056
|
+
font-family: 'JetBrains Mono', monospace !important;
|
|
2057
|
+
font-size: 12px !important;
|
|
2058
|
+
font-weight: 500 !important;
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
/* Step nodes (rectangles) \u2014 match by Mermaid ID pattern */
|
|
2062
|
+
#diagram [id*="flowchart-step_"] rect,
|
|
2063
|
+
#diagram .node.stepStyle rect {
|
|
2064
|
+
fill: var(--node-step-bg) !important;
|
|
2065
|
+
stroke: var(--node-step-border) !important;
|
|
2066
|
+
}
|
|
2067
|
+
#diagram [id*="flowchart-step_"] .nodeLabel,
|
|
2068
|
+
#diagram .node.stepStyle .nodeLabel {
|
|
2069
|
+
color: var(--node-step-text) !important;
|
|
2070
|
+
fill: var(--node-step-text) !important;
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/* Saga step nodes */
|
|
2074
|
+
#diagram [id*="flowchart-saga_step_"] rect,
|
|
2075
|
+
#diagram .node.sagaStepStyle rect {
|
|
2076
|
+
fill: var(--node-saga-bg) !important;
|
|
2077
|
+
stroke: var(--node-saga-border) !important;
|
|
2078
|
+
}
|
|
2079
|
+
#diagram [id*="flowchart-saga_step_"] .nodeLabel,
|
|
2080
|
+
#diagram .node.sagaStepStyle .nodeLabel {
|
|
2081
|
+
color: var(--node-saga-text) !important;
|
|
2082
|
+
fill: var(--node-saga-text) !important;
|
|
2083
|
+
}
|
|
2084
|
+
|
|
2085
|
+
/* Decision/conditional nodes (diamonds) */
|
|
2086
|
+
#diagram [id*="flowchart-decision_"] polygon,
|
|
2087
|
+
#diagram .node.conditionalStyle polygon {
|
|
2088
|
+
fill: var(--node-decision-bg) !important;
|
|
2089
|
+
stroke: var(--node-decision-border) !important;
|
|
2090
|
+
}
|
|
2091
|
+
#diagram [id*="flowchart-decision_"] .nodeLabel,
|
|
2092
|
+
#diagram .node.conditionalStyle .nodeLabel {
|
|
2093
|
+
color: var(--node-decision-text) !important;
|
|
2094
|
+
fill: var(--node-decision-text) !important;
|
|
2095
|
+
}
|
|
2096
|
+
|
|
2097
|
+
/* Start node (circle) */
|
|
2098
|
+
#diagram [id*="flowchart-start"] circle,
|
|
2099
|
+
#diagram .node.startStyle circle {
|
|
2100
|
+
fill: var(--node-start-bg) !important;
|
|
2101
|
+
stroke: var(--node-start-border) !important;
|
|
2102
|
+
}
|
|
2103
|
+
#diagram [id*="flowchart-start"] .nodeLabel,
|
|
2104
|
+
#diagram .node.startStyle .nodeLabel {
|
|
2105
|
+
color: var(--node-start-text) !important;
|
|
2106
|
+
fill: var(--node-start-text) !important;
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
/* End node (circle) */
|
|
2110
|
+
#diagram [id*="flowchart-end_node"] circle,
|
|
2111
|
+
#diagram .node.endStyle circle {
|
|
2112
|
+
fill: var(--node-end-bg) !important;
|
|
2113
|
+
stroke: var(--node-end-border) !important;
|
|
2114
|
+
}
|
|
2115
|
+
#diagram [id*="flowchart-end_node"] .nodeLabel,
|
|
2116
|
+
#diagram .node.endStyle .nodeLabel {
|
|
2117
|
+
color: var(--node-end-text) !important;
|
|
2118
|
+
fill: var(--node-end-text) !important;
|
|
2119
|
+
}
|
|
2120
|
+
|
|
2121
|
+
/* Parallel fork/join */
|
|
2122
|
+
#diagram [id*="flowchart-parallel_fork_"] rect,
|
|
2123
|
+
#diagram [id*="flowchart-parallel_join_"] rect,
|
|
2124
|
+
#diagram .node.parallelStyle rect {
|
|
2125
|
+
fill: var(--node-parallel-bg) !important;
|
|
2126
|
+
stroke: var(--node-parallel-border) !important;
|
|
2127
|
+
}
|
|
2128
|
+
#diagram [id*="flowchart-parallel_fork_"] .nodeLabel,
|
|
2129
|
+
#diagram [id*="flowchart-parallel_join_"] .nodeLabel,
|
|
2130
|
+
#diagram .node.parallelStyle .nodeLabel {
|
|
2131
|
+
color: var(--node-parallel-text) !important;
|
|
2132
|
+
fill: var(--node-parallel-text) !important;
|
|
2133
|
+
}
|
|
2134
|
+
|
|
2135
|
+
/* Edges */
|
|
2136
|
+
#diagram .edge-pattern-solid,
|
|
2137
|
+
#diagram .flowchart-link {
|
|
2138
|
+
stroke: var(--edge-color) !important;
|
|
2139
|
+
}
|
|
2140
|
+
#diagram .edgeLabel {
|
|
2141
|
+
background: var(--edge-label-bg) !important;
|
|
2142
|
+
color: var(--edge-label-text) !important;
|
|
2143
|
+
}
|
|
2144
|
+
#diagram .edgeLabel .edgeLabel {
|
|
2145
|
+
background: transparent !important;
|
|
2146
|
+
color: var(--edge-label-text) !important;
|
|
2147
|
+
fill: var(--edge-label-text) !important;
|
|
2148
|
+
font-family: 'JetBrains Mono', monospace !important;
|
|
2149
|
+
font-size: 10px !important;
|
|
2150
|
+
font-weight: 500 !important;
|
|
2151
|
+
}
|
|
2152
|
+
#diagram .edgeLabel rect {
|
|
2153
|
+
fill: var(--edge-label-bg) !important;
|
|
2154
|
+
stroke: none !important;
|
|
2155
|
+
}
|
|
2156
|
+
/* Arrow markers */
|
|
2157
|
+
#diagram marker path {
|
|
2158
|
+
fill: var(--edge-color) !important;
|
|
2159
|
+
stroke: var(--edge-color) !important;
|
|
2160
|
+
}
|
|
2161
|
+
|
|
2162
|
+
/* ================================================================
|
|
2163
|
+
Node Interaction States
|
|
2164
|
+
================================================================ */
|
|
2165
|
+
|
|
2166
|
+
#diagram .node { cursor: pointer; }
|
|
2167
|
+
|
|
2168
|
+
#diagram .node:hover rect,
|
|
2169
|
+
#diagram .node:hover polygon,
|
|
2170
|
+
#diagram .node:hover circle {
|
|
2171
|
+
filter: brightness(1.3) !important;
|
|
2172
|
+
stroke-width: 2px !important;
|
|
2173
|
+
}
|
|
2174
|
+
|
|
2175
|
+
#diagram .node.selected rect,
|
|
2176
|
+
#diagram .node.selected polygon,
|
|
2177
|
+
#diagram .node.selected circle {
|
|
2178
|
+
stroke: var(--accent) !important;
|
|
2179
|
+
stroke-width: 2.5px !important;
|
|
2180
|
+
filter: drop-shadow(0 0 8px var(--accent-glow)) !important;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
/* ================================================================
|
|
2184
|
+
Inspector Panel
|
|
2185
|
+
================================================================ */
|
|
2186
|
+
|
|
2187
|
+
#inspector {
|
|
2188
|
+
width: 320px;
|
|
2189
|
+
min-width: 320px;
|
|
2190
|
+
border-left: 1px solid var(--border);
|
|
2191
|
+
background: var(--bg-secondary);
|
|
2192
|
+
overflow-y: auto;
|
|
2193
|
+
font-size: 13px;
|
|
2194
|
+
transition: background 0.3s ease, border-color 0.3s ease;
|
|
2195
|
+
}
|
|
2196
|
+
#inspector::-webkit-scrollbar { width: 5px; }
|
|
2197
|
+
#inspector::-webkit-scrollbar-track { background: var(--scrollbar-track); }
|
|
2198
|
+
#inspector::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
|
|
2199
|
+
|
|
2200
|
+
.inspector-placeholder {
|
|
2201
|
+
display: flex;
|
|
2202
|
+
flex-direction: column;
|
|
2203
|
+
align-items: center;
|
|
2204
|
+
justify-content: center;
|
|
2205
|
+
height: 200px;
|
|
2206
|
+
color: var(--fg-dim);
|
|
2207
|
+
text-align: center;
|
|
2208
|
+
}
|
|
2209
|
+
.inspector-placeholder p { margin: 4px 0; font-size: 13px; }
|
|
2210
|
+
.inspector-placeholder .hint { font-size: 11px; color: var(--fg-dim); }
|
|
2211
|
+
|
|
2212
|
+
.inspector-content { padding: 16px; }
|
|
2213
|
+
|
|
2214
|
+
.inspector-header {
|
|
2215
|
+
display: flex;
|
|
2216
|
+
align-items: center;
|
|
2217
|
+
gap: 8px;
|
|
2218
|
+
margin-bottom: 14px;
|
|
2219
|
+
padding-bottom: 14px;
|
|
2220
|
+
border-bottom: 1px solid var(--border);
|
|
2221
|
+
}
|
|
2222
|
+
.inspector-type {
|
|
2223
|
+
font-family: 'JetBrains Mono', monospace;
|
|
2224
|
+
font-size: 9px;
|
|
2225
|
+
font-weight: 600;
|
|
2226
|
+
text-transform: uppercase;
|
|
2227
|
+
letter-spacing: 0.06em;
|
|
2228
|
+
padding: 2px 6px;
|
|
2229
|
+
border-radius: 3px;
|
|
2230
|
+
background: var(--accent-dim);
|
|
2231
|
+
color: var(--accent);
|
|
2232
|
+
}
|
|
2233
|
+
.inspector-name {
|
|
2234
|
+
font-family: 'JetBrains Mono', monospace;
|
|
2235
|
+
font-size: 14px;
|
|
2236
|
+
font-weight: 600;
|
|
2237
|
+
}
|
|
2238
|
+
|
|
2239
|
+
.inspector-section { margin-bottom: 14px; }
|
|
2240
|
+
.inspector-section h3 {
|
|
2241
|
+
font-family: 'JetBrains Mono', monospace;
|
|
2242
|
+
font-size: 9px;
|
|
2243
|
+
font-weight: 600;
|
|
2244
|
+
text-transform: uppercase;
|
|
2245
|
+
letter-spacing: 0.06em;
|
|
2246
|
+
color: var(--fg-dim);
|
|
2247
|
+
margin-bottom: 6px;
|
|
2248
|
+
}
|
|
2249
|
+
|
|
2250
|
+
.inspector-row {
|
|
2251
|
+
display: flex;
|
|
2252
|
+
justify-content: space-between;
|
|
2253
|
+
padding: 4px 0;
|
|
2254
|
+
border-bottom: 1px solid var(--border-subtle);
|
|
2255
|
+
}
|
|
2256
|
+
.inspector-row .label {
|
|
2257
|
+
color: var(--fg-muted);
|
|
2258
|
+
font-size: 12px;
|
|
2259
|
+
}
|
|
2260
|
+
.inspector-row .value {
|
|
2261
|
+
font-family: 'JetBrains Mono', monospace;
|
|
2262
|
+
font-size: 11px;
|
|
2263
|
+
text-align: right;
|
|
2264
|
+
max-width: 180px;
|
|
2265
|
+
overflow: hidden;
|
|
2266
|
+
text-overflow: ellipsis;
|
|
2267
|
+
white-space: nowrap;
|
|
2268
|
+
color: var(--fg);
|
|
2269
|
+
}
|
|
2270
|
+
|
|
2271
|
+
.inspector-code {
|
|
2272
|
+
font-family: 'JetBrains Mono', monospace;
|
|
2273
|
+
font-size: 11px;
|
|
2274
|
+
background: var(--bg-elevated);
|
|
2275
|
+
border: 1px solid var(--border-subtle);
|
|
2276
|
+
padding: 8px 10px;
|
|
2277
|
+
border-radius: 5px;
|
|
2278
|
+
overflow-x: auto;
|
|
2279
|
+
white-space: pre-wrap;
|
|
2280
|
+
word-break: break-all;
|
|
2281
|
+
color: var(--accent);
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
.inspector-tag {
|
|
2285
|
+
display: inline-block;
|
|
2286
|
+
font-family: 'JetBrains Mono', monospace;
|
|
2287
|
+
font-size: 10px;
|
|
2288
|
+
font-weight: 500;
|
|
2289
|
+
padding: 2px 6px;
|
|
2290
|
+
border-radius: 3px;
|
|
2291
|
+
background: var(--accent-dim);
|
|
2292
|
+
color: var(--accent);
|
|
2293
|
+
margin: 2px 2px 2px 0;
|
|
2294
|
+
}
|
|
2295
|
+
|
|
2296
|
+
/* ================================================================
|
|
2297
|
+
Responsive
|
|
2298
|
+
================================================================ */
|
|
2299
|
+
|
|
2300
|
+
@media (max-width: 768px) {
|
|
2301
|
+
main { flex-direction: column; }
|
|
2302
|
+
#inspector { width: 100%; min-width: 100%; max-height: 40vh; border-left: none; border-top: 1px solid var(--border); }
|
|
2303
|
+
}
|
|
2304
|
+
`}function pn(){return`
|
|
2305
|
+
(function() {
|
|
2306
|
+
'use strict';
|
|
2307
|
+
|
|
2308
|
+
// ================================================================
|
|
2309
|
+
// Theme System
|
|
2310
|
+
// ================================================================
|
|
2311
|
+
|
|
2312
|
+
const DARK_THEMES = ['midnight', 'ocean', 'ember', 'forest'];
|
|
2313
|
+
const LIGHT_THEMES = ['daylight', 'paper'];
|
|
2314
|
+
const STORAGE_KEY = 'awaitly-viz-theme';
|
|
2315
|
+
|
|
2316
|
+
function getSystemPreference() {
|
|
2317
|
+
return window.matchMedia('(prefers-color-scheme: light)').matches ? 'daylight' : 'midnight';
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
function resolveTheme() {
|
|
2321
|
+
if (INITIAL_THEME) return INITIAL_THEME;
|
|
2322
|
+
const stored = localStorage.getItem(STORAGE_KEY);
|
|
2323
|
+
if (stored) return stored;
|
|
2324
|
+
return getSystemPreference();
|
|
2325
|
+
}
|
|
2326
|
+
|
|
2327
|
+
function applyTheme(name) {
|
|
2328
|
+
document.documentElement.setAttribute('data-theme', name);
|
|
2329
|
+
localStorage.setItem(STORAGE_KEY, name);
|
|
2330
|
+
|
|
2331
|
+
// Update theme menu active state
|
|
2332
|
+
document.querySelectorAll('.theme-swatch').forEach(function(btn) {
|
|
2333
|
+
btn.classList.toggle('active', btn.dataset.theme === name);
|
|
2334
|
+
});
|
|
2335
|
+
|
|
2336
|
+
// Re-render Mermaid with matching theme
|
|
2337
|
+
rerenderMermaid(DARK_THEMES.includes(name) ? 'dark' : 'default');
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
var currentMermaidTheme = null;
|
|
2341
|
+
var mermaidSource = document.querySelector('.mermaid').textContent;
|
|
2342
|
+
|
|
2343
|
+
function rerenderMermaid(mermaidThemeName) {
|
|
2344
|
+
if (mermaidThemeName === currentMermaidTheme) return;
|
|
2345
|
+
currentMermaidTheme = mermaidThemeName;
|
|
2346
|
+
|
|
2347
|
+
var diagramEl = document.getElementById('diagram');
|
|
2348
|
+
// Clear existing
|
|
2349
|
+
diagramEl.innerHTML = '<pre class="mermaid">' + mermaidSource + '</pre>';
|
|
2350
|
+
|
|
2351
|
+
mermaid.initialize({
|
|
2352
|
+
startOnLoad: false,
|
|
2353
|
+
theme: mermaidThemeName,
|
|
2354
|
+
themeVariables: mermaidThemeName === 'dark' ? {
|
|
2355
|
+
darkMode: true,
|
|
2356
|
+
background: 'transparent',
|
|
2357
|
+
primaryColor: '#1e2235',
|
|
2358
|
+
primaryTextColor: '#c8ccda',
|
|
2359
|
+
primaryBorderColor: '#363d55',
|
|
2360
|
+
lineColor: '#3d4460',
|
|
2361
|
+
secondaryColor: '#2a1c3d',
|
|
2362
|
+
tertiaryColor: '#152e1f',
|
|
2363
|
+
} : {
|
|
2364
|
+
darkMode: false,
|
|
2365
|
+
background: 'transparent',
|
|
2366
|
+
primaryColor: '#ffffff',
|
|
2367
|
+
primaryTextColor: '#2a3448',
|
|
2368
|
+
primaryBorderColor: '#c8d0e0',
|
|
2369
|
+
lineColor: '#b0b8c8',
|
|
2370
|
+
secondaryColor: '#f4eaff',
|
|
2371
|
+
tertiaryColor: '#e8f8ee',
|
|
2372
|
+
},
|
|
2373
|
+
flowchart: {
|
|
2374
|
+
useMaxWidth: true,
|
|
2375
|
+
htmlLabels: true,
|
|
2376
|
+
curve: 'basis',
|
|
2377
|
+
},
|
|
2378
|
+
securityLevel: 'loose',
|
|
2379
|
+
});
|
|
2380
|
+
|
|
2381
|
+
mermaid.run({ querySelector: '.mermaid' }).then(function() {
|
|
2382
|
+
setTimeout(function() {
|
|
2383
|
+
stripMermaidInlineStyles();
|
|
2384
|
+
attachHandlers();
|
|
2385
|
+
}, 50);
|
|
2386
|
+
});
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
// Listen for system theme changes
|
|
2390
|
+
window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', function(e) {
|
|
2391
|
+
if (!localStorage.getItem(STORAGE_KEY)) {
|
|
2392
|
+
applyTheme(e.matches ? 'daylight' : 'midnight');
|
|
2393
|
+
}
|
|
2394
|
+
});
|
|
2395
|
+
|
|
2396
|
+
// ================================================================
|
|
2397
|
+
// Theme Picker UI
|
|
2398
|
+
// ================================================================
|
|
2399
|
+
|
|
2400
|
+
var themeBtn = document.getElementById('theme-btn');
|
|
2401
|
+
var themeMenu = document.getElementById('theme-menu');
|
|
2402
|
+
|
|
2403
|
+
themeBtn.addEventListener('click', function(e) {
|
|
2404
|
+
e.stopPropagation();
|
|
2405
|
+
themeMenu.hidden = !themeMenu.hidden;
|
|
2406
|
+
});
|
|
2407
|
+
|
|
2408
|
+
document.addEventListener('click', function() {
|
|
2409
|
+
themeMenu.hidden = true;
|
|
2410
|
+
});
|
|
2411
|
+
|
|
2412
|
+
themeMenu.addEventListener('click', function(e) {
|
|
2413
|
+
e.stopPropagation();
|
|
2414
|
+
var btn = e.target.closest('[data-theme]');
|
|
2415
|
+
if (btn) {
|
|
2416
|
+
applyTheme(btn.dataset.theme);
|
|
2417
|
+
themeMenu.hidden = true;
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
|
|
2421
|
+
// ================================================================
|
|
2422
|
+
// Mermaid Init & Click Handlers
|
|
2423
|
+
// ================================================================
|
|
2424
|
+
|
|
2425
|
+
// Strip Mermaid's inline style="fill:... !important" so CSS custom properties win
|
|
2426
|
+
function stripMermaidInlineStyles() {
|
|
2427
|
+
var svg = document.querySelector('#diagram svg');
|
|
2428
|
+
if (!svg) return;
|
|
2429
|
+
|
|
2430
|
+
// Remove inline fill/stroke from shape elements inside nodes
|
|
2431
|
+
svg.querySelectorAll('.node rect, .node polygon, .node circle, .node .basic').forEach(function(el) {
|
|
2432
|
+
el.removeAttribute('style');
|
|
2433
|
+
});
|
|
2434
|
+
|
|
2435
|
+
// Also strip inline styles from edge labels and edges
|
|
2436
|
+
svg.querySelectorAll('.edgeLabel, .edgeLabel rect, .edgeLabel .edgeLabel').forEach(function(el) {
|
|
2437
|
+
el.removeAttribute('style');
|
|
2438
|
+
});
|
|
2439
|
+
|
|
2440
|
+
// Strip marker styles
|
|
2441
|
+
svg.querySelectorAll('marker path').forEach(function(el) {
|
|
2442
|
+
el.removeAttribute('style');
|
|
2443
|
+
});
|
|
2444
|
+
|
|
2445
|
+
// Strip edge line styles
|
|
2446
|
+
svg.querySelectorAll('.edge-pattern-solid, .flowchart-link').forEach(function(el) {
|
|
2447
|
+
el.removeAttribute('style');
|
|
2448
|
+
});
|
|
2449
|
+
}
|
|
2450
|
+
|
|
2451
|
+
var selectedNodeId = null;
|
|
2452
|
+
|
|
2453
|
+
function attachHandlers() {
|
|
2454
|
+
var svg = document.querySelector('#diagram svg');
|
|
2455
|
+
if (!svg) return;
|
|
2456
|
+
|
|
2457
|
+
svg.querySelectorAll('.node').forEach(function(node) {
|
|
2458
|
+
node.style.cursor = 'pointer';
|
|
2459
|
+
node.addEventListener('click', function(e) {
|
|
2460
|
+
e.stopPropagation();
|
|
2461
|
+
var nodeId = extractNodeId(node);
|
|
2462
|
+
if (nodeId) selectNode(nodeId, node);
|
|
2463
|
+
});
|
|
2464
|
+
});
|
|
2465
|
+
|
|
2466
|
+
svg.addEventListener('click', function(e) {
|
|
2467
|
+
if (e.target === svg || e.target.closest('.node') === null) {
|
|
2468
|
+
deselectAll();
|
|
2469
|
+
}
|
|
2470
|
+
});
|
|
2471
|
+
}
|
|
2472
|
+
|
|
2473
|
+
function extractNodeId(nodeEl) {
|
|
2474
|
+
var id = nodeEl.id || '';
|
|
2475
|
+
var match = id.match(/^flowchart-(.+?)-\\d+$/);
|
|
2476
|
+
if (match) return match[1];
|
|
2477
|
+
return nodeEl.getAttribute('data-id') || null;
|
|
2478
|
+
}
|
|
2479
|
+
|
|
2480
|
+
function selectNode(mermaidId, nodeEl) {
|
|
2481
|
+
document.querySelectorAll('.node.selected').forEach(function(n) {
|
|
2482
|
+
n.classList.remove('selected');
|
|
2483
|
+
});
|
|
2484
|
+
nodeEl.classList.add('selected');
|
|
2485
|
+
selectedNodeId = mermaidId;
|
|
2486
|
+
|
|
2487
|
+
var meta = WORKFLOW_DATA.nodes[mermaidId];
|
|
2488
|
+
if (meta) {
|
|
2489
|
+
renderInspector(meta);
|
|
2490
|
+
} else {
|
|
2491
|
+
renderInspectorFallback(mermaidId);
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
|
|
2495
|
+
function deselectAll() {
|
|
2496
|
+
document.querySelectorAll('.node.selected').forEach(function(n) {
|
|
2497
|
+
n.classList.remove('selected');
|
|
2498
|
+
});
|
|
2499
|
+
selectedNodeId = null;
|
|
2500
|
+
document.getElementById('inspector').innerHTML =
|
|
2501
|
+
'<div class="inspector-placeholder"><p>Click a node to inspect</p><p class="hint">Hover over nodes to highlight</p></div>';
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
function renderInspector(meta) {
|
|
2505
|
+
var inspector = document.getElementById('inspector');
|
|
2506
|
+
var html = '<div class="inspector-content">';
|
|
2507
|
+
|
|
2508
|
+
html += '<div class="inspector-header">';
|
|
2509
|
+
html += '<span class="inspector-type">' + esc(meta.type) + '</span>';
|
|
2510
|
+
html += '<span class="inspector-name">' + esc(meta.name) + '</span>';
|
|
2511
|
+
html += '</div>';
|
|
2512
|
+
|
|
2513
|
+
if (meta.stepId || meta.callee) {
|
|
2514
|
+
html += '<div class="inspector-section"><h3>Identity</h3>';
|
|
2515
|
+
if (meta.stepId) html += row('Step ID', meta.stepId);
|
|
2516
|
+
if (meta.callee) html += row('Callee', meta.callee);
|
|
2517
|
+
if (meta.mermaidId) html += row('Node ID', meta.mermaidId);
|
|
2518
|
+
html += '</div>';
|
|
2519
|
+
}
|
|
2520
|
+
|
|
2521
|
+
if (meta.description) {
|
|
2522
|
+
html += '<div class="inspector-section"><h3>Description</h3>';
|
|
2523
|
+
html += '<div class="inspector-code">' + esc(meta.description) + '</div></div>';
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
if (meta.inputType || meta.outputType) {
|
|
2527
|
+
html += '<div class="inspector-section"><h3>Types</h3>';
|
|
2528
|
+
if (meta.inputType) html += row('Input', meta.inputType);
|
|
2529
|
+
if (meta.outputType) html += row('Output', meta.outputType);
|
|
2530
|
+
html += '</div>';
|
|
2531
|
+
}
|
|
2532
|
+
|
|
2533
|
+
if (meta.out || (meta.reads && meta.reads.length > 0)) {
|
|
2534
|
+
html += '<div class="inspector-section"><h3>Data Flow</h3>';
|
|
2535
|
+
if (meta.out) html += row('Writes to', 'ctx.' + meta.out);
|
|
2536
|
+
if (meta.reads && meta.reads.length > 0) {
|
|
2537
|
+
html += row('Reads', meta.reads.map(function(r) { return 'ctx.' + r; }).join(', '));
|
|
2538
|
+
}
|
|
2539
|
+
html += '</div>';
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
if (meta.retry || meta.timeout) {
|
|
2543
|
+
html += '<div class="inspector-section"><h3>Resilience</h3>';
|
|
2544
|
+
if (meta.retry) {
|
|
2545
|
+
html += row('Retry attempts', String(meta.retry.attempts || '?'));
|
|
2546
|
+
if (meta.retry.backoff) html += row('Backoff', String(meta.retry.backoff));
|
|
2547
|
+
if (meta.retry.baseDelay) html += row('Base delay', meta.retry.baseDelay + 'ms');
|
|
2548
|
+
}
|
|
2549
|
+
if (meta.timeout) html += row('Timeout', (meta.timeout.ms || '?') + 'ms');
|
|
2550
|
+
html += '</div>';
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
if (meta.condition) {
|
|
2554
|
+
html += '<div class="inspector-section"><h3>Condition</h3>';
|
|
2555
|
+
html += '<div class="inspector-code">' + esc(meta.condition) + '</div>';
|
|
2556
|
+
if (meta.helper) html += row('Helper', meta.helper);
|
|
2557
|
+
html += '</div>';
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2560
|
+
if (meta.expression) {
|
|
2561
|
+
html += '<div class="inspector-section"><h3>Switch Expression</h3>';
|
|
2562
|
+
html += '<div class="inspector-code">' + esc(meta.expression) + '</div>';
|
|
2563
|
+
if (meta.cases) {
|
|
2564
|
+
html += '<div style="margin-top:6px">';
|
|
2565
|
+
meta.cases.forEach(function(c) {
|
|
2566
|
+
html += '<span class="inspector-tag">' + (c.isDefault ? 'default' : esc(c.value || '?')) + '</span>';
|
|
2567
|
+
});
|
|
2568
|
+
html += '</div>';
|
|
2569
|
+
}
|
|
2570
|
+
html += '</div>';
|
|
2571
|
+
}
|
|
2572
|
+
|
|
2573
|
+
if (meta.loopType) {
|
|
2574
|
+
html += '<div class="inspector-section"><h3>Loop</h3>';
|
|
2575
|
+
html += row('Type', meta.loopType);
|
|
2576
|
+
if (meta.iterSource) html += row('Source', meta.iterSource);
|
|
2577
|
+
if (meta.boundCount !== undefined) html += row('Iterations', String(meta.boundCount));
|
|
2578
|
+
html += '</div>';
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
if (meta.mode || meta.childCount !== undefined) {
|
|
2582
|
+
html += '<div class="inspector-section"><h3>Execution</h3>';
|
|
2583
|
+
if (meta.mode) html += row('Mode', meta.mode);
|
|
2584
|
+
if (meta.childCount !== undefined) html += row('Branches', String(meta.childCount));
|
|
2585
|
+
html += '</div>';
|
|
2586
|
+
}
|
|
2587
|
+
|
|
2588
|
+
if (meta.hasCompensation !== undefined) {
|
|
2589
|
+
html += '<div class="inspector-section"><h3>Saga</h3>';
|
|
2590
|
+
html += row('Compensation', meta.hasCompensation ? 'Yes' : 'No');
|
|
2591
|
+
if (meta.compensationCallee) html += row('Compensation fn', meta.compensationCallee);
|
|
2592
|
+
html += '</div>';
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
if (meta.workflowName && meta.type === 'workflow-ref') {
|
|
2596
|
+
html += '<div class="inspector-section"><h3>Reference</h3>';
|
|
2597
|
+
html += row('Workflow', meta.workflowName);
|
|
2598
|
+
html += row('Resolved', meta.resolved ? 'Yes' : 'No');
|
|
2599
|
+
html += '</div>';
|
|
2600
|
+
}
|
|
2601
|
+
|
|
2602
|
+
if (meta.errors && meta.errors.length > 0) {
|
|
2603
|
+
html += '<div class="inspector-section"><h3>Error Tags</h3><div>';
|
|
2604
|
+
meta.errors.forEach(function(err) {
|
|
2605
|
+
html += '<span class="inspector-tag">' + esc(err) + '</span>';
|
|
2606
|
+
});
|
|
2607
|
+
html += '</div></div>';
|
|
2608
|
+
}
|
|
2609
|
+
|
|
2610
|
+
if (meta.location) {
|
|
2611
|
+
html += '<div class="inspector-section"><h3>Source</h3>';
|
|
2612
|
+
html += row('File', meta.location.filePath);
|
|
2613
|
+
html += row('Line', String(meta.location.line));
|
|
2614
|
+
html += '</div>';
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
html += '</div>';
|
|
2618
|
+
inspector.innerHTML = html;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
function renderInspectorFallback(mermaidId) {
|
|
2622
|
+
var inspector = document.getElementById('inspector');
|
|
2623
|
+
var name = mermaidId;
|
|
2624
|
+
if (mermaidId === 'start') name = 'Start';
|
|
2625
|
+
else if (mermaidId === 'end_node') name = 'End';
|
|
2626
|
+
inspector.innerHTML = '<div class="inspector-content">' +
|
|
2627
|
+
'<div class="inspector-header">' +
|
|
2628
|
+
'<span class="inspector-type">node</span>' +
|
|
2629
|
+
'<span class="inspector-name">' + esc(name) + '</span>' +
|
|
2630
|
+
'</div>' +
|
|
2631
|
+
'<div class="inspector-section"><p style="color:var(--fg-dim)">No additional metadata for this node.</p></div>' +
|
|
2632
|
+
'</div>';
|
|
2633
|
+
}
|
|
2634
|
+
|
|
2635
|
+
function row(label, value) {
|
|
2636
|
+
return '<div class="inspector-row"><span class="label">' + esc(label) + '</span><span class="value" title="' + esc(value) + '">' + esc(value) + '</span></div>';
|
|
2637
|
+
}
|
|
2638
|
+
|
|
2639
|
+
function esc(str) {
|
|
2640
|
+
if (str == null) return '';
|
|
2641
|
+
return String(str).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"');
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
// ================================================================
|
|
2645
|
+
// Boot
|
|
2646
|
+
// ================================================================
|
|
2647
|
+
|
|
2648
|
+
var initialTheme = resolveTheme();
|
|
2649
|
+
applyTheme(initialTheme);
|
|
2650
|
+
})();
|
|
2651
|
+
`}function Se(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function et(e={}){let{workflowName:t,detectParallel:r=!0,showTimings:o=!0,showKeys:a=!1,colors:n,export:i}=e,s=ce({detectParallel:r}),u=new Set,d,l=ae(),p=ie(),f=Be(),m=he(),w={showTimings:o,showKeys:a,terminalWidth:process.stdout?.columns??80,colors:{...K,...n}};function k(){if(u.size>0){let v=I();for(let O of u)O(v)}}function M(v){if(v.type==="scope_start"||v.type==="scope_end"){$(v);return}s.handleEvent(v),"workflowName"in v&&typeof v.workflowName=="string"&&(d=v.workflowName),k()}function $(v){s.handleScopeEvent(v),k()}function T(v){s.handleDecisionEvent(v),k()}function I(){let v=s.getIR(),O=t??d??v.root.name;return O&&(v.root.name=O),v}function S(){let v=I();return l.render(v,w)}function x(v){let O=I();switch(v){case"ascii":return l.render(O,w);case"mermaid":return p.render(O,w);case"json":{let J=O.hooks?{...O,hooks:{...O.hooks,onAfterStep:O.hooks.onAfterStep instanceof Map?Object.fromEntries(O.hooks.onAfterStep):O.hooks.onAfterStep??{}}}:O;return JSON.stringify(J,(tt,be)=>typeof be=="bigint"?be.toString():be,2)}case"logger":return f.render(O,w);case"flowchart":return m.render(O,w);default:throw new Error(`Unknown format: ${v}`)}}function g(){s.reset(),k()}function y(v){return u.add(v),()=>u.delete(v)}function E(v,O){if(v)return v;if(i?.default)return i.default;throw new Error(`${O}(): No export provider configured. Pass { provider: 'kroki' } or { provider: 'mermaid-ink' }, or set export.default in createVisualizer().`)}function C(){let v=I();return{kind:"mermaid",source:p.render(v,w)}}function N(v){let O=xe(C(),"svg",E(v,"toSvgUrl"),{caller:"toSvgUrl"});if(!O.ok)throw new Error(`toSvgUrl: Export failed - ${O.error}`);return O.value}function L(v){let O=xe(C(),"png",E(v,"toPngUrl"),{caller:"toPngUrl"});if(!O.ok)throw new Error(`toPngUrl: Export failed - ${O.error}`);return O.value}function P(v){let O=xe(C(),"pdf",E(v,"toPdfUrl"),{caller:"toPdfUrl"});if(!O.ok)throw new Error(`toPdfUrl: Export failed - ${O.error}`);return O.value}function D(v,O){switch(v){case"svg":return N(O);case"png":return L(O);case"pdf":return P(O);default:return v}}return{handleEvent:M,handleScopeEvent:$,handleDecisionEvent:T,getIR:I,render:S,renderAs:x,reset:g,onUpdate:y,toUrl:D,toSvgUrl:N,toPngUrl:L,toPdfUrl:P}}function Io(...e){return(t,r)=>{for(let o of e)o(t,r)}}function Ro(e,t={}){let r=et(t);for(let o of e)o.type.startsWith("decision_")?r.handleDecisionEvent(o):r.handleEvent(o);return r.render()}function Eo(e={}){let t=[];return{handleEvent:r=>{t.push(r)},handleDecisionEvent:r=>{t.push(r)},getEvents:()=>[...t],getWorkflowEvents:()=>t.filter(r=>!r.type.startsWith("decision_")),getDecisionEvents:()=>t.filter(r=>r.type.startsWith("decision_")),clear:()=>{t.length=0},visualize:()=>{let r=et(e);for(let o of t)o.type.startsWith("decision_")?r.handleDecisionEvent(o):r.handleEvent(o);return r.render()},visualizeAs:r=>{let o=et(e);for(let a of t)a.type.startsWith("decision_")?o.handleDecisionEvent(a):o.handleEvent(a);return o.renderAs(r)}}}export{ae as asciiRenderer,Pe as buildMermaidInkUrl,Io as combineEventHandlers,Eo as createEventCollector,ce as createIRBuilder,an as createLiveVisualizer,Vr as createMermaidInkGenerator,Dt as createParallelDetector,Xt as createPerformanceAnalyzer,cn as createTimeTravelController,Ar as createUrlGenerator,et as createVisualizer,K as defaultColorScheme,Ee as detectParallelGroups,wt as encodeForMermaidInk,Se as escapeHtml,he as flowchartRenderer,ln as generateInteractiveHTML,ve as getHeatLevel,wn as hasChildren,nn as htmlRenderer,X as isDecisionNode,G as isParallelNode,z as isRaceNode,rt as isSequenceNode,V as isStepNode,ne as isStreamNode,Be as loggerRenderer,ie as mermaidRenderer,on as renderToHTML,xe as toExportUrl,Br as toKrokiPngUrl,Wr as toKrokiSvgUrl,ue as toKrokiUrl,zr as toMermaidInkJpegUrl,jr as toMermaidInkPdfUrl,Ur as toMermaidInkPngUrl,Fr as toMermaidInkSvgUrl,Y as toMermaidInkUrl,Kr as toMermaidInkWebpUrl,Qe as trackDecision,sn as trackIf,dn as trackSwitch,Ro as visualizeEvents};
|
|
1680
2652
|
//# sourceMappingURL=index.js.map
|