@notmrabhi/flowforge 0.1.56 → 0.1.57

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 (27) hide show
  1. package/dist/{SchemaBuilderDrawer-BqNqYbVF.js → SchemaBuilderDrawer-9m1q_f4y.js} +2 -2
  2. package/dist/{SchemaBuilderDrawer-BqNqYbVF.js.map → SchemaBuilderDrawer-9m1q_f4y.js.map} +1 -1
  3. package/dist/{SchemaBuilderDrawer-C1VhNFEm.js → SchemaBuilderDrawer-C54xKa-P.js} +2 -2
  4. package/dist/{SchemaBuilderDrawer-C1VhNFEm.js.map → SchemaBuilderDrawer-C54xKa-P.js.map} +1 -1
  5. package/dist/{WorkflowExecutionHistory-BuTFR_lG.js → WorkflowExecutionHistory-DsrLtY5i.js} +2 -2
  6. package/dist/{WorkflowExecutionHistory-BuTFR_lG.js.map → WorkflowExecutionHistory-DsrLtY5i.js.map} +1 -1
  7. package/dist/{WorkflowExecutionHistory-DeakdR2x.js → WorkflowExecutionHistory-n2xLZdI9.js} +2 -2
  8. package/dist/{WorkflowExecutionHistory-DeakdR2x.js.map → WorkflowExecutionHistory-n2xLZdI9.js.map} +1 -1
  9. package/dist/canvas.cjs +1 -1
  10. package/dist/canvas.js +1 -1
  11. package/dist/form.cjs +1 -1
  12. package/dist/form.js +2 -2
  13. package/dist/{index-DgFeszTW.js → index-BQHjXZIn.js} +2 -2
  14. package/dist/{index-DgFeszTW.js.map → index-BQHjXZIn.js.map} +1 -1
  15. package/dist/{index-DKZKHw5W.js → index-BypSWEYO.js} +5 -5
  16. package/dist/{index-DKZKHw5W.js.map → index-BypSWEYO.js.map} +1 -1
  17. package/dist/{index-CEDP3md_.js → index-D-ObmLY1.js} +99 -89
  18. package/dist/{index-CEDP3md_.js.map → index-D-ObmLY1.js.map} +1 -1
  19. package/dist/{index-BEgvjJKb.js → index-DNBDuEzF.js} +2 -2
  20. package/dist/{index-BEgvjJKb.js.map → index-DNBDuEzF.js.map} +1 -1
  21. package/dist/{index-Cgy0mjGX.js → index-b0hy-r3d.js} +2 -2
  22. package/dist/{index-Cgy0mjGX.js.map → index-b0hy-r3d.js.map} +1 -1
  23. package/dist/{index-DXoOohrF.js → index-hByI0uXP.js} +2 -2
  24. package/dist/{index-DXoOohrF.js.map → index-hByI0uXP.js.map} +1 -1
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.js +3 -3
  27. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";const c=require("react/jsx-runtime"),p=require("react"),ae=require("reactflow");require("reactflow/dist/style.css");const re=require("./GatewayBranchEdge-6rCziASt.js"),A=require("@mui/material"),Nn=require("react-select"),I=require("react-icons/md"),On=require("react-icons/gr"),Et=require("react-icons/bi"),Xe=require("./index-DKZKHw5W.js"),In=require("./messages-Bg7b9RbI.js"),H=require("./canvasTokens-gKNYrPl4.js");var Dt=Object.defineProperty,Mn=(e,t,n)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zn=(e,t)=>{for(var n in t)Dt(e,n,{get:t[n],enumerable:!0})},Ln=(e,t,n)=>Mn(e,t+"",n),Wt={};zn(Wt,{Graph:()=>Y,alg:()=>Ve,json:()=>Gt,version:()=>Bn});var Rn=Object.defineProperty,$t=(e,t)=>{for(var n in t)Rn(e,n,{get:t[n],enumerable:!0})},Y=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,s,l,d=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(l=t,d=!0)):(o=e,i=t,s=r,arguments.length>2&&(l=n,d=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let a=he(this._isDirected,o,i,s);if(a in this._edgeLabels)return d&&(this._edgeLabels[a]=l),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[a]=d?l:this._defaultEdgeLabelFn(o,i,s);let u=Pn(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[a]=u,kt(this._preds[i],o),kt(this._sucs[o],i),this._in[i][a]=u,this._out[o][a]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Le(this._isDirected,e):he(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Le(this._isDirected,e):he(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Le(this._isDirected,e):he(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],jt(this._preds[s],i),jt(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function kt(e,t){e[t]?e[t]++:e[t]=1}function jt(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function he(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function Pn(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let l=o;o=i,i=l}let s={v:o,w:i};return r&&(s.name=r),s}function Le(e,t){return he(e,t.v,t.w,t.name)}var Bn="4.0.1",Gt={};$t(Gt,{read:()=>Wn,write:()=>Fn});function Fn(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:An(e),edges:Dn(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function An(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function Dn(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Wn(e){let t=new Y(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var Ve={};$t(Ve,{CycleException:()=>je,bellmanFord:()=>Yt,components:()=>Yn,dijkstra:()=>ke,dijkstraAll:()=>qn,findCycles:()=>Hn,floydWarshall:()=>Vn,isAcyclic:()=>Zn,postorder:()=>er,preorder:()=>tr,prim:()=>nr,shortestPaths:()=>rr,tarjan:()=>Kt,topsort:()=>qt});var $n=()=>1;function Yt(e,t,n,r){return Gn(e,String(t),n||$n,r||function(o){return e.outEdges(o)})}function Gn(e,t,n,r){let o={},i,s=0,l=e.nodes(),d=function(f){let h=n(f);o[f.v].distance+h<o[f.w].distance&&(o[f.w]={distance:o[f.v].distance+h,predecessor:f.v},i=!0)},a=function(){l.forEach(function(f){r(f).forEach(function(h){let g=h.v===f?h.v:h.w,b=g===h.v?h.w:h.v;d({v:g,w:b})})})};l.forEach(function(f){let h=f===t?0:Number.POSITIVE_INFINITY;o[f]={distance:h,predecessor:""}});let u=l.length;for(let f=1;f<u&&(i=!1,s++,a(),!!i);f++);if(s===u-1&&(i=!1,a(),i))throw new Error("The graph contains a negative weight cycle");return o}function Yn(e){let t={},n=[],r;function o(i){i in t||(t[i]=!0,r.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var Ut=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},Un=()=>1;function ke(e,t,n,r){let o=function(i){return e.outEdges(i)};return Kn(e,String(t),n||Un,r||o)}function Kn(e,t,n,r){let o={},i=new Ut,s,l,d=function(a){let u=a.v!==s?a.v:a.w,f=o[u],h=n(a),g=l.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+a+" Weight: "+h);g<f.distance&&(f.distance=g,f.predecessor=s,i.decrease(u,g))};for(e.nodes().forEach(function(a){let u=a===t?0:Number.POSITIVE_INFINITY;o[a]={distance:u,predecessor:""},i.add(a,u)});i.size()>0&&(s=i.removeMin(),l=o[s],l.distance!==Number.POSITIVE_INFINITY);)r(s).forEach(d);return o}function qn(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=ke(e,o,t,n),r},{})}function Kt(e){let t=0,n=[],r={},o=[];function i(s){let l=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach(function(d){d in r?r[d].onStack&&(l.lowlink=Math.min(l.lowlink,r[d].index)):(i(d),l.lowlink=Math.min(l.lowlink,r[d].lowlink))}),l.lowlink===l.index){let d=[],a;do a=n.pop(),r[a].onStack=!1,d.push(a);while(s!==a);o.push(d)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function Hn(e){return Kt(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Xn=()=>1;function Vn(e,t,n){return Jn(e,t||Xn,n||function(r){return e.outEdges(r)})}function Jn(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){r[i]={},r[i][i]={distance:0,predecessor:""},o.forEach(function(s){i!==s&&(r[i][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(s){let l=s.v===i?s.w:s.v,d=t(s);r[i][l]={distance:d,predecessor:i}})}),o.forEach(function(i){let s=r[i];o.forEach(function(l){let d=r[l];o.forEach(function(a){let u=d[i],f=s[a],h=d[a],g=u.distance+f.distance;g<h.distance&&(h.distance=g,h.predecessor=f.predecessor)})})}),r}var je=class extends Error{constructor(...e){super(...e)}};function qt(e){let t={},n={},r=[];function o(i){if(i in n)throw new je;i in t||(n[i]=!0,t[i]=!0,e.predecessors(i).forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new je;return r}function Zn(e){try{qt(e)}catch(t){if(t instanceof je)return!1;throw t}return!0}function Qn(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=l=>{var d;return(d=e.isDirected()?e.successors(l):e.neighbors(l))!=null?d:[]},s={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);o=Ht(e,l,n==="post",s,i,r,o)}),o}function Ht(e,t,n,r,o,i,s){return t in r||(r[t]=!0,n||(s=i(s,t)),o(t).forEach(function(l){s=Ht(e,l,n,r,o,i,s)}),n&&(s=i(s,t))),s}function Xt(e,t,n){return Qn(e,t,n,function(r,o){return r.push(o),r},[])}function er(e,t){return Xt(e,t,"post")}function tr(e,t){return Xt(e,t,"pre")}function nr(e,t){let n=new Y,r={},o=new Ut,i;function s(d){let a=d.v===i?d.w:d.v,u=o.priority(a);if(u!==void 0){let f=t(d);f<u&&(r[a]=i,o.decrease(a,f))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(d){o.add(d,Number.POSITIVE_INFINITY),n.setNode(d)}),o.decrease(e.nodes()[0],0);let l=!1;for(;o.size()>0;){if(i=o.removeMin(),i in r)n.setEdge(i,r[i]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(i).forEach(s)}return n}function rr(e,t,n,r){return or(e,t,n,r??(o=>{let i=e.outEdges(o);return i??[]}))}function or(e,t,n,r){if(n===void 0)return ke(e,t,n,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let l=r(i[s]);for(let d=0;d<l.length;d++){let a=l[d],u=a.v===i[s]?a.v:a.w,f=u===a.v?a.w:a.v;n({v:u,w:f})<0&&(o=!0)}if(o)return Yt(e,t,n,r)}return ke(e,t,n,r)}function ce(e,t,n,r){let o=r;for(;e.hasNode(o);)o=Je(r);return n.dummy=t,e.setNode(o,n),o}function ir(e){let t=new Y().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function Vt(e){let t=new Y({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function St(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,s=e.width/2,l=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let d,a;return Math.abs(i)*s>Math.abs(o)*l?(i<0&&(l=-l),d=l*o/i,a=l):(o<0&&(s=-s),d=s,a=s*i/o),{x:n+d,y:r+a}}function be(e){let t=ge(Zt(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function sr(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=X(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function lr(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=X(Math.min,t),r=[];e.nodes().forEach(s=>{let l=e.node(s).rank-n;r[l]||(r[l]=[]),r[l].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,l)=>{s===void 0&&l%i!==0?--o:s!==void 0&&o&&s.forEach(d=>e.node(d).rank+=o)})}function _t(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),ce(e,"border",o,t)}function ar(e,t=Jt){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var Jt=65535;function X(e,t){if(t.length>Jt){let n=ar(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function Zt(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return X(Math.max,t)}function dr(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Qt(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function en(e,t){return t()}var cr=0;function Je(e){let t=++cr;return e+(""+t)}function ge(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function Se(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function _e(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function ur(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Te="\0",fr="3.0.0",hr=class{constructor(){Ln(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Tt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Tt(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,gr)),n=n._prev;return"["+e.join(", ")+"]"}};function Tt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function gr(e,t){if(e!=="_next"&&e!=="_prev")return t}var pr=hr,br=()=>1;function yr(e,t){if(e.nodeCount()<=1)return[];let n=mr(e,t||br);return xr(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function xr(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],l;for(;e.nodeCount();){for(;l=s.dequeue();)Re(e,t,n,l);for(;l=i.dequeue();)Re(e,t,n,l);if(e.nodeCount()){for(let d=t.length-2;d>0;--d)if(l=(r=t[d])==null?void 0:r.dequeue(),l){o=o.concat(Re(e,t,n,l,!0)||[]);break}}}return o}function Re(e,t,n,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),a=e.node(l.v);o&&i.push({v:l.v,w:l.w}),a.out-=d,Ge(t,n,a)}),(e.outEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),a=l.w,u=e.node(a);u.in-=d,Ge(t,n,u)}),e.removeNode(r.v),s}function mr(e,t){let n=new Y,r=0,o=0;e.nodes().forEach(l=>{n.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let d=n.edge(l.v,l.w)||0,a=t(l),u=d+a;n.setEdge(l.v,l.w,u);let f=n.node(l.v),h=n.node(l.w);o=Math.max(o,f.out+=a),r=Math.max(r,h.in+=a)});let i=vr(o+r+3).map(()=>new pr),s=r+1;return n.nodes().forEach(l=>{Ge(i,s,n.node(l))}),{graph:n,buckets:i,zeroIdx:s}}function Ge(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function vr(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function wr(e){(e.graph().acyclicer==="greedy"?yr(e,t(e)):Er(e)).forEach(n=>{let r=e.edge(n);e.removeEdge(n),r.forwardName=n.name,r.reversed=!0,e.setEdge(n.w,n.v,r,Je("rev"))});function t(n){return r=>n.edge(r).weight}}function Er(e){let t=[],n={},r={};function o(i){Object.hasOwn(r,i)||(r[i]=!0,n[i]=!0,e.outEdges(i).forEach(s=>{Object.hasOwn(n,s.w)?t.push(s):o(s.w)}),delete n[i])}return e.nodes().forEach(o),t}function kr(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function jr(e){e.graph().dummyChains=[],e.edges().forEach(t=>Sr(e,t))}function Sr(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,s=t.name,l=e.edge(t),d=l.labelRank;if(i===r+1)return;e.removeEdge(t);let a,u,f;for(f=0,++r;r<i;++f,++r)l.points=[],u={width:0,height:0,edgeLabel:l,edgeObj:t,rank:r},a=ce(e,"edge",u,"_d"),r===d&&(u.width=l.width,u.height=l.height,u.dummy="edge-label",u.labelpos=l.labelpos),e.setEdge(n,a,{weight:l.weight},s),f===0&&e.graph().dummyChains.push(a),n=a;e.setEdge(n,o,{weight:l.weight},s)}function _r(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function Ze(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),s=i?i.map(d=>d==null?Number.POSITIVE_INFINITY:n(d.w)-e.edge(d).minlen):[],l=X(Math.min,s);return l===Number.POSITIVE_INFINITY&&(l=0),o.rank=l}e.sources().forEach(n)}function de(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var tn=Tr;function Tr(e){let t=new Y({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,s;for(;Cr(t,e)<o&&(i=Nr(t,e),!!i);)s=t.hasNode(i.v)?de(e,i):-de(e,i),Or(t,e,s);return t}function Cr(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,l=r===s?i.w:s;!e.hasNode(l)&&!de(t,i)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function Nr(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=de(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function Or(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Ir,postorder:Mr}=Ve,zr=ie;ie.initLowLimValues=et;ie.initCutValues=Qe;ie.calcCutValue=nn;ie.leaveEdge=on;ie.enterEdge=sn;ie.exchangeEdges=ln;function ie(e){e=ir(e),Ze(e);let t=tn(e);et(t),Qe(t,e);let n,r;for(;n=on(t);)r=sn(t,e,n),ln(t,e,n,r)}function Qe(e,t){let n=Mr(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>Lr(e,t,r))}function Lr(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=nn(e,t,n)}function nn(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),s=0;i||(o=!1,i=t.edge(r,n)),s=i.weight;let l=t.nodeEdges(n);return l&&l.forEach(d=>{let a=d.v===n,u=a?d.w:d.v;if(u!==r){let f=a===o,h=t.edge(d).weight;if(s+=f?h:-h,Pr(e,n,u)){let g=e.edge(n,u).cutvalue;s+=f?-g:g}}}),s}function et(e,t){arguments.length<2&&(t=e.nodes()[0]),rn(e,{},1,t)}function rn(e,t,n,r,o){let i=n,s=e.node(r);t[r]=!0;let l=e.neighbors(r);return l&&l.forEach(d=>{Object.hasOwn(t,d)||(n=rn(e,t,n,d,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function on(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function sn(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),s=e.node(o),l=i,d=!1;return i.lim>s.lim&&(l=s,d=!0),t.edges().filter(a=>d===Ct(e,e.node(a.v),l)&&d!==Ct(e,e.node(a.w),l)).reduce((a,u)=>de(t,u)<de(t,a)?u:a)}function ln(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),et(e),Qe(e,t),Rr(e,t)}function Rr(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=Ir(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),l=!1;s||(s=t.edge(i,o),l=!0),t.node(o).rank=t.node(i).rank+(l?s.minlen:-s.minlen)})}function Pr(e,t,n){return e.hasEdge(t,n)}function Ct(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Br=Fr;function Fr(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Nt(e);break;case"tight-tree":Dr(e);break;case"longest-path":Ar(e);break;case"none":break;default:Nt(e)}}var Ar=Ze;function Dr(e){Ze(e),tn(e)}function Nt(e){zr(e)}var Wr=$r;function $r(e){let t=Yr(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=Gr(e,t,o.v,o.w),s=i.path,l=i.lca,d=0,a=s[d],u=!0;for(;n!==o.w;){if(r=e.node(n),u){for(;(a=s[d])!==l&&e.node(a).maxRank<r.rank;)d++;a===l&&(u=!1)}if(!u){for(;d<s.length-1&&e.node(s[d+1]).minRank<=r.rank;)d++;a=s[d]}a!==void 0&&e.setParent(n,a),n=e.successors(n)[0]}})}function Gr(e,t,n,r){let o=[],i=[],s=Math.min(t[n].low,t[r].low),l=Math.max(t[n].lim,t[r].lim),d;d=n;do d=e.parent(d),o.push(d);while(d&&(t[d].low>s||l>t[d].lim));let a=d,u=r;for(;(u=e.parent(u))!==a;)i.push(u);return{path:o.concat(i.reverse()),lca:a}}function Yr(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(Te).forEach(r),t}function Ur(e){let t=ce(e,"root",{},"_root"),n=Kr(e),r=Object.values(n),o=X(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=i);let s=qr(e)+1;e.children(Te).forEach(l=>an(e,t,i,s,o,n,l)),e.graph().nodeRankFactor=i}function an(e,t,n,r,o,i,s){var l;let d=e.children(s);if(!d.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let a=_t(e,"_bt"),u=_t(e,"_bb"),f=e.node(s);e.setParent(a,s),f.borderTop=a,e.setParent(u,s),f.borderBottom=u,d.forEach(h=>{var g;an(e,t,n,r,o,i,h);let b=e.node(h),w=b.borderTop?b.borderTop:h,y=b.borderBottom?b.borderBottom:h,k=b.borderTop?r:2*r,_=w!==y?1:o-((g=i[s])!=null?g:0)+1;e.setEdge(a,w,{weight:k,minlen:_,nestingEdge:!0}),e.setEdge(y,u,{weight:k,minlen:_,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,a,{weight:0,minlen:o+((l=i[s])!=null?l:0)})}function Kr(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children(Te).forEach(r=>n(r,1)),t}function qr(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Hr(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Xr=Vr;function Vr(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Ot(e,"borderLeft","_bl",n,o,i),Ot(e,"borderRight","_br",n,o,i)}}e.children(Te).forEach(t)}function Ot(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},l=o[t][i-1],d=ce(e,"border",s,n);o[t][i]=d,e.setParent(d,r),l&&e.setEdge(l,d,{weight:1})}function Jr(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&dn(e)}function Zr(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Qr(e),(n==="lr"||n==="rl")&&(eo(e),dn(e))}function dn(e){e.nodes().forEach(t=>It(e.node(t))),e.edges().forEach(t=>It(e.edge(t)))}function It(e){let t=e.width;e.width=e.height,e.height=t}function Qr(e){e.nodes().forEach(t=>Pe(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Pe),Object.hasOwn(r,"y")&&Pe(r)})}function Pe(e){e.y=-e.y}function eo(e){e.nodes().forEach(t=>Be(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Be),Object.hasOwn(r,"x")&&Be(r)})}function Be(e){let t=e.x;e.x=e.y,e.y=t}function to(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),o=X(Math.max,r),i=ge(o+1).map(()=>[]);function s(l){if(t[l])return;t[l]=!0;let d=e.node(l);i[d.rank].push(l);let a=e.successors(l);a&&a.forEach(s)}return n.sort((l,d)=>e.node(l).rank-e.node(d).rank).forEach(s),i}function no(e,t){let n=0;for(let r=1;r<t.length;++r)n+=ro(e,t[r-1],t[r]);return n}function ro(e,t,n){let r=ur(n,n.map((a,u)=>u)),o=t.flatMap(a=>{let u=e.outEdges(a);return u?u.map(f=>({pos:r[f.w],weight:e.edge(f).weight})).sort((f,h)=>f.pos-h.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let l=new Array(s).fill(0),d=0;return o.forEach(a=>{let u=a.pos+i;l[u]+=a.weight;let f=0;for(;u>0;)u%2&&(f+=l[u+1]),u=u-1>>1,l[u]+=a.weight;d+=a.weight*f}),d}function oo(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,s)=>{let l=e.edge(s),d=e.node(s.v);return{sum:i.sum+l.weight*d.order,weight:i.weight+l.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function io(e,t){let n={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),n[o.v]=s}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(n).filter(o=>!o.indegree);return so(r)}function so(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&lo(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>Se(o,["vs","i","barycenter","weight"]))}function lo(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function ao(e,t){let n=dr(e,u=>Object.hasOwn(u,"barycenter")),r=n.lhs,o=n.rhs.sort((u,f)=>f.i-u.i),i=[],s=0,l=0,d=0;r.sort(co(!!t)),d=Mt(i,o,d),r.forEach(u=>{d+=u.vs.length,i.push(u.vs),s+=u.barycenter*u.weight,l+=u.weight,d=Mt(i,o,d)});let a={vs:i.flat(1)};return l&&(a.barycenter=s/l,a.weight=l),a}function Mt(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function co(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function cn(e,t,n,r){let o=e.children(t),i=e.node(t),s=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,d={};s&&(o=o.filter(h=>h!==s&&h!==l));let a=oo(e,o);a.forEach(h=>{if(e.children(h.v).length){let g=cn(e,h.v,n,r);d[h.v]=g,Object.hasOwn(g,"barycenter")&&fo(h,g)}});let u=io(a,n);uo(u,d);let f=ao(u,r);if(s&&l){f.vs=[s,f.vs,l].flat(1);let h=e.predecessors(s);if(h&&h.length){let g=e.node(h[0]),b=e.predecessors(l),w=e.node(b[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+g.order+w.order)/(f.weight+2),f.weight+=2}}return f}function uo(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function fo(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function ho(e,t,n,r){r||(r=e.nodes());let o=go(e),i=new Y({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let l=e.node(s),d=e.parent(s);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){i.setNode(s),i.setParent(s,d||o);let a=e[n](s);a&&a.forEach(u=>{let f=u.v===s?u.w:u.v,h=i.edge(f,s),g=h!==void 0?h.weight:0;i.setEdge(f,s,{weight:e.edge(u).weight+g})}),Object.hasOwn(l,"minRank")&&i.setNode(s,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),i}function go(e){let t;for(;e.hasNode(t=Je("_root")););return t}function po(e,t,n){let r={},o;n.forEach(i=>{let s=e.parent(i),l,d;for(;s;){if(l=e.parent(s),l?(d=r[l],r[l]=s):(d=o,o=s),d&&d!==s){t.setEdge(d,s);return}s=l}})}function un(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,un);return}let n=Zt(e),r=zt(e,ge(1,n+1),"inEdges"),o=zt(e,ge(n-1,-1,-1),"outEdges"),i=to(e);if(Lt(e,i),t.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,l,d=t.constraints||[];for(let a=0,u=0;u<4;++a,++u){bo(a%2?r:o,a%4>=2,d),i=be(e);let f=no(e,i);f<s?(u=0,l=Object.assign({},i),s=f):f===s&&(l=structuredClone(i))}Lt(e,l)}function zt(e,t,n){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let l=s.minRank;l<=s.maxRank;l++)l!==s.rank&&o(l,i)}return t.map(function(i){return ho(e,i,n,r.get(i)||[])})}function bo(e,t,n){let r=new Y;e.forEach(function(o){n.forEach(l=>r.setEdge(l.left,l.right));let i=o.graph().root,s=cn(o,i,r,t);s.vs.forEach((l,d)=>o.node(l).order=d),po(o,r,s.vs)})}function Lt(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function yo(e,t){let n={};function r(o,i){let s=0,l=0,d=o.length,a=i[i.length-1];return i.forEach((u,f)=>{let h=mo(e,u),g=h?e.node(h).order:d;(h||u===a)&&(i.slice(l,f+1).forEach(b=>{let w=e.predecessors(b);w&&w.forEach(y=>{let k=e.node(y),_=k.order;(_<s||g<_)&&!(k.dummy&&e.node(b).dummy)&&fn(n,y,b)})}),l=f+1,s=g)}),i}return t.length&&t.reduce(r),n}function xo(e,t){let n={};function r(i,s,l,d,a){ge(s,l).forEach(u=>{let f=i[u];if(f!==void 0&&e.node(f).dummy){let h=e.predecessors(f);h&&h.forEach(g=>{if(g===void 0)return;let b=e.node(g);b.dummy&&(b.order<d||b.order>a)&&fn(n,g,f)})}})}function o(i,s){let l=-1,d=-1,a=0;return s.forEach((u,f)=>{if(e.node(u).dummy==="border"){let h=e.predecessors(u);if(h&&h.length){let g=h[0];if(g===void 0)return;d=e.node(g).order,r(s,a,f,l,d),a=f,l=d}}r(s,a,s.length,d,i.length)}),s}return t.length&&t.reduce(o),n}function mo(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function fn(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function vo(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function wo(e,t,n,r){let o={},i={},s={};return t.forEach(l=>{l.forEach((d,a)=>{o[d]=d,i[d]=d,s[d]=a})}),t.forEach(l=>{let d=-1;l.forEach(a=>{let u=r(a);if(u&&u.length){let f=u.sort((g,b)=>{let w=s[g],y=s[b];return(w!==void 0?w:0)-(y!==void 0?y:0)}),h=(f.length-1)/2;for(let g=Math.floor(h),b=Math.ceil(h);g<=b;++g){let w=f[g];if(w===void 0)continue;let y=s[w];if(y!==void 0&&i[a]===a&&d<y&&!vo(n,a,w)){let k=o[w];k!==void 0&&(i[w]=a,i[a]=o[a]=k,d=y)}}}})}),{root:o,align:i}}function Eo(e,t,n,r,o=!1){let i={},s=ko(e,t,n,o),l=o?"borderLeft":"borderRight";function d(g,b){let w=s.nodes().slice(),y={},k=w.pop();for(;k;){if(y[k])g(k);else{y[k]=!0,w.push(k);for(let _ of b(k))w.push(_)}k=w.pop()}}function a(g){let b=s.inEdges(g);b?i[g]=b.reduce((w,y)=>{var k;let _=(k=i[y.v])!=null?k:0,O=s.edge(y);return Math.max(w,_+(O!==void 0?O:0))},0):i[g]=0}function u(g){let b=s.outEdges(g),w=Number.POSITIVE_INFINITY;b&&(w=b.reduce((k,_)=>{let O=i[_.w],M=s.edge(_);return Math.min(k,(O!==void 0?O:0)-(M!==void 0?M:0))},Number.POSITIVE_INFINITY));let y=e.node(g);w!==Number.POSITIVE_INFINITY&&y.borderType!==l&&(i[g]=Math.max(i[g]!==void 0?i[g]:0,w))}function f(g){return s.predecessors(g)||[]}function h(g){return s.successors(g)||[]}return d(a,f),d(u,h),Object.keys(r).forEach(g=>{var b;let w=n[g];w!==void 0&&(i[g]=(b=i[w])!=null?b:0)}),i}function ko(e,t,n,r){let o=new Y,i=e.graph(),s=Co(i.nodesep,i.edgesep,r);return t.forEach(l=>{let d;l.forEach(a=>{let u=n[a];if(u!==void 0){if(o.setNode(u),d!==void 0){let f=n[d];if(f!==void 0){let h=o.edge(f,u);o.setEdge(f,u,Math.max(s(e,a,d),h||0))}}d=a}})}),o}function jo(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([l,d])=>{let a=No(e,l)/2;o=Math.max(d+a,o),i=Math.min(d-a,i)});let s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function So(e,t){let n=Object.values(t),r=X(Math.min,n),o=X(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let l=i+s,d=e[l];if(!d||d===t)return;let a=Object.values(d),u=r-X(Math.min,a);s!=="l"&&(u=o-X(Math.max,a)),u&&(e[l]=_e(d,f=>f+u))})})}function _o(e,t=void 0){let n=e.ul;return n?_e(n,(r,o)=>{var i,s;if(t){let d=t.toLowerCase(),a=e[d];if(a&&a[o]!==void 0)return a[o]}let l=Object.values(e).map(d=>{let a=d[o];return a!==void 0?a:0}).sort((d,a)=>d-a);return(((i=l[1])!=null?i:0)+((s=l[2])!=null?s:0))/2}):{}}function To(e){let t=be(e),n=Object.assign(yo(e,t),xo(e,t)),r={},o;["u","d"].forEach(s=>{o=s==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(o=o.map(u=>Object.values(u).reverse()));let d=wo(e,o,n,u=>(s==="u"?e.predecessors(u):e.successors(u))||[]),a=Eo(e,o,d.root,d.align,l==="r");l==="r"&&(a=_e(a,u=>-u)),r[s+l]=a})});let i=jo(e,r);return So(r,i),_o(r,e.graph().align)}function Co(e,t,n){return(r,o,i)=>{let s=r.node(o),l=r.node(i),d=0,a;if(d+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2;break}if(a&&(d+=n?a:-a),a=void 0,d+=(s.dummy?t:e)/2,d+=(l.dummy?t:e)/2,d+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2;break}return a&&(d+=n?a:-a),d}}function No(e,t){return e.node(t).width}function Oo(e){e=Vt(e),Io(e),Object.entries(To(e)).forEach(([t,n])=>e.node(t).x=n)}function Io(e){let t=be(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(s=>{let l=s.reduce((d,a)=>{var u;let f=(u=e.node(a).height)!=null?u:0;return d>f?d:f},0);s.forEach(d=>{let a=e.node(d);o==="top"?a.y=i+a.height/2:o==="bottom"?a.y=i+l-a.height/2:a.y=i+l/2}),i+=l+r})}function Mo(e,t={}){let n=t.debugTiming?Qt:en;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>$o(e));return n(" runLayout",()=>zo(r,n,t)),n(" updateInputGraph",()=>Lo(e,r)),r})}function zo(e,t,n){t(" makeSpaceForEdgeLabels",()=>Go(e)),t(" removeSelfEdges",()=>Zo(e)),t(" acyclic",()=>wr(e)),t(" nestingGraph.run",()=>Ur(e)),t(" rank",()=>Br(Vt(e))),t(" injectEdgeLabelProxies",()=>Yo(e)),t(" removeEmptyRanks",()=>lr(e)),t(" nestingGraph.cleanup",()=>Hr(e)),t(" normalizeRanks",()=>sr(e)),t(" assignRankMinMax",()=>Uo(e)),t(" removeEdgeLabelProxies",()=>Ko(e)),t(" normalize.run",()=>jr(e)),t(" parentDummyChains",()=>Wr(e)),t(" addBorderSegments",()=>Xr(e)),t(" order",()=>un(e,n)),t(" insertSelfEdges",()=>Qo(e)),t(" adjustCoordinateSystem",()=>Jr(e)),t(" position",()=>Oo(e)),t(" positionSelfEdges",()=>ei(e)),t(" removeBorderNodes",()=>Jo(e)),t(" normalize.undo",()=>_r(e)),t(" fixupEdgeLabelCoords",()=>Xo(e)),t(" undoCoordinateSystem",()=>Zr(e)),t(" translateGraph",()=>qo(e)),t(" assignNodeIntersects",()=>Ho(e)),t(" reversePoints",()=>Vo(e)),t(" acyclic.undo",()=>kr(e))}function Lo(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Ro=["nodesep","edgesep","ranksep","marginx","marginy"],Po={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},Bo=["acyclicer","ranker","rankdir","align","rankalign"],Fo=["width","height","rank"],Rt={width:0,height:0},Ao=["minlen","weight","width","height","labeloffset"],Do={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Wo=["labelpos"];function $o(e){let t=new Y({multigraph:!0,compound:!0}),n=Ae(e.graph());return t.setGraph(Object.assign({},Po,Fe(n,Ro),Se(n,Bo))),e.nodes().forEach(r=>{let o=Ae(e.node(r)),i=Fe(o,Fo);Object.keys(Rt).forEach(l=>{i[l]===void 0&&(i[l]=Rt[l])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Ae(e.edge(r));t.setEdge(r,Object.assign({},Do,Fe(o,Ao),Se(o,Wo)))}),t}function Go(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Yo(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};ce(e,"edge-proxy",o,"_ep")}})}function Uo(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Ko(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function qo(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,l=i.marginy||0;function d(a){let u=a.x,f=a.y,h=a.width,g=a.height;t=Math.min(t,u-h/2),n=Math.max(n,u+h/2),r=Math.min(r,f-g/2),o=Math.max(o,f+g/2)}e.nodes().forEach(a=>d(e.node(a))),e.edges().forEach(a=>{let u=e.edge(a);Object.hasOwn(u,"x")&&d(u)}),t-=s,r-=l,e.nodes().forEach(a=>{let u=e.node(a);u.x-=t,u.y-=r}),e.edges().forEach(a=>{let u=e.edge(a);u.points.forEach(f=>{f.x-=t,f.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=n-t+s,i.height=o-r+l}function Ho(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=o,s=r),n.points.unshift(St(r,i)),n.points.push(St(o,s))})}function Xo(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Vo(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Jo(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Zo(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Qo(e){be(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);i.order=o+n,(i.selfEdges||[]).forEach(s=>{ce(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++n,e:s.e,label:s.label},"_se")}),delete i.selfEdges})})}function ei(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let r=n,o=e.node(r.e.v),i=o.x+o.width/2,s=o.y,l=n.x-i,d=o.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:i+2*l/3,y:s-d},{x:i+5*l/6,y:s-d},{x:i+l,y:s},{x:i+5*l/6,y:s+d},{x:i+2*l/3,y:s+d}],r.label.x=n.x,r.label.y=n.y}})}function Fe(e,t){return _e(Se(e,t),Number)}function Ae(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function ti(e){let t=be(e),n=new Y({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,o)=>{let i="layer"+o;n.setNode(i,{rank:"same"}),r.reduce((s,l)=>(n.setEdge(s,l,{style:"invis"}),l))}),n}var ni={graphlib:Wt,version:fr,layout:Mo,debug:ti,util:{time:Qt,notime:en}},Pt=ni;/*! For license information please see dagre.esm.js.LEGAL.txt */const ri=e=>{const t=[];return e.nodeInternals.forEach((n,r)=>t.push(`${r}:${n.height??0}`)),t.join(",")},oi=({onHeightsReady:e,nodeCount:t})=>{const n=ae.useStore(ri),r=p.useRef("");p.useRef(0);const{fitView:o}=ae.useReactFlow();return p.useEffect(()=>{if(!n||n===r.current)return;const i={};for(const s of n.split(",")){const[l,d]=s.split(":"),a=Number(d);l&&a>0&&(i[l]=a)}Object.keys(i).length!==0&&(r.current=n,e(i))},[n]),null},ii={gray:{bg:"#f1f5f9",fg:"#475569"},green:{bg:"#dcfce7",fg:"#166534"},amber:{bg:"#fef3c7",fg:"#92400e"},red:{bg:"#fee2e2",fg:"#991b1b"}};function hn({workflowName:e,onWorkflowNameChange:t,status:n,statusColor:r="gray",onSave:o,onCancel:i,saveLabel:s="Save",saveDisabled:l=!1}){const[d,a]=p.useState(!1),[u,f]=p.useState(!1),[h,g]=p.useState(e??"");p.useEffect(()=>{g(e??"")},[e]);const b=async()=>{if(!(!o||d||l)){a(!0);try{await o()}finally{a(!1)}}},w=ii[r]??{bg:r,fg:"#fff"};return c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 20px",background:"#fff",borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[u&&t?c.jsx("input",{value:h,onChange:y=>g(y.target.value),onBlur:()=>{f(!1),h!==e&&t(h)},onKeyDown:y=>{y.key==="Enter"&&y.target.blur(),y.key==="Escape"&&(g(e??""),f(!1))},autoFocus:!0,style:{fontSize:15,fontWeight:600,color:"#0f172a",border:"1px solid #cbd5e1",borderRadius:4,padding:"2px 6px",minWidth:200}}):c.jsx("span",{onClick:()=>t&&f(!0),style:{fontSize:15,fontWeight:600,color:"#0f172a",cursor:t?"text":"default",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:360},title:e,children:e||"Untitled workflow"}),n&&c.jsx("span",{style:{fontSize:11,fontWeight:600,padding:"3px 8px",borderRadius:999,background:w.bg,color:w.fg,textTransform:"uppercase",letterSpacing:.4,flexShrink:0},children:n})]}),c.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[i&&c.jsx("button",{type:"button",onClick:i,disabled:d,style:{padding:"6px 14px",fontSize:13,fontWeight:500,border:"1px solid #cbd5e1",background:"#fff",color:"#475569",borderRadius:6,cursor:d?"not-allowed":"pointer",opacity:d?.6:1},children:"Cancel"}),o&&c.jsx("button",{type:"button",onClick:b,disabled:d||l,style:{padding:"6px 16px",fontSize:13,fontWeight:600,border:"none",background:l?"#94a3b8":"var(--ff-primary, #1dbf60)",color:"#fff",borderRadius:6,cursor:d||l?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6,minWidth:80,justifyContent:"center"},children:d?"Saving…":s})]})]})}const Ce=({isOpen:e,onClose:t,title:n,icon:r,children:o,footer:i,width:s=600})=>{const[l,d]=p.useState(!1),a=()=>d(h=>!h),u=()=>c.jsxs(A.Box,{sx:{display:"flex",alignItems:"center",p:2,pt:3,borderBottom:"1px solid #e0e0e0",mb:0,flexShrink:0},children:[r&&c.jsx(A.Box,{sx:{mr:1.5,display:"flex",alignItems:"center",fontSize:"1.25rem",color:"#1DBF60"},children:r}),c.jsx("span",{style:{flexGrow:1,fontSize:14,fontWeight:500,color:"#212121"},children:n}),c.jsx(A.IconButton,{onClick:a,size:"small",sx:{mr:1},title:l?"Collapse":"Expand","data-testid":"expand-collapse-base-drawer-btn",children:l?c.jsx(Et.BiCollapse,{}):c.jsx(Et.BiExpand,{})}),c.jsx(A.IconButton,{onClick:t,size:"small","data-testid":"close-drawer-button",children:c.jsx(I.MdClose,{})})]}),f=()=>i?c.jsx(A.Box,{sx:{flexShrink:0,p:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:2},children:i}):null;return l?c.jsxs(A.Dialog,{open:e,onClose:t,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{display:"flex",flexDirection:"column",height:"80vh",boxShadow:24,width:"750px",maxWidth:"100%"}},children:[c.jsx(u,{}),c.jsx(A.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),c.jsx(f,{})]}):c.jsxs(A.Drawer,{anchor:"right",open:e,onClose:t,variant:"persistent",sx:{zIndex:900},ModalProps:{keepMounted:!1},PaperProps:{sx:{width:s,position:"fixed",top:"64px",height:"calc(100% - 74px)",right:"10px",borderRadius:"8px",border:"1px solid #bdbdbd",boxShadow:"none",zIndex:900,display:"flex",flexDirection:"column"}},children:[c.jsx(u,{}),c.jsx(A.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),c.jsx(f,{})]})},si=({open:e,templates:t,messages:n,onSelect:r,onClose:o,loadTriggerSources:i})=>{const[s,l]=p.useState("trigger"),[d,a]=p.useState(null),[u,f]=p.useState([]),[h,g]=p.useState([]),[b,w]=p.useState(!1),[y,k]=p.useState(null);p.useEffect(()=>{e||(l("trigger"),a(null),f([]),g([]),w(!1),k(null))},[e]);const _=p.useCallback(async L=>{if(!i){r(L);return}a(L),w(!0),k(null);try{const F=await i(L.triggerKey);if(!F||F.length===0){r(L);return}f(F),l("sources")}catch(F){k(F instanceof Error?F.message:"Failed to load sources.")}finally{w(!1)}},[i,r]),O=()=>{l("trigger"),a(null),f([]),g([]),k(null)},M=()=>{d&&r(d,h)},z=s==="sources"&&d,W=z?c.jsxs(c.Fragment,{children:[c.jsx(A.Button,{type:"button",variant:"outlined",size:"small",onClick:O,children:n.cancel??"Back"}),c.jsx(A.Button,{type:"button",variant:"contained",size:"small",onClick:M,disabled:h.length===0,children:n.save??"Continue"})]}):null;return c.jsx(Ce,{isOpen:e,onClose:o,title:z?d.label:n.addTriggerTitle,icon:c.jsx(On.GrTrigger,{}),width:500,footer:W,children:c.jsxs(A.Box,{sx:{p:2},children:[!z&&c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"ff-text-muted ff-mb-3",style:{fontSize:13},children:n.chooseTrigger}),c.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-2",children:[t.map(L=>c.jsxs("div",{className:"ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-start ff-gap-3",style:{cursor:b?"wait":"pointer",transition:"background 0.15s",opacity:b?.6:1},onClick:()=>!b&&_(L),role:"button",tabIndex:0,onKeyDown:F=>{F.key==="Enter"&&!b&&_(L)},onMouseEnter:F=>{b||(F.currentTarget.style.background="#f5f5f5")},onMouseLeave:F=>{F.currentTarget.style.background=""},children:[c.jsx("div",{style:{color:L.triggerCategory==="scheduler"?"#1976d2":"#f57c00",marginTop:2,flexShrink:0},children:L.triggerCategory==="scheduler"?c.jsx(I.MdCalendarToday,{size:18}):c.jsx(I.MdBolt,{size:18})}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:L.label}),L.description&&c.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:L.description})]})]},L.triggerKey)),t.length===0&&c.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:n.noTriggers})]}),b&&c.jsxs(A.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:2,fontSize:12,color:"#64748b"},children:[c.jsx(A.CircularProgress,{size:14}),c.jsx("span",{children:"Loading sources for the selected trigger…"})]}),y&&c.jsx("p",{style:{fontSize:12,color:"#d32f2f",marginTop:12},children:y})]}),z&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{role:"button",tabIndex:0,onClick:O,onKeyDown:L=>{L.key==="Enter"&&O()},className:"ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",style:{cursor:"pointer",color:"#0066cc",fontSize:13,fontWeight:500,width:"fit-content"},children:[c.jsx(I.MdArrowBack,{size:16}),c.jsx("span",{children:n.addTriggerTitle})]}),c.jsxs("p",{className:"ff-text-muted ff-mb-2",style:{fontSize:13},children:["Pick one or more sources for ",c.jsx("strong",{children:d.label}),":"]}),c.jsx(Nn,{isMulti:!0,options:u,value:h,onChange:L=>g(L??[]),placeholder:"Select sources…",menuPosition:"fixed",menuPortalTarget:typeof document<"u"?document.body:void 0,styles:Xe.buildSelectStyles(!1,!0)})]})]})})},De={cursor:"pointer",transition:"background 0.15s"},We="ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-center ff-gap-3",li=({open:e,availableDescriptors:t,messages:n,onSelect:r,onClose:o})=>{const{apps:i,ungrouped:s}=p.useMemo(()=>{const f=new Map,h=[];for(const g of t)if(g.app){const b=f.get(g.app.key);b?b.descriptors.push(g):f.set(g.app.key,{key:g.app.key,label:g.app.label,icon:g.app.icon,description:g.app.description,descriptors:[g]})}else h.push(g);return{apps:[...f.values()],ungrouped:h}},[t]),[l,d]=p.useState(null),a=l?i.find(f=>f.key===l)??null:null;p.useEffect(()=>{e||d(null)},[e]),p.useEffect(()=>{d(null)},[t]);const u=!a;return c.jsx(Ce,{isOpen:e,onClose:o,title:u?n.addStepTitle:a.label,icon:u?c.jsx(I.MdAddCircleOutline,{}):a.icon??c.jsx(I.MdApps,{}),width:500,children:c.jsxs(A.Box,{sx:{p:2},children:[!u&&c.jsxs("div",{role:"button",tabIndex:0,onClick:()=>d(null),onKeyDown:f=>{f.key==="Enter"&&d(null)},className:"ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",style:{cursor:"pointer",color:"#0066cc",fontSize:13,fontWeight:500,width:"fit-content"},children:[c.jsx(I.MdArrowBack,{size:16}),c.jsx("span",{children:n.addStepTitle})]}),c.jsx("p",{className:"ff-text-muted ff-mb-3",style:{fontSize:13},children:u?n.chooseAction:`Pick an action from ${a.label}`}),c.jsx("div",{className:"ff-d-flex ff-flex-column ff-gap-2",children:u?c.jsxs(c.Fragment,{children:[i.map(f=>c.jsxs("div",{className:We,style:De,onClick:()=>d(f.key),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&d(f.key)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&c.jsx("div",{style:{flexShrink:0},children:f.icon}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label}),c.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:f.description??`${f.descriptors.length} action${f.descriptors.length===1?"":"s"}`})]}),c.jsx(I.MdChevronRight,{size:18,color:"#9e9e9e"})]},`app-${f.key}`)),s.map(f=>c.jsxs("div",{className:We,style:De,onClick:()=>r(f),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&r(f)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&c.jsx("div",{style:{flexShrink:0},children:f.icon}),c.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label})]},f.type)),i.length===0&&s.length===0&&c.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:n.noActions})]}):a.descriptors.map(f=>c.jsxs("div",{className:We,style:De,onClick:()=>r(f),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&r(f)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&c.jsx("div",{style:{flexShrink:0},children:f.icon}),c.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label})]},f.type))})]})})},Bt="_conditionConfig",ai=({open:e,nodeId:t,descriptor:n,initialValues:r,messages:o,onSave:i,onClose:s})=>{const[l,d]=p.useState([]),[a,u]=p.useState(!1),[f,h]=p.useState(null),[g,b]=p.useState({});p.useEffect(()=>{b((r==null?void 0:r[Bt])??{})},[r,t]),p.useEffect(()=>{let _=!1;if(h(null),!n||!t){d([]),u(!1);return}const O=n.formSchema;return typeof O=="function"?(u(!0),O(t).then(M=>{_||(d(M),u(!1))}).catch(M=>{_||(d([]),h(M instanceof Error?M.message:"Unable to load configuration."),u(!1))})):(d(O),u(!1)),()=>{_=!0}},[n,t]);const w=t?`node-config-form-${t}`:"node-config-form",y=!a&&!f&&l.length>0,k=y?c.jsxs(c.Fragment,{children:[c.jsx(A.Button,{type:"button",variant:"outlined",size:"small",onClick:s,children:o.cancel}),c.jsx(A.Button,{type:"submit",form:w,variant:"contained",size:"small",children:o.save})]}):null;return c.jsx(Ce,{isOpen:e,onClose:s,title:(n==null?void 0:n.label)??o.configureStep,icon:n==null?void 0:n.icon,width:500,footer:k,children:c.jsxs(A.Box,{sx:{p:2},children:[a&&c.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.loadingConfiguration}),!a&&f&&c.jsx("p",{style:{fontSize:13,color:"#d32f2f"},children:f}),!a&&!f&&l.length===0&&c.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.noConfigurationNeeded}),y&&c.jsx(Xe.FlowForm,{schema:{layout:"flat",fields:l},initialValues:r??{},formId:w,conditionConfig:g,onConditionConfigChange:b,onSubmit:_=>{if(!t)return;const O=Object.keys(g).length>0;i(t,{..._,[Bt]:O?g:void 0}),s()}})]})})},gn=({isOpen:e,onClose:t,workflowId:n,workflowLabel:r,onFetchWorkflow:o})=>{const[i,s]=p.useState({status:"idle"});return p.useEffect(()=>{if(!e||!n){s({status:"idle"});return}s({status:"loading"}),o(n).then(l=>s({status:"loaded",state:l})).catch(l=>s({status:"error",message:(l==null?void 0:l.message)??"Failed to load workflow"}))},[e,n,o]),c.jsx(Ce,{isOpen:e,onClose:t,title:r?`Preview: ${r}`:"Sub-Workflow Preview",icon:c.jsx(I.MdAccountTree,{size:18,color:"#00695c"}),width:700,children:c.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24},children:[i.status==="idle"&&c.jsx("span",{style:{color:"#9e9e9e",fontSize:14},children:"Select a workflow to preview"}),i.status==="loading"&&c.jsxs("div",{style:{textAlign:"center",color:"#9e9e9e"},children:[c.jsx("div",{style:{width:32,height:32,borderRadius:"50%",border:"3px solid #e0e0e0",borderTopColor:"#00897b",animation:"spin 0.8s linear infinite",margin:"0 auto 12px"}}),c.jsx("span",{style:{fontSize:14},children:"Loading workflow…"}),c.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}),i.status==="error"&&c.jsxs("div",{style:{textAlign:"center",color:"#c62828"},children:[c.jsx(I.MdErrorOutline,{size:32,style:{marginBottom:8}}),c.jsx("p",{style:{margin:0,fontSize:14},children:i.message})]}),i.status==="loaded"&&c.jsx("div",{style:{width:"100%",flex:1},children:c.jsx(di,{state:i.state})})]})})},di=({state:e})=>{const[t,n]=p.useState(null),[r,o]=p.useState(null);return p.useEffect(()=>{Promise.all([Promise.resolve().then(()=>pi).then(i=>i.default),Promise.resolve().then(()=>require("./nodeRegistry.cjs")).then(i=>i.nodeTypeRegistry),Promise.resolve().then(()=>require("./templateRegistry.cjs")).then(i=>i.templateRegistry)]).then(([i,s,l])=>{n(()=>i),o({nodeTypeRegistry:s,templateRegistry:l})})},[]),!t||!r?c.jsx("div",{style:{color:"#9e9e9e",fontSize:13,textAlign:"center"},children:"Loading canvas…"}):c.jsx("div",{style:{width:"100%",height:480,border:"1px solid #e0e0e0",borderRadius:8,overflow:"hidden"},children:c.jsx(t,{nodeRegistry:r.nodeTypeRegistry,templateRegistry:r.templateRegistry,initialValue:e,readOnly:!0})})},pe=350,Ye=70,Ue=60,Ke={startNode:40,endNode:40,addTriggerNode:56,triggerNode:110,actionNode:90,filterNode:90,approvalNode:90,delayNode:80,notificationNode:80},ci={plusEdge:re.PlusEdge,labelPlusEdge:re.LabelPlusEdge,plainEdge:re.PlainEdge,edgeWithPlusLabel:re.EdgeWithPlusLabel,gatewayBranchEdge:re.GatewayBranchEdge};function Ft(){return[{id:"start",kind:"start",reactFlowType:"startNode"},{id:"addTrigger",kind:"addTrigger",reactFlowType:"addTriggerNode"},{id:"end",kind:"end",reactFlowType:"endNode"}]}function ui(e,t,n,r="TB"){const o=new Pt.graphlib.Graph;return o.setGraph({rankdir:r,ranksep:70,nodesep:50}),o.setDefaultEdgeLabel(()=>({})),e.forEach(i=>{const s=n[i.id]??{width:pe,height:Ke[i.type??""]??80};o.setNode(i.id,{width:s.width,height:s.height})}),t.forEach(i=>o.setEdge(i.source,i.target)),Pt.layout(o),e.map(i=>{var a,u;const s=o.node(i.id),l=((a=n[i.id])==null?void 0:a.width)??pe,d=((u=n[i.id])==null?void 0:u.height)??Ke[i.type??""]??80;return{...i,position:{x:s.x-l/2,y:s.y-d/2}}})}const oe=e=>e==="filter"||e==="approval";function fi(e,t,n,r){const s=Ye,l=30,d=30,a={},u={},f=new Map;for(const y of e)f.set(y.id,y);for(const y of Object.values(t))for(const k of Object.values(y))for(const _ of k)f.set(_.id,_);const h=(y,k,_)=>{const O=r[y]??{width:pe,height:80};return a[y]={x:k-O.width/2,y:_},_+O.height},g=(y,k,_)=>{let O=_;for(const M of y)O=h(M.id,k,O)+s,oe(M.kind)&&t[M.id]&&(O=b(M.id,k,O));return O},b=(y,k,_)=>{const O=k+180,M=t[y],z=Object.keys(M),W=f.get(y),L=(W==null?void 0:W.branchLabels)??{pass:"Pass",fail:"Fail"},F=a[y],$=r[y]??{height:80},ye=F.y+$.height,xe=[];let Z=_;return z.forEach((ue,me)=>{const Ne=M[ue],Oe=Z;xe.push({y:Oe-ye,label:L[ue]??ue,isPass:me===0}),Z=g(Ne,O,Z+d),me<z.length-1&&(Z+=l)}),u[y]={branches:xe,height:Z-ye,indent:180},Z};let w=Ue;for(const y of e)w=h(y.id,400,w)+s,oe(y.kind)&&t[y.id]&&(w=b(y.id,400,w));return{nodes:n.map(y=>a[y.id]?{...y,position:a[y.id]}:y),railSpecs:u}}function At(e){return{id:e.id,type:e.reactFlowType,position:{x:0,y:0},data:{...e.nodeData,...e.formData,descriptorType:e.descriptorType},draggable:!1,selectable:!1}}function hi(e,t,n,r,o){return{id:`e-${e.id}-${t.id}`,source:e.id,target:t.id,type:"plusEdge",style:{stroke:n},data:{onAddStepClick:r,referenceNodeType:e.reactFlowType,...o??{}}}}function gi(e,t,n,r,o={},i="TB",s="horizontal"){const l=o.edgeColor??"#b0bec5",d=[],a=[],u=(b,w)=>{const y=t[b];if(!y)return;const _=w??{pass:"Pass",fail:"Fail"},O=Object.keys(y),M=(z,W,L,F)=>{if(z.length!==0){z.forEach($=>d.push(At($))),a.push({id:`e-${b}-${W}-start`,source:b,target:z[0].id,type:"gatewayBranchEdge",style:{stroke:l},data:{branch:W,filterId:b,label:L,isFirst:F===0,onAddStepClick:n,verticalRouting:s==="vertical"}});for(let $=1;$<z.length;$++)oe(z[$-1].kind)||a.push(hi(z[$-1],z[$],l,n,{filterId:b,branch:W}));for(const $ of z)oe($.kind)&&t[$.id]&&u($.id,$.branchLabels)}};O.forEach((z,W)=>{M(y[z],z,_[z]??z,W)})};for(let b=0;b<e.length;b++){const w=e[b];if(d.push(At(w)),b>0){const y=e[b-1],k=y.kind==="start"||y.kind==="addTrigger";if(y.kind==="filter"||y.kind==="approval")continue;a.push({id:`e-${y.id}-${w.id}`,source:y.id,target:w.id,type:k?"plainEdge":"plusEdge",style:{stroke:l},data:k?{}:{onAddStepClick:n,referenceNodeType:y.reactFlowType}})}(w.kind==="filter"||w.kind==="approval")&&t[w.id]&&u(w.id,w.branchLabels)}const f={};if(d.forEach(b=>{f[b.id]={width:pe,height:r[b.id]??Ke[b.type??""]??80}}),!(Object.keys(t).length>0)){if(i==="LR"){let _=Ue;return{nodes:d.map(M=>{const z=f[M.id].width,W=f[M.id].height,L={...M,position:{x:_,y:300-W/2}};return _+=z+Ye,L}),edges:a}}const b=400;let w=Ue;return{nodes:d.map(k=>{const _=f[k.id].height,O={...k,position:{x:b-pe/2,y:w}};return w+=_+Ye,O}),edges:a}}if(s==="vertical"){const{nodes:b,railSpecs:w}=fi(e,t,d,f);return{nodes:b.map(k=>w[k.id]?{...k,data:{...k.data,_branchRail:w[k.id]}}:k),edges:a}}return{nodes:ui(d,a,f,i),edges:a}}const qe=({nodeRegistry:e,templateRegistry:t,initialValue:n,nodeTypes:r,edgeTypes:o,onSave:i,readOnly:s=!1,theme:l={},messages:d,canvasOptions:a={},renderTriggerSelector:u,loadTriggerSources:f,renderNodePicker:h,renderNodeConfig:g,onNodeClick:b,maxNodes:w,layoutDirection:y="TB",executionRecord:k,onFetchWorkflow:_,hideHeader:O=!1,workflowName:M,onWorkflowNameChange:z,onCancel:W,workflowStatus:L,workflowStatusColor:F,saveLabel:$,optionsResolvers:ye})=>{const{fitView:xe=!0,fitViewPadding:Z=.3,showControls:ue=!0,showMiniMap:me=!1,panOnScroll:Ne=!0,zoomOnScroll:Oe=!1,minZoom:bn=.25,maxZoom:yn=2,snapToGrid:xn=!1,snapGrid:mn=[15,15],branchLayout:tt="horizontal",nodeBody:nt="full"}=a,fe=p.useMemo(()=>In.mergeMessages(d),[d]),[R,ee]=p.useState(()=>(n==null?void 0:n.slots)??Ft()),[G,V]=p.useState(()=>(n==null?void 0:n.branches)??{}),[se,U]=p.useState(null),[Ie,rt]=p.useState(null),[K,ve]=p.useState(null),[te,ot]=p.useState(null),[we,it]=p.useState(null),[q,st]=p.useState(()=>{const x=n==null?void 0:n.slots.find(S=>S.kind==="triggerFixed"),v=x!=null&&x.id.startsWith("trigger-")?x.id.slice(8):void 0;return v?t.lookup(v)??null:null}),[lt,vn]=p.useState({}),wn=p.useCallback(x=>{vn(x)},[]),En=p.useMemo(()=>({...re.builtInNodeTypes,...r}),[r]),kn=p.useMemo(()=>({...ci,...o}),[o]),jn=p.useMemo(()=>{const x=R.filter(S=>S.kind==="userTask").length,v=Object.values(G).flatMap(S=>Object.values(S).flat()).filter(S=>S.kind==="userTask").length;return x+v},[R,G]),at=w??(q==null?void 0:q.maxTasks),dt=at!==void 0&&jn>=at,ne=p.useCallback(x=>{const v=R.find(S=>S.id===x);if(v)return v;for(const S of Object.values(G)){const E=Object.values(S).flat().find(N=>N.id===x);if(E)return E}return null},[R,G]),Me=p.useCallback(x=>{s||(rt(x),U("nodeConfig"))},[s]),ct=p.useCallback(x=>{if(!s){if(R.some(v=>v.id===x)){const v=R.find(S=>S.id===x);if((v==null?void 0:v.kind)==="triggerFixed"){ee(Ft()),V({}),st(null);return}ee(S=>{const E=S.filter(N=>N.id!==x);return oe((v==null?void 0:v.kind)??"")&&!E.some(N=>N.kind==="end")?[...E,{id:"end",kind:"end",reactFlowType:"endNode"}]:E}),V(S=>{const E={...S},N=m=>{E[m]&&(Object.values(E[m]).flat().filter(j=>oe(j.kind)).forEach(j=>N(j.id)),delete E[m])};return N(x),E});return}V(v=>{const S=(N,m)=>{const j=[];for(const C of N)oe(C.kind)&&m[C.id]&&(j.push(C.id),Object.values(m[C.id]).forEach(T=>j.push(...S(T,m))));return j},E={...v};for(const N of Object.keys(E))for(const m of Object.keys(E[N])){const j=E[N][m],C=j.findIndex(P=>P.id===x);if(C===-1||j[C].kind==="end")continue;const T=j[C];let B=j.filter(P=>P.id!==x);return T.kind==="filter"&&((T.id in E?S([T],E):[]).forEach(D=>delete E[D]),delete E[T.id],B.some(D=>D.kind==="end")||(B=[...B,{id:`end-${N}-${m}`,kind:"end",reactFlowType:"endNode"}])),E[N]={...E[N],[m]:B},E}return E})}},[s,R]),ze=p.useCallback(()=>{s||U("triggerSelect")},[s]),ut=p.useCallback((x,v)=>{s||dt||(ve(x),ot(v.filterId&&v.branch?{filterId:v.filterId,branch:v.branch}:null),U("nodePicker"))},[s,dt]),ft=p.useCallback((x,v)=>{if(st(x),U(null),x.skeletonState){const E=Array.isArray(v)&&v.length>0,N=(x.skeletonState.slots??[]).map(m=>m.kind!=="triggerFixed"?m:{...m,nodeData:{label:x.label,...m.nodeData??{},...E&&{sources:v}}});V(x.skeletonState.branches??{}),ee(N);return}V({});const S=Array.isArray(v)&&v.length>0;ee([{id:"start",kind:"start",reactFlowType:"startNode"},{id:`trigger-${x.triggerKey}`,kind:"triggerFixed",reactFlowType:"triggerNode",nodeData:{label:x.label,source:x.source,eventType:x.triggerKey,type:x.triggerCategory==="scheduler"?"scheduler":"event",...S&&{sources:v}},deletable:!1},{id:"end",kind:"end",reactFlowType:"endNode"}])},[]),ht=p.useCallback(()=>{var S;const x={insertAfterSlot:null,upstreamSlots:[],downstreamSlots:[],branch:te,template:q};if(!K)return x;if(te){const{filterId:E,branch:N}=te,m=R.findIndex(P=>P.id===E),j=m>=0?R.slice(0,m+1):[],C=((S=G[E])==null?void 0:S[N])??[],T=C.findIndex(P=>P.id===K),B=T>=0?C.slice(0,T+1):[];return x.upstreamSlots=[...j,...B],x.downstreamSlots=T>=0?C.slice(T+1):C,x.insertAfterSlot=B[B.length-1]??null,x}const v=R.findIndex(E=>E.id===K);return x.upstreamSlots=v>=0?R.slice(0,v+1):[],x.downstreamSlots=v>=0?R.slice(v+1):[],x.insertAfterSlot=x.upstreamSlots[x.upstreamSlots.length-1]??null,x},[R,G,K,te,q]),gt=(x,v)=>x.descriptorType===v||x.id===v||x.kind===v,pt=p.useCallback(()=>{const x=e.list(),v=q!=null&&q.availableTasks?x.filter(E=>q.availableTasks.includes(E.type)):x,S=ht();return v.filter(E=>E.maxPerWorkflow!==void 0&&R.filter(m=>m.descriptorType===E.type).length+Object.values(G).flatMap(m=>Object.values(m).flat()).filter(m=>m.descriptorType===E.type).length>=E.maxPerWorkflow?!1:E.canInsert?E.canInsert(S):!(E.insertAfter&&E.insertAfter.length>0&&!S.upstreamSlots.some(m=>E.insertAfter.some(j=>gt(m,j)))||E.insertBefore&&E.insertBefore.length>0&&!S.downstreamSlots.some(m=>E.insertBefore.some(j=>gt(m,j)))))},[e,q,R,G,ht]),bt=p.useCallback(x=>{if(!K)return;const v=`${x.type}-${Date.now()}`,S=x.reactFlowType==="filterNode"||x.reactFlowType==="approvalNode"||x.reactFlowType==="conditionBranchNode",E=x.branchLabels??{pass:"Pass",fail:"Fail"},N={id:v,kind:S?x.reactFlowType==="approvalNode"?"approval":"filter":"userTask",reactFlowType:x.reactFlowType,descriptorType:x.type,formData:{},nodeData:{title:x.label},deletable:!0,branchLabels:E};if(te){const{filterId:m,branch:j}=te;V(C=>{const T=[...C[m][j]];if(S){const Q=T.filter(le=>le.kind!=="end"),wt=Q.findIndex(le=>le.id===K),Cn=wt===-1?Q.length:wt+1;return Q.splice(Cn,0,N),{...C,[m]:{...C[m],[j]:Q},[v]:Object.fromEntries(Object.keys(E).map(le=>[le,[{id:`end-${v}-${le}`,kind:"end",reactFlowType:"endNode"}]]))}}const B=T.findIndex(Q=>Q.id===K),P=T.findIndex(Q=>Q.kind==="end"),D=B===-1?P===-1?T.length:P:B+1;return T.splice(D,0,N),{...C,[m]:{...C[m],[j]:T}}})}else S?(ee(m=>{const j=m.findIndex(T=>T.id===K);return[...m.filter(T=>T.kind!=="end").slice(0,j+1),N]}),V(m=>({...m,[v]:Object.fromEntries(Object.keys(E).map(j=>[j,[{id:`end-${v}-${j}`,kind:"end",reactFlowType:"endNode"}]]))}))):ee(m=>{const j=m.findIndex(C=>C.id===K);return j===-1?m:[...m.slice(0,j+1),N,...m.slice(j+1)]});ve(null),ot(null),rt(v),U("nodeConfig")},[K,te]),yt=p.useCallback((x,v)=>{const S=m=>{const j=m.label||m.key;switch(m.kind){case"if":return`IF · ${j}`;case"elseif":return`ELSE IF · ${j}`;case"else":return j.toUpperCase()==="ELSE"?j:`ELSE · ${j}`;default:return j}},E=m=>{const j=ne(x);if((j==null?void 0:j.descriptorType)!=="conditionBranch")return m;const T=(v.branchConfigs??[]).map(D=>D.key).filter(Boolean);if(T.length===0)return m;const B=m[x]??{},P={};return T.forEach(D=>{P[D]=B[D]??[{id:`end-${x}-${D}`,kind:"end",reactFlowType:"endNode"}]}),{...m,[x]:P}},N=(m,j)=>{if(m.descriptorType!=="conditionBranch")return{...m,formData:j};const C=j.branchConfigs??[],T={};return C.forEach(B=>{B.key&&(T[B.key]=S(B))}),{...m,formData:j,branchLabels:T}};if(R.some(m=>m.id===x)){V(m=>{const j=E(m);return ee(C=>C.map(T=>T.id===x?N(T,v):T)),j});return}V(m=>{const C={...E(m)};for(const T of Object.keys(C)){const B=P=>P.map(D=>D.id===x?N(D,v):D);for(const P of Object.keys(C[T]))if(C[T][P].some(D=>D.id===x))return C[T]={...C[T],[P]:B(C[T][P])},C}return C})},[R,G,ne]),J=p.useMemo(()=>ne(Ie??""),[ne,Ie]),xt=p.useMemo(()=>J!=null&&J.descriptorType?e.forType(J.descriptorType)??null:null,[J,e]),{nodes:mt,edges:Sn}=p.useMemo(()=>gi(R,G,s?null:ut,lt,l,y,tt),[R,G,s,ut,lt,l,y,tt]),vt=p.useMemo(()=>{const x=k?new Map(k.steps.map(v=>[v.nodeId,v])):null;return mt.map(v=>{let S={};if(x){const E=x.get(v.id);E&&(S={_executionStatus:E.status,_executionError:E.error})}return v.type==="subWorkflowNode"&&_&&(S.onPreview=E=>{var m;const N=ne(v.id);it({workflowId:E,workflowLabel:((m=N==null?void 0:N.formData)==null?void 0:m.workflowLabel)??void 0})}),Object.keys(S).length>0?{...v,data:{...v.data,...S}}:v})},[mt,k,_,ne]),_n=p.useMemo(()=>({onEditNode:Me,onDeleteNode:ct,onAddStep:()=>{},onClickAddTrigger:ze,messages:fe,nodeRegistry:e,nodeBody:nt}),[Me,ct,ze,fe,e,nt]),Tn=p.useCallback(async()=>{i&&await i({slots:R,branches:G})},[i,R,G]);return c.jsx(Xe.OptionsResolversProvider,{resolvers:ye,children:c.jsx(re.WorkflowCanvasContext.Provider,{value:_n,children:c.jsxs("div",{className:"flowforge-canvas",style:{width:"100%",height:"100%",position:"relative",display:"flex",flexDirection:"column","--ff-primary":l.primaryColor??"#1dbf60","--ff-edge-color":l.edgeColor??"#b0bec5","--ff-text":l.textColor??"#212121","--ff-muted":l.mutedTextColor??"#9ca3af","--ff-surface":l.surfaceColor??"#fff","--ff-border":l.borderColor??"#dee2e6","--ff-danger":l.dangerColor??"#d32f2f","--ff-radius":`${l.borderRadius??6}px`,"--ff-font-family":l.fontFamily},children:[!O&&(i||W||M)&&c.jsx(hn,{workflowName:M,onWorkflowNameChange:z,status:L,statusColor:F,onSave:i?Tn:void 0,onCancel:W,saveLabel:$}),c.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[c.jsxs(ae,{nodes:vt,edges:Sn,nodeTypes:En,edgeTypes:kn,fitView:xe,fitViewOptions:{padding:Z},nodesDraggable:!1,nodesConnectable:!1,panOnScroll:Ne,zoomOnScroll:Oe,minZoom:bn,maxZoom:yn,snapToGrid:xn,snapGrid:mn,proOptions:{hideAttribution:!0},onNodeClick:(x,v)=>{const S=ne(v.id);S&&(b!=null&&b(S)||(S.kind==="addTrigger"||S.kind==="triggerFixed"?ze():(S.kind==="userTask"||S.kind==="filter"||S.kind==="approval")&&Me(v.id)))},children:[l.background!=="none"&&c.jsx(ae.Background,{variant:l.background,color:l.backgroundColor??"#e0e0e0",gap:20}),ue&&c.jsx(ae.Controls,{showInteractive:!1}),me&&c.jsx(ae.MiniMap,{zoomable:!0,pannable:!0}),c.jsx(oi,{onHeightsReady:wn,nodeCount:vt.length})]}),u?se==="triggerSelect"&&u(t.list(),ft,()=>U(null)):c.jsx(si,{open:se==="triggerSelect",templates:t.list(),messages:fe,onSelect:ft,onClose:()=>U(null),loadTriggerSources:f}),h?se==="nodePicker"&&h(pt(),bt,()=>{U(null),ve(null)}):c.jsx(li,{open:se==="nodePicker",availableDescriptors:pt(),messages:fe,onSelect:bt,onClose:()=>{U(null),ve(null)}}),g?se==="nodeConfig"&&g(xt??void 0,J,yt,()=>U(null)):c.jsx(ai,{open:se==="nodeConfig",nodeId:Ie,descriptor:xt,initialValues:J==null?void 0:J.formData,messages:fe,onSave:yt,onClose:()=>U(null)}),_&&we&&c.jsx(gn,{isOpen:!!we,onClose:()=>it(null),workflowId:we.workflowId,workflowLabel:we.workflowLabel,onFetchWorkflow:_})]})]})})})},pi=Object.freeze(Object.defineProperty({__proto__:null,WorkflowCanvas:qe,default:qe},Symbol.toStringTag,{value:"Module"})),$e="All";function bi({template:e,onSelect:t}){var o,i;const n=e.triggerCategory?H.TRIGGER_CATEGORY_STYLE[e.triggerCategory]:null,r=((o=e.skeletonState)==null?void 0:o.slots.filter(s=>s.kind==="userTask").length)??0;return c.jsxs("div",{role:"button",tabIndex:0,onClick:t,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&t()},style:{border:"1.5px solid #e0e0e0",borderRadius:10,padding:"16px",background:"#fff",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s",display:"flex",flexDirection:"column",gap:8,outline:"none"},onMouseEnter:s=>{s.currentTarget.style.borderColor="#1976d2",s.currentTarget.style.boxShadow="0 2px 8px rgba(25,118,210,0.12)"},onMouseLeave:s=>{s.currentTarget.style.borderColor="#e0e0e0",s.currentTarget.style.boxShadow="none"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[e.icon&&c.jsx("div",{style:{flexShrink:0,width:36,height:36,borderRadius:8,background:"#f5f5f5",display:"flex",alignItems:"center",justifyContent:"center"},children:e.icon}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontWeight:600,fontSize:14,color:"#212121",marginBottom:2},children:e.label}),e.description&&c.jsx("div",{style:{fontSize:12,color:"#757575",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.description})]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:4},children:[n&&c.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:n.bg,color:n.color},children:n.label}),(i=e.tags)==null?void 0:i.map(s=>c.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:10,background:"#f5f5f5",color:"#616161"},children:s},s)),r>0&&c.jsxs("span",{style:{fontSize:10,color:"#9e9e9e",marginLeft:"auto"},children:[r," step",r!==1?"s":""]})]}),e.author&&c.jsxs("div",{style:{fontSize:11,color:"#bdbdbd"},children:["by ",e.author]})]})}const yi=({templates:e,onSelectTemplate:t,onStartFromScratch:n})=>{const[r,o]=p.useState(""),[i,s]=p.useState($e),l=p.useMemo(()=>{const a=new Set;return e.forEach(u=>{u.category&&a.add(u.category)}),[$e,...Array.from(a)]},[e]),d=p.useMemo(()=>{let a=e;if(i!==$e&&(a=a.filter(u=>u.category===i)),r.trim()){const u=r.toLowerCase();a=a.filter(f=>{var h,g;return f.label.toLowerCase().includes(u)||((h=f.description)==null?void 0:h.toLowerCase().includes(u))||((g=f.tags)==null?void 0:g.some(b=>b.toLowerCase().includes(u)))})}return[...a].sort((u,f)=>(f.popularity??0)-(u.popularity??0))},[e,i,r]);return c.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"inherit"},children:[c.jsxs("div",{style:{padding:"24px 24px 0",borderBottom:"1px solid #f0f0f0",paddingBottom:16},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[c.jsxs("div",{children:[c.jsx("h2",{style:{margin:0,fontSize:20,fontWeight:700,color:"#212121"},children:"Workflow Templates"}),c.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#757575"},children:"Choose a pre-built template or start from scratch"})]}),n&&c.jsxs("button",{onClick:n,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 16px",border:"1.5px solid #1976d2",borderRadius:6,background:"#fff",color:"#1976d2",fontSize:13,fontWeight:600,cursor:"pointer"},children:[c.jsx(I.MdAdd,{size:16}),"Start from Scratch"]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"#f5f5f5",borderRadius:8,padding:"8px 12px",marginBottom:12},children:[c.jsx(I.MdSearch,{size:18,color:"#9e9e9e"}),c.jsx("input",{value:r,onChange:a=>o(a.target.value),placeholder:"Search templates...",style:{border:"none",background:"transparent",outline:"none",fontSize:14,color:"#212121",flex:1}})]}),l.length>1&&c.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:l.map(a=>c.jsx("button",{onClick:()=>s(a),style:{padding:"4px 12px",borderRadius:20,border:"1.5px solid",borderColor:i===a?"#1976d2":"#e0e0e0",background:i===a?"#e3f2fd":"#fff",color:i===a?"#1565c0":"#616161",fontSize:12,fontWeight:i===a?600:400,cursor:"pointer"},children:a},a))})]}),c.jsx("div",{style:{flex:1,overflowY:"auto",padding:24},children:d.length===0?c.jsxs("div",{style:{textAlign:"center",padding:"40px 0",color:"#9e9e9e"},children:[c.jsx(I.MdCategory,{size:36,style:{marginBottom:8}}),c.jsx("p",{style:{margin:0,fontSize:14},children:"No templates found"})]}):c.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:16},children:d.map(a=>c.jsx(bi,{template:a,onSelect:()=>t(a)},a.triggerKey))})})]})},Ee={running:{label:"Running",color:H.EXECUTION_STATUS_COLOR.running,icon:p.createElement(I.MdPlayArrow,{size:14})},success:{label:"Success",color:H.EXECUTION_STATUS_COLOR.success,icon:p.createElement(I.MdCheckCircle,{size:14})},failed:{label:"Failed",color:H.EXECUTION_STATUS_COLOR.failed,icon:p.createElement(I.MdError,{size:14})},cancelled:{label:"Cancelled",color:H.EXECUTION_STATUS_COLOR.cancelled,icon:p.createElement(I.MdCancel,{size:14})}},xi={pending:{color:H.EXECUTION_STATUS_COLOR.pending,icon:p.createElement(I.MdHourglassEmpty,{size:14})},running:{color:H.EXECUTION_STATUS_COLOR.running,icon:p.createElement(I.MdPlayArrow,{size:14})},success:{color:H.EXECUTION_STATUS_COLOR.success,icon:p.createElement(I.MdCheckCircle,{size:14})},failed:{color:H.EXECUTION_STATUS_COLOR.failed,icon:p.createElement(I.MdError,{size:14})},skipped:{color:H.EXECUTION_STATUS_COLOR.skipped,icon:p.createElement(I.MdCancel,{size:14})}};function He(e){try{return new Date(e).toLocaleString()}catch{return e}}function pn(e,t){try{const n=new Date(t??new Date().toISOString()).getTime()-new Date(e).getTime();return n<1e3?`${n}ms`:n<6e4?`${(n/1e3).toFixed(1)}s`:`${Math.floor(n/6e4)}m ${Math.floor(n%6e4/1e3)}s`}catch{return"—"}}function mi({step:e}){const[t,n]=p.useState(!1),r=xi[e.status],o=!!(e.inputs||e.outputs||e.error);return c.jsxs("div",{style:{borderBottom:"1px solid #f5f5f5"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",cursor:o?"pointer":"default"},onClick:()=>{o&&n(i=>!i)},role:o?"button":void 0,tabIndex:o?0:void 0,onKeyDown:i=>{o&&(i.key==="Enter"||i.key===" ")&&n(s=>!s)},children:[c.jsx("span",{style:{color:r.color,flexShrink:0},children:p.cloneElement(r.icon,{color:r.color})}),c.jsx("span",{style:{flex:1,fontSize:13,color:"#212121"},children:e.label||e.nodeId}),e.branchTaken&&c.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"#e3f2fd",color:"#1565c0",fontWeight:600},children:e.branchTaken}),c.jsx("span",{style:{fontSize:11,color:"#9e9e9e",flexShrink:0},children:e.startedAt?pn(e.startedAt,e.completedAt):"—"}),o&&c.jsx("span",{style:{color:"#9e9e9e",flexShrink:0},children:t?p.createElement(I.MdExpandLess,{size:16}):p.createElement(I.MdExpandMore,{size:16})})]}),t&&o&&c.jsxs("div",{style:{padding:"0 12px 10px 32px",fontSize:12},children:[e.error&&c.jsx("div",{style:{padding:"6px 10px",borderRadius:6,background:"#ffebee",color:"#c62828",marginBottom:6},children:e.error}),e.inputs&&Object.keys(e.inputs).length>0&&c.jsxs("details",{style:{marginBottom:4},children:[c.jsx("summary",{style:{cursor:"pointer",color:"#616161",marginBottom:4},children:"Inputs"}),c.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:8,borderRadius:4,overflowX:"auto"},children:JSON.stringify(e.inputs,null,2)})]}),e.outputs&&Object.keys(e.outputs).length>0&&c.jsxs("details",{children:[c.jsx("summary",{style:{cursor:"pointer",color:"#616161",marginBottom:4},children:"Outputs"}),c.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:8,borderRadius:4,overflowX:"auto"},children:JSON.stringify(e.outputs,null,2)})]})]})]})}function vi({record:e,selected:t,onSelect:n}){const r=Ee[e.status];return c.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&n()},style:{padding:"10px 14px",borderBottom:"1px solid #f0f0f0",cursor:"pointer",background:t?"#e3f2fd":"#fff",display:"flex",alignItems:"center",gap:10,outline:"none"},children:[c.jsx("span",{style:{color:r.color,flexShrink:0},children:p.cloneElement(r.icon,{color:r.color,size:16})}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontSize:12,color:"#212121",fontWeight:t?600:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:He(e.triggeredAt)}),c.jsxs("div",{style:{fontSize:11,color:"#9e9e9e"},children:[e.triggeredBy?`by ${e.triggeredBy}`:"System"," · ",e.steps.length," step",e.steps.length!==1?"s":""]})]}),c.jsx("span",{style:{fontSize:11,fontWeight:600,color:r.color,flexShrink:0},children:r.label}),c.jsx(I.MdChevronRight,{size:14,color:"#bdbdbd"})]})}const wi=({records:e,onViewOnCanvas:t})=>{var s;const[n,r]=p.useState(((s=e[0])==null?void 0:s.id)??null),o=e.find(l=>l.id===n)??null,i=[...e].sort((l,d)=>new Date(d.triggeredAt).getTime()-new Date(l.triggeredAt).getTime());return e.length===0?c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:300,color:"#9e9e9e",gap:8},children:[c.jsx(I.MdSchedule,{size:36}),c.jsx("p",{style:{margin:0,fontSize:14},children:"No executions yet"}),c.jsx("p",{style:{margin:0,fontSize:12},children:"Run history will appear here"})]}):c.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:"inherit",border:"1px solid #e0e0e0",borderRadius:8,overflow:"hidden"},children:[c.jsxs("div",{style:{width:260,flexShrink:0,borderRight:"1px solid #e0e0e0",overflowY:"auto",background:"#fafafa"},children:[c.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #e0e0e0",fontWeight:600,fontSize:13,color:"#212121"},children:["Run History (",e.length,")"]}),i.map(l=>c.jsx(vi,{record:l,selected:l.id===n,onSelect:()=>r(l.id)},l.id))]}),c.jsx("div",{style:{flex:1,overflowY:"auto"},children:o?c.jsxs("div",{children:[c.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #f0f0f0",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[c.jsxs("div",{children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[p.cloneElement(Ee[o.status].icon,{color:Ee[o.status].color,size:18}),c.jsx("span",{style:{fontWeight:700,fontSize:15,color:"#212121"},children:Ee[o.status].label})]}),c.jsxs("div",{style:{fontSize:12,color:"#757575",display:"flex",flexDirection:"column",gap:2},children:[c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[c.jsx(I.MdSchedule,{size:13})," ",He(o.triggeredAt),o.completedAt&&` → ${He(o.completedAt)} (${pn(o.triggeredAt,o.completedAt)})`]}),o.triggeredBy&&c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[c.jsx(I.MdPerson,{size:13})," ",o.triggeredBy]})]})]}),t&&c.jsx("button",{onClick:()=>t(o),style:{padding:"6px 12px",border:"1.5px solid #1976d2",borderRadius:6,background:"#fff",color:"#1976d2",fontSize:12,fontWeight:600,cursor:"pointer",flexShrink:0},children:"View on Canvas"})]}),o.error&&c.jsx("div",{style:{margin:"12px 16px",padding:"10px 14px",borderRadius:6,background:"#ffebee",color:"#c62828",fontSize:13},children:o.error}),c.jsxs("div",{children:[c.jsxs("div",{style:{padding:"10px 12px",fontSize:12,fontWeight:600,color:"#757575",borderBottom:"1px solid #f0f0f0"},children:["STEPS (",o.steps.length,")"]}),o.steps.map((l,d)=>c.jsx(mi,{step:l},`${l.nodeId}-${d}`))]}),o.inputs&&Object.keys(o.inputs).length>0&&c.jsx("div",{style:{padding:"10px 16px"},children:c.jsxs("details",{children:[c.jsx("summary",{style:{cursor:"pointer",fontSize:12,fontWeight:600,color:"#757575",marginBottom:6},children:"TRIGGER INPUTS"}),c.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:10,borderRadius:4,overflowX:"auto"},children:JSON.stringify(o.inputs,null,2)})]})})]}):c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9e9e9e",fontSize:14},children:"Select a run to see details"})})]})};exports.FlowForgeCanvas=qe;exports.FlowForgeHeader=hn;exports.SubWorkflowPreviewDrawer=gn;exports.WorkflowExecutionHistory=wi;exports.WorkflowTemplateLibrary=yi;
