@notmrabhi/flowforge 0.1.105 → 0.1.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/WorkflowExecutionHistory-8xEbKYsc.js +2 -0
- package/dist/WorkflowExecutionHistory-8xEbKYsc.js.map +1 -0
- package/dist/{WorkflowExecutionHistory-DYp-l7mk.js → WorkflowExecutionHistory-BA5IpymY.js} +574 -553
- package/dist/WorkflowExecutionHistory-BA5IpymY.js.map +1 -0
- package/dist/buildBackendPayload-C16SLotf.js +378 -0
- package/dist/{buildBackendPayload-DoRFqe2X.js.map → buildBackendPayload-C16SLotf.js.map} +1 -1
- package/dist/buildBackendPayload-CTCfdT8R.js +2 -0
- package/dist/{buildBackendPayload-c7Arn1ji.js.map → buildBackendPayload-CTCfdT8R.js.map} +1 -1
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.d.ts +22 -0
- package/dist/canvas.js +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +10 -0
- package/dist/core.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.js +2 -2
- package/dist/nodeRegistry.d.ts +10 -0
- package/dist/templateRegistry.d.ts +2 -0
- package/package.json +1 -1
- package/dist/WorkflowExecutionHistory-CsBnVxC5.js +0 -2
- package/dist/WorkflowExecutionHistory-CsBnVxC5.js.map +0 -1
- package/dist/WorkflowExecutionHistory-DYp-l7mk.js.map +0 -1
- package/dist/buildBackendPayload-DoRFqe2X.js +0 -2
- package/dist/buildBackendPayload-c7Arn1ji.js +0 -371
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),b=require("react"),he=require("reactflow");require("reactflow/dist/style.css");const ae=require("./GatewayBranchEdge-hUano0YJ.js"),W=require("@mui/material"),zn=require("react-select"),z=require("react-icons/md"),Ln=require("react-icons/gr"),Et=require("react-icons/bi"),Ve=require("./index-BhhUO6Ue.js"),Pn=require("./messages-Bg7b9RbI.js"),kt=require("@mui/material/styles"),J=require("./canvasTokens-gKNYrPl4.js");var Gt=Object.defineProperty,Rn=(e,t,n)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fn=(e,t)=>{for(var n in t)Gt(e,n,{get:t[n],enumerable:!0})},Bn=(e,t,n)=>Rn(e,t+"",n),Yt={};Fn(Yt,{Graph:()=>q,alg:()=>Je,json:()=>qt,version:()=>Wn});var An=Object.defineProperty,Ut=(e,t)=>{for(var n in t)An(e,n,{get:t[n],enumerable:!0})},q=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=xe(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=Dn(this._isDirected,o,i,s);return o=u.v,i=u.w,Object.freeze(u),this._edgeObjs[a]=u,jt(this._preds[i],o),jt(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?Pe(this._isDirected,e):xe(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?Pe(this._isDirected,e):xe(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Pe(this._isDirected,e):xe(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],St(this._preds[s],i),St(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 jt(e,t){e[t]?e[t]++:e[t]=1}function St(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function xe(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 Dn(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 Pe(e,t){return xe(e,t.v,t.w,t.name)}var Wn="4.0.1",qt={};Ut(qt,{read:()=>Un,write:()=>$n});function $n(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Gn(e),edges:Yn(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Gn(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 Yn(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 Un(e){let t=new q(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 Je={};Ut(Je,{CycleException:()=>Ce,bellmanFord:()=>Kt,components:()=>Hn,dijkstra:()=>_e,dijkstraAll:()=>Jn,findCycles:()=>Zn,floydWarshall:()=>er,isAcyclic:()=>nr,postorder:()=>or,preorder:()=>ir,prim:()=>sr,shortestPaths:()=>lr,tarjan:()=>Xt,topsort:()=>Vt});var qn=()=>1;function Kt(e,t,n,r){return Kn(e,String(t),n||qn,r||function(o){return e.outEdges(o)})}function Kn(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,w=g===h.v?h.w:h.v;d({v:g,w})})})};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 Hn(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 Ht=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}},Xn=()=>1;function _e(e,t,n,r){let o=function(i){return e.outEdges(i)};return Vn(e,String(t),n||Xn,r||o)}function Vn(e,t,n,r){let o={},i=new Ht,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 Jn(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=_e(e,o,t,n),r},{})}function Xt(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 Zn(e){return Xt(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}var Qn=()=>1;function er(e,t,n){return tr(e,t||Qn,n||function(r){return e.outEdges(r)})}function tr(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 Ce=class extends Error{constructor(...e){super(...e)}};function Vt(e){let t={},n={},r=[];function o(i){if(i in n)throw new Ce;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 Ce;return r}function nr(e){try{Vt(e)}catch(t){if(t instanceof Ce)return!1;throw t}return!0}function rr(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=Jt(e,l,n==="post",s,i,r,o)}),o}function Jt(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=Jt(e,l,n,r,o,i,s)}),n&&(s=i(s,t))),s}function Zt(e,t,n){return rr(e,t,n,function(r,o){return r.push(o),r},[])}function or(e,t){return Zt(e,t,"post")}function ir(e,t){return Zt(e,t,"pre")}function sr(e,t){let n=new q,r={},o=new Ht,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 lr(e,t,n,r){return ar(e,t,n,r??(o=>{let i=e.outEdges(o);return i??[]}))}function ar(e,t,n,r){if(n===void 0)return _e(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 Kt(e,t,n,r)}return _e(e,t,n,r)}function pe(e,t,n,r){let o=r;for(;e.hasNode(o);)o=Ze(r);return n.dummy=t,e.setNode(o,n),o}function dr(e){let t=new q().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 Qt(e){let t=new q({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 _t(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 Ee(e){let t=me(tn(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 cr(e){let t=e.nodes().map(r=>{let o=e.node(r).rank;return o===void 0?Number.MAX_VALUE:o}),n=Z(Math.min,t);e.nodes().forEach(r=>{let o=e.node(r);Object.hasOwn(o,"rank")&&(o.rank-=n)})}function ur(e){let t=e.nodes().map(s=>e.node(s).rank).filter(s=>s!==void 0),n=Z(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 Ct(e,t,n,r){let o={width:0,height:0};return arguments.length>=4&&(o.rank=n,o.order=r),pe(e,"border",o,t)}function fr(e,t=en){let n=[];for(let r=0;r<e.length;r+=t){let o=e.slice(r,r+t);n.push(o)}return n}var en=65535;function Z(e,t){if(t.length>en){let n=fr(t);return e(...n.map(r=>e(...r)))}else return e(...t)}function tn(e){let t=e.nodes().map(n=>{let r=e.node(n).rank;return r===void 0?Number.MIN_VALUE:r});return Z(Math.max,t)}function hr(e,t){let n={lhs:[],rhs:[]};return e.forEach(r=>{t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function nn(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}}function rn(e,t){return t()}var gr=0;function Ze(e){let t=++gr;return e+(""+t)}function me(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 Te(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Ne(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 pr(e,t){return e.reduce((n,r,o)=>(n[r]=t[o],n),{})}var Oe="\0",br="3.0.0",yr=class{constructor(){Bn(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,xr)),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 xr(e,t){if(e!=="_next"&&e!=="_prev")return t}var mr=yr,vr=()=>1;function wr(e,t){if(e.nodeCount()<=1)return[];let n=kr(e,t||vr);return Er(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function Er(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,Ye(t,n,a)}),(e.outEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),a=l.w,u=e.node(a);u.in-=d,Ye(t,n,u)}),e.removeNode(r.v),s}function kr(e,t){let n=new q,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=jr(o+r+3).map(()=>new mr),s=r+1;return n.nodes().forEach(l=>{Ye(i,s,n.node(l))}),{graph:n,buckets:i,zeroIdx:s}}function Ye(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 jr(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function Sr(e){(e.graph().acyclicer==="greedy"?wr(e,t(e)):_r(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,Ze("rev"))});function t(n){return r=>n.edge(r).weight}}function _r(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 Cr(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 Tr(e){e.graph().dummyChains=[],e.edges().forEach(t=>Nr(e,t))}function Nr(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=pe(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 Or(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 Qe(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=Z(Math.min,s);return l===Number.POSITIVE_INFINITY&&(l=0),o.rank=l}e.sources().forEach(n)}function ge(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var on=Ir;function Ir(e){let t=new q({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(;Mr(t,e)<o&&(i=zr(t,e),!!i);)s=t.hasNode(i.v)?ge(e,i):-ge(e,i),Lr(t,e,s);return t}function Mr(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)&&!ge(t,i)&&(e.setNode(l,{}),e.setEdge(r,l,{}),n(l))})}return e.nodes().forEach(n),e.nodeCount()}function zr(e,t){return t.edges().reduce((n,r)=>{let o=Number.POSITIVE_INFINITY;return e.hasNode(r.v)!==e.hasNode(r.w)&&(o=ge(t,r)),o<n[0]?[o,r]:n},[Number.POSITIVE_INFINITY,null])[1]}function Lr(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Pr,postorder:Rr}=Je,Fr=ce;ce.initLowLimValues=tt;ce.initCutValues=et;ce.calcCutValue=sn;ce.leaveEdge=an;ce.enterEdge=dn;ce.exchangeEdges=cn;function ce(e){e=dr(e),Qe(e);let t=on(e);tt(t),et(t,e);let n,r;for(;n=an(t);)r=dn(t,e,n),cn(t,e,n,r)}function et(e,t){let n=Rr(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(r=>Br(e,t,r))}function Br(e,t,n){let r=e.node(n).parent,o=e.edge(n,r);o.cutvalue=sn(e,t,n)}function sn(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,Dr(e,n,u)){let g=e.edge(n,u).cutvalue;s+=f?-g:g}}}),s}function tt(e,t){arguments.length<2&&(t=e.nodes()[0]),ln(e,{},1,t)}function ln(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=ln(e,t,n,d,r))}),s.low=i,s.lim=n++,o?s.parent=o:delete s.parent,n}function an(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function dn(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===Nt(e,e.node(a.v),l)&&d!==Nt(e,e.node(a.w),l)).reduce((a,u)=>ge(t,u)<ge(t,a)?u:a)}function cn(e,t,n,r){let o=n.v,i=n.w;e.removeEdge(o,i),e.setEdge(r.v,r.w,{}),tt(e),et(e,t),Ar(e,t)}function Ar(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=Pr(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 Dr(e,t,n){return e.hasEdge(t,n)}function Nt(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Wr=$r;function $r(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Ot(e);break;case"tight-tree":Yr(e);break;case"longest-path":Gr(e);break;case"none":break;default:Ot(e)}}var Gr=Qe;function Yr(e){Qe(e),on(e)}function Ot(e){Fr(e)}var Ur=qr;function qr(e){let t=Hr(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=Kr(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 Kr(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 Hr(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(Oe).forEach(r),t}function Xr(e){let t=pe(e,"root",{},"_root"),n=Vr(e),r=Object.values(n),o=Z(Math.max,r)-1,i=2*o+1;e.graph().nestingRoot=t,e.edges().forEach(l=>e.edge(l).minlen*=i);let s=Jr(e)+1;e.children(Oe).forEach(l=>un(e,t,i,s,o,n,l)),e.graph().nodeRankFactor=i}function un(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=Ct(e,"_bt"),u=Ct(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;un(e,t,n,r,o,i,h);let w=e.node(h),m=w.borderTop?w.borderTop:h,p=w.borderBottom?w.borderBottom:h,k=w.borderTop?r:2*r,E=m!==p?1:o-((g=i[s])!=null?g:0)+1;e.setEdge(a,m,{weight:k,minlen:E,nestingEdge:!0}),e.setEdge(p,u,{weight:k,minlen:E,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,a,{weight:0,minlen:o+((l=i[s])!=null?l:0)})}function Vr(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(Oe).forEach(r=>n(r,1)),t}function Jr(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Zr(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(n=>{e.edge(n).nestingEdge&&e.removeEdge(n)})}var Qr=eo;function eo(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)It(e,"borderLeft","_bl",n,o,i),It(e,"borderRight","_br",n,o,i)}}e.children(Oe).forEach(t)}function It(e,t,n,r,o,i){let s={width:0,height:0,rank:i,borderType:t},l=o[t][i-1],d=pe(e,"border",s,n);o[t][i]=d,e.setParent(d,r),l&&e.setEdge(l,d,{weight:1})}function to(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="lr"||n==="rl")&&fn(e)}function no(e){var t;let n=(t=e.graph().rankdir)==null?void 0:t.toLowerCase();(n==="bt"||n==="rl")&&ro(e),(n==="lr"||n==="rl")&&(oo(e),fn(e))}function fn(e){e.nodes().forEach(t=>Mt(e.node(t))),e.edges().forEach(t=>Mt(e.edge(t)))}function Mt(e){let t=e.width;e.width=e.height,e.height=t}function ro(e){e.nodes().forEach(t=>Fe(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Fe),Object.hasOwn(r,"y")&&Fe(r)})}function Fe(e){e.y=-e.y}function oo(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 io(e){let t={},n=e.nodes().filter(l=>!e.children(l).length),r=n.map(l=>e.node(l).rank),o=Z(Math.max,r),i=me(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 so(e,t){let n=0;for(let r=1;r<t.length;++r)n+=lo(e,t[r-1],t[r]);return n}function lo(e,t,n){let r=pr(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 ao(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 co(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 uo(r)}function uo(e){let t=[];function n(o){return i=>{i.merged||(i.barycenter===void 0||o.barycenter===void 0||i.barycenter>=o.barycenter)&&fo(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=>Te(o,["vs","i","barycenter","weight"]))}function fo(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 ho(e,t){let n=hr(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(go(!!t)),d=zt(i,o,d),r.forEach(u=>{d+=u.vs.length,i.push(u.vs),s+=u.barycenter*u.weight,l+=u.weight,d=zt(i,o,d)});let a={vs:i.flat(1)};return l&&(a.barycenter=s/l,a.weight=l),a}function zt(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 go(e){return(t,n)=>t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}function hn(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=ao(e,o);a.forEach(h=>{if(e.children(h.v).length){let g=hn(e,h.v,n,r);d[h.v]=g,Object.hasOwn(g,"barycenter")&&bo(h,g)}});let u=co(a,n);po(u,d);let f=ho(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]),w=e.predecessors(l),m=e.node(w[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+g.order+m.order)/(f.weight+2),f.weight+=2}}return f}function po(e,t){e.forEach(n=>{n.vs=n.vs.flatMap(r=>t[r]?t[r].vs:r)})}function bo(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 yo(e,t,n,r){r||(r=e.nodes());let o=xo(e),i=new q({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 xo(e){let t;for(;e.hasNode(t=Ze("_root")););return t}function mo(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 gn(e,t={}){if(typeof t.customOrder=="function"){t.customOrder(e,gn);return}let n=tn(e),r=Lt(e,me(1,n+1),"inEdges"),o=Lt(e,me(n-1,-1,-1),"outEdges"),i=io(e);if(Pt(e,i),t.disableOptimalOrderHeuristic)return;let s=Number.POSITIVE_INFINITY,l,d=t.constraints||[];for(let a=0,u=0;u<4;++a,++u){vo(a%2?r:o,a%4>=2,d),i=Ee(e);let f=so(e,i);f<s?(u=0,l=Object.assign({},i),s=f):f===s&&(l=structuredClone(i))}Pt(e,l)}function Lt(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 yo(e,i,n,r.get(i)||[])})}function vo(e,t,n){let r=new q;e.forEach(function(o){n.forEach(l=>r.setEdge(l.left,l.right));let i=o.graph().root,s=hn(o,i,r,t);s.vs.forEach((l,d)=>o.node(l).order=d),mo(o,r,s.vs)})}function Pt(e,t){Object.values(t).forEach(n=>n.forEach((r,o)=>e.node(r).order=o))}function wo(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=ko(e,u),g=h?e.node(h).order:d;(h||u===a)&&(i.slice(l,f+1).forEach(w=>{let m=e.predecessors(w);m&&m.forEach(p=>{let k=e.node(p),E=k.order;(E<s||g<E)&&!(k.dummy&&e.node(w).dummy)&&pn(n,p,w)})}),l=f+1,s=g)}),i}return t.length&&t.reduce(r),n}function Eo(e,t){let n={};function r(i,s,l,d,a){me(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 w=e.node(g);w.dummy&&(w.order<d||w.order>a)&&pn(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 ko(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(r=>e.node(r).dummy)}}function pn(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 jo(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 So(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,w)=>{let m=s[g],p=s[w];return(m!==void 0?m:0)-(p!==void 0?p:0)}),h=(f.length-1)/2;for(let g=Math.floor(h),w=Math.ceil(h);g<=w;++g){let m=f[g];if(m===void 0)continue;let p=s[m];if(p!==void 0&&i[a]===a&&d<p&&!jo(n,a,m)){let k=o[m];k!==void 0&&(i[m]=a,i[a]=o[a]=k,d=p)}}}})}),{root:o,align:i}}function _o(e,t,n,r,o=!1){let i={},s=Co(e,t,n,o),l=o?"borderLeft":"borderRight";function d(g,w){let m=s.nodes().slice(),p={},k=m.pop();for(;k;){if(p[k])g(k);else{p[k]=!0,m.push(k);for(let E of w(k))m.push(E)}k=m.pop()}}function a(g){let w=s.inEdges(g);w?i[g]=w.reduce((m,p)=>{var k;let E=(k=i[p.v])!=null?k:0,O=s.edge(p);return Math.max(m,E+(O!==void 0?O:0))},0):i[g]=0}function u(g){let w=s.outEdges(g),m=Number.POSITIVE_INFINITY;w&&(m=w.reduce((k,E)=>{let O=i[E.w],L=s.edge(E);return Math.min(k,(O!==void 0?O:0)-(L!==void 0?L:0))},Number.POSITIVE_INFINITY));let p=e.node(g);m!==Number.POSITIVE_INFINITY&&p.borderType!==l&&(i[g]=Math.max(i[g]!==void 0?i[g]:0,m))}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 w;let m=n[g];m!==void 0&&(i[g]=(w=i[m])!=null?w:0)}),i}function Co(e,t,n,r){let o=new q,i=e.graph(),s=Mo(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 To(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=zo(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 No(e,t){let n=Object.values(t),r=Z(Math.min,n),o=Z(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-Z(Math.min,a);s!=="l"&&(u=o-Z(Math.max,a)),u&&(e[l]=Ne(d,f=>f+u))})})}function Oo(e,t=void 0){let n=e.ul;return n?Ne(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 Io(e){let t=Ee(e),n=Object.assign(wo(e,t),Eo(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=So(e,o,n,u=>(s==="u"?e.predecessors(u):e.successors(u))||[]),a=_o(e,o,d.root,d.align,l==="r");l==="r"&&(a=Ne(a,u=>-u)),r[s+l]=a})});let i=To(e,r);return No(r,i),Oo(r,e.graph().align)}function Mo(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 zo(e,t){return e.node(t).width}function Lo(e){e=Qt(e),Po(e),Object.entries(Io(e)).forEach(([t,n])=>e.node(t).x=n)}function Po(e){let t=Ee(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 Ro(e,t={}){let n=t.debugTiming?nn:rn;return n("layout",()=>{let r=n(" buildLayoutGraph",()=>qo(e));return n(" runLayout",()=>Fo(r,n,t)),n(" updateInputGraph",()=>Bo(e,r)),r})}function Fo(e,t,n){t(" makeSpaceForEdgeLabels",()=>Ko(e)),t(" removeSelfEdges",()=>ni(e)),t(" acyclic",()=>Sr(e)),t(" nestingGraph.run",()=>Xr(e)),t(" rank",()=>Wr(Qt(e))),t(" injectEdgeLabelProxies",()=>Ho(e)),t(" removeEmptyRanks",()=>ur(e)),t(" nestingGraph.cleanup",()=>Zr(e)),t(" normalizeRanks",()=>cr(e)),t(" assignRankMinMax",()=>Xo(e)),t(" removeEdgeLabelProxies",()=>Vo(e)),t(" normalize.run",()=>Tr(e)),t(" parentDummyChains",()=>Ur(e)),t(" addBorderSegments",()=>Qr(e)),t(" order",()=>gn(e,n)),t(" insertSelfEdges",()=>ri(e)),t(" adjustCoordinateSystem",()=>to(e)),t(" position",()=>Lo(e)),t(" positionSelfEdges",()=>oi(e)),t(" removeBorderNodes",()=>ti(e)),t(" normalize.undo",()=>Or(e)),t(" fixupEdgeLabelCoords",()=>Qo(e)),t(" undoCoordinateSystem",()=>no(e)),t(" translateGraph",()=>Jo(e)),t(" assignNodeIntersects",()=>Zo(e)),t(" reversePoints",()=>ei(e)),t(" acyclic.undo",()=>Cr(e))}function Bo(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 Ao=["nodesep","edgesep","ranksep","marginx","marginy"],Do={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},Wo=["acyclicer","ranker","rankdir","align","rankalign"],$o=["width","height","rank"],Rt={width:0,height:0},Go=["minlen","weight","width","height","labeloffset"],Yo={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Uo=["labelpos"];function qo(e){let t=new q({multigraph:!0,compound:!0}),n=De(e.graph());return t.setGraph(Object.assign({},Do,Ae(n,Ao),Te(n,Wo))),e.nodes().forEach(r=>{let o=De(e.node(r)),i=Ae(o,$o);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=De(e.edge(r));t.setEdge(r,Object.assign({},Yo,Ae(o,Go),Te(o,Uo)))}),t}function Ko(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 Ho(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};pe(e,"edge-proxy",o,"_ep")}})}function Xo(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 Vo(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 Jo(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 Zo(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(_t(r,i)),n.points.push(_t(o,s))})}function Qo(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 ei(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function ti(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 ni(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 ri(e){Ee(e).forEach(t=>{let n=0;t.forEach((r,o)=>{let i=e.node(r);i.order=o+n,(i.selfEdges||[]).forEach(s=>{pe(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 oi(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 Ae(e,t){return Ne(Te(e,t),Number)}function De(e){let t={};return e&&Object.entries(e).forEach(([n,r])=>{typeof n=="string"&&(n=n.toLowerCase()),t[n]=r}),t}function ii(e){let t=Ee(e),n=new q({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 si={graphlib:Yt,version:br,layout:Ro,debug:ii,util:{time:nn,notime:rn}},Ft=si;/*! For license information please see dagre.esm.js.LEGAL.txt */const li=e=>{const t=[];return e.nodeInternals.forEach((n,r)=>t.push(`${r}:${n.height??0}`)),t.join(",")},ai=({onHeightsReady:e,nodeCount:t})=>{const n=he.useStore(li),r=b.useRef("");b.useRef(0);const{fitView:o}=he.useReactFlow();return b.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},di={gray:{bg:"#f1f5f9",fg:"#475569"},green:{bg:"#dcfce7",fg:"#166534"},amber:{bg:"#fef3c7",fg:"#92400e"},red:{bg:"#fee2e2",fg:"#991b1b"}};function bn({workflowName:e,onWorkflowNameChange:t,status:n,statusColor:r="gray",onSave:o,onCancel:i,saveLabel:s="Save",saveDisabled:l=!1}){const[d,a]=b.useState(!1),[u,f]=b.useState(!1),[h,g]=b.useState(e??"");b.useEffect(()=>{g(e??"")},[e]);const w=async()=>{if(!(!o||d||l)){a(!0);try{await o()}finally{a(!1)}}},m=di[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:p=>g(p.target.value),onBlur:()=>{f(!1),h!==e&&t(h)},onKeyDown:p=>{p.key==="Enter"&&p.target.blur(),p.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:m.bg,color:m.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:w,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 ve=({isOpen:e,onClose:t,title:n,icon:r,children:o,footer:i,width:s=720})=>{const[l,d]=b.useState(!1),a=()=>d(h=>!h),u=()=>c.jsxs(W.Box,{sx:{display:"flex",alignItems:"center",p:2,pt:3,borderBottom:"1px solid #e0e0e0",mb:0,flexShrink:0},children:[r&&c.jsx(W.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(W.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(W.IconButton,{onClick:t,size:"small","data-testid":"close-drawer-button",children:c.jsx(z.MdClose,{})})]}),f=()=>i?c.jsx(W.Box,{sx:{flexShrink:0,p:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:2},children:i}):null;return l?c.jsxs(W.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(W.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),c.jsx(f,{})]}):c.jsxs(W.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(W.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),c.jsx(f,{})]})},ci=({open:e,templates:t,messages:n,onSelect:r,onClose:o,loadTriggerSources:i})=>{const[s,l]=b.useState("trigger"),[d,a]=b.useState(null),[u,f]=b.useState([]),[h,g]=b.useState([]),[w,m]=b.useState(!1),[p,k]=b.useState(null);b.useEffect(()=>{e||(l("trigger"),a(null),f([]),g([]),m(!1),k(null))},[e]);const E=b.useCallback(async P=>{if(!i){r(P);return}a(P),m(!0),k(null);try{const M=await i(P.triggerKey);if(!M||M.length===0){r(P);return}f(M),l("sources")}catch(M){k(M instanceof Error?M.message:"Failed to load sources.")}finally{m(!1)}},[i,r]),O=()=>{l("trigger"),a(null),f([]),g([]),k(null)},L=()=>{d&&r(d,h)},D=s==="sources"&&d,G=D?c.jsxs(c.Fragment,{children:[c.jsx(W.Button,{type:"button",variant:"outlined",size:"small",onClick:O,children:n.cancel??"Back"}),c.jsx(W.Button,{type:"button",variant:"contained",size:"small",onClick:L,disabled:h.length===0,children:n.save??"Continue"})]}):null;return c.jsx(ve,{isOpen:e,onClose:o,title:D?d.label:n.addTriggerTitle,icon:c.jsx(Ln.GrTrigger,{}),width:500,footer:G,children:c.jsxs(W.Box,{sx:{p:2},children:[!D&&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(P=>c.jsxs("div",{className:"ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-start ff-gap-3",style:{cursor:w?"wait":"pointer",transition:"background 0.15s",opacity:w?.6:1},onClick:()=>!w&&E(P),role:"button",tabIndex:0,onKeyDown:M=>{M.key==="Enter"&&!w&&E(P)},onMouseEnter:M=>{w||(M.currentTarget.style.background="#f5f5f5")},onMouseLeave:M=>{M.currentTarget.style.background=""},children:[c.jsx("div",{style:{color:P.triggerCategory==="scheduler"?"#1976d2":"#f57c00",marginTop:2,flexShrink:0},children:P.triggerCategory==="scheduler"?c.jsx(z.MdCalendarToday,{size:18}):c.jsx(z.MdBolt,{size:18})}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:P.label}),P.description&&c.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:P.description})]})]},P.triggerKey)),t.length===0&&c.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:n.noTriggers})]}),w&&c.jsxs(W.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:2,fontSize:12,color:"#64748b"},children:[c.jsx(W.CircularProgress,{size:14}),c.jsx("span",{children:"Loading sources for the selected trigger…"})]}),p&&c.jsx("p",{style:{fontSize:12,color:"#d32f2f",marginTop:12},children:p})]}),D&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{role:"button",tabIndex:0,onClick:O,onKeyDown:P=>{P.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(z.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(zn,{isMulti:!0,options:u,value:h,onChange:P=>g(P??[]),placeholder:"Select sources…",menuPosition:"fixed",menuPortalTarget:typeof document<"u"?document.body:void 0,styles:Ve.buildSelectStyles(!1,!0)})]})]})})},We={cursor:"pointer",transition:"background 0.15s"},$e="ff-p-3 ff-rounded ff-border ff-d-flex ff-align-items-center ff-gap-3",ui=({open:e,availableDescriptors:t,messages:n,onSelect:r,onClose:o})=>{const{apps:i,ungrouped:s}=b.useMemo(()=>{const f=new Map,h=[];for(const g of t)if(g.app){const w=f.get(g.app.key);w?w.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]=b.useState(null),a=l?i.find(f=>f.key===l)??null:null;b.useEffect(()=>{e||d(null)},[e]),b.useEffect(()=>{d(null)},[t]);const u=!a;return c.jsx(ve,{isOpen:e,onClose:o,title:u?n.addStepTitle:a.label,icon:u?c.jsx(z.MdAddCircleOutline,{}):a.icon??c.jsx(z.MdApps,{}),width:500,children:c.jsxs(W.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(z.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:$e,style:We,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(z.MdChevronRight,{size:18,color:"#9e9e9e"})]},`app-${f.key}`)),s.map(f=>c.jsxs("div",{className:$e,style:We,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:$e,style:We,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";function At(e){return Array.isArray(e)?{layout:"flat",fields:e}:e&&typeof e=="object"?e:{layout:"flat",fields:[]}}function Dt(e){return e.layout==="stepper"?Array.isArray(e.steps)&&e.steps.some(t=>{var n;return((n=t.fields)==null?void 0:n.length)>0}):Array.isArray(e.fields)&&e.fields.length>0}const fi=({open:e,nodeId:t,descriptor:n,initialValues:r,messages:o,onSave:i,onClose:s})=>{const[l,d]=b.useState({layout:"flat",fields:[]}),[a,u]=b.useState(!1),[f,h]=b.useState(null),[g,w]=b.useState({});b.useEffect(()=>{w((r==null?void 0:r[Bt])??{})},[r,t]),b.useEffect(()=>{let E=!1;if(h(null),!n||!t||n.customPanel){d({layout:"flat",fields:[]}),u(!1);return}const O=n.formSchema;return typeof O=="function"?(u(!0),O(t).then(L=>{E||(d(At(L)),u(!1))}).catch(L=>{E||(d({layout:"flat",fields:[]}),h(L instanceof Error?L.message:"Unable to load configuration."),u(!1))})):(d(At(O)),u(!1)),()=>{E=!0}},[n,t]);const m=t?`node-config-form-${t}`:"node-config-form",p=!a&&!f&&Dt(l),k=p?c.jsxs(c.Fragment,{children:[c.jsx(W.Button,{type:"button",variant:"text",size:"small",sx:{textTransform:"none",color:"#475569"},onClick:s,children:o.cancel}),c.jsx(W.Button,{type:"submit",form:m,variant:"contained",size:"small",disableElevation:!0,sx:{textTransform:"none",boxShadow:"none","&:hover":{boxShadow:"none",filter:"brightness(0.94)"}},children:o.save})]}):null;return n!=null&&n.customPanel&&t?c.jsx(ve,{isOpen:e,onClose:s,title:n.label??o.configureStep,icon:n.icon,width:500,children:n.customPanel({nodeId:t,data:r??{},onSave:E=>{i(t,E),s()},onClose:s})}):c.jsx(ve,{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(W.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&&!Dt(l)&&c.jsx("p",{className:"ff-text-muted",style:{fontSize:13},children:o.noConfigurationNeeded}),p&&c.jsx(Ve.FlowForm,{schema:l,initialValues:r??{},formId:m,conditionConfig:g,onConditionConfigChange:w,onSubmit:E=>{if(!t)return;const O=Object.keys(g).length>0;i(t,{...E,[Bt]:O?g:void 0}),s()}})]})})},yn=({isOpen:e,onClose:t,workflowId:n,workflowLabel:r,onFetchWorkflow:o})=>{const[i,s]=b.useState({status:"idle"});return b.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(ve,{isOpen:e,onClose:t,title:r?`Preview: ${r}`:"Sub-Workflow Preview",icon:c.jsx(z.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(z.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(hi,{state:i.state})})]})})},hi=({state:e})=>{const[t,n]=b.useState(null),[r,o]=b.useState(null);return b.useEffect(()=>{Promise.all([Promise.resolve().then(()=>mi).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})})},we=350,Ue=70,qe=60,Ke={startNode:40,endNode:40,addTriggerNode:56,triggerNode:110,actionNode:90,filterNode:90,approvalNode:90,delayNode:80,notificationNode:80},gi={plusEdge:ae.PlusEdge,labelPlusEdge:ae.LabelPlusEdge,plainEdge:ae.PlainEdge,edgeWithPlusLabel:ae.EdgeWithPlusLabel,gatewayBranchEdge:ae.GatewayBranchEdge};function Wt(){return[{id:"start",kind:"start",reactFlowType:"startNode"},{id:"addTrigger",kind:"addTrigger",reactFlowType:"addTriggerNode"},{id:"end",kind:"end",reactFlowType:"endNode"}]}function pi(e,t,n,r="TB"){const o=new Ft.graphlib.Graph;return o.setGraph({rankdir:r,ranksep:70,nodesep:50}),o.setDefaultEdgeLabel(()=>({})),e.forEach(i=>{const s=n[i.id]??{width:we,height:Ke[i.type??""]??80};o.setNode(i.id,{width:s.width,height:s.height})}),t.forEach(i=>o.setEdge(i.source,i.target)),Ft.layout(o),e.map(i=>{var a,u;const s=o.node(i.id),l=((a=n[i.id])==null?void 0:a.width)??we,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 de=e=>e==="filter"||e==="approval";function bi(e,t,n,r){const s=Ue,l=30,d=30,a={},u={},f=new Map;for(const p of e)f.set(p.id,p);for(const p of Object.values(t))for(const k of Object.values(p))for(const E of k)f.set(E.id,E);const h=(p,k,E)=>{const O=r[p]??{width:we,height:80};return a[p]={x:k-O.width/2,y:E},E+O.height},g=(p,k,E)=>{let O=E;for(const L of p)O=h(L.id,k,O)+s,de(L.kind)&&t[L.id]&&(O=w(L.id,k,O));return O},w=(p,k,E)=>{const O=k+180,L=t[p],D=Object.keys(L),G=f.get(p),P=(G==null?void 0:G.branchLabels)??{pass:"Pass",fail:"Fail"},M=a[p],K=r[p]??{height:80},ee=M.y+K.height;if((G==null?void 0:G.branchStyle)==="inline-gate"){const te=[];let X=E;D.slice(1).forEach(oe=>{te.push({y:X-ee,label:P[oe]??oe,isPass:!1}),X=g(L[oe],O,X+d)+l});const be=g(L[D[0]],k,E);return u[p]={branches:te,height:X-ee,indent:180},Math.max(be,X)}const re=[];let R=E;return D.forEach((te,X)=>{const be=L[te],oe=R;re.push({y:oe-ee,label:P[te]??te,isPass:X===0}),R=g(be,O,R+d),X<D.length-1&&(R+=l)}),u[p]={branches:re,height:R-ee,indent:180},R};let m=qe;for(const p of e)m=h(p.id,400,m)+s,de(p.kind)&&t[p.id]&&(m=w(p.id,400,m));return{nodes:n.map(p=>a[p.id]?{...p,position:a[p.id]}:p),railSpecs:u}}function $t(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 yi(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 xi(e,t,n,r,o={},i="TB",s="horizontal"){const l=o.edgeColor??"#b0bec5",d=[],a=[],u=(m,p,k)=>{const E=t[m];if(!E)return;const L=p??{pass:"Pass",fail:"Fail"},D=Object.keys(E),G=k==="inline-gate",P=(M,K,ee,re)=>{if(M.length!==0){M.forEach(R=>d.push($t(R))),G&&re===0?a.push({id:`e-${m}-${K}-start`,source:m,target:M[0].id,type:"plusEdge",style:{stroke:l},data:{onAddStepClick:n,referenceNodeType:"filterNode",filterId:m,branch:K}}):a.push({id:`e-${m}-${K}-start`,source:m,target:M[0].id,type:"gatewayBranchEdge",style:{stroke:l},data:{branch:K,filterId:m,label:ee,isFirst:re===0,onAddStepClick:n,verticalRouting:s==="vertical"||G}});for(let R=1;R<M.length;R++)de(M[R-1].kind)||a.push(yi(M[R-1],M[R],l,n,{filterId:m,branch:K}));for(const R of M)de(R.kind)&&t[R.id]&&u(R.id,R.branchLabels,R.branchStyle)}};D.forEach((M,K)=>{P(E[M],M,L[M]??M,K)})};for(let m=0;m<e.length;m++){const p=e[m];if(d.push($t(p)),m>0){const k=e[m-1],E=k.kind==="start"||k.kind==="addTrigger";if(k.kind==="filter"||k.kind==="approval")continue;a.push({id:`e-${k.id}-${p.id}`,source:k.id,target:p.id,type:E?"plainEdge":"plusEdge",style:{stroke:l},data:E?{}:{onAddStepClick:n,referenceNodeType:k.reactFlowType}})}(p.kind==="filter"||p.kind==="approval")&&t[p.id]&&u(p.id,p.branchLabels,p.branchStyle)}const f={};if(d.forEach(m=>{f[m.id]={width:we,height:r[m.id]??Ke[m.type??""]??80}}),!(Object.keys(t).length>0)){if(i==="LR"){let O=qe;return{nodes:d.map(D=>{const G=f[D.id].width,P=f[D.id].height,M={...D,position:{x:O,y:300-P/2}};return O+=G+Ue,M}),edges:a}}const m=400;let p=qe;return{nodes:d.map(E=>{const O=f[E.id].height,L={...E,position:{x:m-we/2,y:p}};return p+=O+Ue,L}),edges:a}}const g=e.some(m=>m.branchStyle==="inline-gate")||Object.values(t).some(m=>Object.values(m).flat().some(p=>p.branchStyle==="inline-gate"));if(s==="vertical"||g){const{nodes:m,railSpecs:p}=bi(e,t,d,f);return{nodes:m.map(E=>p[E.id]?{...E,data:{...E.data,_branchRail:p[E.id]}}:E),edges:a}}return{nodes:pi(d,a,f,i),edges:a}}const He=({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:w,maxNodes:m,layoutDirection:p="TB",executionRecord:k,onFetchWorkflow:E,hideHeader:O=!1,workflowName:L,onWorkflowNameChange:D,onCancel:G,workflowStatus:P,workflowStatusColor:M,saveLabel:K,optionsResolvers:ee})=>{const{fitView:re=!0,fitViewPadding:R=.3,showControls:te=!0,showMiniMap:X=!1,panOnScroll:be=!0,zoomOnScroll:oe=!1,minZoom:mn=.25,maxZoom:vn=2,snapToGrid:wn=!1,snapGrid:En=[15,15],branchLayout:nt="horizontal",nodeBody:rt="full"}=a,ye=b.useMemo(()=>Pn.mergeMessages(d),[d]),[F,ie]=b.useState(()=>(n==null?void 0:n.slots)??Wt()),[Y,Q]=b.useState(()=>(n==null?void 0:n.branches)??{}),[ue,H]=b.useState(null),[Ie,ot]=b.useState(null),[V,ke]=b.useState(null),[se,it]=b.useState(null),[je,st]=b.useState(null),[I,lt]=b.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}),[at,kn]=b.useState({}),jn=b.useCallback(x=>{kn(x)},[]),Sn=b.useMemo(()=>({...ae.builtInNodeTypes,...r}),[r]),_n=b.useMemo(()=>({...gi,...o}),[o]),Cn=b.useMemo(()=>{const x=F.filter(S=>S.kind==="userTask").length,v=Object.values(Y).flatMap(S=>Object.values(S).flat()).filter(S=>S.kind==="userTask").length;return x+v},[F,Y]),dt=m??(I==null?void 0:I.maxTasks),ct=dt!==void 0&&Cn>=dt,le=b.useCallback(x=>{const v=F.find(S=>S.id===x);if(v)return v;for(const S of Object.values(Y)){const C=Object.values(S).flat().find(T=>T.id===x);if(C)return C}return null},[F,Y]),Me=b.useCallback(x=>{s||(ot(x),H("nodeConfig"))},[s]),ut=b.useCallback(x=>{if(!s){if(F.some(v=>v.id===x)){const v=F.find(S=>S.id===x);if((v==null?void 0:v.kind)==="triggerFixed"){ie(Wt()),Q({}),lt(null);return}ie(S=>{const C=S.filter(T=>T.id!==x);return de((v==null?void 0:v.kind)??"")&&!C.some(T=>T.kind==="end")?[...C,{id:"end",kind:"end",reactFlowType:"endNode"}]:C}),Q(S=>{const C={...S},T=y=>{C[y]&&(Object.values(C[y]).flat().filter(j=>de(j.kind)).forEach(j=>T(j.id)),delete C[y])};return T(x),C});return}Q(v=>{const S=(T,y)=>{const j=[];for(const _ of T)de(_.kind)&&y[_.id]&&(j.push(_.id),Object.values(y[_.id]).forEach(N=>j.push(...S(N,y))));return j},C={...v};for(const T of Object.keys(C))for(const y of Object.keys(C[T])){const j=C[T][y],_=j.findIndex(B=>B.id===x);if(_===-1||j[_].kind==="end")continue;const N=j[_];let A=j.filter(B=>B.id!==x);return N.kind==="filter"&&((N.id in C?S([N],C):[]).forEach($=>delete C[$]),delete C[N.id],A.some($=>$.kind==="end")||(A=[...A,{id:`end-${T}-${y}`,kind:"end",reactFlowType:"endNode"}])),C[T]={...C[T],[y]:A},C}return C})}},[s,F]),ze=b.useCallback(()=>{s||H("triggerSelect")},[s]),ft=b.useCallback((x,v)=>{s||ct||(ke(x),it(v.filterId&&v.branch?{filterId:v.filterId,branch:v.branch}:null),H("nodePicker"))},[s,ct]),ht=b.useCallback((x,v)=>{if(lt(x),H(null),x.skeletonState){const C=Array.isArray(v)&&v.length>0,T=(x.skeletonState.slots??[]).map(y=>y.kind!=="triggerFixed"?y:{...y,nodeData:{label:x.label,...y.nodeData??{},...C&&{sources:v}}});Q(x.skeletonState.branches??{}),ie(T);return}Q({});const S=Array.isArray(v)&&v.length>0;ie([{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"}])},[]),gt=b.useCallback(()=>{var S;const x={insertAfterSlot:null,upstreamSlots:[],downstreamSlots:[],branch:se,template:I};if(!V)return x;if(se){const{filterId:C,branch:T}=se,y=F.findIndex(B=>B.id===C),j=y>=0?F.slice(0,y+1):[],_=((S=Y[C])==null?void 0:S[T])??[],N=_.findIndex(B=>B.id===V),A=N>=0?_.slice(0,N+1):[];return x.upstreamSlots=[...j,...A],x.downstreamSlots=N>=0?_.slice(N+1):_,x.insertAfterSlot=A[A.length-1]??null,x}const v=F.findIndex(C=>C.id===V);return x.upstreamSlots=v>=0?F.slice(0,v+1):[],x.downstreamSlots=v>=0?F.slice(v+1):[],x.insertAfterSlot=x.upstreamSlots[x.upstreamSlots.length-1]??null,x},[F,Y,V,se,I]),Le=(x,v)=>x.descriptorType===v||x.id===v||x.kind===v,pt=b.useCallback(()=>{const x=e.list(),v=I!=null&&I.availableTasks?x.filter(y=>I.availableTasks.includes(y.type)):x,S=gt(),C=[...F,...Object.values(Y).flatMap(y=>Object.values(y).flat())],T=y=>C.some(j=>y.some(_=>Le(j,_)));return v.filter(y=>y.maxPerWorkflow!==void 0&&F.filter(_=>_.descriptorType===y.type).length+Object.values(Y).flatMap(_=>Object.values(_).flat()).filter(_=>_.descriptorType===y.type).length>=y.maxPerWorkflow?!1:y.canInsert?y.canInsert(S):!(y.insertAfter&&y.insertAfter.length>0&&T(y.insertAfter)&&!S.upstreamSlots.some(_=>y.insertAfter.some(N=>Le(_,N)))||y.insertBefore&&y.insertBefore.length>0&&T(y.insertBefore)&&!S.downstreamSlots.some(_=>y.insertBefore.some(N=>Le(_,N)))))},[e,I,F,Y,gt]),bt=b.useCallback(x=>{if(!V)return;const v=`${x.type}-${Date.now()}`,S=x.reactFlowType==="filterNode"||x.reactFlowType==="approvalNode"||x.reactFlowType==="conditionBranchNode",C=x.branchLabels??{pass:"Pass",fail:"Fail"},T={id:v,kind:S?x.reactFlowType==="approvalNode"?"approval":"filter":"userTask",reactFlowType:x.reactFlowType,descriptorType:x.type,formData:{},nodeData:{title:x.label},deletable:!0,branchLabels:C,...x.branchStyle?{branchStyle:x.branchStyle}:{}};if(se){const{filterId:y,branch:j}=se;Q(_=>{const N=[..._[y][j]];if(S){const ne=N.filter(fe=>fe.kind!=="end"),wt=ne.findIndex(fe=>fe.id===V),Mn=wt===-1?ne.length:wt+1;return ne.splice(Mn,0,T),{..._,[y]:{..._[y],[j]:ne},[v]:Object.fromEntries(Object.keys(C).map(fe=>[fe,[{id:`end-${v}-${fe}`,kind:"end",reactFlowType:"endNode"}]]))}}const A=N.findIndex(ne=>ne.id===V),B=N.findIndex(ne=>ne.kind==="end"),$=A===-1?B===-1?N.length:B:A+1;return N.splice($,0,T),{..._,[y]:{..._[y],[j]:N}}})}else S?(ie(y=>{const j=y.findIndex(N=>N.id===V);return[...y.filter(N=>N.kind!=="end").slice(0,j+1),T]}),Q(y=>({...y,[v]:Object.fromEntries(Object.keys(C).map(j=>[j,[{id:`end-${v}-${j}`,kind:"end",reactFlowType:"endNode"}]]))}))):ie(y=>{const j=y.findIndex(_=>_.id===V);return j===-1?y:[...y.slice(0,j+1),T,...y.slice(j+1)]});ke(null),it(null),ot(v),H("nodeConfig")},[V,se]),yt=b.useCallback((x,v)=>{const S=y=>{const j=y.label||y.key;switch(y.kind){case"if":return`IF · ${j}`;case"elseif":return`ELSE IF · ${j}`;case"else":return j.toUpperCase()==="ELSE"?j:`ELSE · ${j}`;default:return j}},C=y=>{const j=le(x);if((j==null?void 0:j.descriptorType)!=="conditionBranch")return y;const N=(v.branchConfigs??[]).map($=>$.key).filter(Boolean);if(N.length===0)return y;const A=y[x]??{},B={};return N.forEach($=>{B[$]=A[$]??[{id:`end-${x}-${$}`,kind:"end",reactFlowType:"endNode"}]}),{...y,[x]:B}},T=(y,j)=>{if(y.descriptorType!=="conditionBranch")return{...y,formData:j};const _=j.branchConfigs??[],N={};return _.forEach(A=>{A.key&&(N[A.key]=S(A))}),{...y,formData:j,branchLabels:N}};if(F.some(y=>y.id===x)){Q(y=>{const j=C(y);return ie(_=>_.map(N=>N.id===x?T(N,v):N)),j});return}Q(y=>{const _={...C(y)};for(const N of Object.keys(_)){const A=B=>B.map($=>$.id===x?T($,v):$);for(const B of Object.keys(_[N]))if(_[N][B].some($=>$.id===x))return _[N]={..._[N],[B]:A(_[N][B])},_}return _})},[F,Y,le]),U=b.useMemo(()=>le(Ie??""),[le,Ie]),xt=b.useMemo(()=>{if((U==null?void 0:U.kind)==="triggerFixed"){const x=(I==null?void 0:I.triggerCategory)==="scheduler",v=(I==null?void 0:I.triggerConfigTitle)??(x?"Scheduler":I==null?void 0:I.label)??"Trigger",S=I==null?void 0:I.triggerCustomPanel;if(S)return{type:U.id,label:v,icon:I==null?void 0:I.icon,reactFlowType:"triggerNode",formSchema:[],customPanel:({nodeId:T,data:y,onSave:j,onClose:_})=>S({data:y,onSave:j,onClose:_}),matches:()=>!1,bpmnEntry:T=>T,bpmnExit:T=>T,emitBpmnElements:()=>[]};const C=I==null?void 0:I.triggerConfigSchema;return Array.isArray(C)&&C.length>0?{type:U.id,label:v,icon:I==null?void 0:I.icon,reactFlowType:"triggerNode",formSchema:C,matches:()=>!1,bpmnEntry:T=>T,bpmnExit:T=>T,emitBpmnElements:()=>[]}:null}return U!=null&&U.descriptorType?e.forType(U.descriptorType)??null:null},[U,e,I]),{nodes:mt,edges:Tn}=b.useMemo(()=>xi(F,Y,s?null:ft,at,l,p,nt),[F,Y,s,ft,at,l,p,nt]),vt=b.useMemo(()=>{const x=k?new Map(k.steps.map(v=>[v.nodeId,v])):null;return mt.map(v=>{let S={};if(x){const C=x.get(v.id);C&&(S={_executionStatus:C.status,_executionError:C.error})}return v.type==="subWorkflowNode"&&E&&(S.onPreview=C=>{var y;const T=le(v.id);st({workflowId:C,workflowLabel:((y=T==null?void 0:T.formData)==null?void 0:y.workflowLabel)??void 0})}),Object.keys(S).length>0?{...v,data:{...v.data,...S}}:v})},[mt,k,E,le]),Nn=b.useMemo(()=>({onEditNode:Me,onDeleteNode:ut,onAddStep:()=>{},onClickAddTrigger:ze,messages:ye,nodeRegistry:e,nodeBody:rt,activeTemplate:I}),[Me,ut,ze,ye,e,rt,I]),On=b.useCallback(async()=>{i&&await i({slots:F,branches:Y})},[i,F,Y]),In=b.useMemo(()=>kt.createTheme({palette:{primary:{main:l.primaryColor??"#1976d2"},secondary:{main:l.secondaryColor??"#9c27b0"},...l.successColor?{success:{main:l.successColor}}:{},...l.warningColor?{warning:{main:l.warningColor}}:{},...l.dangerColor?{error:{main:l.dangerColor}}:{},...l.textColor?{text:{primary:l.textColor}}:{}},shape:{borderRadius:l.borderRadius??6},typography:l.fontFamily?{fontFamily:l.fontFamily}:{}}),[l]);return c.jsx(kt.ThemeProvider,{theme:In,children:c.jsx(Ve.OptionsResolversProvider,{resolvers:ee,children:c.jsx(ae.WorkflowCanvasContext.Provider,{value:Nn,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||G||L)&&c.jsx(bn,{workflowName:L,onWorkflowNameChange:D,status:P,statusColor:M,onSave:i?On:void 0,onCancel:G,saveLabel:K}),c.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[c.jsxs(he,{nodes:vt,edges:Tn,nodeTypes:Sn,edgeTypes:_n,fitView:re,fitViewOptions:{padding:R},nodesDraggable:!1,nodesConnectable:!1,panOnScroll:be,zoomOnScroll:oe,minZoom:mn,maxZoom:vn,snapToGrid:wn,snapGrid:En,proOptions:{hideAttribution:!0},onNodeClick:(x,v)=>{const S=le(v.id);S&&(w!=null&&w(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(he.Background,{variant:l.background,color:l.backgroundColor??"#e0e0e0",gap:20}),te&&c.jsx(he.Controls,{showInteractive:!1}),X&&c.jsx(he.MiniMap,{zoomable:!0,pannable:!0}),c.jsx(ai,{onHeightsReady:jn,nodeCount:vt.length})]}),u?ue==="triggerSelect"&&u(t.list(),ht,()=>H(null)):c.jsx(ci,{open:ue==="triggerSelect",templates:t.list(),messages:ye,onSelect:ht,onClose:()=>H(null),loadTriggerSources:f}),h?ue==="nodePicker"&&h(pt(),bt,()=>{H(null),ke(null)}):c.jsx(ui,{open:ue==="nodePicker",availableDescriptors:pt(),messages:ye,onSelect:bt,onClose:()=>{H(null),ke(null)}}),g?ue==="nodeConfig"&&g(xt??void 0,U,yt,()=>H(null)):c.jsx(fi,{open:ue==="nodeConfig",nodeId:Ie,descriptor:xt,initialValues:U==null?void 0:U.formData,messages:ye,onSave:yt,onClose:()=>H(null)}),E&&je&&c.jsx(yn,{isOpen:!!je,onClose:()=>st(null),workflowId:je.workflowId,workflowLabel:je.workflowLabel,onFetchWorkflow:E})]})]})})})})},mi=Object.freeze(Object.defineProperty({__proto__:null,WorkflowCanvas:He,default:He},Symbol.toStringTag,{value:"Module"})),Ge="All";function vi({template:e,onSelect:t}){var o,i;const n=e.triggerCategory?J.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 wi=({templates:e,onSelectTemplate:t,onStartFromScratch:n})=>{const[r,o]=b.useState(""),[i,s]=b.useState(Ge),l=b.useMemo(()=>{const a=new Set;return e.forEach(u=>{u.category&&a.add(u.category)}),[Ge,...Array.from(a)]},[e]),d=b.useMemo(()=>{let a=e;if(i!==Ge&&(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(w=>w.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(z.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(z.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(z.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(vi,{template:a,onSelect:()=>t(a)},a.triggerKey))})})]})},Se={running:{label:"Running",color:J.EXECUTION_STATUS_COLOR.running,icon:b.createElement(z.MdPlayArrow,{size:14})},success:{label:"Success",color:J.EXECUTION_STATUS_COLOR.success,icon:b.createElement(z.MdCheckCircle,{size:14})},failed:{label:"Failed",color:J.EXECUTION_STATUS_COLOR.failed,icon:b.createElement(z.MdError,{size:14})},cancelled:{label:"Cancelled",color:J.EXECUTION_STATUS_COLOR.cancelled,icon:b.createElement(z.MdCancel,{size:14})}},Ei={pending:{color:J.EXECUTION_STATUS_COLOR.pending,icon:b.createElement(z.MdHourglassEmpty,{size:14})},running:{color:J.EXECUTION_STATUS_COLOR.running,icon:b.createElement(z.MdPlayArrow,{size:14})},success:{color:J.EXECUTION_STATUS_COLOR.success,icon:b.createElement(z.MdCheckCircle,{size:14})},failed:{color:J.EXECUTION_STATUS_COLOR.failed,icon:b.createElement(z.MdError,{size:14})},skipped:{color:J.EXECUTION_STATUS_COLOR.skipped,icon:b.createElement(z.MdCancel,{size:14})}};function Xe(e){try{return new Date(e).toLocaleString()}catch{return e}}function xn(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 ki({step:e}){const[t,n]=b.useState(!1),r=Ei[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:b.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?xn(e.startedAt,e.completedAt):"—"}),o&&c.jsx("span",{style:{color:"#9e9e9e",flexShrink:0},children:t?b.createElement(z.MdExpandLess,{size:16}):b.createElement(z.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 ji({record:e,selected:t,onSelect:n}){const r=Se[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:b.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:Xe(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(z.MdChevronRight,{size:14,color:"#bdbdbd"})]})}const Si=({records:e,onViewOnCanvas:t})=>{var s;const[n,r]=b.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(z.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(ji,{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:[b.cloneElement(Se[o.status].icon,{color:Se[o.status].color,size:18}),c.jsx("span",{style:{fontWeight:700,fontSize:15,color:"#212121"},children:Se[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(z.MdSchedule,{size:13})," ",Xe(o.triggeredAt),o.completedAt&&` → ${Xe(o.completedAt)} (${xn(o.triggeredAt,o.completedAt)})`]}),o.triggeredBy&&c.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[c.jsx(z.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(ki,{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=He;exports.FlowForgeHeader=bn;exports.SubWorkflowPreviewDrawer=yn;exports.WorkflowExecutionHistory=Si;exports.WorkflowTemplateLibrary=wi;
|
|
2
|
+
//# sourceMappingURL=WorkflowExecutionHistory-8xEbKYsc.js.map
|