1import{j7 as we,eh as P,r as v,j as g,q as R,ek as be,kH as ye,t as O,kI as Se,es as ve,et as xe,eu as He}from"./main-qTUrSfJn.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";import{H as L,P as B,R as Ie,u as ke,a as De,b as Ae,i as Ce,B as Re,c as Me}from"./style-B7PUgldk.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";import{u as Te,D as Oe,R as Ge,H as Pe}from"./HiddenNodesRevealPanel-BETTEDPT.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";import{l as oe}from"./layoutDagreGraph-CH4I5-0O.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";import{g as je}from"./dagSpecNodePresentation-CUv-wJOB.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";import"./value-BH0JElIf.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";import"./scan-DDSaGSYL.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";import"./createLucideIcon-myCTXGWt.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";import"./pyramid-Bqjt-tSz.js?dpl=27a70693-48ce-4eff-ba3d-7c367d82390c";try{let e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="6097095e-14f6-45ae-a2c4-1868545c9965",e._sentryDebugIdIdentifier="sentry-dbid-6097095e-14f6-45ae-a2c4-1868545c9965")}catch{}function ne(e){return e.kind==="trigger"?we(e.schedule):e.kind==="exploratory"?P(e.prompt):e.kind==="code"?P(e.notes):e.kind==="live_artifact"?P(e.artifact_description):e.kind==="dashboard"?P(e.dashboard_description):null}function ae(e,o,n){var p;if(e.kind!=="workflow_invocation")return null;const i=e.existing_workflow_name??o,c=[];return i&&c.push(`Calls ${i}`),e.fan_out&&(e.fan_out.source_node_id?c.push(`fans out over ${n??"an upstream step"}`):(p=e.fan_out.values)!=null&&p.length?c.push(`fans out over ${e.fan_out.values.length} items`):e.fan_out.description?c.push(`${e.fan_out.description.charAt(0).toLowerCase()}${e.fan_out.description.slice(1)}`):c.push("fans out (unconfigured)")),c.length>0?c.join(" · "):null}const G=260,ie=26,re=39,de=20,J=16,Le=2,Be=6,We=2,$e=30,Q=34,F=ie+re+de,$=(e,o)=>Math.max(1,Math.ceil(e.length/o));function ce(e,o,n){const i=$(e.name,$e)*de,c=ae(e,o,n),p=c?Le+$(c,Q)*J:0,_=ne(e),h=_?Be+Math.min(We,$(_,Q))*J:0;return ie+re+i+p+h}const j=16,ee=10,Fe=44,Ue=32,ze=12,Ke=16,te=2,Ye=18,Xe=16,Ve=2,Ze=7;function qe(e,o,n){const i=Math.max(1,Math.floor((n-j*2)/Ze)),c=Math.min(Ve,Math.max(1,Math.ceil(e.length/i)));return ze+Ke+te+c*Ye+(o?te+Xe:0)}const Je="::",M=(e,o)=>`${e}\0${o}`,T=e=>(e==null?void 0:e.kind)==="live_artifact"||(e==null?void 0:e.kind)==="dashboard",Qe=e=>e.kind!=="trigger"&&!T(e),et=e=>e.is_glue===!0&&!T(e),U=e=>{const o=new Set(e.filter(et).map(i=>i.id)),n=e.filter(Qe);return n.length>0&&n.every(i=>o.has(i.id))?o.delete(n[0].id):o.size===e.length&&e.length>0&&o.delete(e[0].id),o},le=(e,o)=>{if(!(e.kind!=="workflow_invocation"||!e.workflow_id))return o.get(e.workflow_id)};function ue(e){const o=new Map;for(const n of e){const i=M(n.source,n.target);o.has(i)||o.set(i,{...n,isSyntheticHiddenStep:!1})}return[...o.values()]}function ge(e,o){const n=U(e),i=new Map(e.map(s=>[s.id,s])),c=e.filter(s=>!n.has(s.id)),p=o.filter(s=>!(T(i.get(s.source))||T(i.get(s.target)))),_=new Map,h=new Map;for(const s of p){const t=_.get(s.source)??[];t.push(s),_.set(s.source,t);const r=h.get(s.target)??[];r.push(s),h.set(s.target,r)}const f=new Map,y=new Set(o.map(s=>M(s.source,s.target)));for(const s of o)if(!(n.has(s.source)||n.has(s.target))){const t=M(s.source,s.target);f.has(t)||f.set(t,{...s,isSyntheticHiddenStep:!1})}const x=(s,t,r)=>{if(s===t||!r)return;const d=M(s,t),l=f.get(d);f.set(d,{...l,id:(l==null?void 0:l.id)??`glue-bypass:${s}:${t}`,source:s,target:t,isSyntheticHiddenStep:(l==null?void 0:l.isSyntheticHiddenStep)??!0})};for(const s of c){const t=(_.get(s.id)??[]).map(r=>({target:r.target,traversedHiddenNode:!1,visitedHidden:new Set}));for(;t.length>0;){const r=t.pop();if(!r)break;const d=i.get(r.target);if(!d)continue;if(!n.has(d.id)){x(s.id,d.id,r.traversedHiddenNode);continue}if(r.visitedHidden.has(d.id))continue;const l=new Set(r.visitedHidden);l.add(d.id);for(const b of _.get(d.id)??[])t.push({target:b.target,traversedHiddenNode:!0,visitedHidden:l})}}const E=(s,t,r)=>{const d=new Set,l=new Set([s]),b=[s];for(;b.length>0;){const k=b.pop();if(k)for(const a of t.get(k)??[]){const I=r(a);if(i.has(I)){if(!n.has(I)){d.add(I);continue}l.has(I)||(l.add(I),b.push(I))}}}return[...d]},S=s=>s.filter(t=>{var r;return((r=i.get(t))==null?void 0:r.kind)!=="trigger"}),D=s=>{const t=S(s);return t.length>0?t:s},N=(s,t)=>{const r=E(s,t==="write"?h:_,l=>t==="write"?l.source:l.target);if(t==="write")return D(r);const d=S(r);return d.length>0?d:S(E(s,h,l=>l.source))},C=(s,t)=>{if(s===t)return;const r=M(s,t),d=M(t,s);if(y.has(d)||f.has(d))return;const l=f.get(r);f.set(r,{...l,id:(l==null?void 0:l.id)??`glue-lineage-bypass:${s}:${t}`,source:s,target:t,isSyntheticHiddenStep:(l==null?void 0:l.isSyntheticHiddenStep)??!0})},A=o.filter(s=>n.has(s.source)&&T(i.get(s.target))),H=o.filter(s=>T(i.get(s.source))&&n.has(s.target));for(const s of A)for(const t of N(s.source,"write"))C(t,s.target);for(const s of H)for(const t of N(s.target,"read"))C(s.source,t);return{nodes:c,edges:[...f.values()]}}function tt(e,o){if(U(e).size>0)return!0;const n=new Map(o.map(i=>[i.id,i]));return e.some(i=>{var c;return U(((c=le(i,n))==null?void 0:c.nodes)??[]).size>0})}const fe="var(--colors-border-medium)",st={stroke:fe,strokeWidth:1},ot={type:"arrowclosed",color:fe,width:12,height:12};function pe(e,o){const n=new Set(e.map(i=>i.id));return new Set(o.filter(i=>n.has(i.source)&&n.has(i.target)).map(i=>i.source))}function se(e,o){var i;if(!e.fan_out)return null;if(e.fan_out.source_node_id)return`Fans out over ${o.get(e.fan_out.source_node_id)??"an upstream step"}`;if(e.fan_out.description)return e.fan_out.description;const n=((i=e.fan_out.values)==null?void 0:i.length)??0;return n>0?`Fans out over ${n} items`:"Fans out (unconfigured)"}function nt(e,o,n,i,c){const p=o.nodes??[],_=o.edges??[],h=c?{nodes:p,edges:ue
1(_)}:ge(p,_),f=h.nodes;if(f.length===0)return null;const y=new Map(f.map(a=>[a.id,a.name])),x=a=>{var I;return(I=a.fan_out)!=null&&I.source_node_id?y.get(a.fan_out.source_node_id)??null:null},E=new Map(f.map(a=>[a.id,ce(a,null,x(a))])),S=a=>E.get(a.id)??F,D=pe(f,h.edges),{nodes:N,edges:C}=oe({nodes:f,edges:h.edges,nodeWidth:G,nodeHeight:F,getNodeSize:a=>({width:G,height:S(a)}),nodeType:"dagSpecNode",getNodeId:a=>a.id,getNodeData:a=>({node:a,hasError:n.has(a.id),hasOutgoingEdge:D.has(a.id),workflowName:null,fanOutSourceName:x(a)}),getEdgeId:a=>a.id,getEdgeSource:a=>a.source,getEdgeTarget:a=>a.target,skipUnknownEdges:!0,nodesep:Ue,ranksep:Fe,marginx:0,marginy:0}),A=Math.min(...N.map(a=>a.position.x)),H=Math.min(...N.map(a=>a.position.y)),s=Math.max(...N.map(a=>a.position.x+G)),t=Math.max(...N.map(a=>a.position.y+S(a.data.node))),r=s-A+j*2,d=qe(o.name,i!==null,r),l=j-A,b=d+ee-H,k=a=>`${e.id}${Je}${a}`;return{hostId:e.id,workflow:o,width:r,height:t-H+d+ee+j,headerHeight:d,memberNodes:N.map(a=>({...a,id:k(a.id),parentId:e.id,extent:"parent",draggable:!1,connectable:!1,deletable:!1,data:{...a.data,selection:{nodeId:a.id,workflowId:o.id}},position:{x:a.position.x+l,y:a.position.y+b}})),memberEdges:C.map(a=>({...a,id:k(a.id),source:k(a.source),target:k(a.target),selectable:!1,deletable:!1,data:{...a.data,isWorkflowMember:!0}}))}}function at(e,o,n,i,c=!1){const p=c?{nodes:e,edges:ue(o)}:ge(e,o),_=new Map(i.map(t=>[t.id,t.name])),h=new Map(i.map(t=>[t.id,t])),f=new Map(e.map(t=>[t.id,t.name])),y=t=>t.workflow_id?_.get(t.workflow_id)??null:null,x=t=>{var r;return(r=t.fan_out)!=null&&r.source_node_id?f.get(t.fan_out.source_node_id)??null:null},E=new Map;for(const t of p.nodes){const r=le(t,h);if(!r)continue;const d=nt(t,r,n,se(t,f),c);d&&E.set(t.id,d)}const S=pe(p.nodes,p.edges),{nodes:D,edges:N}=oe({nodes:p.nodes,edges:p.edges,nodeWidth:G,nodeHeight:F,getNodeSize:t=>{const r=E.get(t.id);return r?{width:r.width,height:r.height}:{width:G,height:ce(t,y(t),x(t))}},nodeType:"dagSpecNode",getNodeId:t=>t.id,getNodeData:t=>({node:t,hasError:n.has(t.id),hasOutgoingEdge:S.has(t.id),workflowName:y(t),fanOutSourceName:x(t)}),getEdgeId:t=>t.id,getEdgeSource:t=>t.source,getEdgeTarget:t=>t.target,skipUnknownEdges:!0,ranksep:70}),C=new Map(p.edges.map(t=>[t.id,t])),A=t=>{const r=C.get(t.id);return{...t,style:st,markerEnd:ot,deletable:r!=null&&r.isSyntheticHiddenStep?!1:t.deletable}};if(E.size===0)return{flowNodes:D,flowEdges:N.map(A)};const H=[];for(const t of D){const r=E.get(t.id);if(!r){H.push(t);continue}const d=t.data.node;H.push({...t,type:"dagSpecWorkflowGroup",style:{width:r.width,height:r.height},data:{node:d,workflowName:r.workflow.name,fanOutSummary:se(d,f),hasError:n.has(t.id),hasOutgoingEdge:S.has(t.id),width:r.width,height:r.height,headerHeight:r.headerHeight}}),H.push(...r.memberNodes)}const s=[...E.values()].flatMap(t=>t.memberEdges);return{flowNodes:H,flowEdges:[...N,...s].map(A)}}function z(e){return e?"!h-2.5 !w-2.5 !border-2 !border-elevated !bg-slate-400 shadow-sm":"!invisible"}function he(e,o){return z(e&&o)}function it({data:e,isConnectable:o}){const{node:n,hasError:i,hasOutgoingEdge:c,workflowName:p,fanOutSourceName:_}=e,h=je(n),f=h.icon,y=h.style,x=v.useMemo(()=>ne(n),[n]),E=ae(n,p??null,_??null),S=z(o&&n.kind!=="trigger"),D=he(o&&n.kind!=="dashboard",c);return g.jsxs("div",{className:R("w-[260px] cursor-pointer rounded-none border px-4 py-3 text-left shadow-none transition-colors duration-75",i?"border-red-400 bg-elevated ring-2 ring-red-200":R(y.border,y.bg)),children:[g.jsx(L,{className:S,isConnectable:o&&n.kind!=="trigger",position:B.Top,type:"target"}),g.jsx(L,{className:D,isConnectable:o&&n.kind!=="dashboard",position:B.Bottom,type:"source"}),g.jsxs("div",{className:R("-mx-4 mb-2 flex items-center gap-1.5 border-light border-b px-4 pb-2.5 text-xs",i?"text-red-600":y.accent),children:[g.jsx("span",{className:R("inline-flex size-5 shrink-0 items-center justify-center rounded-[3px]",i?"bg-red-100":y.iconBg),children:g.jsx(f,{size:12,strokeWidth:2.5})}),h.label]}),g.jsx("div",{className:"font-medium text-prose-base text-sm",children:n.name}),E?g.jsx("p",{className:"mt-0.5 text-prose-tertiary text-xs",children:E}):null,x?g.jsx("p",{className:"mt-1.5 line-clamp-2 text-prose-tertiary text-xs",children:x}):null]})}function rt({data:e,isConnectable:o}){const n=e,i=z(o),c=he(o,n.hasOutgoingEdge);return g.jsxs("div",{className:R("relative rounded-none border-2 bg-violet-50/40 shadow-none transition-colors duration-75",n.hasError?"border-system-error":"border-violet-300 hover:border-violet-400"),style:{width:n.width,height:n.height},children:[g.jsx(L,{className:i,position:B.Top,type:"target"}),g.jsx(L,{className:c,position:B.Bottom,type:"source"}),g.jsxs("div",{className:"absolute inset-x-0 top-0 flex flex-col justify-center gap-0.5 rounded-none border-violet-200 border-b bg-violet-100/60 px-3 py-1.5",style:{minHeight:n.headerHeight},children:[g.jsxs("div",{className:"flex items-center gap-1.5 text-violet-500 text-xs",children:[g.jsx(be,{className:"shrink-0",size:11,strokeWidth:2.5}),"Workflow call"]}),g.jsx("span",{className:"line-clamp-2 font-medium text-prose-base text-sm leading-tight",children:n.workflowName}),n.fanOutSummary?g.jsx("span",{className:"truncate text-prose-tertiary text-xs",children:n.fanOutSummary}):null]})]})}const dt={padding:.2,minZoom:.05,maxZoom:1.2},ct=["Backspace","Delete"],lt={dagSpecNode:it,dagSpecWorkflowGroup:rt};function ut({nodes:e,edges:o,workflows:n,editable:i,validationIssues:c,onSelectNode:p,onDeleteNode:_,onDeleteEdge:h,onConnect:f,heightClassName:y,canvasSurfaceClassName:x=He,fitViewOptions:E=dt,fullBleed:S,hideBackgroun
1d:D,hideControls:N,onOpenFullView:C,disableScrollHijack:A}){const H=ke(),s=v.useMemo(()=>tt(e,n??[]),[e,n]),{canRevealHiddenNodes:t,setRevealRequested:r,showHiddenNodes:d}=Te(s),l=v.useMemo(()=>new Set(c.filter(u=>u.severity==="error"&&u.node_id).map(u=>u.node_id)),[c]),b=v.useMemo(()=>at(e,o,l,n??[],d),[e,o,l,n,d]),[k,a,I]=De(b.flowNodes),[W,K,Y]=Ae(b.flowEdges);v.useEffect(()=>{a(b.flowNodes)},[b.flowNodes,a]),v.useEffect(()=>{K(b.flowEdges)},[b.flowEdges,K]);const X=v.useCallback(u=>k.some(m=>m.id===u&&m.parentId!==void 0),[k]),V=v.useCallback(u=>W.some(m=>{var w;return m.id===u&&((w=m.data)==null?void 0:w.isWorkflowMember)===!0}),[W]),me=v.useCallback(u=>{const m=[];for(const w of u)w.type==="remove"&&X(w.id)||(w.type==="remove"?_(w.id):m.push(w));I(m)},[X,_,I]),_e=v.useCallback(u=>{const m=[];for(const w of u)w.type==="remove"&&V(w.id)||(w.type==="remove"?h(w.id):m.push(w));Y(m)},[V,h,Y]),Z=v.useMemo(()=>e.map(u=>u.id),[e]),Ee=v.useCallback(u=>{if(!(i&&u.source&&u.target))return;if(ye(Z,o,{source:u.source,target:u.target})){O({title:"That connection would create a cycle",description:"Choose a different source or target node.",variant:"destructive"});return}const m=Se(e,{source:u.source,target:u.target},o);if(m==="duplicate_edge"){O({title:"Those nodes are already connected",description:"Choose a different source or target node.",variant:"destructive"});return}if(m==="trigger_target"){O({title:"Triggers can't have incoming connections",description:"Choose a different target node.",variant:"destructive"});return}if(m==="dashboard_input_not_live_artifact"){O({title:"Dashboards only accept LiveArtifact inputs",description:"Connect a LiveArtifact node to this Dashboard.",variant:"destructive"});return}if(m==="dashboard_has_outgoing_edge"){O({title:"Dashboards can't have outgoing connections",description:"Choose a different source node.",variant:"destructive"});return}f({source:u.source,target:u.target})},[i,Z,o,e,f]),Ne=v.useCallback((u,m)=>{var q;const w=(q=m.data)==null?void 0:q.selection;p(w??{nodeId:m.id})},[p]);return g.jsx("div",{className:R("w-full overflow-hidden",x,S?"h-full min-h-0":R(xe,y??"h-[420px] md:h-[520px]")),children:g.jsxs(Ce,{deleteKeyCode:i?ct:null,edges:W,edgeTypes:Oe,fitView:!0,fitViewOptions:E,id:H,minZoom:.05,nodes:k,nodesConnectable:i,nodesDraggable:i,nodeTypes:lt,onConnect:Ee,onEdgesChange:_e,onNodeClick:Ne,onNodesChange:me,preventScrolling:!A,proOptions:{hideAttribution:!0},zoomOnScroll:!A,children:[D?null:g.jsx(Re,{color:ve,gap:16,size:2.5,variant:Me.Cross}),(!N||C)&&g.jsx(Ge,{fitViewOptions:E,onOpenFullView:C,position:N?"top-right":"bottom-right",showZoomButtons:!N}),g.jsx(Pe,{checked:d,flowId:H,onCheckedChange:r,position:"top-right",visible:!N&&t})]})})}function bt(e){return g.jsx(Ie,{children:g.jsx(ut,{...e})})}export{bt as DagSpecCanvas};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.