2
- //# sourceMappingURL=WorkflowExecutionHistory-DeakdR2x.js.map
1
+ "use strict";const c=require("react/jsx-runtime"),p=require("react"),ae=require("reactflow");require("reactflow/dist/style.css");const re=require("./GatewayBranchEdge-6rCziASt.js"),A=require("@mui/material"),Nn=require("react-select"),I=require("react-icons/md"),On=require("react-icons/gr"),Et=require("react-icons/bi"),Xe=require("./index-BypSWEYO.js"),In=require("./messages-Bg7b9RbI.js"),H=require("./canvasTokens-gKNYrPl4.js");var Dt=Object.defineProperty,Mn=(e,t,n)=>t in e?Dt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zn=(e,t)=>{for(var n in t)Dt(e,n,{get:t[n],enumerable:!0})},Ln=(e,t,n)=>Mn(e,t+"",n),Wt={};zn(Wt,{Graph:()=>Y,alg:()=>Ve,json:()=>Gt,version:()=>Bn});var Rn=Object.defineProperty,$t=(e,t)=>{for(var n in t)Rn(e,n,{get:t[n],enumerable:!0})},Y=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected="directed"in e?e.directed:!0,this._isMultigraph="multigraph"in e?e.multigraph:!1,this._isCompound="compound"in e?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children["\0"]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return typeof e!="function"?this._defaultNodeLabelFn=()=>e:this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(n=>{t!==void 0?this.setNode(n,t):this.setNode(n)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return e in this._nodes}removeNode(e){if(e in this._nodes){let t=n=>this.removeEdge(this._edgeObjs[n]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(n=>{this.setParent(n)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(t===void 0)t="\0";else{t+="";for(let n=t;n!==void 0;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}parent(e){if(this._isCompound){let t=this._parent[e];if(t!=="\0")return t}}children(e="\0"){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e==="\0")return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t);for(let r of this.successors(e))n.add(r);return Array.from(n.values())}}isLeaf(e){let t;return this.isDirected()?t=this.successors(e):t=this.neighbors(e),t.length===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([o,i])=>{e(o)&&t.setNode(o,i)}),Object.values(this._edgeObjs).forEach(o=>{t.hasNode(o.v)&&t.hasNode(o.w)&&t.setEdge(o,this.edge(o))});let n={},r=o=>{let i=this.parent(o);return!i||t.hasNode(i)?(n[o]=i??void 0,i??void 0):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(o=>t.setParent(o,r(o))),t}setDefaultEdgeLabel(e){return typeof e!="function"?this._defaultEdgeLabelFn=()=>e:this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((n,r)=>(t!==void 0?this.setEdge(n,r,t):this.setEdge(n,r),r)),this}setEdge(e,t,n,r){let o,i,s,l,d=!1;typeof e=="object"&&e!==null&&"v"in e?(o=e.v,i=e.w,s=e.name,arguments.length===2&&(l=t,d=!0)):(o=e,i=t,s=r,arguments.length>2&&(l=n,d=!0)),o=""+o,i=""+i,s!==void 0&&(s=""+s);let a=he(this._isDirected,o,i,s);if(a in this._edgeLabels)return d&&(this._edgeLabels[a]=l),this;if(s!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(o),this.setNode(i),this._edgeLabels[a]=d?l:this._defaultEdgeLabelFn(o,i,s);let u=Pn(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[a]=u,kt(this._preds[i],o),kt(this._sucs[o],i),this._in[i][a]=u,this._out[o][a]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Le(this._isDirected,e):he(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!="object"?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Le(this._isDirected,e):he(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Le(this._isDirected,e):he(this._isDirected,e,t,n),o=this._edgeObjs[r];if(o){let i=o.v,s=o.w;delete this._edgeLabels[r],delete this._edgeObjs[r],jt(this._preds[s],i),jt(this._sucs[i],s),delete this._in[s][r],delete this._out[i][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(o=>o.v===t&&o.w===n||o.v===n&&o.w===t):r}};function kt(e,t){e[t]?e[t]++:e[t]=1}function jt(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function he(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let s=o;o=i,i=s}return o+""+i+""+(r===void 0?"\0":r)}function Pn(e,t,n,r){let o=""+t,i=""+n;if(!e&&o>i){let l=o;o=i,i=l}let s={v:o,w:i};return r&&(s.name=r),s}function Le(e,t){return he(e,t.v,t.w,t.name)}var Bn="4.0.1",Gt={};$t(Gt,{read:()=>Wn,write:()=>Fn});function Fn(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:An(e),edges:Dn(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function An(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),o={v:t};return n!==void 0&&(o.value=n),r!==void 0&&(o.parent=r),o})}function Dn(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Wn(e){let t=new Y(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(n=>{t.setNode(n.v,n.value),n.parent&&t.setParent(n.v,n.parent)}),e.edges.forEach(n=>{t.setEdge({v:n.v,w:n.w,name:n.name},n.value)}),t}var Ve={};$t(Ve,{CycleException:()=>je,bellmanFord:()=>Yt,components:()=>Yn,dijkstra:()=>ke,dijkstraAll:()=>qn,findCycles:()=>Hn,floydWarshall:()=>Vn,isAcyclic:()=>Zn,postorder:()=>er,preorder:()=>tr,prim:()=>nr,shortestPaths:()=>rr,tarjan:()=>Kt,topsort:()=>qt});var $n=()=>1;function Yt(e,t,n,r){return Gn(e,String(t),n||$n,r||function(o){return e.outEdges(o)})}function Gn(e,t,n,r){let o={},i,s=0,l=e.nodes(),d=function(f){let h=n(f);o[f.v].distance+h<o[f.w].distance&&(o[f.w]={distance:o[f.v].distance+h,predecessor:f.v},i=!0)},a=function(){l.forEach(function(f){r(f).forEach(function(h){let g=h.v===f?h.v:h.w,b=g===h.v?h.w:h.v;d({v:g,w:b})})})};l.forEach(function(f){let h=f===t?0:Number.POSITIVE_INFINITY;o[f]={distance:h,predecessor:""}});let u=l.length;for(let f=1;f<u&&(i=!1,s++,a(),!!i);f++);if(s===u-1&&(i=!1,a(),i))throw new Error("The graph contains a negative weight cycle");return o}function Yn(e){let t={},n=[],r;function o(i){i in t||(t[i]=!0,r.push(i),e.successors(i).forEach(o),e.predecessors(i).forEach(o))}return e.nodes().forEach(function(i){r=[],o(i),r.length&&n.push(r)}),n}var Ut=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let o=this._arr,i=o.length;return n[r]=i,o.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw new Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw new Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,o=n[e],i=n[t];n[e]=i,n[t]=o,r[i.key]=e,r[o.key]=t}},Un=()=>1;function ke(e,t,n,r){let o=function(i){return e.outEdges(i)};return Kn(e,String(t),n||Un,r||o)}function Kn(e,t,n,r){let o={},i=new Ut,s,l,d=function(a){let u=a.v!==s?a.v:a.w,f=o[u],h=n(a),g=l.distance+h;if(h<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+a+" Weight: "+h);g<f.distance&&(f.distance=g,f.predecessor=s,i.decrease(u,g))};for(e.nodes().forEach(function(a){let u=a===t?0:Number.POSITIVE_INFINITY;o[a]={distance:u,predecessor:""},i.add(a,u)});i.size()>0&&(s=i.removeMin(),l=o[s],l.distance!==Number.POSITIVE_INFINITY);)r(s).forEach(d);return o}function qn(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=ke(e,o,t,n),r},{})}function Kt(e){let t=0,n=[],r={},o=[];function i(s){let l=r[s]={onStack:!0,lowlink:t,index:t++};if(n.push(s),e.successors(s).forEach(function(d){d in r?r[d].onStack&&(l.lowlink=Math.min(l.lowlink,r[d].index)):(i(d),l.lowlink=Math.min(l.lowlink,r[d].lowlink))}),l.lowlink===l.index){let d=[],a;do a=n.pop(),r[a].onStack=!1,d.push(a);while(s!==a);o.push(d)}}return e.nodes().forEach(function(s){s in r||i(s)}),o}function Hn(e){return Kt(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Xn=()=>1;function Vn(e,t,n){return Jn(e,t||Xn,n||function(r){return e.outEdges(r)})}function Jn(e,t,n){let r={},o=e.nodes();return o.forEach(function(i){r[i]={},r[i][i]={distance:0,predecessor:""},o.forEach(function(s){i!==s&&(r[i][s]={distance:Number.POSITIVE_INFINITY,predecessor:""})}),n(i).forEach(function(s){let l=s.v===i?s.w:s.v,d=t(s);r[i][l]={distance:d,predecessor:i}})}),o.forEach(function(i){let s=r[i];o.forEach(function(l){let d=r[l];o.forEach(function(a){let u=d[i],f=s[a],h=d[a],g=u.distance+f.distance;g<h.distance&&(h.distance=g,h.predecessor=f.predecessor)})})}),r}var je=class extends Error{constructor(...e){super(...e)}};function qt(e){let t={},n={},r=[];function o(i){if(i in n)throw new je;i in t||(n[i]=!0,t[i]=!0,e.predecessors(i).forEach(o),delete n[i],r.push(i))}if(e.sinks().forEach(o),Object.keys(t).length!==e.nodeCount())throw new je;return r}function Zn(e){try{qt(e)}catch(t){if(t instanceof je)return!1;throw t}return!0}function Qn(e,t,n,r,o){Array.isArray(t)||(t=[t]);let i=l=>{var d;return(d=e.isDirected()?e.successors(l):e.neighbors(l))!=null?d:[]},s={};return t.forEach(function(l){if(!e.hasNode(l))throw new Error("Graph does not have node: "+l);o=Ht(e,l,n==="post",s,i,r,o)}),o}function Ht(e,t,n,r,o,i,s){return t in r||(r[t]=!0,n||(s=i(s,t)),o(t).forEach(function(l){s=Ht(e,l,n,r,o,i,s)}),n&&(s=i(s,t))),s}function Xt(e,t,n){return Qn(e,t,n,function(r,o){return r.push(o),r},[])}function er(e,t){return Xt(e,t,"post")}function tr(e,t){return Xt(e,t,"pre")}function nr(e,t){let n=new Y,r={},o=new Ut,i;function s(d){let a=d.v===i?d.w:d.v,u=o.priority(a);if(u!==void 0){let f=t(d);f<u&&(r[a]=i,o.decrease(a,f))}}if(e.nodeCount()===0)return n;e.nodes().forEach(function(d){o.add(d,Number.POSITIVE_INFINITY),n.setNode(d)}),o.decrease(e.nodes()[0],0);let l=!1;for(;o.size()>0;){if(i=o.removeMin(),i in r)n.setEdge(i,r[i]);else{if(l)throw new Error("Input graph is not connected: "+e);l=!0}e.nodeEdges(i).forEach(s)}return n}function rr(e,t,n,r){return or(e,t,n,r??(o=>{let i=e.outEdges(o);return i??[]}))}function or(e,t,n,r){if(n===void 0)return ke(e,t,n,r);let o=!1,i=e.nodes();for(let s=0;s<i.length;s++){let l=r(i[s]);for(let d=0;d<l.length;d++){let a=l[d],u=a.v===i[s]?a.v:a.w,f=u===a.v?a.w:a.v;n({v:u,w:f})<0&&(o=!0)}if(o)return Yt(e,t,n,r)}return ke(e,t,n,r)}function ce(e,t,n,r){let o=r;for(;e.hasNode(o);)o=Je(r);return n.dummy=t,e.setNode(o,n),o}function ir(e){let t=new Y().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},o=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})}),t}function Vt(e){let t=new Y({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function St(e,t){let n=e.x,r=e.y,o=t.x-n,i=t.y-r,s=e.width/2,l=e.height/2;if(!o&&!i)throw new Error("Not possible to find intersection inside of the rectangle");let d,a;return Math.abs(i)*s>Math.abs(o)*l?(i<0&&(l=-l),d=l*o/i,a=l):(o<0&&(s=-s),d=s,a=s*i/o),{x:n+d,y:r+a}}function be(e){let t=ge(Zt(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),o=r.rank;o!==void 0&&(t[o]||(t[o]=[]),t[o][r.order]=n)}),t}function sr(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=X(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function lr(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=X(Math.min,t),r=[];e.nodes().forEach(s=>{let l=e.node(s).rank-n;r[l]||(r[l]=[]),r[l].push(s)});let o=0,i=e.graph().nodeRankFactor;Array.from(r).forEach((s,l)=>{s===void 0&&l%i!==0?--o:s!==void 0&&o&&s.forEach(d=>e.node(d).rank+=o)})}function _t(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),ce(e,"border",o,t)}function ar(e,t=Jt){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var Jt=65535;function X(e,t){if(t.length>Jt){let n=ar(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function Zt(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return X(Math.max,t)}function dr(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function Qt(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function en(e,t){return t()}var cr=0;function Je(e){let t=++cr;return e+(""+t)}function ge(e,t,n=1){t==null&&(t=e,e=0);let r=i=>i<t;n<0&&(r=i=>t<i);let o=[];for(let i=e;r(i);i+=n)o.push(i);return o}function Se(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function _e(e,t){let n;return typeof t=="string"?n=r=>r[t]:n=t,Object.entries(e).reduce((r,[o,i])=>(r[o]=n(i,o),r),{})}function ur(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Te="\0",fr="3.0.0",hr=class{constructor(){Ln(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Tt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Tt(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,gr)),n=n._prev;return"["+e.join(", ")+"]"}};function Tt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function gr(e,t){if(e!=="_next"&&e!=="_prev")return t}var pr=hr,br=()=>1;function yr(e,t){if(e.nodeCount()<=1)return[];let n=mr(e,t||br);return xr(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function xr(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],l;for(;e.nodeCount();){for(;l=s.dequeue();)Re(e,t,n,l);for(;l=i.dequeue();)Re(e,t,n,l);if(e.nodeCount()){for(let d=t.length-2;d>0;--d)if(l=(r=t[d])==null?void 0:r.dequeue(),l){o=o.concat(Re(e,t,n,l,!0)||[]);break}}}return o}function Re(e,t,n,r,o){let i=[],s=o?i:void 0;return(e.inEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),a=e.node(l.v);o&&i.push({v:l.v,w:l.w}),a.out-=d,Ge(t,n,a)}),(e.outEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),a=l.w,u=e.node(a);u.in-=d,Ge(t,n,u)}),e.removeNode(r.v),s}function mr(e,t){let n=new Y,r=0,o=0;e.nodes().forEach(l=>{n.setNode(l,{v:l,in:0,out:0})}),e.edges().forEach(l=>{let d=n.edge(l.v,l.w)||0,a=t(l),u=d+a;n.setEdge(l.v,l.w,u);let f=n.node(l.v),h=n.node(l.w);o=Math.max(o,f.out+=a),r=Math.max(r,h.in+=a)});let i=vr(o+r+3).map(()=>new pr),s=r+1;return n.nodes().forEach(l=>{Ge(i,s,n.node(l))}),{graph:n,buckets:i,zeroIdx:s}}function Ge(e,t,n){var r,o,i;n.out?n.in?(i=e[n.out-n.in+t])==null||i.enqueue(n):(o=e[e.length-1])==null||o.enqueue(n):(r=e[0])==null||r.enqueue(n)}function vr(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function wr(e){(e.graph().acyclicer==="greedy"?yr(e,t(e)):Er(e)).forEach(n=>{let r=e.edge(n);e.removeEdge(n),r.forwardName=n.name,r.reversed=!0,e.setEdge(n.w,n.v,r,Je("rev"))});function t(n){return r=>n.edge(r).weight}}function Er(e){let t=[],n={},r={};function o(i){Object.hasOwn(r,i)||(r[i]=!0,n[i]=!0,e.outEdges(i).forEach(s=>{Object.hasOwn(n,s.w)?t.push(s):o(s.w)}),delete n[i])}return e.nodes().forEach(o),t}function kr(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function jr(e){e.graph().dummyChains=[],e.edges().forEach(t=>Sr(e,t))}function Sr(e,t){let n=t.v,r=e.node(n).rank,o=t.w,i=e.node(o).rank,s=t.name,l=e.edge(t),d=l.labelRank;if(i===r+1)return;e.removeEdge(t);let a,u,f;for(f=0,++r;r<i;++f,++r)l.points=[],u={width:0,height:0,edgeLabel:l,edgeObj:t,rank:r},a=ce(e,"edge",u,"_d"),r===d&&(u.width=l.width,u.height=l.height,u.dummy="edge-label",u.labelpos=l.labelpos),e.setEdge(n,a,{weight:l.weight},s),f===0&&e.graph().dummyChains.push(a),n=a;e.setEdge(n,o,{weight:l.weight},s)}function _r(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,o;for(e.setEdge(n.edgeObj,r);n.dummy;)o=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=o,n=e.node(t)})}function Ze(e){let t={};function n(r){let o=e.node(r);if(Object.hasOwn(t,r))return o.rank;t[r]=!0;let i=e.outEdges(r),s=i?i.map(d=>d==null?Number.POSITIVE_INFINITY:n(d.w)-e.edge(d).minlen):[],l=X(Math.min,s);return l===Number.POSITIVE_INFINITY&&(l=0),o.rank=l}e.sources().forEach(n)}function de(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var tn=Tr;function Tr(e){let t=new Y({directed:!1}),n=e.nodes();if(n.length===0)throw new Error("Graph must have at least one node");let r=n[0],o=e.nodeCount();t.setNode(r,{});let i,s;for(;Cr(t,e)<o&&(i=Nr(t,e),!!i);)s=t.hasNode(i.v)?de(e,i):-de(e,i),Or(t,e,s);return t}function Cr(e,t){function n(r){let o=t.nodeEdges(r);o&&o.forEach(i=>{let s=i.v,l=r===s?i.w:s;!e.hasNode(l)&&!de(t,i)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function Nr(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=de(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function Or(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Ir,postorder:Mr}=Ve,zr=ie;ie.initLowLimValues=et;ie.initCutValues=Qe;ie.calcCutValue=nn;ie.leaveEdge=on;ie.enterEdge=sn;ie.exchangeEdges=ln;function ie(e){e=ir(e),Ze(e);let t=tn(e);et(t),Qe(t,e);let n,r;for(;n=on(t);)r=sn(t,e,n),ln(t,e,n,r)}function Qe(e,t){let n=Mr(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>Lr(e,t,r))}function Lr(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=nn(e,t,n)}function nn(e,t,n){let r=e.node(n).parent,o=!0,i=t.edge(n,r),s=0;i||(o=!1,i=t.edge(r,n)),s=i.weight;let l=t.nodeEdges(n);return l&&l.forEach(d=>{let a=d.v===n,u=a?d.w:d.v;if(u!==r){let f=a===o,h=t.edge(d).weight;if(s+=f?h:-h,Pr(e,n,u)){let g=e.edge(n,u).cutvalue;s+=f?-g:g}}}),s}function et(e,t){arguments.length<2&&(t=e.nodes()[0]),rn(e,{},1,t)}function rn(e,t,n,r,o){let i=n,s=e.node(r);t[r]=!0;let l=e.neighbors(r);return l&&l.forEach(d=>{Object.hasOwn(t,d)||(n=rn(e,t,n,d,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function on(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function sn(e,t,n){let r=n.v,o=n.w;t.hasEdge(r,o)||(r=n.w,o=n.v);let i=e.node(r),s=e.node(o),l=i,d=!1;return i.lim>s.lim&&(l=s,d=!0),t.edges().filter(a=>d===Ct(e,e.node(a.v),l)&&d!==Ct(e,e.node(a.w),l)).reduce((a,u)=>de(t,u)<de(t,a)?u:a)}function ln(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),et(e),Qe(e,t),Rr(e,t)}function Rr(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=Ir(e,[n]);r=r.slice(1),r.forEach(o=>{let i=e.node(o).parent,s=t.edge(o,i),l=!1;s||(s=t.edge(i,o),l=!0),t.node(o).rank=t.node(i).rank+(l?s.minlen:-s.minlen)})}function Pr(e,t,n){return e.hasEdge(t,n)}function Ct(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Br=Fr;function Fr(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Nt(e);break;case"tight-tree":Dr(e);break;case"longest-path":Ar(e);break;case"none":break;default:Nt(e)}}var Ar=Ze;function Dr(e){Ze(e),tn(e)}function Nt(e){zr(e)}var Wr=$r;function $r(e){let t=Yr(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=Gr(e,t,o.v,o.w),s=i.path,l=i.lca,d=0,a=s[d],u=!0;for(;n!==o.w;){if(r=e.node(n),u){for(;(a=s[d])!==l&&e.node(a).maxRank<r.rank;)d++;a===l&&(u=!1)}if(!u){for(;d<s.length-1&&e.node(s[d+1]).minRank<=r.rank;)d++;a=s[d]}a!==void 0&&e.setParent(n,a),n=e.successors(n)[0]}})}function Gr(e,t,n,r){let o=[],i=[],s=Math.min(t[n].low,t[r].low),l=Math.max(t[n].lim,t[r].lim),d;d=n;do d=e.parent(d),o.push(d);while(d&&(t[d].low>s||l>t[d].lim));let a=d,u=r;for(;(u=e.parent(u))!==a;)i.push(u);return{path:o.concat(i.reverse()),lca:a}}function Yr(e){let t={},n=0;function r(o){let i=n;e.children(o).forEach(r),t[o]={low:i,lim:n++}}return e.children(Te).forEach(r),t}function Ur(e){let t=ce(e,"root",{},"_root"),n=Kr(e),r=Object.values(n),o=X(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=i);let s=qr(e)+1;e.children(Te).forEach(l=>an(e,t,i,s,o,n,l)),e.graph().nodeRankFactor=i}function an(e,t,n,r,o,i,s){var l;let d=e.children(s);if(!d.length){s!==t&&e.setEdge(t,s,{weight:0,minlen:n});return}let a=_t(e,"_bt"),u=_t(e,"_bb"),f=e.node(s);e.setParent(a,s),f.borderTop=a,e.setParent(u,s),f.borderBottom=u,d.forEach(h=>{var g;an(e,t,n,r,o,i,h);let b=e.node(h),w=b.borderTop?b.borderTop:h,y=b.borderBottom?b.borderBottom:h,k=b.borderTop?r:2*r,_=w!==y?1:o-((g=i[s])!=null?g:0)+1;e.setEdge(a,w,{weight:k,minlen:_,nestingEdge:!0}),e.setEdge(y,u,{weight:k,minlen:_,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,a,{weight:0,minlen:o+((l=i[s])!=null?l:0)})}function Kr(e){let t={};function n(r,o){let i=e.children(r);i&&i.length&&i.forEach(s=>n(s,o+1)),t[r]=o}return e.children(Te).forEach(r=>n(r,1)),t}function qr(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Hr(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Xr=Vr;function Vr(e){function t(n){let r=e.children(n),o=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(o,"minRank")){o.borderLeft=[],o.borderRight=[];for(let i=o.minRank,s=o.maxRank+1;i<s;++i)Ot(e,"borderLeft","_bl",n,o,i),Ot(e,"borderRight","_br",n,o,i)}}e.children(Te).forEach(t)}function Ot(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},l=o[t][i-1],d=ce(e,"border",s,n);o[t][i]=d,e.setParent(d,r),l&&e.setEdge(l,d,{weight:1})}function Jr(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&dn(e)}function Zr(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&Qr(e),(n==="lr"||n==="rl")&&(eo(e),dn(e))}function dn(e){e.nodes().forEach(t=>It(e.node(t))),e.edges().forEach(t=>It(e.edge(t)))}function It(e){let t=e.width;e.width=e.height,e.height=t}function Qr(e){e.nodes().forEach(t=>Pe(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Pe),Object.hasOwn(r,"y")&&Pe(r)})}function Pe(e){e.y=-e.y}function eo(e){e.nodes().forEach(t=>Be(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Be),Object.hasOwn(r,"x")&&Be(r)})}function Be(e){let t=e.x;e.x=e.y,e.y=t}function to(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),o=X(Math.max,r),i=ge(o+1).map(()=>[]);function s(l){if(t[l])return;t[l]=!0;let d=e.node(l);i[d.rank].push(l);let a=e.successors(l);a&&a.forEach(s)}return n.sort((l,d)=>e.node(l).rank-e.node(d).rank).forEach(s),i}function no(e,t){let n=0;for(let r=1;r<t.length;++r)n+=ro(e,t[r-1],t[r]);return n}function ro(e,t,n){let r=ur(n,n.map((a,u)=>u)),o=t.flatMap(a=>{let u=e.outEdges(a);return u?u.map(f=>({pos:r[f.w],weight:e.edge(f).weight})).sort((f,h)=>f.pos-h.pos):[]}),i=1;for(;i<n.length;)i<<=1;let s=2*i-1;i-=1;let l=new Array(s).fill(0),d=0;return o.forEach(a=>{let u=a.pos+i;l[u]+=a.weight;let f=0;for(;u>0;)u%2&&(f+=l[u+1]),u=u-1>>1,l[u]+=a.weight;d+=a.weight*f}),d}function oo(e,t=[]){return t.map(n=>{let r=e.inEdges(n);if(!r||!r.length)return{v:n};{let o=r.reduce((i,s)=>{let l=e.edge(s),d=e.node(s.v);return{sum:i.sum+l.weight*d.order,weight:i.weight+l.weight}},{sum:0,weight:0});return{v:n,barycenter:o.sum/o.weight,weight:o.weight}}})}function io(e,t){let n={};e.forEach((o,i)=>{let s={indegree:0,in:[],out:[],vs:[o.v],i};o.barycenter!==void 0&&(s.barycenter=o.barycenter,s.weight=o.weight),n[o.v]=s}),t.edges().forEach(o=>{let i=n[o.v],s=n[o.w];i!==void 0&&s!==void 0&&(s.indegree++,i.out.push(s))});let r=Object.values(n).filter(o=>!o.indegree);return so(r)}function so(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&lo(o,i)}}function r(o){return i=>{i.in.push(o),--i.indegree===0&&e.push(i)}}for(;e.length;){let o=e.pop();t.push(o),o.in.reverse().forEach(n(o)),o.out.forEach(r(o))}return t.filter(o=>!o.merged).map(o=>Se(o,["vs","i","barycenter","weight"]))}function lo(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function ao(e,t){let n=dr(e,u=>Object.hasOwn(u,"barycenter")),r=n.lhs,o=n.rhs.sort((u,f)=>f.i-u.i),i=[],s=0,l=0,d=0;r.sort(co(!!t)),d=Mt(i,o,d),r.forEach(u=>{d+=u.vs.length,i.push(u.vs),s+=u.barycenter*u.weight,l+=u.weight,d=Mt(i,o,d)});let a={vs:i.flat(1)};return l&&(a.barycenter=s/l,a.weight=l),a}function Mt(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function co(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function cn(e,t,n,r){let o=e.children(t),i=e.node(t),s=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,d={};s&&(o=o.filter(h=>h!==s&&h!==l));let a=oo(e,o);a.forEach(h=>{if(e.children(h.v).length){let g=cn(e,h.v,n,r);d[h.v]=g,Object.hasOwn(g,"barycenter")&&fo(h,g)}});let u=io(a,n);uo(u,d);let f=ao(u,r);if(s&&l){f.vs=[s,f.vs,l].flat(1);let h=e.predecessors(s);if(h&&h.length){let g=e.node(h[0]),b=e.predecessors(l),w=e.node(b[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+g.order+w.order)/(f.weight+2),f.weight+=2}}return f}function uo(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function fo(e,t){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight):(e.barycenter=t.barycenter,e.weight=t.weight)}function ho(e,t,n,r){r||(r=e.nodes());let o=go(e),i=new Y({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(s=>e.node(s));return r.forEach(s=>{let l=e.node(s),d=e.parent(s);if(l.rank===t||l.minRank<=t&&t<=l.maxRank){i.setNode(s),i.setParent(s,d||o);let a=e[n](s);a&&a.forEach(u=>{let f=u.v===s?u.w:u.v,h=i.edge(f,s),g=h!==void 0?h.weight:0;i.setEdge(f,s,{weight:e.edge(u).weight+g})}),Object.hasOwn(l,"minRank")&&i.setNode(s,{borderLeft:l.borderLeft[t],borderRight:l.borderRight[t]})}}),i}function go(e){let t;for(;e.hasNode(t=Je("_root")););return t}function po(e,t,n){let r={},o;n.forEach(i=>{let s=e.parent(i),l,d;for(;s;){if(l=e.parent(s),l?(d=r[l],r[l]=s):(d=o,o=s),d&&d!==s){t.setEdge(d,s);return}s=l}})}function un(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,un);return}let n=Zt(e),r=zt(e,ge(1,n+1),"inEdges"),o=zt(e,ge(n-1,-1,-1),"outEdges"),i=to(e);if(Lt(e,i),t.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,l,d=t.constraints||[];for(let a=0,u=0;u<4;++a,++u){bo(a%2?r:o,a%4>=2,d),i=be(e);let f=no(e,i);f<s?(u=0,l=Object.assign({},i),s=f):f===s&&(l=structuredClone(i))}Lt(e,l)}function zt(e,t,n){let r=new Map,o=(i,s)=>{r.has(i)||r.set(i,[]),r.get(i).push(s)};for(let i of e.nodes()){let s=e.node(i);if(typeof s.rank=="number"&&o(s.rank,i),typeof s.minRank=="number"&&typeof s.maxRank=="number")for(let l=s.minRank;l<=s.maxRank;l++)l!==s.rank&&o(l,i)}return t.map(function(i){return ho(e,i,n,r.get(i)||[])})}function bo(e,t,n){let r=new Y;e.forEach(function(o){n.forEach(l=>r.setEdge(l.left,l.right));let i=o.graph().root,s=cn(o,i,r,t);s.vs.forEach((l,d)=>o.node(l).order=d),po(o,r,s.vs)})}function Lt(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function yo(e,t){let n={};function r(o,i){let s=0,l=0,d=o.length,a=i[i.length-1];return i.forEach((u,f)=>{let h=mo(e,u),g=h?e.node(h).order:d;(h||u===a)&&(i.slice(l,f+1).forEach(b=>{let w=e.predecessors(b);w&&w.forEach(y=>{let k=e.node(y),_=k.order;(_<s||g<_)&&!(k.dummy&&e.node(b).dummy)&&fn(n,y,b)})}),l=f+1,s=g)}),i}return t.length&&t.reduce(r),n}function xo(e,t){let n={};function r(i,s,l,d,a){ge(s,l).forEach(u=>{let f=i[u];if(f!==void 0&&e.node(f).dummy){let h=e.predecessors(f);h&&h.forEach(g=>{if(g===void 0)return;let b=e.node(g);b.dummy&&(b.order<d||b.order>a)&&fn(n,g,f)})}})}function o(i,s){let l=-1,d=-1,a=0;return s.forEach((u,f)=>{if(e.node(u).dummy==="border"){let h=e.predecessors(u);if(h&&h.length){let g=h[0];if(g===void 0)return;d=e.node(g).order,r(s,a,f,l,d),a=f,l=d}}r(s,a,s.length,d,i.length)}),s}return t.length&&t.reduce(o),n}function mo(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function fn(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];r||(e[t]=r={}),r[n]=!0}function vo(e,t,n){if(t>n){let o=t;t=n,n=o}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function wo(e,t,n,r){let o={},i={},s={};return t.forEach(l=>{l.forEach((d,a)=>{o[d]=d,i[d]=d,s[d]=a})}),t.forEach(l=>{let d=-1;l.forEach(a=>{let u=r(a);if(u&&u.length){let f=u.sort((g,b)=>{let w=s[g],y=s[b];return(w!==void 0?w:0)-(y!==void 0?y:0)}),h=(f.length-1)/2;for(let g=Math.floor(h),b=Math.ceil(h);g<=b;++g){let w=f[g];if(w===void 0)continue;let y=s[w];if(y!==void 0&&i[a]===a&&d<y&&!vo(n,a,w)){let k=o[w];k!==void 0&&(i[w]=a,i[a]=o[a]=k,d=y)}}}})}),{root:o,align:i}}function Eo(e,t,n,r,o=!1){let i={},s=ko(e,t,n,o),l=o?"borderLeft":"borderRight";function d(g,b){let w=s.nodes().slice(),y={},k=w.pop();for(;k;){if(y[k])g(k);else{y[k]=!0,w.push(k);for(let _ of b(k))w.push(_)}k=w.pop()}}function a(g){let b=s.inEdges(g);b?i[g]=b.reduce((w,y)=>{var k;let _=(k=i[y.v])!=null?k:0,O=s.edge(y);return Math.max(w,_+(O!==void 0?O:0))},0):i[g]=0}function u(g){let b=s.outEdges(g),w=Number.POSITIVE_INFINITY;b&&(w=b.reduce((k,_)=>{let O=i[_.w],M=s.edge(_);return Math.min(k,(O!==void 0?O:0)-(M!==void 0?M:0))},Number.POSITIVE_INFINITY));let y=e.node(g);w!==Number.POSITIVE_INFINITY&&y.borderType!==l&&(i[g]=Math.max(i[g]!==void 0?i[g]:0,w))}function f(g){return s.predecessors(g)||[]}function h(g){return s.successors(g)||[]}return d(a,f),d(u,h),Object.keys(r).forEach(g=>{var b;let w=n[g];w!==void 0&&(i[g]=(b=i[w])!=null?b:0)}),i}function ko(e,t,n,r){let o=new Y,i=e.graph(),s=Co(i.nodesep,i.edgesep,r);return t.forEach(l=>{let d;l.forEach(a=>{let u=n[a];if(u!==void 0){if(o.setNode(u),d!==void 0){let f=n[d];if(f!==void 0){let h=o.edge(f,u);o.setEdge(f,u,Math.max(s(e,a,d),h||0))}}d=a}})}),o}function jo(e,t){return Object.values(t).reduce((n,r)=>{let o=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;Object.entries(r).forEach(([l,d])=>{let a=No(e,l)/2;o=Math.max(d+a,o),i=Math.min(d-a,i)});let s=o-i;return s<n[0]&&(n=[s,r]),n},[Number.POSITIVE_INFINITY,null])[1]}function So(e,t){let n=Object.values(t),r=X(Math.min,n),o=X(Math.max,n);["u","d"].forEach(i=>{["l","r"].forEach(s=>{let l=i+s,d=e[l];if(!d||d===t)return;let a=Object.values(d),u=r-X(Math.min,a);s!=="l"&&(u=o-X(Math.max,a)),u&&(e[l]=_e(d,f=>f+u))})})}function _o(e,t=void 0){let n=e.ul;return n?_e(n,(r,o)=>{var i,s;if(t){let d=t.toLowerCase(),a=e[d];if(a&&a[o]!==void 0)return a[o]}let l=Object.values(e).map(d=>{let a=d[o];return a!==void 0?a:0}).sort((d,a)=>d-a);return(((i=l[1])!=null?i:0)+((s=l[2])!=null?s:0))/2}):{}}function To(e){let t=be(e),n=Object.assign(yo(e,t),xo(e,t)),r={},o;["u","d"].forEach(s=>{o=s==="u"?t:Object.values(t).reverse(),["l","r"].forEach(l=>{l==="r"&&(o=o.map(u=>Object.values(u).reverse()));let d=wo(e,o,n,u=>(s==="u"?e.predecessors(u):e.successors(u))||[]),a=Eo(e,o,d.root,d.align,l==="r");l==="r"&&(a=_e(a,u=>-u)),r[s+l]=a})});let i=jo(e,r);return So(r,i),_o(r,e.graph().align)}function Co(e,t,n){return(r,o,i)=>{let s=r.node(o),l=r.node(i),d=0,a;if(d+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":a=-s.width/2;break;case"r":a=s.width/2;break}if(a&&(d+=n?a:-a),a=void 0,d+=(s.dummy?t:e)/2,d+=(l.dummy?t:e)/2,d+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":a=l.width/2;break;case"r":a=-l.width/2;break}return a&&(d+=n?a:-a),d}}function No(e,t){return e.node(t).width}function Oo(e){e=Vt(e),Io(e),Object.entries(To(e)).forEach(([t,n])=>e.node(t).x=n)}function Io(e){let t=be(e),n=e.graph(),r=n.ranksep,o=n.rankalign,i=0;t.forEach(s=>{let l=s.reduce((d,a)=>{var u;let f=(u=e.node(a).height)!=null?u:0;return d>f?d:f},0);s.forEach(d=>{let a=e.node(d);o==="top"?a.y=i+a.height/2:o==="bottom"?a.y=i+l-a.height/2:a.y=i+l/2}),i+=l+r})}function Mo(e,t={}){let n=t.debugTiming?Qt:en;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>$o(e));return n(" runLayout",()=>zo(r,n,t)),n(" updateInputGraph",()=>Lo(e,r)),r})}function zo(e,t,n){t(" makeSpaceForEdgeLabels",()=>Go(e)),t(" removeSelfEdges",()=>Zo(e)),t(" acyclic",()=>wr(e)),t(" nestingGraph.run",()=>Ur(e)),t(" rank",()=>Br(Vt(e))),t(" injectEdgeLabelProxies",()=>Yo(e)),t(" removeEmptyRanks",()=>lr(e)),t(" nestingGraph.cleanup",()=>Hr(e)),t(" normalizeRanks",()=>sr(e)),t(" assignRankMinMax",()=>Uo(e)),t(" removeEdgeLabelProxies",()=>Ko(e)),t(" normalize.run",()=>jr(e)),t(" parentDummyChains",()=>Wr(e)),t(" addBorderSegments",()=>Xr(e)),t(" order",()=>un(e,n)),t(" insertSelfEdges",()=>Qo(e)),t(" adjustCoordinateSystem",()=>Jr(e)),t(" position",()=>Oo(e)),t(" positionSelfEdges",()=>ei(e)),t(" removeBorderNodes",()=>Jo(e)),t(" normalize.undo",()=>_r(e)),t(" fixupEdgeLabelCoords",()=>Xo(e)),t(" undoCoordinateSystem",()=>Zr(e)),t(" translateGraph",()=>qo(e)),t(" assignNodeIntersects",()=>Ho(e)),t(" reversePoints",()=>Vo(e)),t(" acyclic.undo",()=>kr(e))}function Lo(e,t){e.nodes().forEach(n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.order=o.order,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))}),e.edges().forEach(n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Ro=["nodesep","edgesep","ranksep","marginx","marginy"],Po={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},Bo=["acyclicer","ranker","rankdir","align","rankalign"],Fo=["width","height","rank"],Rt={width:0,height:0},Ao=["minlen","weight","width","height","labeloffset"],Do={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Wo=["labelpos"];function $o(e){let t=new Y({multigraph:!0,compound:!0}),n=Ae(e.graph());return t.setGraph(Object.assign({},Po,Fe(n,Ro),Se(n,Bo))),e.nodes().forEach(r=>{let o=Ae(e.node(r)),i=Fe(o,Fo);Object.keys(Rt).forEach(l=>{i[l]===void 0&&(i[l]=Rt[l])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Ae(e.edge(r));t.setEdge(r,Object.assign({},Do,Fe(o,Ao),Se(o,Wo)))}),t}function Go(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Yo(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let r=e.node(t.v),o={rank:(e.node(t.w).rank-r.rank)/2+r.rank,e:t};ce(e,"edge-proxy",o,"_ep")}})}function Uo(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Ko(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="edge-proxy"){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function qo(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,i=e.graph(),s=i.marginx||0,l=i.marginy||0;function d(a){let u=a.x,f=a.y,h=a.width,g=a.height;t=Math.min(t,u-h/2),n=Math.max(n,u+h/2),r=Math.min(r,f-g/2),o=Math.max(o,f+g/2)}e.nodes().forEach(a=>d(e.node(a))),e.edges().forEach(a=>{let u=e.edge(a);Object.hasOwn(u,"x")&&d(u)}),t-=s,r-=l,e.nodes().forEach(a=>{let u=e.node(a);u.x-=t,u.y-=r}),e.edges().forEach(a=>{let u=e.edge(a);u.points.forEach(f=>{f.x-=t,f.y-=r}),Object.hasOwn(u,"x")&&(u.x-=t),Object.hasOwn(u,"y")&&(u.y-=r)}),i.width=n-t+s,i.height=o-r+l}function Ho(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),o=e.node(t.w),i,s;n.points?(i=n.points[0],s=n.points[n.points.length-1]):(n.points=[],i=o,s=r),n.points.unshift(St(r,i)),n.points.push(St(o,s))})}function Xo(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function Vo(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function Jo(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),i=e.node(n.borderLeft[n.borderLeft.length-1]),s=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(s.x-i.x),n.height=Math.abs(o.y-r.y),n.x=i.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy==="border"&&e.removeNode(t)})}function Zo(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function Qo(e){be(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);i.order=o+n,(i.selfEdges||[]).forEach(s=>{ce(e,"selfedge",{width:s.label.width,height:s.label.height,rank:i.rank,order:o+ ++n,e:s.e,label:s.label},"_se")}),delete i.selfEdges})})}function ei(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy==="selfedge"){let r=n,o=e.node(r.e.v),i=o.x+o.width/2,s=o.y,l=n.x-i,d=o.height/2;e.setEdge(r.e,r.label),e.removeNode(t),r.label.points=[{x:i+2*l/3,y:s-d},{x:i+5*l/6,y:s-d},{x:i+l,y:s},{x:i+5*l/6,y:s+d},{x:i+2*l/3,y:s+d}],r.label.x=n.x,r.label.y=n.y}})}function Fe(e,t){return _e(Se(e,t),Number)}function Ae(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function ti(e){let t=be(e),n=new Y({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(r=>{n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),e.edges().forEach(r=>n.setEdge(r.v,r.w,{},r.name)),t.forEach((r,o)=>{let i="layer"+o;n.setNode(i,{rank:"same"}),r.reduce((s,l)=>(n.setEdge(s,l,{style:"invis"}),l))}),n}var ni={graphlib:Wt,version:fr,layout:Mo,debug:ti,util:{time:Qt,notime:en}},Pt=ni;/*! For license information please see dagre.esm.js.LEGAL.txt */const ri=e=>{const t=[];return e.nodeInternals.forEach((n,r)=>t.push(`${r}:${n.height??0}`)),t.join(",")},oi=({onHeightsReady:e,nodeCount:t})=>{const n=ae.useStore(ri),r=p.useRef("");p.useRef(0);const{fitView:o}=ae.useReactFlow();return p.useEffect(()=>{if(!n||n===r.current)return;const i={};for(const s of n.split(",")){const[l,d]=s.split(":"),a=Number(d);l&&a>0&&(i[l]=a)}Object.keys(i).length!==0&&(r.current=n,e(i))},[n]),null},ii={gray:{bg:"#f1f5f9",fg:"#475569"},green:{bg:"#dcfce7",fg:"#166534"},amber:{bg:"#fef3c7",fg:"#92400e"},red:{bg:"#fee2e2",fg:"#991b1b"}};function hn({workflowName:e,onWorkflowNameChange:t,status:n,statusColor:r="gray",onSave:o,onCancel:i,saveLabel:s="Save",saveDisabled:l=!1}){const[d,a]=p.useState(!1),[u,f]=p.useState(!1),[h,g]=p.useState(e??"");p.useEffect(()=>{g(e??"")},[e]);const b=async()=>{if(!(!o||d||l)){a(!0);try{await o()}finally{a(!1)}}},w=ii[r]??{bg:r,fg:"#fff"};return c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 20px",background:"#fff",borderBottom:"1px solid #e2e8f0",flexShrink:0},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minWidth:0},children:[u&&t?c.jsx("input",{value:h,onChange:y=>g(y.target.value),onBlur:()=>{f(!1),h!==e&&t(h)},onKeyDown:y=>{y.key==="Enter"&&y.target.blur(),y.key==="Escape"&&(g(e??""),f(!1))},autoFocus:!0,style:{fontSize:15,fontWeight:600,color:"#0f172a",border:"1px solid #cbd5e1",borderRadius:4,padding:"2px 6px",minWidth:200}}):c.jsx("span",{onClick:()=>t&&f(!0),style:{fontSize:15,fontWeight:600,color:"#0f172a",cursor:t?"text":"default",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:360},title:e,children:e||"Untitled workflow"}),n&&c.jsx("span",{style:{fontSize:11,fontWeight:600,padding:"3px 8px",borderRadius:999,background:w.bg,color:w.fg,textTransform:"uppercase",letterSpacing:.4,flexShrink:0},children:n})]}),c.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[i&&c.jsx("button",{type:"button",onClick:i,disabled:d,style:{padding:"6px 14px",fontSize:13,fontWeight:500,border:"1px solid #cbd5e1",background:"#fff",color:"#475569",borderRadius:6,cursor:d?"not-allowed":"pointer",opacity:d?.6:1},children:"Cancel"}),o&&c.jsx("button",{type:"button",onClick:b,disabled:d||l,style:{padding:"6px 16px",fontSize:13,fontWeight:600,border:"none",background:l?"#94a3b8":"var(--ff-primary, #1dbf60)",color:"#fff",borderRadius:6,cursor:d||l?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6,minWidth:80,justifyContent:"center"},children:d?"Saving…":s})]})]})}const Ce=({isOpen:e,onClose:t,title:n,icon:r,children:o,footer:i,width:s=600})=>{const[l,d]=p.useState(!1),a=()=>d(h=>!h),u=()=>c.jsxs(A.Box,{sx:{display:"flex",alignItems:"center",p:2,pt:3,borderBottom:"1px solid #e0e0e0",mb:0,flexShrink:0},children:[r&&c.jsx(A.Box,{sx:{mr:1.5,display:"flex",alignItems:"center",fontSize:"1.25rem",color:"#1DBF60"},children:r}),c.jsx("span",{style:{flexGrow:1,fontSize:14,fontWeight:500,color:"#212121"},children:n}),c.jsx(A.IconButton,{onClick:a,size:"small",sx:{mr:1},title:l?"Collapse":"Expand","data-testid":"expand-collapse-base-drawer-btn",children:l?c.jsx(Et.BiCollapse,{}):c.jsx(Et.BiExpand,{})}),c.jsx(A.IconButton,{onClick:t,size:"small","data-testid":"close-drawer-button",children:c.jsx(I.MdClose,{})})]}),f=()=>i?c.jsx(A.Box,{sx:{flexShrink:0,p:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:2},children:i}):null;return l?c.jsxs(A.Dialog,{open:e,onClose:t,maxWidth:!1,fullWidth:!0,PaperProps:{sx:{display:"flex",flexDirection:"column",height:"80vh",boxShadow:24,width:"750px",maxWidth:"100%"}},children:[c.jsx(u,{}),c.jsx(A.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),c.jsx(f,{})]}):c.jsxs(A.Drawer,{anchor:"right",open:e,onClose:t,variant:"persistent",sx:{zIndex:900},ModalProps:{keepMounted:!1},PaperProps:{sx:{width:s,position:"fixed",top:"64px",height:"calc(100% - 74px)",right:"10px",borderRadius:"8px",border:"1px solid #bdbdbd",boxShadow:"none",zIndex:900,display:"flex",flexDirection:"column"}},children:[c.jsx(u,{}),c.jsx(A.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),c.jsx(f,{})]})},si=({open:e,templates:t,messages:n,onSelect:r,onClose:o,loadTriggerSources:i})=>{const[s,l]=p.useState("trigger"),[d,a]=p.useState(null),[u,f]=p.useState([]),[h,g]=p.useState([]),[b,w]=p.useState(!1),[y,k]=p.useState(null);p.useEffect(()=>{e||(l("trigger"),a(null),f([]),g([]),w(!1),k(null))},[e]);const _=p.useCallback(async L=>{if(!i){r(L);return}a(L),w(!0),k(null);try{const F=await i(L.triggerKey);if(!F||F.length===0){r(L);return}f(F),l("sources")}catch(F){k(F instanceof Error?F.message:"Failed to load sources.")}finally{w(!1)}},[i,r]),O=()=>{l("trigger"),a(null),f([]),g([]),k(null)},M=()=>{d&&r(d,h)},z=s==="sources"&&d,W=z?c.jsxs(c.Fragment,{children:[c.jsx(A.Button,{type:"button",variant:"outlined",size:"small",onClick:O,children:n.cancel??"Back"}),c.jsx(A.Button,{type:"button",variant:"contained",size:"small",onClick:M,disabled:h.length===0,children:n.save??"Continue"})]}):null;return c.jsx(Ce,{isOpen:e,onClose:o,title:z?d.label:n.addTriggerTitle,icon:c.jsx(On.GrTrigger,{}),width:500,footer:W,children:c.jsxs(A.Box,{sx:{p:2},children:[!z&&c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"ff-text-muted ff-mb-3",style:{fontSize:13},children:n.chooseTrigger}),c.jsxs("div",{className:"ff-d-flex ff-flex-column ff-gap-2",children:[t.map(L=>c.jsxs("div",{className:"ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-start ff-gap-3",style:{cursor:b?"wait":"pointer",transition:"background 0.15s",opacity:b?.6:1},onClick:()=>!b&&_(L),role:"button",tabIndex:0,onKeyDown:F=>{F.key==="Enter"&&!b&&_(L)},onMouseEnter:F=>{b||(F.currentTarget.style.background="#f5f5f5")},onMouseLeave:F=>{F.currentTarget.style.background=""},children:[c.jsx("div",{style:{color:L.triggerCategory==="scheduler"?"#1976d2":"#f57c00",marginTop:2,flexShrink:0},children:L.triggerCategory==="scheduler"?c.jsx(I.MdCalendarToday,{size:18}):c.jsx(I.MdBolt,{size:18})}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:L.label}),L.description&&c.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:L.description})]})]},L.triggerKey)),t.length===0&&c.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:n.noTriggers})]}),b&&c.jsxs(A.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:2,fontSize:12,color:"#64748b"},children:[c.jsx(A.CircularProgress,{size:14}),c.jsx("span",{children:"Loading sources for the selected trigger…"})]}),y&&c.jsx("p",{style:{fontSize:12,color:"#d32f2f",marginTop:12},children:y})]}),z&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{role:"button",tabIndex:0,onClick:O,onKeyDown:L=>{L.key==="Enter"&&O()},className:"ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",style:{cursor:"pointer",color:"#0066cc",fontSize:13,fontWeight:500,width:"fit-content"},children:[c.jsx(I.MdArrowBack,{size:16}),c.jsx("span",{children:n.addTriggerTitle})]}),c.jsxs("p",{className:"ff-text-muted ff-mb-2",style:{fontSize:13},children:["Pick one or more sources for ",c.jsx("strong",{children:d.label}),":"]}),c.jsx(Nn,{isMulti:!0,options:u,value:h,onChange:L=>g(L??[]),placeholder:"Select sources…",menuPosition:"fixed",menuPortalTarget:typeof document<"u"?document.body:void 0,styles:Xe.buildSelectStyles(!1,!0)})]})]})})},De={cursor:"pointer",transition:"background 0.15s"},We="ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-center ff-gap-3",li=({open:e,availableDescriptors:t,messages:n,onSelect:r,onClose:o})=>{const{apps:i,ungrouped:s}=p.useMemo(()=>{const f=new Map,h=[];for(const g of t)if(g.app){const b=f.get(g.app.key);b?b.descriptors.push(g):f.set(g.app.key,{key:g.app.key,label:g.app.label,icon:g.app.icon,description:g.app.description,descriptors:[g]})}else h.push(g);return{apps:[...f.values()],ungrouped:h}},[t]),[l,d]=p.useState(null),a=l?i.find(f=>f.key===l)??null:null;p.useEffect(()=>{e||d(null)},[e]),p.useEffect(()=>{d(null)},[t]);const u=!a;return c.jsx(Ce,{isOpen:e,onClose:o,title:u?n.addStepTitle:a.label,icon:u?c.jsx(I.MdAddCircleOutline,{}):a.icon??c.jsx(I.MdApps,{}),width:500,children:c.jsxs(A.Box,{sx:{p:2},children:[!u&&c.jsxs("div",{role:"button",tabIndex:0,onClick:()=>d(null),onKeyDown:f=>{f.key==="Enter"&&d(null)},className:"ff-d-flex ff-align-items-center ff-gap-1 ff-mb-3",style:{cursor:"pointer",color:"#0066cc",fontSize:13,fontWeight:500,width:"fit-content"},children:[c.jsx(I.MdArrowBack,{size:16}),c.jsx("span",{children:n.addStepTitle})]}),c.jsx("p",{className:"ff-text-muted ff-mb-3",style:{fontSize:13},children:u?n.chooseAction:`Pick an action from ${a.label}`}),c.jsx("div",{className:"ff-d-flex ff-flex-column ff-gap-2",children:u?c.jsxs(c.Fragment,{children:[i.map(f=>c.jsxs("div",{className:We,style:De,onClick:()=>d(f.key),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&d(f.key)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&c.jsx("div",{style:{flexShrink:0},children:f.icon}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label}),c.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:f.description??`${f.descriptors.length} action${f.descriptors.length===1?"":"s"}`})]}),c.jsx(I.MdChevronRight,{size:18,color:"#9e9e9e"})]},`app-${f.key}`)),s.map(f=>c.jsxs("div",{className:We,style:De,onClick:()=>r(f),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&r(f)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&c.jsx("div",{style:{flexShrink:0},children:f.icon}),c.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label})]},f.type)),i.length===0&&s.length===0&&c.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:n.noActions})]}):a.descriptors.map(f=>c.jsxs("div",{className:We,style:De,onClick:()=>r(f),role:"button",tabIndex:0,onKeyDown:h=>{h.key==="Enter"&&r(f)},onMouseEnter:h=>{h.currentTarget.style.background="#f5f5f5"},onMouseLeave:h=>{h.currentTarget.style.background=""},children:[f.icon&&c.jsx("div",{style:{flexShrink:0},children:f.icon}),c.jsx("span",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:f.label})]},f.type))})]})})},Bt="_conditionConfig",ai=({open:e,nodeId:t,descriptor:n,initialValues:r,messages:o,onSave:i,onClose:s})=>{const[l,d]=p.useState([]),[a,u]=p.useState(!1),[f,h]=p.useState(null),[g,b]=p.useState({});p.useEffect(()=>{b((r==null?void 0:r[Bt])??{})},[r,t]),p.useEffect(()=>{let _=!1;if(h(null),!n||!t){d([]),u(!1);return}const O=n.formSchema;return typeof O=="function"?(u(!0),O(t).then(M=>{_||(d(M),u(!1))}).catch(M=>{_||(d([]),h(M instanceof Error?M.message:"Unable to load configuration."),u(!1))})):(d(O),u(!1)),()=>{_=!0}},[n,t]);const w=t?`node-config-form-${t}`:"node-config-form",y=!a&&!f&&l.length>0,k=y?c.jsxs(c.Fragment,{children:[c.jsx(A.Button,{type:"button",variant:"outlined",size:"small",onClick:s,children:o.cancel}),c.jsx(A.Button,{type:"submit",form:w,variant:"contained",size:"small",children:o.save})]}):null;return c.jsx(Ce,{isOpen:e,onClose:s,title:(n==null?void 0:n.label)??o.configureStep,icon:n==null?void 0:n.icon,width:500,footer:k,children:c.jsxs(A.Box,{sx:{p:2},children:[a&&c.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.loadingConfiguration}),!a&&f&&c.jsx("p",{style:{fontSize:13,color:"#d32f2f"},children:f}),!a&&!f&&l.length===0&&c.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.noConfigurationNeeded}),y&&c.jsx(Xe.FlowForm,{schema:{layout:"flat",fields:l},initialValues:r??{},formId:w,conditionConfig:g,onConditionConfigChange:b,onSubmit:_=>{if(!t)return;const O=Object.keys(g).length>0;i(t,{..._,[Bt]:O?g:void 0}),s()}})]})})},gn=({isOpen:e,onClose:t,workflowId:n,workflowLabel:r,onFetchWorkflow:o})=>{const[i,s]=p.useState({status:"idle"});return p.useEffect(()=>{if(!e||!n){s({status:"idle"});return}s({status:"loading"}),o(n).then(l=>s({status:"loaded",state:l})).catch(l=>s({status:"error",message:(l==null?void 0:l.message)??"Failed to load workflow"}))},[e,n,o]),c.jsx(Ce,{isOpen:e,onClose:t,title:r?`Preview: ${r}`:"Sub-Workflow Preview",icon:c.jsx(I.MdAccountTree,{size:18,color:"#00695c"}),width:700,children:c.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:24},children:[i.status==="idle"&&c.jsx("span",{style:{color:"#9e9e9e",fontSize:14},children:"Select a workflow to preview"}),i.status==="loading"&&c.jsxs("div",{style:{textAlign:"center",color:"#9e9e9e"},children:[c.jsx("div",{style:{width:32,height:32,borderRadius:"50%",border:"3px solid #e0e0e0",borderTopColor:"#00897b",animation:"spin 0.8s linear infinite",margin:"0 auto 12px"}}),c.jsx("span",{style:{fontSize:14},children:"Loading workflow…"}),c.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}),i.status==="error"&&c.jsxs("div",{style:{textAlign:"center",color:"#c62828"},children:[c.jsx(I.MdErrorOutline,{size:32,style:{marginBottom:8}}),c.jsx("p",{style:{margin:0,fontSize:14},children:i.message})]}),i.status==="loaded"&&c.jsx("div",{style:{width:"100%",flex:1},children:c.jsx(di,{state:i.state})})]})})},di=({state:e})=>{const[t,n]=p.useState(null),[r,o]=p.useState(null);return p.useEffect(()=>{Promise.all([Promise.resolve().then(()=>pi).then(i=>i.default),Promise.resolve().then(()=>require("./nodeRegistry.cjs")).then(i=>i.nodeTypeRegistry),Promise.resolve().then(()=>require("./templateRegistry.cjs")).then(i=>i.templateRegistry)]).then(([i,s,l])=>{n(()=>i),o({nodeTypeRegistry:s,templateRegistry:l})})},[]),!t||!r?c.jsx("div",{style:{color:"#9e9e9e",fontSize:13,textAlign:"center"},children:"Loading canvas…"}):c.jsx("div",{style:{width:"100%",height:480,border:"1px solid #e0e0e0",borderRadius:8,overflow:"hidden"},children:c.jsx(t,{nodeRegistry:r.nodeTypeRegistry,templateRegistry:r.templateRegistry,initialValue:e,readOnly:!0})})},pe=350,Ye=70,Ue=60,Ke={startNode:40,endNode:40,addTriggerNode:56,triggerNode:110,actionNode:90,filterNode:90,approvalNode:90,delayNode:80,notificationNode:80},ci={plusEdge:re.PlusEdge,labelPlusEdge:re.LabelPlusEdge,plainEdge:re.PlainEdge,edgeWithPlusLabel:re.EdgeWithPlusLabel,gatewayBranchEdge:re.GatewayBranchEdge};function Ft(){return[{id:"start",kind:"start",reactFlowType:"startNode"},{id:"addTrigger",kind:"addTrigger",reactFlowType:"addTriggerNode"},{id:"end",kind:"end",reactFlowType:"endNode"}]}function ui(e,t,n,r="TB"){const o=new Pt.graphlib.Graph;return o.setGraph({rankdir:r,ranksep:70,nodesep:50}),o.setDefaultEdgeLabel(()=>({})),e.forEach(i=>{const s=n[i.id]??{width:pe,height:Ke[i.type??""]??80};o.setNode(i.id,{width:s.width,height:s.height})}),t.forEach(i=>o.setEdge(i.source,i.target)),Pt.layout(o),e.map(i=>{var a,u;const s=o.node(i.id),l=((a=n[i.id])==null?void 0:a.width)??pe,d=((u=n[i.id])==null?void 0:u.height)??Ke[i.type??""]??80;return{...i,position:{x:s.x-l/2,y:s.y-d/2}}})}const oe=e=>e==="filter"||e==="approval";function fi(e,t,n,r){const s=Ye,l=30,d=30,a={},u={},f=new Map;for(const y of e)f.set(y.id,y);for(const y of Object.values(t))for(const k of Object.values(y))for(const _ of k)f.set(_.id,_);const h=(y,k,_)=>{const O=r[y]??{width:pe,height:80};return a[y]={x:k-O.width/2,y:_},_+O.height},g=(y,k,_)=>{let O=_;for(const M of y)O=h(M.id,k,O)+s,oe(M.kind)&&t[M.id]&&(O=b(M.id,k,O));return O},b=(y,k,_)=>{const O=k+180,M=t[y],z=Object.keys(M),W=f.get(y),L=(W==null?void 0:W.branchLabels)??{pass:"Pass",fail:"Fail"},F=a[y],$=r[y]??{height:80},ye=F.y+$.height,xe=[];let Z=_;return z.forEach((ue,me)=>{const Ne=M[ue],Oe=Z;xe.push({y:Oe-ye,label:L[ue]??ue,isPass:me===0}),Z=g(Ne,O,Z+d),me<z.length-1&&(Z+=l)}),u[y]={branches:xe,height:Z-ye,indent:180},Z};let w=Ue;for(const y of e)w=h(y.id,400,w)+s,oe(y.kind)&&t[y.id]&&(w=b(y.id,400,w));return{nodes:n.map(y=>a[y.id]?{...y,position:a[y.id]}:y),railSpecs:u}}function At(e){return{id:e.id,type:e.reactFlowType,position:{x:0,y:0},data:{...e.nodeData,...e.formData,descriptorType:e.descriptorType},draggable:!1,selectable:!1}}function hi(e,t,n,r,o){return{id:`e-${e.id}-${t.id}`,source:e.id,target:t.id,type:"plusEdge",style:{stroke:n},data:{onAddStepClick:r,referenceNodeType:e.reactFlowType,...o??{}}}}function gi(e,t,n,r,o={},i="TB",s="horizontal"){const l=o.edgeColor??"#b0bec5",d=[],a=[],u=(b,w)=>{const y=t[b];if(!y)return;const _=w??{pass:"Pass",fail:"Fail"},O=Object.keys(y),M=(z,W,L,F)=>{if(z.length!==0){z.forEach($=>d.push(At($))),a.push({id:`e-${b}-${W}-start`,source:b,target:z[0].id,type:"gatewayBranchEdge",style:{stroke:l},data:{branch:W,filterId:b,label:L,isFirst:F===0,onAddStepClick:n,verticalRouting:s==="vertical"}});for(let $=1;$<z.length;$++)oe(z[$-1].kind)||a.push(hi(z[$-1],z[$],l,n,{filterId:b,branch:W}));for(const $ of z)oe($.kind)&&t[$.id]&&u($.id,$.branchLabels)}};O.forEach((z,W)=>{M(y[z],z,_[z]??z,W)})};for(let b=0;b<e.length;b++){const w=e[b];if(d.push(At(w)),b>0){const y=e[b-1],k=y.kind==="start"||y.kind==="addTrigger";if(y.kind==="filter"||y.kind==="approval")continue;a.push({id:`e-${y.id}-${w.id}`,source:y.id,target:w.id,type:k?"plainEdge":"plusEdge",style:{stroke:l},data:k?{}:{onAddStepClick:n,referenceNodeType:y.reactFlowType}})}(w.kind==="filter"||w.kind==="approval")&&t[w.id]&&u(w.id,w.branchLabels)}const f={};if(d.forEach(b=>{f[b.id]={width:pe,height:r[b.id]??Ke[b.type??""]??80}}),!(Object.keys(t).length>0)){if(i==="LR"){let _=Ue;return{nodes:d.map(M=>{const z=f[M.id].width,W=f[M.id].height,L={...M,position:{x:_,y:300-W/2}};return _+=z+Ye,L}),edges:a}}const b=400;let w=Ue;return{nodes:d.map(k=>{const _=f[k.id].height,O={...k,position:{x:b-pe/2,y:w}};return w+=_+Ye,O}),edges:a}}if(s==="vertical"){const{nodes:b,railSpecs:w}=fi(e,t,d,f);return{nodes:b.map(k=>w[k.id]?{...k,data:{...k.data,_branchRail:w[k.id]}}:k),edges:a}}return{nodes:ui(d,a,f,i),edges:a}}const qe=({nodeRegistry:e,templateRegistry:t,initialValue:n,nodeTypes:r,edgeTypes:o,onSave:i,readOnly:s=!1,theme:l={},messages:d,canvasOptions:a={},renderTriggerSelector:u,loadTriggerSources:f,renderNodePicker:h,renderNodeConfig:g,onNodeClick:b,maxNodes:w,layoutDirection:y="TB",executionRecord:k,onFetchWorkflow:_,hideHeader:O=!1,workflowName:M,onWorkflowNameChange:z,onCancel:W,workflowStatus:L,workflowStatusColor:F,saveLabel:$,optionsResolvers:ye})=>{const{fitView:xe=!0,fitViewPadding:Z=.3,showControls:ue=!0,showMiniMap:me=!1,panOnScroll:Ne=!0,zoomOnScroll:Oe=!1,minZoom:bn=.25,maxZoom:yn=2,snapToGrid:xn=!1,snapGrid:mn=[15,15],branchLayout:tt="horizontal",nodeBody:nt="full"}=a,fe=p.useMemo(()=>In.mergeMessages(d),[d]),[R,ee]=p.useState(()=>(n==null?void 0:n.slots)??Ft()),[G,V]=p.useState(()=>(n==null?void 0:n.branches)??{}),[se,U]=p.useState(null),[Ie,rt]=p.useState(null),[K,ve]=p.useState(null),[te,ot]=p.useState(null),[we,it]=p.useState(null),[q,st]=p.useState(()=>{const x=n==null?void 0:n.slots.find(S=>S.kind==="triggerFixed"),v=x!=null&&x.id.startsWith("trigger-")?x.id.slice(8):void 0;return v?t.lookup(v)??null:null}),[lt,vn]=p.useState({}),wn=p.useCallback(x=>{vn(x)},[]),En=p.useMemo(()=>({...re.builtInNodeTypes,...r}),[r]),kn=p.useMemo(()=>({...ci,...o}),[o]),jn=p.useMemo(()=>{const x=R.filter(S=>S.kind==="userTask").length,v=Object.values(G).flatMap(S=>Object.values(S).flat()).filter(S=>S.kind==="userTask").length;return x+v},[R,G]),at=w??(q==null?void 0:q.maxTasks),dt=at!==void 0&&jn>=at,ne=p.useCallback(x=>{const v=R.find(S=>S.id===x);if(v)return v;for(const S of Object.values(G)){const E=Object.values(S).flat().find(N=>N.id===x);if(E)return E}return null},[R,G]),Me=p.useCallback(x=>{s||(rt(x),U("nodeConfig"))},[s]),ct=p.useCallback(x=>{if(!s){if(R.some(v=>v.id===x)){const v=R.find(S=>S.id===x);if((v==null?void 0:v.kind)==="triggerFixed"){ee(Ft()),V({}),st(null);return}ee(S=>{const E=S.filter(N=>N.id!==x);return oe((v==null?void 0:v.kind)??"")&&!E.some(N=>N.kind==="end")?[...E,{id:"end",kind:"end",reactFlowType:"endNode"}]:E}),V(S=>{const E={...S},N=m=>{E[m]&&(Object.values(E[m]).flat().filter(j=>oe(j.kind)).forEach(j=>N(j.id)),delete E[m])};return N(x),E});return}V(v=>{const S=(N,m)=>{const j=[];for(const C of N)oe(C.kind)&&m[C.id]&&(j.push(C.id),Object.values(m[C.id]).forEach(T=>j.push(...S(T,m))));return j},E={...v};for(const N of Object.keys(E))for(const m of Object.keys(E[N])){const j=E[N][m],C=j.findIndex(P=>P.id===x);if(C===-1||j[C].kind==="end")continue;const T=j[C];let B=j.filter(P=>P.id!==x);return T.kind==="filter"&&((T.id in E?S([T],E):[]).forEach(D=>delete E[D]),delete E[T.id],B.some(D=>D.kind==="end")||(B=[...B,{id:`end-${N}-${m}`,kind:"end",reactFlowType:"endNode"}])),E[N]={...E[N],[m]:B},E}return E})}},[s,R]),ze=p.useCallback(()=>{s||U("triggerSelect")},[s]),ut=p.useCallback((x,v)=>{s||dt||(ve(x),ot(v.filterId&&v.branch?{filterId:v.filterId,branch:v.branch}:null),U("nodePicker"))},[s,dt]),ft=p.useCallback((x,v)=>{if(st(x),U(null),x.skeletonState){const E=Array.isArray(v)&&v.length>0,N=(x.skeletonState.slots??[]).map(m=>m.kind!=="triggerFixed"?m:{...m,nodeData:{label:x.label,...m.nodeData??{},...E&&{sources:v}}});V(x.skeletonState.branches??{}),ee(N);return}V({});const S=Array.isArray(v)&&v.length>0;ee([{id:"start",kind:"start",reactFlowType:"startNode"},{id:`trigger-${x.triggerKey}`,kind:"triggerFixed",reactFlowType:"triggerNode",nodeData:{label:x.label,source:x.source,eventType:x.triggerKey,type:x.triggerCategory==="scheduler"?"scheduler":"event",...S&&{sources:v}},deletable:!1},{id:"end",kind:"end",reactFlowType:"endNode"}])},[]),ht=p.useCallback(()=>{var S;const x={insertAfterSlot:null,upstreamSlots:[],downstreamSlots:[],branch:te,template:q};if(!K)return x;if(te){const{filterId:E,branch:N}=te,m=R.findIndex(P=>P.id===E),j=m>=0?R.slice(0,m+1):[],C=((S=G[E])==null?void 0:S[N])??[],T=C.findIndex(P=>P.id===K),B=T>=0?C.slice(0,T+1):[];return x.upstreamSlots=[...j,...B],x.downstreamSlots=T>=0?C.slice(T+1):C,x.insertAfterSlot=B[B.length-1]??null,x}const v=R.findIndex(E=>E.id===K);return x.upstreamSlots=v>=0?R.slice(0,v+1):[],x.downstreamSlots=v>=0?R.slice(v+1):[],x.insertAfterSlot=x.upstreamSlots[x.upstreamSlots.length-1]??null,x},[R,G,K,te,q]),gt=(x,v)=>x.descriptorType===v||x.id===v||x.kind===v,pt=p.useCallback(()=>{const x=e.list(),v=q!=null&&q.availableTasks?x.filter(E=>q.availableTasks.includes(E.type)):x,S=ht();return v.filter(E=>E.maxPerWorkflow!==void 0&&R.filter(m=>m.descriptorType===E.type).length+Object.values(G).flatMap(m=>Object.values(m).flat()).filter(m=>m.descriptorType===E.type).length>=E.maxPerWorkflow?!1:E.canInsert?E.canInsert(S):!(E.insertAfter&&E.insertAfter.length>0&&!S.upstreamSlots.some(m=>E.insertAfter.some(j=>gt(m,j)))||E.insertBefore&&E.insertBefore.length>0&&!S.downstreamSlots.some(m=>E.insertBefore.some(j=>gt(m,j)))))},[e,q,R,G,ht]),bt=p.useCallback(x=>{if(!K)return;const v=`${x.type}-${Date.now()}`,S=x.reactFlowType==="filterNode"||x.reactFlowType==="approvalNode"||x.reactFlowType==="conditionBranchNode",E=x.branchLabels??{pass:"Pass",fail:"Fail"},N={id:v,kind:S?x.reactFlowType==="approvalNode"?"approval":"filter":"userTask",reactFlowType:x.reactFlowType,descriptorType:x.type,formData:{},nodeData:{title:x.label},deletable:!0,branchLabels:E};if(te){const{filterId:m,branch:j}=te;V(C=>{const T=[...C[m][j]];if(S){const Q=T.filter(le=>le.kind!=="end"),wt=Q.findIndex(le=>le.id===K),Cn=wt===-1?Q.length:wt+1;return Q.splice(Cn,0,N),{...C,[m]:{...C[m],[j]:Q},[v]:Object.fromEntries(Object.keys(E).map(le=>[le,[{id:`end-${v}-${le}`,kind:"end",reactFlowType:"endNode"}]]))}}const B=T.findIndex(Q=>Q.id===K),P=T.findIndex(Q=>Q.kind==="end"),D=B===-1?P===-1?T.length:P:B+1;return T.splice(D,0,N),{...C,[m]:{...C[m],[j]:T}}})}else S?(ee(m=>{const j=m.findIndex(T=>T.id===K);return[...m.filter(T=>T.kind!=="end").slice(0,j+1),N]}),V(m=>({...m,[v]:Object.fromEntries(Object.keys(E).map(j=>[j,[{id:`end-${v}-${j}`,kind:"end",reactFlowType:"endNode"}]]))}))):ee(m=>{const j=m.findIndex(C=>C.id===K);return j===-1?m:[...m.slice(0,j+1),N,...m.slice(j+1)]});ve(null),ot(null),rt(v),U("nodeConfig")},[K,te]),yt=p.useCallback((x,v)=>{const S=m=>{const j=m.label||m.key;switch(m.kind){case"if":return`IF · ${j}`;case"elseif":return`ELSE IF · ${j}`;case"else":return j.toUpperCase()==="ELSE"?j:`ELSE · ${j}`;default:return j}},E=m=>{const j=ne(x);if((j==null?void 0:j.descriptorType)!=="conditionBranch")return m;const T=(v.branchConfigs??[]).map(D=>D.key).filter(Boolean);if(T.length===0)return m;const B=m[x]??{},P={};return T.forEach(D=>{P[D]=B[D]??[{id:`end-${x}-${D}`,kind:"end",reactFlowType:"endNode"}]}),{...m,[x]:P}},N=(m,j)=>{if(m.descriptorType!=="conditionBranch")return{...m,formData:j};const C=j.branchConfigs??[],T={};return C.forEach(B=>{B.key&&(T[B.key]=S(B))}),{...m,formData:j,branchLabels:T}};if(R.some(m=>m.id===x)){V(m=>{const j=E(m);return ee(C=>C.map(T=>T.id===x?N(T,v):T)),j});return}V(m=>{const C={...E(m)};for(const T of Object.keys(C)){const B=P=>P.map(D=>D.id===x?N(D,v):D);for(const P of Object.keys(C[T]))if(C[T][P].some(D=>D.id===x))return C[T]={...C[T],[P]:B(C[T][P])},C}return C})},[R,G,ne]),J=p.useMemo(()=>ne(Ie??""),[ne,Ie]),xt=p.useMemo(()=>J!=null&&J.descriptorType?e.forType(J.descriptorType)??null:null,[J,e]),{nodes:mt,edges:Sn}=p.useMemo(()=>gi(R,G,s?null:ut,lt,l,y,tt),[R,G,s,ut,lt,l,y,tt]),vt=p.useMemo(()=>{const x=k?new Map(k.steps.map(v=>[v.nodeId,v])):null;return mt.map(v=>{let S={};if(x){const E=x.get(v.id);E&&(S={_executionStatus:E.status,_executionError:E.error})}return v.type==="subWorkflowNode"&&_&&(S.onPreview=E=>{var m;const N=ne(v.id);it({workflowId:E,workflowLabel:((m=N==null?void 0:N.formData)==null?void 0:m.workflowLabel)??void 0})}),Object.keys(S).length>0?{...v,data:{...v.data,...S}}:v})},[mt,k,_,ne]),_n=p.useMemo(()=>({onEditNode:Me,onDeleteNode:ct,onAddStep:()=>{},onClickAddTrigger:ze,messages:fe,nodeRegistry:e,nodeBody:nt}),[Me,ct,ze,fe,e,nt]),Tn=p.useCallback(async()=>{i&&await i({slots:R,branches:G})},[i,R,G]);return c.jsx(Xe.OptionsResolversProvider,{resolvers:ye,children:c.jsx(re.WorkflowCanvasContext.Provider,{value:_n,children:c.jsxs("div",{className:"flowforge-canvas",style:{width:"100%",height:"100%",position:"relative",display:"flex",flexDirection:"column","--ff-primary":l.primaryColor??"#1dbf60","--ff-edge-color":l.edgeColor??"#b0bec5","--ff-text":l.textColor??"#212121","--ff-muted":l.mutedTextColor??"#9ca3af","--ff-surface":l.surfaceColor??"#fff","--ff-border":l.borderColor??"#dee2e6","--ff-danger":l.dangerColor??"#d32f2f","--ff-radius":`${l.borderRadius??6}px`,"--ff-font-family":l.fontFamily},children:[!O&&(i||W||M)&&c.jsx(hn,{workflowName:M,onWorkflowNameChange:z,status:L,statusColor:F,onSave:i?Tn:void 0,onCancel:W,saveLabel:$}),c.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[c.jsxs(ae,{nodes:vt,edges:Sn,nodeTypes:En,edgeTypes:kn,fitView:xe,fitViewOptions:{padding:Z},nodesDraggable:!1,nodesConnectable:!1,panOnScroll:Ne,zoomOnScroll:Oe,minZoom:bn,maxZoom:yn,snapToGrid:xn,snapGrid:mn,proOptions:{hideAttribution:!0},onNodeClick:(x,v)=>{const S=ne(v.id);S&&(b!=null&&b(S)||(S.kind==="addTrigger"||S.kind==="triggerFixed"?ze():(S.kind==="userTask"||S.kind==="filter"||S.kind==="approval")&&Me(v.id)))},children:[l.background!=="none"&&c.jsx(ae.Background,{variant:l.background,color:l.backgroundColor??"#e0e0e0",gap:20}),ue&&c.jsx(ae.Controls,{showInteractive:!1}),me&&c.jsx(ae.MiniMap,{zoomable:!0,pannable:!0}),c.jsx(oi,{onHeightsReady:wn,nodeCount:vt.length})]}),u?se==="triggerSelect"&&u(t.list(),ft,()=>U(null)):c.jsx(si,{open:se==="triggerSelect",templates:t.list(),messages:fe,onSelect:ft,onClose:()=>U(null),loadTriggerSources:f}),h?se==="nodePicker"&&h(pt(),bt,()=>{U(null),ve(null)}):c.jsx(li,{open:se==="nodePicker",availableDescriptors:pt(),messages:fe,onSelect:bt,onClose:()=>{U(null),ve(null)}}),g?se==="nodeConfig"&&g(xt??void 0,J,yt,()=>U(null)):c.jsx(ai,{open:se==="nodeConfig",nodeId:Ie,descriptor:xt,initialValues:J==null?void 0:J.formData,messages:fe,onSave:yt,onClose:()=>U(null)}),_&&we&&c.jsx(gn,{isOpen:!!we,onClose:()=>it(null),workflowId:we.workflowId,workflowLabel:we.workflowLabel,onFetchWorkflow:_})]})]})})})},pi=Object.freeze(Object.defineProperty({__proto__:null,WorkflowCanvas:qe,default:qe},Symbol.toStringTag,{value:"Module"})),$e="All";function bi({template:e,onSelect:t}){var o,i;const n=e.triggerCategory?H.TRIGGER_CATEGORY_STYLE[e.triggerCategory]:null,r=((o=e.skeletonState)==null?void 0:o.slots.filter(s=>s.kind==="userTask").length)??0;return c.jsxs("div",{role:"button",tabIndex:0,onClick:t,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&t()},style:{border:"1.5px solid #e0e0e0",borderRadius:10,padding:"16px",background:"#fff",cursor:"pointer",transition:"border-color 0.15s, box-shadow 0.15s",display:"flex",flexDirection:"column",gap:8,outline:"none"},onMouseEnter:s=>{s.currentTarget.style.borderColor="#1976d2",s.currentTarget.style.boxShadow="0 2px 8px rgba(25,118,210,0.12)"},onMouseLeave:s=>{s.currentTarget.style.borderColor="#e0e0e0",s.currentTarget.style.boxShadow="none"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[e.icon&&c.jsx("div",{style:{flexShrink:0,width:36,height:36,borderRadius:8,background:"#f5f5f5",display:"flex",alignItems:"center",justifyContent:"center"},children:e.icon}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontWeight:600,fontSize:14,color:"#212121",marginBottom:2},children:e.label}),e.description&&c.jsx("div",{style:{fontSize:12,color:"#757575",lineHeight:1.4,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.description})]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:4},children:[n&&c.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:10,background:n.bg,color:n.color},children:n.label}),(i=e.tags)==null?void 0:i.map(s=>c.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:10,background:"#f5f5f5",color:"#616161"},children:s},s)),r>0&&c.jsxs("span",{style:{fontSize:10,color:"#9e9e9e",marginLeft:"auto"},children:[r," step",r!==1?"s":""]})]}),e.author&&c.jsxs("div",{style:{fontSize:11,color:"#bdbdbd"},children:["by ",e.author]})]})}const yi=({templates:e,onSelectTemplate:t,onStartFromScratch:n})=>{const[r,o]=p.useState(""),[i,s]=p.useState($e),l=p.useMemo(()=>{const a=new Set;return e.forEach(u=>{u.category&&a.add(u.category)}),[$e,...Array.from(a)]},[e]),d=p.useMemo(()=>{let a=e;if(i!==$e&&(a=a.filter(u=>u.category===i)),r.trim()){const u=r.toLowerCase();a=a.filter(f=>{var h,g;return f.label.toLowerCase().includes(u)||((h=f.description)==null?void 0:h.toLowerCase().includes(u))||((g=f.tags)==null?void 0:g.some(b=>b.toLowerCase().includes(u)))})}return[...a].sort((u,f)=>(f.popularity??0)-(u.popularity??0))},[e,i,r]);return c.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",fontFamily:"inherit"},children:[c.jsxs("div",{style:{padding:"24px 24px 0",borderBottom:"1px solid #f0f0f0",paddingBottom:16},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:16},children:[c.jsxs("div",{children:[c.jsx("h2",{style:{margin:0,fontSize:20,fontWeight:700,color:"#212121"},children:"Workflow Templates"}),c.jsx("p",{style:{margin:"4px 0 0",fontSize:13,color:"#757575"},children:"Choose a pre-built template or start from scratch"})]}),n&&c.jsxs("button",{onClick:n,style:{display:"flex",alignItems:"center",gap:6,padding:"8px 16px",border:"1.5px solid #1976d2",borderRadius:6,background:"#fff",color:"#1976d2",fontSize:13,fontWeight:600,cursor:"pointer"},children:[c.jsx(I.MdAdd,{size:16}),"Start from Scratch"]})]}),c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"#f5f5f5",borderRadius:8,padding:"8px 12px",marginBottom:12},children:[c.jsx(I.MdSearch,{size:18,color:"#9e9e9e"}),c.jsx("input",{value:r,onChange:a=>o(a.target.value),placeholder:"Search templates...",style:{border:"none",background:"transparent",outline:"none",fontSize:14,color:"#212121",flex:1}})]}),l.length>1&&c.jsx("div",{style:{display:"flex",gap:4,flexWrap:"wrap"},children:l.map(a=>c.jsx("button",{onClick:()=>s(a),style:{padding:"4px 12px",borderRadius:20,border:"1.5px solid",borderColor:i===a?"#1976d2":"#e0e0e0",background:i===a?"#e3f2fd":"#fff",color:i===a?"#1565c0":"#616161",fontSize:12,fontWeight:i===a?600:400,cursor:"pointer"},children:a},a))})]}),c.jsx("div",{style:{flex:1,overflowY:"auto",padding:24},children:d.length===0?c.jsxs("div",{style:{textAlign:"center",padding:"40px 0",color:"#9e9e9e"},children:[c.jsx(I.MdCategory,{size:36,style:{marginBottom:8}}),c.jsx("p",{style:{margin:0,fontSize:14},children:"No templates found"})]}):c.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(280px, 1fr))",gap:16},children:d.map(a=>c.jsx(bi,{template:a,onSelect:()=>t(a)},a.triggerKey))})})]})},Ee={running:{label:"Running",color:H.EXECUTION_STATUS_COLOR.running,icon:p.createElement(I.MdPlayArrow,{size:14})},success:{label:"Success",color:H.EXECUTION_STATUS_COLOR.success,icon:p.createElement(I.MdCheckCircle,{size:14})},failed:{label:"Failed",color:H.EXECUTION_STATUS_COLOR.failed,icon:p.createElement(I.MdError,{size:14})},cancelled:{label:"Cancelled",color:H.EXECUTION_STATUS_COLOR.cancelled,icon:p.createElement(I.MdCancel,{size:14})}},xi={pending:{color:H.EXECUTION_STATUS_COLOR.pending,icon:p.createElement(I.MdHourglassEmpty,{size:14})},running:{color:H.EXECUTION_STATUS_COLOR.running,icon:p.createElement(I.MdPlayArrow,{size:14})},success:{color:H.EXECUTION_STATUS_COLOR.success,icon:p.createElement(I.MdCheckCircle,{size:14})},failed:{color:H.EXECUTION_STATUS_COLOR.failed,icon:p.createElement(I.MdError,{size:14})},skipped:{color:H.EXECUTION_STATUS_COLOR.skipped,icon:p.createElement(I.MdCancel,{size:14})}};function He(e){try{return new Date(e).toLocaleString()}catch{return e}}function pn(e,t){try{const n=new Date(t??new Date().toISOString()).getTime()-new Date(e).getTime();return n<1e3?`${n}ms`:n<6e4?`${(n/1e3).toFixed(1)}s`:`${Math.floor(n/6e4)}m ${Math.floor(n%6e4/1e3)}s`}catch{return"—"}}function mi({step:e}){const[t,n]=p.useState(!1),r=xi[e.status],o=!!(e.inputs||e.outputs||e.error);return c.jsxs("div",{style:{borderBottom:"1px solid #f5f5f5"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",cursor:o?"pointer":"default"},onClick:()=>{o&&n(i=>!i)},role:o?"button":void 0,tabIndex:o?0:void 0,onKeyDown:i=>{o&&(i.key==="Enter"||i.key===" ")&&n(s=>!s)},children:[c.jsx("span",{style:{color:r.color,flexShrink:0},children:p.cloneElement(r.icon,{color:r.color})}),c.jsx("span",{style:{flex:1,fontSize:13,color:"#212121"},children:e.label||e.nodeId}),e.branchTaken&&c.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:10,background:"#e3f2fd",color:"#1565c0",fontWeight:600},children:e.branchTaken}),c.jsx("span",{style:{fontSize:11,color:"#9e9e9e",flexShrink:0},children:e.startedAt?pn(e.startedAt,e.completedAt):"—"}),o&&c.jsx("span",{style:{color:"#9e9e9e",flexShrink:0},children:t?p.createElement(I.MdExpandLess,{size:16}):p.createElement(I.MdExpandMore,{size:16})})]}),t&&o&&c.jsxs("div",{style:{padding:"0 12px 10px 32px",fontSize:12},children:[e.error&&c.jsx("div",{style:{padding:"6px 10px",borderRadius:6,background:"#ffebee",color:"#c62828",marginBottom:6},children:e.error}),e.inputs&&Object.keys(e.inputs).length>0&&c.jsxs("details",{style:{marginBottom:4},children:[c.jsx("summary",{style:{cursor:"pointer",color:"#616161",marginBottom:4},children:"Inputs"}),c.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:8,borderRadius:4,overflowX:"auto"},children:JSON.stringify(e.inputs,null,2)})]}),e.outputs&&Object.keys(e.outputs).length>0&&c.jsxs("details",{children:[c.jsx("summary",{style:{cursor:"pointer",color:"#616161",marginBottom:4},children:"Outputs"}),c.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:8,borderRadius:4,overflowX:"auto"},children:JSON.stringify(e.outputs,null,2)})]})]})]})}function vi({record:e,selected:t,onSelect:n}){const r=Ee[e.status];return c.jsxs("div",{role:"button",tabIndex:0,onClick:n,onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&n()},style:{padding:"10px 14px",borderBottom:"1px solid #f0f0f0",cursor:"pointer",background:t?"#e3f2fd":"#fff",display:"flex",alignItems:"center",gap:10,outline:"none"},children:[c.jsx("span",{style:{color:r.color,flexShrink:0},children:p.cloneElement(r.icon,{color:r.color,size:16})}),c.jsxs("div",{style:{flex:1,minWidth:0},children:[c.jsx("div",{style:{fontSize:12,color:"#212121",fontWeight:t?600:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:He(e.triggeredAt)}),c.jsxs("div",{style:{fontSize:11,color:"#9e9e9e"},children:[e.triggeredBy?`by ${e.triggeredBy}`:"System"," · ",e.steps.length," step",e.steps.length!==1?"s":""]})]}),c.jsx("span",{style:{fontSize:11,fontWeight:600,color:r.color,flexShrink:0},children:r.label}),c.jsx(I.MdChevronRight,{size:14,color:"#bdbdbd"})]})}const wi=({records:e,onViewOnCanvas:t})=>{var s;const[n,r]=p.useState(((s=e[0])==null?void 0:s.id)??null),o=e.find(l=>l.id===n)??null,i=[...e].sort((l,d)=>new Date(d.triggeredAt).getTime()-new Date(l.triggeredAt).getTime());return e.length===0?c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:300,color:"#9e9e9e",gap:8},children:[c.jsx(I.MdSchedule,{size:36}),c.jsx("p",{style:{margin:0,fontSize:14},children:"No executions yet"}),c.jsx("p",{style:{margin:0,fontSize:12},children:"Run history will appear here"})]}):c.jsxs("div",{style:{display:"flex",height:"100%",fontFamily:"inherit",border:"1px solid #e0e0e0",borderRadius:8,overflow:"hidden"},children:[c.jsxs("div",{style:{width:260,flexShrink:0,borderRight:"1px solid #e0e0e0",overflowY:"auto",background:"#fafafa"},children:[c.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid #e0e0e0",fontWeight:600,fontSize:13,color:"#212121"},children:["Run History (",e.length,")"]}),i.map(l=>c.jsx(vi,{record:l,selected:l.id===n,onSelect:()=>r(l.id)},l.id))]}),c.jsx("div",{style:{flex:1,overflowY:"auto"},children:o?c.jsxs("div",{children:[c.jsxs("div",{style:{padding:"16px 20px",borderBottom:"1px solid #f0f0f0",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:12},children:[c.jsxs("div",{children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:4},children:[p.cloneElement(Ee[o.status].icon,{color:Ee[o.status].color,size:18}),c.jsx("span",{style:{fontWeight:700,fontSize:15,color:"#212121"},children:Ee[o.status].label})]}),c.jsxs("div",{style:{fontSize:12,color:"#757575",display:"flex",flexDirection:"column",gap:2},children:[c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[c.jsx(I.MdSchedule,{size:13})," ",He(o.triggeredAt),o.completedAt&&` → ${He(o.completedAt)} (${pn(o.triggeredAt,o.completedAt)})`]}),o.triggeredBy&&c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[c.jsx(I.MdPerson,{size:13})," ",o.triggeredBy]})]})]}),t&&c.jsx("button",{onClick:()=>t(o),style:{padding:"6px 12px",border:"1.5px solid #1976d2",borderRadius:6,background:"#fff",color:"#1976d2",fontSize:12,fontWeight:600,cursor:"pointer",flexShrink:0},children:"View on Canvas"})]}),o.error&&c.jsx("div",{style:{margin:"12px 16px",padding:"10px 14px",borderRadius:6,background:"#ffebee",color:"#c62828",fontSize:13},children:o.error}),c.jsxs("div",{children:[c.jsxs("div",{style:{padding:"10px 12px",fontSize:12,fontWeight:600,color:"#757575",borderBottom:"1px solid #f0f0f0"},children:["STEPS (",o.steps.length,")"]}),o.steps.map((l,d)=>c.jsx(mi,{step:l},`${l.nodeId}-${d}`))]}),o.inputs&&Object.keys(o.inputs).length>0&&c.jsx("div",{style:{padding:"10px 16px"},children:c.jsxs("details",{children:[c.jsx("summary",{style:{cursor:"pointer",fontSize:12,fontWeight:600,color:"#757575",marginBottom:6},children:"TRIGGER INPUTS"}),c.jsx("pre",{style:{margin:0,fontSize:11,background:"#f5f5f5",padding:10,borderRadius:4,overflowX:"auto"},children:JSON.stringify(o.inputs,null,2)})]})})]}):c.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"#9e9e9e",fontSize:14},children:"Select a run to see details"})})]})};exports.FlowForgeCanvas=qe;exports.FlowForgeHeader=hn;exports.SubWorkflowPreviewDrawer=gn;exports.WorkflowExecutionHistory=wi;exports.WorkflowTemplateLibrary=yi;
2
+ //# sourceMappingURL=WorkflowExecutionHistory-n2xLZdI9.js.map