@workflow/web 4.0.1-beta.21 → 4.0.1-beta.23

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.
Files changed (63) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/build-manifest.json +2 -2
  3. package/.next/fallback-build-manifest.json +2 -2
  4. package/.next/prerender-manifest.json +3 -3
  5. package/.next/server/app/_global-error.html +2 -2
  6. package/.next/server/app/_global-error.rsc +1 -1
  7. package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  8. package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  9. package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  10. package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  11. package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  12. package/.next/server/app/_not-found/page/server-reference-manifest.json +36 -21
  13. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  14. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  15. package/.next/server/app/page/server-reference-manifest.json +37 -22
  16. package/.next/server/app/page.js.nft.json +1 -1
  17. package/.next/server/app/page_client-reference-manifest.js +1 -1
  18. package/.next/server/app/run/[runId]/page/server-reference-manifest.json +37 -22
  19. package/.next/server/app/run/[runId]/page.js.nft.json +1 -1
  20. package/.next/server/app/run/[runId]/page_client-reference-manifest.js +1 -1
  21. package/.next/server/chunks/ssr/[root-of-the-server]__1365a866._.js +3 -3
  22. package/.next/server/chunks/ssr/[root-of-the-server]__1365a866._.js.map +1 -1
  23. package/.next/server/chunks/ssr/[root-of-the-server]__2168651f._.js +1 -1
  24. package/.next/server/chunks/ssr/[root-of-the-server]__2168651f._.js.map +1 -1
  25. package/.next/server/chunks/ssr/[root-of-the-server]__25c4ca9a._.js +1 -1
  26. package/.next/server/chunks/ssr/[root-of-the-server]__25c4ca9a._.js.map +1 -1
  27. package/.next/server/chunks/ssr/[root-of-the-server]__d416fa5e._.js +1 -1
  28. package/.next/server/chunks/ssr/[root-of-the-server]__d416fa5e._.js.map +1 -1
  29. package/.next/server/chunks/ssr/[root-of-the-server]__e576a2e1._.js +7 -7
  30. package/.next/server/chunks/ssr/[root-of-the-server]__e576a2e1._.js.map +1 -1
  31. package/.next/server/chunks/ssr/_af28dabd._.js +1 -1
  32. package/.next/server/chunks/ssr/_af28dabd._.js.map +1 -1
  33. package/.next/server/chunks/ssr/_bff7cae2._.js +1 -1
  34. package/.next/server/chunks/ssr/_bff7cae2._.js.map +1 -1
  35. package/.next/server/chunks/ssr/_c8bf1458._.js +1 -1
  36. package/.next/server/chunks/ssr/_c8bf1458._.js.map +1 -1
  37. package/.next/server/chunks/ssr/packages_web_src_19bb3951._.js +3 -0
  38. package/.next/server/chunks/ssr/packages_web_src_19bb3951._.js.map +1 -0
  39. package/.next/server/chunks/ssr/packages_web_src_app_page_tsx_cd282e82._.js +2 -2
  40. package/.next/server/chunks/ssr/packages_web_src_app_page_tsx_cd282e82._.js.map +1 -1
  41. package/.next/server/chunks/ssr/packages_web_src_app_run_[runId]_page_tsx_c7d0b139._.js +1 -1
  42. package/.next/server/chunks/ssr/packages_web_src_app_run_[runId]_page_tsx_c7d0b139._.js.map +1 -1
  43. package/.next/server/pages/500.html +2 -2
  44. package/.next/server/server-reference-manifest.js +1 -1
  45. package/.next/server/server-reference-manifest.json +56 -27
  46. package/.next/static/chunks/{1633a4677cb7eacd.js → 30b98d965a129331.js} +1 -1
  47. package/.next/static/chunks/{a2fdd31ef7d1ed50.js → 31d3eed44663a2d8.js} +3 -3
  48. package/.next/static/chunks/4b98d98ef7601f2c.js +1 -0
  49. package/.next/static/chunks/50691ade475383ae.js +5 -0
  50. package/.next/static/chunks/837b0d5cc6ee8f87.js +60 -0
  51. package/.next/static/chunks/8f6413f9323a44e5.js +14 -0
  52. package/.next/static/chunks/{d3781b000675e89a.js → ce42d7684243cb43.js} +1 -1
  53. package/.next/trace +1 -1
  54. package/.next/trace-build +1 -1
  55. package/package.json +4 -3
  56. package/.next/server/chunks/ssr/packages_web_src_components_ui_select_tsx_7c5238ef._.js +0 -3
  57. package/.next/server/chunks/ssr/packages_web_src_components_ui_select_tsx_7c5238ef._.js.map +0 -1
  58. package/.next/static/chunks/7993564ea9cd3862.js +0 -60
  59. package/.next/static/chunks/915c48af605695f8.js +0 -5
  60. package/.next/static/chunks/ebaf4c277606b4fc.js +0 -14
  61. /package/.next/static/{1Gd0u_mHFXgTr2DR4OTNR → Ven1ulyDX7wtUfVstJodR}/_buildManifest.js +0 -0
  62. /package/.next/static/{1Gd0u_mHFXgTr2DR4OTNR → Ven1ulyDX7wtUfVstJodR}/_clientMiddlewareManifest.json +0 -0
  63. /package/.next/static/{1Gd0u_mHFXgTr2DR4OTNR → Ven1ulyDX7wtUfVstJodR}/_ssgManifest.js +0 -0
