@notmrabhi/flowforge 0.1.37 → 0.1.39

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