@notmrabhi/flowforge 0.1.47 → 0.1.49
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/{SchemaBuilderDrawer-DwpDhvfw.js → SchemaBuilderDrawer-BlL83YY1.js} +2 -2
- package/dist/{SchemaBuilderDrawer-DwpDhvfw.js.map → SchemaBuilderDrawer-BlL83YY1.js.map} +1 -1
- package/dist/{SchemaBuilderDrawer-ZvBnHvoK.js → SchemaBuilderDrawer-CcsuQXAA.js} +2 -2
- package/dist/{SchemaBuilderDrawer-ZvBnHvoK.js.map → SchemaBuilderDrawer-CcsuQXAA.js.map} +1 -1
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.js +1 -1
- package/dist/form.cjs +1 -1
- package/dist/form.js +2 -2
- package/dist/{index-BD74UunS.js → index-Bf1-wgQA.js} +2 -2
- package/dist/{index-BD74UunS.js.map → index-Bf1-wgQA.js.map} +1 -1
- package/dist/{index-B8W6oBhy.js → index-Cp4CA6tn.js} +2 -2
- package/dist/{index-B8W6oBhy.js.map → index-Cp4CA6tn.js.map} +1 -1
- package/dist/{index-DDo516bn.js → index-CvMXmKr6.js} +771 -770
- package/dist/index-CvMXmKr6.js.map +1 -0
- package/dist/{index-3DvBym9i.js → index-le3_BkKg.js} +2 -2
- package/dist/{index-3DvBym9i.js.map → index-le3_BkKg.js.map} +1 -1
- package/dist/{index-Da1aQdfo.js → index-rIRhggmY.js} +2 -2
- package/dist/{index-Da1aQdfo.js.map → index-rIRhggmY.js.map} +1 -1
- package/dist/index-yOtdNWwA.js +10 -0
- package/dist/index-yOtdNWwA.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +44 -0
- package/dist/index.js +132 -96
- package/dist/index.js.map +1 -1
- package/dist/{templateSkeletons-BG1SF0vl.js → templateSkeletons-BSE8YZ80.js} +2 -2
- package/dist/{templateSkeletons-BG1SF0vl.js.map → templateSkeletons-BSE8YZ80.js.map} +1 -1
- package/dist/{templateSkeletons-Bgq5hGIM.js → templateSkeletons-Ct26LDFe.js} +2 -2
- package/dist/{templateSkeletons-Bgq5hGIM.js.map → templateSkeletons-Ct26LDFe.js.map} +1 -1
- package/package.json +1 -1
- package/dist/index-CL2SnGNk.js +0 -10
- package/dist/index-CL2SnGNk.js.map +0 -1
- package/dist/index-DDo516bn.js.map +0 -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-CMY30xhz.js"),P=require("@mui/material"),Cn=require("react-select"),O=require("react-icons/md"),In=require("react-icons/gr"),Et=require("react-icons/bi"),Xe=require("./index-CL2SnGNk.js"),On=require("./messages-O9Tw_XXR.js"),H=require("./canvasTokens-gKNYrPl4.js");var Bt=Object.defineProperty,Mn=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fn=(e,t)=>{for(var n in t)Bt(e,n,{get:t[n],enumerable:!0})},Rn=(e,t,n)=>Mn(e,t+"",n),Wt={};Fn(Wt,{Graph:()=>U,alg:()=>Ve,json:()=>$t,version:()=>zn});var An=Object.defineProperty,Gt=(e,t)=>{for(var n in t)An(e,n,{get:t[n],enumerable:!0})},U=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=Ln(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?Re(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?Re(this._isDirected,e):he(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Re(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 Ln(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 Re(e,t){return he(e,t.v,t.w,t.name)}var zn="4.0.1",$t={};Gt($t,{read:()=>Wn,write:()=>Dn});function Dn(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Pn(e),edges:Bn(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Pn(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 Bn(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 U(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={};Gt(Ve,{CycleException:()=>je,bellmanFord:()=>Ut,components:()=>Un,dijkstra:()=>ke,dijkstraAll:()=>Kn,findCycles:()=>Hn,floydWarshall:()=>Vn,isAcyclic:()=>Zn,postorder:()=>er,preorder:()=>tr,prim:()=>nr,shortestPaths:()=>rr,tarjan:()=>qt,topsort:()=>Kt});var Gn=()=>1;function Ut(e,t,n,r){return $n(e,String(t),n||Gn,r||function(o){return e.outEdges(o)})}function $n(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 Un(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 Yt=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}},Yn=()=>1;function ke(e,t,n,r){let o=function(i){return e.outEdges(i)};return qn(e,String(t),n||Yn,r||o)}function qn(e,t,n,r){let o={},i=new Yt,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 Kn(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=ke(e,o,t,n),r},{})}function qt(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 qt(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 Kt(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{Kt(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 U,r={},o=new Yt,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 Ut(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 U().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 U({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 Tt(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 Te(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 _e="\0",fr="3.0.0",hr=class{constructor(){Rn(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return _t(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&_t(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 _t(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=xr(e,t||br);return mr(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function mr(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],l;for(;e.nodeCount();){for(;l=s.dequeue();)Ae(e,t,n,l);for(;l=i.dequeue();)Ae(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(Ae(e,t,n,l,!0)||[]);break}}}return o}function Ae(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,$e(t,n,a)}),(e.outEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),a=l.w,u=e.node(a);u.in-=d,$e(t,n,u)}),e.removeNode(r.v),s}function xr(e,t){let n=new U,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=wr(o+r+3).map(()=>new pr),s=r+1;return n.nodes().forEach(l=>{$e(i,s,n.node(l))}),{graph:n,buckets:i,zeroIdx:s}}function $e(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 wr(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function vr(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 Tr(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=_r;function _r(e){let t=new U({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(;Nr(t,e)<o&&(i=Cr(t,e),!!i);)s=t.hasNode(i.v)?de(e,i):-de(e,i),Ir(t,e,s);return t}function Nr(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 Cr(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 Ir(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Or,postorder:Mr}=Ve,Fr=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=>Rr(e,t,r))}function Rr(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,Lr(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===Nt(e,e.node(a.v),l)&&d!==Nt(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),Ar(e,t)}function Ar(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=Or(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 Lr(e,t,n){return e.hasEdge(t,n)}function Nt(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var zr=Dr;function Dr(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Ct(e);break;case"tight-tree":Br(e);break;case"longest-path":Pr(e);break;case"none":break;default:Ct(e)}}var Pr=Ze;function Br(e){Ze(e),tn(e)}function Ct(e){Fr(e)}var Wr=Gr;function Gr(e){let t=Ur(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=$r(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 $r(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 Ur(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(_e).forEach(r),t}function Yr(e){let t=ce(e,"root",{},"_root"),n=qr(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=Kr(e)+1;e.children(_e).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=Tt(e,"_bt"),u=Tt(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),v=b.borderTop?b.borderTop:h,y=b.borderBottom?b.borderBottom:h,k=b.borderTop?r:2*r,T=v!==y?1:o-((g=i[s])!=null?g:0)+1;e.setEdge(a,v,{weight:k,minlen:T,nestingEdge:!0}),e.setEdge(y,u,{weight:k,minlen:T,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,a,{weight:0,minlen:o+((l=i[s])!=null?l:0)})}function qr(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(_e).forEach(r=>n(r,1)),t}function Kr(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)It(e,"borderLeft","_bl",n,o,i),It(e,"borderRight","_br",n,o,i)}}e.children(_e).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=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=>Ot(e.node(t))),e.edges().forEach(t=>Ot(e.edge(t)))}function Ot(e){let t=e.width;e.width=e.height,e.height=t}function Qr(e){e.nodes().forEach(t=>Le(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Le),Object.hasOwn(r,"y")&&Le(r)})}function Le(e){e.y=-e.y}function eo(e){e.nodes().forEach(t=>ze(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ze),Object.hasOwn(r,"x")&&ze(r)})}function ze(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),v=e.node(b[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+g.order+v.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 U({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=Ft(e,ge(1,n+1),"inEdges"),o=Ft(e,ge(n-1,-1,-1),"outEdges"),i=to(e);if(Rt(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))}Rt(e,l)}function Ft(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 U;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 Rt(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=xo(e,u),g=h?e.node(h).order:d;(h||u===a)&&(i.slice(l,f+1).forEach(b=>{let v=e.predecessors(b);v&&v.forEach(y=>{let k=e.node(y),T=k.order;(T<s||g<T)&&!(k.dummy&&e.node(b).dummy)&&fn(n,y,b)})}),l=f+1,s=g)}),i}return t.length&&t.reduce(r),n}function mo(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 xo(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 wo(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 vo(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 v=s[g],y=s[b];return(v!==void 0?v: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 v=f[g];if(v===void 0)continue;let y=s[v];if(y!==void 0&&i[a]===a&&d<y&&!wo(n,a,v)){let k=o[v];k!==void 0&&(i[v]=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 v=s.nodes().slice(),y={},k=v.pop();for(;k;){if(y[k])g(k);else{y[k]=!0,v.push(k);for(let T of b(k))v.push(T)}k=v.pop()}}function a(g){let b=s.inEdges(g);b?i[g]=b.reduce((v,y)=>{var k;let T=(k=i[y.v])!=null?k:0,I=s.edge(y);return Math.max(v,T+(I!==void 0?I:0))},0):i[g]=0}function u(g){let b=s.outEdges(g),v=Number.POSITIVE_INFINITY;b&&(v=b.reduce((k,T)=>{let I=i[T.w],M=s.edge(T);return Math.min(k,(I!==void 0?I:0)-(M!==void 0?M:0))},Number.POSITIVE_INFINITY));let y=e.node(g);v!==Number.POSITIVE_INFINITY&&y.borderType!==l&&(i[g]=Math.max(i[g]!==void 0?i[g]:0,v))}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 v=n[g];v!==void 0&&(i[g]=(b=i[v])!=null?b:0)}),i}function ko(e,t,n,r){let o=new U,i=e.graph(),s=No(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=Co(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]=Te(d,f=>f+u))})})}function To(e,t=void 0){let n=e.ul;return n?Te(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 _o(e){let t=be(e),n=Object.assign(yo(e,t),mo(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=vo(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=Te(a,u=>-u)),r[s+l]=a})});let i=jo(e,r);return So(r,i),To(r,e.graph().align)}function No(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 Co(e,t){return e.node(t).width}function Io(e){e=Vt(e),Oo(e),Object.entries(_o(e)).forEach(([t,n])=>e.node(t).x=n)}function Oo(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",()=>Go(e));return n(" runLayout",()=>Fo(r,n,t)),n(" updateInputGraph",()=>Ro(e,r)),r})}function Fo(e,t,n){t(" makeSpaceForEdgeLabels",()=>$o(e)),t(" removeSelfEdges",()=>Zo(e)),t(" acyclic",()=>vr(e)),t(" nestingGraph.run",()=>Yr(e)),t(" rank",()=>zr(Vt(e))),t(" injectEdgeLabelProxies",()=>Uo(e)),t(" removeEmptyRanks",()=>lr(e)),t(" nestingGraph.cleanup",()=>Hr(e)),t(" normalizeRanks",()=>sr(e)),t(" assignRankMinMax",()=>Yo(e)),t(" removeEdgeLabelProxies",()=>qo(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",()=>Io(e)),t(" positionSelfEdges",()=>ei(e)),t(" removeBorderNodes",()=>Jo(e)),t(" normalize.undo",()=>Tr(e)),t(" fixupEdgeLabelCoords",()=>Xo(e)),t(" undoCoordinateSystem",()=>Zr(e)),t(" translateGraph",()=>Ko(e)),t(" assignNodeIntersects",()=>Ho(e)),t(" reversePoints",()=>Vo(e)),t(" acyclic.undo",()=>kr(e))}function Ro(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"],Lo={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},zo=["acyclicer","ranker","rankdir","align","rankalign"],Do=["width","height","rank"],At={width:0,height:0},Po=["minlen","weight","width","height","labeloffset"],Bo={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Wo=["labelpos"];function Go(e){let t=new U({multigraph:!0,compound:!0}),n=Pe(e.graph());return t.setGraph(Object.assign({},Lo,De(n,Ao),Se(n,zo))),e.nodes().forEach(r=>{let o=Pe(e.node(r)),i=De(o,Do);Object.keys(At).forEach(l=>{i[l]===void 0&&(i[l]=At[l])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Pe(e.edge(r));t.setEdge(r,Object.assign({},Bo,De(o,Po),Se(o,Wo)))}),t}function $o(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 Uo(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 Yo(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 qo(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 Ko(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 De(e,t){return Te(Se(e,t),Number)}function Pe(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 U({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}},Lt=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)}}},v=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:v.bg,color:v.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 Ne=({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(P.Box,{sx:{display:"flex",alignItems:"center",p:2,pt:3,borderBottom:"1px solid #e0e0e0",mb:0,flexShrink:0},children:[r&&c.jsx(P.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(P.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(P.IconButton,{onClick:t,size:"small","data-testid":"close-drawer-button",children:c.jsx(O.MdClose,{})})]}),f=()=>i?c.jsx(P.Box,{sx:{flexShrink:0,p:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:2},children:i}):null;return l?c.jsxs(P.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(P.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),c.jsx(f,{})]}):c.jsxs(P.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(P.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,v]=p.useState(!1),[y,k]=p.useState(null);p.useEffect(()=>{e||(l("trigger"),a(null),f([]),g([]),v(!1),k(null))},[e]);const T=p.useCallback(async R=>{if(!i){r(R);return}a(R),v(!0),k(null);try{const D=await i(R.triggerKey);if(!D||D.length===0){r(R);return}f(D),l("sources")}catch(D){k(D instanceof Error?D.message:"Failed to load sources.")}finally{v(!1)}},[i,r]),I=()=>{l("trigger"),a(null),f([]),g([]),k(null)},M=()=>{d&&r(d,h)},F=s==="sources"&&d,W=F?c.jsxs(c.Fragment,{children:[c.jsx(P.Button,{type:"button",variant:"outlined",size:"small",onClick:I,children:n.cancel??"Back"}),c.jsx(P.Button,{type:"button",variant:"contained",size:"small",onClick:M,disabled:h.length===0,children:n.save??"Continue"})]}):null;return c.jsx(Ne,{isOpen:e,onClose:o,title:F?d.label:n.addTriggerTitle,icon:c.jsx(In.GrTrigger,{}),width:500,footer:W,children:c.jsxs(P.Box,{sx:{p:2},children:[!F&&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(R=>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&&T(R),role:"button",tabIndex:0,onKeyDown:D=>{D.key==="Enter"&&!b&&T(R)},onMouseEnter:D=>{b||(D.currentTarget.style.background="#f5f5f5")},onMouseLeave:D=>{D.currentTarget.style.background=""},children:[c.jsx("div",{style:{color:R.triggerCategory==="scheduler"?"#1976d2":"#f57c00",marginTop:2,flexShrink:0},children:R.triggerCategory==="scheduler"?c.jsx(O.MdCalendarToday,{size:18}):c.jsx(O.MdBolt,{size:18})}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:R.label}),R.description&&c.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:R.description})]})]},R.triggerKey)),t.length===0&&c.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:n.noTriggers})]}),b&&c.jsxs(P.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:2,fontSize:12,color:"#64748b"},children:[c.jsx(P.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})]}),F&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{role:"button",tabIndex:0,onClick:I,onKeyDown:R=>{R.key==="Enter"&&I()},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(O.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(Cn,{isMulti:!0,options:u,value:h,onChange:R=>g(R??[]),placeholder:"Select sources…",menuPosition:"fixed",menuPortalTarget:typeof document<"u"?document.body:void 0,styles:Xe.buildSelectStyles(!1,!0)})]})]})})},Be={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(Ne,{isOpen:e,onClose:o,title:u?n.addStepTitle:a.label,icon:u?c.jsx(O.MdAddCircleOutline,{}):a.icon??c.jsx(O.MdApps,{}),width:500,children:c.jsxs(P.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(O.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:Be,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(O.MdChevronRight,{size:18,color:"#9e9e9e"})]},`app-${f.key}`)),s.map(f=>c.jsxs("div",{className:We,style:Be,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:Be,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))})]})})},zt="_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[zt])??{})},[r,t]),p.useEffect(()=>{let T=!1;if(h(null),!n||!t){d([]),u(!1);return}const I=n.formSchema;return typeof I=="function"?(u(!0),I(t).then(M=>{T||(d(M),u(!1))}).catch(M=>{T||(d([]),h(M instanceof Error?M.message:"Unable to load configuration."),u(!1))})):(d(I),u(!1)),()=>{T=!0}},[n,t]);const v=t?`node-config-form-${t}`:"node-config-form",y=!a&&!f&&l.length>0,k=y?c.jsxs(c.Fragment,{children:[c.jsx(P.Button,{type:"button",variant:"outlined",size:"small",onClick:s,children:o.cancel}),c.jsx(P.Button,{type:"submit",form:v,variant:"contained",size:"small",children:o.save})]}):null;return c.jsx(Ne,{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(P.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:v,conditionConfig:g,onConditionConfigChange:b,onSubmit:T=>{if(!t)return;const I=Object.keys(g).length>0;i(t,{...T,[zt]:I?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(Ne,{isOpen:e,onClose:t,title:r?`Preview: ${r}`:"Sub-Workflow Preview",icon:c.jsx(O.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(O.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,Ue=70,Ye=60,qe={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 Dt(){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 Lt.graphlib.Graph;return o.setGraph({rankdir:r,ranksep:70,nodesep:50}),o.setDefaultEdgeLabel(()=>({})),e.forEach(i=>{const s=n[i.id]??{width:pe,height:qe[i.type??""]??80};o.setNode(i.id,{width:s.width,height:s.height})}),t.forEach(i=>o.setEdge(i.source,i.target)),Lt.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)??qe[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=Ue,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 T of k)f.set(T.id,T);const h=(y,k,T)=>{const I=r[y]??{width:pe,height:80};return a[y]={x:k-I.width/2,y:T},T+I.height},g=(y,k,T)=>{let I=T;for(const M of y)I=h(M.id,k,I)+s,oe(M.kind)&&t[M.id]&&(I=b(M.id,k,I));return I},b=(y,k,T)=>{const I=k+180,M=t[y],F=Object.keys(M),W=f.get(y),R=(W==null?void 0:W.branchLabels)??{pass:"Pass",fail:"Fail"},D=a[y],G=r[y]??{height:80},ye=D.y+G.height,me=[];let Z=T;return F.forEach((ue,xe)=>{const Ce=M[ue],Ie=Z;me.push({y:Ie-ye,label:R[ue]??ue,isPass:xe===0}),Z=g(Ce,I,Z+d),xe<F.length-1&&(Z+=l)}),u[y]={branches:me,height:Z-ye,indent:180},Z};let v=Ye;for(const y of e)v=h(y.id,400,v)+s,oe(y.kind)&&t[y.id]&&(v=b(y.id,400,v));return{nodes:n.map(y=>a[y.id]?{...y,position:a[y.id]}:y),railSpecs:u}}function Pt(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,v)=>{const y=t[b];if(!y)return;const T=v??{pass:"Pass",fail:"Fail"},I=Object.keys(y),M=(F,W,R,D)=>{if(F.length!==0){F.forEach(G=>d.push(Pt(G))),a.push({id:`e-${b}-${W}-start`,source:b,target:F[0].id,type:"gatewayBranchEdge",style:{stroke:l},data:{branch:W,filterId:b,label:R,isFirst:D===0,onAddStepClick:n,verticalRouting:s==="vertical"}});for(let G=1;G<F.length;G++)oe(F[G-1].kind)||a.push(hi(F[G-1],F[G],l,n,{filterId:b,branch:W}));for(const G of F)oe(G.kind)&&t[G.id]&&u(G.id,G.branchLabels)}};I.forEach((F,W)=>{M(y[F],F,T[F]??F,W)})};for(let b=0;b<e.length;b++){const v=e[b];if(d.push(Pt(v)),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}-${v.id}`,source:y.id,target:v.id,type:k?"plainEdge":"plusEdge",style:{stroke:l},data:k?{}:{onAddStepClick:n,referenceNodeType:y.reactFlowType}})}(v.kind==="filter"||v.kind==="approval")&&t[v.id]&&u(v.id,v.branchLabels)}const f={};if(d.forEach(b=>{f[b.id]={width:pe,height:r[b.id]??qe[b.type??""]??80}}),!(Object.keys(t).length>0)){if(i==="LR"){let T=Ye;return{nodes:d.map(M=>{const F=f[M.id].width,W=f[M.id].height,R={...M,position:{x:T,y:300-W/2}};return T+=F+Ue,R}),edges:a}}const b=400;let v=Ye;return{nodes:d.map(k=>{const T=f[k.id].height,I={...k,position:{x:b-pe/2,y:v}};return v+=T+Ue,I}),edges:a}}if(s==="vertical"){const{nodes:b,railSpecs:v}=fi(e,t,d,f);return{nodes:b.map(k=>v[k.id]?{...k,data:{...k.data,_branchRail:v[k.id]}}:k),edges:a}}return{nodes:ui(d,a,f,i),edges:a}}const Ke=({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:v,layoutDirection:y="TB",executionRecord:k,onFetchWorkflow:T,hideHeader:I=!1,workflowName:M,onWorkflowNameChange:F,onCancel:W,workflowStatus:R,workflowStatusColor:D,saveLabel:G,optionsResolvers:ye})=>{const{fitView:me=!0,fitViewPadding:Z=.3,showControls:ue=!0,showMiniMap:xe=!1,panOnScroll:Ce=!0,zoomOnScroll:Ie=!1,minZoom:bn=.25,maxZoom:yn=2,snapToGrid:mn=!1,snapGrid:xn=[15,15],branchLayout:tt="horizontal",nodeBody:nt="full"}=a,fe=p.useMemo(()=>On.mergeMessages(d),[d]),[A,ee]=p.useState(()=>(n==null?void 0:n.slots)??Dt()),[$,V]=p.useState(()=>(n==null?void 0:n.branches)??{}),[se,Y]=p.useState(null),[Oe,rt]=p.useState(null),[q,we]=p.useState(null),[te,ot]=p.useState(null),[ve,it]=p.useState(null),[K,st]=p.useState(()=>{const m=n==null?void 0:n.slots.find(S=>S.kind==="triggerFixed"),w=m!=null&&m.id.startsWith("trigger-")?m.id.slice(8):void 0;return w?t.lookup(w)??null:null}),[lt,wn]=p.useState({}),vn=p.useCallback(m=>{wn(m)},[]),En=p.useMemo(()=>({...re.builtInNodeTypes,...r}),[r]),kn=p.useMemo(()=>({...ci,...o}),[o]),jn=p.useMemo(()=>{const m=A.filter(S=>S.kind==="userTask").length,w=Object.values($).flatMap(S=>Object.values(S).flat()).filter(S=>S.kind==="userTask").length;return m+w},[A,$]),at=v??(K==null?void 0:K.maxTasks),dt=at!==void 0&&jn>=at,ne=p.useCallback(m=>{const w=A.find(S=>S.id===m);if(w)return w;for(const S of Object.values($)){const E=Object.values(S).flat().find(C=>C.id===m);if(E)return E}return null},[A,$]),Me=p.useCallback(m=>{s||(rt(m),Y("nodeConfig"))},[s]),ct=p.useCallback(m=>{if(!s){if(A.some(w=>w.id===m)){const w=A.find(S=>S.id===m);if((w==null?void 0:w.kind)==="triggerFixed"){ee(Dt()),V({}),st(null);return}ee(S=>{const E=S.filter(C=>C.id!==m);return oe((w==null?void 0:w.kind)??"")&&!E.some(C=>C.kind==="end")?[...E,{id:"end",kind:"end",reactFlowType:"endNode"}]:E}),V(S=>{const E={...S},C=x=>{E[x]&&(Object.values(E[x]).flat().filter(j=>oe(j.kind)).forEach(j=>C(j.id)),delete E[x])};return C(m),E});return}V(w=>{const S=(C,x)=>{const j=[];for(const N of C)oe(N.kind)&&x[N.id]&&(j.push(N.id),Object.values(x[N.id]).forEach(_=>j.push(...S(_,x))));return j},E={...w};for(const C of Object.keys(E))for(const x of Object.keys(E[C])){const j=E[C][x],N=j.findIndex(L=>L.id===m);if(N===-1||j[N].kind==="end")continue;const _=j[N];let z=j.filter(L=>L.id!==m);return _.kind==="filter"&&((_.id in E?S([_],E):[]).forEach(B=>delete E[B]),delete E[_.id],z.some(B=>B.kind==="end")||(z=[...z,{id:`end-${C}-${x}`,kind:"end",reactFlowType:"endNode"}])),E[C]={...E[C],[x]:z},E}return E})}},[s,A]),Fe=p.useCallback(()=>{s||Y("triggerSelect")},[s]),ut=p.useCallback((m,w)=>{s||dt||(we(m),ot(w.filterId&&w.branch?{filterId:w.filterId,branch:w.branch}:null),Y("nodePicker"))},[s,dt]),ft=p.useCallback((m,w)=>{if(st(m),Y(null),m.skeletonState){const E=Array.isArray(w)&&w.length>0,C=(m.skeletonState.slots??[]).map(x=>x.kind!=="triggerFixed"?x:{...x,nodeData:{label:m.label,...x.nodeData??{},...E&&{sources:w}}});V(m.skeletonState.branches??{}),ee(C);return}V({});const S=Array.isArray(w)&&w.length>0;ee([{id:"start",kind:"start",reactFlowType:"startNode"},{id:`trigger-${m.triggerKey}`,kind:"triggerFixed",reactFlowType:"triggerNode",nodeData:{label:m.label,source:m.source,eventType:m.triggerKey,type:m.triggerCategory==="scheduler"?"scheduler":"event",...S&&{sources:w}},deletable:!1},{id:"end",kind:"end",reactFlowType:"endNode"}])},[]),ht=p.useCallback(()=>{var S;const m={insertAfterSlot:null,upstreamSlots:[],downstreamSlots:[],branch:te,template:K};if(!q)return m;if(te){const{filterId:E,branch:C}=te,x=A.findIndex(L=>L.id===E),j=x>=0?A.slice(0,x+1):[],N=((S=$[E])==null?void 0:S[C])??[],_=N.findIndex(L=>L.id===q),z=_>=0?N.slice(0,_+1):[];return m.upstreamSlots=[...j,...z],m.downstreamSlots=_>=0?N.slice(_+1):N,m.insertAfterSlot=z[z.length-1]??null,m}const w=A.findIndex(E=>E.id===q);return m.upstreamSlots=w>=0?A.slice(0,w+1):[],m.downstreamSlots=w>=0?A.slice(w+1):[],m.insertAfterSlot=m.upstreamSlots[m.upstreamSlots.length-1]??null,m},[A,$,q,te,K]),gt=(m,w)=>m.descriptorType===w||m.id===w||m.kind===w,pt=p.useCallback(()=>{const m=e.list(),w=K!=null&&K.availableTasks?m.filter(E=>K.availableTasks.includes(E.type)):m,S=ht();return w.filter(E=>E.maxPerWorkflow!==void 0&&A.filter(x=>x.descriptorType===E.type).length+Object.values($).flatMap(x=>Object.values(x).flat()).filter(x=>x.descriptorType===E.type).length>=E.maxPerWorkflow?!1:E.canInsert?E.canInsert(S):!(E.insertAfter&&E.insertAfter.length>0&&!S.upstreamSlots.some(x=>E.insertAfter.some(j=>gt(x,j)))||E.insertBefore&&E.insertBefore.length>0&&!S.downstreamSlots.some(x=>E.insertBefore.some(j=>gt(x,j)))))},[e,K,A,$,ht]),bt=p.useCallback(m=>{if(!q)return;const w=`${m.type}-${Date.now()}`,S=m.reactFlowType==="filterNode"||m.reactFlowType==="approvalNode"||m.reactFlowType==="conditionBranchNode",E=m.branchLabels??{pass:"Pass",fail:"Fail"},C={id:w,kind:S?m.reactFlowType==="approvalNode"?"approval":"filter":"userTask",reactFlowType:m.reactFlowType,descriptorType:m.type,formData:{},nodeData:{title:m.label},deletable:!0,branchLabels:E};if(te){const{filterId:x,branch:j}=te;V(N=>{const _=[...N[x][j]];if(S){const Q=_.filter(le=>le.kind!=="end"),vt=Q.findIndex(le=>le.id===q),Nn=vt===-1?Q.length:vt+1;return Q.splice(Nn,0,C),{...N,[x]:{...N[x],[j]:Q},[w]:Object.fromEntries(Object.keys(E).map(le=>[le,[{id:`end-${w}-${le}`,kind:"end",reactFlowType:"endNode"}]]))}}const z=_.findIndex(Q=>Q.id===q),L=_.findIndex(Q=>Q.kind==="end"),B=z===-1?L===-1?_.length:L:z+1;return _.splice(B,0,C),{...N,[x]:{...N[x],[j]:_}}})}else S?(ee(x=>{const j=x.findIndex(_=>_.id===q);return[...x.filter(_=>_.kind!=="end").slice(0,j+1),C]}),V(x=>({...x,[w]:Object.fromEntries(Object.keys(E).map(j=>[j,[{id:`end-${w}-${j}`,kind:"end",reactFlowType:"endNode"}]]))}))):ee(x=>{const j=x.findIndex(N=>N.id===q);return j===-1?x:[...x.slice(0,j+1),C,...x.slice(j+1)]});we(null),ot(null),rt(w),Y("nodeConfig")},[q,te]),yt=p.useCallback((m,w)=>{const S=x=>{const j=x.label||x.key;switch(x.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=x=>{const j=ne(m);if((j==null?void 0:j.descriptorType)!=="conditionBranch")return x;const _=(w.branchConfigs??[]).map(B=>B.key).filter(Boolean);if(_.length===0)return x;const z=x[m]??{},L={};return _.forEach(B=>{L[B]=z[B]??[{id:`end-${m}-${B}`,kind:"end",reactFlowType:"endNode"}]}),{...x,[m]:L}},C=(x,j)=>{if(x.descriptorType!=="conditionBranch")return{...x,formData:j};const N=j.branchConfigs??[],_={};return N.forEach(z=>{z.key&&(_[z.key]=S(z))}),{...x,formData:j,branchLabels:_}};if(A.some(x=>x.id===m)){V(x=>{const j=E(x);return ee(N=>N.map(_=>_.id===m?C(_,w):_)),j});return}V(x=>{const N={...E(x)};for(const _ of Object.keys(N)){const z=L=>L.map(B=>B.id===m?C(B,w):B);for(const L of Object.keys(N[_]))if(N[_][L].some(B=>B.id===m))return N[_]={...N[_],[L]:z(N[_][L])},N}return N})},[A,$,ne]),J=p.useMemo(()=>ne(Oe??""),[ne,Oe]),mt=p.useMemo(()=>J!=null&&J.descriptorType?e.forType(J.descriptorType)??null:null,[J,e]),{nodes:xt,edges:Sn}=p.useMemo(()=>gi(A,$,s?null:ut,lt,l,y,tt),[A,$,s,ut,lt,l,y,tt]),wt=p.useMemo(()=>{const m=k?new Map(k.steps.map(w=>[w.nodeId,w])):null;return xt.map(w=>{let S={};if(m){const E=m.get(w.id);E&&(S={_executionStatus:E.status,_executionError:E.error})}return w.type==="subWorkflowNode"&&T&&(S.onPreview=E=>{var x;const C=ne(w.id);it({workflowId:E,workflowLabel:((x=C==null?void 0:C.formData)==null?void 0:x.workflowLabel)??void 0})}),Object.keys(S).length>0?{...w,data:{...w.data,...S}}:w})},[xt,k,T,ne]),Tn=p.useMemo(()=>({onEditNode:Me,onDeleteNode:ct,onAddStep:()=>{},onClickAddTrigger:Fe,messages:fe,nodeRegistry:e,nodeBody:nt}),[Me,ct,Fe,fe,e,nt]),_n=p.useCallback(async()=>{i&&await i({slots:A,branches:$})},[i,A,$]);return c.jsx(Xe.OptionsResolversProvider,{resolvers:ye,children:c.jsx(re.WorkflowCanvasContext.Provider,{value:Tn,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:[!I&&(i||W||M)&&c.jsx(hn,{workflowName:M,onWorkflowNameChange:F,status:R,statusColor:D,onSave:i?_n:void 0,onCancel:W,saveLabel:G}),c.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[c.jsxs(ae,{nodes:wt,edges:Sn,nodeTypes:En,edgeTypes:kn,fitView:me,fitViewOptions:{padding:Z},nodesDraggable:!1,nodesConnectable:!1,panOnScroll:Ce,zoomOnScroll:Ie,minZoom:bn,maxZoom:yn,snapToGrid:mn,snapGrid:xn,proOptions:{hideAttribution:!0},onNodeClick:(m,w)=>{const S=ne(w.id);S&&(b!=null&&b(S)||(S.kind==="addTrigger"||S.kind==="triggerFixed"?Fe():(S.kind==="userTask"||S.kind==="filter"||S.kind==="approval")&&Me(w.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}),xe&&c.jsx(ae.MiniMap,{zoomable:!0,pannable:!0}),c.jsx(oi,{onHeightsReady:vn,nodeCount:wt.length})]}),u?se==="triggerSelect"&&u(t.list(),ft,()=>Y(null)):c.jsx(si,{open:se==="triggerSelect",templates:t.list(),messages:fe,onSelect:ft,onClose:()=>Y(null),loadTriggerSources:f}),h?se==="nodePicker"&&h(pt(),bt,()=>{Y(null),we(null)}):c.jsx(li,{open:se==="nodePicker",availableDescriptors:pt(),messages:fe,onSelect:bt,onClose:()=>{Y(null),we(null)}}),g?se==="nodeConfig"&&g(mt??void 0,J,yt,()=>Y(null)):c.jsx(ai,{open:se==="nodeConfig",nodeId:Oe,descriptor:mt,initialValues:J==null?void 0:J.formData,messages:fe,onSave:yt,onClose:()=>Y(null)}),T&&ve&&c.jsx(gn,{isOpen:!!ve,onClose:()=>it(null),workflowId:ve.workflowId,workflowLabel:ve.workflowLabel,onFetchWorkflow:T})]})]})})})},pi=Object.freeze(Object.defineProperty({__proto__:null,WorkflowCanvas:Ke,default:Ke},Symbol.toStringTag,{value:"Module"})),Ge="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(Ge),l=p.useMemo(()=>{const a=new Set;return e.forEach(u=>{u.category&&a.add(u.category)}),[Ge,...Array.from(a)]},[e]),d=p.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(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(O.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(O.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(O.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(O.MdPlayArrow,{size:14})},success:{label:"Success",color:H.EXECUTION_STATUS_COLOR.success,icon:p.createElement(O.MdCheckCircle,{size:14})},failed:{label:"Failed",color:H.EXECUTION_STATUS_COLOR.failed,icon:p.createElement(O.MdError,{size:14})},cancelled:{label:"Cancelled",color:H.EXECUTION_STATUS_COLOR.cancelled,icon:p.createElement(O.MdCancel,{size:14})}},mi={pending:{color:H.EXECUTION_STATUS_COLOR.pending,icon:p.createElement(O.MdHourglassEmpty,{size:14})},running:{color:H.EXECUTION_STATUS_COLOR.running,icon:p.createElement(O.MdPlayArrow,{size:14})},success:{color:H.EXECUTION_STATUS_COLOR.success,icon:p.createElement(O.MdCheckCircle,{size:14})},failed:{color:H.EXECUTION_STATUS_COLOR.failed,icon:p.createElement(O.MdError,{size:14})},skipped:{color:H.EXECUTION_STATUS_COLOR.skipped,icon:p.createElement(O.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 xi({step:e}){const[t,n]=p.useState(!1),r=mi[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(O.MdExpandLess,{size:16}):p.createElement(O.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 wi({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(O.MdChevronRight,{size:14,color:"#bdbdbd"})]})}const vi=({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(O.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(wi,{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(O.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(O.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(xi,{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"})})]})},Ei={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-END_USER_CREATION",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"New User Registration",nodeData:{label:"New User Registration"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Welcome Email",nodeData:{title:"Welcome Email"}},{id:"approval-1",kind:"approval",reactFlowType:"approvalNode",descriptorType:"approval",deletable:!0,label:"Manager Approval",branchLabels:{pass:"Approved",fail:"Rejected"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{"approval-1":{pass:[{id:"notification-pass-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Approval Confirmed",nodeData:{title:"Approval Confirmed"}}],fail:[{id:"notification-fail-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Rejection Notice",nodeData:{title:"Rejection Notice"}}]}}},ki={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-ACCESS_REQUEST",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"Access Request Submitted",nodeData:{label:"Access Request Submitted"}},{id:"approval-1",kind:"approval",reactFlowType:"approvalNode",descriptorType:"approval",deletable:!0,label:"Access Approval",branchLabels:{pass:"Approved",fail:"Denied"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{"approval-1":{pass:[{id:"restApi-1",kind:"userTask",reactFlowType:"restApiNode",descriptorType:"restApi",deletable:!0,label:"Provision Access",nodeData:{title:"Provision Access"}},{id:"notification-pass-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Access Granted Email",nodeData:{title:"Access Granted Email"}}],fail:[{id:"notification-fail-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Access Denied Email",nodeData:{title:"Access Denied Email"}}]}}},ji={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-USER_DEACTIVATION",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"User Deactivation",nodeData:{label:"User Deactivation"}},{id:"delay-1",kind:"userTask",reactFlowType:"delayNode",descriptorType:"delay",deletable:!0,label:"Grace Period",nodeData:{title:"Grace Period",duration:7,unit:"days"},formData:{duration:7,unit:"days"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Notify IT Team",nodeData:{title:"Notify IT Team"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{}},Si={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-WEBHOOK_TRIGGER",kind:"triggerFixed",reactFlowType:"webhookTriggerNode",deletable:!0,label:"Incoming Webhook",nodeData:{label:"Incoming Webhook"}},{id:"restApi-1",kind:"userTask",reactFlowType:"restApiNode",descriptorType:"restApi",deletable:!0,label:"Call External API",nodeData:{title:"Call External API"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Notify on Completion",nodeData:{title:"Notify on Completion"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{}};exports.FlowForgeCanvas=Ke;exports.FlowForgeHeader=hn;exports.SubWorkflowPreviewDrawer=gn;exports.WorkflowExecutionHistory=vi;exports.WorkflowTemplateLibrary=yi;exports.accessRequestSkeleton=ki;exports.offboardingSkeleton=ji;exports.userOnboardingSkeleton=Ei;exports.webhookIntegrationSkeleton=Si;
|
|
2
|
-
//# sourceMappingURL=templateSkeletons-
|
|
1
|
+
"use strict";const c=require("react/jsx-runtime"),p=require("react"),ae=require("reactflow");require("reactflow/dist/style.css");const re=require("./GatewayBranchEdge-CMY30xhz.js"),P=require("@mui/material"),Cn=require("react-select"),O=require("react-icons/md"),In=require("react-icons/gr"),Et=require("react-icons/bi"),Xe=require("./index-yOtdNWwA.js"),On=require("./messages-O9Tw_XXR.js"),H=require("./canvasTokens-gKNYrPl4.js");var Bt=Object.defineProperty,Mn=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fn=(e,t)=>{for(var n in t)Bt(e,n,{get:t[n],enumerable:!0})},Rn=(e,t,n)=>Mn(e,t+"",n),Wt={};Fn(Wt,{Graph:()=>U,alg:()=>Ve,json:()=>$t,version:()=>zn});var An=Object.defineProperty,Gt=(e,t)=>{for(var n in t)An(e,n,{get:t[n],enumerable:!0})},U=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=Ln(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?Re(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?Re(this._isDirected,e):he(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Re(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 Ln(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 Re(e,t){return he(e,t.v,t.w,t.name)}var zn="4.0.1",$t={};Gt($t,{read:()=>Wn,write:()=>Dn});function Dn(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Pn(e),edges:Bn(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Pn(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 Bn(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 U(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={};Gt(Ve,{CycleException:()=>je,bellmanFord:()=>Ut,components:()=>Un,dijkstra:()=>ke,dijkstraAll:()=>Kn,findCycles:()=>Hn,floydWarshall:()=>Vn,isAcyclic:()=>Zn,postorder:()=>er,preorder:()=>tr,prim:()=>nr,shortestPaths:()=>rr,tarjan:()=>qt,topsort:()=>Kt});var Gn=()=>1;function Ut(e,t,n,r){return $n(e,String(t),n||Gn,r||function(o){return e.outEdges(o)})}function $n(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 Un(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 Yt=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}},Yn=()=>1;function ke(e,t,n,r){let o=function(i){return e.outEdges(i)};return qn(e,String(t),n||Yn,r||o)}function qn(e,t,n,r){let o={},i=new Yt,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 Kn(e,t,n){return e.nodes().reduce(function(r,o){return r[o]=ke(e,o,t,n),r},{})}function qt(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 qt(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 Kt(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{Kt(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 U,r={},o=new Yt,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 Ut(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 U().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 U({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 Tt(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 Te(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 _e="\0",fr="3.0.0",hr=class{constructor(){Rn(this,"_sentinel");let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return _t(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&_t(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 _t(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=xr(e,t||br);return mr(n.graph,n.buckets,n.zeroIdx).flatMap(r=>e.outEdges(r.v,r.w)||[])}function mr(e,t,n){var r;let o=[],i=t[t.length-1],s=t[0],l;for(;e.nodeCount();){for(;l=s.dequeue();)Ae(e,t,n,l);for(;l=i.dequeue();)Ae(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(Ae(e,t,n,l,!0)||[]);break}}}return o}function Ae(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,$e(t,n,a)}),(e.outEdges(r.v)||[]).forEach(l=>{let d=e.edge(l),a=l.w,u=e.node(a);u.in-=d,$e(t,n,u)}),e.removeNode(r.v),s}function xr(e,t){let n=new U,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=wr(o+r+3).map(()=>new pr),s=r+1;return n.nodes().forEach(l=>{$e(i,s,n.node(l))}),{graph:n,buckets:i,zeroIdx:s}}function $e(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 wr(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function vr(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 Tr(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=_r;function _r(e){let t=new U({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(;Nr(t,e)<o&&(i=Cr(t,e),!!i);)s=t.hasNode(i.v)?de(e,i):-de(e,i),Ir(t,e,s);return t}function Nr(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 Cr(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 Ir(e,t,n){e.nodes().forEach(r=>t.node(r).rank+=n)}var{preorder:Or,postorder:Mr}=Ve,Fr=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=>Rr(e,t,r))}function Rr(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,Lr(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===Nt(e,e.node(a.v),l)&&d!==Nt(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),Ar(e,t)}function Ar(e,t){let n=e.nodes().find(o=>!e.node(o).parent);if(!n)return;let r=Or(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 Lr(e,t,n){return e.hasEdge(t,n)}function Nt(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var zr=Dr;function Dr(e){let t=e.graph().ranker;if(typeof t=="function")return t(e);switch(t){case"network-simplex":Ct(e);break;case"tight-tree":Br(e);break;case"longest-path":Pr(e);break;case"none":break;default:Ct(e)}}var Pr=Ze;function Br(e){Ze(e),tn(e)}function Ct(e){Fr(e)}var Wr=Gr;function Gr(e){let t=Ur(e);e.graph().dummyChains.forEach(n=>{let r=e.node(n),o=r.edgeObj,i=$r(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 $r(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 Ur(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(_e).forEach(r),t}function Yr(e){let t=ce(e,"root",{},"_root"),n=qr(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=Kr(e)+1;e.children(_e).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=Tt(e,"_bt"),u=Tt(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),v=b.borderTop?b.borderTop:h,y=b.borderBottom?b.borderBottom:h,k=b.borderTop?r:2*r,T=v!==y?1:o-((g=i[s])!=null?g:0)+1;e.setEdge(a,v,{weight:k,minlen:T,nestingEdge:!0}),e.setEdge(y,u,{weight:k,minlen:T,nestingEdge:!0})}),e.parent(s)||e.setEdge(t,a,{weight:0,minlen:o+((l=i[s])!=null?l:0)})}function qr(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(_e).forEach(r=>n(r,1)),t}function Kr(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)It(e,"borderLeft","_bl",n,o,i),It(e,"borderRight","_br",n,o,i)}}e.children(_e).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=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=>Ot(e.node(t))),e.edges().forEach(t=>Ot(e.edge(t)))}function Ot(e){let t=e.width;e.width=e.height,e.height=t}function Qr(e){e.nodes().forEach(t=>Le(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Le),Object.hasOwn(r,"y")&&Le(r)})}function Le(e){e.y=-e.y}function eo(e){e.nodes().forEach(t=>ze(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ze),Object.hasOwn(r,"x")&&ze(r)})}function ze(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),v=e.node(b[0]);Object.hasOwn(f,"barycenter")||(f.barycenter=0,f.weight=0),f.barycenter=(f.barycenter*f.weight+g.order+v.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 U({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=Ft(e,ge(1,n+1),"inEdges"),o=Ft(e,ge(n-1,-1,-1),"outEdges"),i=to(e);if(Rt(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))}Rt(e,l)}function Ft(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 U;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 Rt(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=xo(e,u),g=h?e.node(h).order:d;(h||u===a)&&(i.slice(l,f+1).forEach(b=>{let v=e.predecessors(b);v&&v.forEach(y=>{let k=e.node(y),T=k.order;(T<s||g<T)&&!(k.dummy&&e.node(b).dummy)&&fn(n,y,b)})}),l=f+1,s=g)}),i}return t.length&&t.reduce(r),n}function mo(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 xo(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 wo(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 vo(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 v=s[g],y=s[b];return(v!==void 0?v: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 v=f[g];if(v===void 0)continue;let y=s[v];if(y!==void 0&&i[a]===a&&d<y&&!wo(n,a,v)){let k=o[v];k!==void 0&&(i[v]=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 v=s.nodes().slice(),y={},k=v.pop();for(;k;){if(y[k])g(k);else{y[k]=!0,v.push(k);for(let T of b(k))v.push(T)}k=v.pop()}}function a(g){let b=s.inEdges(g);b?i[g]=b.reduce((v,y)=>{var k;let T=(k=i[y.v])!=null?k:0,I=s.edge(y);return Math.max(v,T+(I!==void 0?I:0))},0):i[g]=0}function u(g){let b=s.outEdges(g),v=Number.POSITIVE_INFINITY;b&&(v=b.reduce((k,T)=>{let I=i[T.w],M=s.edge(T);return Math.min(k,(I!==void 0?I:0)-(M!==void 0?M:0))},Number.POSITIVE_INFINITY));let y=e.node(g);v!==Number.POSITIVE_INFINITY&&y.borderType!==l&&(i[g]=Math.max(i[g]!==void 0?i[g]:0,v))}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 v=n[g];v!==void 0&&(i[g]=(b=i[v])!=null?b:0)}),i}function ko(e,t,n,r){let o=new U,i=e.graph(),s=No(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=Co(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]=Te(d,f=>f+u))})})}function To(e,t=void 0){let n=e.ul;return n?Te(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 _o(e){let t=be(e),n=Object.assign(yo(e,t),mo(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=vo(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=Te(a,u=>-u)),r[s+l]=a})});let i=jo(e,r);return So(r,i),To(r,e.graph().align)}function No(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 Co(e,t){return e.node(t).width}function Io(e){e=Vt(e),Oo(e),Object.entries(_o(e)).forEach(([t,n])=>e.node(t).x=n)}function Oo(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",()=>Go(e));return n(" runLayout",()=>Fo(r,n,t)),n(" updateInputGraph",()=>Ro(e,r)),r})}function Fo(e,t,n){t(" makeSpaceForEdgeLabels",()=>$o(e)),t(" removeSelfEdges",()=>Zo(e)),t(" acyclic",()=>vr(e)),t(" nestingGraph.run",()=>Yr(e)),t(" rank",()=>zr(Vt(e))),t(" injectEdgeLabelProxies",()=>Uo(e)),t(" removeEmptyRanks",()=>lr(e)),t(" nestingGraph.cleanup",()=>Hr(e)),t(" normalizeRanks",()=>sr(e)),t(" assignRankMinMax",()=>Yo(e)),t(" removeEdgeLabelProxies",()=>qo(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",()=>Io(e)),t(" positionSelfEdges",()=>ei(e)),t(" removeBorderNodes",()=>Jo(e)),t(" normalize.undo",()=>Tr(e)),t(" fixupEdgeLabelCoords",()=>Xo(e)),t(" undoCoordinateSystem",()=>Zr(e)),t(" translateGraph",()=>Ko(e)),t(" assignNodeIntersects",()=>Ho(e)),t(" reversePoints",()=>Vo(e)),t(" acyclic.undo",()=>kr(e))}function Ro(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"],Lo={ranksep:50,edgesep:20,nodesep:50,rankdir:"TB",rankalign:"center"},zo=["acyclicer","ranker","rankdir","align","rankalign"],Do=["width","height","rank"],At={width:0,height:0},Po=["minlen","weight","width","height","labeloffset"],Bo={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},Wo=["labelpos"];function Go(e){let t=new U({multigraph:!0,compound:!0}),n=Pe(e.graph());return t.setGraph(Object.assign({},Lo,De(n,Ao),Se(n,zo))),e.nodes().forEach(r=>{let o=Pe(e.node(r)),i=De(o,Do);Object.keys(At).forEach(l=>{i[l]===void 0&&(i[l]=At[l])}),t.setNode(r,i);let s=e.parent(r);s!==void 0&&t.setParent(r,s)}),e.edges().forEach(r=>{let o=Pe(e.edge(r));t.setEdge(r,Object.assign({},Bo,De(o,Po),Se(o,Wo)))}),t}function $o(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 Uo(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 Yo(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 qo(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 Ko(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 De(e,t){return Te(Se(e,t),Number)}function Pe(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 U({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}},Lt=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)}}},v=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:v.bg,color:v.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 Ne=({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(P.Box,{sx:{display:"flex",alignItems:"center",p:2,pt:3,borderBottom:"1px solid #e0e0e0",mb:0,flexShrink:0},children:[r&&c.jsx(P.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(P.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(P.IconButton,{onClick:t,size:"small","data-testid":"close-drawer-button",children:c.jsx(O.MdClose,{})})]}),f=()=>i?c.jsx(P.Box,{sx:{flexShrink:0,p:2,borderTop:"1px solid #e0e0e0",display:"flex",justifyContent:"flex-end",gap:2},children:i}):null;return l?c.jsxs(P.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(P.Box,{sx:{flexGrow:1,overflowY:"auto",p:0},children:o}),c.jsx(f,{})]}):c.jsxs(P.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(P.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,v]=p.useState(!1),[y,k]=p.useState(null);p.useEffect(()=>{e||(l("trigger"),a(null),f([]),g([]),v(!1),k(null))},[e]);const T=p.useCallback(async R=>{if(!i){r(R);return}a(R),v(!0),k(null);try{const D=await i(R.triggerKey);if(!D||D.length===0){r(R);return}f(D),l("sources")}catch(D){k(D instanceof Error?D.message:"Failed to load sources.")}finally{v(!1)}},[i,r]),I=()=>{l("trigger"),a(null),f([]),g([]),k(null)},M=()=>{d&&r(d,h)},F=s==="sources"&&d,W=F?c.jsxs(c.Fragment,{children:[c.jsx(P.Button,{type:"button",variant:"outlined",size:"small",onClick:I,children:n.cancel??"Back"}),c.jsx(P.Button,{type:"button",variant:"contained",size:"small",onClick:M,disabled:h.length===0,children:n.save??"Continue"})]}):null;return c.jsx(Ne,{isOpen:e,onClose:o,title:F?d.label:n.addTriggerTitle,icon:c.jsx(In.GrTrigger,{}),width:500,footer:W,children:c.jsxs(P.Box,{sx:{p:2},children:[!F&&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(R=>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&&T(R),role:"button",tabIndex:0,onKeyDown:D=>{D.key==="Enter"&&!b&&T(R)},onMouseEnter:D=>{b||(D.currentTarget.style.background="#f5f5f5")},onMouseLeave:D=>{D.currentTarget.style.background=""},children:[c.jsx("div",{style:{color:R.triggerCategory==="scheduler"?"#1976d2":"#f57c00",marginTop:2,flexShrink:0},children:R.triggerCategory==="scheduler"?c.jsx(O.MdCalendarToday,{size:18}):c.jsx(O.MdBolt,{size:18})}),c.jsxs("div",{children:[c.jsx("div",{style:{fontSize:14,fontWeight:500,color:"#212121"},children:R.label}),R.description&&c.jsx("div",{style:{fontSize:12,color:"#757575",marginTop:2},children:R.description})]})]},R.triggerKey)),t.length===0&&c.jsx("p",{className:"ff-text-muted ff-text-center",style:{fontSize:13},children:n.noTriggers})]}),b&&c.jsxs(P.Box,{sx:{display:"flex",alignItems:"center",gap:1,mt:2,fontSize:12,color:"#64748b"},children:[c.jsx(P.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})]}),F&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{role:"button",tabIndex:0,onClick:I,onKeyDown:R=>{R.key==="Enter"&&I()},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(O.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(Cn,{isMulti:!0,options:u,value:h,onChange:R=>g(R??[]),placeholder:"Select sources…",menuPosition:"fixed",menuPortalTarget:typeof document<"u"?document.body:void 0,styles:Xe.buildSelectStyles(!1,!0)})]})]})})},Be={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(Ne,{isOpen:e,onClose:o,title:u?n.addStepTitle:a.label,icon:u?c.jsx(O.MdAddCircleOutline,{}):a.icon??c.jsx(O.MdApps,{}),width:500,children:c.jsxs(P.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(O.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:Be,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(O.MdChevronRight,{size:18,color:"#9e9e9e"})]},`app-${f.key}`)),s.map(f=>c.jsxs("div",{className:We,style:Be,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:Be,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))})]})})},zt="_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[zt])??{})},[r,t]),p.useEffect(()=>{let T=!1;if(h(null),!n||!t){d([]),u(!1);return}const I=n.formSchema;return typeof I=="function"?(u(!0),I(t).then(M=>{T||(d(M),u(!1))}).catch(M=>{T||(d([]),h(M instanceof Error?M.message:"Unable to load configuration."),u(!1))})):(d(I),u(!1)),()=>{T=!0}},[n,t]);const v=t?`node-config-form-${t}`:"node-config-form",y=!a&&!f&&l.length>0,k=y?c.jsxs(c.Fragment,{children:[c.jsx(P.Button,{type:"button",variant:"outlined",size:"small",onClick:s,children:o.cancel}),c.jsx(P.Button,{type:"submit",form:v,variant:"contained",size:"small",children:o.save})]}):null;return c.jsx(Ne,{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(P.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:v,conditionConfig:g,onConditionConfigChange:b,onSubmit:T=>{if(!t)return;const I=Object.keys(g).length>0;i(t,{...T,[zt]:I?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(Ne,{isOpen:e,onClose:t,title:r?`Preview: ${r}`:"Sub-Workflow Preview",icon:c.jsx(O.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(O.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,Ue=70,Ye=60,qe={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 Dt(){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 Lt.graphlib.Graph;return o.setGraph({rankdir:r,ranksep:70,nodesep:50}),o.setDefaultEdgeLabel(()=>({})),e.forEach(i=>{const s=n[i.id]??{width:pe,height:qe[i.type??""]??80};o.setNode(i.id,{width:s.width,height:s.height})}),t.forEach(i=>o.setEdge(i.source,i.target)),Lt.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)??qe[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=Ue,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 T of k)f.set(T.id,T);const h=(y,k,T)=>{const I=r[y]??{width:pe,height:80};return a[y]={x:k-I.width/2,y:T},T+I.height},g=(y,k,T)=>{let I=T;for(const M of y)I=h(M.id,k,I)+s,oe(M.kind)&&t[M.id]&&(I=b(M.id,k,I));return I},b=(y,k,T)=>{const I=k+180,M=t[y],F=Object.keys(M),W=f.get(y),R=(W==null?void 0:W.branchLabels)??{pass:"Pass",fail:"Fail"},D=a[y],G=r[y]??{height:80},ye=D.y+G.height,me=[];let Z=T;return F.forEach((ue,xe)=>{const Ce=M[ue],Ie=Z;me.push({y:Ie-ye,label:R[ue]??ue,isPass:xe===0}),Z=g(Ce,I,Z+d),xe<F.length-1&&(Z+=l)}),u[y]={branches:me,height:Z-ye,indent:180},Z};let v=Ye;for(const y of e)v=h(y.id,400,v)+s,oe(y.kind)&&t[y.id]&&(v=b(y.id,400,v));return{nodes:n.map(y=>a[y.id]?{...y,position:a[y.id]}:y),railSpecs:u}}function Pt(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,v)=>{const y=t[b];if(!y)return;const T=v??{pass:"Pass",fail:"Fail"},I=Object.keys(y),M=(F,W,R,D)=>{if(F.length!==0){F.forEach(G=>d.push(Pt(G))),a.push({id:`e-${b}-${W}-start`,source:b,target:F[0].id,type:"gatewayBranchEdge",style:{stroke:l},data:{branch:W,filterId:b,label:R,isFirst:D===0,onAddStepClick:n,verticalRouting:s==="vertical"}});for(let G=1;G<F.length;G++)oe(F[G-1].kind)||a.push(hi(F[G-1],F[G],l,n,{filterId:b,branch:W}));for(const G of F)oe(G.kind)&&t[G.id]&&u(G.id,G.branchLabels)}};I.forEach((F,W)=>{M(y[F],F,T[F]??F,W)})};for(let b=0;b<e.length;b++){const v=e[b];if(d.push(Pt(v)),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}-${v.id}`,source:y.id,target:v.id,type:k?"plainEdge":"plusEdge",style:{stroke:l},data:k?{}:{onAddStepClick:n,referenceNodeType:y.reactFlowType}})}(v.kind==="filter"||v.kind==="approval")&&t[v.id]&&u(v.id,v.branchLabels)}const f={};if(d.forEach(b=>{f[b.id]={width:pe,height:r[b.id]??qe[b.type??""]??80}}),!(Object.keys(t).length>0)){if(i==="LR"){let T=Ye;return{nodes:d.map(M=>{const F=f[M.id].width,W=f[M.id].height,R={...M,position:{x:T,y:300-W/2}};return T+=F+Ue,R}),edges:a}}const b=400;let v=Ye;return{nodes:d.map(k=>{const T=f[k.id].height,I={...k,position:{x:b-pe/2,y:v}};return v+=T+Ue,I}),edges:a}}if(s==="vertical"){const{nodes:b,railSpecs:v}=fi(e,t,d,f);return{nodes:b.map(k=>v[k.id]?{...k,data:{...k.data,_branchRail:v[k.id]}}:k),edges:a}}return{nodes:ui(d,a,f,i),edges:a}}const Ke=({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:v,layoutDirection:y="TB",executionRecord:k,onFetchWorkflow:T,hideHeader:I=!1,workflowName:M,onWorkflowNameChange:F,onCancel:W,workflowStatus:R,workflowStatusColor:D,saveLabel:G,optionsResolvers:ye})=>{const{fitView:me=!0,fitViewPadding:Z=.3,showControls:ue=!0,showMiniMap:xe=!1,panOnScroll:Ce=!0,zoomOnScroll:Ie=!1,minZoom:bn=.25,maxZoom:yn=2,snapToGrid:mn=!1,snapGrid:xn=[15,15],branchLayout:tt="horizontal",nodeBody:nt="full"}=a,fe=p.useMemo(()=>On.mergeMessages(d),[d]),[A,ee]=p.useState(()=>(n==null?void 0:n.slots)??Dt()),[$,V]=p.useState(()=>(n==null?void 0:n.branches)??{}),[se,Y]=p.useState(null),[Oe,rt]=p.useState(null),[q,we]=p.useState(null),[te,ot]=p.useState(null),[ve,it]=p.useState(null),[K,st]=p.useState(()=>{const m=n==null?void 0:n.slots.find(S=>S.kind==="triggerFixed"),w=m!=null&&m.id.startsWith("trigger-")?m.id.slice(8):void 0;return w?t.lookup(w)??null:null}),[lt,wn]=p.useState({}),vn=p.useCallback(m=>{wn(m)},[]),En=p.useMemo(()=>({...re.builtInNodeTypes,...r}),[r]),kn=p.useMemo(()=>({...ci,...o}),[o]),jn=p.useMemo(()=>{const m=A.filter(S=>S.kind==="userTask").length,w=Object.values($).flatMap(S=>Object.values(S).flat()).filter(S=>S.kind==="userTask").length;return m+w},[A,$]),at=v??(K==null?void 0:K.maxTasks),dt=at!==void 0&&jn>=at,ne=p.useCallback(m=>{const w=A.find(S=>S.id===m);if(w)return w;for(const S of Object.values($)){const E=Object.values(S).flat().find(C=>C.id===m);if(E)return E}return null},[A,$]),Me=p.useCallback(m=>{s||(rt(m),Y("nodeConfig"))},[s]),ct=p.useCallback(m=>{if(!s){if(A.some(w=>w.id===m)){const w=A.find(S=>S.id===m);if((w==null?void 0:w.kind)==="triggerFixed"){ee(Dt()),V({}),st(null);return}ee(S=>{const E=S.filter(C=>C.id!==m);return oe((w==null?void 0:w.kind)??"")&&!E.some(C=>C.kind==="end")?[...E,{id:"end",kind:"end",reactFlowType:"endNode"}]:E}),V(S=>{const E={...S},C=x=>{E[x]&&(Object.values(E[x]).flat().filter(j=>oe(j.kind)).forEach(j=>C(j.id)),delete E[x])};return C(m),E});return}V(w=>{const S=(C,x)=>{const j=[];for(const N of C)oe(N.kind)&&x[N.id]&&(j.push(N.id),Object.values(x[N.id]).forEach(_=>j.push(...S(_,x))));return j},E={...w};for(const C of Object.keys(E))for(const x of Object.keys(E[C])){const j=E[C][x],N=j.findIndex(L=>L.id===m);if(N===-1||j[N].kind==="end")continue;const _=j[N];let z=j.filter(L=>L.id!==m);return _.kind==="filter"&&((_.id in E?S([_],E):[]).forEach(B=>delete E[B]),delete E[_.id],z.some(B=>B.kind==="end")||(z=[...z,{id:`end-${C}-${x}`,kind:"end",reactFlowType:"endNode"}])),E[C]={...E[C],[x]:z},E}return E})}},[s,A]),Fe=p.useCallback(()=>{s||Y("triggerSelect")},[s]),ut=p.useCallback((m,w)=>{s||dt||(we(m),ot(w.filterId&&w.branch?{filterId:w.filterId,branch:w.branch}:null),Y("nodePicker"))},[s,dt]),ft=p.useCallback((m,w)=>{if(st(m),Y(null),m.skeletonState){const E=Array.isArray(w)&&w.length>0,C=(m.skeletonState.slots??[]).map(x=>x.kind!=="triggerFixed"?x:{...x,nodeData:{label:m.label,...x.nodeData??{},...E&&{sources:w}}});V(m.skeletonState.branches??{}),ee(C);return}V({});const S=Array.isArray(w)&&w.length>0;ee([{id:"start",kind:"start",reactFlowType:"startNode"},{id:`trigger-${m.triggerKey}`,kind:"triggerFixed",reactFlowType:"triggerNode",nodeData:{label:m.label,source:m.source,eventType:m.triggerKey,type:m.triggerCategory==="scheduler"?"scheduler":"event",...S&&{sources:w}},deletable:!1},{id:"end",kind:"end",reactFlowType:"endNode"}])},[]),ht=p.useCallback(()=>{var S;const m={insertAfterSlot:null,upstreamSlots:[],downstreamSlots:[],branch:te,template:K};if(!q)return m;if(te){const{filterId:E,branch:C}=te,x=A.findIndex(L=>L.id===E),j=x>=0?A.slice(0,x+1):[],N=((S=$[E])==null?void 0:S[C])??[],_=N.findIndex(L=>L.id===q),z=_>=0?N.slice(0,_+1):[];return m.upstreamSlots=[...j,...z],m.downstreamSlots=_>=0?N.slice(_+1):N,m.insertAfterSlot=z[z.length-1]??null,m}const w=A.findIndex(E=>E.id===q);return m.upstreamSlots=w>=0?A.slice(0,w+1):[],m.downstreamSlots=w>=0?A.slice(w+1):[],m.insertAfterSlot=m.upstreamSlots[m.upstreamSlots.length-1]??null,m},[A,$,q,te,K]),gt=(m,w)=>m.descriptorType===w||m.id===w||m.kind===w,pt=p.useCallback(()=>{const m=e.list(),w=K!=null&&K.availableTasks?m.filter(E=>K.availableTasks.includes(E.type)):m,S=ht();return w.filter(E=>E.maxPerWorkflow!==void 0&&A.filter(x=>x.descriptorType===E.type).length+Object.values($).flatMap(x=>Object.values(x).flat()).filter(x=>x.descriptorType===E.type).length>=E.maxPerWorkflow?!1:E.canInsert?E.canInsert(S):!(E.insertAfter&&E.insertAfter.length>0&&!S.upstreamSlots.some(x=>E.insertAfter.some(j=>gt(x,j)))||E.insertBefore&&E.insertBefore.length>0&&!S.downstreamSlots.some(x=>E.insertBefore.some(j=>gt(x,j)))))},[e,K,A,$,ht]),bt=p.useCallback(m=>{if(!q)return;const w=`${m.type}-${Date.now()}`,S=m.reactFlowType==="filterNode"||m.reactFlowType==="approvalNode"||m.reactFlowType==="conditionBranchNode",E=m.branchLabels??{pass:"Pass",fail:"Fail"},C={id:w,kind:S?m.reactFlowType==="approvalNode"?"approval":"filter":"userTask",reactFlowType:m.reactFlowType,descriptorType:m.type,formData:{},nodeData:{title:m.label},deletable:!0,branchLabels:E};if(te){const{filterId:x,branch:j}=te;V(N=>{const _=[...N[x][j]];if(S){const Q=_.filter(le=>le.kind!=="end"),vt=Q.findIndex(le=>le.id===q),Nn=vt===-1?Q.length:vt+1;return Q.splice(Nn,0,C),{...N,[x]:{...N[x],[j]:Q},[w]:Object.fromEntries(Object.keys(E).map(le=>[le,[{id:`end-${w}-${le}`,kind:"end",reactFlowType:"endNode"}]]))}}const z=_.findIndex(Q=>Q.id===q),L=_.findIndex(Q=>Q.kind==="end"),B=z===-1?L===-1?_.length:L:z+1;return _.splice(B,0,C),{...N,[x]:{...N[x],[j]:_}}})}else S?(ee(x=>{const j=x.findIndex(_=>_.id===q);return[...x.filter(_=>_.kind!=="end").slice(0,j+1),C]}),V(x=>({...x,[w]:Object.fromEntries(Object.keys(E).map(j=>[j,[{id:`end-${w}-${j}`,kind:"end",reactFlowType:"endNode"}]]))}))):ee(x=>{const j=x.findIndex(N=>N.id===q);return j===-1?x:[...x.slice(0,j+1),C,...x.slice(j+1)]});we(null),ot(null),rt(w),Y("nodeConfig")},[q,te]),yt=p.useCallback((m,w)=>{const S=x=>{const j=x.label||x.key;switch(x.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=x=>{const j=ne(m);if((j==null?void 0:j.descriptorType)!=="conditionBranch")return x;const _=(w.branchConfigs??[]).map(B=>B.key).filter(Boolean);if(_.length===0)return x;const z=x[m]??{},L={};return _.forEach(B=>{L[B]=z[B]??[{id:`end-${m}-${B}`,kind:"end",reactFlowType:"endNode"}]}),{...x,[m]:L}},C=(x,j)=>{if(x.descriptorType!=="conditionBranch")return{...x,formData:j};const N=j.branchConfigs??[],_={};return N.forEach(z=>{z.key&&(_[z.key]=S(z))}),{...x,formData:j,branchLabels:_}};if(A.some(x=>x.id===m)){V(x=>{const j=E(x);return ee(N=>N.map(_=>_.id===m?C(_,w):_)),j});return}V(x=>{const N={...E(x)};for(const _ of Object.keys(N)){const z=L=>L.map(B=>B.id===m?C(B,w):B);for(const L of Object.keys(N[_]))if(N[_][L].some(B=>B.id===m))return N[_]={...N[_],[L]:z(N[_][L])},N}return N})},[A,$,ne]),J=p.useMemo(()=>ne(Oe??""),[ne,Oe]),mt=p.useMemo(()=>J!=null&&J.descriptorType?e.forType(J.descriptorType)??null:null,[J,e]),{nodes:xt,edges:Sn}=p.useMemo(()=>gi(A,$,s?null:ut,lt,l,y,tt),[A,$,s,ut,lt,l,y,tt]),wt=p.useMemo(()=>{const m=k?new Map(k.steps.map(w=>[w.nodeId,w])):null;return xt.map(w=>{let S={};if(m){const E=m.get(w.id);E&&(S={_executionStatus:E.status,_executionError:E.error})}return w.type==="subWorkflowNode"&&T&&(S.onPreview=E=>{var x;const C=ne(w.id);it({workflowId:E,workflowLabel:((x=C==null?void 0:C.formData)==null?void 0:x.workflowLabel)??void 0})}),Object.keys(S).length>0?{...w,data:{...w.data,...S}}:w})},[xt,k,T,ne]),Tn=p.useMemo(()=>({onEditNode:Me,onDeleteNode:ct,onAddStep:()=>{},onClickAddTrigger:Fe,messages:fe,nodeRegistry:e,nodeBody:nt}),[Me,ct,Fe,fe,e,nt]),_n=p.useCallback(async()=>{i&&await i({slots:A,branches:$})},[i,A,$]);return c.jsx(Xe.OptionsResolversProvider,{resolvers:ye,children:c.jsx(re.WorkflowCanvasContext.Provider,{value:Tn,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:[!I&&(i||W||M)&&c.jsx(hn,{workflowName:M,onWorkflowNameChange:F,status:R,statusColor:D,onSave:i?_n:void 0,onCancel:W,saveLabel:G}),c.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[c.jsxs(ae,{nodes:wt,edges:Sn,nodeTypes:En,edgeTypes:kn,fitView:me,fitViewOptions:{padding:Z},nodesDraggable:!1,nodesConnectable:!1,panOnScroll:Ce,zoomOnScroll:Ie,minZoom:bn,maxZoom:yn,snapToGrid:mn,snapGrid:xn,proOptions:{hideAttribution:!0},onNodeClick:(m,w)=>{const S=ne(w.id);S&&(b!=null&&b(S)||(S.kind==="addTrigger"||S.kind==="triggerFixed"?Fe():(S.kind==="userTask"||S.kind==="filter"||S.kind==="approval")&&Me(w.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}),xe&&c.jsx(ae.MiniMap,{zoomable:!0,pannable:!0}),c.jsx(oi,{onHeightsReady:vn,nodeCount:wt.length})]}),u?se==="triggerSelect"&&u(t.list(),ft,()=>Y(null)):c.jsx(si,{open:se==="triggerSelect",templates:t.list(),messages:fe,onSelect:ft,onClose:()=>Y(null),loadTriggerSources:f}),h?se==="nodePicker"&&h(pt(),bt,()=>{Y(null),we(null)}):c.jsx(li,{open:se==="nodePicker",availableDescriptors:pt(),messages:fe,onSelect:bt,onClose:()=>{Y(null),we(null)}}),g?se==="nodeConfig"&&g(mt??void 0,J,yt,()=>Y(null)):c.jsx(ai,{open:se==="nodeConfig",nodeId:Oe,descriptor:mt,initialValues:J==null?void 0:J.formData,messages:fe,onSave:yt,onClose:()=>Y(null)}),T&&ve&&c.jsx(gn,{isOpen:!!ve,onClose:()=>it(null),workflowId:ve.workflowId,workflowLabel:ve.workflowLabel,onFetchWorkflow:T})]})]})})})},pi=Object.freeze(Object.defineProperty({__proto__:null,WorkflowCanvas:Ke,default:Ke},Symbol.toStringTag,{value:"Module"})),Ge="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(Ge),l=p.useMemo(()=>{const a=new Set;return e.forEach(u=>{u.category&&a.add(u.category)}),[Ge,...Array.from(a)]},[e]),d=p.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(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(O.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(O.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(O.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(O.MdPlayArrow,{size:14})},success:{label:"Success",color:H.EXECUTION_STATUS_COLOR.success,icon:p.createElement(O.MdCheckCircle,{size:14})},failed:{label:"Failed",color:H.EXECUTION_STATUS_COLOR.failed,icon:p.createElement(O.MdError,{size:14})},cancelled:{label:"Cancelled",color:H.EXECUTION_STATUS_COLOR.cancelled,icon:p.createElement(O.MdCancel,{size:14})}},mi={pending:{color:H.EXECUTION_STATUS_COLOR.pending,icon:p.createElement(O.MdHourglassEmpty,{size:14})},running:{color:H.EXECUTION_STATUS_COLOR.running,icon:p.createElement(O.MdPlayArrow,{size:14})},success:{color:H.EXECUTION_STATUS_COLOR.success,icon:p.createElement(O.MdCheckCircle,{size:14})},failed:{color:H.EXECUTION_STATUS_COLOR.failed,icon:p.createElement(O.MdError,{size:14})},skipped:{color:H.EXECUTION_STATUS_COLOR.skipped,icon:p.createElement(O.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 xi({step:e}){const[t,n]=p.useState(!1),r=mi[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(O.MdExpandLess,{size:16}):p.createElement(O.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 wi({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(O.MdChevronRight,{size:14,color:"#bdbdbd"})]})}const vi=({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(O.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(wi,{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(O.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(O.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(xi,{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"})})]})},Ei={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-END_USER_CREATION",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"New User Registration",nodeData:{label:"New User Registration"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Welcome Email",nodeData:{title:"Welcome Email"}},{id:"approval-1",kind:"approval",reactFlowType:"approvalNode",descriptorType:"approval",deletable:!0,label:"Manager Approval",branchLabels:{pass:"Approved",fail:"Rejected"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{"approval-1":{pass:[{id:"notification-pass-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Approval Confirmed",nodeData:{title:"Approval Confirmed"}}],fail:[{id:"notification-fail-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Rejection Notice",nodeData:{title:"Rejection Notice"}}]}}},ki={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-ACCESS_REQUEST",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"Access Request Submitted",nodeData:{label:"Access Request Submitted"}},{id:"approval-1",kind:"approval",reactFlowType:"approvalNode",descriptorType:"approval",deletable:!0,label:"Access Approval",branchLabels:{pass:"Approved",fail:"Denied"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{"approval-1":{pass:[{id:"restApi-1",kind:"userTask",reactFlowType:"restApiNode",descriptorType:"restApi",deletable:!0,label:"Provision Access",nodeData:{title:"Provision Access"}},{id:"notification-pass-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Access Granted Email",nodeData:{title:"Access Granted Email"}}],fail:[{id:"notification-fail-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Access Denied Email",nodeData:{title:"Access Denied Email"}}]}}},ji={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-USER_DEACTIVATION",kind:"triggerFixed",reactFlowType:"triggerNode",deletable:!0,label:"User Deactivation",nodeData:{label:"User Deactivation"}},{id:"delay-1",kind:"userTask",reactFlowType:"delayNode",descriptorType:"delay",deletable:!0,label:"Grace Period",nodeData:{title:"Grace Period",duration:7,unit:"days"},formData:{duration:7,unit:"days"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Notify IT Team",nodeData:{title:"Notify IT Team"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{}},Si={slots:[{id:"start",kind:"start",reactFlowType:"startNode",deletable:!1},{id:"trigger-WEBHOOK_TRIGGER",kind:"triggerFixed",reactFlowType:"webhookTriggerNode",deletable:!0,label:"Incoming Webhook",nodeData:{label:"Incoming Webhook"}},{id:"restApi-1",kind:"userTask",reactFlowType:"restApiNode",descriptorType:"restApi",deletable:!0,label:"Call External API",nodeData:{title:"Call External API"}},{id:"notification-1",kind:"userTask",reactFlowType:"notificationNode",descriptorType:"notification",deletable:!0,label:"Notify on Completion",nodeData:{title:"Notify on Completion"}},{id:"end",kind:"end",reactFlowType:"endNode",deletable:!1}],branches:{}};exports.FlowForgeCanvas=Ke;exports.FlowForgeHeader=hn;exports.SubWorkflowPreviewDrawer=gn;exports.WorkflowExecutionHistory=vi;exports.WorkflowTemplateLibrary=yi;exports.accessRequestSkeleton=ki;exports.offboardingSkeleton=ji;exports.userOnboardingSkeleton=Ei;exports.webhookIntegrationSkeleton=Si;
|
|
2
|
+
//# sourceMappingURL=templateSkeletons-Ct26LDFe.js.map
|