@@ -11,6 +11,6 @@ Alternatively, you can use your own component as a description by assigning it a
11
11
  For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return r.useEffect(()=>{document.getElementById(a.current?.getAttribute("aria-describedby"))||console.warn(b)},[b,a]),null},aV=a.i(397494),aW=a.i(676653);function aX({...a}){return(0,d.jsx)(aG,{"data-slot":"alert-dialog",...a})}function aY({...a}){return(0,d.jsx)(aH,{"data-slot":"alert-dialog-portal",...a})}function aZ({className:a,...b}){return(0,d.jsx)(aI,{"data-slot":"alert-dialog-overlay",className:(0,aW.cn)("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...b})}function a$({className:a,...b}){return(0,d.jsxs)(aY,{children:[(0,d.jsx)(aZ,{}),(0,d.jsx)(aM,{"data-slot":"alert-dialog-content",className:(0,aW.cn)("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...b})]})}function a_({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"alert-dialog-header",className:(0,aW.cn)("flex flex-col gap-2 text-center sm:text-left",a),...b})}function a0({className:a,...b}){return(0,d.jsx)("div",{"data-slot":"alert-dialog-footer",className:(0,aW.cn)("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...b})}function a1({className:a,...b}){return(0,d.jsx)(aO,{"data-slot":"alert-dialog-title",className:(0,aW.cn)("text-lg font-semibold",a),...b})}function a2({className:a,...b}){return(0,d.jsx)(aQ,{"data-slot":"alert-dialog-description",className:(0,aW.cn)("text-muted-foreground text-sm",a),...b})}function a3({className:a,...b}){return(0,d.jsx)(aR,{className:(0,aW.cn)((0,aV.buttonVariants)(),a),...b})}function a4({className:a,...b}){return(0,d.jsx)(aT,{className:(0,aW.cn)((0,aV.buttonVariants)({variant:"outline"}),a),...b})}var a5=a.i(322178);function a6({...a}){return(0,d.jsx)("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...a})}function a7({className:a,...b}){return(0,d.jsx)("ol",{"data-slot":"breadcrumb-list",className:(0,aW.cn)("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",a),...b})}function a8({className:a,...b}){return(0,d.jsx)("li",{"data-slot":"breadcrumb-item",className:(0,aW.cn)("inline-flex items-center gap-1.5",a),...b})}function a9({asChild:a,className:b,...c}){let e=a?A.Slot:"a";return(0,d.jsx)(e,{"data-slot":"breadcrumb-link",className:(0,aW.cn)("hover:text-foreground transition-colors",b),...c})}function ba({className:a,...b}){return(0,d.jsx)("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:(0,aW.cn)("text-foreground font-normal",a),...b})}function bb({children:a,className:b,...c}){return(0,d.jsx)("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:(0,aW.cn)("[&>svg]:size-3.5",b),...c,children:a??(0,d.jsx)(a5.ChevronRight,{})})}a.i(139274);var bc=a.i(725538),bd=a.i(393557),be=a.i(508624);let bf="sleep";function bg(a){return a.replace(/\/\/\.\.\//g,"//")}function bh(a){let b=a.split("//");return b.length>=3?b[b.length-1]:null}var bi=a.i(691435),bj=a.i(432320);function bk({hasError:a,errorMessage:b}){return(0,d.jsx)("div",{className:"flex items-center gap-2",children:(0,d.jsxs)(bd.Tooltip,{children:[(0,d.jsx)(bd.TooltipTrigger,{asChild:!0,children:(0,d.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,d.jsx)("div",{className:`w-2 h-2 rounded-full ${a?"bg-red-500":"bg-green-500 animate-pulse"}`}),(0,d.jsx)("span",{className:`text-xs $
12
12
  hasError
13
13
  ? 'text-red-600 dark:text-red-400'
14
- : 'text-muted-foreground'`,children:a?"Error":"Live"})]})}),(0,d.jsx)(bd.TooltipContent,{children:(0,d.jsx)("p",{children:a?`Error updating data: ${b}`:`Content updates every ${aW.LIVE_UPDATE_INTERVAL_MS/1e3} seconds`})})]})})}var bl=a.i(315244),bm=a.i(93354),bn=a.i(358088),bo=a.i(602049),bp=a.i(26790),bq=a.i(16303),br=a.i(904730),bs=a.i(706998);function bt(a){return"retrying"===a?"running":a}let bu={loopNode:function({data:a,selected:b}){return(0,d.jsxs)("div",{className:`relative ${a.className||""}`,style:{borderWidth:a.nodeStyle?.borderWidth??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:a.nodeStyle?.backgroundColor,borderColor:a.nodeStyle?.borderColor??"#9ca3af",opacity:a.nodeStyle?.opacity,boxShadow:b?"0 0 0 2px rgba(168, 85, 247, 0.5)":void 0},children:[a.label,(0,d.jsx)(bn.Handle,{type:"target",position:bo.Position.Top,className:"!bg-purple-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Bottom,className:"!bg-purple-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Left,id:"loop-out",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"30%"}}),(0,d.jsx)(bn.Handle,{type:"target",position:bo.Position.Left,id:"loop-in",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"70%"}})]})},parallelGroup:bs.ParallelGroupComponent,executionNode:function({data:a,selected:b}){let c="workflow_start"===a.nodeKind,e="workflow_end"===a.nodeKind;return(0,d.jsxs)("div",{className:`relative ${a.className||""}`,style:{borderWidth:a.nodeStyle?.borderWidth??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:a.nodeStyle?.backgroundColor,borderColor:a.nodeStyle?.borderColor??"#9ca3af",opacity:a.nodeStyle?.opacity,boxShadow:b?"0 0 0 2px rgba(59, 130, 246, 0.35)":void 0},children:[a.label,!c&&(0,d.jsx)(bn.Handle,{type:"target",position:bo.Position.Top,className:"!bg-muted"}),!e&&(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Bottom,className:"!bg-muted"})]})},diamondNode:function({data:a,selected:b}){return(0,d.jsxs)("div",{className:`relative flex items-center justify-center ${a.className||""}`,style:{width:160,height:160},children:[(0,d.jsx)("div",{style:{width:112,height:112,transform:"rotate(45deg)",borderWidth:2,borderStyle:"solid",borderRadius:4,backgroundColor:a.nodeStyle?.backgroundColor,borderColor:a.nodeStyle?.borderColor??"#ef4444",opacity:a.nodeStyle?.opacity,boxShadow:b?"0 0 0 2px rgba(239, 68, 68, 0.5)":void 0}}),(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-auto",style:{fontSize:11,fontWeight:600,padding:40},title:"string"==typeof a.label?a.label:void 0,children:(0,d.jsx)("span",{className:"text-center line-clamp-3 overflow-hidden",children:a.label})}),(0,d.jsx)(bn.Handle,{type:"target",position:bo.Position.Top,className:"!bg-red-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Bottom,id:"bottom",className:"!bg-red-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Left,id:"left",className:"!bg-red-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Right,id:"right",className:"!bg-red-500"})]})}},bv=(0,bs.createEdgeTypes)(bs.executionSelfLoopStyle);function bw(a,b,c){let e=(0,d.jsxs)("div",{className:"flex items-start gap-2 w-full overflow-hidden",children:[(0,d.jsx)("div",{className:"flex-shrink-0",children:(0,bs.getNodeIcon)(a.nodeKind,a.label)}),(0,d.jsx)("span",{className:"text-sm font-medium break-words whitespace-normal leading-tight flex-1 min-w-0",children:a.label})]});if(!c||0===c.length)return e;let f=c[c.length-1],g=c.length,h=g>1;return h||f.duration&&f.duration>0?(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 w-full",children:[e,(0,d.jsxs)("div",{className:"flex flex-wrap gap-1 text-xs",children:[h&&(0,d.jsxs)(br.Badge,{variant:"outline",className:"text-xs px-1.5 py-0 border-orange-500 text-orange-700 dark:text-orange-300",children:["↻ ",g,"x"]}),f.duration&&f.duration>0&&(0,d.jsxs)(br.Badge,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",(0,bq.formatDuration)(f.duration,!0)]})]})]}):e}let bx={...bs.LAYOUT,VERTICAL_SPACING:320};function by(a,b){let{nodes:c,groupNodes:d}=(0,bs.calculateEnhancedLayout)(a,bx),e=new Map,f=new Map;for(let a of d)a.id.startsWith("group_")&&f.set(a.id,a.position);for(let a of c){let b=a.metadata?.parallelGroupId?`group_${a.metadata.parallelGroupId}`:null;b&&f.has(b)&&e.set(a.id,b)}let g=[];for(let a of d.filter(a=>a.id.startsWith("group_")))g.push({id:a.id,type:"parallelGroup",position:a.position,style:{...a.style,cursor:"grab",zIndex:-1},data:a.data,selectable:!0,draggable:!0});for(let a of c){let c=b?.nodeExecutions.get(a.id),d=function(a,b){let c=(0,bs.getNodeBackgroundColor)(a);if(!b||0===b.length)return{color:"hsl(var(--card-foreground))",backgroundColor:c,borderColor:"#9ca3af",opacity:.4};let d=b[b.length-1],e="#9ca3af",f=2;switch(d.status){case"completed":e="#22c55e";break;case"failed":e="#ef4444",f=3;break;case"running":e="#3b82f6",f=2;break;case"retrying":e="#f97316";break;case"cancelled":e="#eab308";break;case"pending":e="#9ca3af"}return{color:"hsl(var(--card-foreground))",backgroundColor:c,borderColor:e,borderWidth:f}}(a.data.nodeKind,c),h=b?.currentNode===a.id,i=!!a.metadata?.loopId,j=!!a.metadata?.loopIsAwait,k="conditional"===a.data.nodeKind,l=k?"diamondNode":i?"loopNode":"executionNode",m=e.get(a.id),n=a.position;if(m){let b=f.get(m);b&&(n={x:a.position.x-b.x,y:a.position.y-b.y})}let o=h?"animate-pulse-subtle":"";i?g.push({id:a.id,type:l,position:n,parentId:m,extent:m?"parent":void 0,expandParent:!0,data:{...a.data,label:bw(a.data,a.metadata,c),executions:c,isLoopNode:!0,isAwaitLoop:j,nodeStyle:d,className:o}}):k?g.push({id:a.id,type:l,position:n,parentId:m,extent:m?"parent":void 0,expandParent:!0,data:{...a.data,label:a.data.label,executions:c,nodeStyle:d,className:o}}):g.push({id:a.id,type:l,position:n,parentId:m,extent:m?"parent":void 0,expandParent:!0,data:{...a.data,label:bw(a.data,a.metadata,c),executions:c,nodeStyle:d,className:o},style:{width:220}})}return g}function bz(a,b){let{additionalEdges:c}=(0,bs.calculateEnhancedLayout)(a,bx),e=[...a.edges.map(a=>"loop"===a.type?{...a,id:`loop_back_${a.source}_${a.target}`,isOriginal:!0}:{...a,isOriginal:!0}),...c.map(a=>({...a,isOriginal:!1}))];return(0,bs.consolidateEdges)(e,a.nodes).map(a=>{let c;if("selfLoop"===a.type)return{id:a.id,source:a.source,target:a.target,sourceHandle:a.sourceHandle,targetHandle:a.targetHandle,type:"selfLoop",label:a.label,markerEnd:{type:bo.MarkerType.ArrowClosed,width:12,height:12,color:"#a855f7"}};let e=b?.edgeTraversals.get(a.id);if(!e&&a.isConsolidated&&a.originalEdgeIds)for(let c of a.originalEdgeIds){let a=b?.edgeTraversals.get(c);if(a&&a.traversalCount>0){e=a;break}}let f=e&&e.traversalCount>0,g=!!b,h=e?.timings.length?e.timings.reduce((a,b)=>a+b,0)/e.timings.length:void 0,i="bezier",j=a.label,k=!1;switch(a.type){case"parallel":i="smoothstep",c="4,4",j=void 0;break;case"loop":i="step",c="8,4";break;case"conditional":i="smoothstep",c="8,4",k=!0;break;default:i="bezier"}let l=f?"#22c55e":"#6b7280",m=f?void 0:c,n=k?"#ffffff":"#6b7280",o=k?"#374151":"#f3f4f6",p=k?"#4b5563":"#d1d5db";return{id:a.id,source:a.source,target:a.target,type:i,animated:f&&b?.status==="running",label:e&&e.traversalCount>1?(0,d.jsxs)("div",{className:"flex flex-col items-center gap-0.5",children:[(0,d.jsxs)(br.Badge,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[e.traversalCount,"×"]}),h&&h>0&&(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["~",(0,bq.formatDuration)(h,!0)]})]}):j,labelStyle:{fill:n,fontWeight:500,fontSize:"11px"},labelBgStyle:{fill:o,fillOpacity:.95,stroke:p,strokeWidth:1},labelBgPadding:[4,6],labelBgBorderRadius:4,markerEnd:{type:bo.MarkerType.ArrowClosed,width:f?14:10,height:f?14:10,color:l},style:{strokeWidth:f?2.5:1,stroke:l,opacity:g&&!f?.35:1,strokeDasharray:m}}})}function bA({selectedNode:a,env:b,onClose:c}){let{node:e,executions:f,stepId:g,runId:i}=a,j=f[f.length-1],k=f.length>1,{data:l,loading:m}=(0,h.useWorkflowResourceData)(b??{},"step",g??"",{runId:i}),n=l?.input??j?.input,o=l?.output??j?.output,q=l?.error??j?.error;return(0,d.jsxs)("div",{className:"h-full flex flex-col bg-background border-l",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b flex-none",children:[(0,d.jsx)("span",{className:"text-xs font-medium truncate flex-1",title:e.data.label,children:e.data.label}),(0,d.jsxs)("div",{className:"flex items-center gap-2 flex-none",children:[j?.duration!==void 0&&j.duration>0&&(0,d.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:(0,bq.formatDuration)(j.duration)}),(0,d.jsx)("div",{className:"w-px h-4 bg-border"}),(0,d.jsx)("button",{type:"button",onClick:c,className:"p-1 rounded hover:bg-muted transition-colors","aria-label":"Close panel",children:(0,d.jsx)(bp.X,{className:"h-4 w-4 text-muted-foreground"})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-3 min-h-0",children:[(0,d.jsxs)("div",{className:"flex flex-col divide-y rounded-lg border overflow-hidden mb-3",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"type"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:e.data.nodeKind})]}),j&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"status"}),(0,d.jsx)(bm.StatusBadge,{status:bt(j.status)})]}),void 0!==j.duration&&j.duration>0&&(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"duration"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:(0,bq.formatDuration)(j.duration)})]}),k&&(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"attempts"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:f.length})]}),j.startedAt&&(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"startedAt"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:new Date(j.startedAt).toLocaleString()})]}),j.completedAt&&(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"completedAt"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:new Date(j.completedAt).toLocaleString()})]})]})]}),m&&g&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[(0,d.jsx)(p.Loader2,{className:"h-3 w-3 animate-spin"}),(0,d.jsx)("span",{children:"Loading step data..."})]}),void 0!==n&&(0,d.jsxs)("details",{className:"group mb-3",children:[(0,d.jsxs)("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[(0,d.jsx)("span",{className:"font-medium",children:"Input"}),(0,d.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",Array.isArray(n)?n.length:1," args)"]})]}),(0,d.jsxs)("div",{className:"relative pl-6 mt-3",children:[(0,d.jsx)("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),(0,d.jsx)("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),(0,d.jsx)("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:(0,d.jsx)("code",{children:JSON.stringify(n,null,2)})})]})]}),void 0!==o&&(0,d.jsxs)("details",{className:"group mb-3",children:[(0,d.jsx)("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:(0,d.jsx)("span",{className:"font-medium",children:"Output"})}),(0,d.jsxs)("div",{className:"relative pl-6 mt-3",children:[(0,d.jsx)("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),(0,d.jsx)("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),(0,d.jsx)("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:(0,d.jsx)("code",{children:JSON.stringify(o,null,2)})})]})]}),q&&(0,d.jsxs)("details",{className:"group mb-3",open:!0,children:[(0,d.jsx)("summary",{className:"cursor-pointer rounded-md border border-red-300 bg-red-50 dark:bg-red-950/20 px-2.5 py-1.5 text-xs hover:brightness-95",children:(0,d.jsx)("span",{className:"font-medium text-red-600 dark:text-red-400",children:"Error"})}),(0,d.jsxs)("div",{className:"relative pl-6 mt-3",children:[(0,d.jsx)("div",{className:"absolute left-3 -top-3 w-px h-3 bg-red-300"}),(0,d.jsx)("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-red-300"}),(0,d.jsx)("pre",{className:"text-[11px] overflow-x-auto rounded-md border border-red-200 p-2.5 bg-red-50 dark:bg-red-950/20 text-red-700 dark:text-red-300 whitespace-pre-wrap max-h-64 overflow-y-auto",children:(0,d.jsx)("code",{children:"object"==typeof q?JSON.stringify(q,null,2):String(q)})})]})]}),k&&(0,d.jsxs)("details",{className:"group",children:[(0,d.jsxs)("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[(0,d.jsx)("span",{className:"font-medium",children:"Attempt History"}),(0,d.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",f.length," attempts)"]})]}),(0,d.jsxs)("div",{className:"relative pl-6 mt-3",children:[(0,d.jsx)("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),(0,d.jsx)("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),(0,d.jsx)("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",children:f.map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 text-[11px]",children:[(0,d.jsxs)("span",{className:"text-muted-foreground",children:["Attempt ",a.attemptNumber]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(bm.StatusBadge,{status:bt(a.status)}),void 0!==a.duration&&a.duration>0&&(0,d.jsx)("span",{className:"font-mono text-muted-foreground",children:(0,bq.formatDuration)(a.duration)})]})]},a.attemptNumber))})]})]})]})]})}function bB({workflow:a,execution:b,env:c,onNodeClick:e}){let[f,g]=(0,r.useState)(null),h=(0,r.useMemo)(()=>by(a,b),[a,b]),i=(0,r.useMemo)(()=>bz(a,b),[a,b]),[j,k,l]=(0,bn.useNodesState)(h),[m,n,o]=(0,bn.useEdgesState)(i);(0,r.useEffect)(()=>{k(c=>{let d=by(a,b),e=new Map(c.map(a=>[a.id,a.position]));return d.map(a=>({...a,position:e.get(a.id)??a.position}))}),n(bz(a,b))},[a,b,k,n]);let p=(0,r.useCallback)((c,d)=>{let f=a.nodes.find(a=>a.id===d.id);if(f){let a=d.data.executions||[],c=a[a.length-1];g({nodeId:d.id,node:f,executions:a,stepId:c?.stepId,runId:b?.runId}),e&&a.length>0&&e(d.id,a)}},[a.nodes,b?.runId,e]),q=(0,r.useCallback)(()=>{g(null)},[]);return(0,d.jsxs)("div",{className:"h-full w-full border rounded-lg bg-background relative overflow-hidden flex",children:[(0,d.jsx)("div",{className:"h-full flex-1 min-w-0",style:{width:f?"calc(100% - 320px)":"100%"},children:(0,d.jsxs)(bn.ReactFlow,{nodes:j,edges:m,onNodesChange:l,onEdgesChange:o,onNodeClick:p,nodeTypes:bu,edgeTypes:bv,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[(0,d.jsx)(bn.Background,{}),(0,d.jsx)(bn.Controls,{}),(0,d.jsx)(bn.Panel,{position:"top-left",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-2 text-xs",children:(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("div",{className:"font-semibold text-[10px] text-muted-foreground mb-1",children:"Status"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-green-500 bg-background"}),(0,d.jsx)("span",{children:"Completed"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-red-500 bg-background"}),(0,d.jsx)("span",{children:"Failed"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-blue-500 bg-background"}),(0,d.jsx)("span",{children:"Running"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-yellow-500 bg-background"}),(0,d.jsx)("span",{children:"Cancelled"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 opacity-50",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-gray-400 bg-background"}),(0,d.jsx)("span",{children:"Pending"})]})]})}),b&&(0,d.jsxs)(bn.Panel,{position:"top-right",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-3 text-xs space-y-1.5",children:[(0,d.jsx)("div",{className:"font-semibold text-sm",children:"Execution"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-muted-foreground",children:"Status:"}),(0,d.jsx)(br.Badge,{variant:"completed"===b.status?"default":"failed"===b.status?"destructive":"cancelled"===b.status?"outline":"secondary",className:"text-xs",children:b.status})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-muted-foreground",children:"Progress:"}),(0,d.jsxs)("span",{className:"font-mono",children:[b.executionPath.length," / ",a.nodes.length]})]})]})]})}),f&&(0,d.jsx)("div",{className:"h-full flex-none",style:{width:320},children:(0,d.jsx)(bA,{selectedNode:f,env:c,onClose:q})})]})}var bC=a.i(303872),bD=a.i(433105);function bE({config:a,run:b,allSteps:c,allEvents:e,env:f}){let{manifest:g,loading:h,error:i}=(0,bi.useWorkflowGraphManifest)(a),j=(0,r.useMemo)(()=>g&&b.workflowName?g.workflows[b.workflowName]??null:null,[g,b.workflowName]),l=(0,r.useMemo)(()=>j&&b.runId?function(a,b,c,d){let e,f,g=new Map,h=[];console.log("[Graph Mapper] Mapping run to execution:",{runId:a.runId,workflowName:a.workflowName,graphNodes:d.nodes.length,stepsCount:b.length}),(f=d.nodes.find(a=>"workflow_start"===a.data.nodeKind))&&(h.push(f.id),g.set(f.id,[{nodeId:f.id,attemptNumber:1,status:"completed",startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0}]));let i=[...b].sort((a,b)=>new Date(a.createdAt).getTime()-new Date(b.createdAt).getTime());console.log("[Graph Mapper] Sorted steps:",i.map(a=>({stepId:a.stepId,stepName:a.stepName,attempt:a.attempt,status:a.status,createdAt:a.createdAt})));let{byStepId:j,byFunctionName:k,primitivesByLabel:l,agentNodes:m,toolNodes:n}=function(a){let b=new Map,c=new Map,d=new Map,e=[],f=new Map;for(let g of a){if(g.data.stepId){let a=bg(g.data.stepId),d=b.get(a)||[];d.push(g),b.set(a,d);let e=bh(a);if(e){let a=c.get(e)||[];a.push(g),c.set(e,a)}}if("primitive"===g.data.nodeKind){let a=g.data.label,b=d.get(a)||[];b.push(g),d.set(a,b)}if("agent"===g.data.nodeKind&&e.push(g),"tool"===g.data.nodeKind){let a=g.data.label.replace(/ \(tool\)$/,""),b=f.get(a)||[];if(b.push(g),f.set(a,b),g.data.stepId){let a=bh(bg(g.data.stepId));if(a){let b=f.get(a)||[];b.includes(g)||(b.push(g),f.set(a,b))}}}}return{byStepId:b,byFunctionName:c,primitivesByLabel:d,agentNodes:e,toolNodes:f}}(d.nodes);console.log("[Graph Mapper] Graph nodes by stepId:",{allGraphNodes:d.nodes.map(a=>({id:a.id,stepId:a.data.stepId,normalizedStepId:a.data.stepId?bg(a.data.stepId):void 0,nodeKind:a.data.nodeKind})),nodesByStepId:Array.from(j.entries()).map(([a,b])=>({stepId:a,nodeIds:b.map(a=>a.id)}))});let o=new Map,p=[],q=null,r=null;for(let a=0;a<=i.length;a++){let b=i[a];if(b&&b.stepId===q)p.push(b);else{if(p.length>0&&r){let a=function(a,b,c,d,e,f,g){let h=bg(b),i=e.get(h)||0;e.set(h,i+1);let j=c.get(h)||[],k="step-id";if(0===j.length){let a=bh(h);a&&(j=d.get(a)||[],k="function-name")}let l=1===j.length?j[0]:j[i];if(console.log("[Graph Mapper] Processing step group:",{stepName:b,normalizedStepName:h,attempts:a.length,occurrenceIndex:i,totalNodesWithStepId:j.length,selectedNode:l?.id,allNodesWithStepId:j.map(a=>a.id),matchStrategy:k,strategy:1===j.length?"single-node-multiple-invocations":"occurrence-based"}),!l)return;let m=a.map((b,c)=>(function(a,b,c,d){let e;switch(a.status){case"completed":e="completed";break;case"failed":e=c<d-1?"retrying":"failed";break;case"running":e="running";break;case"cancelled":e="cancelled";break;default:e="pending"}let f=a.completedAt&&a.startedAt?new Date(a.completedAt).getTime()-new Date(a.startedAt).getTime():void 0;return{nodeId:b,stepId:a.stepId,attemptNumber:a.attempt,status:e,startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.completedAt?new Date(a.completedAt).toISOString():void 0,duration:f,input:a.input,output:a.output,error:a.error?{message:a.error.message,stack:a.error.stack||""}:void 0}})(b,l.id,c,a.length));if(1===j.length){let a=f.get(l.id)||[];f.set(l.id,[...a,...m])}else f.set(l.id,m);return g.includes(l.id)||g.push(l.id),"running"===m[m.length-1].status?l.id:void 0}(p,r,j,k,o,g,h);a&&(e=a)}b&&(p=[b],q=b.stepId,r=b.stepName)}}let s=function(a,b,c,d){let e,f=new Map,g=new Map;for(let b of a){if(!b.correlationId)continue;let a=g.get(b.correlationId)||[];a.push(b),g.set(b.correlationId,a)}let h=b.get(bf)||[],i=new Set;for(let b of a)"wait_created"===b.eventType&&b.correlationId&&i.add(b.correlationId);for(let a of Array.from(i).sort((a,b)=>{let c=g.get(a)||[],d=g.get(b)||[],e=c.find(a=>"wait_created"===a.eventType)?.createdAt,f=d.find(a=>"wait_created"===a.eventType)?.createdAt;return e&&f?new Date(e).getTime()-new Date(f).getTime():0})){let b=g.get(a)||[],i=b.find(a=>"wait_created"===a.eventType),j=b.find(a=>"wait_completed"===a.eventType);if(!i)continue;let k=f.get(bf)||0;f.set(bf,k+1);let l=1===h.length?h[0]:h[k];if(!l)continue;let m="running";j&&(m="completed");let n=new Date(i.createdAt).toISOString(),o=j?new Date(j.createdAt).toISOString():void 0,p=j?new Date(j.createdAt).getTime()-new Date(i.createdAt).getTime():void 0,q={nodeId:l.id,attemptNumber:1,status:m,startedAt:n,completedAt:o,duration:p},r=c.get(l.id)||[];c.set(l.id,[...r,q]),d.includes(l.id)||d.push(l.id),"running"===m&&(e=l.id)}let j=[...b.get("createHook")||[],...b.get("createWebhook")||[]],k=new Set;for(let b of a)"hook_created"===b.eventType&&b.correlationId&&k.add(b.correlationId);let l=Array.from(k).sort((a,b)=>{let c=g.get(a)||[],d=g.get(b)||[],e=c.find(a=>"hook_created"===a.eventType)?.createdAt,f=d.find(a=>"hook_created"===a.eventType)?.createdAt;return e&&f?new Date(e).getTime()-new Date(f).getTime():0}),m=0;for(let a of l){let b=(g.get(a)||[]).find(a=>"hook_created"===a.eventType);if(!b)continue;let e=1===j.length?j[0]:j[m];if(m++,!e)continue;let f=new Date(b.createdAt).toISOString(),h=new Date(b.createdAt).toISOString(),i={nodeId:e.id,attemptNumber:1,status:"completed",startedAt:f,completedAt:h,duration:0},k=c.get(e.id)||[];c.set(e.id,[...k,i]),d.includes(e.id)||d.push(e.id)}let n=b.get("awaitWebhook")||[],o=new Set;for(let b of a)"hook_received"===b.eventType&&b.correlationId&&o.add(b.correlationId);let p=0;for(let a of l){let b,e,f,h=1===n.length?n[0]:n[p];if(p++,!h)continue;let i=g.get(a)||[],j=i.find(a=>"hook_created"===a.eventType),k=i.find(a=>"hook_received"===a.eventType),l=0;k?(b="completed",e=j?new Date(j.createdAt).toISOString():new Date(k.createdAt).toISOString(),l=new Date(f=new Date(k.createdAt).toISOString()).getTime()-new Date(e).getTime()):j?(b="running",e=new Date(j.createdAt).toISOString()):b="pending";let m={nodeId:h.id,attemptNumber:1,status:b,startedAt:e,completedAt:f,duration:l},o=c.get(h.id)||[];c.set(h.id,[...o,m]),d.includes(h.id)||d.push(h.id)}return e}(c,l,g,h);s&&(e=s),function(a,b,c,d,e,f,g){let h="pending";for(let b of("completed"===a.status?h="completed":"failed"===a.status?h="failed":"running"===a.status&&(h="running"),c)){let c={nodeId:b.id,attemptNumber:1,status:h,startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.completedAt&&("completed"===h||"failed"===h)?new Date(a.completedAt).toISOString():void 0};e.set(b.id,[c]),f.includes(b.id)||f.push(b.id)}for(let a of b){let b,c=bh(a.stepName);if(!c)continue;let g=d.get(c);if(!g||0===g.length)continue;let h=g[0];switch(a.status){case"completed":b="completed";break;case"failed":b="failed";break;case"running":b="running";break;case"cancelled":b="cancelled";break;default:b="pending"}let i=a.completedAt&&a.startedAt?new Date(a.completedAt).getTime()-new Date(a.startedAt).getTime():void 0,j={nodeId:h.id,stepId:a.stepId,attemptNumber:a.attempt,status:b,startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.completedAt?new Date(a.completedAt).toISOString():void 0,duration:i,input:a.input,output:a.output,error:a.error},k=e.get(h.id)||[];e.set(h.id,[...k,j]),f.includes(h.id)||f.push(h.id)}for(let b of g){let c=b.metadata?.isToolsCollection===!0;if("tool"===b.data.nodeKind&&c&&!e.has(b.id)){let c={nodeId:b.id,attemptNumber:1,status:h,startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.completedAt&&("completed"===h||"failed"===h)?new Date(a.completedAt).toISOString():void 0};e.set(b.id,[c]),f.includes(b.id)||f.push(b.id)}}}(a,i,m,n,g,h,d.nodes),function(a,b,c,d){let e=a.nodes.filter(a=>"conditional"===a.data.nodeKind),f=new Map;for(let b of a.nodes){let a=b.metadata?.conditionalId;if(a){let c=f.get(a)||{thenNodes:[],elseNodes:[]};b.metadata?.conditionalBranch==="Then"?c.thenNodes.push(b):b.metadata?.conditionalBranch==="Else"&&c.elseNodes.push(b),f.set(a,c)}}for(let a of e){let e=a.id.match(/^(cond_\d+)_node$/);if(!e)continue;let g=e[1],h=f.get(g);if(!h)continue;let i=h.thenNodes.some(a=>b.has(a.id)),j=h.elseNodes.some(a=>b.has(a.id));if(i||j){let e=[...h.thenNodes,...h.elseNodes];if(!b.has(a.id)){let c;for(let a of e){let d=b.get(a.id);if(d&&d.length>0){let a=d[0];a.startedAt&&(!c||a.startedAt<c)&&(c=a.startedAt)}}let f=d.startedAt?new Date(d.startedAt).toISOString():void 0,g={nodeId:a.id,attemptNumber:1,status:"completed",startedAt:c||f,completedAt:c||f};b.set(a.id,[g])}if(!c.includes(a.id)){let b=e.map(a=>c.indexOf(a.id)).filter(a=>a>=0);if(b.length>0){let d=Math.min(...b);d>=0&&d<c.length?c.splice(d,0,a.id):c.push(a.id)}else c.push(a.id)}}}}(d,g,h,a),function(a,b,c,d){let e,f=b.nodes.find(a=>"workflow_end"===a.data.nodeKind);if(!(!f||c.includes(f.id))){switch(a.status){case"completed":e="completed";break;case"failed":e="failed";break;case"cancelled":e="cancelled";break;case"running":e="running";break;case"paused":e="pending";break;default:return}c.push(f.id),d.set(f.id,[{nodeId:f.id,attemptNumber:1,status:e,startedAt:a.completedAt?new Date(a.completedAt).toISOString():void 0,completedAt:a.completedAt?new Date(a.completedAt).toISOString():void 0}])}}(a,d,h,g);let t=function(a,b,c){let d=new Map,e=new Set(a),f=new Map;for(let a of b.nodes){let b=a.metadata?.parallelGroupId;if(b){let c=f.get(b)||{nodes:[]};c.nodes.push(a),c.method=a.metadata?.parallelMethod,f.set(b,c)}}let g=new Map;for(let[a,b]of f)if("race"===b.method){let d,e;for(let a of b.nodes){let b=c.get(a.id);if(b){for(let c of b)if("completed"===c.status&&c.completedAt){let b=new Date(c.completedAt);(!e||b<e)&&(e=b,d=a.id)}}}d&&g.set(a,d)}let h=a=>{let b=d.get(a.id);b?b.traversalCount++:d.set(a.id,{edgeId:a.id,traversalCount:1,timings:[]})};for(let a of b.edges){let c=b.nodes.find(b=>b.id===a.source),d=b.nodes.find(b=>b.id===a.target);if(!c||!d)continue;let f=e.has(a.source),i=e.has(a.target);if(!f&&!i)continue;if("conditional"===a.type){f&&i&&h(a);continue}let j=c.metadata?.parallelGroupId,k=c.metadata?.parallelMethod;j&&"race"===k?g.get(j)===a.source&&i&&h(a):f&&i?h(a):f&&"parallel"===a.type&&i&&h(a)}return d}(h,d,g),u={runId:a.runId,status:a.status,nodeExecutions:g,edgeTraversals:t,currentNode:e,executionPath:h};return console.log("[Graph Mapper] Mapping complete:",{executionPath:h,nodeExecutionsCount:g.size,nodeExecutions:Array.from(g.entries()).map(([a,b])=>({nodeId:a,executionCount:b.length,latestStatus:b[b.length-1]?.status}))}),u}(b,c||[],e||[],j):null,[j,b,c,e]);return h?(0,d.jsxs)("div",{className:"flex items-center justify-center w-full h-full",children:[(0,d.jsx)(p.Loader2,{className:"h-8 w-8 animate-spin text-muted-foreground"}),(0,d.jsx)("span",{className:"ml-4 text-muted-foreground",children:"Loading workflow graph..."})]}):i?(0,d.jsx)("div",{className:"flex items-center justify-center w-full h-full p-4",children:(0,d.jsxs)(t.Alert,{variant:"destructive",className:"max-w-lg",children:[(0,d.jsx)(k.AlertCircle,{className:"h-4 w-4"}),(0,d.jsx)(t.AlertTitle,{children:"Error Loading Workflow Graph"}),(0,d.jsx)(t.AlertDescription,{children:i.message})]})}):j?(0,d.jsx)(bB,{workflow:j,execution:l||void 0,env:f}):(0,d.jsx)("div",{className:"flex items-center justify-center w-full h-full",children:(0,d.jsxs)(t.Alert,{className:"max-w-lg",children:[(0,d.jsx)(k.AlertCircle,{className:"h-4 w-4"}),(0,d.jsx)(t.AlertTitle,{children:"Workflow Graph Not Found"}),(0,d.jsx)(t.AlertDescription,{children:"Could not find the workflow graph for this run. The workflow may have been deleted or the graph manifest may need to be regenerated."})]})})}function bF({config:a,runId:b,selectedId:c}){let e=(0,f.useRouter)(),m=(0,f.useSearchParams)(),[u,v]=(0,r.useState)(!1),[w,x]=(0,r.useState)(!1),[y,z]=(0,r.useState)(!1),[A,B]=(0,r.useState)(!1),C=(0,r.useMemo)(()=>(0,be.worldConfigToEnvMap)(a),[a]),D=m.get("tab")||"trace",E=m.get("streamId"),F="1"===m.get("debug"),G=(0,r.useCallback)(a=>{let b=new URLSearchParams(m.toString());for(let[c,d]of Object.entries(a))null===d?b.delete(c):b.set(c,d);e.push(`?${b.toString()}`,{scroll:!1})},[e,m]),H=(0,r.useCallback)(a=>{"trace"===a||"graph"===a?G({tab:a,streamId:null}):G({tab:a})},[G]),I=(0,r.useCallback)(a=>{G({streamId:a})},[G]),J=(0,r.useCallback)(a=>{G({tab:"streams",streamId:a})},[G]),K="local"===a.backend,{run:L,steps:M,hooks:N,events:O,loading:P,auxiliaryDataLoading:Q,error:R,update:S}=(0,h.useWorkflowTraceViewerData)(C,b,{live:!0}),T=L??{},{streams:U,loading:V,error:W}=(0,h.useWorkflowStreams)(C,b),X=async()=>{if(!u)try{v(!0),z(!1),await (0,h.cancelRun)(C,b),await S(),s.toast.success("Run cancelled successfully")}catch(a){console.error("Failed to cancel run:",a),s.toast.error("Failed to cancel run",{description:a instanceof Error?a.message:"An unknown error occurred"})}finally{v(!1)}},Y=async()=>{if(!w)try{x(!0),B(!1);let b=await (0,h.recreateRun)(C,T.runId);s.toast.success("New run started successfully",{description:`Run ID: ${b}`}),e.push((0,be.buildUrlWithConfig)(`/run/${b}`,a))}catch(a){console.error("Failed to re-run workflow:",a),s.toast.error("Failed to start new run",{description:a instanceof Error?a.message:"An unknown error occurred"})}finally{x(!1),B(!1)}};if(R&&!L)return(0,d.jsxs)(t.Alert,{variant:"destructive",className:"m-4",children:[(0,d.jsx)(k.AlertCircle,{className:"h-4 w-4"}),(0,d.jsx)(t.AlertTitle,{children:"Error loading workflow run"}),(0,d.jsx)(t.AlertDescription,{children:R.message})]});let Z=(0,g.parseWorkflowName)(T.workflowName)?.shortName;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(aX,{open:y,onOpenChange:z,children:(0,d.jsxs)(a$,{children:[(0,d.jsxs)(a_,{children:[(0,d.jsx)(a1,{children:"Cancel Workflow Run?"}),(0,d.jsx)(a2,{children:"This will stop the workflow execution immediately, and no further steps will be executed. Partial workflow execution may occur. Are you sure you want to cancel the run?"})]}),(0,d.jsxs)(a0,{children:[(0,d.jsx)(a4,{children:"Keep Running"}),(0,d.jsx)(a3,{onClick:X,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),(0,d.jsx)(aX,{open:A,onOpenChange:B,children:(0,d.jsxs)(a$,{children:[(0,d.jsxs)(a_,{children:[(0,d.jsx)(a1,{children:"Replay Run?"}),(0,d.jsx)(a2,{children:"This can potentially re-run code that is meant to only execute once. Are you sure you want to replay the workflow run?"})]}),(0,d.jsxs)(a0,{children:[(0,d.jsx)(a4,{children:"Cancel"}),(0,d.jsx)(a3,{onClick:Y,children:"Replay Run"})]})]})}),(0,d.jsxs)("div",{className:"flex flex-col h-[calc(100vh-97px)]",children:[(0,d.jsxs)("div",{className:"flex-none space-y-4",children:[(0,d.jsx)(a6,{children:(0,d.jsxs)(a7,{children:[(0,d.jsx)(a8,{children:(0,d.jsx)(a9,{asChild:!0,children:(0,d.jsx)(q.default,{href:(0,be.buildUrlWithConfig)("/",a),children:"Runs"})})}),(0,d.jsx)(bb,{}),(0,d.jsx)(a8,{children:(0,d.jsx)(ba,{className:"font-mono text-xs",children:b})})]})}),(0,d.jsxs)("div",{className:"space-y-4 p-6 border rounded-lg",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between",children:[(0,d.jsx)("div",{className:"mb-4",children:(0,d.jsx)("h1",{className:"text-xl font-semibold",children:Z||(0,d.jsx)(bD.Skeleton,{className:"w-[260px] h-[28px]"})})}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)(bk,{hasError:!1,errorMessage:""}),(0,d.jsx)(bC.RunActionsButtons,{env:C,runId:b,runStatus:T.status,events:O,eventsLoading:Q,loading:P,onRerunClick:()=>{B(!0)},onCancelClick:()=>{z(!0)},callbacks:{onSuccess:S},showDebugActions:F})]})]}),(0,d.jsxs)("div",{className:"flex items-start gap-8",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Status"}),T.status?(0,d.jsx)(bm.StatusBadge,{status:T.status,context:T}):(0,d.jsx)(bD.Skeleton,{className:"w-[55px] h-[24px]"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Duration"}),(0,d.jsx)("div",{className:"text-xs",children:T.runId?T.startedAt?(()=>{let a=Math.floor(((T.completedAt?new Date(T.completedAt).getTime():Date.now())-new Date(T.startedAt).getTime())/1e3);if(a<60)return`${a}s`;let b=Math.floor(a/60),c=a%60;if(b<60)return c>0?`${b}m ${c}s`:`${b}m`;let d=Math.floor(b/60),e=b%60;return e>0?`${d}h ${e}m`:`${d}h`})():"-":(0,d.jsx)(bD.Skeleton,{className:"w-[60px] h-[20px]"})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Run ID"}),T.runId?(0,d.jsx)(bj.CopyableText,{text:T.runId,children:(0,d.jsx)("div",{className:"text-xs mt-0.5 font-mono",children:T.runId})}):(0,d.jsx)(bD.Skeleton,{className:"w-[280px] h-[20px]"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Queued"}),T.createdAt?(0,d.jsx)("div",{className:"text-xs",children:(0,d.jsx)(bl.RelativeTime,{date:T.createdAt})}):(0,d.jsx)(bD.Skeleton,{className:"w-[110px] h-[20px]"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Started"}),(0,d.jsx)("div",{className:"text-xs",children:T.runId?T.startedAt?(0,d.jsx)(bl.RelativeTime,{date:T.startedAt}):"-":(0,d.jsx)(bD.Skeleton,{className:"w-[110px] h-[20px]"})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Completed"}),(0,d.jsx)("div",{className:"text-xs",children:T.runId?T.completedAt?(0,d.jsx)(bl.RelativeTime,{date:T.completedAt}):"-":(0,d.jsx)(bD.Skeleton,{className:"w-[110px] h-[20px]"})})]}),null!=T.expiredAt&&(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsxs)(bd.Tooltip,{children:[(0,d.jsx)(bd.TooltipTrigger,{asChild:!0,children:(0,d.jsxs)("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",(0,d.jsx)(n,{className:"w-3 h-3"})]})}),(0,d.jsx)(bd.TooltipContent,{children:(0,d.jsx)("p",{children:"The storage data for this run has expired and is no longer available."})})]}),(0,d.jsx)("div",{className:"text-xs",children:(0,d.jsx)(bl.RelativeTime,{date:T.expiredAt})})]})]})]})]}),(0,d.jsxs)("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:[(0,d.jsxs)(bc.Tabs,{value:D,onValueChange:a=>H(a),className:"flex-1 flex flex-col min-h-0",children:[(0,d.jsxs)(bc.TabsList,{className:"mb-4 flex-none",children:[(0,d.jsxs)(bc.TabsTrigger,{value:"trace",className:"gap-2",children:[(0,d.jsx)(o,{className:"h-4 w-4"}),"Trace"]}),K&&(0,d.jsxs)(bc.TabsTrigger,{value:"graph",className:"gap-2",children:[(0,d.jsx)(l.GitBranch,{className:"h-4 w-4"}),"Graph"]}),(0,d.jsxs)(bc.TabsTrigger,{value:"streams",className:"gap-2",children:[(0,d.jsx)(o,{className:"h-4 w-4"}),"Streams"]})]}),(0,d.jsx)(bc.TabsContent,{value:"trace",className:"mt-0 flex-1 min-h-0",children:(0,d.jsx)("div",{className:"h-full",children:(0,d.jsx)(j.WorkflowTraceViewer,{error:R,steps:M,events:O,hooks:N,env:C,run:T,isLoading:P,onStreamClick:J})})}),(0,d.jsx)(bc.TabsContent,{value:"streams",className:"mt-0 flex-1 min-h-0",children:(0,d.jsxs)("div",{className:"h-full flex gap-4",children:[(0,d.jsxs)("div",{className:"w-64 flex-shrink-0 border rounded-lg overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-background-100)"},children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b text-xs font-medium",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-900)"},children:["Streams (",U.length,")"]}),(0,d.jsx)("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:V?(0,d.jsx)("div",{className:"p-4 flex items-center justify-center",children:(0,d.jsx)(p.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):W?(0,d.jsx)("div",{className:"p-4 text-xs text-destructive",children:W.message}):0===U.length?(0,d.jsx)("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):U.map(a=>(0,d.jsx)("button",{type:"button",onClick:()=>I(a),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:E===a?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:a,children:a},a))})]}),(0,d.jsx)("div",{className:"flex-1 min-w-0",children:E?(0,d.jsx)(i.StreamViewer,{env:C,streamId:E}):(0,d.jsx)("div",{className:"h-full flex items-center justify-center rounded-lg border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:(0,d.jsx)("div",{className:"text-sm",style:{color:"var(--ds-gray-600)"},children:U.length>0?"Select a stream to view its data":"No streams available"})})})]})}),K&&(0,d.jsx)(bc.TabsContent,{value:"graph",className:"mt-0 flex-1 min-h-0",children:(0,d.jsx)("div",{className:"h-full min-h-[500px]",children:(0,d.jsx)(bE,{config:a,run:T,allSteps:M,allEvents:O,env:C})})})]}),Q&&(0,d.jsxs)("div",{className:"fixed flex items-center gap-2 left-8 bottom-8 bg-background border rounded-md px-4 py-2 shadow-lg",children:[(0,d.jsx)(p.Loader2,{className:"size-4 animate-spin"}),(0,d.jsx)("span",{className:"text-sm",children:"Fetching data..."})]})]})]})]})}var bG=a.i(47318);function bH(){let a=(0,f.useParams)(),b=(0,be.useQueryParamConfig)(),[c]=(0,bG.useStepIdState)(),[g]=(0,bG.useEventIdState)(),[h]=(0,bG.useHookIdState)(),i=a.runId;return(0,d.jsx)(e.ErrorBoundary,{title:"Run Detail Error",description:"Failed to load run details. Please try navigating back to the home page.",children:(0,d.jsx)(bF,{config:b,runId:i,selectedId:c||g||h||void 0})})}a.s(["default",()=>bH],365642)}];
14
+ : 'text-muted-foreground'`,children:a?"Error":"Live"})]})}),(0,d.jsx)(bd.TooltipContent,{children:(0,d.jsx)("p",{children:a?`Error updating data: ${b}`:`Content updates every ${aW.LIVE_UPDATE_INTERVAL_MS/1e3} seconds`})})]})})}var bl=a.i(315244),bm=a.i(93354),bn=a.i(358088),bo=a.i(602049),bp=a.i(26790),bq=a.i(16303),br=a.i(904730),bs=a.i(706998);function bt(a){return"retrying"===a?"running":a}let bu={loopNode:function({data:a,selected:b}){return(0,d.jsxs)("div",{className:`relative ${a.className||""}`,style:{borderWidth:a.nodeStyle?.borderWidth??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:a.nodeStyle?.backgroundColor,borderColor:a.nodeStyle?.borderColor??"#9ca3af",opacity:a.nodeStyle?.opacity,boxShadow:b?"0 0 0 2px rgba(168, 85, 247, 0.5)":void 0},children:[a.label,(0,d.jsx)(bn.Handle,{type:"target",position:bo.Position.Top,className:"!bg-purple-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Bottom,className:"!bg-purple-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Left,id:"loop-out",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"30%"}}),(0,d.jsx)(bn.Handle,{type:"target",position:bo.Position.Left,id:"loop-in",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"70%"}})]})},parallelGroup:bs.ParallelGroupComponent,executionNode:function({data:a,selected:b}){let c="workflow_start"===a.nodeKind,e="workflow_end"===a.nodeKind;return(0,d.jsxs)("div",{className:`relative ${a.className||""}`,style:{borderWidth:a.nodeStyle?.borderWidth??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:a.nodeStyle?.backgroundColor,borderColor:a.nodeStyle?.borderColor??"#9ca3af",opacity:a.nodeStyle?.opacity,boxShadow:b?"0 0 0 2px rgba(59, 130, 246, 0.35)":void 0},children:[a.label,!c&&(0,d.jsx)(bn.Handle,{type:"target",position:bo.Position.Top,className:"!bg-muted"}),!e&&(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Bottom,className:"!bg-muted"})]})},diamondNode:function({data:a,selected:b}){return(0,d.jsxs)("div",{className:`relative flex items-center justify-center ${a.className||""}`,style:{width:160,height:160},children:[(0,d.jsx)("div",{style:{width:112,height:112,transform:"rotate(45deg)",borderWidth:2,borderStyle:"solid",borderRadius:4,backgroundColor:a.nodeStyle?.backgroundColor,borderColor:a.nodeStyle?.borderColor??"#ef4444",opacity:a.nodeStyle?.opacity,boxShadow:b?"0 0 0 2px rgba(239, 68, 68, 0.5)":void 0}}),(0,d.jsx)("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-auto",style:{fontSize:11,fontWeight:600,padding:40},title:"string"==typeof a.label?a.label:void 0,children:(0,d.jsx)("span",{className:"text-center line-clamp-3 overflow-hidden",children:a.label})}),(0,d.jsx)(bn.Handle,{type:"target",position:bo.Position.Top,className:"!bg-red-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Bottom,id:"bottom",className:"!bg-red-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Left,id:"left",className:"!bg-red-500"}),(0,d.jsx)(bn.Handle,{type:"source",position:bo.Position.Right,id:"right",className:"!bg-red-500"})]})}},bv=(0,bs.createEdgeTypes)(bs.executionSelfLoopStyle);function bw(a,b,c){let e=(0,d.jsxs)("div",{className:"flex items-start gap-2 w-full overflow-hidden",children:[(0,d.jsx)("div",{className:"flex-shrink-0",children:(0,bs.getNodeIcon)(a.nodeKind,a.label)}),(0,d.jsx)("span",{className:"text-sm font-medium break-words whitespace-normal leading-tight flex-1 min-w-0",children:a.label})]});if(!c||0===c.length)return e;let f=c[c.length-1],g=c.length,h=g>1;return h||f.duration&&f.duration>0?(0,d.jsxs)("div",{className:"flex flex-col gap-1.5 w-full",children:[e,(0,d.jsxs)("div",{className:"flex flex-wrap gap-1 text-xs",children:[h&&(0,d.jsxs)(br.Badge,{variant:"outline",className:"text-xs px-1.5 py-0 border-orange-500 text-orange-700 dark:text-orange-300",children:["↻ ",g,"x"]}),f.duration&&f.duration>0&&(0,d.jsxs)(br.Badge,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",(0,bq.formatDuration)(f.duration,!0)]})]})]}):e}let bx={...bs.LAYOUT,VERTICAL_SPACING:320};function by(a,b){let{nodes:c,groupNodes:d}=(0,bs.calculateEnhancedLayout)(a,bx),e=new Map,f=new Map;for(let a of d)a.id.startsWith("group_")&&f.set(a.id,a.position);for(let a of c){let b=a.metadata?.parallelGroupId?`group_${a.metadata.parallelGroupId}`:null;b&&f.has(b)&&e.set(a.id,b)}let g=[];for(let a of d.filter(a=>a.id.startsWith("group_")))g.push({id:a.id,type:"parallelGroup",position:a.position,style:{...a.style,cursor:"grab",zIndex:-1},data:a.data,selectable:!0,draggable:!0});for(let a of c){let c=b?.nodeExecutions.get(a.id),d=function(a,b){let c=(0,bs.getNodeBackgroundColor)(a);if(!b||0===b.length)return{color:"hsl(var(--card-foreground))",backgroundColor:c,borderColor:"#9ca3af",opacity:.4};let d=b[b.length-1],e="#9ca3af",f=2;switch(d.status){case"completed":e="#22c55e";break;case"failed":e="#ef4444",f=3;break;case"running":e="#3b82f6",f=2;break;case"retrying":e="#f97316";break;case"cancelled":e="#eab308";break;case"pending":e="#9ca3af"}return{color:"hsl(var(--card-foreground))",backgroundColor:c,borderColor:e,borderWidth:f}}(a.data.nodeKind,c),h=b?.currentNode===a.id,i=!!a.metadata?.loopId,j=!!a.metadata?.loopIsAwait,k="conditional"===a.data.nodeKind,l=k?"diamondNode":i?"loopNode":"executionNode",m=e.get(a.id),n=a.position;if(m){let b=f.get(m);b&&(n={x:a.position.x-b.x,y:a.position.y-b.y})}let o=h?"animate-pulse-subtle":"";i?g.push({id:a.id,type:l,position:n,parentId:m,extent:m?"parent":void 0,expandParent:!0,data:{...a.data,label:bw(a.data,a.metadata,c),executions:c,isLoopNode:!0,isAwaitLoop:j,nodeStyle:d,className:o}}):k?g.push({id:a.id,type:l,position:n,parentId:m,extent:m?"parent":void 0,expandParent:!0,data:{...a.data,label:a.data.label,executions:c,nodeStyle:d,className:o}}):g.push({id:a.id,type:l,position:n,parentId:m,extent:m?"parent":void 0,expandParent:!0,data:{...a.data,label:bw(a.data,a.metadata,c),executions:c,nodeStyle:d,className:o},style:{width:220}})}return g}function bz(a,b){let{additionalEdges:c}=(0,bs.calculateEnhancedLayout)(a,bx),e=[...a.edges.map(a=>"loop"===a.type?{...a,id:`loop_back_${a.source}_${a.target}`,isOriginal:!0}:{...a,isOriginal:!0}),...c.map(a=>({...a,isOriginal:!1}))];return(0,bs.consolidateEdges)(e,a.nodes).map(a=>{let c;if("selfLoop"===a.type)return{id:a.id,source:a.source,target:a.target,sourceHandle:a.sourceHandle,targetHandle:a.targetHandle,type:"selfLoop",label:a.label,markerEnd:{type:bo.MarkerType.ArrowClosed,width:12,height:12,color:"#a855f7"}};let e=b?.edgeTraversals.get(a.id);if(!e&&a.isConsolidated&&a.originalEdgeIds)for(let c of a.originalEdgeIds){let a=b?.edgeTraversals.get(c);if(a&&a.traversalCount>0){e=a;break}}let f=e&&e.traversalCount>0,g=!!b,h=e?.timings.length?e.timings.reduce((a,b)=>a+b,0)/e.timings.length:void 0,i="bezier",j=a.label,k=!1;switch(a.type){case"parallel":i="smoothstep",c="4,4",j=void 0;break;case"loop":i="step",c="8,4";break;case"conditional":i="smoothstep",c="8,4",k=!0;break;default:i="bezier"}let l=f?"#22c55e":"#6b7280",m=f?void 0:c,n=k?"#ffffff":"#6b7280",o=k?"#374151":"#f3f4f6",p=k?"#4b5563":"#d1d5db";return{id:a.id,source:a.source,target:a.target,type:i,animated:f&&b?.status==="running",label:e&&e.traversalCount>1?(0,d.jsxs)("div",{className:"flex flex-col items-center gap-0.5",children:[(0,d.jsxs)(br.Badge,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[e.traversalCount,"×"]}),h&&h>0&&(0,d.jsxs)("span",{className:"text-[10px] text-muted-foreground",children:["~",(0,bq.formatDuration)(h,!0)]})]}):j,labelStyle:{fill:n,fontWeight:500,fontSize:"11px"},labelBgStyle:{fill:o,fillOpacity:.95,stroke:p,strokeWidth:1},labelBgPadding:[4,6],labelBgBorderRadius:4,markerEnd:{type:bo.MarkerType.ArrowClosed,width:f?14:10,height:f?14:10,color:l},style:{strokeWidth:f?2.5:1,stroke:l,opacity:g&&!f?.35:1,strokeDasharray:m}}})}function bA({selectedNode:a,env:b,onClose:c}){let{node:e,executions:f,stepId:g,runId:i}=a,j=f[f.length-1],k=f.length>1,{data:l,loading:m}=(0,h.useWorkflowResourceData)(b??{},"step",g??"",{runId:i}),n=l?.input??j?.input,o=l?.output??j?.output,q=l?.error??j?.error;return(0,d.jsxs)("div",{className:"h-full flex flex-col bg-background border-l",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b flex-none",children:[(0,d.jsx)("span",{className:"text-xs font-medium truncate flex-1",title:e.data.label,children:e.data.label}),(0,d.jsxs)("div",{className:"flex items-center gap-2 flex-none",children:[j?.duration!==void 0&&j.duration>0&&(0,d.jsx)("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:(0,bq.formatDuration)(j.duration)}),(0,d.jsx)("div",{className:"w-px h-4 bg-border"}),(0,d.jsx)("button",{type:"button",onClick:c,className:"p-1 rounded hover:bg-muted transition-colors","aria-label":"Close panel",children:(0,d.jsx)(bp.X,{className:"h-4 w-4 text-muted-foreground"})})]})]}),(0,d.jsxs)("div",{className:"flex-1 overflow-y-auto p-3 min-h-0",children:[(0,d.jsxs)("div",{className:"flex flex-col divide-y rounded-lg border overflow-hidden mb-3",children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"type"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:e.data.nodeKind})]}),j&&(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"status"}),(0,d.jsx)(bm.StatusBadge,{status:bt(j.status)})]}),void 0!==j.duration&&j.duration>0&&(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"duration"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:(0,bq.formatDuration)(j.duration)})]}),k&&(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"attempts"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:f.length})]}),j.startedAt&&(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"startedAt"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:new Date(j.startedAt).toLocaleString()})]}),j.completedAt&&(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,d.jsx)("span",{className:"text-[11px] font-medium text-muted-foreground",children:"completedAt"}),(0,d.jsx)("span",{className:"text-[11px] font-mono",children:new Date(j.completedAt).toLocaleString()})]})]})]}),m&&g&&(0,d.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[(0,d.jsx)(p.Loader2,{className:"h-3 w-3 animate-spin"}),(0,d.jsx)("span",{children:"Loading step data..."})]}),void 0!==n&&(0,d.jsxs)("details",{className:"group mb-3",children:[(0,d.jsxs)("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[(0,d.jsx)("span",{className:"font-medium",children:"Input"}),(0,d.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",Array.isArray(n)?n.length:1," args)"]})]}),(0,d.jsxs)("div",{className:"relative pl-6 mt-3",children:[(0,d.jsx)("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),(0,d.jsx)("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),(0,d.jsx)("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:(0,d.jsx)("code",{children:JSON.stringify(n,null,2)})})]})]}),void 0!==o&&(0,d.jsxs)("details",{className:"group mb-3",children:[(0,d.jsx)("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:(0,d.jsx)("span",{className:"font-medium",children:"Output"})}),(0,d.jsxs)("div",{className:"relative pl-6 mt-3",children:[(0,d.jsx)("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),(0,d.jsx)("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),(0,d.jsx)("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:(0,d.jsx)("code",{children:JSON.stringify(o,null,2)})})]})]}),q&&(0,d.jsxs)("details",{className:"group mb-3",open:!0,children:[(0,d.jsx)("summary",{className:"cursor-pointer rounded-md border border-red-300 bg-red-50 dark:bg-red-950/20 px-2.5 py-1.5 text-xs hover:brightness-95",children:(0,d.jsx)("span",{className:"font-medium text-red-600 dark:text-red-400",children:"Error"})}),(0,d.jsxs)("div",{className:"relative pl-6 mt-3",children:[(0,d.jsx)("div",{className:"absolute left-3 -top-3 w-px h-3 bg-red-300"}),(0,d.jsx)("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-red-300"}),(0,d.jsx)("pre",{className:"text-[11px] overflow-x-auto rounded-md border border-red-200 p-2.5 bg-red-50 dark:bg-red-950/20 text-red-700 dark:text-red-300 whitespace-pre-wrap max-h-64 overflow-y-auto",children:(0,d.jsx)("code",{children:"object"==typeof q?JSON.stringify(q,null,2):String(q)})})]})]}),k&&(0,d.jsxs)("details",{className:"group",children:[(0,d.jsxs)("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[(0,d.jsx)("span",{className:"font-medium",children:"Attempt History"}),(0,d.jsxs)("span",{className:"text-muted-foreground ml-1",children:["(",f.length," attempts)"]})]}),(0,d.jsxs)("div",{className:"relative pl-6 mt-3",children:[(0,d.jsx)("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),(0,d.jsx)("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),(0,d.jsx)("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",children:f.map(a=>(0,d.jsxs)("div",{className:"flex items-center justify-between px-2.5 py-1.5 text-[11px]",children:[(0,d.jsxs)("span",{className:"text-muted-foreground",children:["Attempt ",a.attemptNumber]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)(bm.StatusBadge,{status:bt(a.status)}),void 0!==a.duration&&a.duration>0&&(0,d.jsx)("span",{className:"font-mono text-muted-foreground",children:(0,bq.formatDuration)(a.duration)})]})]},a.attemptNumber))})]})]})]})]})}function bB({workflow:a,execution:b,env:c,onNodeClick:e}){let[f,g]=(0,r.useState)(null),h=(0,r.useMemo)(()=>by(a,b),[a,b]),i=(0,r.useMemo)(()=>bz(a,b),[a,b]),[j,k,l]=(0,bn.useNodesState)(h),[m,n,o]=(0,bn.useEdgesState)(i);(0,r.useEffect)(()=>{k(c=>{let d=by(a,b),e=new Map(c.map(a=>[a.id,a.position]));return d.map(a=>({...a,position:e.get(a.id)??a.position}))}),n(bz(a,b))},[a,b,k,n]);let p=(0,r.useCallback)((c,d)=>{let f=a.nodes.find(a=>a.id===d.id);if(f){let a=d.data.executions||[],c=a[a.length-1];g({nodeId:d.id,node:f,executions:a,stepId:c?.stepId,runId:b?.runId}),e&&a.length>0&&e(d.id,a)}},[a.nodes,b?.runId,e]),q=(0,r.useCallback)(()=>{g(null)},[]);return(0,d.jsxs)("div",{className:"h-full w-full border rounded-lg bg-background relative overflow-hidden flex",children:[(0,d.jsx)("div",{className:"h-full flex-1 min-w-0",style:{width:f?"calc(100% - 320px)":"100%"},children:(0,d.jsxs)(bn.ReactFlow,{nodes:j,edges:m,onNodesChange:l,onEdgesChange:o,onNodeClick:p,nodeTypes:bu,edgeTypes:bv,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[(0,d.jsx)(bn.Background,{}),(0,d.jsx)(bn.Controls,{}),(0,d.jsx)(bn.Panel,{position:"top-left",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-2 text-xs",children:(0,d.jsxs)("div",{className:"space-y-1.5",children:[(0,d.jsx)("div",{className:"font-semibold text-[10px] text-muted-foreground mb-1",children:"Status"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-green-500 bg-background"}),(0,d.jsx)("span",{children:"Completed"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-red-500 bg-background"}),(0,d.jsx)("span",{children:"Failed"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-blue-500 bg-background"}),(0,d.jsx)("span",{children:"Running"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-yellow-500 bg-background"}),(0,d.jsx)("span",{children:"Cancelled"})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2 opacity-50",children:[(0,d.jsx)("div",{className:"w-6 h-4 rounded border-2 border-gray-400 bg-background"}),(0,d.jsx)("span",{children:"Pending"})]})]})}),b&&(0,d.jsxs)(bn.Panel,{position:"top-right",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-3 text-xs space-y-1.5",children:[(0,d.jsx)("div",{className:"font-semibold text-sm",children:"Execution"}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-muted-foreground",children:"Status:"}),(0,d.jsx)(br.Badge,{variant:"completed"===b.status?"default":"failed"===b.status?"destructive":"cancelled"===b.status?"outline":"secondary",className:"text-xs",children:b.status})]}),(0,d.jsxs)("div",{className:"flex items-center gap-2",children:[(0,d.jsx)("span",{className:"text-muted-foreground",children:"Progress:"}),(0,d.jsxs)("span",{className:"font-mono",children:[b.executionPath.length," / ",a.nodes.length]})]})]})]})}),f&&(0,d.jsx)("div",{className:"h-full flex-none",style:{width:320},children:(0,d.jsx)(bA,{selectedNode:f,env:c,onClose:q})})]})}var bC=a.i(303872),bD=a.i(433105);function bE({config:a,run:b,allSteps:c,allEvents:e,env:f}){let{manifest:g,loading:h,error:i}=(0,bi.useWorkflowGraphManifest)(a),j=(0,r.useMemo)(()=>g&&b.workflowName?g.workflows[b.workflowName]??null:null,[g,b.workflowName]),l=(0,r.useMemo)(()=>j&&b.runId?function(a,b,c,d){let e,f,g=new Map,h=[];console.log("[Graph Mapper] Mapping run to execution:",{runId:a.runId,workflowName:a.workflowName,graphNodes:d.nodes.length,stepsCount:b.length}),(f=d.nodes.find(a=>"workflow_start"===a.data.nodeKind))&&(h.push(f.id),g.set(f.id,[{nodeId:f.id,attemptNumber:1,status:"completed",startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0}]));let i=[...b].sort((a,b)=>new Date(a.createdAt).getTime()-new Date(b.createdAt).getTime());console.log("[Graph Mapper] Sorted steps:",i.map(a=>({stepId:a.stepId,stepName:a.stepName,attempt:a.attempt,status:a.status,createdAt:a.createdAt})));let{byStepId:j,byFunctionName:k,primitivesByLabel:l,agentNodes:m,toolNodes:n}=function(a){let b=new Map,c=new Map,d=new Map,e=[],f=new Map;for(let g of a){if(g.data.stepId){let a=bg(g.data.stepId),d=b.get(a)||[];d.push(g),b.set(a,d);let e=bh(a);if(e){let a=c.get(e)||[];a.push(g),c.set(e,a)}}if("primitive"===g.data.nodeKind){let a=g.data.label,b=d.get(a)||[];b.push(g),d.set(a,b)}if("agent"===g.data.nodeKind&&e.push(g),"tool"===g.data.nodeKind){let a=g.data.label.replace(/ \(tool\)$/,""),b=f.get(a)||[];if(b.push(g),f.set(a,b),g.data.stepId){let a=bh(bg(g.data.stepId));if(a){let b=f.get(a)||[];b.includes(g)||(b.push(g),f.set(a,b))}}}}return{byStepId:b,byFunctionName:c,primitivesByLabel:d,agentNodes:e,toolNodes:f}}(d.nodes);console.log("[Graph Mapper] Graph nodes by stepId:",{allGraphNodes:d.nodes.map(a=>({id:a.id,stepId:a.data.stepId,normalizedStepId:a.data.stepId?bg(a.data.stepId):void 0,nodeKind:a.data.nodeKind})),nodesByStepId:Array.from(j.entries()).map(([a,b])=>({stepId:a,nodeIds:b.map(a=>a.id)}))});let o=new Map,p=[],q=null,r=null;for(let a=0;a<=i.length;a++){let b=i[a];if(b&&b.stepId===q)p.push(b);else{if(p.length>0&&r){let a=function(a,b,c,d,e,f,g){let h=bg(b),i=e.get(h)||0;e.set(h,i+1);let j=c.get(h)||[],k="step-id";if(0===j.length){let a=bh(h);a&&(j=d.get(a)||[],k="function-name")}let l=1===j.length?j[0]:j[i];if(console.log("[Graph Mapper] Processing step group:",{stepName:b,normalizedStepName:h,attempts:a.length,occurrenceIndex:i,totalNodesWithStepId:j.length,selectedNode:l?.id,allNodesWithStepId:j.map(a=>a.id),matchStrategy:k,strategy:1===j.length?"single-node-multiple-invocations":"occurrence-based"}),!l)return;let m=a.map((b,c)=>(function(a,b,c,d){let e;switch(a.status){case"completed":e="completed";break;case"failed":e=c<d-1?"retrying":"failed";break;case"running":e="running";break;case"cancelled":e="cancelled";break;default:e="pending"}let f=a.completedAt&&a.startedAt?new Date(a.completedAt).getTime()-new Date(a.startedAt).getTime():void 0;return{nodeId:b,stepId:a.stepId,attemptNumber:a.attempt,status:e,startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.completedAt?new Date(a.completedAt).toISOString():void 0,duration:f,input:a.input,output:a.output,error:a.error?{message:a.error.message,stack:a.error.stack||""}:void 0}})(b,l.id,c,a.length));if(1===j.length){let a=f.get(l.id)||[];f.set(l.id,[...a,...m])}else f.set(l.id,m);return g.includes(l.id)||g.push(l.id),"running"===m[m.length-1].status?l.id:void 0}(p,r,j,k,o,g,h);a&&(e=a)}b&&(p=[b],q=b.stepId,r=b.stepName)}}let s=function(a,b,c,d){let e,f=new Map,g=new Map;for(let b of a){if(!b.correlationId)continue;let a=g.get(b.correlationId)||[];a.push(b),g.set(b.correlationId,a)}let h=b.get(bf)||[],i=new Set;for(let b of a)"wait_created"===b.eventType&&b.correlationId&&i.add(b.correlationId);for(let a of Array.from(i).sort((a,b)=>{let c=g.get(a)||[],d=g.get(b)||[],e=c.find(a=>"wait_created"===a.eventType)?.createdAt,f=d.find(a=>"wait_created"===a.eventType)?.createdAt;return e&&f?new Date(e).getTime()-new Date(f).getTime():0})){let b=g.get(a)||[],i=b.find(a=>"wait_created"===a.eventType),j=b.find(a=>"wait_completed"===a.eventType);if(!i)continue;let k=f.get(bf)||0;f.set(bf,k+1);let l=1===h.length?h[0]:h[k];if(!l)continue;let m="running";j&&(m="completed");let n=new Date(i.createdAt).toISOString(),o=j?new Date(j.createdAt).toISOString():void 0,p=j?new Date(j.createdAt).getTime()-new Date(i.createdAt).getTime():void 0,q={nodeId:l.id,attemptNumber:1,status:m,startedAt:n,completedAt:o,duration:p},r=c.get(l.id)||[];c.set(l.id,[...r,q]),d.includes(l.id)||d.push(l.id),"running"===m&&(e=l.id)}let j=[...b.get("createHook")||[],...b.get("createWebhook")||[]],k=new Set;for(let b of a)"hook_created"===b.eventType&&b.correlationId&&k.add(b.correlationId);let l=Array.from(k).sort((a,b)=>{let c=g.get(a)||[],d=g.get(b)||[],e=c.find(a=>"hook_created"===a.eventType)?.createdAt,f=d.find(a=>"hook_created"===a.eventType)?.createdAt;return e&&f?new Date(e).getTime()-new Date(f).getTime():0}),m=0;for(let a of l){let b=(g.get(a)||[]).find(a=>"hook_created"===a.eventType);if(!b)continue;let e=1===j.length?j[0]:j[m];if(m++,!e)continue;let f=new Date(b.createdAt).toISOString(),h=new Date(b.createdAt).toISOString(),i={nodeId:e.id,attemptNumber:1,status:"completed",startedAt:f,completedAt:h,duration:0},k=c.get(e.id)||[];c.set(e.id,[...k,i]),d.includes(e.id)||d.push(e.id)}let n=b.get("awaitWebhook")||[],o=new Set;for(let b of a)"hook_received"===b.eventType&&b.correlationId&&o.add(b.correlationId);let p=0;for(let a of l){let b,e,f,h=1===n.length?n[0]:n[p];if(p++,!h)continue;let i=g.get(a)||[],j=i.find(a=>"hook_created"===a.eventType),k=i.find(a=>"hook_received"===a.eventType),l=0;k?(b="completed",e=j?new Date(j.createdAt).toISOString():new Date(k.createdAt).toISOString(),l=new Date(f=new Date(k.createdAt).toISOString()).getTime()-new Date(e).getTime()):j?(b="running",e=new Date(j.createdAt).toISOString()):b="pending";let m={nodeId:h.id,attemptNumber:1,status:b,startedAt:e,completedAt:f,duration:l},o=c.get(h.id)||[];c.set(h.id,[...o,m]),d.includes(h.id)||d.push(h.id)}return e}(c,l,g,h);s&&(e=s),function(a,b,c,d,e,f,g){let h="pending";for(let b of("completed"===a.status?h="completed":"failed"===a.status?h="failed":"running"===a.status&&(h="running"),c)){let c={nodeId:b.id,attemptNumber:1,status:h,startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.completedAt&&("completed"===h||"failed"===h)?new Date(a.completedAt).toISOString():void 0};e.set(b.id,[c]),f.includes(b.id)||f.push(b.id)}for(let a of b){let b,c=bh(a.stepName);if(!c)continue;let g=d.get(c);if(!g||0===g.length)continue;let h=g[0];switch(a.status){case"completed":b="completed";break;case"failed":b="failed";break;case"running":b="running";break;case"cancelled":b="cancelled";break;default:b="pending"}let i=a.completedAt&&a.startedAt?new Date(a.completedAt).getTime()-new Date(a.startedAt).getTime():void 0,j={nodeId:h.id,stepId:a.stepId,attemptNumber:a.attempt,status:b,startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.completedAt?new Date(a.completedAt).toISOString():void 0,duration:i,input:a.input,output:a.output,error:a.error},k=e.get(h.id)||[];e.set(h.id,[...k,j]),f.includes(h.id)||f.push(h.id)}for(let b of g){let c=b.metadata?.isToolsCollection===!0;if("tool"===b.data.nodeKind&&c&&!e.has(b.id)){let c={nodeId:b.id,attemptNumber:1,status:h,startedAt:a.startedAt?new Date(a.startedAt).toISOString():void 0,completedAt:a.completedAt&&("completed"===h||"failed"===h)?new Date(a.completedAt).toISOString():void 0};e.set(b.id,[c]),f.includes(b.id)||f.push(b.id)}}}(a,i,m,n,g,h,d.nodes),function(a,b,c,d){let e=a.nodes.filter(a=>"conditional"===a.data.nodeKind),f=new Map;for(let b of a.nodes){let a=b.metadata?.conditionalId;if(a){let c=f.get(a)||{thenNodes:[],elseNodes:[]};b.metadata?.conditionalBranch==="Then"?c.thenNodes.push(b):b.metadata?.conditionalBranch==="Else"&&c.elseNodes.push(b),f.set(a,c)}}for(let a of e){let e=a.id.match(/^(cond_\d+)_node$/);if(!e)continue;let g=e[1],h=f.get(g);if(!h)continue;let i=h.thenNodes.some(a=>b.has(a.id)),j=h.elseNodes.some(a=>b.has(a.id));if(i||j){let e=[...h.thenNodes,...h.elseNodes];if(!b.has(a.id)){let c;for(let a of e){let d=b.get(a.id);if(d&&d.length>0){let a=d[0];a.startedAt&&(!c||a.startedAt<c)&&(c=a.startedAt)}}let f=d.startedAt?new Date(d.startedAt).toISOString():void 0,g={nodeId:a.id,attemptNumber:1,status:"completed",startedAt:c||f,completedAt:c||f};b.set(a.id,[g])}if(!c.includes(a.id)){let b=e.map(a=>c.indexOf(a.id)).filter(a=>a>=0);if(b.length>0){let d=Math.min(...b);d>=0&&d<c.length?c.splice(d,0,a.id):c.push(a.id)}else c.push(a.id)}}}}(d,g,h,a),function(a,b,c,d){let e,f=b.nodes.find(a=>"workflow_end"===a.data.nodeKind);if(!(!f||c.includes(f.id))){switch(a.status){case"completed":e="completed";break;case"failed":e="failed";break;case"cancelled":e="cancelled";break;case"running":e="running";break;case"paused":e="pending";break;default:return}c.push(f.id),d.set(f.id,[{nodeId:f.id,attemptNumber:1,status:e,startedAt:a.completedAt?new Date(a.completedAt).toISOString():void 0,completedAt:a.completedAt?new Date(a.completedAt).toISOString():void 0}])}}(a,d,h,g);let t=function(a,b,c){let d=new Map,e=new Set(a),f=new Map;for(let a of b.nodes){let b=a.metadata?.parallelGroupId;if(b){let c=f.get(b)||{nodes:[]};c.nodes.push(a),c.method=a.metadata?.parallelMethod,f.set(b,c)}}let g=new Map;for(let[a,b]of f)if("race"===b.method){let d,e;for(let a of b.nodes){let b=c.get(a.id);if(b){for(let c of b)if("completed"===c.status&&c.completedAt){let b=new Date(c.completedAt);(!e||b<e)&&(e=b,d=a.id)}}}d&&g.set(a,d)}let h=a=>{let b=d.get(a.id);b?b.traversalCount++:d.set(a.id,{edgeId:a.id,traversalCount:1,timings:[]})};for(let a of b.edges){let c=b.nodes.find(b=>b.id===a.source),d=b.nodes.find(b=>b.id===a.target);if(!c||!d)continue;let f=e.has(a.source),i=e.has(a.target);if(!f&&!i)continue;if("conditional"===a.type){f&&i&&h(a);continue}let j=c.metadata?.parallelGroupId,k=c.metadata?.parallelMethod;j&&"race"===k?g.get(j)===a.source&&i&&h(a):f&&i?h(a):f&&"parallel"===a.type&&i&&h(a)}return d}(h,d,g),u={runId:a.runId,status:a.status,nodeExecutions:g,edgeTraversals:t,currentNode:e,executionPath:h};return console.log("[Graph Mapper] Mapping complete:",{executionPath:h,nodeExecutionsCount:g.size,nodeExecutions:Array.from(g.entries()).map(([a,b])=>({nodeId:a,executionCount:b.length,latestStatus:b[b.length-1]?.status}))}),u}(b,c||[],e||[],j):null,[j,b,c,e]);return h?(0,d.jsxs)("div",{className:"flex items-center justify-center w-full h-full",children:[(0,d.jsx)(p.Loader2,{className:"h-8 w-8 animate-spin text-muted-foreground"}),(0,d.jsx)("span",{className:"ml-4 text-muted-foreground",children:"Loading workflow graph..."})]}):i?(0,d.jsx)("div",{className:"flex items-center justify-center w-full h-full p-4",children:(0,d.jsxs)(t.Alert,{variant:"destructive",className:"max-w-lg",children:[(0,d.jsx)(k.AlertCircle,{className:"h-4 w-4"}),(0,d.jsx)(t.AlertTitle,{children:"Error Loading Workflow Graph"}),(0,d.jsx)(t.AlertDescription,{children:i.message})]})}):j?(0,d.jsx)(bB,{workflow:j,execution:l||void 0,env:f}):(0,d.jsx)("div",{className:"flex items-center justify-center w-full h-full",children:(0,d.jsxs)(t.Alert,{className:"max-w-lg",children:[(0,d.jsx)(k.AlertCircle,{className:"h-4 w-4"}),(0,d.jsx)(t.AlertTitle,{children:"Workflow Graph Not Found"}),(0,d.jsx)(t.AlertDescription,{children:"Could not find the workflow graph for this run. The workflow may have been deleted or the graph manifest may need to be regenerated."})]})})}function bF({config:a,runId:b,selectedId:c}){let m=(0,f.useRouter)(),u=(0,f.useSearchParams)(),[v,w]=(0,r.useState)(!1),[x,y]=(0,r.useState)(!1),[z,A]=(0,r.useState)(!1),[B,C]=(0,r.useState)(!1),D=(0,r.useMemo)(()=>(0,be.worldConfigToEnvMap)(a),[a]),E=u.get("tab")||"trace",F=u.get("streamId"),G="1"===u.get("debug"),H=(0,r.useCallback)(a=>{let b=new URLSearchParams(u.toString());for(let[c,d]of Object.entries(a))null===d?b.delete(c):b.set(c,d);m.push(`?${b.toString()}`,{scroll:!1})},[m,u]),I=(0,r.useCallback)(a=>{"trace"===a||"graph"===a?H({tab:a,streamId:null}):H({tab:a})},[H]),J=(0,r.useCallback)(a=>{H({streamId:a})},[H]),K=(0,r.useCallback)(a=>{H({tab:"streams",streamId:a})},[H]),L="local"===a.backend,{run:M,steps:N,hooks:O,events:P,loading:Q,auxiliaryDataLoading:R,error:S,update:T}=(0,h.useWorkflowTraceViewerData)(D,b,{live:!0}),U=M??{},{streams:V,loading:W,error:X}=(0,h.useWorkflowStreams)(D,b),Y=async()=>{if(!v)try{w(!0),A(!1),await (0,h.cancelRun)(D,b),await T(),s.toast.success("Run cancelled successfully")}catch(a){console.error("Failed to cancel run:",a),s.toast.error("Failed to cancel run",{description:a instanceof Error?a.message:"An unknown error occurred"})}finally{w(!1)}},Z=async()=>{if(!x)try{y(!0),C(!1);let b=await (0,h.recreateRun)(D,U.runId);s.toast.success("New run started successfully",{description:`Run ID: ${b}`}),m.push((0,be.buildUrlWithConfig)(`/run/${b}`,a))}catch(a){console.error("Failed to re-run workflow:",a),s.toast.error("Failed to start new run",{description:a instanceof Error?a.message:"An unknown error occurred"})}finally{y(!1),C(!1)}};if(S&&!M)return(0,d.jsxs)(t.Alert,{variant:"destructive",className:"m-4",children:[(0,d.jsx)(k.AlertCircle,{className:"h-4 w-4"}),(0,d.jsx)(t.AlertTitle,{children:"Error loading workflow run"}),(0,d.jsx)(t.AlertDescription,{children:S.message})]});let $=(0,g.parseWorkflowName)(U.workflowName)?.shortName;return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(aX,{open:z,onOpenChange:A,children:(0,d.jsxs)(a$,{children:[(0,d.jsxs)(a_,{children:[(0,d.jsx)(a1,{children:"Cancel Workflow Run?"}),(0,d.jsx)(a2,{children:"This will stop the workflow execution immediately, and no further steps will be executed. Partial workflow execution may occur. Are you sure you want to cancel the run?"})]}),(0,d.jsxs)(a0,{children:[(0,d.jsx)(a4,{children:"Keep Running"}),(0,d.jsx)(a3,{onClick:Y,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),(0,d.jsx)(aX,{open:B,onOpenChange:C,children:(0,d.jsxs)(a$,{children:[(0,d.jsxs)(a_,{children:[(0,d.jsx)(a1,{children:"Replay Run?"}),(0,d.jsx)(a2,{children:"This can potentially re-run code that is meant to only execute once. Are you sure you want to replay the workflow run?"})]}),(0,d.jsxs)(a0,{children:[(0,d.jsx)(a4,{children:"Cancel"}),(0,d.jsx)(a3,{onClick:Z,children:"Replay Run"})]})]})}),(0,d.jsxs)("div",{className:"flex flex-col h-[calc(100vh-97px)]",children:[(0,d.jsxs)("div",{className:"flex-none space-y-4",children:[(0,d.jsx)(a6,{children:(0,d.jsxs)(a7,{children:[(0,d.jsx)(a8,{children:(0,d.jsx)(a9,{asChild:!0,children:(0,d.jsx)(q.default,{href:(0,be.buildUrlWithConfig)("/",a),children:"Runs"})})}),(0,d.jsx)(bb,{}),(0,d.jsx)(a8,{children:(0,d.jsx)(ba,{className:"font-mono text-xs",children:b})})]})}),(0,d.jsxs)("div",{className:"space-y-4 p-6 border rounded-lg",children:[(0,d.jsxs)("div",{className:"flex items-start justify-between",children:[(0,d.jsx)("div",{className:"mb-4",children:(0,d.jsx)("h1",{className:"text-xl font-semibold",children:$||(0,d.jsx)(bD.Skeleton,{className:"w-[260px] h-[28px]"})})}),(0,d.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,d.jsx)(bk,{hasError:!1,errorMessage:""}),(0,d.jsx)(bC.RunActionsButtons,{env:D,runId:b,runStatus:U.status,events:P,eventsLoading:R,loading:Q,onRerunClick:()=>{C(!0)},onCancelClick:()=>{A(!0)},callbacks:{onSuccess:T},showDebugActions:G})]})]}),(0,d.jsxs)("div",{className:"flex items-start gap-8",children:[(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Status"}),U.status?(0,d.jsx)(bm.StatusBadge,{status:U.status,context:U}):(0,d.jsx)(bD.Skeleton,{className:"w-[55px] h-[24px]"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Duration"}),(0,d.jsx)("div",{className:"text-xs",children:U.runId?U.startedAt?(()=>{let a=Math.floor(((U.completedAt?new Date(U.completedAt).getTime():Date.now())-new Date(U.startedAt).getTime())/1e3);if(a<60)return`${a}s`;let b=Math.floor(a/60),c=a%60;if(b<60)return c>0?`${b}m ${c}s`:`${b}m`;let d=Math.floor(b/60),e=b%60;return e>0?`${d}h ${e}m`:`${d}h`})():"-":(0,d.jsx)(bD.Skeleton,{className:"w-[60px] h-[20px]"})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Run ID"}),U.runId?(0,d.jsx)(bj.CopyableText,{text:U.runId,children:(0,d.jsx)("div",{className:"text-xs mt-0.5 font-mono",children:U.runId})}):(0,d.jsx)(bD.Skeleton,{className:"w-[280px] h-[20px]"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Queued"}),U.createdAt?(0,d.jsx)("div",{className:"text-xs",children:(0,d.jsx)(bl.RelativeTime,{date:U.createdAt})}):(0,d.jsx)(bD.Skeleton,{className:"w-[110px] h-[20px]"})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Started"}),(0,d.jsx)("div",{className:"text-xs",children:U.runId?U.startedAt?(0,d.jsx)(bl.RelativeTime,{date:U.startedAt}):"-":(0,d.jsx)(bD.Skeleton,{className:"w-[110px] h-[20px]"})})]}),(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsx)("div",{className:"text-xs text-muted-foreground",children:"Completed"}),(0,d.jsx)("div",{className:"text-xs",children:U.runId?U.completedAt?(0,d.jsx)(bl.RelativeTime,{date:U.completedAt}):"-":(0,d.jsx)(bD.Skeleton,{className:"w-[110px] h-[20px]"})})]}),null!=U.expiredAt&&(0,d.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,d.jsxs)(bd.Tooltip,{children:[(0,d.jsx)(bd.TooltipTrigger,{asChild:!0,children:(0,d.jsxs)("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",(0,d.jsx)(n,{className:"w-3 h-3"})]})}),(0,d.jsx)(bd.TooltipContent,{children:(0,d.jsx)("p",{children:"The storage data for this run has expired and is no longer available."})})]}),(0,d.jsx)("div",{className:"text-xs",children:(0,d.jsx)(bl.RelativeTime,{date:U.expiredAt})})]})]})]})]}),(0,d.jsxs)("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:[(0,d.jsxs)(bc.Tabs,{value:E,onValueChange:a=>I(a),className:"flex-1 flex flex-col min-h-0",children:[(0,d.jsxs)(bc.TabsList,{className:"mb-4 flex-none",children:[(0,d.jsxs)(bc.TabsTrigger,{value:"trace",className:"gap-2",children:[(0,d.jsx)(o,{className:"h-4 w-4"}),"Trace"]}),L&&(0,d.jsxs)(bc.TabsTrigger,{value:"graph",className:"gap-2",children:[(0,d.jsx)(l.GitBranch,{className:"h-4 w-4"}),"Graph"]}),(0,d.jsxs)(bc.TabsTrigger,{value:"streams",className:"gap-2",children:[(0,d.jsx)(o,{className:"h-4 w-4"}),"Streams"]})]}),(0,d.jsx)(bc.TabsContent,{value:"trace",className:"mt-0 flex-1 min-h-0",children:(0,d.jsx)(e.ErrorBoundary,{title:"Trace Viewer Error",description:"Failed to load trace viewer. Please try refreshing the page.",children:(0,d.jsx)("div",{className:"h-full",children:(0,d.jsx)(j.WorkflowTraceViewer,{error:S,steps:N,events:P,hooks:O,env:D,run:U,isLoading:Q,onStreamClick:K})})})}),(0,d.jsx)(bc.TabsContent,{value:"streams",className:"mt-0 flex-1 min-h-0",children:(0,d.jsx)(e.ErrorBoundary,{title:"Streams Error",description:"Failed to load streams. Please try refreshing the page.",children:(0,d.jsxs)("div",{className:"h-full flex gap-4",children:[(0,d.jsxs)("div",{className:"w-64 flex-shrink-0 border rounded-lg overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-background-100)"},children:[(0,d.jsxs)("div",{className:"px-3 py-2 border-b text-xs font-medium",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-900)"},children:["Streams (",V.length,")"]}),(0,d.jsx)("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:W?(0,d.jsx)("div",{className:"p-4 flex items-center justify-center",children:(0,d.jsx)(p.Loader2,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):X?(0,d.jsx)("div",{className:"p-4 text-xs text-destructive",children:X.message}):0===V.length?(0,d.jsx)("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):V.map(a=>(0,d.jsx)("button",{type:"button",onClick:()=>J(a),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:F===a?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:a,children:a},a))})]}),(0,d.jsx)("div",{className:"flex-1 min-w-0",children:F?(0,d.jsx)(i.StreamViewer,{env:D,streamId:F}):(0,d.jsx)("div",{className:"h-full flex items-center justify-center rounded-lg border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:(0,d.jsx)("div",{className:"text-sm",style:{color:"var(--ds-gray-600)"},children:V.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),L&&(0,d.jsx)(bc.TabsContent,{value:"graph",className:"mt-0 flex-1 min-h-0",children:(0,d.jsx)(e.ErrorBoundary,{title:"Graph Viewer Error",description:"Failed to load execution graph. Please try refreshing the page.",children:(0,d.jsx)("div",{className:"h-full min-h-[500px]",children:(0,d.jsx)(bE,{config:a,run:U,allSteps:N,allEvents:P,env:D})})})})]}),R&&(0,d.jsxs)("div",{className:"fixed flex items-center gap-2 left-8 bottom-8 bg-background border rounded-md px-4 py-2 shadow-lg",children:[(0,d.jsx)(p.Loader2,{className:"size-4 animate-spin"}),(0,d.jsx)("span",{className:"text-sm",children:"Fetching data..."})]})]})]})]})}var bG=a.i(47318);function bH(){let a=(0,f.useParams)(),b=(0,be.useQueryParamConfig)(),[c]=(0,bG.useStepIdState)(),[g]=(0,bG.useEventIdState)(),[h]=(0,bG.useHookIdState)(),i=a.runId;return(0,d.jsx)(e.ErrorBoundary,{title:"Run Detail Error",description:"Failed to load run details. Please try navigating back to the home page.",children:(0,d.jsx)(bF,{config:b,runId:i,selectedId:c||g||h||void 0})})}a.s(["default",()=>bH],365642)}];
15
15
 
16
16
  //# sourceMappingURL=packages_web_src_app_run_%5BrunId%5D_page_tsx_c7d0b139._.js.map