@wjmpantig/react-dbml-renderer 1.0.0 → 1.0.1
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/README.md +3 -1
- package/dist/react-dbml-renderer.cjs +1 -12
- package/dist/react-dbml-renderer.js +1996 -8663
- package/dist/style.css +1 -1
- package/package.json +17 -5
|
@@ -1,12 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const z=require("react"),Rl=require("@dbml/core");require("react-dom");function ks(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var It={exports:{}},tt={};var xo;function Pl(){if(xo)return tt;xo=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,o,s){var i=null;if(s!==void 0&&(i=""+s),o.key!==void 0&&(i=""+o.key),"key"in o){s={};for(var a in o)a!=="key"&&(s[a]=o[a])}else s=o;return o=s.ref,{$$typeof:e,type:r,key:i,ref:o!==void 0?o:null,props:s}}return tt.Fragment=t,tt.jsx=n,tt.jsxs=n,tt}var nt={};var bo;function Tl(){return bo||(bo=1,process.env.NODE_ENV!=="production"&&(function(){function e(I){if(I==null)return null;if(typeof I=="function")return I.$$typeof===k?null:I.displayName||I.name||null;if(typeof I=="string")return I;switch(I){case y:return"Fragment";case b:return"Profiler";case w:return"StrictMode";case _:return"Suspense";case C:return"SuspenseList";case P:return"Activity"}if(typeof I=="object")switch(typeof I.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),I.$$typeof){case g:return"Portal";case x:return I.displayName||"Context";case p:return(I._context.displayName||"Context")+".Consumer";case E:var B=I.render;return I=I.displayName,I||(I=B.displayName||B.name||"",I=I!==""?"ForwardRef("+I+")":"ForwardRef"),I;case v:return B=I.displayName||null,B!==null?B:e(I.type)||"Memo";case N:B=I._payload,I=I._init;try{return e(I(B))}catch{}}return null}function t(I){return""+I}function n(I){try{t(I);var B=!1}catch{B=!0}if(B){B=console;var O=B.error,T=typeof Symbol=="function"&&Symbol.toStringTag&&I[Symbol.toStringTag]||I.constructor.name||"Object";return O.call(B,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",T),t(I)}}function r(I){if(I===y)return"<>";if(typeof I=="object"&&I!==null&&I.$$typeof===N)return"<...>";try{var B=e(I);return B?"<"+B+">":"<...>"}catch{return"<...>"}}function o(){var I=M.A;return I===null?null:I.getOwner()}function s(){return Error("react-stack-top-frame")}function i(I){if($.call(I,"key")){var B=Object.getOwnPropertyDescriptor(I,"key").get;if(B&&B.isReactWarning)return!1}return I.key!==void 0}function a(I,B){function O(){A||(A=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",B))}O.isReactWarning=!0,Object.defineProperty(I,"key",{get:O,configurable:!0})}function d(){var I=e(this.type);return L[I]||(L[I]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),I=this.props.ref,I!==void 0?I:null}function u(I,B,O,T,H,Y){var F=O.ref;return I={$$typeof:m,type:I,key:B,props:O,_owner:T},(F!==void 0?F:null)!==null?Object.defineProperty(I,"ref",{enumerable:!1,get:d}):Object.defineProperty(I,"ref",{enumerable:!1,value:null}),I._store={},Object.defineProperty(I._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(I,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(I,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.defineProperty(I,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Y}),Object.freeze&&(Object.freeze(I.props),Object.freeze(I)),I}function c(I,B,O,T,H,Y){var F=B.children;if(F!==void 0)if(T)if(S(F)){for(T=0;T<F.length;T++)l(F[T]);Object.freeze&&Object.freeze(F)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else l(F);if($.call(B,"key")){F=e(I);var q=Object.keys(B).filter(function(U){return U!=="key"});T=0<q.length?"{key: someKey, "+q.join(": ..., ")+": ...}":"{key: someKey}",W[F+T]||(q=0<q.length?"{"+q.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
|
-
let props = %s;
|
|
3
|
-
<%s {...props} />
|
|
4
|
-
React keys must be passed directly to JSX without using spread:
|
|
5
|
-
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,T,F,q,F),W[F+T]=!0)}if(F=null,O!==void 0&&(n(O),F=""+O),i(B)&&(n(B.key),F=""+B.key),"key"in B){O={};for(var G in B)G!=="key"&&(O[G]=B[G])}else O=B;return F&&a(O,typeof I=="function"?I.displayName||I.name||"Unknown":I),u(I,F,O,o(),H,Y)}function l(I){f(I)?I._store&&(I._store.validated=1):typeof I=="object"&&I!==null&&I.$$typeof===N&&(I._payload.status==="fulfilled"?f(I._payload.value)&&I._payload.value._store&&(I._payload.value._store.validated=1):I._store&&(I._store.validated=1))}function f(I){return typeof I=="object"&&I!==null&&I.$$typeof===m}var h=z,m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),w=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),p=Symbol.for("react.consumer"),x=Symbol.for("react.context"),E=Symbol.for("react.forward_ref"),_=Symbol.for("react.suspense"),C=Symbol.for("react.suspense_list"),v=Symbol.for("react.memo"),N=Symbol.for("react.lazy"),P=Symbol.for("react.activity"),k=Symbol.for("react.client.reference"),M=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,$=Object.prototype.hasOwnProperty,S=Array.isArray,R=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(I){return I()}};var A,L={},j=h.react_stack_bottom_frame.bind(h,s)(),V=R(r(s)),W={};nt.Fragment=y,nt.jsx=function(I,B,O){var T=1e4>M.recentlyCreatedOwnerStacks++;return c(I,B,O,!1,T?Error("react-stack-top-frame"):j,T?R(r(I)):V)},nt.jsxs=function(I,B,O){var T=1e4>M.recentlyCreatedOwnerStacks++;return c(I,B,O,!0,T?Error("react-stack-top-frame"):j,T?R(r(I)):V)}})()),nt}var vo;function Al(){return vo||(vo=1,process.env.NODE_ENV==="production"?It.exports=Pl():It.exports=Tl()),It.exports}var D=Al(),Nn,_o;function Wr(){if(_o)return Nn;_o=1;var e="\0",t="\0",n="";class r{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(c){c&&(this._isDirected=Object.hasOwn(c,"directed")?c.directed:!0,this._isMultigraph=Object.hasOwn(c,"multigraph")?c.multigraph:!1,this._isCompound=Object.hasOwn(c,"compound")?c.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(c){return this._label=c,this}graph(){return this._label}setDefaultNodeLabel(c){return this._defaultNodeLabelFn=c,typeof c!="function"&&(this._defaultNodeLabelFn=()=>c),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var c=this;return this.nodes().filter(l=>Object.keys(c._in[l]).length===0)}sinks(){var c=this;return this.nodes().filter(l=>Object.keys(c._out[l]).length===0)}setNodes(c,l){var f=arguments,h=this;return c.forEach(function(m){f.length>1?h.setNode(m,l):h.setNode(m)}),this}setNode(c,l){return Object.hasOwn(this._nodes,c)?(arguments.length>1&&(this._nodes[c]=l),this):(this._nodes[c]=arguments.length>1?l:this._defaultNodeLabelFn(c),this._isCompound&&(this._parent[c]=t,this._children[c]={},this._children[t][c]=!0),this._in[c]={},this._preds[c]={},this._out[c]={},this._sucs[c]={},++this._nodeCount,this)}node(c){return this._nodes[c]}hasNode(c){return Object.hasOwn(this._nodes,c)}removeNode(c){var l=this;if(Object.hasOwn(this._nodes,c)){var f=h=>l.removeEdge(l._edgeObjs[h]);delete this._nodes[c],this._isCompound&&(this._removeFromParentsChildList(c),delete this._parent[c],this.children(c).forEach(function(h){l.setParent(h)}),delete this._children[c]),Object.keys(this._in[c]).forEach(f),delete this._in[c],delete this._preds[c],Object.keys(this._out[c]).forEach(f),delete this._out[c],delete this._sucs[c],--this._nodeCount}return this}setParent(c,l){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(l===void 0)l=t;else{l+="";for(var f=l;f!==void 0;f=this.parent(f))if(f===c)throw new Error("Setting "+l+" as parent of "+c+" would create a cycle");this.setNode(l)}return this.setNode(c),this._removeFromParentsChildList(c),this._parent[c]=l,this._children[l][c]=!0,this}_removeFromParentsChildList(c){delete this._children[this._parent[c]][c]}parent(c){if(this._isCompound){var l=this._parent[c];if(l!==t)return l}}children(c=t){if(this._isCompound){var l=this._children[c];if(l)return Object.keys(l)}else{if(c===t)return this.nodes();if(this.hasNode(c))return[]}}predecessors(c){var l=this._preds[c];if(l)return Object.keys(l)}successors(c){var l=this._sucs[c];if(l)return Object.keys(l)}neighbors(c){var l=this.predecessors(c);if(l){const h=new Set(l);for(var f of this.successors(c))h.add(f);return Array.from(h.values())}}isLeaf(c){var l;return this.isDirected()?l=this.successors(c):l=this.neighbors(c),l.length===0}filterNodes(c){var l=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});l.setGraph(this.graph());var f=this;Object.entries(this._nodes).forEach(function([g,y]){c(g)&&l.setNode(g,y)}),Object.values(this._edgeObjs).forEach(function(g){l.hasNode(g.v)&&l.hasNode(g.w)&&l.setEdge(g,f.edge(g))});var h={};function m(g){var y=f.parent(g);return y===void 0||l.hasNode(y)?(h[g]=y,y):y in h?h[y]:m(y)}return this._isCompound&&l.nodes().forEach(g=>l.setParent(g,m(g))),l}setDefaultEdgeLabel(c){return this._defaultEdgeLabelFn=c,typeof c!="function"&&(this._defaultEdgeLabelFn=()=>c),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(c,l){var f=this,h=arguments;return c.reduce(function(m,g){return h.length>1?f.setEdge(m,g,l):f.setEdge(m,g),g}),this}setEdge(){var c,l,f,h,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(c=g.v,l=g.w,f=g.name,arguments.length===2&&(h=arguments[1],m=!0)):(c=g,l=arguments[1],f=arguments[3],arguments.length>2&&(h=arguments[2],m=!0)),c=""+c,l=""+l,f!==void 0&&(f=""+f);var y=i(this._isDirected,c,l,f);if(Object.hasOwn(this._edgeLabels,y))return m&&(this._edgeLabels[y]=h),this;if(f!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(c),this.setNode(l),this._edgeLabels[y]=m?h:this._defaultEdgeLabelFn(c,l,f);var w=a(this._isDirected,c,l,f);return c=w.v,l=w.w,Object.freeze(w),this._edgeObjs[y]=w,o(this._preds[l],c),o(this._sucs[c],l),this._in[l][y]=w,this._out[c][y]=w,this._edgeCount++,this}edge(c,l,f){var h=arguments.length===1?d(this._isDirected,arguments[0]):i(this._isDirected,c,l,f);return this._edgeLabels[h]}edgeAsObj(){const c=this.edge(...arguments);return typeof c!="object"?{label:c}:c}hasEdge(c,l,f){var h=arguments.length===1?d(this._isDirected,arguments[0]):i(this._isDirected,c,l,f);return Object.hasOwn(this._edgeLabels,h)}removeEdge(c,l,f){var h=arguments.length===1?d(this._isDirected,arguments[0]):i(this._isDirected,c,l,f),m=this._edgeObjs[h];return m&&(c=m.v,l=m.w,delete this._edgeLabels[h],delete this._edgeObjs[h],s(this._preds[l],c),s(this._sucs[c],l),delete this._in[l][h],delete this._out[c][h],this._edgeCount--),this}inEdges(c,l){var f=this._in[c];if(f){var h=Object.values(f);return l?h.filter(m=>m.v===l):h}}outEdges(c,l){var f=this._out[c];if(f){var h=Object.values(f);return l?h.filter(m=>m.w===l):h}}nodeEdges(c,l){var f=this.inEdges(c,l);if(f)return f.concat(this.outEdges(c,l))}}function o(u,c){u[c]?u[c]++:u[c]=1}function s(u,c){--u[c]||delete u[c]}function i(u,c,l,f){var h=""+c,m=""+l;if(!u&&h>m){var g=h;h=m,m=g}return h+n+m+n+(f===void 0?e:f)}function a(u,c,l,f){var h=""+c,m=""+l;if(!u&&h>m){var g=h;h=m,m=g}var y={v:h,w:m};return f&&(y.name=f),y}function d(u,c){return i(u,c.v,c.w,c.name)}return Nn=r,Nn}var Cn,Eo;function Dl(){return Eo||(Eo=1,Cn="2.2.4"),Cn}var kn,So;function Ll(){return So||(So=1,kn={Graph:Wr(),version:Dl()}),kn}var Mn,No;function $l(){if(No)return Mn;No=1;var e=Wr();Mn={write:t,read:o};function t(s){var i={options:{directed:s.isDirected(),multigraph:s.isMultigraph(),compound:s.isCompound()},nodes:n(s),edges:r(s)};return s.graph()!==void 0&&(i.value=structuredClone(s.graph())),i}function n(s){return s.nodes().map(function(i){var a=s.node(i),d=s.parent(i),u={v:i};return a!==void 0&&(u.value=a),d!==void 0&&(u.parent=d),u})}function r(s){return s.edges().map(function(i){var a=s.edge(i),d={v:i.v,w:i.w};return i.name!==void 0&&(d.name=i.name),a!==void 0&&(d.value=a),d})}function o(s){var i=new e(s.options).setGraph(s.value);return s.nodes.forEach(function(a){i.setNode(a.v,a.value),a.parent&&i.setParent(a.v,a.parent)}),s.edges.forEach(function(a){i.setEdge({v:a.v,w:a.w,name:a.name},a.value)}),i}return Mn}var On,Co;function jl(){if(Co)return On;Co=1,On=e;function e(t){var n={},r=[],o;function s(i){Object.hasOwn(n,i)||(n[i]=!0,o.push(i),t.successors(i).forEach(s),t.predecessors(i).forEach(s))}return t.nodes().forEach(function(i){o=[],s(i),o.length&&r.push(o)}),r}return On}var In,ko;function Ms(){if(ko)return In;ko=1;class e{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var o=this._keyIndices;if(n=String(n),!Object.hasOwn(o,n)){var s=this._arr,i=s.length;return o[n]=i,s.push({key:n,priority:r}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var o=this._keyIndices[n];if(r>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+r);this._arr[o].priority=r,this._decrease(o)}_heapify(n){var r=this._arr,o=2*n,s=o+1,i=n;o<r.length&&(i=r[o].priority<r[i].priority?o:i,s<r.length&&(i=r[s].priority<r[i].priority?s:i),i!==n&&(this._swap(n,i),this._heapify(i)))}_decrease(n){for(var r=this._arr,o=r[n].priority,s;n!==0&&(s=n>>1,!(r[s].priority<o));)this._swap(n,s),n=s}_swap(n,r){var o=this._arr,s=this._keyIndices,i=o[n],a=o[r];o[n]=a,o[r]=i,s[a.key]=n,s[i.key]=r}}return In=e,In}var Rn,Mo;function Os(){if(Mo)return Rn;Mo=1;var e=Ms();Rn=n;var t=()=>1;function n(o,s,i,a){return r(o,String(s),i||t,a||function(d){return o.outEdges(d)})}function r(o,s,i,a){var d={},u=new e,c,l,f=function(h){var m=h.v!==c?h.v:h.w,g=d[m],y=i(h),w=l.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+h+" Weight: "+y);w<g.distance&&(g.distance=w,g.predecessor=c,u.decrease(m,w))};for(o.nodes().forEach(function(h){var m=h===s?0:Number.POSITIVE_INFINITY;d[h]={distance:m},u.add(h,m)});u.size()>0&&(c=u.removeMin(),l=d[c],l.distance!==Number.POSITIVE_INFINITY);)a(c).forEach(f);return d}return Rn}var Pn,Oo;function zl(){if(Oo)return Pn;Oo=1;var e=Os();Pn=t;function t(n,r,o){return n.nodes().reduce(function(s,i){return s[i]=e(n,i,r,o),s},{})}return Pn}var Tn,Io;function Is(){if(Io)return Tn;Io=1,Tn=e;function e(t){var n=0,r=[],o={},s=[];function i(a){var d=o[a]={onStack:!0,lowlink:n,index:n++};if(r.push(a),t.successors(a).forEach(function(l){Object.hasOwn(o,l)?o[l].onStack&&(d.lowlink=Math.min(d.lowlink,o[l].index)):(i(l),d.lowlink=Math.min(d.lowlink,o[l].lowlink))}),d.lowlink===d.index){var u=[],c;do c=r.pop(),o[c].onStack=!1,u.push(c);while(a!==c);s.push(u)}}return t.nodes().forEach(function(a){Object.hasOwn(o,a)||i(a)}),s}return Tn}var An,Ro;function Hl(){if(Ro)return An;Ro=1;var e=Is();An=t;function t(n){return e(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return An}var Dn,Po;function Vl(){if(Po)return Dn;Po=1,Dn=t;var e=()=>1;function t(r,o,s){return n(r,o||e,s||function(i){return r.outEdges(i)})}function n(r,o,s){var i={},a=r.nodes();return a.forEach(function(d){i[d]={},i[d][d]={distance:0},a.forEach(function(u){d!==u&&(i[d][u]={distance:Number.POSITIVE_INFINITY})}),s(d).forEach(function(u){var c=u.v===d?u.w:u.v,l=o(u);i[d][c]={distance:l,predecessor:d}})}),a.forEach(function(d){var u=i[d];a.forEach(function(c){var l=i[c];a.forEach(function(f){var h=l[d],m=u[f],g=l[f],y=h.distance+m.distance;y<g.distance&&(g.distance=y,g.predecessor=m.predecessor)})})}),i}return Dn}var Ln,To;function Rs(){if(To)return Ln;To=1;function e(n){var r={},o={},s=[];function i(a){if(Object.hasOwn(o,a))throw new t;Object.hasOwn(r,a)||(o[a]=!0,r[a]=!0,n.predecessors(a).forEach(i),delete o[a],s.push(a))}if(n.sinks().forEach(i),Object.keys(r).length!==n.nodeCount())throw new t;return s}class t extends Error{constructor(){super(...arguments)}}return Ln=e,e.CycleException=t,Ln}var $n,Ao;function Bl(){if(Ao)return $n;Ao=1;var e=Rs();$n=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return $n}var jn,Do;function Ps(){if(Do)return jn;Do=1,jn=e;function e(o,s,i){Array.isArray(s)||(s=[s]);var a=o.isDirected()?l=>o.successors(l):l=>o.neighbors(l),d=i==="post"?t:n,u=[],c={};return s.forEach(l=>{if(!o.hasNode(l))throw new Error("Graph does not have node: "+l);d(l,a,c,u)}),u}function t(o,s,i,a){for(var d=[[o,!1]];d.length>0;){var u=d.pop();u[1]?a.push(u[0]):Object.hasOwn(i,u[0])||(i[u[0]]=!0,d.push([u[0],!0]),r(s(u[0]),c=>d.push([c,!1])))}}function n(o,s,i,a){for(var d=[o];d.length>0;){var u=d.pop();Object.hasOwn(i,u)||(i[u]=!0,a.push(u),r(s(u),c=>d.push(c)))}}function r(o,s){for(var i=o.length;i--;)s(o[i],i,o);return o}return jn}var zn,Lo;function Fl(){if(Lo)return zn;Lo=1;var e=Ps();zn=t;function t(n,r){return e(n,r,"post")}return zn}var Hn,$o;function ql(){if($o)return Hn;$o=1;var e=Ps();Hn=t;function t(n,r){return e(n,r,"pre")}return Hn}var Vn,jo;function Yl(){if(jo)return Vn;jo=1;var e=Wr(),t=Ms();Vn=n;function n(r,o){var s=new e,i={},a=new t,d;function u(l){var f=l.v===d?l.w:l.v,h=a.priority(f);if(h!==void 0){var m=o(l);m<h&&(i[f]=d,a.decrease(f,m))}}if(r.nodeCount()===0)return s;r.nodes().forEach(function(l){a.add(l,Number.POSITIVE_INFINITY),s.setNode(l)}),a.decrease(r.nodes()[0],0);for(var c=!1;a.size()>0;){if(d=a.removeMin(),Object.hasOwn(i,d))s.setEdge(d,i[d]);else{if(c)throw new Error("Input graph is not connected: "+r);c=!0}r.nodeEdges(d).forEach(u)}return s}return Vn}var Bn,zo;function Wl(){return zo||(zo=1,Bn={components:jl(),dijkstra:Os(),dijkstraAll:zl(),findCycles:Hl(),floydWarshall:Vl(),isAcyclic:Bl(),postorder:Fl(),preorder:ql(),prim:Yl(),tarjan:Is(),topsort:Rs()}),Bn}var Fn,Ho;function ye(){if(Ho)return Fn;Ho=1;var e=Ll();return Fn={Graph:e.Graph,json:$l(),alg:Wl(),version:e.version},Fn}var qn,Vo;function Gl(){if(Vo)return qn;Vo=1;class e{constructor(){let o={};o._next=o._prev=o,this._sentinel=o}dequeue(){let o=this._sentinel,s=o._prev;if(s!==o)return t(s),s}enqueue(o){let s=this._sentinel;o._prev&&o._next&&t(o),o._next=s._next,s._next._prev=o,s._next=o,o._prev=s}toString(){let o=[],s=this._sentinel,i=s._prev;for(;i!==s;)o.push(JSON.stringify(i,n)),i=i._prev;return"["+o.join(", ")+"]"}}function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,o){if(r!=="_next"&&r!=="_prev")return o}return qn=e,qn}var Yn,Bo;function Xl(){if(Bo)return Yn;Bo=1;let e=ye().Graph,t=Gl();Yn=r;let n=()=>1;function r(u,c){if(u.nodeCount()<=1)return[];let l=i(u,c||n);return o(l.graph,l.buckets,l.zeroIdx).flatMap(h=>u.outEdges(h.v,h.w))}function o(u,c,l){let f=[],h=c[c.length-1],m=c[0],g;for(;u.nodeCount();){for(;g=m.dequeue();)s(u,c,l,g);for(;g=h.dequeue();)s(u,c,l,g);if(u.nodeCount()){for(let y=c.length-2;y>0;--y)if(g=c[y].dequeue(),g){f=f.concat(s(u,c,l,g,!0));break}}}return f}function s(u,c,l,f,h){let m=h?[]:void 0;return u.inEdges(f.v).forEach(g=>{let y=u.edge(g),w=u.node(g.v);h&&m.push({v:g.v,w:g.w}),w.out-=y,a(c,l,w)}),u.outEdges(f.v).forEach(g=>{let y=u.edge(g),w=g.w,b=u.node(w);b.in-=y,a(c,l,b)}),u.removeNode(f.v),m}function i(u,c){let l=new e,f=0,h=0;u.nodes().forEach(y=>{l.setNode(y,{v:y,in:0,out:0})}),u.edges().forEach(y=>{let w=l.edge(y.v,y.w)||0,b=c(y),p=w+b;l.setEdge(y.v,y.w,p),h=Math.max(h,l.node(y.v).out+=b),f=Math.max(f,l.node(y.w).in+=b)});let m=d(h+f+3).map(()=>new t),g=f+1;return l.nodes().forEach(y=>{a(m,g,l.node(y))}),{graph:l,buckets:m,zeroIdx:g}}function a(u,c,l){l.out?l.in?u[l.out-l.in+c].enqueue(l):u[u.length-1].enqueue(l):u[0].enqueue(l)}function d(u){const c=[];for(let l=0;l<u;l++)c.push(l);return c}return Yn}var Wn,Fo;function ie(){if(Fo)return Wn;Fo=1;let e=ye().Graph;Wn={addBorderNode:c,addDummyNode:t,applyWithChunking:h,asNonCompoundGraph:r,buildLayerMatrix:a,intersectRect:i,mapValues:_,maxRank:m,normalizeRanks:d,notime:w,partition:g,pick:E,predecessorWeights:s,range:x,removeEmptyRanks:u,simplify:n,successorWeights:o,time:y,uniqueId:p,zipObject:C};function t(v,N,P,k){for(var M=k;v.hasNode(M);)M=p(k);return P.dummy=N,v.setNode(M,P),M}function n(v){let N=new e().setGraph(v.graph());return v.nodes().forEach(P=>N.setNode(P,v.node(P))),v.edges().forEach(P=>{let k=N.edge(P.v,P.w)||{weight:0,minlen:1},M=v.edge(P);N.setEdge(P.v,P.w,{weight:k.weight+M.weight,minlen:Math.max(k.minlen,M.minlen)})}),N}function r(v){let N=new e({multigraph:v.isMultigraph()}).setGraph(v.graph());return v.nodes().forEach(P=>{v.children(P).length||N.setNode(P,v.node(P))}),v.edges().forEach(P=>{N.setEdge(P,v.edge(P))}),N}function o(v){let N=v.nodes().map(P=>{let k={};return v.outEdges(P).forEach(M=>{k[M.w]=(k[M.w]||0)+v.edge(M).weight}),k});return C(v.nodes(),N)}function s(v){let N=v.nodes().map(P=>{let k={};return v.inEdges(P).forEach(M=>{k[M.v]=(k[M.v]||0)+v.edge(M).weight}),k});return C(v.nodes(),N)}function i(v,N){let P=v.x,k=v.y,M=N.x-P,$=N.y-k,S=v.width/2,R=v.height/2;if(!M&&!$)throw new Error("Not possible to find intersection inside of the rectangle");let A,L;return Math.abs($)*S>Math.abs(M)*R?($<0&&(R=-R),A=R*M/$,L=R):(M<0&&(S=-S),A=S,L=S*$/M),{x:P+A,y:k+L}}function a(v){let N=x(m(v)+1).map(()=>[]);return v.nodes().forEach(P=>{let k=v.node(P),M=k.rank;M!==void 0&&(N[M][k.order]=P)}),N}function d(v){let N=v.nodes().map(k=>{let M=v.node(k).rank;return M===void 0?Number.MAX_VALUE:M}),P=h(Math.min,N);v.nodes().forEach(k=>{let M=v.node(k);Object.hasOwn(M,"rank")&&(M.rank-=P)})}function u(v){let N=v.nodes().map(S=>v.node(S).rank),P=h(Math.min,N),k=[];v.nodes().forEach(S=>{let R=v.node(S).rank-P;k[R]||(k[R]=[]),k[R].push(S)});let M=0,$=v.graph().nodeRankFactor;Array.from(k).forEach((S,R)=>{S===void 0&&R%$!==0?--M:S!==void 0&&M&&S.forEach(A=>v.node(A).rank+=M)})}function c(v,N,P,k){let M={width:0,height:0};return arguments.length>=4&&(M.rank=P,M.order=k),t(v,"border",M,N)}function l(v,N=f){const P=[];for(let k=0;k<v.length;k+=N){const M=v.slice(k,k+N);P.push(M)}return P}const f=65535;function h(v,N){if(N.length>f){const P=l(N);return v.apply(null,P.map(k=>v.apply(null,k)))}else return v.apply(null,N)}function m(v){const P=v.nodes().map(k=>{let M=v.node(k).rank;return M===void 0?Number.MIN_VALUE:M});return h(Math.max,P)}function g(v,N){let P={lhs:[],rhs:[]};return v.forEach(k=>{N(k)?P.lhs.push(k):P.rhs.push(k)}),P}function y(v,N){let P=Date.now();try{return N()}finally{console.log(v+" time: "+(Date.now()-P)+"ms")}}function w(v,N){return N()}let b=0;function p(v){var N=++b;return v+(""+N)}function x(v,N,P=1){N==null&&(N=v,v=0);let k=$=>$<N;P<0&&(k=$=>N<$);const M=[];for(let $=v;k($);$+=P)M.push($);return M}function E(v,N){const P={};for(const k of N)v[k]!==void 0&&(P[k]=v[k]);return P}function _(v,N){let P=N;return typeof N=="string"&&(P=k=>k[N]),Object.entries(v).reduce((k,[M,$])=>(k[M]=P($,M),k),{})}function C(v,N){return v.reduce((P,k,M)=>(P[k]=N[M],P),{})}return Wn}var Gn,qo;function Zl(){if(qo)return Gn;qo=1;let e=Xl(),t=ie().uniqueId;Gn={run:n,undo:o};function n(s){(s.graph().acyclicer==="greedy"?e(s,a(s)):r(s)).forEach(d=>{let u=s.edge(d);s.removeEdge(d),u.forwardName=d.name,u.reversed=!0,s.setEdge(d.w,d.v,u,t("rev"))});function a(d){return u=>d.edge(u).weight}}function r(s){let i=[],a={},d={};function u(c){Object.hasOwn(d,c)||(d[c]=!0,a[c]=!0,s.outEdges(c).forEach(l=>{Object.hasOwn(a,l.w)?i.push(l):u(l.w)}),delete a[c])}return s.nodes().forEach(u),i}function o(s){s.edges().forEach(i=>{let a=s.edge(i);if(a.reversed){s.removeEdge(i);let d=a.forwardName;delete a.reversed,delete a.forwardName,s.setEdge(i.w,i.v,a,d)}})}return Gn}var Xn,Yo;function Kl(){if(Yo)return Xn;Yo=1;let e=ie();Xn={run:t,undo:r};function t(o){o.graph().dummyChains=[],o.edges().forEach(s=>n(o,s))}function n(o,s){let i=s.v,a=o.node(i).rank,d=s.w,u=o.node(d).rank,c=s.name,l=o.edge(s),f=l.labelRank;if(u===a+1)return;o.removeEdge(s);let h,m,g;for(g=0,++a;a<u;++g,++a)l.points=[],m={width:0,height:0,edgeLabel:l,edgeObj:s,rank:a},h=e.addDummyNode(o,"edge",m,"_d"),a===f&&(m.width=l.width,m.height=l.height,m.dummy="edge-label",m.labelpos=l.labelpos),o.setEdge(i,h,{weight:l.weight},c),g===0&&o.graph().dummyChains.push(h),i=h;o.setEdge(i,d,{weight:l.weight},c)}function r(o){o.graph().dummyChains.forEach(s=>{let i=o.node(s),a=i.edgeLabel,d;for(o.setEdge(i.edgeObj,a);i.dummy;)d=o.successors(s)[0],o.removeNode(s),a.points.push({x:i.x,y:i.y}),i.dummy==="edge-label"&&(a.x=i.x,a.y=i.y,a.width=i.width,a.height=i.height),s=d,i=o.node(s)})}return Xn}var Zn,Wo;function Xt(){if(Wo)return Zn;Wo=1;const{applyWithChunking:e}=ie();Zn={longestPath:t,slack:n};function t(r){var o={};function s(i){var a=r.node(i);if(Object.hasOwn(o,i))return a.rank;o[i]=!0;let d=r.outEdges(i).map(c=>c==null?Number.POSITIVE_INFINITY:s(c.w)-r.edge(c).minlen);var u=e(Math.min,d);return u===Number.POSITIVE_INFINITY&&(u=0),a.rank=u}r.sources().forEach(s)}function n(r,o){return r.node(o.w).rank-r.node(o.v).rank-r.edge(o).minlen}return Zn}var Kn,Go;function Ts(){if(Go)return Kn;Go=1;var e=ye().Graph,t=Xt().slack;Kn=n;function n(i){var a=new e({directed:!1}),d=i.nodes()[0],u=i.nodeCount();a.setNode(d,{});for(var c,l;r(a,i)<u;)c=o(a,i),l=a.hasNode(c.v)?t(i,c):-t(i,c),s(a,i,l);return a}function r(i,a){function d(u){a.nodeEdges(u).forEach(c=>{var l=c.v,f=u===l?c.w:l;!i.hasNode(f)&&!t(a,c)&&(i.setNode(f,{}),i.setEdge(u,f,{}),d(f))})}return i.nodes().forEach(d),i.nodeCount()}function o(i,a){return a.edges().reduce((u,c)=>{let l=Number.POSITIVE_INFINITY;return i.hasNode(c.v)!==i.hasNode(c.w)&&(l=t(a,c)),l<u[0]?[l,c]:u},[Number.POSITIVE_INFINITY,null])[1]}function s(i,a,d){i.nodes().forEach(u=>a.node(u).rank+=d)}return Kn}var Un,Xo;function Ul(){if(Xo)return Un;Xo=1;var e=Ts(),t=Xt().slack,n=Xt().longestPath,r=ye().alg.preorder,o=ye().alg.postorder,s=ie().simplify;Un=i,i.initLowLimValues=c,i.initCutValues=a,i.calcCutValue=u,i.leaveEdge=f,i.enterEdge=h,i.exchangeEdges=m;function i(b){b=s(b),n(b);var p=e(b);c(p),a(p,b);for(var x,E;x=f(p);)E=h(p,b,x),m(p,b,x,E)}function a(b,p){var x=o(b,b.nodes());x=x.slice(0,x.length-1),x.forEach(E=>d(b,p,E))}function d(b,p,x){var E=b.node(x),_=E.parent;b.edge(x,_).cutvalue=u(b,p,x)}function u(b,p,x){var E=b.node(x),_=E.parent,C=!0,v=p.edge(x,_),N=0;return v||(C=!1,v=p.edge(_,x)),N=v.weight,p.nodeEdges(x).forEach(P=>{var k=P.v===x,M=k?P.w:P.v;if(M!==_){var $=k===C,S=p.edge(P).weight;if(N+=$?S:-S,y(b,x,M)){var R=b.edge(x,M).cutvalue;N+=$?-R:R}}}),N}function c(b,p){arguments.length<2&&(p=b.nodes()[0]),l(b,{},1,p)}function l(b,p,x,E,_){var C=x,v=b.node(E);return p[E]=!0,b.neighbors(E).forEach(N=>{Object.hasOwn(p,N)||(x=l(b,p,x,N,E))}),v.low=C,v.lim=x++,_?v.parent=_:delete v.parent,x}function f(b){return b.edges().find(p=>b.edge(p).cutvalue<0)}function h(b,p,x){var E=x.v,_=x.w;p.hasEdge(E,_)||(E=x.w,_=x.v);var C=b.node(E),v=b.node(_),N=C,P=!1;C.lim>v.lim&&(N=v,P=!0);var k=p.edges().filter(M=>P===w(b,b.node(M.v),N)&&P!==w(b,b.node(M.w),N));return k.reduce((M,$)=>t(p,$)<t(p,M)?$:M)}function m(b,p,x,E){var _=x.v,C=x.w;b.removeEdge(_,C),b.setEdge(E.v,E.w,{}),c(b),a(b,p),g(b,p)}function g(b,p){var x=b.nodes().find(_=>!p.node(_).parent),E=r(b,x);E=E.slice(1),E.forEach(_=>{var C=b.node(_).parent,v=p.edge(_,C),N=!1;v||(v=p.edge(C,_),N=!0),p.node(_).rank=p.node(C).rank+(N?v.minlen:-v.minlen)})}function y(b,p,x){return b.hasEdge(p,x)}function w(b,p,x){return x.low<=p.lim&&p.lim<=x.lim}return Un}var Qn,Zo;function Ql(){if(Zo)return Qn;Zo=1;var e=Xt(),t=e.longestPath,n=Ts(),r=Ul();Qn=o;function o(d){var u=d.graph().ranker;if(u instanceof Function)return u(d);switch(d.graph().ranker){case"network-simplex":a(d);break;case"tight-tree":i(d);break;case"longest-path":s(d);break;case"none":break;default:a(d)}}var s=t;function i(d){t(d),n(d)}function a(d){r(d)}return Qn}var Jn,Ko;function Jl(){if(Ko)return Jn;Ko=1,Jn=e;function e(r){let o=n(r);r.graph().dummyChains.forEach(s=>{let i=r.node(s),a=i.edgeObj,d=t(r,o,a.v,a.w),u=d.path,c=d.lca,l=0,f=u[l],h=!0;for(;s!==a.w;){if(i=r.node(s),h){for(;(f=u[l])!==c&&r.node(f).maxRank<i.rank;)l++;f===c&&(h=!1)}if(!h){for(;l<u.length-1&&r.node(f=u[l+1]).minRank<=i.rank;)l++;f=u[l]}r.setParent(s,f),s=r.successors(s)[0]}})}function t(r,o,s,i){let a=[],d=[],u=Math.min(o[s].low,o[i].low),c=Math.max(o[s].lim,o[i].lim),l,f;l=s;do l=r.parent(l),a.push(l);while(l&&(o[l].low>u||c>o[l].lim));for(f=l,l=i;(l=r.parent(l))!==f;)d.push(l);return{path:a.concat(d.reverse()),lca:f}}function n(r){let o={},s=0;function i(a){let d=s;r.children(a).forEach(i),o[a]={low:d,lim:s++}}return r.children().forEach(i),o}return Jn}var er,Uo;function eu(){if(Uo)return er;Uo=1;let e=ie();er={run:t,cleanup:s};function t(i){let a=e.addDummyNode(i,"root",{},"_root"),d=r(i),u=Object.values(d),c=e.applyWithChunking(Math.max,u)-1,l=2*c+1;i.graph().nestingRoot=a,i.edges().forEach(h=>i.edge(h).minlen*=l);let f=o(i)+1;i.children().forEach(h=>n(i,a,l,f,c,d,h)),i.graph().nodeRankFactor=l}function n(i,a,d,u,c,l,f){let h=i.children(f);if(!h.length){f!==a&&i.setEdge(a,f,{weight:0,minlen:d});return}let m=e.addBorderNode(i,"_bt"),g=e.addBorderNode(i,"_bb"),y=i.node(f);i.setParent(m,f),y.borderTop=m,i.setParent(g,f),y.borderBottom=g,h.forEach(w=>{n(i,a,d,u,c,l,w);let b=i.node(w),p=b.borderTop?b.borderTop:w,x=b.borderBottom?b.borderBottom:w,E=b.borderTop?u:2*u,_=p!==x?1:c-l[f]+1;i.setEdge(m,p,{weight:E,minlen:_,nestingEdge:!0}),i.setEdge(x,g,{weight:E,minlen:_,nestingEdge:!0})}),i.parent(f)||i.setEdge(a,m,{weight:0,minlen:c+l[f]})}function r(i){var a={};function d(u,c){var l=i.children(u);l&&l.length&&l.forEach(f=>d(f,c+1)),a[u]=c}return i.children().forEach(u=>d(u,1)),a}function o(i){return i.edges().reduce((a,d)=>a+i.edge(d).weight,0)}function s(i){var a=i.graph();i.removeNode(a.nestingRoot),delete a.nestingRoot,i.edges().forEach(d=>{var u=i.edge(d);u.nestingEdge&&i.removeEdge(d)})}return er}var tr,Qo;function tu(){if(Qo)return tr;Qo=1;let e=ie();tr=t;function t(r){function o(s){let i=r.children(s),a=r.node(s);if(i.length&&i.forEach(o),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let d=a.minRank,u=a.maxRank+1;d<u;++d)n(r,"borderLeft","_bl",s,a,d),n(r,"borderRight","_br",s,a,d)}}r.children().forEach(o)}function n(r,o,s,i,a,d){let u={width:0,height:0,rank:d,borderType:o},c=a[o][d-1],l=e.addDummyNode(r,"border",u,s);a[o][d]=l,r.setParent(l,i),c&&r.setEdge(c,l,{weight:1})}return tr}var nr,Jo;function nu(){if(Jo)return nr;Jo=1,nr={adjust:e,undo:t};function e(d){let u=d.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(d)}function t(d){let u=d.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&o(d),(u==="lr"||u==="rl")&&(i(d),n(d))}function n(d){d.nodes().forEach(u=>r(d.node(u))),d.edges().forEach(u=>r(d.edge(u)))}function r(d){let u=d.width;d.width=d.height,d.height=u}function o(d){d.nodes().forEach(u=>s(d.node(u))),d.edges().forEach(u=>{let c=d.edge(u);c.points.forEach(s),Object.hasOwn(c,"y")&&s(c)})}function s(d){d.y=-d.y}function i(d){d.nodes().forEach(u=>a(d.node(u))),d.edges().forEach(u=>{let c=d.edge(u);c.points.forEach(a),Object.hasOwn(c,"x")&&a(c)})}function a(d){let u=d.x;d.x=d.y,d.y=u}return nr}var rr,ei;function ru(){if(ei)return rr;ei=1;let e=ie();rr=t;function t(n){let r={},o=n.nodes().filter(c=>!n.children(c).length),s=o.map(c=>n.node(c).rank),i=e.applyWithChunking(Math.max,s),a=e.range(i+1).map(()=>[]);function d(c){if(r[c])return;r[c]=!0;let l=n.node(c);a[l.rank].push(c),n.successors(c).forEach(d)}return o.sort((c,l)=>n.node(c).rank-n.node(l).rank).forEach(d),a}return rr}var or,ti;function ou(){if(ti)return or;ti=1;let e=ie().zipObject;or=t;function t(r,o){let s=0;for(let i=1;i<o.length;++i)s+=n(r,o[i-1],o[i]);return s}function n(r,o,s){let i=e(s,s.map((f,h)=>h)),a=o.flatMap(f=>r.outEdges(f).map(h=>({pos:i[h.w],weight:r.edge(h).weight})).sort((h,m)=>h.pos-m.pos)),d=1;for(;d<s.length;)d<<=1;let u=2*d-1;d-=1;let c=new Array(u).fill(0),l=0;return a.forEach(f=>{let h=f.pos+d;c[h]+=f.weight;let m=0;for(;h>0;)h%2&&(m+=c[h+1]),h=h-1>>1,c[h]+=f.weight;l+=f.weight*m}),l}return or}var ir,ni;function iu(){if(ni)return ir;ni=1,ir=e;function e(t,n=[]){return n.map(r=>{let o=t.inEdges(r);if(o.length){let s=o.reduce((i,a)=>{let d=t.edge(a),u=t.node(a.v);return{sum:i.sum+d.weight*u.order,weight:i.weight+d.weight}},{sum:0,weight:0});return{v:r,barycenter:s.sum/s.weight,weight:s.weight}}else return{v:r}})}return ir}var sr,ri;function su(){if(ri)return sr;ri=1;let e=ie();sr=t;function t(o,s){let i={};o.forEach((d,u)=>{let c=i[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:u};d.barycenter!==void 0&&(c.barycenter=d.barycenter,c.weight=d.weight)}),s.edges().forEach(d=>{let u=i[d.v],c=i[d.w];u!==void 0&&c!==void 0&&(c.indegree++,u.out.push(i[d.w]))});let a=Object.values(i).filter(d=>!d.indegree);return n(a)}function n(o){let s=[];function i(d){return u=>{u.merged||(u.barycenter===void 0||d.barycenter===void 0||u.barycenter>=d.barycenter)&&r(d,u)}}function a(d){return u=>{u.in.push(d),--u.indegree===0&&o.push(u)}}for(;o.length;){let d=o.pop();s.push(d),d.in.reverse().forEach(i(d)),d.out.forEach(a(d))}return s.filter(d=>!d.merged).map(d=>e.pick(d,["vs","i","barycenter","weight"]))}function r(o,s){let i=0,a=0;o.weight&&(i+=o.barycenter*o.weight,a+=o.weight),s.weight&&(i+=s.barycenter*s.weight,a+=s.weight),o.vs=s.vs.concat(o.vs),o.barycenter=i/a,o.weight=a,o.i=Math.min(s.i,o.i),s.merged=!0}return sr}var ar,oi;function au(){if(oi)return ar;oi=1;let e=ie();ar=t;function t(o,s){let i=e.partition(o,m=>Object.hasOwn(m,"barycenter")),a=i.lhs,d=i.rhs.sort((m,g)=>g.i-m.i),u=[],c=0,l=0,f=0;a.sort(r(!!s)),f=n(u,d,f),a.forEach(m=>{f+=m.vs.length,u.push(m.vs),c+=m.barycenter*m.weight,l+=m.weight,f=n(u,d,f)});let h={vs:u.flat(!0)};return l&&(h.barycenter=c/l,h.weight=l),h}function n(o,s,i){let a;for(;s.length&&(a=s[s.length-1]).i<=i;)s.pop(),o.push(a.vs),i++;return i}function r(o){return(s,i)=>s.barycenter<i.barycenter?-1:s.barycenter>i.barycenter?1:o?i.i-s.i:s.i-i.i}return ar}var cr,ii;function cu(){if(ii)return cr;ii=1;let e=iu(),t=su(),n=au();cr=r;function r(i,a,d,u){let c=i.children(a),l=i.node(a),f=l?l.borderLeft:void 0,h=l?l.borderRight:void 0,m={};f&&(c=c.filter(b=>b!==f&&b!==h));let g=e(i,c);g.forEach(b=>{if(i.children(b.v).length){let p=r(i,b.v,d,u);m[b.v]=p,Object.hasOwn(p,"barycenter")&&s(b,p)}});let y=t(g,d);o(y,m);let w=n(y,u);if(f&&(w.vs=[f,w.vs,h].flat(!0),i.predecessors(f).length)){let b=i.node(i.predecessors(f)[0]),p=i.node(i.predecessors(h)[0]);Object.hasOwn(w,"barycenter")||(w.barycenter=0,w.weight=0),w.barycenter=(w.barycenter*w.weight+b.order+p.order)/(w.weight+2),w.weight+=2}return w}function o(i,a){i.forEach(d=>{d.vs=d.vs.flatMap(u=>a[u]?a[u].vs:u)})}function s(i,a){i.barycenter!==void 0?(i.barycenter=(i.barycenter*i.weight+a.barycenter*a.weight)/(i.weight+a.weight),i.weight+=a.weight):(i.barycenter=a.barycenter,i.weight=a.weight)}return cr}var lr,si;function lu(){if(si)return lr;si=1;let e=ye().Graph,t=ie();lr=n;function n(o,s,i,a){a||(a=o.nodes());let d=r(o),u=new e({compound:!0}).setGraph({root:d}).setDefaultNodeLabel(c=>o.node(c));return a.forEach(c=>{let l=o.node(c),f=o.parent(c);(l.rank===s||l.minRank<=s&&s<=l.maxRank)&&(u.setNode(c),u.setParent(c,f||d),o[i](c).forEach(h=>{let m=h.v===c?h.w:h.v,g=u.edge(m,c),y=g!==void 0?g.weight:0;u.setEdge(m,c,{weight:o.edge(h).weight+y})}),Object.hasOwn(l,"minRank")&&u.setNode(c,{borderLeft:l.borderLeft[s],borderRight:l.borderRight[s]}))}),u}function r(o){for(var s;o.hasNode(s=t.uniqueId("_root")););return s}return lr}var ur,ai;function uu(){if(ai)return ur;ai=1,ur=e;function e(t,n,r){let o={},s;r.forEach(i=>{let a=t.parent(i),d,u;for(;a;){if(d=t.parent(a),d?(u=o[d],o[d]=a):(u=s,s=a),u&&u!==a){n.setEdge(u,a);return}a=d}})}return ur}var dr,ci;function du(){if(ci)return dr;ci=1;let e=ru(),t=ou(),n=cu(),r=lu(),o=uu(),s=ye().Graph,i=ie();dr=a;function a(l,f){if(f&&typeof f.customOrder=="function"){f.customOrder(l,a);return}let h=i.maxRank(l),m=d(l,i.range(1,h+1),"inEdges"),g=d(l,i.range(h-1,-1,-1),"outEdges"),y=e(l);if(c(l,y),f&&f.disableOptimalOrderHeuristic)return;let w=Number.POSITIVE_INFINITY,b;for(let p=0,x=0;x<4;++p,++x){u(p%2?m:g,p%4>=2),y=i.buildLayerMatrix(l);let E=t(l,y);E<w&&(x=0,b=Object.assign({},y),w=E)}c(l,b)}function d(l,f,h){const m=new Map,g=(y,w)=>{m.has(y)||m.set(y,[]),m.get(y).push(w)};for(const y of l.nodes()){const w=l.node(y);if(typeof w.rank=="number"&&g(w.rank,y),typeof w.minRank=="number"&&typeof w.maxRank=="number")for(let b=w.minRank;b<=w.maxRank;b++)b!==w.rank&&g(b,y)}return f.map(function(y){return r(l,y,h,m.get(y)||[])})}function u(l,f){let h=new s;l.forEach(function(m){let g=m.graph().root,y=n(m,g,h,f);y.vs.forEach((w,b)=>m.node(w).order=b),o(m,h,y.vs)})}function c(l,f){Object.values(f).forEach(h=>h.forEach((m,g)=>l.node(m).order=g))}return dr}var fr,li;function fu(){if(li)return fr;li=1;let e=ye().Graph,t=ie();fr={positionX:h,findType1Conflicts:n,findType2Conflicts:r,addConflict:s,hasConflict:i,verticalAlignment:a,horizontalCompaction:d,alignCoordinates:l,findSmallestWidthAlignment:c,balance:f};function n(y,w){let b={};function p(x,E){let _=0,C=0,v=x.length,N=E[E.length-1];return E.forEach((P,k)=>{let M=o(y,P),$=M?y.node(M).order:v;(M||P===N)&&(E.slice(C,k+1).forEach(S=>{y.predecessors(S).forEach(R=>{let A=y.node(R),L=A.order;(L<_||$<L)&&!(A.dummy&&y.node(S).dummy)&&s(b,R,S)})}),C=k+1,_=$)}),E}return w.length&&w.reduce(p),b}function r(y,w){let b={};function p(E,_,C,v,N){let P;t.range(_,C).forEach(k=>{P=E[k],y.node(P).dummy&&y.predecessors(P).forEach(M=>{let $=y.node(M);$.dummy&&($.order<v||$.order>N)&&s(b,M,P)})})}function x(E,_){let C=-1,v,N=0;return _.forEach((P,k)=>{if(y.node(P).dummy==="border"){let M=y.predecessors(P);M.length&&(v=y.node(M[0]).order,p(_,N,k,C,v),N=k,C=v)}p(_,N,_.length,v,E.length)}),_}return w.length&&w.reduce(x),b}function o(y,w){if(y.node(w).dummy)return y.predecessors(w).find(b=>y.node(b).dummy)}function s(y,w,b){if(w>b){let x=w;w=b,b=x}let p=y[w];p||(y[w]=p={}),p[b]=!0}function i(y,w,b){if(w>b){let p=w;w=b,b=p}return!!y[w]&&Object.hasOwn(y[w],b)}function a(y,w,b,p){let x={},E={},_={};return w.forEach(C=>{C.forEach((v,N)=>{x[v]=v,E[v]=v,_[v]=N})}),w.forEach(C=>{let v=-1;C.forEach(N=>{let P=p(N);if(P.length){P=P.sort((M,$)=>_[M]-_[$]);let k=(P.length-1)/2;for(let M=Math.floor(k),$=Math.ceil(k);M<=$;++M){let S=P[M];E[N]===N&&v<_[S]&&!i(b,N,S)&&(E[S]=N,E[N]=x[N]=x[S],v=_[S])}}})}),{root:x,align:E}}function d(y,w,b,p,x){let E={},_=u(y,w,b,x),C=x?"borderLeft":"borderRight";function v(k,M){let $=_.nodes(),S=$.pop(),R={};for(;S;)R[S]?k(S):(R[S]=!0,$.push(S),$=$.concat(M(S))),S=$.pop()}function N(k){E[k]=_.inEdges(k).reduce((M,$)=>Math.max(M,E[$.v]+_.edge($)),0)}function P(k){let M=_.outEdges(k).reduce((S,R)=>Math.min(S,E[R.w]-_.edge(R)),Number.POSITIVE_INFINITY),$=y.node(k);M!==Number.POSITIVE_INFINITY&&$.borderType!==C&&(E[k]=Math.max(E[k],M))}return v(N,_.predecessors.bind(_)),v(P,_.successors.bind(_)),Object.keys(p).forEach(k=>E[k]=E[b[k]]),E}function u(y,w,b,p){let x=new e,E=y.graph(),_=m(E.nodesep,E.edgesep,p);return w.forEach(C=>{let v;C.forEach(N=>{let P=b[N];if(x.setNode(P),v){var k=b[v],M=x.edge(k,P);x.setEdge(k,P,Math.max(_(y,N,v),M||0))}v=N})}),x}function c(y,w){return Object.values(w).reduce((b,p)=>{let x=Number.NEGATIVE_INFINITY,E=Number.POSITIVE_INFINITY;Object.entries(p).forEach(([C,v])=>{let N=g(y,C)/2;x=Math.max(v+N,x),E=Math.min(v-N,E)});const _=x-E;return _<b[0]&&(b=[_,p]),b},[Number.POSITIVE_INFINITY,null])[1]}function l(y,w){let b=Object.values(w),p=t.applyWithChunking(Math.min,b),x=t.applyWithChunking(Math.max,b);["u","d"].forEach(E=>{["l","r"].forEach(_=>{let C=E+_,v=y[C];if(v===w)return;let N=Object.values(v),P=p-t.applyWithChunking(Math.min,N);_!=="l"&&(P=x-t.applyWithChunking(Math.max,N)),P&&(y[C]=t.mapValues(v,k=>k+P))})})}function f(y,w){return t.mapValues(y.ul,(b,p)=>{if(w)return y[w.toLowerCase()][p];{let x=Object.values(y).map(E=>E[p]).sort((E,_)=>E-_);return(x[1]+x[2])/2}})}function h(y){let w=t.buildLayerMatrix(y),b=Object.assign(n(y,w),r(y,w)),p={},x;["u","d"].forEach(_=>{x=_==="u"?w:Object.values(w).reverse(),["l","r"].forEach(C=>{C==="r"&&(x=x.map(k=>Object.values(k).reverse()));let v=(_==="u"?y.predecessors:y.successors).bind(y),N=a(y,x,b,v),P=d(y,x,N.root,N.align,C==="r");C==="r"&&(P=t.mapValues(P,k=>-k)),p[_+C]=P})});let E=c(y,p);return l(p,E),f(p,y.graph().align)}function m(y,w,b){return(p,x,E)=>{let _=p.node(x),C=p.node(E),v=0,N;if(v+=_.width/2,Object.hasOwn(_,"labelpos"))switch(_.labelpos.toLowerCase()){case"l":N=-_.width/2;break;case"r":N=_.width/2;break}if(N&&(v+=b?N:-N),N=0,v+=(_.dummy?w:y)/2,v+=(C.dummy?w:y)/2,v+=C.width/2,Object.hasOwn(C,"labelpos"))switch(C.labelpos.toLowerCase()){case"l":N=C.width/2;break;case"r":N=-C.width/2;break}return N&&(v+=b?N:-N),N=0,v}}function g(y,w){return y.node(w).width}return fr}var hr,ui;function hu(){if(ui)return hr;ui=1;let e=ie(),t=fu().positionX;hr=n;function n(o){o=e.asNonCompoundGraph(o),r(o),Object.entries(t(o)).forEach(([s,i])=>o.node(s).x=i)}function r(o){let s=e.buildLayerMatrix(o),i=o.graph().ranksep,a=0;s.forEach(d=>{const u=d.reduce((c,l)=>{const f=o.node(l).height;return c>f?c:f},0);d.forEach(c=>o.node(c).y=a+u/2),a+=u+i})}return hr}var pr,di;function pu(){if(di)return pr;di=1;let e=Zl(),t=Kl(),n=Ql(),r=ie().normalizeRanks,o=Jl(),s=ie().removeEmptyRanks,i=eu(),a=tu(),d=nu(),u=du(),c=hu(),l=ie(),f=ye().Graph;pr=h;function h(O,T){let H=T&&T.debugTiming?l.time:l.notime;H("layout",()=>{let Y=H(" buildLayoutGraph",()=>v(O));H(" runLayout",()=>m(Y,H,T)),H(" updateInputGraph",()=>g(O,Y))})}function m(O,T,H){T(" makeSpaceForEdgeLabels",()=>N(O)),T(" removeSelfEdges",()=>j(O)),T(" acyclic",()=>e.run(O)),T(" nestingGraph.run",()=>i.run(O)),T(" rank",()=>n(l.asNonCompoundGraph(O))),T(" injectEdgeLabelProxies",()=>P(O)),T(" removeEmptyRanks",()=>s(O)),T(" nestingGraph.cleanup",()=>i.cleanup(O)),T(" normalizeRanks",()=>r(O)),T(" assignRankMinMax",()=>k(O)),T(" removeEdgeLabelProxies",()=>M(O)),T(" normalize.run",()=>t.run(O)),T(" parentDummyChains",()=>o(O)),T(" addBorderSegments",()=>a(O)),T(" order",()=>u(O,H)),T(" insertSelfEdges",()=>V(O)),T(" adjustCoordinateSystem",()=>d.adjust(O)),T(" position",()=>c(O)),T(" positionSelfEdges",()=>W(O)),T(" removeBorderNodes",()=>L(O)),T(" normalize.undo",()=>t.undo(O)),T(" fixupEdgeLabelCoords",()=>R(O)),T(" undoCoordinateSystem",()=>d.undo(O)),T(" translateGraph",()=>$(O)),T(" assignNodeIntersects",()=>S(O)),T(" reversePoints",()=>A(O)),T(" acyclic.undo",()=>e.undo(O))}function g(O,T){O.nodes().forEach(H=>{let Y=O.node(H),F=T.node(H);Y&&(Y.x=F.x,Y.y=F.y,Y.rank=F.rank,T.children(H).length&&(Y.width=F.width,Y.height=F.height))}),O.edges().forEach(H=>{let Y=O.edge(H),F=T.edge(H);Y.points=F.points,Object.hasOwn(F,"x")&&(Y.x=F.x,Y.y=F.y)}),O.graph().width=T.graph().width,O.graph().height=T.graph().height}let y=["nodesep","edgesep","ranksep","marginx","marginy"],w={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],p=["width","height","rank"],x={width:0,height:0},E=["minlen","weight","width","height","labeloffset"],_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},C=["labelpos"];function v(O){let T=new f({multigraph:!0,compound:!0}),H=B(O.graph());return T.setGraph(Object.assign({},w,I(H,y),l.pick(H,b))),O.nodes().forEach(Y=>{let F=B(O.node(Y));const q=I(F,p);Object.keys(x).forEach(G=>{q[G]===void 0&&(q[G]=x[G])}),T.setNode(Y,q),T.setParent(Y,O.parent(Y))}),O.edges().forEach(Y=>{let F=B(O.edge(Y));T.setEdge(Y,Object.assign({},_,I(F,E),l.pick(F,C)))}),T}function N(O){let T=O.graph();T.ranksep/=2,O.edges().forEach(H=>{let Y=O.edge(H);Y.minlen*=2,Y.labelpos.toLowerCase()!=="c"&&(T.rankdir==="TB"||T.rankdir==="BT"?Y.width+=Y.labeloffset:Y.height+=Y.labeloffset)})}function P(O){O.edges().forEach(T=>{let H=O.edge(T);if(H.width&&H.height){let Y=O.node(T.v),q={rank:(O.node(T.w).rank-Y.rank)/2+Y.rank,e:T};l.addDummyNode(O,"edge-proxy",q,"_ep")}})}function k(O){let T=0;O.nodes().forEach(H=>{let Y=O.node(H);Y.borderTop&&(Y.minRank=O.node(Y.borderTop).rank,Y.maxRank=O.node(Y.borderBottom).rank,T=Math.max(T,Y.maxRank))}),O.graph().maxRank=T}function M(O){O.nodes().forEach(T=>{let H=O.node(T);H.dummy==="edge-proxy"&&(O.edge(H.e).labelRank=H.rank,O.removeNode(T))})}function $(O){let T=Number.POSITIVE_INFINITY,H=0,Y=Number.POSITIVE_INFINITY,F=0,q=O.graph(),G=q.marginx||0,U=q.marginy||0;function Q(X){let Z=X.x,J=X.y,te=X.width,ne=X.height;T=Math.min(T,Z-te/2),H=Math.max(H,Z+te/2),Y=Math.min(Y,J-ne/2),F=Math.max(F,J+ne/2)}O.nodes().forEach(X=>Q(O.node(X))),O.edges().forEach(X=>{let Z=O.edge(X);Object.hasOwn(Z,"x")&&Q(Z)}),T-=G,Y-=U,O.nodes().forEach(X=>{let Z=O.node(X);Z.x-=T,Z.y-=Y}),O.edges().forEach(X=>{let Z=O.edge(X);Z.points.forEach(J=>{J.x-=T,J.y-=Y}),Object.hasOwn(Z,"x")&&(Z.x-=T),Object.hasOwn(Z,"y")&&(Z.y-=Y)}),q.width=H-T+G,q.height=F-Y+U}function S(O){O.edges().forEach(T=>{let H=O.edge(T),Y=O.node(T.v),F=O.node(T.w),q,G;H.points?(q=H.points[0],G=H.points[H.points.length-1]):(H.points=[],q=F,G=Y),H.points.unshift(l.intersectRect(Y,q)),H.points.push(l.intersectRect(F,G))})}function R(O){O.edges().forEach(T=>{let H=O.edge(T);if(Object.hasOwn(H,"x"))switch((H.labelpos==="l"||H.labelpos==="r")&&(H.width-=H.labeloffset),H.labelpos){case"l":H.x-=H.width/2+H.labeloffset;break;case"r":H.x+=H.width/2+H.labeloffset;break}})}function A(O){O.edges().forEach(T=>{let H=O.edge(T);H.reversed&&H.points.reverse()})}function L(O){O.nodes().forEach(T=>{if(O.children(T).length){let H=O.node(T),Y=O.node(H.borderTop),F=O.node(H.borderBottom),q=O.node(H.borderLeft[H.borderLeft.length-1]),G=O.node(H.borderRight[H.borderRight.length-1]);H.width=Math.abs(G.x-q.x),H.height=Math.abs(F.y-Y.y),H.x=q.x+H.width/2,H.y=Y.y+H.height/2}}),O.nodes().forEach(T=>{O.node(T).dummy==="border"&&O.removeNode(T)})}function j(O){O.edges().forEach(T=>{if(T.v===T.w){var H=O.node(T.v);H.selfEdges||(H.selfEdges=[]),H.selfEdges.push({e:T,label:O.edge(T)}),O.removeEdge(T)}})}function V(O){var T=l.buildLayerMatrix(O);T.forEach(H=>{var Y=0;H.forEach((F,q)=>{var G=O.node(F);G.order=q+Y,(G.selfEdges||[]).forEach(U=>{l.addDummyNode(O,"selfedge",{width:U.label.width,height:U.label.height,rank:G.rank,order:q+ ++Y,e:U.e,label:U.label},"_se")}),delete G.selfEdges})})}function W(O){O.nodes().forEach(T=>{var H=O.node(T);if(H.dummy==="selfedge"){var Y=O.node(H.e.v),F=Y.x+Y.width/2,q=Y.y,G=H.x-F,U=Y.height/2;O.setEdge(H.e,H.label),O.removeNode(T),H.label.points=[{x:F+2*G/3,y:q-U},{x:F+5*G/6,y:q-U},{x:F+G,y:q},{x:F+5*G/6,y:q+U},{x:F+2*G/3,y:q+U}],H.label.x=H.x,H.label.y=H.y}})}function I(O,T){return l.mapValues(l.pick(O,T),Number)}function B(O){var T={};return O&&Object.entries(O).forEach(([H,Y])=>{typeof H=="string"&&(H=H.toLowerCase()),T[H]=Y}),T}return pr}var gr,fi;function gu(){if(fi)return gr;fi=1;let e=ie(),t=ye().Graph;gr={debugOrdering:n};function n(r){let o=e.buildLayerMatrix(r),s=new t({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(i=>{s.setNode(i,{label:i}),s.setParent(i,"layer"+r.node(i).rank)}),r.edges().forEach(i=>s.setEdge(i.v,i.w,{},i.name)),o.forEach((i,a)=>{let d="layer"+a;s.setNode(d,{rank:"same"}),i.reduce((u,c)=>(s.setEdge(u,c,{style:"invis"}),c))}),s}return gr}var mr,hi;function mu(){return hi||(hi=1,mr="1.1.8"),mr}var yr,pi;function yu(){return pi||(pi=1,yr={graphlib:ye(),layout:pu(),debug:gu(),util:{time:ie().time,notime:ie().notime},version:mu()}),yr}var wu=yu();const gi=ks(wu);function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=se(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var xu={value:()=>{}};function un(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Bt(n)}function Bt(e){this._=e}function bu(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",o=n.indexOf(".");if(o>=0&&(r=n.slice(o+1),n=n.slice(0,o)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Bt.prototype=un.prototype={constructor:Bt,on:function(e,t){var n=this._,r=bu(e+"",n),o,s=-1,i=r.length;if(arguments.length<2){for(;++s<i;)if((o=(e=r[s]).type)&&(o=vu(n[o],e.name)))return o;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++s<i;)if(o=(e=r[s]).type)n[o]=mi(n[o],e.name,t);else if(t==null)for(o in n)n[o]=mi(n[o],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Bt(e)},call:function(e,t){if((o=arguments.length-2)>0)for(var n=new Array(o),r=0,o,s;r<o;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(s=this._[e],r=0,o=s.length;r<o;++r)s[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],o=0,s=r.length;o<s;++o)r[o].value.apply(t,n)}};function vu(e,t){for(var n=0,r=e.length,o;n<r;++n)if((o=e[n]).name===t)return o.value}function mi(e,t,n){for(var r=0,o=e.length;r<o;++r)if(e[r].name===t){e[r]=xu,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Pr="http://www.w3.org/1999/xhtml";const yi={svg:"http://www.w3.org/2000/svg",xhtml:Pr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function dn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),yi.hasOwnProperty(t)?{space:yi[t],local:e}:e}function _u(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Pr&&t.documentElement.namespaceURI===Pr?t.createElement(e):t.createElementNS(n,e)}}function Eu(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function As(e){var t=dn(e);return(t.local?Eu:_u)(t)}function Su(){}function Gr(e){return e==null?Su:function(){return this.querySelector(e)}}function Nu(e){typeof e!="function"&&(e=Gr(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=new Array(i),d,u,c=0;c<i;++c)(d=s[c])&&(u=e.call(d,d.__data__,c,s))&&("__data__"in d&&(u.__data__=d.__data__),a[c]=u);return new de(r,this._parents)}function Cu(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function ku(){return[]}function Ds(e){return e==null?ku:function(){return this.querySelectorAll(e)}}function Mu(e){return function(){return Cu(e.apply(this,arguments))}}function Ou(e){typeof e=="function"?e=Mu(e):e=Ds(e);for(var t=this._groups,n=t.length,r=[],o=[],s=0;s<n;++s)for(var i=t[s],a=i.length,d,u=0;u<a;++u)(d=i[u])&&(r.push(e.call(d,d.__data__,u,i)),o.push(d));return new de(r,o)}function Ls(e){return function(){return this.matches(e)}}function $s(e){return function(t){return t.matches(e)}}var Iu=Array.prototype.find;function Ru(e){return function(){return Iu.call(this.children,e)}}function Pu(){return this.firstElementChild}function Tu(e){return this.select(e==null?Pu:Ru(typeof e=="function"?e:$s(e)))}var Au=Array.prototype.filter;function Du(){return Array.from(this.children)}function Lu(e){return function(){return Au.call(this.children,e)}}function $u(e){return this.selectAll(e==null?Du:Lu(typeof e=="function"?e:$s(e)))}function ju(e){typeof e!="function"&&(e=Ls(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=[],d,u=0;u<i;++u)(d=s[u])&&e.call(d,d.__data__,u,s)&&a.push(d);return new de(r,this._parents)}function js(e){return new Array(e.length)}function zu(){return new de(this._enter||this._groups.map(js),this._parents)}function Zt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Zt.prototype={constructor:Zt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Hu(e){return function(){return e}}function Vu(e,t,n,r,o,s){for(var i=0,a,d=t.length,u=s.length;i<u;++i)(a=t[i])?(a.__data__=s[i],r[i]=a):n[i]=new Zt(e,s[i]);for(;i<d;++i)(a=t[i])&&(o[i]=a)}function Bu(e,t,n,r,o,s,i){var a,d,u=new Map,c=t.length,l=s.length,f=new Array(c),h;for(a=0;a<c;++a)(d=t[a])&&(f[a]=h=i.call(d,d.__data__,a,t)+"",u.has(h)?o[a]=d:u.set(h,d));for(a=0;a<l;++a)h=i.call(e,s[a],a,s)+"",(d=u.get(h))?(r[a]=d,d.__data__=s[a],u.delete(h)):n[a]=new Zt(e,s[a]);for(a=0;a<c;++a)(d=t[a])&&u.get(f[a])===d&&(o[a]=d)}function Fu(e){return e.__data__}function qu(e,t){if(!arguments.length)return Array.from(this,Fu);var n=t?Bu:Vu,r=this._parents,o=this._groups;typeof e!="function"&&(e=Hu(e));for(var s=o.length,i=new Array(s),a=new Array(s),d=new Array(s),u=0;u<s;++u){var c=r[u],l=o[u],f=l.length,h=Yu(e.call(c,c&&c.__data__,u,r)),m=h.length,g=a[u]=new Array(m),y=i[u]=new Array(m),w=d[u]=new Array(f);n(c,l,g,y,w,h,t);for(var b=0,p=0,x,E;b<m;++b)if(x=g[b]){for(b>=p&&(p=b+1);!(E=y[p])&&++p<m;);x._next=E||null}}return i=new de(i,r),i._enter=a,i._exit=d,i}function Yu(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Wu(){return new de(this._exit||this._groups.map(js),this._parents)}function Gu(e,t,n){var r=this.enter(),o=this,s=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(o=t(o),o&&(o=o.selection())),n==null?s.remove():n(s),r&&o?r.merge(o).order():o}function Xu(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,o=n.length,s=r.length,i=Math.min(o,s),a=new Array(o),d=0;d<i;++d)for(var u=n[d],c=r[d],l=u.length,f=a[d]=new Array(l),h,m=0;m<l;++m)(h=u[m]||c[m])&&(f[m]=h);for(;d<o;++d)a[d]=n[d];return new de(a,this._parents)}function Zu(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],o=r.length-1,s=r[o],i;--o>=0;)(i=r[o])&&(s&&i.compareDocumentPosition(s)^4&&s.parentNode.insertBefore(i,s),s=i);return this}function Ku(e){e||(e=Uu);function t(l,f){return l&&f?e(l.__data__,f.__data__):!l-!f}for(var n=this._groups,r=n.length,o=new Array(r),s=0;s<r;++s){for(var i=n[s],a=i.length,d=o[s]=new Array(a),u,c=0;c<a;++c)(u=i[c])&&(d[c]=u);d.sort(t)}return new de(o,this._parents).order()}function Uu(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Qu(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Ju(){return Array.from(this)}function ed(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length;o<s;++o){var i=r[o];if(i)return i}return null}function td(){let e=0;for(const t of this)++e;return e}function nd(){return!this.node()}function rd(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var o=t[n],s=0,i=o.length,a;s<i;++s)(a=o[s])&&e.call(a,a.__data__,s,o);return this}function od(e){return function(){this.removeAttribute(e)}}function id(e){return function(){this.removeAttributeNS(e.space,e.local)}}function sd(e,t){return function(){this.setAttribute(e,t)}}function ad(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function cd(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ld(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function ud(e,t){var n=dn(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?id:od:typeof t=="function"?n.local?ld:cd:n.local?ad:sd)(n,t))}function zs(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function dd(e){return function(){this.style.removeProperty(e)}}function fd(e,t,n){return function(){this.style.setProperty(e,t,n)}}function hd(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function pd(e,t,n){return arguments.length>1?this.each((t==null?dd:typeof t=="function"?hd:fd)(e,t,n??"")):Ye(this.node(),e)}function Ye(e,t){return e.style.getPropertyValue(t)||zs(e).getComputedStyle(e,null).getPropertyValue(t)}function gd(e){return function(){delete this[e]}}function md(e,t){return function(){this[e]=t}}function yd(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function wd(e,t){return arguments.length>1?this.each((t==null?gd:typeof t=="function"?yd:md)(e,t)):this.node()[e]}function Hs(e){return e.trim().split(/^|\s+/)}function Xr(e){return e.classList||new Vs(e)}function Vs(e){this._node=e,this._names=Hs(e.getAttribute("class")||"")}Vs.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Bs(e,t){for(var n=Xr(e),r=-1,o=t.length;++r<o;)n.add(t[r])}function Fs(e,t){for(var n=Xr(e),r=-1,o=t.length;++r<o;)n.remove(t[r])}function xd(e){return function(){Bs(this,e)}}function bd(e){return function(){Fs(this,e)}}function vd(e,t){return function(){(t.apply(this,arguments)?Bs:Fs)(this,e)}}function _d(e,t){var n=Hs(e+"");if(arguments.length<2){for(var r=Xr(this.node()),o=-1,s=n.length;++o<s;)if(!r.contains(n[o]))return!1;return!0}return this.each((typeof t=="function"?vd:t?xd:bd)(n,t))}function Ed(){this.textContent=""}function Sd(e){return function(){this.textContent=e}}function Nd(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Cd(e){return arguments.length?this.each(e==null?Ed:(typeof e=="function"?Nd:Sd)(e)):this.node().textContent}function kd(){this.innerHTML=""}function Md(e){return function(){this.innerHTML=e}}function Od(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Id(e){return arguments.length?this.each(e==null?kd:(typeof e=="function"?Od:Md)(e)):this.node().innerHTML}function Rd(){this.nextSibling&&this.parentNode.appendChild(this)}function Pd(){return this.each(Rd)}function Td(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Ad(){return this.each(Td)}function Dd(e){var t=typeof e=="function"?e:As(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ld(){return null}function $d(e,t){var n=typeof e=="function"?e:As(e),r=t==null?Ld:typeof t=="function"?t:Gr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function jd(){var e=this.parentNode;e&&e.removeChild(this)}function zd(){return this.each(jd)}function Hd(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Vd(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bd(e){return this.select(e?Vd:Hd)}function Fd(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qd(e){return function(t){e.call(this,t,this.__data__)}}function Yd(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Wd(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,o=t.length,s;n<o;++n)s=t[n],(!e.type||s.type===e.type)&&s.name===e.name?this.removeEventListener(s.type,s.listener,s.options):t[++r]=s;++r?t.length=r:delete this.__on}}}function Gd(e,t,n){return function(){var r=this.__on,o,s=qd(t);if(r){for(var i=0,a=r.length;i<a;++i)if((o=r[i]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=s,o.options=n),o.value=t;return}}this.addEventListener(e.type,s,n),o={type:e.type,name:e.name,value:t,listener:s,options:n},r?r.push(o):this.__on=[o]}}function Xd(e,t,n){var r=Yd(e+""),o,s=r.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var d=0,u=a.length,c;d<u;++d)for(o=0,c=a[d];o<s;++o)if((i=r[o]).type===c.type&&i.name===c.name)return c.value}return}for(a=t?Gd:Wd,o=0;o<s;++o)this.each(a(r[o],t,n));return this}function qs(e,t,n){var r=zs(e),o=r.CustomEvent;typeof o=="function"?o=new o(t,n):(o=r.document.createEvent("Event"),n?(o.initEvent(t,n.bubbles,n.cancelable),o.detail=n.detail):o.initEvent(t,!1,!1)),e.dispatchEvent(o)}function Zd(e,t){return function(){return qs(this,e,t)}}function Kd(e,t){return function(){return qs(this,e,t.apply(this,arguments))}}function Ud(e,t){return this.each((typeof t=="function"?Kd:Zd)(e,t))}function*Qd(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],o=0,s=r.length,i;o<s;++o)(i=r[o])&&(yield i)}var Ys=[null];function de(e,t){this._groups=e,this._parents=t}function vt(){return new de([[document.documentElement]],Ys)}function Jd(){return this}de.prototype=vt.prototype={constructor:de,select:Nu,selectAll:Ou,selectChild:Tu,selectChildren:$u,filter:ju,data:qu,enter:zu,exit:Wu,join:Gu,merge:Xu,selection:Jd,order:Zu,sort:Ku,call:Qu,nodes:Ju,node:ed,size:td,empty:nd,each:rd,attr:ud,style:pd,property:wd,classed:_d,text:Cd,html:Id,raise:Pd,lower:Ad,append:Dd,insert:$d,remove:zd,clone:Bd,datum:Fd,on:Xd,dispatch:Ud,[Symbol.iterator]:Qd};function ue(e){return typeof e=="string"?new de([[document.querySelector(e)]],[document.documentElement]):new de([[e]],Ys)}function ef(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=ef(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const tf={passive:!1},lt={capture:!0,passive:!1};function wr(e){e.stopImmediatePropagation()}function Fe(e){e.preventDefault(),e.stopImmediatePropagation()}function Ws(e){var t=e.document.documentElement,n=ue(e).on("dragstart.drag",Fe,lt);"onselectstart"in t?n.on("selectstart.drag",Fe,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Gs(e,t){var n=e.document.documentElement,r=ue(e).on("dragstart.drag",null);t&&(r.on("click.drag",Fe,lt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Rt=e=>()=>e;function Tr(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:s,x:i,y:a,dx:d,dy:u,dispatch:c}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:c}})}Tr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function nf(e){return!e.ctrlKey&&!e.button}function rf(){return this.parentNode}function of(e,t){return t??{x:e.x,y:e.y}}function sf(){return navigator.maxTouchPoints||"ontouchstart"in this}function Xs(){var e=nf,t=rf,n=of,r=sf,o={},s=un("start","drag","end"),i=0,a,d,u,c,l=0;function f(x){x.on("mousedown.drag",h).filter(r).on("touchstart.drag",y).on("touchmove.drag",w,tf).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,E){if(!(c||!e.call(this,x,E))){var _=p(this,t.call(this,x,E),x,E,"mouse");_&&(ue(x.view).on("mousemove.drag",m,lt).on("mouseup.drag",g,lt),Ws(x.view),wr(x),u=!1,a=x.clientX,d=x.clientY,_("start",x))}}function m(x){if(Fe(x),!u){var E=x.clientX-a,_=x.clientY-d;u=E*E+_*_>l}o.mouse("drag",x)}function g(x){ue(x.view).on("mousemove.drag mouseup.drag",null),Gs(x.view,u),Fe(x),o.mouse("end",x)}function y(x,E){if(e.call(this,x,E)){var _=x.changedTouches,C=t.call(this,x,E),v=_.length,N,P;for(N=0;N<v;++N)(P=p(this,C,x,E,_[N].identifier,_[N]))&&(wr(x),P("start",x,_[N]))}}function w(x){var E=x.changedTouches,_=E.length,C,v;for(C=0;C<_;++C)(v=o[E[C].identifier])&&(Fe(x),v("drag",x,E[C]))}function b(x){var E=x.changedTouches,_=E.length,C,v;for(c&&clearTimeout(c),c=setTimeout(function(){c=null},500),C=0;C<_;++C)(v=o[E[C].identifier])&&(wr(x),v("end",x,E[C]))}function p(x,E,_,C,v,N){var P=s.copy(),k=he(N||_,E),M,$,S;if((S=n.call(x,new Tr("beforestart",{sourceEvent:_,target:f,identifier:v,active:i,x:k[0],y:k[1],dx:0,dy:0,dispatch:P}),C))!=null)return M=S.x-k[0]||0,$=S.y-k[1]||0,function R(A,L,j){var V=k,W;switch(A){case"start":o[v]=R,W=i++;break;case"end":delete o[v],--i;case"drag":k=he(j||L,E),W=i;break}P.call(A,x,new Tr(A,{sourceEvent:L,subject:S,target:f,identifier:v,active:W,x:k[0]+M,y:k[1]+$,dx:k[0]-V[0],dy:k[1]-V[1],dispatch:P}),C)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Rt(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:Rt(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:Rt(x),f):n},f.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:Rt(!!x),f):r},f.on=function(){var x=s.on.apply(s,arguments);return x===s?f:x},f.clickDistance=function(x){return arguments.length?(l=(x=+x)*x,f):Math.sqrt(l)},f}function Zr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Zs(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function _t(){}var ut=.7,Kt=1/ut,qe="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",be="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",af=/^#([0-9a-f]{3,8})$/,cf=new RegExp(`^rgb\\(${qe},${qe},${qe}\\)$`),lf=new RegExp(`^rgb\\(${be},${be},${be}\\)$`),uf=new RegExp(`^rgba\\(${qe},${qe},${qe},${dt}\\)$`),df=new RegExp(`^rgba\\(${be},${be},${be},${dt}\\)$`),ff=new RegExp(`^hsl\\(${dt},${be},${be}\\)$`),hf=new RegExp(`^hsla\\(${dt},${be},${be},${dt}\\)$`),wi={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Zr(_t,Le,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:xi,formatHex:xi,formatHex8:pf,formatHsl:gf,formatRgb:bi,toString:bi});function xi(){return this.rgb().formatHex()}function pf(){return this.rgb().formatHex8()}function gf(){return Ks(this).formatHsl()}function bi(){return this.rgb().formatRgb()}function Le(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=af.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?vi(t):n===3?new le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Pt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Pt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=cf.exec(e))?new le(t[1],t[2],t[3],1):(t=lf.exec(e))?new le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=uf.exec(e))?Pt(t[1],t[2],t[3],t[4]):(t=df.exec(e))?Pt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=ff.exec(e))?Si(t[1],t[2]/100,t[3]/100,1):(t=hf.exec(e))?Si(t[1],t[2]/100,t[3]/100,t[4]):wi.hasOwnProperty(e)?vi(wi[e]):e==="transparent"?new le(NaN,NaN,NaN,0):null}function vi(e){return new le(e>>16&255,e>>8&255,e&255,1)}function Pt(e,t,n,r){return r<=0&&(e=t=n=NaN),new le(e,t,n,r)}function mf(e){return e instanceof _t||(e=Le(e)),e?(e=e.rgb(),new le(e.r,e.g,e.b,e.opacity)):new le}function Ar(e,t,n,r){return arguments.length===1?mf(e):new le(e,t,n,r??1)}function le(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Zr(le,Ar,Zs(_t,{brighter(e){return e=e==null?Kt:Math.pow(Kt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new le(Ae(this.r),Ae(this.g),Ae(this.b),Ut(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:_i,formatHex:_i,formatHex8:yf,formatRgb:Ei,toString:Ei}));function _i(){return`#${Te(this.r)}${Te(this.g)}${Te(this.b)}`}function yf(){return`#${Te(this.r)}${Te(this.g)}${Te(this.b)}${Te((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ei(){const e=Ut(this.opacity);return`${e===1?"rgb(":"rgba("}${Ae(this.r)}, ${Ae(this.g)}, ${Ae(this.b)}${e===1?")":`, ${e})`}`}function Ut(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ae(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Te(e){return e=Ae(e),(e<16?"0":"")+e.toString(16)}function Si(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new pe(e,t,n,r)}function Ks(e){if(e instanceof pe)return new pe(e.h,e.s,e.l,e.opacity);if(e instanceof _t||(e=Le(e)),!e)return new pe;if(e instanceof pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,o=Math.min(t,n,r),s=Math.max(t,n,r),i=NaN,a=s-o,d=(s+o)/2;return a?(t===s?i=(n-r)/a+(n<r)*6:n===s?i=(r-t)/a+2:i=(t-n)/a+4,a/=d<.5?s+o:2-s-o,i*=60):a=d>0&&d<1?0:i,new pe(i,a,d,e.opacity)}function wf(e,t,n,r){return arguments.length===1?Ks(e):new pe(e,t,n,r??1)}function pe(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Zr(pe,wf,Zs(_t,{brighter(e){return e=e==null?Kt:Math.pow(Kt,e),new pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new pe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,o=2*n-r;return new le(xr(e>=240?e-240:e+120,o,r),xr(e,o,r),xr(e<120?e+240:e-120,o,r),this.opacity)},clamp(){return new pe(Ni(this.h),Tt(this.s),Tt(this.l),Ut(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Ut(this.opacity);return`${e===1?"hsl(":"hsla("}${Ni(this.h)}, ${Tt(this.s)*100}%, ${Tt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Ni(e){return e=(e||0)%360,e<0?e+360:e}function Tt(e){return Math.max(0,Math.min(1,e||0))}function xr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Kr=e=>()=>e;function xf(e,t){return function(n){return e+n*t}}function bf(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function vf(e){return(e=+e)==1?Us:function(t,n){return n-t?bf(t,n,e):Kr(isNaN(t)?n:t)}}function Us(e,t){var n=t-e;return n?xf(e,n):Kr(isNaN(e)?t:e)}const Qt=(function e(t){var n=vf(t);function r(o,s){var i=n((o=Ar(o)).r,(s=Ar(s)).r),a=n(o.g,s.g),d=n(o.b,s.b),u=Us(o.opacity,s.opacity);return function(c){return o.r=i(c),o.g=a(c),o.b=d(c),o.opacity=u(c),o+""}}return r.gamma=e,r})(1);function _f(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),o;return function(s){for(o=0;o<n;++o)r[o]=e[o]*(1-s)+t[o]*s;return r}}function Ef(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Sf(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,o=new Array(r),s=new Array(n),i;for(i=0;i<r;++i)o[i]=at(e[i],t[i]);for(;i<n;++i)s[i]=t[i];return function(a){for(i=0;i<r;++i)s[i]=o[i](a);return s}}function Nf(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function xe(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Cf(e,t){var n={},r={},o;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(o in t)o in e?n[o]=at(e[o],t[o]):r[o]=t[o];return function(s){for(o in n)r[o]=n[o](s);return r}}var Dr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,br=new RegExp(Dr.source,"g");function kf(e){return function(){return e}}function Mf(e){return function(t){return e(t)+""}}function Qs(e,t){var n=Dr.lastIndex=br.lastIndex=0,r,o,s,i=-1,a=[],d=[];for(e=e+"",t=t+"";(r=Dr.exec(e))&&(o=br.exec(t));)(s=o.index)>n&&(s=t.slice(n,s),a[i]?a[i]+=s:a[++i]=s),(r=r[0])===(o=o[0])?a[i]?a[i]+=o:a[++i]=o:(a[++i]=null,d.push({i,x:xe(r,o)})),n=br.lastIndex;return n<t.length&&(s=t.slice(n),a[i]?a[i]+=s:a[++i]=s),a.length<2?d[0]?Mf(d[0].x):kf(t):(t=d.length,function(u){for(var c=0,l;c<t;++c)a[(l=d[c]).i]=l.x(u);return a.join("")})}function at(e,t){var n=typeof t,r;return t==null||n==="boolean"?Kr(t):(n==="number"?xe:n==="string"?(r=Le(t))?(t=r,Qt):Qs:t instanceof Le?Qt:t instanceof Date?Nf:Ef(t)?_f:Array.isArray(t)?Sf:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Cf:xe)(e,t)}var Ci=180/Math.PI,Lr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Js(e,t,n,r,o,s){var i,a,d;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(d=e*n+t*r)&&(n-=e*d,r-=t*d),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,d/=a),e*r<t*n&&(e=-e,t=-t,d=-d,i=-i),{translateX:o,translateY:s,rotate:Math.atan2(t,e)*Ci,skewX:Math.atan(d)*Ci,scaleX:i,scaleY:a}}var At;function Of(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Lr:Js(t.a,t.b,t.c,t.d,t.e,t.f)}function If(e){return e==null||(At||(At=document.createElementNS("http://www.w3.org/2000/svg","g")),At.setAttribute("transform",e),!(e=At.transform.baseVal.consolidate()))?Lr:(e=e.matrix,Js(e.a,e.b,e.c,e.d,e.e,e.f))}function ea(e,t,n,r){function o(u){return u.length?u.pop()+" ":""}function s(u,c,l,f,h,m){if(u!==l||c!==f){var g=h.push("translate(",null,t,null,n);m.push({i:g-4,x:xe(u,l)},{i:g-2,x:xe(c,f)})}else(l||f)&&h.push("translate("+l+t+f+n)}function i(u,c,l,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.push({i:l.push(o(l)+"rotate(",null,r)-2,x:xe(u,c)})):c&&l.push(o(l)+"rotate("+c+r)}function a(u,c,l,f){u!==c?f.push({i:l.push(o(l)+"skewX(",null,r)-2,x:xe(u,c)}):c&&l.push(o(l)+"skewX("+c+r)}function d(u,c,l,f,h,m){if(u!==l||c!==f){var g=h.push(o(h)+"scale(",null,",",null,")");m.push({i:g-4,x:xe(u,l)},{i:g-2,x:xe(c,f)})}else(l!==1||f!==1)&&h.push(o(h)+"scale("+l+","+f+")")}return function(u,c){var l=[],f=[];return u=e(u),c=e(c),s(u.translateX,u.translateY,c.translateX,c.translateY,l,f),i(u.rotate,c.rotate,l,f),a(u.skewX,c.skewX,l,f),d(u.scaleX,u.scaleY,c.scaleX,c.scaleY,l,f),u=c=null,function(h){for(var m=-1,g=f.length,y;++m<g;)l[(y=f[m]).i]=y.x(h);return l.join("")}}}var Rf=ea(Of,"px, ","px)","deg)"),Pf=ea(If,", ",")",")"),Tf=1e-12;function ki(e){return((e=Math.exp(e))+1/e)/2}function Af(e){return((e=Math.exp(e))-1/e)/2}function Df(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ft=(function e(t,n,r){function o(s,i){var a=s[0],d=s[1],u=s[2],c=i[0],l=i[1],f=i[2],h=c-a,m=l-d,g=h*h+m*m,y,w;if(g<Tf)w=Math.log(f/u)/t,y=function(C){return[a+C*h,d+C*m,u*Math.exp(t*C*w)]};else{var b=Math.sqrt(g),p=(f*f-u*u+r*g)/(2*u*n*b),x=(f*f-u*u-r*g)/(2*f*n*b),E=Math.log(Math.sqrt(p*p+1)-p),_=Math.log(Math.sqrt(x*x+1)-x);w=(_-E)/t,y=function(C){var v=C*w,N=ki(E),P=u/(n*b)*(N*Df(t*v+E)-Af(E));return[a+P*h,d+P*m,u*N/ki(t*v+E)]}}return y.duration=w*1e3*t/Math.SQRT2,y}return o.rho=function(s){var i=Math.max(.001,+s),a=i*i,d=a*a;return e(i,a,d)},o})(Math.SQRT2,2,4);var We=0,it=0,rt=0,ta=1e3,Jt,st,en=0,$e=0,fn=0,ft=typeof performance=="object"&&performance.now?performance:Date,na=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Ur(){return $e||(na(Lf),$e=ft.now()+fn)}function Lf(){$e=0}function tn(){this._call=this._time=this._next=null}tn.prototype=ra.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Ur():+n)+(t==null?0:+t),!this._next&&st!==this&&(st?st._next=this:Jt=this,st=this),this._call=e,this._time=n,$r()},stop:function(){this._call&&(this._call=null,this._time=1/0,$r())}};function ra(e,t,n){var r=new tn;return r.restart(e,t,n),r}function $f(){Ur(),++We;for(var e=Jt,t;e;)(t=$e-e._time)>=0&&e._call.call(void 0,t),e=e._next;--We}function Mi(){$e=(en=ft.now())+fn,We=it=0;try{$f()}finally{We=0,zf(),$e=0}}function jf(){var e=ft.now(),t=e-en;t>ta&&(fn-=t,en=e)}function zf(){for(var e,t=Jt,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);st=e,$r(r)}function $r(e){if(!We){it&&(it=clearTimeout(it));var t=e-$e;t>24?(e<1/0&&(it=setTimeout(Mi,e-ft.now()-fn)),rt&&(rt=clearInterval(rt))):(rt||(en=ft.now(),rt=setInterval(jf,ta)),We=1,na(Mi))}}function Oi(e,t,n){var r=new tn;return t=t==null?0:+t,r.restart(o=>{r.stop(),e(o+t)},t,n),r}var Hf=un("start","end","cancel","interrupt"),Vf=[],oa=0,Ii=1,jr=2,qt=3,Ri=4,zr=5,Yt=6;function hn(e,t,n,r,o,s){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Bf(e,n,{name:t,index:r,group:o,on:Hf,tween:Vf,time:s.time,delay:s.delay,duration:s.duration,ease:s.ease,timer:null,state:oa})}function Qr(e,t){var n=we(e,t);if(n.state>oa)throw new Error("too late; already scheduled");return n}function ve(e,t){var n=we(e,t);if(n.state>qt)throw new Error("too late; already running");return n}function we(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Bf(e,t,n){var r=e.__transition,o;r[t]=n,n.timer=ra(s,0,n.time);function s(u){n.state=Ii,n.timer.restart(i,n.delay,n.time),n.delay<=u&&i(u-n.delay)}function i(u){var c,l,f,h;if(n.state!==Ii)return d();for(c in r)if(h=r[c],h.name===n.name){if(h.state===qt)return Oi(i);h.state===Ri?(h.state=Yt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+c<t&&(h.state=Yt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[c])}if(Oi(function(){n.state===qt&&(n.state=Ri,n.timer.restart(a,n.delay,n.time),a(u))}),n.state=jr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===jr){for(n.state=qt,o=new Array(f=n.tween.length),c=0,l=-1;c<f;++c)(h=n.tween[c].value.call(e,e.__data__,n.index,n.group))&&(o[++l]=h);o.length=l+1}}function a(u){for(var c=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(d),n.state=zr,1),l=-1,f=o.length;++l<f;)o[l].call(e,c);n.state===zr&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Yt,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function Wt(e,t){var n=e.__transition,r,o,s=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){s=!1;continue}o=r.state>jr&&r.state<zr,r.state=Yt,r.timer.stop(),r.on.call(o?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}s&&delete e.__transition}}function Ff(e){return this.each(function(){Wt(this,e)})}function qf(e,t){var n,r;return function(){var o=ve(this,e),s=o.tween;if(s!==n){r=n=s;for(var i=0,a=r.length;i<a;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}o.tween=r}}function Yf(e,t,n){var r,o;if(typeof n!="function")throw new Error;return function(){var s=ve(this,e),i=s.tween;if(i!==r){o=(r=i).slice();for(var a={name:t,value:n},d=0,u=o.length;d<u;++d)if(o[d].name===t){o[d]=a;break}d===u&&o.push(a)}s.tween=o}}function Wf(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=we(this.node(),n).tween,o=0,s=r.length,i;o<s;++o)if((i=r[o]).name===e)return i.value;return null}return this.each((t==null?qf:Yf)(n,e,t))}function Jr(e,t,n){var r=e._id;return e.each(function(){var o=ve(this,r);(o.value||(o.value={}))[t]=n.apply(this,arguments)}),function(o){return we(o,r).value[t]}}function ia(e,t){var n;return(typeof t=="number"?xe:t instanceof Le?Qt:(n=Le(t))?(t=n,Qt):Qs)(e,t)}function Gf(e){return function(){this.removeAttribute(e)}}function Xf(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zf(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttribute(e);return i===o?null:i===r?s:s=t(r=i,n)}}function Kf(e,t,n){var r,o=n+"",s;return function(){var i=this.getAttributeNS(e.space,e.local);return i===o?null:i===r?s:s=t(r=i,n)}}function Uf(e,t,n){var r,o,s;return function(){var i,a=n(this),d;return a==null?void this.removeAttribute(e):(i=this.getAttribute(e),d=a+"",i===d?null:i===r&&d===o?s:(o=d,s=t(r=i,a)))}}function Qf(e,t,n){var r,o,s;return function(){var i,a=n(this),d;return a==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),d=a+"",i===d?null:i===r&&d===o?s:(o=d,s=t(r=i,a)))}}function Jf(e,t){var n=dn(e),r=n==="transform"?Pf:ia;return this.attrTween(e,typeof t=="function"?(n.local?Qf:Uf)(n,r,Jr(this,"attr."+e,t)):t==null?(n.local?Xf:Gf)(n):(n.local?Kf:Zf)(n,r,t))}function eh(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function th(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function nh(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&th(e,s)),n}return o._value=t,o}function rh(e,t){var n,r;function o(){var s=t.apply(this,arguments);return s!==r&&(n=(r=s)&&eh(e,s)),n}return o._value=t,o}function oh(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=dn(e);return this.tween(n,(r.local?nh:rh)(r,t))}function ih(e,t){return function(){Qr(this,e).delay=+t.apply(this,arguments)}}function sh(e,t){return t=+t,function(){Qr(this,e).delay=t}}function ah(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ih:sh)(t,e)):we(this.node(),t).delay}function ch(e,t){return function(){ve(this,e).duration=+t.apply(this,arguments)}}function lh(e,t){return t=+t,function(){ve(this,e).duration=t}}function uh(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?ch:lh)(t,e)):we(this.node(),t).duration}function dh(e,t){if(typeof t!="function")throw new Error;return function(){ve(this,e).ease=t}}function fh(e){var t=this._id;return arguments.length?this.each(dh(t,e)):we(this.node(),t).ease}function hh(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ve(this,e).ease=n}}function ph(e){if(typeof e!="function")throw new Error;return this.each(hh(this._id,e))}function gh(e){typeof e!="function"&&(e=Ls(e));for(var t=this._groups,n=t.length,r=new Array(n),o=0;o<n;++o)for(var s=t[o],i=s.length,a=r[o]=[],d,u=0;u<i;++u)(d=s[u])&&e.call(d,d.__data__,u,s)&&a.push(d);return new Ne(r,this._parents,this._name,this._id)}function mh(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,o=n.length,s=Math.min(r,o),i=new Array(r),a=0;a<s;++a)for(var d=t[a],u=n[a],c=d.length,l=i[a]=new Array(c),f,h=0;h<c;++h)(f=d[h]||u[h])&&(l[h]=f);for(;a<r;++a)i[a]=t[a];return new Ne(i,this._parents,this._name,this._id)}function yh(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function wh(e,t,n){var r,o,s=yh(t)?Qr:ve;return function(){var i=s(this,e),a=i.on;a!==r&&(o=(r=a).copy()).on(t,n),i.on=o}}function xh(e,t){var n=this._id;return arguments.length<2?we(this.node(),n).on.on(e):this.each(wh(n,e,t))}function bh(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function vh(){return this.on("end.remove",bh(this._id))}function _h(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Gr(e));for(var r=this._groups,o=r.length,s=new Array(o),i=0;i<o;++i)for(var a=r[i],d=a.length,u=s[i]=new Array(d),c,l,f=0;f<d;++f)(c=a[f])&&(l=e.call(c,c.__data__,f,a))&&("__data__"in c&&(l.__data__=c.__data__),u[f]=l,hn(u[f],t,n,f,u,we(c,n)));return new Ne(s,this._parents,t,n)}function Eh(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ds(e));for(var r=this._groups,o=r.length,s=[],i=[],a=0;a<o;++a)for(var d=r[a],u=d.length,c,l=0;l<u;++l)if(c=d[l]){for(var f=e.call(c,c.__data__,l,d),h,m=we(c,n),g=0,y=f.length;g<y;++g)(h=f[g])&&hn(h,t,n,g,f,m);s.push(f),i.push(c)}return new Ne(s,i,t,n)}var Sh=vt.prototype.constructor;function Nh(){return new Sh(this._groups,this._parents)}function Ch(e,t){var n,r,o;return function(){var s=Ye(this,e),i=(this.style.removeProperty(e),Ye(this,e));return s===i?null:s===n&&i===r?o:o=t(n=s,r=i)}}function sa(e){return function(){this.style.removeProperty(e)}}function kh(e,t,n){var r,o=n+"",s;return function(){var i=Ye(this,e);return i===o?null:i===r?s:s=t(r=i,n)}}function Mh(e,t,n){var r,o,s;return function(){var i=Ye(this,e),a=n(this),d=a+"";return a==null&&(d=a=(this.style.removeProperty(e),Ye(this,e))),i===d?null:i===r&&d===o?s:(o=d,s=t(r=i,a))}}function Oh(e,t){var n,r,o,s="style."+t,i="end."+s,a;return function(){var d=ve(this,e),u=d.on,c=d.value[s]==null?a||(a=sa(t)):void 0;(u!==n||o!==c)&&(r=(n=u).copy()).on(i,o=c),d.on=r}}function Ih(e,t,n){var r=(e+="")=="transform"?Rf:ia;return t==null?this.styleTween(e,Ch(e,r)).on("end.style."+e,sa(e)):typeof t=="function"?this.styleTween(e,Mh(e,r,Jr(this,"style."+e,t))).each(Oh(this._id,e)):this.styleTween(e,kh(e,r,t),n).on("end.style."+e,null)}function Rh(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Ph(e,t,n){var r,o;function s(){var i=t.apply(this,arguments);return i!==o&&(r=(o=i)&&Rh(e,i,n)),r}return s._value=t,s}function Th(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,Ph(e,t,n??""))}function Ah(e){return function(){this.textContent=e}}function Dh(e){return function(){var t=e(this);this.textContent=t??""}}function Lh(e){return this.tween("text",typeof e=="function"?Dh(Jr(this,"text",e)):Ah(e==null?"":e+""))}function $h(e){return function(t){this.textContent=e.call(this,t)}}function jh(e){var t,n;function r(){var o=e.apply(this,arguments);return o!==n&&(t=(n=o)&&$h(o)),t}return r._value=e,r}function zh(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,jh(e))}function Hh(){for(var e=this._name,t=this._id,n=aa(),r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],a=i.length,d,u=0;u<a;++u)if(d=i[u]){var c=we(d,t);hn(d,e,n,u,i,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new Ne(r,this._parents,e,n)}function Vh(){var e,t,n=this,r=n._id,o=n.size();return new Promise(function(s,i){var a={value:i},d={value:function(){--o===0&&s()}};n.each(function(){var u=ve(this,r),c=u.on;c!==e&&(t=(e=c).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(d)),u.on=t}),o===0&&s()})}var Bh=0;function Ne(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function aa(){return++Bh}var Ee=vt.prototype;Ne.prototype={constructor:Ne,select:_h,selectAll:Eh,selectChild:Ee.selectChild,selectChildren:Ee.selectChildren,filter:gh,merge:mh,selection:Nh,transition:Hh,call:Ee.call,nodes:Ee.nodes,node:Ee.node,size:Ee.size,empty:Ee.empty,each:Ee.each,on:xh,attr:Jf,attrTween:oh,style:Ih,styleTween:Th,text:Lh,textTween:zh,remove:vh,tween:Wf,delay:ah,duration:uh,ease:fh,easeVarying:ph,end:Vh,[Symbol.iterator]:Ee[Symbol.iterator]};function Fh(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var qh={time:null,delay:0,duration:250,ease:Fh};function Yh(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Wh(e){var t,n;e instanceof Ne?(t=e._id,e=e._name):(t=aa(),(n=qh).time=Ur(),e=e==null?null:e+"");for(var r=this._groups,o=r.length,s=0;s<o;++s)for(var i=r[s],a=i.length,d,u=0;u<a;++u)(d=i[u])&&hn(d,e,t,u,i,n||Yh(d,t));return new Ne(r,this._parents,e,t)}vt.prototype.interrupt=Ff;vt.prototype.transition=Wh;const Dt=e=>()=>e;function Gh(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:o}})}function Se(e,t,n){this.k=e,this.x=t,this.y=n}Se.prototype={constructor:Se,scale:function(e){return e===1?this:new Se(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Se(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var pn=new Se(1,0,0);ca.prototype=Se.prototype;function ca(e){for(;!e.__zoom;)if(!(e=e.parentNode))return pn;return e.__zoom}function vr(e){e.stopImmediatePropagation()}function ot(e){e.preventDefault(),e.stopImmediatePropagation()}function Xh(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Zh(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Pi(){return this.__zoom||pn}function Kh(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Uh(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qh(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}function la(){var e=Xh,t=Zh,n=Qh,r=Kh,o=Uh,s=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,d=Ft,u=un("start","zoom","end"),c,l,f,h=500,m=150,g=0,y=10;function w(S){S.property("__zoom",Pi).on("wheel.zoom",v,{passive:!1}).on("mousedown.zoom",N).on("dblclick.zoom",P).filter(o).on("touchstart.zoom",k).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",$).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}w.transform=function(S,R,A,L){var j=S.selection?S.selection():S;j.property("__zoom",Pi),S!==j?E(S,R,A,L):j.interrupt().each(function(){_(this,arguments).event(L).start().zoom(null,typeof R=="function"?R.apply(this,arguments):R).end()})},w.scaleBy=function(S,R,A,L){w.scaleTo(S,function(){var j=this.__zoom.k,V=typeof R=="function"?R.apply(this,arguments):R;return j*V},A,L)},w.scaleTo=function(S,R,A,L){w.transform(S,function(){var j=t.apply(this,arguments),V=this.__zoom,W=A==null?x(j):typeof A=="function"?A.apply(this,arguments):A,I=V.invert(W),B=typeof R=="function"?R.apply(this,arguments):R;return n(p(b(V,B),W,I),j,i)},A,L)},w.translateBy=function(S,R,A,L){w.transform(S,function(){return n(this.__zoom.translate(typeof R=="function"?R.apply(this,arguments):R,typeof A=="function"?A.apply(this,arguments):A),t.apply(this,arguments),i)},null,L)},w.translateTo=function(S,R,A,L,j){w.transform(S,function(){var V=t.apply(this,arguments),W=this.__zoom,I=L==null?x(V):typeof L=="function"?L.apply(this,arguments):L;return n(pn.translate(I[0],I[1]).scale(W.k).translate(typeof R=="function"?-R.apply(this,arguments):-R,typeof A=="function"?-A.apply(this,arguments):-A),V,i)},L,j)};function b(S,R){return R=Math.max(s[0],Math.min(s[1],R)),R===S.k?S:new Se(R,S.x,S.y)}function p(S,R,A){var L=R[0]-A[0]*S.k,j=R[1]-A[1]*S.k;return L===S.x&&j===S.y?S:new Se(S.k,L,j)}function x(S){return[(+S[0][0]+ +S[1][0])/2,(+S[0][1]+ +S[1][1])/2]}function E(S,R,A,L){S.on("start.zoom",function(){_(this,arguments).event(L).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(L).end()}).tween("zoom",function(){var j=this,V=arguments,W=_(j,V).event(L),I=t.apply(j,V),B=A==null?x(I):typeof A=="function"?A.apply(j,V):A,O=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),T=j.__zoom,H=typeof R=="function"?R.apply(j,V):R,Y=d(T.invert(B).concat(O/T.k),H.invert(B).concat(O/H.k));return function(F){if(F===1)F=H;else{var q=Y(F),G=O/q[2];F=new Se(G,B[0]-q[0]*G,B[1]-q[1]*G)}W.zoom(null,F)}})}function _(S,R,A){return!A&&S.__zooming||new C(S,R)}function C(S,R){this.that=S,this.args=R,this.active=0,this.sourceEvent=null,this.extent=t.apply(S,R),this.taps=0}C.prototype={event:function(S){return S&&(this.sourceEvent=S),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(S,R){return this.mouse&&S!=="mouse"&&(this.mouse[1]=R.invert(this.mouse[0])),this.touch0&&S!=="touch"&&(this.touch0[1]=R.invert(this.touch0[0])),this.touch1&&S!=="touch"&&(this.touch1[1]=R.invert(this.touch1[0])),this.that.__zoom=R,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(S){var R=ue(this.that).datum();u.call(S,this.that,new Gh(S,{sourceEvent:this.sourceEvent,target:w,transform:this.that.__zoom,dispatch:u}),R)}};function v(S,...R){if(!e.apply(this,arguments))return;var A=_(this,R).event(S),L=this.__zoom,j=Math.max(s[0],Math.min(s[1],L.k*Math.pow(2,r.apply(this,arguments)))),V=he(S);if(A.wheel)(A.mouse[0][0]!==V[0]||A.mouse[0][1]!==V[1])&&(A.mouse[1]=L.invert(A.mouse[0]=V)),clearTimeout(A.wheel);else{if(L.k===j)return;A.mouse=[V,L.invert(V)],Wt(this),A.start()}ot(S),A.wheel=setTimeout(W,m),A.zoom("mouse",n(p(b(L,j),A.mouse[0],A.mouse[1]),A.extent,i));function W(){A.wheel=null,A.end()}}function N(S,...R){if(f||!e.apply(this,arguments))return;var A=S.currentTarget,L=_(this,R,!0).event(S),j=ue(S.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",O,!0),V=he(S,A),W=S.clientX,I=S.clientY;Ws(S.view),vr(S),L.mouse=[V,this.__zoom.invert(V)],Wt(this),L.start();function B(T){if(ot(T),!L.moved){var H=T.clientX-W,Y=T.clientY-I;L.moved=H*H+Y*Y>g}L.event(T).zoom("mouse",n(p(L.that.__zoom,L.mouse[0]=he(T,A),L.mouse[1]),L.extent,i))}function O(T){j.on("mousemove.zoom mouseup.zoom",null),Gs(T.view,L.moved),ot(T),L.event(T).end()}}function P(S,...R){if(e.apply(this,arguments)){var A=this.__zoom,L=he(S.changedTouches?S.changedTouches[0]:S,this),j=A.invert(L),V=A.k*(S.shiftKey?.5:2),W=n(p(b(A,V),L,j),t.apply(this,R),i);ot(S),a>0?ue(this).transition().duration(a).call(E,W,L,S):ue(this).call(w.transform,W,L,S)}}function k(S,...R){if(e.apply(this,arguments)){var A=S.touches,L=A.length,j=_(this,R,S.changedTouches.length===L).event(S),V,W,I,B;for(vr(S),W=0;W<L;++W)I=A[W],B=he(I,this),B=[B,this.__zoom.invert(B),I.identifier],j.touch0?!j.touch1&&j.touch0[2]!==B[2]&&(j.touch1=B,j.taps=0):(j.touch0=B,V=!0,j.taps=1+!!c);c&&(c=clearTimeout(c)),V&&(j.taps<2&&(l=B[0],c=setTimeout(function(){c=null},h)),Wt(this),j.start())}}function M(S,...R){if(this.__zooming){var A=_(this,R).event(S),L=S.changedTouches,j=L.length,V,W,I,B;for(ot(S),V=0;V<j;++V)W=L[V],I=he(W,this),A.touch0&&A.touch0[2]===W.identifier?A.touch0[0]=I:A.touch1&&A.touch1[2]===W.identifier&&(A.touch1[0]=I);if(W=A.that.__zoom,A.touch1){var O=A.touch0[0],T=A.touch0[1],H=A.touch1[0],Y=A.touch1[1],F=(F=H[0]-O[0])*F+(F=H[1]-O[1])*F,q=(q=Y[0]-T[0])*q+(q=Y[1]-T[1])*q;W=b(W,Math.sqrt(F/q)),I=[(O[0]+H[0])/2,(O[1]+H[1])/2],B=[(T[0]+Y[0])/2,(T[1]+Y[1])/2]}else if(A.touch0)I=A.touch0[0],B=A.touch0[1];else return;A.zoom("touch",n(p(W,I,B),A.extent,i))}}function $(S,...R){if(this.__zooming){var A=_(this,R).event(S),L=S.changedTouches,j=L.length,V,W;for(vr(S),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),V=0;V<j;++V)W=L[V],A.touch0&&A.touch0[2]===W.identifier?delete A.touch0:A.touch1&&A.touch1[2]===W.identifier&&delete A.touch1;if(A.touch1&&!A.touch0&&(A.touch0=A.touch1,delete A.touch1),A.touch0)A.touch0[1]=this.__zoom.invert(A.touch0[0]);else if(A.end(),A.taps===2&&(W=he(W,this),Math.hypot(l[0]-W[0],l[1]-W[1])<y)){var I=ue(this).on("dblclick.zoom");I&&I.apply(this,arguments)}}}return w.wheelDelta=function(S){return arguments.length?(r=typeof S=="function"?S:Dt(+S),w):r},w.filter=function(S){return arguments.length?(e=typeof S=="function"?S:Dt(!!S),w):e},w.touchable=function(S){return arguments.length?(o=typeof S=="function"?S:Dt(!!S),w):o},w.extent=function(S){return arguments.length?(t=typeof S=="function"?S:Dt([[+S[0][0],+S[0][1]],[+S[1][0],+S[1][1]]]),w):t},w.scaleExtent=function(S){return arguments.length?(s[0]=+S[0],s[1]=+S[1],w):[s[0],s[1]]},w.translateExtent=function(S){return arguments.length?(i[0][0]=+S[0][0],i[1][0]=+S[1][0],i[0][1]=+S[0][1],i[1][1]=+S[1][1],w):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},w.constrain=function(S){return arguments.length?(n=S,w):n},w.duration=function(S){return arguments.length?(a=+S,w):a},w.interpolate=function(S){return arguments.length?(d=S,w):d},w.on=function(){var S=u.on.apply(u,arguments);return S===u?w:S},w.clickDistance=function(S){return arguments.length?(g=(S=+S)*S,w):Math.sqrt(g)},w.tapDistance=function(S){return arguments.length?(y=+S,w):y},w}const fe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},ht=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ua=["Enter"," ","Escape"],da={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Ge;(function(e){e.Strict="strict",e.Loose="loose"})(Ge||(Ge={}));var De;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(De||(De={}));var pt;(function(e){e.Partial="partial",e.Full="full"})(pt||(pt={}));const fa={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null};var Oe;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Oe||(Oe={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var K;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(K||(K={}));const Ti={[K.Left]:K.Right,[K.Right]:K.Left,[K.Top]:K.Bottom,[K.Bottom]:K.Top};function ha(e){return e===null?null:e?"valid":"invalid"}const pa=e=>"id"in e&&"source"in e&&"target"in e,Jh=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),eo=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Et=(e,t=[0,0])=>{const{width:n,height:r}=Ce(e),o=e.origin??t,s=n*o[0],i=r*o[1];return{x:e.position.x-s,y:e.position.y-i}},ep=(e,t={nodeOrigin:[0,0]})=>{if(process.env.NODE_ENV==="development"&&!t.nodeLookup&&console.warn("Please use `getNodesBounds` from `useReactFlow`/`useSvelteFlow` hook to ensure correct values for sub flows. If not possible, you have to provide a nodeLookup to support sub flows."),e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,o)=>{const s=typeof o=="string";let i=!t.nodeLookup&&!s?o:void 0;t.nodeLookup&&(i=s?t.nodeLookup.get(o):eo(o)?o:t.nodeLookup.get(o.id));const a=i?rn(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return gn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return mn(n)},St=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(o=>{(t.filter===void 0||t.filter(o))&&(n=gn(n,rn(o)),r=!0)}),r?mn(n):{x:0,y:0,width:0,height:0}},to=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1)=>{const a={...Ct(t,[n,r,o]),width:t.width/o,height:t.height/o},d=[];for(const u of e.values()){const{measured:c,selectable:l=!0,hidden:f=!1}=u;if(i&&!l||f)continue;const h=c.width??u.width??u.initialWidth??null,m=c.height??u.height??u.initialHeight??null,g=gt(a,Ze(u)),y=(h??0)*(m??0),w=s&&g>0;(!u.internals.handleBounds||w||g>=y||u.dragging)&&d.push(u)}return d},tp=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function np(e,t){const n=new Map,r=t?.nodes?new Set(t.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&(t?.includeHiddenNodes||!o.hidden)&&(!r||r.has(o.id))&&n.set(o.id,o)}),n}async function rp({nodes:e,width:t,height:n,panZoom:r,minZoom:o,maxZoom:s},i){if(e.size===0)return Promise.resolve(!0);const a=np(e,i),d=St(a),u=no(d,t,n,i?.minZoom??o,i?.maxZoom??s,i?.padding??.1);return await r.setViewport(u,{duration:i?.duration,ease:i?.ease,interpolate:i?.interpolate}),Promise.resolve(!0)}function ga({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:o,onError:s}){const i=n.get(e),a=i.parentId?n.get(i.parentId):void 0,{x:d,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},c=i.origin??r;let l=i.extent||o;if(i.extent==="parent"&&!i.expandParent)if(!a)s?.("005",fe.error005());else{const h=a.measured.width,m=a.measured.height;h&&m&&(l=[[d,u],[d+h,u+m]])}else a&&Ke(i.extent)&&(l=[[i.extent[0][0]+d,i.extent[0][1]+u],[i.extent[1][0]+d,i.extent[1][1]+u]]);const f=Ke(l)?je(t,l,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&s?.("015",fe.error015()),{position:{x:f.x-d+(i.measured.width??0)*c[0],y:f.y-u+(i.measured.height??0)*c[1]},positionAbsolute:f}}async function op({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:o}){const s=new Set(e.map(f=>f.id)),i=[];for(const f of n){if(f.deletable===!1)continue;const h=s.has(f.id),m=!h&&f.parentId&&i.find(g=>g.id===f.parentId);(h||m)&&i.push(f)}const a=new Set(t.map(f=>f.id)),d=r.filter(f=>f.deletable!==!1),c=tp(i,d);for(const f of d)a.has(f.id)&&!c.find(m=>m.id===f.id)&&c.push(f);if(!o)return{edges:c,nodes:i};const l=await o({nodes:i,edges:c});return typeof l=="boolean"?l?{edges:c,nodes:i}:{edges:[],nodes:[]}:l}const Xe=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),je=(e={x:0,y:0},t,n)=>({x:Xe(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Xe(e.y,t[0][1],t[1][1]-(n?.height??0))});function ma(e,t,n){const{width:r,height:o}=Ce(n),{x:s,y:i}=n.internals.positionAbsolute;return je(e,[[s,i],[s+r,i+o]],t)}const Ai=(e,t,n)=>e<t?Xe(Math.abs(e-t),1,t)/t:e>n?-Xe(Math.abs(e-n),1,t)/t:0,ya=(e,t,n=15,r=40)=>{const o=Ai(e.x,r,t.width-r)*n,s=Ai(e.y,r,t.height-r)*n;return[o,s]},gn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Hr=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),mn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Ze=(e,t=[0,0])=>{const{x:n,y:r}=eo(e)?e.internals.positionAbsolute:Et(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},rn=(e,t=[0,0])=>{const{x:n,y:r}=eo(e)?e.internals.positionAbsolute:Et(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},wa=(e,t)=>mn(gn(Hr(e),Hr(t))),gt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Di=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),xa=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},Nt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ct=({x:e,y:t},[n,r,o],s=!1,i=[1,1])=>{const a={x:(e-n)/o,y:(t-r)/o};return s?Nt(a,i):a},on=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r});function He(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function ip(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=He(e,n),o=He(e,t);return{top:r,right:o,bottom:r,left:o,x:o*2,y:r*2}}if(typeof e=="object"){const r=He(e.top??e.y??0,n),o=He(e.bottom??e.y??0,n),s=He(e.left??e.x??0,t),i=He(e.right??e.x??0,t);return{top:r,right:i,bottom:o,left:s,x:s+i,y:r+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function sp(e,t,n,r,o,s){const{x:i,y:a}=on(e,[t,n,r]),{x:d,y:u}=on({x:e.x+e.width,y:e.y+e.height},[t,n,r]),c=o-d,l=s-u;return{left:Math.floor(i),top:Math.floor(a),right:Math.floor(c),bottom:Math.floor(l)}}const no=(e,t,n,r,o,s)=>{const i=ip(s,t,n),a=(t-i.x)/e.width,d=(n-i.y)/e.height,u=Math.min(a,d),c=Xe(u,r,o),l=e.x+e.width/2,f=e.y+e.height/2,h=t/2-l*c,m=n/2-f*c,g=sp(e,h,m,c,t,n),y={left:Math.min(g.left-i.left,0),top:Math.min(g.top-i.top,0),right:Math.min(g.right-i.right,0),bottom:Math.min(g.bottom-i.bottom,0)};return{x:h-y.left+y.right,y:m-y.top+y.bottom,zoom:c}},mt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ke(e){return e!=null&&e!=="parent"}function Ce(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ba(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function va(e,t={width:0,height:0},n,r,o){const s={...e},i=r.get(n);if(i){const a=i.origin||o;s.x+=i.internals.positionAbsolute.x-(t.width??0)*a[0],s.y+=i.internals.positionAbsolute.y-(t.height??0)*a[1]}return s}function Li(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ap(){let e,t;return{promise:new Promise((r,o)=>{e=r,t=o}),resolve:e,reject:t}}function cp(e){return{...da,...e||{}}}function ct(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:o}){const{x:s,y:i}=me(e),a=Ct({x:s-(o?.left??0),y:i-(o?.top??0)},r),{x:d,y:u}=n?Nt(a,t):a;return{xSnapped:d,ySnapped:u,...a}}const ro=e=>({width:e.offsetWidth,height:e.offsetHeight}),_a=e=>e?.getRootNode?.()||window?.document,lp=["INPUT","SELECT","TEXTAREA"];function Ea(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:lp.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Sa=e=>"clientX"in e,me=(e,t)=>{const n=Sa(e),r=n?e.clientX:e.touches?.[0].clientX,o=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:o-(t?.top??0)}},$i=(e,t,n,r,o)=>{const s=t.querySelectorAll(`.${e}`);return!s||!s.length?null:Array.from(s).map(i=>{const a=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:o,position:i.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...ro(i)}})};function Na({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:a}){const d=e*.125+o*.375+i*.375+n*.125,u=t*.125+s*.375+a*.375+r*.125,c=Math.abs(d-e),l=Math.abs(u-t);return[d,u,c,l]}function Lt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ji({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case K.Left:return[t-Lt(t-r,s),n];case K.Right:return[t+Lt(r-t,s),n];case K.Top:return[t,n-Lt(n-o,s)];case K.Bottom:return[t,n+Lt(o-n,s)]}}function Ca({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:o,targetPosition:s=K.Top,curvature:i=.25}){const[a,d]=ji({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[u,c]=ji({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[l,f,h,m]=Na({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:d,targetControlX:u,targetControlY:c});return[`M${e},${t} C${a},${d} ${u},${c} ${r},${o}`,l,f,h,m]}function ka({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,s=n<e?n+o:n-o,i=Math.abs(r-t)/2,a=r<t?r+i:r-i;return[s,a,o,i]}function up({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r,elevateOnSelect:o=!1}){if(r!==void 0)return r;const s=o&&n?1e3:0,i=Math.max(e.parentId||o&&e.selected?e.internals.z:0,t.parentId||o&&t.selected?t.internals.z:0);return s+i}function dp({sourceNode:e,targetNode:t,width:n,height:r,transform:o}){const s=gn(rn(e),rn(t));s.x===s.x2&&(s.x2+=1),s.y===s.y2&&(s.y2+=1);const i={x:-o[0]/o[2],y:-o[1]/o[2],width:n/o[2],height:r/o[2]};return gt(i,mn(s))>0}const fp=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,hp=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),pp=(e,t)=>{if(!e.source||!e.target)return xa("006",fe.error006()),t;let n;return pa(e)?n={...e}:n={...e,id:fp(e)},hp(n,t)?t:(n.sourceHandle===null&&delete n.sourceHandle,n.targetHandle===null&&delete n.targetHandle,t.concat(n))};function Ma({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,a]=ka({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,a]}const zi={[K.Left]:{x:-1,y:0},[K.Right]:{x:1,y:0},[K.Top]:{x:0,y:-1},[K.Bottom]:{x:0,y:1}},gp=({source:e,sourcePosition:t=K.Bottom,target:n})=>t===K.Left||t===K.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Hi=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function mp({source:e,sourcePosition:t=K.Bottom,target:n,targetPosition:r=K.Top,center:o,offset:s,stepPosition:i}){const a=zi[t],d=zi[r],u={x:e.x+a.x*s,y:e.y+a.y*s},c={x:n.x+d.x*s,y:n.y+d.y*s},l=gp({source:u,sourcePosition:t,target:c}),f=l.x!==0?"x":"y",h=l[f];let m=[],g,y;const w={x:0,y:0},b={x:0,y:0},[,,p,x]=ka({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*d[f]===-1){f==="x"?(g=o.x??u.x+(c.x-u.x)*i,y=o.y??(u.y+c.y)/2):(g=o.x??(u.x+c.x)/2,y=o.y??u.y+(c.y-u.y)*i);const _=[{x:g,y:u.y},{x:g,y:c.y}],C=[{x:u.x,y},{x:c.x,y}];a[f]===h?m=f==="x"?_:C:m=f==="x"?C:_}else{const _=[{x:u.x,y:c.y}],C=[{x:c.x,y:u.y}];if(f==="x"?m=a.x===h?C:_:m=a.y===h?_:C,t===r){const M=Math.abs(e[f]-n[f]);if(M<=s){const $=Math.min(s-1,s-M);a[f]===h?w[f]=(u[f]>e[f]?-1:1)*$:b[f]=(c[f]>n[f]?-1:1)*$}}if(t!==r){const M=f==="x"?"y":"x",$=a[f]===d[M],S=u[M]>c[M],R=u[M]<c[M];(a[f]===1&&(!$&&S||$&&R)||a[f]!==1&&(!$&&R||$&&S))&&(m=f==="x"?_:C)}const v={x:u.x+w.x,y:u.y+w.y},N={x:c.x+b.x,y:c.y+b.y},P=Math.max(Math.abs(v.x-m[0].x),Math.abs(N.x-m[0].x)),k=Math.max(Math.abs(v.y-m[0].y),Math.abs(N.y-m[0].y));P>=k?(g=(v.x+N.x)/2,y=m[0].y):(g=m[0].x,y=(v.y+N.y)/2)}return[[e,{x:u.x+w.x,y:u.y+w.y},...m,{x:c.x+b.x,y:c.y+b.y},n],g,y,p,x]}function yp(e,t,n,r){const o=Math.min(Hi(e,t)/2,Hi(t,n)/2,r),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i){const u=e.x<n.x?-1:1,c=e.y<n.y?1:-1;return`L ${s+o*u},${i}Q ${s},${i} ${s},${i+o*c}`}const a=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${s},${i+o*d}Q ${s},${i} ${s+o*a},${i}`}function Vr({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:o,targetPosition:s=K.Top,borderRadius:i=5,centerX:a,centerY:d,offset:u=20,stepPosition:c=.5}){const[l,f,h,m,g]=mp({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:a,y:d},offset:u,stepPosition:c});return[l.reduce((w,b,p)=>{let x="";return p>0&&p<l.length-1?x=yp(l[p-1],b,l[p+1],i):x=`${p===0?"M":"L"}${b.x} ${b.y}`,w+=x,w},""),f,h,m,g]}function Vi(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function wp(e){const{sourceNode:t,targetNode:n}=e;if(!Vi(t)||!Vi(n))return null;const r=t.internals.handleBounds||Bi(t.handles),o=n.internals.handleBounds||Bi(n.handles),s=Fi(r?.source??[],e.sourceHandle),i=Fi(e.connectionMode===Ge.Strict?o?.target??[]:(o?.target??[]).concat(o?.source??[]),e.targetHandle);if(!s||!i)return e.onError?.("008",fe.error008(s?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=s?.position||K.Bottom,d=i?.position||K.Top,u=yt(t,s,a),c=yt(n,i,d);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y,sourcePosition:a,targetPosition:d}}function Bi(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function yt(e,t,n=K.Left,r=!1){const o=(t?.x??0)+e.internals.positionAbsolute.x,s=(t?.y??0)+e.internals.positionAbsolute.y,{width:i,height:a}=t??Ce(e);if(r)return{x:o+i/2,y:s+a/2};switch(t?.position??n){case K.Top:return{x:o+i/2,y:s};case K.Right:return{x:o+i,y:s+a/2};case K.Bottom:return{x:o+i/2,y:s+a};case K.Left:return{x:o,y:s+a/2}}}function Fi(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Br(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function xp(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:o}){const s=new Set;return e.reduce((i,a)=>([a.markerStart||r,a.markerEnd||o].forEach(d=>{if(d&&typeof d=="object"){const u=Br(d,t);s.has(u)||(i.push({id:u,color:d.color||n,...d}),s.add(u))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))}const Oa=1e3,bp=10,oo={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,defaults:{}},vp={...oo,checkEquality:!0};function io(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function _p(e,t,n){const r=io(oo,n);for(const o of e.values())if(o.parentId)so(o,e,t,r);else{const s=Et(o,r.nodeOrigin),i=Ke(o.extent)?o.extent:r.nodeExtent,a=je(s,i,Ce(o));o.internals.positionAbsolute=a}}function Ep(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],r=[];for(const o of e.handles){const s={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?n.push(s):o.type==="target"&&r.push(s)}return{source:n,target:r}}function Fr(e,t,n,r){const o=io(vp,r);let s={i:-1},i=e.length>0;const a=new Map(t),d=o?.elevateNodesOnSelect?Oa:0;t.clear(),n.clear();for(const u of e){let c=a.get(u.id);if(o.checkEquality&&u===c?.internals.userNode)t.set(u.id,c);else{const l=Et(u,o.nodeOrigin),f=Ke(u.extent)?u.extent:o.nodeExtent,h=je(l,f,Ce(u));c={...o.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:h,handleBounds:Ep(u,c),z:Ia(u,d),userNode:u}},t.set(u.id,c)}(c.measured===void 0||c.measured.width===void 0||c.measured.height===void 0)&&!c.hidden&&(i=!1),u.parentId&&so(c,t,n,r,s)}return i}function Sp(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function so(e,t,n,r,o){const{elevateNodesOnSelect:s,nodeOrigin:i,nodeExtent:a}=io(oo,r),d=e.parentId,u=t.get(d);if(!u){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Sp(e,n),o&&!u.parentId&&u.internals.rootParentIndex===void 0&&(u.internals.rootParentIndex=++o.i,u.internals.z=u.internals.z+o.i*bp),o&&u.internals.rootParentIndex!==void 0&&(o.i=u.internals.rootParentIndex);const c=s?Oa:0,{x:l,y:f,z:h}=Np(e,u,i,a,c),{positionAbsolute:m}=e.internals,g=l!==m.x||f!==m.y;(g||h!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:g?{x:l,y:f}:m,z:h}})}function Ia(e,t){return(ge(e.zIndex)?e.zIndex:0)+(e.selected?t:0)}function Np(e,t,n,r,o){const{x:s,y:i}=t.internals.positionAbsolute,a=Ce(e),d=Et(e,n),u=Ke(e.extent)?je(d,e.extent,a):d;let c=je({x:s+u.x,y:i+u.y},r,a);e.extent==="parent"&&(c=ma(c,a,t));const l=Ia(e,o),f=t.internals.z??0;return{x:c.x,y:c.y,z:f>=l?f+1:l}}function ao(e,t,n,r=[0,0]){const o=[],s=new Map;for(const i of e){const a=t.get(i.parentId);if(!a)continue;const d=s.get(i.parentId)?.expandedRect??Ze(a),u=wa(d,i.rect);s.set(i.parentId,{expandedRect:u,parent:a})}return s.size>0&&s.forEach(({expandedRect:i,parent:a},d)=>{const u=a.internals.positionAbsolute,c=Ce(a),l=a.origin??r,f=i.x<u.x?Math.round(Math.abs(u.x-i.x)):0,h=i.y<u.y?Math.round(Math.abs(u.y-i.y)):0,m=Math.max(c.width,Math.round(i.width)),g=Math.max(c.height,Math.round(i.height)),y=(m-c.width)*l[0],w=(g-c.height)*l[1];(f>0||h>0||y||w)&&(o.push({id:d,type:"position",position:{x:a.position.x-f+y,y:a.position.y-h+w}}),n.get(d)?.forEach(b=>{e.some(p=>p.id===b.id)||o.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(c.width<i.width||c.height<i.height||f||h)&&o.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:m+(f?l[0]*f-y:0),height:g+(h?l[1]*h-w:0)}})}),o}function Cp(e,t,n,r,o,s){const i=r?.querySelector(".xyflow__viewport");let a=!1;if(!i)return{changes:[],updatedInternals:a};const d=[],u=window.getComputedStyle(i),{m22:c}=new window.DOMMatrixReadOnly(u.transform),l=[];for(const f of e.values()){const h=t.get(f.id);if(!h)continue;if(h.hidden){t.set(h.id,{...h,internals:{...h.internals,handleBounds:void 0}}),a=!0;continue}const m=ro(f.nodeElement),g=h.measured.width!==m.width||h.measured.height!==m.height;if(!!(m.width&&m.height&&(g||!h.internals.handleBounds||f.force))){const w=f.nodeElement.getBoundingClientRect(),b=Ke(h.extent)?h.extent:s;let{positionAbsolute:p}=h.internals;h.parentId&&h.extent==="parent"?p=ma(p,m,t.get(h.parentId)):b&&(p=je(p,b,m));const x={...h,measured:m,internals:{...h.internals,positionAbsolute:p,handleBounds:{source:$i("source",f.nodeElement,w,c,h.id),target:$i("target",f.nodeElement,w,c,h.id)}}};t.set(h.id,x),h.parentId&&so(x,t,n,{nodeOrigin:o}),a=!0,g&&(d.push({id:h.id,type:"dimensions",dimensions:m}),h.expandParent&&h.parentId&&l.push({id:h.id,parentId:h.parentId,rect:Ze(x,o)}))}}if(l.length>0){const f=ao(l,t,n,o);d.push(...f)}return{changes:d,updatedInternals:a}}async function kp({delta:e,panZoom:t,transform:n,translateExtent:r,width:o,height:s}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[o,s]],r),a=!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2]);return Promise.resolve(a)}function qi(e,t,n,r,o,s){let i=o;const a=r.get(i)||new Map;r.set(i,a.set(n,t)),i=`${o}-${e}`;const d=r.get(i)||new Map;if(r.set(i,d.set(n,t)),s){i=`${o}-${e}-${s}`;const u=r.get(i)||new Map;r.set(i,u.set(n,t))}}function Ra(e,t,n){e.clear(),t.clear();for(const r of n){const{source:o,target:s,sourceHandle:i=null,targetHandle:a=null}=r,d={edgeId:r.id,source:o,target:s,sourceHandle:i,targetHandle:a},u=`${o}-${i}--${s}-${a}`,c=`${s}-${a}--${o}-${i}`;qi("source",d,c,e,o,i),qi("target",d,u,e,s,a),t.set(r.id,r)}}function Pa(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Pa(n,t):!1}function Yi(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function Mp(e,t,n,r){const o=new Map;for(const[s,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!Pa(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const a=e.get(s);a&&o.set(s,{id:s,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return o}function _r({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){const o=[];for(const[i,a]of t){const d=n.get(i)?.internals.userNode;d&&o.push({...d,position:a.position,dragging:r})}if(!e)return[o[0],o];const s=n.get(e)?.internals.userNode;return[s?{...s,position:t.get(e)?.position||s.position,dragging:r}:o[0],o]}function Op({dragItems:e,snapGrid:t,x:n,y:r}){const o=e.values().next().value;if(!o)return null;const s={x:n-o.distance.x,y:r-o.distance.y},i=Nt(s,t);return{x:i.x-s.x,y:i.y-s.y}}function Ip({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:o}){let s={x:null,y:null},i=0,a=new Map,d=!1,u={x:0,y:0},c=null,l=!1,f=null,h=!1,m=!1,g=null;function y({noDragClassName:b,handleSelector:p,domNode:x,isSelectable:E,nodeId:_,nodeClickDistance:C=0}){f=ue(x);function v({x:M,y:$}){const{nodeLookup:S,nodeExtent:R,snapGrid:A,snapToGrid:L,nodeOrigin:j,onNodeDrag:V,onSelectionDrag:W,onError:I,updateNodePositions:B}=t();s={x:M,y:$};let O=!1;const T=a.size>1,H=T&&R?Hr(St(a)):null,Y=T&&L?Op({dragItems:a,snapGrid:A,x:M,y:$}):null;for(const[F,q]of a){if(!S.has(F))continue;let G={x:M-q.distance.x,y:$-q.distance.y};L&&(G=Y?{x:Math.round(G.x+Y.x),y:Math.round(G.y+Y.y)}:Nt(G,A));let U=null;if(T&&R&&!q.extent&&H){const{positionAbsolute:Z}=q.internals,J=Z.x-H.x+R[0][0],te=Z.x+q.measured.width-H.x2+R[1][0],ne=Z.y-H.y+R[0][1],ae=Z.y+q.measured.height-H.y2+R[1][1];U=[[J,ne],[te,ae]]}const{position:Q,positionAbsolute:X}=ga({nodeId:F,nextPosition:G,nodeLookup:S,nodeExtent:U||R,nodeOrigin:j,onError:I});O=O||q.position.x!==Q.x||q.position.y!==Q.y,q.position=Q,q.internals.positionAbsolute=X}if(m=m||O,!!O&&(B(a,!0),g&&(r||V||!_&&W))){const[F,q]=_r({nodeId:_,dragItems:a,nodeLookup:S});r?.(g,a,F,q),V?.(g,F,q),_||W?.(g,q)}}async function N(){if(!c)return;const{transform:M,panBy:$,autoPanSpeed:S,autoPanOnNodeDrag:R}=t();if(!R){d=!1,cancelAnimationFrame(i);return}const[A,L]=ya(u,c,S);(A!==0||L!==0)&&(s.x=(s.x??0)-A/M[2],s.y=(s.y??0)-L/M[2],await $({x:A,y:L})&&v(s)),i=requestAnimationFrame(N)}function P(M){const{nodeLookup:$,multiSelectionActive:S,nodesDraggable:R,transform:A,snapGrid:L,snapToGrid:j,selectNodesOnDrag:V,onNodeDragStart:W,onSelectionDragStart:I,unselectNodesAndEdges:B}=t();l=!0,(!V||!E)&&!S&&_&&($.get(_)?.selected||B()),E&&V&&_&&e?.(_);const O=ct(M.sourceEvent,{transform:A,snapGrid:L,snapToGrid:j,containerBounds:c});if(s=O,a=Mp($,R,O,_),a.size>0&&(n||W||!_&&I)){const[T,H]=_r({nodeId:_,dragItems:a,nodeLookup:$});n?.(M.sourceEvent,a,T,H),W?.(M.sourceEvent,T,H),_||I?.(M.sourceEvent,H)}}const k=Xs().clickDistance(C).on("start",M=>{const{domNode:$,nodeDragThreshold:S,transform:R,snapGrid:A,snapToGrid:L}=t();c=$?.getBoundingClientRect()||null,h=!1,m=!1,g=M.sourceEvent,S===0&&P(M),s=ct(M.sourceEvent,{transform:R,snapGrid:A,snapToGrid:L,containerBounds:c}),u=me(M.sourceEvent,c)}).on("drag",M=>{const{autoPanOnNodeDrag:$,transform:S,snapGrid:R,snapToGrid:A,nodeDragThreshold:L,nodeLookup:j}=t(),V=ct(M.sourceEvent,{transform:S,snapGrid:R,snapToGrid:A,containerBounds:c});if(g=M.sourceEvent,(M.sourceEvent.type==="touchmove"&&M.sourceEvent.touches.length>1||_&&!j.has(_))&&(h=!0),!h){if(!d&&$&&l&&(d=!0,N()),!l){const W=me(M.sourceEvent,c),I=W.x-u.x,B=W.y-u.y;Math.sqrt(I*I+B*B)>L&&P(M)}(s.x!==V.xSnapped||s.y!==V.ySnapped)&&a&&l&&(u=me(M.sourceEvent,c),v(V))}}).on("end",M=>{if(!(!l||h)&&(d=!1,l=!1,cancelAnimationFrame(i),a.size>0)){const{nodeLookup:$,updateNodePositions:S,onNodeDragStop:R,onSelectionDragStop:A}=t();if(m&&(S(a,!1),m=!1),o||R||!_&&A){const[L,j]=_r({nodeId:_,dragItems:a,nodeLookup:$,dragging:!1});o?.(M.sourceEvent,a,L,j),R?.(M.sourceEvent,L,j),_||A?.(M.sourceEvent,j)}}}).filter(M=>{const $=M.target;return!M.button&&(!b||!Yi($,`.${b}`,x))&&(!p||Yi($,p,x))});f.call(k)}function w(){f?.on(".drag",null)}return{update:y,destroy:w}}function Rp(e,t,n){const r=[],o={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const s of t.values())gt(o,Ze(s))>0&&r.push(s);return r}const Pp=250;function Tp(e,t,n,r){let o=[],s=1/0;const i=Rp(e,n,t+Pp);for(const a of i){const d=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const u of d){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:c,y:l}=yt(a,u,u.position,!0),f=Math.sqrt(Math.pow(c-e.x,2)+Math.pow(l-e.y,2));f>t||(f<s?(o=[{...u,x:c,y:l}],s=f):f===s&&o.push({...u,x:c,y:l}))}}if(!o.length)return null;if(o.length>1){const a=r.type==="source"?"target":"source";return o.find(d=>d.type===a)??o[0]}return o[0]}function Ta(e,t,n,r,o,s=!1){const i=r.get(e);if(!i)return null;const a=o==="strict"?i.internals.handleBounds?.[t]:[...i.internals.handleBounds?.source??[],...i.internals.handleBounds?.target??[]],d=(n?a?.find(u=>u.id===n):a?.[0])??null;return d&&s?{...d,...yt(i,d,d.position,!0)}:d}function Aa(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Ap(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Da=()=>!0;function Dp(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:o,edgeUpdaterType:s,isTarget:i,domNode:a,nodeLookup:d,lib:u,autoPanOnConnect:c,flowId:l,panBy:f,cancelConnection:h,onConnectStart:m,onConnect:g,onConnectEnd:y,isValidConnection:w=Da,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:E,autoPanSpeed:_,dragThreshold:C=1,handleDomNode:v}){const N=_a(e.target);let P=0,k;const{x:M,y:$}=me(e),S=Aa(s,v),R=a?.getBoundingClientRect();let A=!1;if(!R||!S)return;const L=Ta(o,S,r,d,t);if(!L)return;let j=me(e,R),V=!1,W=null,I=!1,B=null;function O(){if(!c||!R)return;const[Q,X]=ya(j,R,_);f({x:Q,y:X}),P=requestAnimationFrame(O)}const T={...L,nodeId:o,type:S,position:L.position},H=d.get(o);let F={inProgress:!0,isValid:null,from:yt(H,T,K.Left,!0),fromHandle:T,fromPosition:T.position,fromNode:H,to:j,toHandle:null,toPosition:Ti[T.position],toNode:null};function q(){A=!0,p(F),m?.(e,{nodeId:o,handleId:r,handleType:S})}C===0&&q();function G(Q){if(!A){const{x:te,y:ne}=me(Q),ae=te-M,_e=ne-$;if(!(ae*ae+_e*_e>C*C))return;q()}if(!E()||!T){U(Q);return}const X=x();j=me(Q,R),k=Tp(Ct(j,X,!1,[1,1]),n,d,T),V||(O(),V=!0);const Z=La(Q,{handle:k,connectionMode:t,fromNodeId:o,fromHandleId:r,fromType:i?"target":"source",isValidConnection:w,doc:N,lib:u,flowId:l,nodeLookup:d});B=Z.handleDomNode,W=Z.connection,I=Ap(!!k,Z.isValid);const J={...F,isValid:I,to:Z.toHandle&&I?on({x:Z.toHandle.x,y:Z.toHandle.y},X):j,toHandle:Z.toHandle,toPosition:I&&Z.toHandle?Z.toHandle.position:Ti[T.position],toNode:Z.toHandle?d.get(Z.toHandle.nodeId):null};I&&k&&F.toHandle&&J.toHandle&&F.toHandle.type===J.toHandle.type&&F.toHandle.nodeId===J.toHandle.nodeId&&F.toHandle.id===J.toHandle.id&&F.to.x===J.to.x&&F.to.y===J.to.y||(p(J),F=J)}function U(Q){if(!("touches"in Q&&Q.touches.length>0)){if(A){(k||B)&&W&&I&&g?.(W);const{inProgress:X,...Z}=F,J={...Z,toPosition:F.toHandle?F.toPosition:null};y?.(Q,J),s&&b?.(Q,J)}h(),cancelAnimationFrame(P),V=!1,I=!1,W=null,B=null,N.removeEventListener("mousemove",G),N.removeEventListener("mouseup",U),N.removeEventListener("touchmove",G),N.removeEventListener("touchend",U)}}N.addEventListener("mousemove",G),N.addEventListener("mouseup",U),N.addEventListener("touchmove",G),N.addEventListener("touchend",U)}function La(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:o,fromType:s,doc:i,lib:a,flowId:d,isValidConnection:u=Da,nodeLookup:c}){const l=s==="target",f=t?i.querySelector(`.${a}-flow__handle[data-id="${d}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:m}=me(e),g=i.elementFromPoint(h,m),y=g?.classList.contains(`${a}-flow__handle`)?g:f,w={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const b=Aa(void 0,y),p=y.getAttribute("data-nodeid"),x=y.getAttribute("data-handleid"),E=y.classList.contains("connectable"),_=y.classList.contains("connectableend");if(!p||!b)return w;const C={source:l?p:r,sourceHandle:l?x:o,target:l?r:p,targetHandle:l?o:x};w.connection=C;const N=E&&_&&(n===Ge.Strict?l&&b==="source"||!l&&b==="target":p!==r||x!==o);w.isValid=N&&u(C),w.toHandle=Ta(p,b,x,c,n,!0)}return w}const qr={onPointerDown:Dp,isValid:La};function Lp({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const o=ue(e);function s({translateExtent:a,width:d,height:u,zoomStep:c=1,pannable:l=!0,zoomable:f=!0,inversePan:h=!1}){const m=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const x=n(),E=p.sourceEvent.ctrlKey&&mt()?10:1,_=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*c,C=x[2]*Math.pow(2,_*E);t.scaleTo(C)};let g=[0,0];const y=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(g=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},w=p=>{const x=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const E=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],_=[E[0]-g[0],E[1]-g[1]];g=E;const C=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),v={x:x[0]-_[0]*C,y:x[1]-_[1]*C},N=[[0,0],[d,u]];t.setViewportConstrained({x:v.x,y:v.y,zoom:x[2]},N,a)},b=la().on("start",y).on("zoom",l?w:null).on("zoom.wheel",f?m:null);o.call(b,{})}function i(){o.on("zoom",null)}return{update:s,destroy:i,pointer:he}}const yn=e=>({x:e.x,y:e.y,zoom:e.k}),Er=({x:e,y:t,zoom:n})=>pn.translate(e,t).scale(n),Ve=(e,t)=>e.target.closest(`.${t}`),$a=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),$p=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Sr=(e,t=0,n=$p,r=()=>{})=>{const o=typeof t=="number"&&t>0;return o||r(),o?e.transition().duration(t).ease(n).on("end",r):e},ja=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function jp({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:o,panOnScrollSpeed:s,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:d,onPanZoomEnd:u}){return c=>{if(Ve(c,t))return c.ctrlKey&&c.preventDefault(),!1;c.preventDefault(),c.stopImmediatePropagation();const l=n.property("__zoom").k||1;if(c.ctrlKey&&i){const y=he(c),w=ja(c),b=l*Math.pow(2,w);r.scaleTo(n,b,y,c);return}const f=c.deltaMode===1?20:1;let h=o===De.Vertical?0:c.deltaX*f,m=o===De.Horizontal?0:c.deltaY*f;!mt()&&c.shiftKey&&o!==De.Vertical&&(h=c.deltaY*f,m=0),r.translateBy(n,-(h/l)*s,-(m/l)*s,{internal:!0});const g=yn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d?.(c,g),e.panScrollTimeout=setTimeout(()=>{u?.(c,g),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(c,g))}}function zp({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,o){const s=r.type==="wheel",i=!t&&s&&!r.ctrlKey,a=Ve(r,e);if(r.ctrlKey&&s&&a&&r.preventDefault(),i||a)return null;r.preventDefault(),n.call(this,r,o)}}function Hp({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;const o=yn(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=o,r.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(r.sourceEvent,o)}}function Vp({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:o}){return s=>{e.usedRightMouseButton=!!(n&&$a(t,e.mouseButton??0)),s.sourceEvent?.sync||r([s.transform.x,s.transform.y,s.transform.k]),o&&!s.sourceEvent?.internal&&o?.(s.sourceEvent,yn(s.transform))}}function Bp({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:o,onPaneContextMenu:s}){return i=>{if(!i.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,s&&$a(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&s(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),o)){const a=yn(i.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o?.(i.sourceEvent,a)},n?150:0)}}}function Fp({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:o,zoomOnDoubleClick:s,userSelectionActive:i,noWheelClassName:a,noPanClassName:d,lib:u,connectionInProgress:c}){return l=>{const f=e||t,h=n&&l.ctrlKey,m=l.type==="wheel";if(l.button===1&&l.type==="mousedown"&&(Ve(l,`${u}-flow__node`)||Ve(l,`${u}-flow__edge`)))return!0;if(!r&&!f&&!o&&!s&&!n||i||c&&!m||Ve(l,a)&&m||Ve(l,d)&&(!m||o&&m&&!e)||!n&&l.ctrlKey&&m)return!1;if(!n&&l.type==="touchstart"&&l.touches?.length>1)return l.preventDefault(),!1;if(!f&&!o&&!h&&m||!r&&(l.type==="mousedown"||l.type==="touchstart")||Array.isArray(r)&&!r.includes(l.button)&&l.type==="mousedown")return!1;const g=Array.isArray(r)&&r.includes(l.button)||!l.button||l.button<=1;return(!l.ctrlKey||m)&&g}}function qp({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:o,onPanZoom:s,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:d}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},c=e.getBoundingClientRect(),l=la().scaleExtent([t,n]).translateExtent(r),f=ue(e).call(l);b({x:o.x,y:o.y,zoom:Xe(o.zoom,t,n)},[[0,0],[c.width,c.height]],r);const h=f.on("wheel.zoom"),m=f.on("dblclick.zoom");l.wheelDelta(ja);function g(k,M){return f?new Promise($=>{l?.interpolate(M?.interpolate==="linear"?at:Ft).transform(Sr(f,M?.duration,M?.ease,()=>$(!0)),k)}):Promise.resolve(!1)}function y({noWheelClassName:k,noPanClassName:M,onPaneContextMenu:$,userSelectionActive:S,panOnScroll:R,panOnDrag:A,panOnScrollMode:L,panOnScrollSpeed:j,preventScrolling:V,zoomOnPinch:W,zoomOnScroll:I,zoomOnDoubleClick:B,zoomActivationKeyPressed:O,lib:T,onTransformChange:H,connectionInProgress:Y,paneClickDistance:F,selectionOnDrag:q}){S&&!u.isZoomingOrPanning&&w();const G=R&&!O&&!S;l.clickDistance(q?1/0:!ge(F)||F<0?0:F);const U=G?jp({zoomPanValues:u,noWheelClassName:k,d3Selection:f,d3Zoom:l,panOnScrollMode:L,panOnScrollSpeed:j,zoomOnPinch:W,onPanZoomStart:i,onPanZoom:s,onPanZoomEnd:a}):zp({noWheelClassName:k,preventScrolling:V,d3ZoomHandler:h});if(f.on("wheel.zoom",U,{passive:!1}),!S){const X=Hp({zoomPanValues:u,onDraggingChange:d,onPanZoomStart:i});l.on("start",X);const Z=Vp({zoomPanValues:u,panOnDrag:A,onPaneContextMenu:!!$,onPanZoom:s,onTransformChange:H});l.on("zoom",Z);const J=Bp({zoomPanValues:u,panOnDrag:A,panOnScroll:R,onPaneContextMenu:$,onPanZoomEnd:a,onDraggingChange:d});l.on("end",J)}const Q=Fp({zoomActivationKeyPressed:O,panOnDrag:A,zoomOnScroll:I,panOnScroll:R,zoomOnDoubleClick:B,zoomOnPinch:W,userSelectionActive:S,noPanClassName:M,noWheelClassName:k,lib:T,connectionInProgress:Y});l.filter(Q),B?f.on("dblclick.zoom",m):f.on("dblclick.zoom",null)}function w(){l.on("zoom",null)}async function b(k,M,$){const S=Er(k),R=l?.constrain()(S,M,$);return R&&await g(R),new Promise(A=>A(R))}async function p(k,M){const $=Er(k);return await g($,M),new Promise(S=>S($))}function x(k){if(f){const M=Er(k),$=f.property("__zoom");($.k!==k.zoom||$.x!==k.x||$.y!==k.y)&&l?.transform(f,M,null,{sync:!0})}}function E(){const k=f?ca(f.node()):{x:0,y:0,k:1};return{x:k.x,y:k.y,zoom:k.k}}function _(k,M){return f?new Promise($=>{l?.interpolate(M?.interpolate==="linear"?at:Ft).scaleTo(Sr(f,M?.duration,M?.ease,()=>$(!0)),k)}):Promise.resolve(!1)}function C(k,M){return f?new Promise($=>{l?.interpolate(M?.interpolate==="linear"?at:Ft).scaleBy(Sr(f,M?.duration,M?.ease,()=>$(!0)),k)}):Promise.resolve(!1)}function v(k){l?.scaleExtent(k)}function N(k){l?.translateExtent(k)}function P(k){const M=!ge(k)||k<0?0:k;l?.clickDistance(M)}return{update:y,destroy:w,setViewport:p,setViewportConstrained:b,getViewport:E,scaleTo:_,scaleBy:C,setScaleExtent:v,setTranslateExtent:N,syncViewport:x,setClickDistance:P}}var Ue;(function(e){e.Line="line",e.Handle="handle"})(Ue||(Ue={}));function Yp({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:o,affectsY:s}){const i=e-t,a=n-r,d=[i>0?1:i<0?-1:0,a>0?1:a<0?-1:0];return i&&o&&(d[0]=d[0]*-1),a&&s&&(d[1]=d[1]*-1),d}function Wi(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),o=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:o}}function ke(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function $t(e,t,n){return Math.max(0,t-e,e-n)}function Gi(e,t){return e?!t:t}function Wp(e,t,n,r,o,s,i,a){let{affectsX:d,affectsY:u}=t;const{isHorizontal:c,isVertical:l}=t,f=c&&l,{xSnapped:h,ySnapped:m}=n,{minWidth:g,maxWidth:y,minHeight:w,maxHeight:b}=r,{x:p,y:x,width:E,height:_,aspectRatio:C}=e;let v=Math.floor(c?h-e.pointerX:0),N=Math.floor(l?m-e.pointerY:0);const P=E+(d?-v:v),k=_+(u?-N:N),M=-s[0]*E,$=-s[1]*_;let S=$t(P,g,y),R=$t(k,w,b);if(i){let j=0,V=0;d&&v<0?j=ke(p+v+M,i[0][0]):!d&&v>0&&(j=Me(p+P+M,i[1][0])),u&&N<0?V=ke(x+N+$,i[0][1]):!u&&N>0&&(V=Me(x+k+$,i[1][1])),S=Math.max(S,j),R=Math.max(R,V)}if(a){let j=0,V=0;d&&v>0?j=Me(p+v,a[0][0]):!d&&v<0&&(j=ke(p+P,a[1][0])),u&&N>0?V=Me(x+N,a[0][1]):!u&&N<0&&(V=ke(x+k,a[1][1])),S=Math.max(S,j),R=Math.max(R,V)}if(o){if(c){const j=$t(P/C,w,b)*C;if(S=Math.max(S,j),i){let V=0;!d&&!u||d&&!u&&f?V=Me(x+$+P/C,i[1][1])*C:V=ke(x+$+(d?v:-v)/C,i[0][1])*C,S=Math.max(S,V)}if(a){let V=0;!d&&!u||d&&!u&&f?V=ke(x+P/C,a[1][1])*C:V=Me(x+(d?v:-v)/C,a[0][1])*C,S=Math.max(S,V)}}if(l){const j=$t(k*C,g,y)/C;if(R=Math.max(R,j),i){let V=0;!d&&!u||u&&!d&&f?V=Me(p+k*C+M,i[1][0])/C:V=ke(p+(u?N:-N)*C+M,i[0][0])/C,R=Math.max(R,V)}if(a){let V=0;!d&&!u||u&&!d&&f?V=ke(p+k*C,a[1][0])/C:V=Me(p+(u?N:-N)*C,a[0][0])/C,R=Math.max(R,V)}}}N=N+(N<0?R:-R),v=v+(v<0?S:-S),o&&(f?P>k*C?N=(Gi(d,u)?-v:v)/C:v=(Gi(d,u)?-N:N)*C:c?(N=v/C,u=d):(v=N*C,d=u));const A=d?p+v:p,L=u?x+N:x;return{width:E+(d?-v:v),height:_+(u?-N:N),x:s[0]*v*(d?-1:1)+A,y:s[1]*N*(u?-1:1)+L}}const za={width:0,height:0,x:0,y:0},Gp={...za,pointerX:0,pointerY:0,aspectRatio:1};function Xp(e){return[[0,0],[e.measured.width,e.measured.height]]}function Zp(e,t,n){const r=t.position.x+e.position.x,o=t.position.y+e.position.y,s=e.measured.width??0,i=e.measured.height??0,a=n[0]*s,d=n[1]*i;return[[r-a,o-d],[r+s-a,o+i-d]]}function Kp({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:o}){const s=ue(e);let i={controlDirection:Wi("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:c,keepAspectRatio:l,resizeDirection:f,onResizeStart:h,onResize:m,onResizeEnd:g,shouldResize:y}){let w={...za},b={...Gp};i={boundaries:c,resizeDirection:f,keepAspectRatio:l,controlDirection:Wi(u)};let p,x=null,E=[],_,C,v,N=!1;const P=Xs().on("start",k=>{const{nodeLookup:M,transform:$,snapGrid:S,snapToGrid:R,nodeOrigin:A,paneDomNode:L}=n();if(p=M.get(t),!p)return;x=L?.getBoundingClientRect()??null;const{xSnapped:j,ySnapped:V}=ct(k.sourceEvent,{transform:$,snapGrid:S,snapToGrid:R,containerBounds:x});w={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...w,pointerX:j,pointerY:V,aspectRatio:w.width/w.height},_=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(_=M.get(p.parentId),C=_&&p.extent==="parent"?Xp(_):void 0),E=[],v=void 0;for(const[W,I]of M)if(I.parentId===t&&(E.push({id:W,position:{...I.position},extent:I.extent}),I.extent==="parent"||I.expandParent)){const B=Zp(I,p,I.origin??A);v?v=[[Math.min(B[0][0],v[0][0]),Math.min(B[0][1],v[0][1])],[Math.max(B[1][0],v[1][0]),Math.max(B[1][1],v[1][1])]]:v=B}h?.(k,{...w})}).on("drag",k=>{const{transform:M,snapGrid:$,snapToGrid:S,nodeOrigin:R}=n(),A=ct(k.sourceEvent,{transform:M,snapGrid:$,snapToGrid:S,containerBounds:x}),L=[];if(!p)return;const{x:j,y:V,width:W,height:I}=w,B={},O=p.origin??R,{width:T,height:H,x:Y,y:F}=Wp(b,i.controlDirection,A,i.boundaries,i.keepAspectRatio,O,C,v),q=T!==W,G=H!==I,U=Y!==j&&q,Q=F!==V&&G;if(!U&&!Q&&!q&&!G)return;if((U||Q||O[0]===1||O[1]===1)&&(B.x=U?Y:w.x,B.y=Q?F:w.y,w.x=B.x,w.y=B.y,E.length>0)){const te=Y-j,ne=F-V;for(const ae of E)ae.position={x:ae.position.x-te+O[0]*(T-W),y:ae.position.y-ne+O[1]*(H-I)},L.push(ae)}if((q||G)&&(B.width=q&&(!i.resizeDirection||i.resizeDirection==="horizontal")?T:w.width,B.height=G&&(!i.resizeDirection||i.resizeDirection==="vertical")?H:w.height,w.width=B.width,w.height=B.height),_&&p.expandParent){const te=O[0]*(B.width??0);B.x&&B.x<te&&(w.x=te,b.x=b.x-(B.x-te));const ne=O[1]*(B.height??0);B.y&&B.y<ne&&(w.y=ne,b.y=b.y-(B.y-ne))}const X=Yp({width:w.width,prevWidth:W,height:w.height,prevHeight:I,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),Z={...w,direction:X};y?.(k,Z)!==!1&&(N=!0,m?.(k,Z),r(B,L))}).on("end",k=>{N&&(g?.(k,{...w}),o?.({...w}),N=!1)});s.call(P)}function d(){s.on(".drag",null)}return{update:a,destroy:d}}var jt={exports:{}},Nr={},zt={exports:{}},Cr={};var Xi;function Up(){if(Xi)return Cr;Xi=1;var e=z;function t(l,f){return l===f&&(l!==0||1/l===1/f)||l!==l&&f!==f}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,o=e.useEffect,s=e.useLayoutEffect,i=e.useDebugValue;function a(l,f){var h=f(),m=r({inst:{value:h,getSnapshot:f}}),g=m[0].inst,y=m[1];return s(function(){g.value=h,g.getSnapshot=f,d(g)&&y({inst:g})},[l,h,f]),o(function(){return d(g)&&y({inst:g}),l(function(){d(g)&&y({inst:g})})},[l]),i(h),h}function d(l){var f=l.getSnapshot;l=l.value;try{var h=f();return!n(l,h)}catch{return!0}}function u(l,f){return f()}var c=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?u:a;return Cr.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:c,Cr}var kr={};var Zi;function Qp(){return Zi||(Zi=1,process.env.NODE_ENV!=="production"&&(function(){function e(h,m){return h===m&&(h!==0||1/h===1/m)||h!==h&&m!==m}function t(h,m){c||o.startTransition===void 0||(c=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var g=m();if(!l){var y=m();s(g,y)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}y=i({inst:{value:g,getSnapshot:m}});var w=y[0].inst,b=y[1];return d(function(){w.value=g,w.getSnapshot=m,n(w)&&b({inst:w})},[h,g,m]),a(function(){return n(w)&&b({inst:w}),h(function(){n(w)&&b({inst:w})})},[h]),u(g),g}function n(h){var m=h.getSnapshot;h=h.value;try{var g=m();return!s(h,g)}catch{return!0}}function r(h,m){return m()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var o=z,s=typeof Object.is=="function"?Object.is:e,i=o.useState,a=o.useEffect,d=o.useLayoutEffect,u=o.useDebugValue,c=!1,l=!1,f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?r:t;kr.useSyncExternalStore=o.useSyncExternalStore!==void 0?o.useSyncExternalStore:f,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),kr}var Ki;function Ha(){return Ki||(Ki=1,process.env.NODE_ENV==="production"?zt.exports=Up():zt.exports=Qp()),zt.exports}var Ui;function Jp(){if(Ui)return Nr;Ui=1;var e=z,t=Ha();function n(u,c){return u===c&&(u!==0||1/u===1/c)||u!==u&&c!==c}var r=typeof Object.is=="function"?Object.is:n,o=t.useSyncExternalStore,s=e.useRef,i=e.useEffect,a=e.useMemo,d=e.useDebugValue;return Nr.useSyncExternalStoreWithSelector=function(u,c,l,f,h){var m=s(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=a(function(){function w(_){if(!b){if(b=!0,p=_,_=f(_),h!==void 0&&g.hasValue){var C=g.value;if(h(C,_))return x=C}return x=_}if(C=x,r(p,_))return C;var v=f(_);return h!==void 0&&h(C,v)?(p=_,C):(p=_,x=v)}var b=!1,p,x,E=l===void 0?null:l;return[function(){return w(c())},E===null?void 0:function(){return w(E())}]},[c,l,f,h]);var y=o(u,m[0],m[1]);return i(function(){g.hasValue=!0,g.value=y},[y]),d(y),y},Nr}var Mr={};var Qi;function eg(){return Qi||(Qi=1,process.env.NODE_ENV!=="production"&&(function(){function e(u,c){return u===c&&(u!==0||1/u===1/c)||u!==u&&c!==c}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=z,n=Ha(),r=typeof Object.is=="function"?Object.is:e,o=n.useSyncExternalStore,s=t.useRef,i=t.useEffect,a=t.useMemo,d=t.useDebugValue;Mr.useSyncExternalStoreWithSelector=function(u,c,l,f,h){var m=s(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=a(function(){function w(_){if(!b){if(b=!0,p=_,_=f(_),h!==void 0&&g.hasValue){var C=g.value;if(h(C,_))return x=C}return x=_}if(C=x,r(p,_))return C;var v=f(_);return h!==void 0&&h(C,v)?(p=_,C):(p=_,x=v)}var b=!1,p,x,E=l===void 0?null:l;return[function(){return w(c())},E===null?void 0:function(){return w(E())}]},[c,l,f,h]);var y=o(u,m[0],m[1]);return i(function(){g.hasValue=!0,g.value=y},[y]),d(y),y},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Mr}var Ji;function tg(){return Ji||(Ji=1,process.env.NODE_ENV==="production"?jt.exports=Jp():jt.exports=eg()),jt.exports}var ng=tg();const rg=ks(ng),og={},es=e=>{let t;const n=new Set,r=(c,l)=>{const f=typeof c=="function"?c(t):c;if(!Object.is(f,t)){const h=t;t=l??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(m=>m(t,h))}},o=()=>t,d={setState:r,getState:o,getInitialState:()=>u,subscribe:c=>(n.add(c),()=>n.delete(c)),destroy:()=>{(og?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,o,d);return d},ig=e=>e?es(e):es,{useDebugValue:sg}=z,{useSyncExternalStoreWithSelector:ag}=rg,cg=e=>e;function Va(e,t=cg,n){const r=ag(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return sg(r),r}const ts=(e,t)=>{const n=ig(e),r=(o,s=t)=>Va(n,o,s);return Object.assign(r,n),r},lg=(e,t)=>e?ts(e,t):ts;function re(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,o]of e)if(!Object.is(o,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const wn=z.createContext(null),ug=wn.Provider,Ba=fe.error001();function ee(e,t){const n=z.useContext(wn);if(n===null)throw new Error(Ba);return Va(n,e,t)}function oe(){const e=z.useContext(wn);if(e===null)throw new Error(Ba);return z.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const ns={display:"none"},dg={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Fa="react-flow__node-desc",qa="react-flow__edge-desc",fg="react-flow__aria-live",hg=e=>e.ariaLiveMessage,pg=e=>e.ariaLabelConfig;function gg({rfId:e}){const t=ee(hg);return D.jsx("div",{id:`${fg}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:dg,children:t})}function mg({rfId:e,disableKeyboardA11y:t}){const n=ee(pg);return D.jsxs(D.Fragment,{children:[D.jsx("div",{id:`${Fa}-${e}`,style:ns,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),D.jsx("div",{id:`${qa}-${e}`,style:ns,children:n["edge.a11yDescription.default"]}),!t&&D.jsx(gg,{rfId:e})]})}const xn=z.forwardRef(({position:e="top-left",children:t,className:n,style:r,...o},s)=>{const i=`${e}`.split("-");return D.jsx("div",{className:se(["react-flow__panel",n,...i]),style:r,ref:s,...o,children:t})});xn.displayName="Panel";function yg({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:D.jsx(xn,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:D.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const wg=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Ht=e=>e.id;function xg(e,t){return re(e.selectedNodes.map(Ht),t.selectedNodes.map(Ht))&&re(e.selectedEdges.map(Ht),t.selectedEdges.map(Ht))}function bg({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:r}=ee(wg,xg);return z.useEffect(()=>{const o={nodes:n,edges:r};e?.(o),t.getState().onSelectionChangeHandlers.forEach(s=>s(o))},[n,r,e]),null}const vg=e=>!!e.onSelectionChangeHandlers;function _g({onSelectionChange:e}){const t=ee(vg);return e||t?D.jsx(bg,{onSelectionChange:e}):null}const Ya=[0,0],Eg={x:0,y:0,zoom:1},Sg=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig"],rs=[...Sg,"rfId"],Ng=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),os={translateExtent:ht,nodeOrigin:Ya,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Cg(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:o,setTranslateExtent:s,setNodeExtent:i,reset:a,setDefaultNodesAndEdges:d}=ee(Ng,re),u=oe();z.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{c.current=os,a()}),[]);const c=z.useRef(os);return z.useEffect(()=>{for(const l of rs){const f=e[l],h=c.current[l];f!==h&&(typeof e[l]>"u"||(l==="nodes"?t(f):l==="edges"?n(f):l==="minZoom"?r(f):l==="maxZoom"?o(f):l==="translateExtent"?s(f):l==="nodeExtent"?i(f):l==="ariaLabelConfig"?u.setState({ariaLabelConfig:cp(f)}):l==="fitView"?u.setState({fitViewQueued:f}):l==="fitViewOptions"?u.setState({fitViewOptions:f}):u.setState({[l]:f})))}c.current=e},rs.map(l=>e[l])),null}function is(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function kg(e){const[t,n]=z.useState(e==="system"?null:e);return z.useEffect(()=>{if(e!=="system"){n(e);return}const r=is(),o=()=>n(r?.matches?"dark":"light");return o(),r?.addEventListener("change",o),()=>{r?.removeEventListener("change",o)}},[e]),t!==null?t:is()?.matches?"dark":"light"}const ss=typeof document<"u"?document:null;function wt(e=null,t={target:ss,actInsideInputWithModifier:!0}){const[n,r]=z.useState(!1),o=z.useRef(!1),s=z.useRef(new Set([])),[i,a]=z.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(l=>typeof l=="string").map(l=>l.replace("+",`
|
|
7
|
-
`).replace(`
|
|
8
|
-
|
|
9
|
-
`,`
|
|
10
|
-
+`).split(`
|
|
11
|
-
`)),c=u.reduce((l,f)=>l.concat(...f),[]);return[u,c]}return[[],[]]},[e]);return z.useEffect(()=>{const d=t?.target??ss,u=t?.actInsideInputWithModifier??!0;if(e!==null){const c=h=>{if(o.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!o.current||o.current&&!u)&&Ea(h))return!1;const g=cs(h.code,a);if(s.current.add(h[g]),as(i,s.current,!1)){const y=h.composedPath?.()?.[0]||h.target,w=y?.nodeName==="BUTTON"||y?.nodeName==="A";t.preventDefault!==!1&&(o.current||!w)&&h.preventDefault(),r(!0)}},l=h=>{const m=cs(h.code,a);as(i,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(h[m]),h.key==="Meta"&&s.current.clear(),o.current=!1},f=()=>{s.current.clear(),r(!1)};return d?.addEventListener("keydown",c),d?.addEventListener("keyup",l),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{d?.removeEventListener("keydown",c),d?.removeEventListener("keyup",l),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function as(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function cs(e,t){return t.includes(e)?"code":"key"}const Mg=()=>{const e=oe();return z.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,s],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??s},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:s,maxZoom:i,panZoom:a}=e.getState(),d=no(t,r,o,s,i,n?.padding??.1);return a?(await a.setViewport(d,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:s,domNode:i}=e.getState();if(!i)return t;const{x:a,y:d}=i.getBoundingClientRect(),u={x:t.x-a,y:t.y-d},c=n.snapGrid??o,l=n.snapToGrid??s;return Ct(u,r,l,c)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:s}=r.getBoundingClientRect(),i=on(t,n);return{x:i.x+o,y:i.y+s}}}),[])};function Wa(e,t){const n=[],r=new Map,o=[];for(const s of e)if(s.type==="add"){o.push(s);continue}else if(s.type==="remove"||s.type==="replace")r.set(s.id,[s]);else{const i=r.get(s.id);i?i.push(s):r.set(s.id,[s])}for(const s of t){const i=r.get(s.id);if(!i){n.push(s);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const a={...s};for(const d of i)Og(d,a);n.push(a)}return o.length&&o.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function Og(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured??={},t.measured.width=e.dimensions.width,t.measured.height=e.dimensions.height,e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Ga(e,t){return Wa(e,t)}function Xa(e,t){return Wa(e,t)}function Pe(e,t){return{id:e,type:"select",selected:t}}function Be(e,t=new Set,n=!1){const r=[];for(const[o,s]of e){const i=t.has(o);!(s.selected===void 0&&!i)&&s.selected!==i&&(n&&(s.selected=i),r.push(Pe(s.id,i)))}return r}function ls({items:e=[],lookup:t}){const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,s]of e.entries()){const i=t.get(s.id),a=i?.internals?.userNode??i;a!==void 0&&a!==s&&n.push({id:s.id,item:s,type:"replace"}),a===void 0&&n.push({item:s,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function us(e){return{id:e.id,type:"remove"}}const ds=e=>Jh(e),Ig=e=>pa(e);function Za(e){return z.forwardRef(e)}const Rg=typeof window<"u"?z.useLayoutEffect:z.useEffect;function fs(e){const[t,n]=z.useState(BigInt(0)),[r]=z.useState(()=>Pg(()=>n(o=>o+BigInt(1))));return Rg(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function Pg(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ka=z.createContext(null);function Tg({children:e}){const t=oe(),n=z.useCallback(a=>{const{nodes:d=[],setNodes:u,hasDefaultNodes:c,onNodesChange:l,nodeLookup:f,fitViewQueued:h}=t.getState();let m=d;for(const y of a)m=typeof y=="function"?y(m):y;const g=ls({items:m,lookup:f});c&&u(m),g.length>0?l?.(g):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:w,setNodes:b}=t.getState();y&&b(w)})},[]),r=fs(n),o=z.useCallback(a=>{const{edges:d=[],setEdges:u,hasDefaultEdges:c,onEdgesChange:l,edgeLookup:f}=t.getState();let h=d;for(const m of a)h=typeof m=="function"?m(h):m;c?u(h):l&&l(ls({items:h,lookup:f}))},[]),s=fs(o),i=z.useMemo(()=>({nodeQueue:r,edgeQueue:s}),[]);return D.jsx(Ka.Provider,{value:i,children:e})}function Ag(){const e=z.useContext(Ka);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Dg=e=>!!e.panZoom;function co(){const e=Mg(),t=oe(),n=Ag(),r=ee(Dg),o=z.useMemo(()=>{const s=l=>t.getState().nodeLookup.get(l),i=l=>{n.nodeQueue.push(l)},a=l=>{n.edgeQueue.push(l)},d=l=>{const{nodeLookup:f,nodeOrigin:h}=t.getState(),m=ds(l)?l:f.get(l.id),g=m.parentId?va(m.position,m.measured,m.parentId,f,h):m.position,y={...m,position:g,width:m.measured?.width??m.width,height:m.measured?.height??m.height};return Ze(y)},u=(l,f,h={replace:!1})=>{i(m=>m.map(g=>{if(g.id===l){const y=typeof f=="function"?f(g):f;return h.replace&&ds(y)?y:{...g,...y}}return g}))},c=(l,f,h={replace:!1})=>{a(m=>m.map(g=>{if(g.id===l){const y=typeof f=="function"?f(g):f;return h.replace&&Ig(y)?y:{...g,...y}}return g}))};return{getNodes:()=>t.getState().nodes.map(l=>({...l})),getNode:l=>s(l)?.internals.userNode,getInternalNode:s,getEdges:()=>{const{edges:l=[]}=t.getState();return l.map(f=>({...f}))},getEdge:l=>t.getState().edgeLookup.get(l),setNodes:i,setEdges:a,addNodes:l=>{const f=Array.isArray(l)?l:[l];n.nodeQueue.push(h=>[...h,...f])},addEdges:l=>{const f=Array.isArray(l)?l:[l];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:l=[],edges:f=[],transform:h}=t.getState(),[m,g,y]=h;return{nodes:l.map(w=>({...w})),edges:f.map(w=>({...w})),viewport:{x:m,y:g,zoom:y}}},deleteElements:async({nodes:l=[],edges:f=[]})=>{const{nodes:h,edges:m,onNodesDelete:g,onEdgesDelete:y,triggerNodeChanges:w,triggerEdgeChanges:b,onDelete:p,onBeforeDelete:x}=t.getState(),{nodes:E,edges:_}=await op({nodesToRemove:l,edgesToRemove:f,nodes:h,edges:m,onBeforeDelete:x}),C=_.length>0,v=E.length>0;if(C){const N=_.map(us);y?.(_),b(N)}if(v){const N=E.map(us);g?.(E),w(N)}return(v||C)&&p?.({nodes:E,edges:_}),{deletedNodes:E,deletedEdges:_}},getIntersectingNodes:(l,f=!0,h)=>{const m=Di(l),g=m?l:d(l),y=h!==void 0;return g?(h||t.getState().nodes).filter(w=>{const b=t.getState().nodeLookup.get(w.id);if(b&&!m&&(w.id===l.id||!b.internals.positionAbsolute))return!1;const p=Ze(y?w:b),x=gt(p,g);return f&&x>0||x>=p.width*p.height||x>=g.width*g.height}):[]},isNodeIntersecting:(l,f,h=!0)=>{const g=Di(l)?l:d(l);if(!g)return!1;const y=gt(g,f);return h&&y>0||y>=f.width*f.height||y>=g.width*g.height},updateNode:u,updateNodeData:(l,f,h={replace:!1})=>{u(l,m=>{const g=typeof f=="function"?f(m):f;return h.replace?{...m,data:g}:{...m,data:{...m.data,...g}}},h)},updateEdge:c,updateEdgeData:(l,f,h={replace:!1})=>{c(l,m=>{const g=typeof f=="function"?f(m):f;return h.replace?{...m,data:g}:{...m,data:{...m.data,...g}}},h)},getNodesBounds:l=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return ep(l,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:l,id:f,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}-${l}${f?`-${f}`:""}`)?.values()??[]),getNodeConnections:({type:l,handleId:f,nodeId:h})=>Array.from(t.getState().connectionLookup.get(`${h}${l?f?`-${l}-${f}`:`-${l}`:""}`)?.values()??[]),fitView:async l=>{const f=t.getState().fitViewResolver??ap();return t.setState({fitViewQueued:!0,fitViewOptions:l,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return z.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const hs=e=>e.selected,Lg=typeof window<"u"?window:void 0;function $g({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=oe(),{deleteElements:r}=co(),o=wt(e,{actInsideInputWithModifier:!1}),s=wt(t,{target:Lg});z.useEffect(()=>{if(o){const{edges:i,nodes:a}=n.getState();r({nodes:a.filter(hs),edges:i.filter(hs)}),n.setState({nodesSelectionActive:!1})}},[o]),z.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])}function jg(e){const t=oe();z.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const r=ro(e.current);(r.height===0||r.width===0)&&t.getState().onError?.("004",fe.error004()),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const bn={position:"absolute",width:"100%",height:"100%",top:0,left:0},zg=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Hg({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:o=.5,panOnScrollMode:s=De.Free,zoomOnDoubleClick:i=!0,panOnDrag:a=!0,defaultViewport:d,translateExtent:u,minZoom:c,maxZoom:l,zoomActivationKeyCode:f,preventScrolling:h=!0,children:m,noWheelClassName:g,noPanClassName:y,onViewportChange:w,isControlledViewport:b,paneClickDistance:p,selectionOnDrag:x}){const E=oe(),_=z.useRef(null),{userSelectionActive:C,lib:v,connectionInProgress:N}=ee(zg,re),P=wt(f),k=z.useRef();jg(_);const M=z.useCallback($=>{w?.({x:$[0],y:$[1],zoom:$[2]}),b||E.setState({transform:$})},[w,b]);return z.useEffect(()=>{if(_.current){k.current=qp({domNode:_.current,minZoom:c,maxZoom:l,translateExtent:u,viewport:d,onDraggingChange:A=>E.setState({paneDragging:A}),onPanZoomStart:(A,L)=>{const{onViewportChangeStart:j,onMoveStart:V}=E.getState();V?.(A,L),j?.(L)},onPanZoom:(A,L)=>{const{onViewportChange:j,onMove:V}=E.getState();V?.(A,L),j?.(L)},onPanZoomEnd:(A,L)=>{const{onViewportChangeEnd:j,onMoveEnd:V}=E.getState();V?.(A,L),j?.(L)}});const{x:$,y:S,zoom:R}=k.current.getViewport();return E.setState({panZoom:k.current,transform:[$,S,R],domNode:_.current.closest(".react-flow")}),()=>{k.current?.destroy()}}},[]),z.useEffect(()=>{k.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:o,panOnScrollMode:s,zoomOnDoubleClick:i,panOnDrag:a,zoomActivationKeyPressed:P,preventScrolling:h,noPanClassName:y,userSelectionActive:C,noWheelClassName:g,lib:v,onTransformChange:M,connectionInProgress:N,selectionOnDrag:x,paneClickDistance:p})},[e,t,n,r,o,s,i,a,P,h,y,C,g,v,M,N,x,p]),D.jsx("div",{className:"react-flow__renderer",ref:_,style:bn,children:m})}const Vg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Bg(){const{userSelectionActive:e,userSelectionRect:t}=ee(Vg,re);return e&&t?D.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const Or=(e,t)=>n=>{n.target===t.current&&e?.(n)},Fg=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function qg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=pt.Full,panOnDrag:r,paneClickDistance:o,selectionOnDrag:s,onSelectionStart:i,onSelectionEnd:a,onPaneClick:d,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:l,onPaneMouseMove:f,onPaneMouseLeave:h,children:m}){const g=oe(),{userSelectionActive:y,elementsSelectable:w,dragging:b,connectionInProgress:p}=ee(Fg,re),x=w&&(e||y),E=z.useRef(null),_=z.useRef(),C=z.useRef(new Set),v=z.useRef(new Set),N=z.useRef(!1),P=j=>{if(N.current||p){N.current=!1;return}d?.(j),g.getState().resetSelectedElements(),g.setState({nodesSelectionActive:!1})},k=j=>{if(Array.isArray(r)&&r?.includes(2)){j.preventDefault();return}u?.(j)},M=c?j=>c(j):void 0,$=j=>{N.current&&(j.stopPropagation(),N.current=!1)},S=j=>{const{domNode:V}=g.getState();if(_.current=V?.getBoundingClientRect(),!_.current)return;const W=j.target===E.current;if(!W&&!!j.target.closest(".nokey")||!e||!(s&&W||t)||j.button!==0||!j.isPrimary)return;j.target?.setPointerCapture?.(j.pointerId),N.current=!1;const{x:O,y:T}=me(j.nativeEvent,_.current);g.setState({userSelectionRect:{width:0,height:0,startX:O,startY:T,x:O,y:T}}),W||(j.stopPropagation(),j.preventDefault())},R=j=>{const{userSelectionRect:V,transform:W,nodeLookup:I,edgeLookup:B,connectionLookup:O,triggerNodeChanges:T,triggerEdgeChanges:H,defaultEdgeOptions:Y,resetSelectedElements:F}=g.getState();if(!_.current||!V)return;const{x:q,y:G}=me(j.nativeEvent,_.current),{startX:U,startY:Q}=V;if(!N.current){const ne=t?0:o;if(Math.hypot(q-U,G-Q)<=ne)return;F(),i?.(j)}N.current=!0;const X={startX:U,startY:Q,x:q<U?q:U,y:G<Q?G:Q,width:Math.abs(q-U),height:Math.abs(G-Q)},Z=C.current,J=v.current;C.current=new Set(to(I,X,W,n===pt.Partial,!0).map(ne=>ne.id)),v.current=new Set;const te=Y?.selectable??!0;for(const ne of C.current){const ae=O.get(ne);if(ae)for(const{edgeId:_e}of ae.values()){const Re=B.get(_e);Re&&(Re.selectable??te)&&v.current.add(_e)}}if(!Li(Z,C.current)){const ne=Be(I,C.current,!0);T(ne)}if(!Li(J,v.current)){const ne=Be(B,v.current);H(ne)}g.setState({userSelectionRect:X,userSelectionActive:!0,nodesSelectionActive:!1})},A=j=>{j.button===0&&(j.target?.releasePointerCapture?.(j.pointerId),!y&&j.target===E.current&&g.getState().userSelectionRect&&P?.(j),g.setState({userSelectionActive:!1,userSelectionRect:null}),N.current&&(a?.(j),g.setState({nodesSelectionActive:C.current.size>0})))},L=r===!0||Array.isArray(r)&&r.includes(0);return D.jsxs("div",{className:se(["react-flow__pane",{draggable:L,dragging:b,selection:e}]),onClick:x?void 0:Or(P,E),onContextMenu:Or(k,E),onWheel:Or(M,E),onPointerEnter:x?void 0:l,onPointerMove:x?R:f,onPointerUp:x?A:void 0,onPointerDownCapture:x?S:void 0,onClickCapture:x?$:void 0,onPointerLeave:h,ref:E,style:bn,children:[m,D.jsx(Bg,{})]})}function Yr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeLookup:a,onError:d}=t.getState(),u=a.get(e);if(!u){d?.("012",fe.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&i)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):o([e])}function Ua({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:s,nodeClickDistance:i}){const a=oe(),[d,u]=z.useState(!1),c=z.useRef();return z.useEffect(()=>{c.current=Ip({getStoreItems:()=>a.getState(),onNodeMouseDown:l=>{Yr({id:l,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),z.useEffect(()=>{if(t)c.current?.destroy();else if(e.current)return c.current?.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:s,nodeId:o,nodeClickDistance:i}),()=>{c.current?.destroy()}},[n,r,t,s,e,o]),d}const Yg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Qa(){const e=oe();return z.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:s,nodesDraggable:i,onError:a,updateNodePositions:d,nodeLookup:u,nodeOrigin:c}=e.getState(),l=new Map,f=Yg(i),h=o?s[0]:5,m=o?s[1]:5,g=n.direction.x*h*n.factor,y=n.direction.y*m*n.factor;for(const[,w]of u){if(!f(w))continue;let b={x:w.internals.positionAbsolute.x+g,y:w.internals.positionAbsolute.y+y};o&&(b=Nt(b,s));const{position:p,positionAbsolute:x}=ga({nodeId:w.id,nextPosition:b,nodeLookup:u,nodeExtent:r,nodeOrigin:c,onError:a});w.position=p,w.internals.positionAbsolute=x,l.set(w.id,w)}d(l)},[])}const lo=z.createContext(null),Wg=lo.Provider;lo.Consumer;const Ja=()=>z.useContext(lo),Gg=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Xg=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:s,connection:i}=r,{fromHandle:a,toHandle:d,isValid:u}=i,c=d?.nodeId===e&&d?.id===t&&d?.type===n;return{connectingFrom:a?.nodeId===e&&a?.id===t&&a?.type===n,connectingTo:c,clickConnecting:o?.nodeId===e&&o?.id===t&&o?.type===n,isPossibleEndHandle:s===Ge.Strict?a?.type!==n:e!==a?.nodeId||t!==a?.id,connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:c&&u}};function Zg({type:e="source",position:t=K.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:s=!0,id:i,onConnect:a,children:d,className:u,onMouseDown:c,onTouchStart:l,...f},h){const m=i||null,g=e==="target",y=oe(),w=Ja(),{connectOnClick:b,noPanClassName:p,rfId:x}=ee(Gg,re),{connectingFrom:E,connectingTo:_,clickConnecting:C,isPossibleEndHandle:v,connectionInProcess:N,clickConnectionInProcess:P,valid:k}=ee(Xg(w,m,e),re);w||y.getState().onError?.("010",fe.error010());const M=R=>{const{defaultEdgeOptions:A,onConnect:L,hasDefaultEdges:j}=y.getState(),V={...A,...R};if(j){const{edges:W,setEdges:I}=y.getState();I(pp(V,W))}L?.(V),a?.(V)},$=R=>{if(!w)return;const A=Sa(R.nativeEvent);if(o&&(A&&R.button===0||!A)){const L=y.getState();qr.onPointerDown(R.nativeEvent,{handleDomNode:R.currentTarget,autoPanOnConnect:L.autoPanOnConnect,connectionMode:L.connectionMode,connectionRadius:L.connectionRadius,domNode:L.domNode,nodeLookup:L.nodeLookup,lib:L.lib,isTarget:g,handleId:m,nodeId:w,flowId:L.rfId,panBy:L.panBy,cancelConnection:L.cancelConnection,onConnectStart:L.onConnectStart,onConnectEnd:L.onConnectEnd,updateConnection:L.updateConnection,onConnect:M,isValidConnection:n||L.isValidConnection,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,autoPanSpeed:L.autoPanSpeed,dragThreshold:L.connectionDragThreshold})}A?c?.(R):l?.(R)},S=R=>{const{onClickConnectStart:A,onClickConnectEnd:L,connectionClickStartHandle:j,connectionMode:V,isValidConnection:W,lib:I,rfId:B,nodeLookup:O,connection:T}=y.getState();if(!w||!j&&!o)return;if(!j){A?.(R.nativeEvent,{nodeId:w,handleId:m,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:w,type:e,id:m}});return}const H=_a(R.target),Y=n||W,{connection:F,isValid:q}=qr.isValid(R.nativeEvent,{handle:{nodeId:w,id:m,type:e},connectionMode:V,fromNodeId:j.nodeId,fromHandleId:j.id||null,fromType:j.type,isValidConnection:Y,flowId:B,doc:H,lib:I,nodeLookup:O});q&&F&&M(F);const G=structuredClone(T);delete G.inProgress,G.toPosition=G.toHandle?G.toHandle.position:null,L?.(R,G),y.setState({connectionClickStartHandle:null})};return D.jsx("div",{"data-handleid":m,"data-nodeid":w,"data-handlepos":t,"data-id":`${x}-${w}-${m}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,u,{source:!g,target:g,connectable:r,connectablestart:o,connectableend:s,clickconnecting:C,connectingfrom:E,connectingto:_,valid:k,connectionindicator:r&&(!N||v)&&(N||P?s:o)}]),onMouseDown:$,onTouchStart:$,onClick:b?S:void 0,ref:h,...f,children:d})}const xt=z.memo(Za(Zg));function Kg({data:e,isConnectable:t,sourcePosition:n=K.Bottom}){return D.jsxs(D.Fragment,{children:[e?.label,D.jsx(xt,{type:"source",position:n,isConnectable:t})]})}function Ug({data:e,isConnectable:t,targetPosition:n=K.Top,sourcePosition:r=K.Bottom}){return D.jsxs(D.Fragment,{children:[D.jsx(xt,{type:"target",position:n,isConnectable:t}),e?.label,D.jsx(xt,{type:"source",position:r,isConnectable:t})]})}function Qg(){return null}function Jg({data:e,isConnectable:t,targetPosition:n=K.Top}){return D.jsxs(D.Fragment,{children:[D.jsx(xt,{type:"target",position:n,isConnectable:t}),e?.label]})}const sn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},ps={input:Kg,default:Ug,output:Jg,group:Qg};function em(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const tm=e=>{const{width:t,height:n,x:r,y:o}=St(e.nodeLookup,{filter:s=>!!s.selected});return{width:ge(t)?t:null,height:ge(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function nm({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=oe(),{width:o,height:s,transformString:i,userSelectionActive:a}=ee(tm,re),d=Qa(),u=z.useRef(null);if(z.useEffect(()=>{n||u.current?.focus({preventScroll:!0})},[n]),Ua({nodeRef:u}),a||!o||!s)return null;const c=e?f=>{const h=r.getState().nodes.filter(m=>m.selected);e(f,h)}:void 0,l=f=>{Object.prototype.hasOwnProperty.call(sn,f.key)&&(f.preventDefault(),d({direction:sn[f.key],factor:f.shiftKey?4:1}))};return D.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:D.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:c,tabIndex:n?void 0:-1,onKeyDown:n?void 0:l,style:{width:o,height:s}})})}const gs=typeof window<"u"?window:void 0,rm=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function ec({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,paneClickDistance:a,deleteKeyCode:d,selectionKeyCode:u,selectionOnDrag:c,selectionMode:l,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:m,panActivationKeyCode:g,zoomActivationKeyCode:y,elementsSelectable:w,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:x,panOnScrollSpeed:E,panOnScrollMode:_,zoomOnDoubleClick:C,panOnDrag:v,defaultViewport:N,translateExtent:P,minZoom:k,maxZoom:M,preventScrolling:$,onSelectionContextMenu:S,noWheelClassName:R,noPanClassName:A,disableKeyboardA11y:L,onViewportChange:j,isControlledViewport:V}){const{nodesSelectionActive:W,userSelectionActive:I}=ee(rm),B=wt(u,{target:gs}),O=wt(g,{target:gs}),T=O||v,H=O||x,Y=c&&T!==!0,F=B||I||Y;return $g({deleteKeyCode:d,multiSelectionKeyCode:m}),D.jsx(Hg,{onPaneContextMenu:s,elementsSelectable:w,zoomOnScroll:b,zoomOnPinch:p,panOnScroll:H,panOnScrollSpeed:E,panOnScrollMode:_,zoomOnDoubleClick:C,panOnDrag:!B&&T,defaultViewport:N,translateExtent:P,minZoom:k,maxZoom:M,zoomActivationKeyCode:y,preventScrolling:$,noWheelClassName:R,noPanClassName:A,onViewportChange:j,isControlledViewport:V,paneClickDistance:a,selectionOnDrag:Y,children:D.jsxs(qg,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:T,isSelecting:!!F,selectionMode:l,selectionKeyPressed:B,paneClickDistance:a,selectionOnDrag:Y,children:[e,W&&D.jsx(nm,{onSelectionContextMenu:S,noPanClassName:A,disableKeyboardA11y:L})]})})}ec.displayName="FlowRenderer";const om=z.memo(ec),im=e=>t=>e?to(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function sm(e){return ee(z.useCallback(im(e),[e]),re)}const am=e=>e.updateNodeInternals;function cm(){const e=ee(am),[t]=z.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const s=o.target.getAttribute("data-id");r.set(s,{id:s,nodeElement:o.target,force:!0})}),e(r)}));return z.useEffect(()=>()=>{t?.disconnect()},[t]),t}function lm({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=oe(),s=z.useRef(null),i=z.useRef(null),a=z.useRef(e.sourcePosition),d=z.useRef(e.targetPosition),u=z.useRef(t),c=n&&!!e.internals.handleBounds;return z.useEffect(()=>{s.current&&!e.hidden&&(!c||i.current!==s.current)&&(i.current&&r?.unobserve(i.current),r?.observe(s.current),i.current=s.current)},[c,e.hidden]),z.useEffect(()=>()=>{i.current&&(r?.unobserve(i.current),i.current=null)},[]),z.useEffect(()=>{if(s.current){const l=u.current!==t,f=a.current!==e.sourcePosition,h=d.current!==e.targetPosition;(l||f||h)&&(u.current=t,a.current=e.sourcePosition,d.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function um({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:s,onDoubleClick:i,nodesDraggable:a,elementsSelectable:d,nodesConnectable:u,nodesFocusable:c,resizeObserver:l,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:m,rfId:g,nodeTypes:y,nodeClickDistance:w,onError:b}){const{node:p,internals:x,isParent:E}=ee(q=>{const G=q.nodeLookup.get(e),U=q.parentLookup.has(e);return{node:G,internals:G.internals,isParent:U}},re);let _=p.type||"default",C=y?.[_]||ps[_];C===void 0&&(b?.("003",fe.error003(_)),_="default",C=y?.default||ps.default);const v=!!(p.draggable||a&&typeof p.draggable>"u"),N=!!(p.selectable||d&&typeof p.selectable>"u"),P=!!(p.connectable||u&&typeof p.connectable>"u"),k=!!(p.focusable||c&&typeof p.focusable>"u"),M=oe(),$=ba(p),S=lm({node:p,nodeType:_,hasDimensions:$,resizeObserver:l}),R=Ua({nodeRef:S,disabled:p.hidden||!v,noDragClassName:f,handleSelector:p.dragHandle,nodeId:e,isSelectable:N,nodeClickDistance:w}),A=Qa();if(p.hidden)return null;const L=Ce(p),j=em(p),V=N||v||t||n||r||o,W=n?q=>n(q,{...x.userNode}):void 0,I=r?q=>r(q,{...x.userNode}):void 0,B=o?q=>o(q,{...x.userNode}):void 0,O=s?q=>s(q,{...x.userNode}):void 0,T=i?q=>i(q,{...x.userNode}):void 0,H=q=>{const{selectNodesOnDrag:G,nodeDragThreshold:U}=M.getState();N&&(!G||!v||U>0)&&Yr({id:e,store:M,nodeRef:S}),t&&t(q,{...x.userNode})},Y=q=>{if(!(Ea(q.nativeEvent)||m)){if(ua.includes(q.key)&&N){const G=q.key==="Escape";Yr({id:e,store:M,unselect:G,nodeRef:S})}else if(v&&p.selected&&Object.prototype.hasOwnProperty.call(sn,q.key)){q.preventDefault();const{ariaLabelConfig:G}=M.getState();M.setState({ariaLiveMessage:G["node.a11yDescription.ariaLiveMessage"]({direction:q.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),A({direction:sn[q.key],factor:q.shiftKey?4:1})}}},F=()=>{if(m||!S.current?.matches(":focus-visible"))return;const{transform:q,width:G,height:U,autoPanOnNodeFocus:Q,setCenter:X}=M.getState();if(!Q)return;to(new Map([[e,p]]),{x:0,y:0,width:G,height:U},q,!0).length>0||X(p.position.x+L.width/2,p.position.y+L.height/2,{zoom:q[2]})};return D.jsx("div",{className:se(["react-flow__node",`react-flow__node-${_}`,{[h]:v},p.className,{selected:p.selected,selectable:N,parent:E,draggable:v,dragging:R}]),ref:S,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:V?"all":"none",visibility:$?"visible":"hidden",...p.style,...j},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:W,onMouseMove:I,onMouseLeave:B,onContextMenu:O,onClick:H,onDoubleClick:T,onKeyDown:k?Y:void 0,tabIndex:k?0:void 0,onFocus:k?F:void 0,role:p.ariaRole??(k?"group":void 0),"aria-roledescription":"node","aria-describedby":m?void 0:`${Fa}-${g}`,"aria-label":p.ariaLabel,...p.domAttributes,children:D.jsx(Wg,{value:e,children:D.jsx(C,{id:e,data:p.data,type:_,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:p.selected??!1,selectable:N,draggable:v,deletable:p.deletable??!0,isConnectable:P,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:R,dragHandle:p.dragHandle,zIndex:x.z,parentId:p.parentId,...L})})})}var dm=z.memo(um);const fm=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function tc(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,onError:s}=ee(fm,re),i=sm(e.onlyRenderVisibleElements),a=cm();return D.jsx("div",{className:"react-flow__nodes",style:bn,children:i.map(d=>D.jsx(dm,{id:d,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,nodeClickDistance:e.nodeClickDistance,onError:s},d))})}tc.displayName="NodeRenderer";const hm=z.memo(tc);function pm(e){return ee(z.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const s=n.nodeLookup.get(o.source),i=n.nodeLookup.get(o.target);s&&i&&dp({sourceNode:s,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),re)}const gm=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return D.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},mm=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return D.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},ms={[nn.Arrow]:gm,[nn.ArrowClosed]:mm};function ym(e){const t=oe();return z.useMemo(()=>Object.prototype.hasOwnProperty.call(ms,e)?ms[e]:(t.getState().onError?.("009",fe.error009(e)),null),[e])}const wm=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const d=ym(t);return d?D.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:a,refX:"0",refY:"0",children:D.jsx(d,{color:n,strokeWidth:i})}):null},nc=({defaultColor:e,rfId:t})=>{const n=ee(s=>s.edges),r=ee(s=>s.defaultEdgeOptions),o=z.useMemo(()=>xp(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return o.length?D.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:D.jsx("defs",{children:o.map(s=>D.jsx(wm,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};nc.displayName="MarkerDefinitions";var xm=z.memo(nc);function rc({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:s,labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:d,className:u,...c}){const[l,f]=z.useState({x:1,y:0,width:0,height:0}),h=se(["react-flow__edge-textwrapper",u]),m=z.useRef(null);return z.useEffect(()=>{if(m.current){const g=m.current.getBBox();f({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),n?D.jsxs("g",{transform:`translate(${e-l.width/2} ${t-l.height/2})`,className:h,visibility:l.width?"visible":"hidden",...c,children:[o&&D.jsx("rect",{width:l.width+2*i[0],x:-i[0],y:-i[1],height:l.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:a,ry:a}),D.jsx("text",{className:"react-flow__edge-text",y:l.height/2,dy:"0.3em",ref:m,style:r,children:n}),d]}):null}rc.displayName="EdgeText";const bm=z.memo(rc);function vn({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:d,interactionWidth:u=20,...c}){return D.jsxs(D.Fragment,{children:[D.jsx("path",{...c,d:e,fill:"none",className:se(["react-flow__edge-path",c.className])}),u?D.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&ge(t)&&ge(n)?D.jsx(bm,{x:t,y:n,label:r,labelStyle:o,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:d}):null]})}function ys({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===K.Left||e===K.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function oc({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:o,targetPosition:s=K.Top}){const[i,a]=ys({pos:n,x1:e,y1:t,x2:r,y2:o}),[d,u]=ys({pos:s,x1:r,y1:o,x2:e,y2:t}),[c,l,f,h]=Na({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:a,targetControlX:d,targetControlY:u});return[`M${e},${t} C${i},${a} ${d},${u} ${r},${o}`,c,l,f,h]}function ic(e){return z.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,sourcePosition:i,targetPosition:a,label:d,labelStyle:u,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:m,markerEnd:g,markerStart:y,interactionWidth:w})=>{const[b,p,x]=oc({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:s,targetPosition:a}),E=e.isInternal?void 0:t;return D.jsx(vn,{id:E,path:b,labelX:p,labelY:x,label:d,labelStyle:u,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:m,markerEnd:g,markerStart:y,interactionWidth:w})})}const vm=ic({isInternal:!1}),sc=ic({isInternal:!0});vm.displayName="SimpleBezierEdge";sc.displayName="SimpleBezierEdgeInternal";function ac(e){return z.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,label:i,labelStyle:a,labelShowBg:d,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:l,style:f,sourcePosition:h=K.Bottom,targetPosition:m=K.Top,markerEnd:g,markerStart:y,pathOptions:w,interactionWidth:b})=>{const[p,x,E]=Vr({sourceX:n,sourceY:r,sourcePosition:h,targetX:o,targetY:s,targetPosition:m,borderRadius:w?.borderRadius,offset:w?.offset,stepPosition:w?.stepPosition}),_=e.isInternal?void 0:t;return D.jsx(vn,{id:_,path:p,labelX:x,labelY:E,label:i,labelStyle:a,labelShowBg:d,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:l,style:f,markerEnd:g,markerStart:y,interactionWidth:b})})}const cc=ac({isInternal:!1}),lc=ac({isInternal:!0});cc.displayName="SmoothStepEdge";lc.displayName="SmoothStepEdgeInternal";function uc(e){return z.memo(({id:t,...n})=>{const r=e.isInternal?void 0:t;return D.jsx(cc,{...n,id:r,pathOptions:z.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const _m=uc({isInternal:!1}),dc=uc({isInternal:!0});_m.displayName="StepEdge";dc.displayName="StepEdgeInternal";function fc(e){return z.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,label:i,labelStyle:a,labelShowBg:d,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:l,style:f,markerEnd:h,markerStart:m,interactionWidth:g})=>{const[y,w,b]=Ma({sourceX:n,sourceY:r,targetX:o,targetY:s}),p=e.isInternal?void 0:t;return D.jsx(vn,{id:p,path:y,labelX:w,labelY:b,label:i,labelStyle:a,labelShowBg:d,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:l,style:f,markerEnd:h,markerStart:m,interactionWidth:g})})}const Em=fc({isInternal:!1}),hc=fc({isInternal:!0});Em.displayName="StraightEdge";hc.displayName="StraightEdgeInternal";function pc(e){return z.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,sourcePosition:i=K.Bottom,targetPosition:a=K.Top,label:d,labelStyle:u,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:m,markerEnd:g,markerStart:y,pathOptions:w,interactionWidth:b})=>{const[p,x,E]=Ca({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:s,targetPosition:a,curvature:w?.curvature}),_=e.isInternal?void 0:t;return D.jsx(vn,{id:_,path:p,labelX:x,labelY:E,label:d,labelStyle:u,labelShowBg:c,labelBgStyle:l,labelBgPadding:f,labelBgBorderRadius:h,style:m,markerEnd:g,markerStart:y,interactionWidth:b})})}const Sm=pc({isInternal:!1}),gc=pc({isInternal:!0});Sm.displayName="BezierEdge";gc.displayName="BezierEdgeInternal";const ws={default:gc,straight:hc,step:dc,smoothstep:lc,simplebezier:sc},xs={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Nm=(e,t,n)=>n===K.Left?e-t:n===K.Right?e+t:e,Cm=(e,t,n)=>n===K.Top?e-t:n===K.Bottom?e+t:e,bs="react-flow__edgeupdater";function vs({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:a}){return D.jsx("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:se([bs,`${bs}-${a}`]),cx:Nm(t,r,e),cy:Cm(n,r,e),r,stroke:"transparent",fill:"transparent"})}function km({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:s,targetY:i,sourcePosition:a,targetPosition:d,onReconnect:u,onReconnectStart:c,onReconnectEnd:l,setReconnecting:f,setUpdateHover:h}){const m=oe(),g=(x,E)=>{if(x.button!==0)return;const{autoPanOnConnect:_,domNode:C,isValidConnection:v,connectionMode:N,connectionRadius:P,lib:k,onConnectStart:M,onConnectEnd:$,cancelConnection:S,nodeLookup:R,rfId:A,panBy:L,updateConnection:j}=m.getState(),V=E.type==="target",W=(O,T)=>{f(!1),l?.(O,n,E.type,T)},I=O=>u?.(n,O),B=(O,T)=>{f(!0),c?.(x,n,E.type),M?.(O,T)};qr.onPointerDown(x.nativeEvent,{autoPanOnConnect:_,connectionMode:N,connectionRadius:P,domNode:C,handleId:E.id,nodeId:E.nodeId,nodeLookup:R,isTarget:V,edgeUpdaterType:E.type,lib:k,flowId:A,cancelConnection:S,panBy:L,isValidConnection:v,onConnect:I,onConnectStart:B,onConnectEnd:$,onReconnectEnd:W,updateConnection:j,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},y=x=>g(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),w=x=>g(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>h(!0),p=()=>h(!1);return D.jsxs(D.Fragment,{children:[(e===!0||e==="source")&&D.jsx(vs,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:y,onMouseEnter:b,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&D.jsx(vs,{position:d,centerX:s,centerY:i,radius:t,onMouseDown:w,onMouseEnter:b,onMouseOut:p,type:"target"})]})}function Mm({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:s,onContextMenu:i,onMouseEnter:a,onMouseMove:d,onMouseLeave:u,reconnectRadius:c,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,rfId:m,edgeTypes:g,noPanClassName:y,onError:w,disableKeyboardA11y:b}){let p=ee(X=>X.edgeLookup.get(e));const x=ee(X=>X.defaultEdgeOptions);p=x?{...x,...p}:p;let E=p.type||"default",_=g?.[E]||ws[E];_===void 0&&(w?.("011",fe.error011(E)),E="default",_=g?.default||ws.default);const C=!!(p.focusable||t&&typeof p.focusable>"u"),v=typeof l<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),N=!!(p.selectable||r&&typeof p.selectable>"u"),P=z.useRef(null),[k,M]=z.useState(!1),[$,S]=z.useState(!1),R=oe(),{zIndex:A,sourceX:L,sourceY:j,targetX:V,targetY:W,sourcePosition:I,targetPosition:B}=ee(z.useCallback(X=>{const Z=X.nodeLookup.get(p.source),J=X.nodeLookup.get(p.target);if(!Z||!J)return{zIndex:p.zIndex,...xs};const te=wp({id:e,sourceNode:Z,targetNode:J,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:X.connectionMode,onError:w});return{zIndex:up({selected:p.selected,zIndex:p.zIndex,sourceNode:Z,targetNode:J,elevateOnSelect:X.elevateEdgesOnSelect}),...te||xs}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex]),re),O=z.useMemo(()=>p.markerStart?`url('#${Br(p.markerStart,m)}')`:void 0,[p.markerStart,m]),T=z.useMemo(()=>p.markerEnd?`url('#${Br(p.markerEnd,m)}')`:void 0,[p.markerEnd,m]);if(p.hidden||L===null||j===null||V===null||W===null)return null;const H=X=>{const{addSelectedEdges:Z,unselectNodesAndEdges:J,multiSelectionActive:te}=R.getState();N&&(R.setState({nodesSelectionActive:!1}),p.selected&&te?(J({nodes:[],edges:[p]}),P.current?.blur()):Z([e])),o&&o(X,p)},Y=s?X=>{s(X,{...p})}:void 0,F=i?X=>{i(X,{...p})}:void 0,q=a?X=>{a(X,{...p})}:void 0,G=d?X=>{d(X,{...p})}:void 0,U=u?X=>{u(X,{...p})}:void 0,Q=X=>{if(!b&&ua.includes(X.key)&&N){const{unselectNodesAndEdges:Z,addSelectedEdges:J}=R.getState();X.key==="Escape"?(P.current?.blur(),Z({edges:[p]})):J([e])}};return D.jsx("svg",{style:{zIndex:A},children:D.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${E}`,p.className,y,{selected:p.selected,animated:p.animated,inactive:!N&&!o,updating:k,selectable:N}]),onClick:H,onDoubleClick:Y,onContextMenu:F,onMouseEnter:q,onMouseMove:G,onMouseLeave:U,onKeyDown:C?Q:void 0,tabIndex:C?0:void 0,role:p.ariaRole??(C?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":C?`${qa}-${m}`:void 0,ref:P,...p.domAttributes,children:[!$&&D.jsx(_,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:N,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:L,sourceY:j,targetX:V,targetY:W,sourcePosition:I,targetPosition:B,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:O,markerEnd:T,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),v&&D.jsx(km,{edge:p,isReconnectable:v,reconnectRadius:c,onReconnect:l,onReconnectStart:f,onReconnectEnd:h,sourceX:L,sourceY:j,targetX:V,targetY:W,sourcePosition:I,targetPosition:B,setUpdateHover:M,setReconnecting:S})]})})}var Om=z.memo(Mm);const Im=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function mc({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:s,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:d,onEdgeMouseLeave:u,onEdgeClick:c,reconnectRadius:l,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:m,disableKeyboardA11y:g}){const{edgesFocusable:y,edgesReconnectable:w,elementsSelectable:b,onError:p}=ee(Im,re),x=pm(t);return D.jsxs("div",{className:"react-flow__edges",children:[D.jsx(xm,{defaultColor:e,rfId:n}),x.map(E=>D.jsx(Om,{id:E,edgesFocusable:y,edgesReconnectable:w,elementsSelectable:b,noPanClassName:o,onReconnect:s,onContextMenu:i,onMouseEnter:a,onMouseMove:d,onMouseLeave:u,onClick:c,reconnectRadius:l,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:m,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:g},E))]})}mc.displayName="EdgeRenderer";const Rm=z.memo(mc),Pm=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Tm({children:e}){const t=ee(Pm);return D.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Am(e){const t=co(),n=z.useRef(!1);z.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Dm=e=>e.panZoom?.syncViewport;function Lm(e){const t=ee(Dm),n=oe();return z.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function $m(e){return e.connection.inProgress?{...e.connection,to:Ct(e.connection.to,e.transform)}:{...e.connection}}function jm(e){return $m}function zm(e){const t=jm();return ee(t,re)}const Hm=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Vm({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:s,height:i,isValid:a,inProgress:d}=ee(Hm,re);return!(s&&o&&d)?null:D.jsx("svg",{style:e,width:s,height:i,className:"react-flow__connectionline react-flow__container",children:D.jsx("g",{className:se(["react-flow__connection",ha(a)]),children:D.jsx(yc,{style:t,type:n,CustomComponent:r,isValid:a})})})}const yc=({style:e,type:t=Oe.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:s,fromNode:i,fromHandle:a,fromPosition:d,to:u,toNode:c,toHandle:l,toPosition:f}=zm();if(!o)return;if(n)return D.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:a,fromX:s.x,fromY:s.y,toX:u.x,toY:u.y,fromPosition:d,toPosition:f,connectionStatus:ha(r),toNode:c,toHandle:l});let h="";const m={sourceX:s.x,sourceY:s.y,sourcePosition:d,targetX:u.x,targetY:u.y,targetPosition:f};switch(t){case Oe.Bezier:[h]=Ca(m);break;case Oe.SimpleBezier:[h]=oc(m);break;case Oe.Step:[h]=Vr({...m,borderRadius:0});break;case Oe.SmoothStep:[h]=Vr(m);break;default:[h]=Ma(m)}return D.jsx("path",{d:h,fill:"none",className:"react-flow__connection-path",style:e})};yc.displayName="ConnectionLine";const Bm={};function _s(e=Bm){const t=z.useRef(e),n=oe();z.useEffect(()=>{if(process.env.NODE_ENV==="development"){const r=new Set([...Object.keys(t.current),...Object.keys(e)]);for(const o of r)if(t.current[o]!==e[o]){n.getState().onError?.("002",fe.error002());break}t.current=e}},[e])}function Fm(){const e=oe(),t=z.useRef(!1);z.useEffect(()=>{if(process.env.NODE_ENV==="development"&&!t.current){const n=document.querySelector(".react-flow__pane");n&&window.getComputedStyle(n).zIndex!=="1"&&e.getState().onError?.("013",fe.error013("react")),t.current=!0}},[])}function wc({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:s,onEdgeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:d,onNodeMouseLeave:u,onNodeContextMenu:c,onSelectionContextMenu:l,onSelectionStart:f,onSelectionEnd:h,connectionLineType:m,connectionLineStyle:g,connectionLineComponent:y,connectionLineContainerStyle:w,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,multiSelectionKeyCode:E,panActivationKeyCode:_,zoomActivationKeyCode:C,deleteKeyCode:v,onlyRenderVisibleElements:N,elementsSelectable:P,defaultViewport:k,translateExtent:M,minZoom:$,maxZoom:S,preventScrolling:R,defaultMarkerColor:A,zoomOnScroll:L,zoomOnPinch:j,panOnScroll:V,panOnScrollSpeed:W,panOnScrollMode:I,zoomOnDoubleClick:B,panOnDrag:O,onPaneClick:T,onPaneMouseEnter:H,onPaneMouseMove:Y,onPaneMouseLeave:F,onPaneScroll:q,onPaneContextMenu:G,paneClickDistance:U,nodeClickDistance:Q,onEdgeContextMenu:X,onEdgeMouseEnter:Z,onEdgeMouseMove:J,onEdgeMouseLeave:te,reconnectRadius:ne,onReconnect:ae,onReconnectStart:_e,onReconnectEnd:Re,noDragClassName:kt,noWheelClassName:Mt,noPanClassName:Qe,disableKeyboardA11y:Je,nodeExtent:_n,rfId:Ot,viewport:ze,onViewportChange:et}){return _s(e),_s(t),Fm(),Am(n),Lm(ze),D.jsx(om,{onPaneClick:T,onPaneMouseEnter:H,onPaneMouseMove:Y,onPaneMouseLeave:F,onPaneContextMenu:G,onPaneScroll:q,paneClickDistance:U,deleteKeyCode:v,selectionKeyCode:b,selectionOnDrag:p,selectionMode:x,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:E,panActivationKeyCode:_,zoomActivationKeyCode:C,elementsSelectable:P,zoomOnScroll:L,zoomOnPinch:j,zoomOnDoubleClick:B,panOnScroll:V,panOnScrollSpeed:W,panOnScrollMode:I,panOnDrag:O,defaultViewport:k,translateExtent:M,minZoom:$,maxZoom:S,onSelectionContextMenu:l,preventScrolling:R,noDragClassName:kt,noWheelClassName:Mt,noPanClassName:Qe,disableKeyboardA11y:Je,onViewportChange:et,isControlledViewport:!!ze,children:D.jsxs(Tm,{children:[D.jsx(Rm,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:i,onReconnect:ae,onReconnectStart:_e,onReconnectEnd:Re,onlyRenderVisibleElements:N,onEdgeContextMenu:X,onEdgeMouseEnter:Z,onEdgeMouseMove:J,onEdgeMouseLeave:te,reconnectRadius:ne,defaultMarkerColor:A,noPanClassName:Qe,disableKeyboardA11y:Je,rfId:Ot}),D.jsx(Vm,{style:g,type:m,component:y,containerStyle:w}),D.jsx("div",{className:"react-flow__edgelabel-renderer"}),D.jsx(hm,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:d,onNodeMouseLeave:u,onNodeContextMenu:c,nodeClickDistance:Q,onlyRenderVisibleElements:N,noPanClassName:Qe,noDragClassName:kt,disableKeyboardA11y:Je,nodeExtent:_n,rfId:Ot}),D.jsx("div",{className:"react-flow__viewport-portal"})]})})}wc.displayName="GraphView";const qm=z.memo(wc),Es=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:d=.5,maxZoom:u=2,nodeOrigin:c,nodeExtent:l}={})=>{const f=new Map,h=new Map,m=new Map,g=new Map,y=r??t??[],w=n??e??[],b=c??[0,0],p=l??ht;Ra(m,g,y);const x=Fr(w,f,h,{nodeOrigin:b,nodeExtent:p,elevateNodesOnSelect:!1});let E=[0,0,1];if(i&&o&&s){const _=St(f,{filter:P=>!!((P.width||P.initialWidth)&&(P.height||P.initialHeight))}),{x:C,y:v,zoom:N}=no(_,o,s,d,u,a?.padding??.1);E=[C,v,N]}return{rfId:"1",width:o??0,height:s??0,transform:E,nodes:w,nodesInitialized:x,nodeLookup:f,parentLookup:h,edges:y,edgeLookup:g,connectionLookup:m,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:d,maxZoom:u,translateExtent:ht,nodeExtent:p,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ge.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:b,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!1,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:a,fitViewResolver:null,connection:{...fa},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:xa,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:da}},Ym=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:d,maxZoom:u,nodeOrigin:c,nodeExtent:l})=>lg((f,h)=>{async function m(){const{nodeLookup:g,panZoom:y,fitViewOptions:w,fitViewResolver:b,width:p,height:x,minZoom:E,maxZoom:_}=h();y&&(await rp({nodes:g,width:p,height:x,panZoom:y,minZoom:E,maxZoom:_},w),b?.resolve(!0),f({fitViewResolver:null}))}return{...Es({nodes:e,edges:t,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:d,maxZoom:u,nodeOrigin:c,nodeExtent:l,defaultNodes:n,defaultEdges:r}),setNodes:g=>{const{nodeLookup:y,parentLookup:w,nodeOrigin:b,elevateNodesOnSelect:p,fitViewQueued:x}=h(),E=Fr(g,y,w,{nodeOrigin:b,nodeExtent:l,elevateNodesOnSelect:p,checkEquality:!0});x&&E?(m(),f({nodes:g,nodesInitialized:E,fitViewQueued:!1,fitViewOptions:void 0})):f({nodes:g,nodesInitialized:E})},setEdges:g=>{const{connectionLookup:y,edgeLookup:w}=h();Ra(y,w,g),f({edges:g})},setDefaultNodesAndEdges:(g,y)=>{if(g){const{setNodes:w}=h();w(g),f({hasDefaultNodes:!0})}if(y){const{setEdges:w}=h();w(y),f({hasDefaultEdges:!0})}},updateNodeInternals:g=>{const{triggerNodeChanges:y,nodeLookup:w,parentLookup:b,domNode:p,nodeOrigin:x,nodeExtent:E,debug:_,fitViewQueued:C}=h(),{changes:v,updatedInternals:N}=Cp(g,w,b,p,x,E);N&&(_p(w,b,{nodeOrigin:x,nodeExtent:E}),C?(m(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),v?.length>0&&(_&&console.log("React Flow: trigger node changes",v),y?.(v)))},updateNodePositions:(g,y=!1)=>{const w=[],b=[],{nodeLookup:p,triggerNodeChanges:x}=h();for(const[E,_]of g){const C=p.get(E),v=!!(C?.expandParent&&C?.parentId&&_?.position),N={id:E,type:"position",position:v?{x:Math.max(0,_.position.x),y:Math.max(0,_.position.y)}:_.position,dragging:y};v&&C.parentId&&w.push({id:E,parentId:C.parentId,rect:{..._.internals.positionAbsolute,width:_.measured.width??0,height:_.measured.height??0}}),b.push(N)}if(w.length>0){const{parentLookup:E,nodeOrigin:_}=h(),C=ao(w,p,E,_);b.push(...C)}x(b)},triggerNodeChanges:g=>{const{onNodesChange:y,setNodes:w,nodes:b,hasDefaultNodes:p,debug:x}=h();if(g?.length){if(p){const E=Ga(g,b);w(E)}x&&console.log("React Flow: trigger node changes",g),y?.(g)}},triggerEdgeChanges:g=>{const{onEdgesChange:y,setEdges:w,edges:b,hasDefaultEdges:p,debug:x}=h();if(g?.length){if(p){const E=Xa(g,b);w(E)}x&&console.log("React Flow: trigger edge changes",g),y?.(g)}},addSelectedNodes:g=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:b,triggerNodeChanges:p,triggerEdgeChanges:x}=h();if(y){const E=g.map(_=>Pe(_,!0));p(E);return}p(Be(b,new Set([...g]),!0)),x(Be(w))},addSelectedEdges:g=>{const{multiSelectionActive:y,edgeLookup:w,nodeLookup:b,triggerNodeChanges:p,triggerEdgeChanges:x}=h();if(y){const E=g.map(_=>Pe(_,!0));x(E);return}x(Be(w,new Set([...g]))),p(Be(b,new Set,!0))},unselectNodesAndEdges:({nodes:g,edges:y}={})=>{const{edges:w,nodes:b,nodeLookup:p,triggerNodeChanges:x,triggerEdgeChanges:E}=h(),_=g||b,C=y||w,v=_.map(P=>{const k=p.get(P.id);return k&&(k.selected=!1),Pe(P.id,!1)}),N=C.map(P=>Pe(P.id,!1));x(v),E(N)},setMinZoom:g=>{const{panZoom:y,maxZoom:w}=h();y?.setScaleExtent([g,w]),f({minZoom:g})},setMaxZoom:g=>{const{panZoom:y,minZoom:w}=h();y?.setScaleExtent([w,g]),f({maxZoom:g})},setTranslateExtent:g=>{h().panZoom?.setTranslateExtent(g),f({translateExtent:g})},resetSelectedElements:()=>{const{edges:g,nodes:y,triggerNodeChanges:w,triggerEdgeChanges:b,elementsSelectable:p}=h();if(!p)return;const x=y.reduce((_,C)=>C.selected?[..._,Pe(C.id,!1)]:_,[]),E=g.reduce((_,C)=>C.selected?[..._,Pe(C.id,!1)]:_,[]);w(x),b(E)},setNodeExtent:g=>{const{nodes:y,nodeLookup:w,parentLookup:b,nodeOrigin:p,elevateNodesOnSelect:x,nodeExtent:E}=h();g[0][0]===E[0][0]&&g[0][1]===E[0][1]&&g[1][0]===E[1][0]&&g[1][1]===E[1][1]||(Fr(y,w,b,{nodeOrigin:p,nodeExtent:g,elevateNodesOnSelect:x,checkEquality:!1}),f({nodeExtent:g}))},panBy:g=>{const{transform:y,width:w,height:b,panZoom:p,translateExtent:x}=h();return kp({delta:g,panZoom:p,transform:y,translateExtent:x,width:w,height:b})},setCenter:async(g,y,w)=>{const{width:b,height:p,maxZoom:x,panZoom:E}=h();if(!E)return Promise.resolve(!1);const _=typeof w?.zoom<"u"?w.zoom:x;return await E.setViewport({x:b/2-g*_,y:p/2-y*_,zoom:_},{duration:w?.duration,ease:w?.ease,interpolate:w?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{f({connection:{...fa}})},updateConnection:g=>{f({connection:g})},reset:()=>f({...Es()})}},Object.is);function Wm({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:s,initialMinZoom:i,initialMaxZoom:a,initialFitViewOptions:d,fitView:u,nodeOrigin:c,nodeExtent:l,children:f}){const[h]=z.useState(()=>Ym({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:u,minZoom:i,maxZoom:a,fitViewOptions:d,nodeOrigin:c,nodeExtent:l}));return D.jsx(ug,{value:h,children:D.jsx(Tg,{children:f})})}function Gm({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:s,height:i,fitView:a,fitViewOptions:d,minZoom:u,maxZoom:c,nodeOrigin:l,nodeExtent:f}){return z.useContext(wn)?D.jsx(D.Fragment,{children:e}):D.jsx(Wm,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:s,initialHeight:i,fitView:a,initialFitViewOptions:d,initialMinZoom:u,initialMaxZoom:c,nodeOrigin:l,nodeExtent:f,children:e})}const Xm={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function Zm({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s,edgeTypes:i,onNodeClick:a,onEdgeClick:d,onInit:u,onMove:c,onMoveStart:l,onMoveEnd:f,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:w,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:E,onNodeDoubleClick:_,onNodeDragStart:C,onNodeDrag:v,onNodeDragStop:N,onNodesDelete:P,onEdgesDelete:k,onDelete:M,onSelectionChange:$,onSelectionDragStart:S,onSelectionDrag:R,onSelectionDragStop:A,onSelectionContextMenu:L,onSelectionStart:j,onSelectionEnd:V,onBeforeDelete:W,connectionMode:I,connectionLineType:B=Oe.Bezier,connectionLineStyle:O,connectionLineComponent:T,connectionLineContainerStyle:H,deleteKeyCode:Y="Backspace",selectionKeyCode:F="Shift",selectionOnDrag:q=!1,selectionMode:G=pt.Full,panActivationKeyCode:U="Space",multiSelectionKeyCode:Q=mt()?"Meta":"Control",zoomActivationKeyCode:X=mt()?"Meta":"Control",snapToGrid:Z,snapGrid:J,onlyRenderVisibleElements:te=!1,selectNodesOnDrag:ne,nodesDraggable:ae,autoPanOnNodeFocus:_e,nodesConnectable:Re,nodesFocusable:kt,nodeOrigin:Mt=Ya,edgesFocusable:Qe,edgesReconnectable:Je,elementsSelectable:_n=!0,defaultViewport:Ot=Eg,minZoom:ze=.5,maxZoom:et=2,translateExtent:uo=ht,preventScrolling:Mc=!0,nodeExtent:En,defaultMarkerColor:Oc="#b1b1b7",zoomOnScroll:Ic=!0,zoomOnPinch:Rc=!0,panOnScroll:Pc=!1,panOnScrollSpeed:Tc=.5,panOnScrollMode:Ac=De.Free,zoomOnDoubleClick:Dc=!0,panOnDrag:Lc=!0,onPaneClick:$c,onPaneMouseEnter:jc,onPaneMouseMove:zc,onPaneMouseLeave:Hc,onPaneScroll:Vc,onPaneContextMenu:Bc,paneClickDistance:Fc=0,nodeClickDistance:qc=0,children:Yc,onReconnect:Wc,onReconnectStart:Gc,onReconnectEnd:Xc,onEdgeContextMenu:Zc,onEdgeDoubleClick:Kc,onEdgeMouseEnter:Uc,onEdgeMouseMove:Qc,onEdgeMouseLeave:Jc,reconnectRadius:el=10,onNodesChange:tl,onEdgesChange:nl,noDragClassName:rl="nodrag",noWheelClassName:ol="nowheel",noPanClassName:fo="nopan",fitView:ho,fitViewOptions:po,connectOnClick:il,attributionPosition:sl,proOptions:al,defaultEdgeOptions:cl,elevateNodesOnSelect:ll,elevateEdgesOnSelect:ul,disableKeyboardA11y:go=!1,autoPanOnConnect:dl,autoPanOnNodeDrag:fl,autoPanSpeed:hl,connectionRadius:pl,isValidConnection:gl,onError:ml,style:yl,id:mo,nodeDragThreshold:wl,connectionDragThreshold:xl,viewport:bl,onViewportChange:vl,width:_l,height:El,colorMode:Sl="light",debug:Nl,onScroll:yo,ariaLabelConfig:Cl,...kl},Ml){const Sn=mo||"1",Ol=kg(Sl),Il=z.useCallback(wo=>{wo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yo?.(wo)},[yo]);return D.jsx("div",{"data-testid":"rf__wrapper",...kl,onScroll:Il,style:{...yl,...Xm},ref:Ml,className:se(["react-flow",o,Ol]),id:mo,role:"application",children:D.jsxs(Gm,{nodes:e,edges:t,width:_l,height:El,fitView:ho,fitViewOptions:po,minZoom:ze,maxZoom:et,nodeOrigin:Mt,nodeExtent:En,children:[D.jsx(qm,{onInit:u,onNodeClick:a,onEdgeClick:d,onNodeMouseEnter:b,onNodeMouseMove:p,onNodeMouseLeave:x,onNodeContextMenu:E,onNodeDoubleClick:_,nodeTypes:s,edgeTypes:i,connectionLineType:B,connectionLineStyle:O,connectionLineComponent:T,connectionLineContainerStyle:H,selectionKeyCode:F,selectionOnDrag:q,selectionMode:G,deleteKeyCode:Y,multiSelectionKeyCode:Q,panActivationKeyCode:U,zoomActivationKeyCode:X,onlyRenderVisibleElements:te,defaultViewport:Ot,translateExtent:uo,minZoom:ze,maxZoom:et,preventScrolling:Mc,zoomOnScroll:Ic,zoomOnPinch:Rc,zoomOnDoubleClick:Dc,panOnScroll:Pc,panOnScrollSpeed:Tc,panOnScrollMode:Ac,panOnDrag:Lc,onPaneClick:$c,onPaneMouseEnter:jc,onPaneMouseMove:zc,onPaneMouseLeave:Hc,onPaneScroll:Vc,onPaneContextMenu:Bc,paneClickDistance:Fc,nodeClickDistance:qc,onSelectionContextMenu:L,onSelectionStart:j,onSelectionEnd:V,onReconnect:Wc,onReconnectStart:Gc,onReconnectEnd:Xc,onEdgeContextMenu:Zc,onEdgeDoubleClick:Kc,onEdgeMouseEnter:Uc,onEdgeMouseMove:Qc,onEdgeMouseLeave:Jc,reconnectRadius:el,defaultMarkerColor:Oc,noDragClassName:rl,noWheelClassName:ol,noPanClassName:fo,rfId:Sn,disableKeyboardA11y:go,nodeExtent:En,viewport:bl,onViewportChange:vl}),D.jsx(Cg,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:w,nodesDraggable:ae,autoPanOnNodeFocus:_e,nodesConnectable:Re,nodesFocusable:kt,edgesFocusable:Qe,edgesReconnectable:Je,elementsSelectable:_n,elevateNodesOnSelect:ll,elevateEdgesOnSelect:ul,minZoom:ze,maxZoom:et,nodeExtent:En,onNodesChange:tl,onEdgesChange:nl,snapToGrid:Z,snapGrid:J,connectionMode:I,translateExtent:uo,connectOnClick:il,defaultEdgeOptions:cl,fitView:ho,fitViewOptions:po,onNodesDelete:P,onEdgesDelete:k,onDelete:M,onNodeDragStart:C,onNodeDrag:v,onNodeDragStop:N,onSelectionDrag:R,onSelectionDragStart:S,onSelectionDragStop:A,onMove:c,onMoveStart:l,onMoveEnd:f,noPanClassName:fo,nodeOrigin:Mt,rfId:Sn,autoPanOnConnect:dl,autoPanOnNodeDrag:fl,autoPanSpeed:hl,onError:ml,connectionRadius:pl,isValidConnection:gl,selectNodesOnDrag:ne,nodeDragThreshold:wl,connectionDragThreshold:xl,onBeforeDelete:W,debug:Nl,ariaLabelConfig:Cl}),D.jsx(_g,{onSelectionChange:$}),Yc,D.jsx(yg,{proOptions:al,position:sl}),D.jsx(mg,{rfId:Sn,disableKeyboardA11y:go})]})})}var Km=Za(Zm);const Um=e=>e.edges;function Qm(){return ee(Um,re)}function Jm(e){const[t,n]=z.useState(e),r=z.useCallback(o=>n(s=>Ga(o,s)),[]);return[t,n,r]}function e0(e){const[t,n]=z.useState(e),r=z.useCallback(o=>n(s=>Xa(o,s)),[]);return[t,n,r]}function t0({dimensions:e,lineWidth:t,variant:n,className:r}){return D.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,r])})}function n0({radius:e,className:t}){return D.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var Ie;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ie||(Ie={}));const r0={[Ie.Dots]:1,[Ie.Lines]:1,[Ie.Cross]:6},o0=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function xc({id:e,variant:t=Ie.Dots,gap:n=20,size:r,lineWidth:o=1,offset:s=0,color:i,bgColor:a,style:d,className:u,patternClassName:c}){const l=z.useRef(null),{transform:f,patternId:h}=ee(o0,re),m=r||r0[t],g=t===Ie.Dots,y=t===Ie.Cross,w=Array.isArray(n)?n:[n,n],b=[w[0]*f[2]||1,w[1]*f[2]||1],p=m*f[2],x=Array.isArray(s)?s:[s,s],E=y?[p,p]:b,_=[x[0]*f[2]||1+E[0]/2,x[1]*f[2]||1+E[1]/2],C=`${h}${e||""}`;return D.jsxs("svg",{className:se(["react-flow__background",u]),style:{...d,...bn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":i},ref:l,"data-testid":"rf__background",children:[D.jsx("pattern",{id:C,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:g?D.jsx(n0,{radius:p/2,className:c}):D.jsx(t0,{dimensions:E,lineWidth:o,variant:t,className:c})}),D.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${C})`})]})}xc.displayName="Background";const i0=z.memo(xc);function s0(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:D.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function a0(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:D.jsx("path",{d:"M0 0h32v4.2H0z"})})}function c0(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:D.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function l0(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:D.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function u0(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:D.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Vt({children:e,className:t,...n}){return D.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const d0=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function bc({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:a,onInteractiveChange:d,className:u,children:c,position:l="bottom-left",orientation:f="vertical","aria-label":h}){const m=oe(),{isInteractive:g,minZoomReached:y,maxZoomReached:w,ariaLabelConfig:b}=ee(d0,re),{zoomIn:p,zoomOut:x,fitView:E}=co(),_=()=>{p(),s?.()},C=()=>{x(),i?.()},v=()=>{E(o),a?.()},N=()=>{m.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),d?.(!g)},P=f==="horizontal"?"horizontal":"vertical";return D.jsxs(xn,{className:se(["react-flow__controls",P,u]),position:l,style:e,"data-testid":"rf__controls","aria-label":h??b["controls.ariaLabel"],children:[t&&D.jsxs(D.Fragment,{children:[D.jsx(Vt,{onClick:_,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:w,children:D.jsx(s0,{})}),D.jsx(Vt,{onClick:C,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:y,children:D.jsx(a0,{})})]}),n&&D.jsx(Vt,{className:"react-flow__controls-fitview",onClick:v,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:D.jsx(c0,{})}),r&&D.jsx(Vt,{className:"react-flow__controls-interactive",onClick:N,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:g?D.jsx(u0,{}):D.jsx(l0,{})}),c]})}bc.displayName="Controls";const f0=z.memo(bc);function h0({id:e,x:t,y:n,width:r,height:o,style:s,color:i,strokeColor:a,strokeWidth:d,className:u,borderRadius:c,shapeRendering:l,selected:f,onClick:h}){const{background:m,backgroundColor:g}=s||{},y=i||m||g;return D.jsx("rect",{className:se(["react-flow__minimap-node",{selected:f},u]),x:t,y:n,rx:c,ry:c,width:r,height:o,style:{fill:y,stroke:a,strokeWidth:d},shapeRendering:l,onClick:h?w=>h(w,e):void 0})}const p0=z.memo(h0),g0=e=>e.nodes.map(t=>t.id),Ir=e=>e instanceof Function?e:()=>e;function m0({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:s=p0,onClick:i}){const a=ee(g0,re),d=Ir(t),u=Ir(e),c=Ir(n),l=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return D.jsx(D.Fragment,{children:a.map(f=>D.jsx(w0,{id:f,nodeColorFunc:d,nodeStrokeColorFunc:u,nodeClassNameFunc:c,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:s,onClick:i,shapeRendering:l},f))})}function y0({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:s,shapeRendering:i,NodeComponent:a,onClick:d}){const{node:u,x:c,y:l,width:f,height:h}=ee(m=>{const{internals:g}=m.nodeLookup.get(e),y=g.userNode,{x:w,y:b}=g.positionAbsolute,{width:p,height:x}=Ce(y);return{node:y,x:w,y:b,width:p,height:x}},re);return!u||u.hidden||!ba(u)?null:D.jsx(a,{x:c,y:l,width:f,height:h,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:o,strokeColor:n(u),strokeWidth:s,shapeRendering:i,onClick:d,id:u.id})}const w0=z.memo(y0);var x0=z.memo(m0);const b0=200,v0=150,_0=e=>!e.hidden,E0=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?wa(St(e.nodeLookup,{filter:_0}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},S0="react-flow__minimap-desc";function vc({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:a,bgColor:d,maskColor:u,maskStrokeColor:c,maskStrokeWidth:l,position:f="bottom-right",onClick:h,onNodeClick:m,pannable:g=!1,zoomable:y=!1,ariaLabel:w,inversePan:b,zoomStep:p=1,offsetScale:x=5}){const E=oe(),_=z.useRef(null),{boundingRect:C,viewBB:v,rfId:N,panZoom:P,translateExtent:k,flowWidth:M,flowHeight:$,ariaLabelConfig:S}=ee(E0,re),R=e?.width??b0,A=e?.height??v0,L=C.width/R,j=C.height/A,V=Math.max(L,j),W=V*R,I=V*A,B=x*V,O=C.x-(W-C.width)/2-B,T=C.y-(I-C.height)/2-B,H=W+B*2,Y=I+B*2,F=`${S0}-${N}`,q=z.useRef(0),G=z.useRef();q.current=V,z.useEffect(()=>{if(_.current&&P)return G.current=Lp({domNode:_.current,panZoom:P,getTransform:()=>E.getState().transform,getViewScale:()=>q.current}),()=>{G.current?.destroy()}},[P]),z.useEffect(()=>{G.current?.update({translateExtent:k,width:M,height:$,inversePan:b,pannable:g,zoomStep:p,zoomable:y})},[g,y,b,p,k,M,$]);const U=h?Z=>{const[J,te]=G.current?.pointer(Z)||[0,0];h(Z,{x:J,y:te})}:void 0,Q=m?z.useCallback((Z,J)=>{const te=E.getState().nodeLookup.get(J).internals.userNode;m(Z,te)},[]):void 0,X=w??S["minimap.ariaLabel"];return D.jsx(xn,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-width-props":typeof l=="number"?l*V:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:D.jsxs("svg",{width:R,height:A,viewBox:`${O} ${T} ${H} ${Y}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":F,ref:_,onClick:U,children:[X&&D.jsx("title",{id:F,children:X}),D.jsx(x0,{onClick:Q,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:a}),D.jsx("path",{className:"react-flow__minimap-mask",d:`M${O-B},${T-B}h${H+B*2}v${Y+B*2}h${-H-B*2}z
|
|
12
|
-
M${v.x},${v.y}h${v.width}v${v.height}h${-v.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}vc.displayName="MiniMap";const N0=z.memo(vc),C0=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,k0={[Ue.Line]:"right",[Ue.Handle]:"bottom-right"};function M0({nodeId:e,position:t,variant:n=Ue.Handle,className:r,style:o=void 0,children:s,color:i,minWidth:a=10,minHeight:d=10,maxWidth:u=Number.MAX_VALUE,maxHeight:c=Number.MAX_VALUE,keepAspectRatio:l=!1,resizeDirection:f,autoScale:h=!0,shouldResize:m,onResizeStart:g,onResize:y,onResizeEnd:w}){const b=Ja(),p=typeof e=="string"?e:b,x=oe(),E=z.useRef(null),_=n===Ue.Handle,C=ee(z.useCallback(C0(_&&h),[_,h]),re),v=z.useRef(null),N=t??k0[n];z.useEffect(()=>{if(!(!E.current||!p))return v.current||(v.current=Kp({domNode:E.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:k,transform:M,snapGrid:$,snapToGrid:S,nodeOrigin:R,domNode:A}=x.getState();return{nodeLookup:k,transform:M,snapGrid:$,snapToGrid:S,nodeOrigin:R,paneDomNode:A}},onChange:(k,M)=>{const{triggerNodeChanges:$,nodeLookup:S,parentLookup:R,nodeOrigin:A}=x.getState(),L=[],j={x:k.x,y:k.y},V=S.get(p);if(V&&V.expandParent&&V.parentId){const W=V.origin??A,I=k.width??V.measured.width??0,B=k.height??V.measured.height??0,O={id:V.id,parentId:V.parentId,rect:{width:I,height:B,...va({x:k.x??V.position.x,y:k.y??V.position.y},{width:I,height:B},V.parentId,S,W)}},T=ao([O],S,R,A);L.push(...T),j.x=k.x?Math.max(W[0]*I,k.x):void 0,j.y=k.y?Math.max(W[1]*B,k.y):void 0}if(j.x!==void 0&&j.y!==void 0){const W={id:p,type:"position",position:{...j}};L.push(W)}if(k.width!==void 0&&k.height!==void 0){const I={id:p,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:k.width,height:k.height}};L.push(I)}for(const W of M){const I={...W,type:"position"};L.push(I)}$(L)},onEnd:({width:k,height:M})=>{const $={id:p,type:"dimensions",resizing:!1,dimensions:{width:k,height:M}};x.getState().triggerNodeChanges([$])}})),v.current.update({controlPosition:N,boundaries:{minWidth:a,minHeight:d,maxWidth:u,maxHeight:c},keepAspectRatio:l,resizeDirection:f,onResizeStart:g,onResize:y,onResizeEnd:w,shouldResize:m}),()=>{v.current?.destroy()}},[N,a,d,u,c,l,g,y,w,m]);const P=N.split("-");return D.jsx("div",{className:se(["react-flow__resize-control","nodrag",...P,n,r]),ref:E,style:{...o,scale:C,...i&&{[_?"backgroundColor":"borderColor"]:i}},children:s})}z.memo(M0);function _c(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=_c(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function an(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=_c(e))&&(r&&(r+=" "),r+=t);return r}const Ec=z.createContext({tables:{},setTable:()=>{},animatedEdges:[],addAnimatedEdges:()=>{},removeAnimatedEdges:()=>{},refs:[]}),Sc=()=>{const e=z.useContext(Ec);if(!e)throw new Error("useDbmlRendererContext must be used within a DbmlRendererContext");return e},Gt=e=>`table-${e.id}`,O0=e=>{const{schema:t,id:n}=e;return`relation-${t.id}-${n}`};var Nc={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ss=z.createContext&&z.createContext(Nc),I0=["attr","size","title"];function R0(e,t){if(e==null)return{};var n=P0(e,t),r,o;if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(o=0;o<s.length;o++)r=s[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function P0(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function cn(){return cn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},cn.apply(this,arguments)}function Ns(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ln(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Ns(Object(n),!0).forEach(function(r){T0(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ns(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function T0(e,t,n){return t=A0(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function A0(e){var t=D0(e,"string");return typeof t=="symbol"?t:t+""}function D0(e,t){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Cc(e){return e&&e.map((t,n)=>z.createElement(t.tag,ln({key:n},t.attr),Cc(t.child)))}function kc(e){return t=>z.createElement(L0,cn({attr:ln({},e.attr)},t),Cc(e.child))}function L0(e){var t=n=>{var{attr:r,size:o,title:s}=e,i=R0(e,I0),a=o||n.size||"1em",d;return n.className&&(d=n.className),e.className&&(d=(d?d+" ":"")+e.className),z.createElement("svg",cn({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,i,{className:d,style:ln(ln({color:e.color||n.color},n.style),e.style),height:a,width:a,xmlns:"http://www.w3.org/2000/svg"}),s&&z.createElement("title",null,s),e.children)};return Ss!==void 0?z.createElement(Ss.Consumer,null,n=>t(n)):t(Nc)}function $0(e){return kc({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M336 352c97.2 0 176-78.8 176-176S433.2 0 336 0S160 78.8 160 176c0 18.7 2.9 36.8 8.3 53.7L7 391c-4.5 4.5-7 10.6-7 17l0 80c0 13.3 10.7 24 24 24l80 0c13.3 0 24-10.7 24-24l0-40 40 0c13.3 0 24-10.7 24-24l0-40 40 0c6.4 0 12.5-2.5 17-7l33.3-33.3c16.9 5.4 35 8.3 53.7 8.3zM376 96a40 40 0 1 1 0 80 40 40 0 1 1 0-80z"},child:[]}]})(e)}function j0(e){return kc({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l224 0 0-112c0-26.5 21.5-48 48-48l112 0 0-224c0-35.3-28.7-64-64-64L64 32zM448 352l-45.3 0L336 352c-8.8 0-16 7.2-16 16l0 66.7 0 45.3 32-32 64-64 32-32z"},child:[]}]})(e)}const z0="_base_2tvbf_1",H0="_relation-one_2tvbf_15",V0="_relation-many_2tvbf_19",B0="_left_2tvbf_23",F0="_right_2tvbf_27",bt={base:z0,relationOne:H0,relationMany:V0,left:B0,right:F0},q0={1:bt.relationOne,"*":bt.relationMany},Y0={left:bt.left,right:bt.right},W0=e=>{const{relation:t,position:n,...r}=e,o=q0[t],s=Y0[n];return D.jsx(xt,{...r,position:n,className:an(bt.base,s,o)})},G0="_field-container_9xmax_1",X0="_field_9xmax_1",Z0="_field-highlighted_9xmax_27",K0="_field-name_9xmax_32",U0="_nowrap_9xmax_38",Q0="_label_9xmax_44",J0="_field-name-pk_9xmax_48",ey="_properties_9xmax_63",ty="_data-type_9xmax_69",ny="_details_9xmax_73",ry="_details-field-name_9xmax_82",oy="_details-content_9xmax_88",iy="_enum-list_9xmax_94",sy="_icon_9xmax_104",ce={fieldContainer:G0,field:X0,fieldHighlighted:Z0,fieldName:K0,nowrap:U0,label:Q0,fieldNamePk:J0,properties:ey,dataType:ty,details:ny,detailsFieldName:ry,detailsContent:oy,enumList:iy,icon:sy},ay=e=>{const{field:t}=e,{name:n,type:r,not_null:o,pk:s,note:i,id:a,_enum:d,dbdefault:u}=t,c=Qm(),l=`field-${a}-`,f=c.filter(E=>E.sourceHandle?.startsWith(l)||E.targetHandle?.startsWith(l)),[h,m]=z.useState(!1),{animatedEdges:g,addAnimatedEdges:y,removeAnimatedEdges:w}=Sc(),b=f.map(E=>{const _=/field-\d+-(source|target)-(left|right)/,C=E.sourceHandle?.startsWith(l),{sourceHandle:v,targetHandle:N}=E,P=C?v:N,[,k,M]=P?.match(_)||[],$=E.data?.ref;if(!$)return null;const[S,R]=$.endpoints,L=k==="target"?R:S;return D.jsx(W0,{id:P,type:k,position:M==="left"?K.Left:K.Right,relation:L.relation},E.id)}),p=!!i||!!d||!!u;z.useEffect(()=>{h?y(f):w(f)},[h]);const x=z.useMemo(()=>g.some(E=>f.some(_=>_.id===E.id)),[g,f]);return D.jsxs("div",{className:ce.fieldContainer,children:[D.jsxs("button",{className:an(ce.field,x&&ce.fieldHighlighted),type:"button",onMouseEnter:()=>{m(!0)},onMouseLeave:()=>{m(!1)},children:[D.jsx("div",{className:ce.label,children:D.jsxs("span",{className:an(ce.fieldName,s&&ce.fieldNamePk),title:i,children:[n,s&&D.jsx($0,{className:ce.icon}),i&&D.jsx(j0,{className:ce.icon})]})}),b,D.jsxs("div",{className:ce.properties,children:[D.jsx("span",{className:ce.dataType,children:D.jsx("code",{children:r?.type_name})}),!!d&&D.jsx("span",{title:"Enum",children:"E"}),o&&D.jsx("span",{title:"Not null",children:"NN"})]})]}),p&&h&&D.jsxs("aside",{className:ce.details,children:[D.jsx("div",{className:ce.detailsFieldName,children:n}),D.jsxs("div",{className:ce.detailsContent,children:[d&&D.jsxs("div",{children:[D.jsxs("div",{className:ce.nowrap,children:["ENUM ",d.name]}),D.jsx("ul",{className:ce.enumList,children:d.values.map(E=>D.jsx("li",{children:D.jsx("code",{children:E.name})},E.id))})]}),i&&D.jsx("div",{children:i}),u&&D.jsxs("div",{className:ce.nowrap,children:["DEFAULT ",D.jsx("code",{children:u?.value})]})]})]})]})},cy="_table_igwli_1",ly="_header_igwli_9",Cs={table:cy,header:ly},uy=e=>{const{data:{table:t}}=e,[n,r]=z.useState(!1),o=z.useRef(null),{setTable:s}=Sc(),{fields:i,name:a,schema:d}=t,u=Gt(t);return z.useEffect(()=>{if(!o.current||!n)return;const{clientHeight:c,clientWidth:l}=o.current;s(u,{width:l,height:c})},[n]),z.useEffect(()=>{r(!0)},[]),D.jsxs("div",{className:Cs.table,ref:o,children:[D.jsx("div",{className:Cs.header,children:`${d.name}.${a}`}),i.map(c=>D.jsx(ay,{field:c},c.id))]})},dy="_container_ym2nb_1",fy="_edge_ym2nb_6",hy="_edge-animated_ym2nb_10",Rr={container:dy,edge:fy,edgeAnimated:hy},py=172,gy=36,my={table:uy},yy=e=>{const{content:t}=e,[n,r]=z.useState({}),[o,s]=z.useState([]),i=z.useRef(null),a=z.useMemo(()=>{try{return Rl.Parser.parse(t,"dbmlv2")}catch(y){return console.error(y),null}},[t]),d=z.useRef(null),[u,c,l]=Jm([]),[f,h]=e0([]),m=z.useCallback(y=>y.schemas.reduce(({nodes:b,edges:p},x)=>{const E=x.tables.map(C=>{const v=Gt(C),{width:N,height:P}=n[v]||{};return{id:v,type:"table",width:N,height:P,position:{x:0,y:0},data:{table:C},draggable:!0}}),_=x.refs.map(C=>{const{endpoints:v}=C,[N,P]=v,{id:k,table:M}=N.fields[0],{id:$,table:S}=P.fields[0],R=`field-${k}-source`,A=`field-${$}-target`,L=O0(C),j=o.some(W=>W.id===L),V=an(Rr.edge,j&&Rr.edgeAnimated);return{id:L,source:Gt(M),target:Gt(S),sourceHandle:R,targetHandle:A,type:"step",data:{ref:C},animated:j,className:V}});return{nodes:b.concat(E),edges:p.concat(_)}},{nodes:[],edges:[]}),[n,o]),g=z.useCallback((y,w,b="TB")=>{const p=new gi.graphlib.Graph().setDefaultEdgeLabel(()=>({}));p.setGraph({rankdir:b,nodesep:150,ranksep:150}),y.forEach(C=>{const v=n[C.id]||{width:py,height:gy};p.setNode(C.id,v)}),w.forEach(C=>{p.setEdge(C.source,C.target)}),gi.layout(p);const x=y.map(C=>{const v=p.node(C.id);return{...C,position:{x:v.x,y:v.y}}}),E=C=>x.find(v=>C===v.id),_=w.map(C=>{const{target:v,source:N}=C,P=E(N),k=E(v);if(!P||!k)return console.error(`cant find source or target node, source: ${N} target: ${v}`),C;const{x:M}=P.position,{x:$}=k.position,S={...C};return M>=$?(S.sourceHandle=`${C.sourceHandle}-left`,S.targetHandle=`${C.targetHandle}-right`):M<$&&(S.sourceHandle=`${C.sourceHandle}-right`,S.targetHandle=`${C.targetHandle}-left`),S});return{nodes:x,edges:_}},[n]);return z.useEffect(()=>{if(!a){c([]);return}const{nodes:y,edges:w}=m(a),{nodes:b,edges:p}=g(y,w);c(b),h(p)},[a,m,g,h,c]),D.jsx(Ec,{value:{tables:n,setTable:(y,w)=>{r(b=>({...b,[y]:w}))},refs:f,animatedEdges:o,addAnimatedEdges:y=>{s(w=>[...w,...y])},removeAnimatedEdges:y=>{const w=y.map(b=>b.id);s(b=>b.filter(p=>!w.includes(p.id)))}},children:D.jsx("div",{className:Rr.container,children:D.jsxs(Km,{nodes:u,onNodesChange:l,edges:f,fitView:!0,ref:d,nodeTypes:my,colorMode:"system",onInit:y=>{i.current=y},children:[D.jsx(i0,{}),D.jsx(f0,{}),D.jsx(N0,{})]})})})};exports.DbmlRenderer=yy;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react/jsx-runtime"),mr=require("@dbml/core"),X=require("@xyflow/react"),A=require("react");function br(u){return u&&u.__esModule&&Object.prototype.hasOwnProperty.call(u,"default")?u.default:u}var de,st;function rt(){if(st)return de;st=1;var u="\0",c="\0",l="";class d{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>{};_defaultEdgeLabelFn=()=>{};_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(t){t&&(this._isDirected=Object.hasOwn(t,"directed")?t.directed:!0,this._isMultigraph=Object.hasOwn(t,"multigraph")?t.multigraph:!1,this._isCompound=Object.hasOwn(t,"compound")?t.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[c]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(t){return this._label=t,this}graph(){return this._label}setDefaultNodeLabel(t){return this._defaultNodeLabelFn=t,typeof t!="function"&&(this._defaultNodeLabelFn=()=>t),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var t=this;return this.nodes().filter(r=>Object.keys(t._in[r]).length===0)}sinks(){var t=this;return this.nodes().filter(r=>Object.keys(t._out[r]).length===0)}setNodes(t,r){var h=arguments,m=this;return t.forEach(function(E){h.length>1?m.setNode(E,r):m.setNode(E)}),this}setNode(t,r){return Object.hasOwn(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=r),this):(this._nodes[t]=arguments.length>1?r:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=c,this._children[t]={},this._children[c][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++this._nodeCount,this)}node(t){return this._nodes[t]}hasNode(t){return Object.hasOwn(this._nodes,t)}removeNode(t){var r=this;if(Object.hasOwn(this._nodes,t)){var h=m=>r.removeEdge(r._edgeObjs[m]);delete this._nodes[t],this._isCompound&&(this._removeFromParentsChildList(t),delete this._parent[t],this.children(t).forEach(function(m){r.setParent(m)}),delete this._children[t]),Object.keys(this._in[t]).forEach(h),delete this._in[t],delete this._preds[t],Object.keys(this._out[t]).forEach(h),delete this._out[t],delete this._sucs[t],--this._nodeCount}return this}setParent(t,r){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(r===void 0)r=c;else{r+="";for(var h=r;h!==void 0;h=this.parent(h))if(h===t)throw new Error("Setting "+r+" as parent of "+t+" would create a cycle");this.setNode(r)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=r,this._children[r][t]=!0,this}_removeFromParentsChildList(t){delete this._children[this._parent[t]][t]}parent(t){if(this._isCompound){var r=this._parent[t];if(r!==c)return r}}children(t=c){if(this._isCompound){var r=this._children[t];if(r)return Object.keys(r)}else{if(t===c)return this.nodes();if(this.hasNode(t))return[]}}predecessors(t){var r=this._preds[t];if(r)return Object.keys(r)}successors(t){var r=this._sucs[t];if(r)return Object.keys(r)}neighbors(t){var r=this.predecessors(t);if(r){const m=new Set(r);for(var h of this.successors(t))m.add(h);return Array.from(m.values())}}isLeaf(t){var r;return this.isDirected()?r=this.successors(t):r=this.neighbors(t),r.length===0}filterNodes(t){var r=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});r.setGraph(this.graph());var h=this;Object.entries(this._nodes).forEach(function([x,p]){t(x)&&r.setNode(x,p)}),Object.values(this._edgeObjs).forEach(function(x){r.hasNode(x.v)&&r.hasNode(x.w)&&r.setEdge(x,h.edge(x))});var m={};function E(x){var p=h.parent(x);return p===void 0||r.hasNode(p)?(m[x]=p,p):p in m?m[p]:E(p)}return this._isCompound&&r.nodes().forEach(x=>r.setParent(x,E(x))),r}setDefaultEdgeLabel(t){return this._defaultEdgeLabelFn=t,typeof t!="function"&&(this._defaultEdgeLabelFn=()=>t),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(t,r){var h=this,m=arguments;return t.reduce(function(E,x){return m.length>1?h.setEdge(E,x,r):h.setEdge(E,x),x}),this}setEdge(){var t,r,h,m,E=!1,x=arguments[0];typeof x=="object"&&x!==null&&"v"in x?(t=x.v,r=x.w,h=x.name,arguments.length===2&&(m=arguments[1],E=!0)):(t=x,r=arguments[1],h=arguments[3],arguments.length>2&&(m=arguments[2],E=!0)),t=""+t,r=""+r,h!==void 0&&(h=""+h);var p=e(this._isDirected,t,r,h);if(Object.hasOwn(this._edgeLabels,p))return E&&(this._edgeLabels[p]=m),this;if(h!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(t),this.setNode(r),this._edgeLabels[p]=E?m:this._defaultEdgeLabelFn(t,r,h);var w=s(this._isDirected,t,r,h);return t=w.v,r=w.w,Object.freeze(w),this._edgeObjs[p]=w,a(this._preds[r],t),a(this._sucs[t],r),this._in[r][p]=w,this._out[t][p]=w,this._edgeCount++,this}edge(t,r,h){var m=arguments.length===1?n(this._isDirected,arguments[0]):e(this._isDirected,t,r,h);return this._edgeLabels[m]}edgeAsObj(){const t=this.edge(...arguments);return typeof t!="object"?{label:t}:t}hasEdge(t,r,h){var m=arguments.length===1?n(this._isDirected,arguments[0]):e(this._isDirected,t,r,h);return Object.hasOwn(this._edgeLabels,m)}removeEdge(t,r,h){var m=arguments.length===1?n(this._isDirected,arguments[0]):e(this._isDirected,t,r,h),E=this._edgeObjs[m];return E&&(t=E.v,r=E.w,delete this._edgeLabels[m],delete this._edgeObjs[m],i(this._preds[r],t),i(this._sucs[t],r),delete this._in[r][m],delete this._out[t][m],this._edgeCount--),this}inEdges(t,r){var h=this._in[t];if(h){var m=Object.values(h);return r?m.filter(E=>E.v===r):m}}outEdges(t,r){var h=this._out[t];if(h){var m=Object.values(h);return r?m.filter(E=>E.w===r):m}}nodeEdges(t,r){var h=this.inEdges(t,r);if(h)return h.concat(this.outEdges(t,r))}}function a(o,t){o[t]?o[t]++:o[t]=1}function i(o,t){--o[t]||delete o[t]}function e(o,t,r,h){var m=""+t,E=""+r;if(!o&&m>E){var x=m;m=E,E=x}return m+l+E+l+(h===void 0?u:h)}function s(o,t,r,h){var m=""+t,E=""+r;if(!o&&m>E){var x=m;m=E,E=x}var p={v:m,w:E};return h&&(p.name=h),p}function n(o,t){return e(o,t.v,t.w,t.name)}return de=d,de}var le,ot;function gr(){return ot||(ot=1,le="2.2.4"),le}var ue,dt;function vr(){return dt||(dt=1,ue={Graph:rt(),version:gr()}),ue}var ce,lt;function wr(){if(lt)return ce;lt=1;var u=rt();ce={write:c,read:a};function c(i){var e={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:l(i),edges:d(i)};return i.graph()!==void 0&&(e.value=structuredClone(i.graph())),e}function l(i){return i.nodes().map(function(e){var s=i.node(e),n=i.parent(e),o={v:e};return s!==void 0&&(o.value=s),n!==void 0&&(o.parent=n),o})}function d(i){return i.edges().map(function(e){var s=i.edge(e),n={v:e.v,w:e.w};return e.name!==void 0&&(n.name=e.name),s!==void 0&&(n.value=s),n})}function a(i){var e=new u(i.options).setGraph(i.value);return i.nodes.forEach(function(s){e.setNode(s.v,s.value),s.parent&&e.setParent(s.v,s.parent)}),i.edges.forEach(function(s){e.setEdge({v:s.v,w:s.w,name:s.name},s.value)}),e}return ce}var he,ut;function Er(){if(ut)return he;ut=1,he=u;function u(c){var l={},d=[],a;function i(e){Object.hasOwn(l,e)||(l[e]=!0,a.push(e),c.successors(e).forEach(i),c.predecessors(e).forEach(i))}return c.nodes().forEach(function(e){a=[],i(e),a.length&&d.push(a)}),d}return he}var fe,ct;function nr(){if(ct)return fe;ct=1;class u{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(l){return l.key})}has(l){return Object.hasOwn(this._keyIndices,l)}priority(l){var d=this._keyIndices[l];if(d!==void 0)return this._arr[d].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(l,d){var a=this._keyIndices;if(l=String(l),!Object.hasOwn(a,l)){var i=this._arr,e=i.length;return a[l]=e,i.push({key:l,priority:d}),this._decrease(e),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var l=this._arr.pop();return delete this._keyIndices[l.key],this._heapify(0),l.key}decrease(l,d){var a=this._keyIndices[l];if(d>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+l+" Old: "+this._arr[a].priority+" New: "+d);this._arr[a].priority=d,this._decrease(a)}_heapify(l){var d=this._arr,a=2*l,i=a+1,e=l;a<d.length&&(e=d[a].priority<d[e].priority?a:e,i<d.length&&(e=d[i].priority<d[e].priority?i:e),e!==l&&(this._swap(l,e),this._heapify(e)))}_decrease(l){for(var d=this._arr,a=d[l].priority,i;l!==0&&(i=l>>1,!(d[i].priority<a));)this._swap(l,i),l=i}_swap(l,d){var a=this._arr,i=this._keyIndices,e=a[l],s=a[d];a[l]=s,a[d]=e,i[s.key]=l,i[e.key]=d}}return fe=u,fe}var pe,ht;function ir(){if(ht)return pe;ht=1;var u=nr();pe=l;var c=()=>1;function l(a,i,e,s){return d(a,String(i),e||c,s||function(n){return a.outEdges(n)})}function d(a,i,e,s){var n={},o=new u,t,r,h=function(m){var E=m.v!==t?m.v:m.w,x=n[E],p=e(m),w=r.distance+p;if(p<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+p);w<x.distance&&(x.distance=w,x.predecessor=t,o.decrease(E,w))};for(a.nodes().forEach(function(m){var E=m===i?0:Number.POSITIVE_INFINITY;n[m]={distance:E},o.add(m,E)});o.size()>0&&(t=o.removeMin(),r=n[t],r.distance!==Number.POSITIVE_INFINITY);)s(t).forEach(h);return n}return pe}var me,ft;function _r(){if(ft)return me;ft=1;var u=ir();me=c;function c(l,d,a){return l.nodes().reduce(function(i,e){return i[e]=u(l,e,d,a),i},{})}return me}var be,pt;function ar(){if(pt)return be;pt=1,be=u;function u(c){var l=0,d=[],a={},i=[];function e(s){var n=a[s]={onStack:!0,lowlink:l,index:l++};if(d.push(s),c.successors(s).forEach(function(r){Object.hasOwn(a,r)?a[r].onStack&&(n.lowlink=Math.min(n.lowlink,a[r].index)):(e(r),n.lowlink=Math.min(n.lowlink,a[r].lowlink))}),n.lowlink===n.index){var o=[],t;do t=d.pop(),a[t].onStack=!1,o.push(t);while(s!==t);i.push(o)}}return c.nodes().forEach(function(s){Object.hasOwn(a,s)||e(s)}),i}return be}var ge,mt;function yr(){if(mt)return ge;mt=1;var u=ar();ge=c;function c(l){return u(l).filter(function(d){return d.length>1||d.length===1&&l.hasEdge(d[0],d[0])})}return ge}var ve,bt;function kr(){if(bt)return ve;bt=1,ve=c;var u=()=>1;function c(d,a,i){return l(d,a||u,i||function(e){return d.outEdges(e)})}function l(d,a,i){var e={},s=d.nodes();return s.forEach(function(n){e[n]={},e[n][n]={distance:0},s.forEach(function(o){n!==o&&(e[n][o]={distance:Number.POSITIVE_INFINITY})}),i(n).forEach(function(o){var t=o.v===n?o.w:o.v,r=a(o);e[n][t]={distance:r,predecessor:n}})}),s.forEach(function(n){var o=e[n];s.forEach(function(t){var r=e[t];s.forEach(function(h){var m=r[n],E=o[h],x=r[h],p=m.distance+E.distance;p<x.distance&&(x.distance=p,x.predecessor=E.predecessor)})})}),e}return ve}var we,gt;function sr(){if(gt)return we;gt=1;function u(l){var d={},a={},i=[];function e(s){if(Object.hasOwn(a,s))throw new c;Object.hasOwn(d,s)||(a[s]=!0,d[s]=!0,l.predecessors(s).forEach(e),delete a[s],i.push(s))}if(l.sinks().forEach(e),Object.keys(d).length!==l.nodeCount())throw new c;return i}class c extends Error{constructor(){super(...arguments)}}return we=u,u.CycleException=c,we}var Ee,vt;function Or(){if(vt)return Ee;vt=1;var u=sr();Ee=c;function c(l){try{u(l)}catch(d){if(d instanceof u.CycleException)return!1;throw d}return!0}return Ee}var _e,wt;function or(){if(wt)return _e;wt=1,_e=u;function u(a,i,e){Array.isArray(i)||(i=[i]);var s=a.isDirected()?r=>a.successors(r):r=>a.neighbors(r),n=e==="post"?c:l,o=[],t={};return i.forEach(r=>{if(!a.hasNode(r))throw new Error("Graph does not have node: "+r);n(r,s,t,o)}),o}function c(a,i,e,s){for(var n=[[a,!1]];n.length>0;){var o=n.pop();o[1]?s.push(o[0]):Object.hasOwn(e,o[0])||(e[o[0]]=!0,n.push([o[0],!0]),d(i(o[0]),t=>n.push([t,!1])))}}function l(a,i,e,s){for(var n=[a];n.length>0;){var o=n.pop();Object.hasOwn(e,o)||(e[o]=!0,s.push(o),d(i(o),t=>n.push(t)))}}function d(a,i){for(var e=a.length;e--;)i(a[e],e,a);return a}return _e}var ye,Et;function Nr(){if(Et)return ye;Et=1;var u=or();ye=c;function c(l,d){return u(l,d,"post")}return ye}var ke,_t;function xr(){if(_t)return ke;_t=1;var u=or();ke=c;function c(l,d){return u(l,d,"pre")}return ke}var Oe,yt;function jr(){if(yt)return Oe;yt=1;var u=rt(),c=nr();Oe=l;function l(d,a){var i=new u,e={},s=new c,n;function o(r){var h=r.v===n?r.w:r.v,m=s.priority(h);if(m!==void 0){var E=a(r);E<m&&(e[h]=n,s.decrease(h,E))}}if(d.nodeCount()===0)return i;d.nodes().forEach(function(r){s.add(r,Number.POSITIVE_INFINITY),i.setNode(r)}),s.decrease(d.nodes()[0],0);for(var t=!1;s.size()>0;){if(n=s.removeMin(),Object.hasOwn(e,n))i.setEdge(n,e[n]);else{if(t)throw new Error("Input graph is not connected: "+d);t=!0}d.nodeEdges(n).forEach(o)}return i}return Oe}var Ne,kt;function Cr(){return kt||(kt=1,Ne={components:Er(),dijkstra:ir(),dijkstraAll:_r(),findCycles:yr(),floydWarshall:kr(),isAcyclic:Or(),postorder:Nr(),preorder:xr(),prim:jr(),tarjan:ar(),topsort:sr()}),Ne}var xe,Ot;function U(){if(Ot)return xe;Ot=1;var u=vr();return xe={Graph:u.Graph,json:wr(),alg:Cr(),version:u.version},xe}var je,Nt;function Rr(){if(Nt)return je;Nt=1;class u{constructor(){let a={};a._next=a._prev=a,this._sentinel=a}dequeue(){let a=this._sentinel,i=a._prev;if(i!==a)return c(i),i}enqueue(a){let i=this._sentinel;a._prev&&a._next&&c(a),a._next=i._next,i._next._prev=a,i._next=a,a._prev=i}toString(){let a=[],i=this._sentinel,e=i._prev;for(;e!==i;)a.push(JSON.stringify(e,l)),e=e._prev;return"["+a.join(", ")+"]"}}function c(d){d._prev._next=d._next,d._next._prev=d._prev,delete d._next,delete d._prev}function l(d,a){if(d!=="_next"&&d!=="_prev")return a}return je=u,je}var Ce,xt;function Ir(){if(xt)return Ce;xt=1;let u=U().Graph,c=Rr();Ce=d;let l=()=>1;function d(o,t){if(o.nodeCount()<=1)return[];let r=e(o,t||l);return a(r.graph,r.buckets,r.zeroIdx).flatMap(m=>o.outEdges(m.v,m.w))}function a(o,t,r){let h=[],m=t[t.length-1],E=t[0],x;for(;o.nodeCount();){for(;x=E.dequeue();)i(o,t,r,x);for(;x=m.dequeue();)i(o,t,r,x);if(o.nodeCount()){for(let p=t.length-2;p>0;--p)if(x=t[p].dequeue(),x){h=h.concat(i(o,t,r,x,!0));break}}}return h}function i(o,t,r,h,m){let E=m?[]:void 0;return o.inEdges(h.v).forEach(x=>{let p=o.edge(x),w=o.node(x.v);m&&E.push({v:x.v,w:x.w}),w.out-=p,s(t,r,w)}),o.outEdges(h.v).forEach(x=>{let p=o.edge(x),w=x.w,b=o.node(w);b.in-=p,s(t,r,b)}),o.removeNode(h.v),E}function e(o,t){let r=new u,h=0,m=0;o.nodes().forEach(p=>{r.setNode(p,{v:p,in:0,out:0})}),o.edges().forEach(p=>{let w=r.edge(p.v,p.w)||0,b=t(p),y=w+b;r.setEdge(p.v,p.w,y),m=Math.max(m,r.node(p.v).out+=b),h=Math.max(h,r.node(p.w).in+=b)});let E=n(m+h+3).map(()=>new c),x=h+1;return r.nodes().forEach(p=>{s(E,x,r.node(p))}),{graph:r,buckets:E,zeroIdx:x}}function s(o,t,r){r.out?r.in?o[r.out-r.in+t].enqueue(r):o[o.length-1].enqueue(r):o[0].enqueue(r)}function n(o){const t=[];for(let r=0;r<o;r++)t.push(r);return t}return Ce}var Re,jt;function V(){if(jt)return Re;jt=1;let u=U().Graph;Re={addBorderNode:t,addDummyNode:c,applyWithChunking:m,asNonCompoundGraph:d,buildLayerMatrix:s,intersectRect:e,mapValues:I,maxRank:E,normalizeRanks:n,notime:w,partition:x,pick:C,predecessorWeights:i,range:O,removeEmptyRanks:o,simplify:l,successorWeights:a,time:p,uniqueId:y,zipObject:L};function c(f,g,_,k){for(var j=k;f.hasNode(j);)j=y(k);return _.dummy=g,f.setNode(j,_),j}function l(f){let g=new u().setGraph(f.graph());return f.nodes().forEach(_=>g.setNode(_,f.node(_))),f.edges().forEach(_=>{let k=g.edge(_.v,_.w)||{weight:0,minlen:1},j=f.edge(_);g.setEdge(_.v,_.w,{weight:k.weight+j.weight,minlen:Math.max(k.minlen,j.minlen)})}),g}function d(f){let g=new u({multigraph:f.isMultigraph()}).setGraph(f.graph());return f.nodes().forEach(_=>{f.children(_).length||g.setNode(_,f.node(_))}),f.edges().forEach(_=>{g.setEdge(_,f.edge(_))}),g}function a(f){let g=f.nodes().map(_=>{let k={};return f.outEdges(_).forEach(j=>{k[j.w]=(k[j.w]||0)+f.edge(j).weight}),k});return L(f.nodes(),g)}function i(f){let g=f.nodes().map(_=>{let k={};return f.inEdges(_).forEach(j=>{k[j.v]=(k[j.v]||0)+f.edge(j).weight}),k});return L(f.nodes(),g)}function e(f,g){let _=f.x,k=f.y,j=g.x-_,S=g.y-k,T=f.width/2,D=f.height/2;if(!j&&!S)throw new Error("Not possible to find intersection inside of the rectangle");let H,z;return Math.abs(S)*T>Math.abs(j)*D?(S<0&&(D=-D),H=D*j/S,z=D):(j<0&&(T=-T),H=T,z=T*S/j),{x:_+H,y:k+z}}function s(f){let g=O(E(f)+1).map(()=>[]);return f.nodes().forEach(_=>{let k=f.node(_),j=k.rank;j!==void 0&&(g[j][k.order]=_)}),g}function n(f){let g=f.nodes().map(k=>{let j=f.node(k).rank;return j===void 0?Number.MAX_VALUE:j}),_=m(Math.min,g);f.nodes().forEach(k=>{let j=f.node(k);Object.hasOwn(j,"rank")&&(j.rank-=_)})}function o(f){let g=f.nodes().map(T=>f.node(T).rank),_=m(Math.min,g),k=[];f.nodes().forEach(T=>{let D=f.node(T).rank-_;k[D]||(k[D]=[]),k[D].push(T)});let j=0,S=f.graph().nodeRankFactor;Array.from(k).forEach((T,D)=>{T===void 0&&D%S!==0?--j:T!==void 0&&j&&T.forEach(H=>f.node(H).rank+=j)})}function t(f,g,_,k){let j={width:0,height:0};return arguments.length>=4&&(j.rank=_,j.order=k),c(f,"border",j,g)}function r(f,g=h){const _=[];for(let k=0;k<f.length;k+=g){const j=f.slice(k,k+g);_.push(j)}return _}const h=65535;function m(f,g){if(g.length>h){const _=r(g);return f.apply(null,_.map(k=>f.apply(null,k)))}else return f.apply(null,g)}function E(f){const _=f.nodes().map(k=>{let j=f.node(k).rank;return j===void 0?Number.MIN_VALUE:j});return m(Math.max,_)}function x(f,g){let _={lhs:[],rhs:[]};return f.forEach(k=>{g(k)?_.lhs.push(k):_.rhs.push(k)}),_}function p(f,g){let _=Date.now();try{return g()}finally{console.log(f+" time: "+(Date.now()-_)+"ms")}}function w(f,g){return g()}let b=0;function y(f){var g=++b;return f+(""+g)}function O(f,g,_=1){g==null&&(g=f,f=0);let k=S=>S<g;_<0&&(k=S=>g<S);const j=[];for(let S=f;k(S);S+=_)j.push(S);return j}function C(f,g){const _={};for(const k of g)f[k]!==void 0&&(_[k]=f[k]);return _}function I(f,g){let _=g;return typeof g=="string"&&(_=k=>k[g]),Object.entries(f).reduce((k,[j,S])=>(k[j]=_(S,j),k),{})}function L(f,g){return f.reduce((_,k,j)=>(_[k]=g[j],_),{})}return Re}var Ie,Ct;function Lr(){if(Ct)return Ie;Ct=1;let u=Ir(),c=V().uniqueId;Ie={run:l,undo:a};function l(i){(i.graph().acyclicer==="greedy"?u(i,s(i)):d(i)).forEach(n=>{let o=i.edge(n);i.removeEdge(n),o.forwardName=n.name,o.reversed=!0,i.setEdge(n.w,n.v,o,c("rev"))});function s(n){return o=>n.edge(o).weight}}function d(i){let e=[],s={},n={};function o(t){Object.hasOwn(n,t)||(n[t]=!0,s[t]=!0,i.outEdges(t).forEach(r=>{Object.hasOwn(s,r.w)?e.push(r):o(r.w)}),delete s[t])}return i.nodes().forEach(o),e}function a(i){i.edges().forEach(e=>{let s=i.edge(e);if(s.reversed){i.removeEdge(e);let n=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(e.w,e.v,s,n)}})}return Ie}var Le,Rt;function qr(){if(Rt)return Le;Rt=1;let u=V();Le={run:c,undo:d};function c(a){a.graph().dummyChains=[],a.edges().forEach(i=>l(a,i))}function l(a,i){let e=i.v,s=a.node(e).rank,n=i.w,o=a.node(n).rank,t=i.name,r=a.edge(i),h=r.labelRank;if(o===s+1)return;a.removeEdge(i);let m,E,x;for(x=0,++s;s<o;++x,++s)r.points=[],E={width:0,height:0,edgeLabel:r,edgeObj:i,rank:s},m=u.addDummyNode(a,"edge",E,"_d"),s===h&&(E.width=r.width,E.height=r.height,E.dummy="edge-label",E.labelpos=r.labelpos),a.setEdge(e,m,{weight:r.weight},t),x===0&&a.graph().dummyChains.push(m),e=m;a.setEdge(e,n,{weight:r.weight},t)}function d(a){a.graph().dummyChains.forEach(i=>{let e=a.node(i),s=e.edgeLabel,n;for(a.setEdge(e.edgeObj,s);e.dummy;)n=a.successors(i)[0],a.removeNode(i),s.points.push({x:e.x,y:e.y}),e.dummy==="edge-label"&&(s.x=e.x,s.y=e.y,s.width=e.width,s.height=e.height),i=n,e=a.node(i)})}return Le}var qe,It;function ee(){if(It)return qe;It=1;const{applyWithChunking:u}=V();qe={longestPath:c,slack:l};function c(d){var a={};function i(e){var s=d.node(e);if(Object.hasOwn(a,e))return s.rank;a[e]=!0;let n=d.outEdges(e).map(t=>t==null?Number.POSITIVE_INFINITY:i(t.w)-d.edge(t).minlen);var o=u(Math.min,n);return o===Number.POSITIVE_INFINITY&&(o=0),s.rank=o}d.sources().forEach(i)}function l(d,a){return d.node(a.w).rank-d.node(a.v).rank-d.edge(a).minlen}return qe}var Se,Lt;function dr(){if(Lt)return Se;Lt=1;var u=U().Graph,c=ee().slack;Se=l;function l(e){var s=new u({directed:!1}),n=e.nodes()[0],o=e.nodeCount();s.setNode(n,{});for(var t,r;d(s,e)<o;)t=a(s,e),r=s.hasNode(t.v)?c(e,t):-c(e,t),i(s,e,r);return s}function d(e,s){function n(o){s.nodeEdges(o).forEach(t=>{var r=t.v,h=o===r?t.w:r;!e.hasNode(h)&&!c(s,t)&&(e.setNode(h,{}),e.setEdge(o,h,{}),n(h))})}return e.nodes().forEach(n),e.nodeCount()}function a(e,s){return s.edges().reduce((o,t)=>{let r=Number.POSITIVE_INFINITY;return e.hasNode(t.v)!==e.hasNode(t.w)&&(r=c(s,t)),r<o[0]?[r,t]:o},[Number.POSITIVE_INFINITY,null])[1]}function i(e,s,n){e.nodes().forEach(o=>s.node(o).rank+=n)}return Se}var Te,qt;function Sr(){if(qt)return Te;qt=1;var u=dr(),c=ee().slack,l=ee().longestPath,d=U().alg.preorder,a=U().alg.postorder,i=V().simplify;Te=e,e.initLowLimValues=t,e.initCutValues=s,e.calcCutValue=o,e.leaveEdge=h,e.enterEdge=m,e.exchangeEdges=E;function e(b){b=i(b),l(b);var y=u(b);t(y),s(y,b);for(var O,C;O=h(y);)C=m(y,b,O),E(y,b,O,C)}function s(b,y){var O=a(b,b.nodes());O=O.slice(0,O.length-1),O.forEach(C=>n(b,y,C))}function n(b,y,O){var C=b.node(O),I=C.parent;b.edge(O,I).cutvalue=o(b,y,O)}function o(b,y,O){var C=b.node(O),I=C.parent,L=!0,f=y.edge(O,I),g=0;return f||(L=!1,f=y.edge(I,O)),g=f.weight,y.nodeEdges(O).forEach(_=>{var k=_.v===O,j=k?_.w:_.v;if(j!==I){var S=k===L,T=y.edge(_).weight;if(g+=S?T:-T,p(b,O,j)){var D=b.edge(O,j).cutvalue;g+=S?-D:D}}}),g}function t(b,y){arguments.length<2&&(y=b.nodes()[0]),r(b,{},1,y)}function r(b,y,O,C,I){var L=O,f=b.node(C);return y[C]=!0,b.neighbors(C).forEach(g=>{Object.hasOwn(y,g)||(O=r(b,y,O,g,C))}),f.low=L,f.lim=O++,I?f.parent=I:delete f.parent,O}function h(b){return b.edges().find(y=>b.edge(y).cutvalue<0)}function m(b,y,O){var C=O.v,I=O.w;y.hasEdge(C,I)||(C=O.w,I=O.v);var L=b.node(C),f=b.node(I),g=L,_=!1;L.lim>f.lim&&(g=f,_=!0);var k=y.edges().filter(j=>_===w(b,b.node(j.v),g)&&_!==w(b,b.node(j.w),g));return k.reduce((j,S)=>c(y,S)<c(y,j)?S:j)}function E(b,y,O,C){var I=O.v,L=O.w;b.removeEdge(I,L),b.setEdge(C.v,C.w,{}),t(b),s(b,y),x(b,y)}function x(b,y){var O=b.nodes().find(I=>!y.node(I).parent),C=d(b,O);C=C.slice(1),C.forEach(I=>{var L=b.node(I).parent,f=y.edge(I,L),g=!1;f||(f=y.edge(L,I),g=!0),y.node(I).rank=y.node(L).rank+(g?f.minlen:-f.minlen)})}function p(b,y,O){return b.hasEdge(y,O)}function w(b,y,O){return O.low<=y.lim&&y.lim<=O.lim}return Te}var Pe,St;function Tr(){if(St)return Pe;St=1;var u=ee(),c=u.longestPath,l=dr(),d=Sr();Pe=a;function a(n){var o=n.graph().ranker;if(o instanceof Function)return o(n);switch(n.graph().ranker){case"network-simplex":s(n);break;case"tight-tree":e(n);break;case"longest-path":i(n);break;case"none":break;default:s(n)}}var i=c;function e(n){c(n),l(n)}function s(n){d(n)}return Pe}var Me,Tt;function Pr(){if(Tt)return Me;Tt=1,Me=u;function u(d){let a=l(d);d.graph().dummyChains.forEach(i=>{let e=d.node(i),s=e.edgeObj,n=c(d,a,s.v,s.w),o=n.path,t=n.lca,r=0,h=o[r],m=!0;for(;i!==s.w;){if(e=d.node(i),m){for(;(h=o[r])!==t&&d.node(h).maxRank<e.rank;)r++;h===t&&(m=!1)}if(!m){for(;r<o.length-1&&d.node(h=o[r+1]).minRank<=e.rank;)r++;h=o[r]}d.setParent(i,h),i=d.successors(i)[0]}})}function c(d,a,i,e){let s=[],n=[],o=Math.min(a[i].low,a[e].low),t=Math.max(a[i].lim,a[e].lim),r,h;r=i;do r=d.parent(r),s.push(r);while(r&&(a[r].low>o||t>a[r].lim));for(h=r,r=e;(r=d.parent(r))!==h;)n.push(r);return{path:s.concat(n.reverse()),lca:h}}function l(d){let a={},i=0;function e(s){let n=i;d.children(s).forEach(e),a[s]={low:n,lim:i++}}return d.children().forEach(e),a}return Me}var De,Pt;function Mr(){if(Pt)return De;Pt=1;let u=V();De={run:c,cleanup:i};function c(e){let s=u.addDummyNode(e,"root",{},"_root"),n=d(e),o=Object.values(n),t=u.applyWithChunking(Math.max,o)-1,r=2*t+1;e.graph().nestingRoot=s,e.edges().forEach(m=>e.edge(m).minlen*=r);let h=a(e)+1;e.children().forEach(m=>l(e,s,r,h,t,n,m)),e.graph().nodeRankFactor=r}function l(e,s,n,o,t,r,h){let m=e.children(h);if(!m.length){h!==s&&e.setEdge(s,h,{weight:0,minlen:n});return}let E=u.addBorderNode(e,"_bt"),x=u.addBorderNode(e,"_bb"),p=e.node(h);e.setParent(E,h),p.borderTop=E,e.setParent(x,h),p.borderBottom=x,m.forEach(w=>{l(e,s,n,o,t,r,w);let b=e.node(w),y=b.borderTop?b.borderTop:w,O=b.borderBottom?b.borderBottom:w,C=b.borderTop?o:2*o,I=y!==O?1:t-r[h]+1;e.setEdge(E,y,{weight:C,minlen:I,nestingEdge:!0}),e.setEdge(O,x,{weight:C,minlen:I,nestingEdge:!0})}),e.parent(h)||e.setEdge(s,E,{weight:0,minlen:t+r[h]})}function d(e){var s={};function n(o,t){var r=e.children(o);r&&r.length&&r.forEach(h=>n(h,t+1)),s[o]=t}return e.children().forEach(o=>n(o,1)),s}function a(e){return e.edges().reduce((s,n)=>s+e.edge(n).weight,0)}function i(e){var s=e.graph();e.removeNode(s.nestingRoot),delete s.nestingRoot,e.edges().forEach(n=>{var o=e.edge(n);o.nestingEdge&&e.removeEdge(n)})}return De}var Fe,Mt;function Dr(){if(Mt)return Fe;Mt=1;let u=V();Fe=c;function c(d){function a(i){let e=d.children(i),s=d.node(i);if(e.length&&e.forEach(a),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let n=s.minRank,o=s.maxRank+1;n<o;++n)l(d,"borderLeft","_bl",i,s,n),l(d,"borderRight","_br",i,s,n)}}d.children().forEach(a)}function l(d,a,i,e,s,n){let o={width:0,height:0,rank:n,borderType:a},t=s[a][n-1],r=u.addDummyNode(d,"border",o,i);s[a][n]=r,d.setParent(r,e),t&&d.setEdge(t,r,{weight:1})}return Fe}var Ae,Dt;function Fr(){if(Dt)return Ae;Dt=1,Ae={adjust:u,undo:c};function u(n){let o=n.graph().rankdir.toLowerCase();(o==="lr"||o==="rl")&&l(n)}function c(n){let o=n.graph().rankdir.toLowerCase();(o==="bt"||o==="rl")&&a(n),(o==="lr"||o==="rl")&&(e(n),l(n))}function l(n){n.nodes().forEach(o=>d(n.node(o))),n.edges().forEach(o=>d(n.edge(o)))}function d(n){let o=n.width;n.width=n.height,n.height=o}function a(n){n.nodes().forEach(o=>i(n.node(o))),n.edges().forEach(o=>{let t=n.edge(o);t.points.forEach(i),Object.hasOwn(t,"y")&&i(t)})}function i(n){n.y=-n.y}function e(n){n.nodes().forEach(o=>s(n.node(o))),n.edges().forEach(o=>{let t=n.edge(o);t.points.forEach(s),Object.hasOwn(t,"x")&&s(t)})}function s(n){let o=n.x;n.x=n.y,n.y=o}return Ae}var Ge,Ft;function Ar(){if(Ft)return Ge;Ft=1;let u=V();Ge=c;function c(l){let d={},a=l.nodes().filter(t=>!l.children(t).length),i=a.map(t=>l.node(t).rank),e=u.applyWithChunking(Math.max,i),s=u.range(e+1).map(()=>[]);function n(t){if(d[t])return;d[t]=!0;let r=l.node(t);s[r.rank].push(t),l.successors(t).forEach(n)}return a.sort((t,r)=>l.node(t).rank-l.node(r).rank).forEach(n),s}return Ge}var Ve,At;function Gr(){if(At)return Ve;At=1;let u=V().zipObject;Ve=c;function c(d,a){let i=0;for(let e=1;e<a.length;++e)i+=l(d,a[e-1],a[e]);return i}function l(d,a,i){let e=u(i,i.map((h,m)=>m)),s=a.flatMap(h=>d.outEdges(h).map(m=>({pos:e[m.w],weight:d.edge(m).weight})).sort((m,E)=>m.pos-E.pos)),n=1;for(;n<i.length;)n<<=1;let o=2*n-1;n-=1;let t=new Array(o).fill(0),r=0;return s.forEach(h=>{let m=h.pos+n;t[m]+=h.weight;let E=0;for(;m>0;)m%2&&(E+=t[m+1]),m=m-1>>1,t[m]+=h.weight;r+=h.weight*E}),r}return Ve}var Be,Gt;function Vr(){if(Gt)return Be;Gt=1,Be=u;function u(c,l=[]){return l.map(d=>{let a=c.inEdges(d);if(a.length){let i=a.reduce((e,s)=>{let n=c.edge(s),o=c.node(s.v);return{sum:e.sum+n.weight*o.order,weight:e.weight+n.weight}},{sum:0,weight:0});return{v:d,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:d}})}return Be}var We,Vt;function Br(){if(Vt)return We;Vt=1;let u=V();We=c;function c(a,i){let e={};a.forEach((n,o)=>{let t=e[n.v]={indegree:0,in:[],out:[],vs:[n.v],i:o};n.barycenter!==void 0&&(t.barycenter=n.barycenter,t.weight=n.weight)}),i.edges().forEach(n=>{let o=e[n.v],t=e[n.w];o!==void 0&&t!==void 0&&(t.indegree++,o.out.push(e[n.w]))});let s=Object.values(e).filter(n=>!n.indegree);return l(s)}function l(a){let i=[];function e(n){return o=>{o.merged||(o.barycenter===void 0||n.barycenter===void 0||o.barycenter>=n.barycenter)&&d(n,o)}}function s(n){return o=>{o.in.push(n),--o.indegree===0&&a.push(o)}}for(;a.length;){let n=a.pop();i.push(n),n.in.reverse().forEach(e(n)),n.out.forEach(s(n))}return i.filter(n=>!n.merged).map(n=>u.pick(n,["vs","i","barycenter","weight"]))}function d(a,i){let e=0,s=0;a.weight&&(e+=a.barycenter*a.weight,s+=a.weight),i.weight&&(e+=i.barycenter*i.weight,s+=i.weight),a.vs=i.vs.concat(a.vs),a.barycenter=e/s,a.weight=s,a.i=Math.min(i.i,a.i),i.merged=!0}return We}var He,Bt;function Wr(){if(Bt)return He;Bt=1;let u=V();He=c;function c(a,i){let e=u.partition(a,E=>Object.hasOwn(E,"barycenter")),s=e.lhs,n=e.rhs.sort((E,x)=>x.i-E.i),o=[],t=0,r=0,h=0;s.sort(d(!!i)),h=l(o,n,h),s.forEach(E=>{h+=E.vs.length,o.push(E.vs),t+=E.barycenter*E.weight,r+=E.weight,h=l(o,n,h)});let m={vs:o.flat(!0)};return r&&(m.barycenter=t/r,m.weight=r),m}function l(a,i,e){let s;for(;i.length&&(s=i[i.length-1]).i<=e;)i.pop(),a.push(s.vs),e++;return e}function d(a){return(i,e)=>i.barycenter<e.barycenter?-1:i.barycenter>e.barycenter?1:a?e.i-i.i:i.i-e.i}return He}var ze,Wt;function Hr(){if(Wt)return ze;Wt=1;let u=Vr(),c=Br(),l=Wr();ze=d;function d(e,s,n,o){let t=e.children(s),r=e.node(s),h=r?r.borderLeft:void 0,m=r?r.borderRight:void 0,E={};h&&(t=t.filter(b=>b!==h&&b!==m));let x=u(e,t);x.forEach(b=>{if(e.children(b.v).length){let y=d(e,b.v,n,o);E[b.v]=y,Object.hasOwn(y,"barycenter")&&i(b,y)}});let p=c(x,n);a(p,E);let w=l(p,o);if(h&&(w.vs=[h,w.vs,m].flat(!0),e.predecessors(h).length)){let b=e.node(e.predecessors(h)[0]),y=e.node(e.predecessors(m)[0]);Object.hasOwn(w,"barycenter")||(w.barycenter=0,w.weight=0),w.barycenter=(w.barycenter*w.weight+b.order+y.order)/(w.weight+2),w.weight+=2}return w}function a(e,s){e.forEach(n=>{n.vs=n.vs.flatMap(o=>s[o]?s[o].vs:o)})}function i(e,s){e.barycenter!==void 0?(e.barycenter=(e.barycenter*e.weight+s.barycenter*s.weight)/(e.weight+s.weight),e.weight+=s.weight):(e.barycenter=s.barycenter,e.weight=s.weight)}return ze}var Ye,Ht;function zr(){if(Ht)return Ye;Ht=1;let u=U().Graph,c=V();Ye=l;function l(a,i,e,s){s||(s=a.nodes());let n=d(a),o=new u({compound:!0}).setGraph({root:n}).setDefaultNodeLabel(t=>a.node(t));return s.forEach(t=>{let r=a.node(t),h=a.parent(t);(r.rank===i||r.minRank<=i&&i<=r.maxRank)&&(o.setNode(t),o.setParent(t,h||n),a[e](t).forEach(m=>{let E=m.v===t?m.w:m.v,x=o.edge(E,t),p=x!==void 0?x.weight:0;o.setEdge(E,t,{weight:a.edge(m).weight+p})}),Object.hasOwn(r,"minRank")&&o.setNode(t,{borderLeft:r.borderLeft[i],borderRight:r.borderRight[i]}))}),o}function d(a){for(var i;a.hasNode(i=c.uniqueId("_root")););return i}return Ye}var $e,zt;function Yr(){if(zt)return $e;zt=1,$e=u;function u(c,l,d){let a={},i;d.forEach(e=>{let s=c.parent(e),n,o;for(;s;){if(n=c.parent(s),n?(o=a[n],a[n]=s):(o=i,i=s),o&&o!==s){l.setEdge(o,s);return}s=n}})}return $e}var Ue,Yt;function $r(){if(Yt)return Ue;Yt=1;let u=Ar(),c=Gr(),l=Hr(),d=zr(),a=Yr(),i=U().Graph,e=V();Ue=s;function s(r,h){if(h&&typeof h.customOrder=="function"){h.customOrder(r,s);return}let m=e.maxRank(r),E=n(r,e.range(1,m+1),"inEdges"),x=n(r,e.range(m-1,-1,-1),"outEdges"),p=u(r);if(t(r,p),h&&h.disableOptimalOrderHeuristic)return;let w=Number.POSITIVE_INFINITY,b;for(let y=0,O=0;O<4;++y,++O){o(y%2?E:x,y%4>=2),p=e.buildLayerMatrix(r);let C=c(r,p);C<w&&(O=0,b=Object.assign({},p),w=C)}t(r,b)}function n(r,h,m){const E=new Map,x=(p,w)=>{E.has(p)||E.set(p,[]),E.get(p).push(w)};for(const p of r.nodes()){const w=r.node(p);if(typeof w.rank=="number"&&x(w.rank,p),typeof w.minRank=="number"&&typeof w.maxRank=="number")for(let b=w.minRank;b<=w.maxRank;b++)b!==w.rank&&x(b,p)}return h.map(function(p){return d(r,p,m,E.get(p)||[])})}function o(r,h){let m=new i;r.forEach(function(E){let x=E.graph().root,p=l(E,x,m,h);p.vs.forEach((w,b)=>E.node(w).order=b),a(E,m,p.vs)})}function t(r,h){Object.values(h).forEach(m=>m.forEach((E,x)=>r.node(E).order=x))}return Ue}var Xe,$t;function Ur(){if($t)return Xe;$t=1;let u=U().Graph,c=V();Xe={positionX:m,findType1Conflicts:l,findType2Conflicts:d,addConflict:i,hasConflict:e,verticalAlignment:s,horizontalCompaction:n,alignCoordinates:r,findSmallestWidthAlignment:t,balance:h};function l(p,w){let b={};function y(O,C){let I=0,L=0,f=O.length,g=C[C.length-1];return C.forEach((_,k)=>{let j=a(p,_),S=j?p.node(j).order:f;(j||_===g)&&(C.slice(L,k+1).forEach(T=>{p.predecessors(T).forEach(D=>{let H=p.node(D),z=H.order;(z<I||S<z)&&!(H.dummy&&p.node(T).dummy)&&i(b,D,T)})}),L=k+1,I=S)}),C}return w.length&&w.reduce(y),b}function d(p,w){let b={};function y(C,I,L,f,g){let _;c.range(I,L).forEach(k=>{_=C[k],p.node(_).dummy&&p.predecessors(_).forEach(j=>{let S=p.node(j);S.dummy&&(S.order<f||S.order>g)&&i(b,j,_)})})}function O(C,I){let L=-1,f,g=0;return I.forEach((_,k)=>{if(p.node(_).dummy==="border"){let j=p.predecessors(_);j.length&&(f=p.node(j[0]).order,y(I,g,k,L,f),g=k,L=f)}y(I,g,I.length,f,C.length)}),I}return w.length&&w.reduce(O),b}function a(p,w){if(p.node(w).dummy)return p.predecessors(w).find(b=>p.node(b).dummy)}function i(p,w,b){if(w>b){let O=w;w=b,b=O}let y=p[w];y||(p[w]=y={}),y[b]=!0}function e(p,w,b){if(w>b){let y=w;w=b,b=y}return!!p[w]&&Object.hasOwn(p[w],b)}function s(p,w,b,y){let O={},C={},I={};return w.forEach(L=>{L.forEach((f,g)=>{O[f]=f,C[f]=f,I[f]=g})}),w.forEach(L=>{let f=-1;L.forEach(g=>{let _=y(g);if(_.length){_=_.sort((j,S)=>I[j]-I[S]);let k=(_.length-1)/2;for(let j=Math.floor(k),S=Math.ceil(k);j<=S;++j){let T=_[j];C[g]===g&&f<I[T]&&!e(b,g,T)&&(C[T]=g,C[g]=O[g]=O[T],f=I[T])}}})}),{root:O,align:C}}function n(p,w,b,y,O){let C={},I=o(p,w,b,O),L=O?"borderLeft":"borderRight";function f(k,j){let S=I.nodes(),T=S.pop(),D={};for(;T;)D[T]?k(T):(D[T]=!0,S.push(T),S=S.concat(j(T))),T=S.pop()}function g(k){C[k]=I.inEdges(k).reduce((j,S)=>Math.max(j,C[S.v]+I.edge(S)),0)}function _(k){let j=I.outEdges(k).reduce((T,D)=>Math.min(T,C[D.w]-I.edge(D)),Number.POSITIVE_INFINITY),S=p.node(k);j!==Number.POSITIVE_INFINITY&&S.borderType!==L&&(C[k]=Math.max(C[k],j))}return f(g,I.predecessors.bind(I)),f(_,I.successors.bind(I)),Object.keys(y).forEach(k=>C[k]=C[b[k]]),C}function o(p,w,b,y){let O=new u,C=p.graph(),I=E(C.nodesep,C.edgesep,y);return w.forEach(L=>{let f;L.forEach(g=>{let _=b[g];if(O.setNode(_),f){var k=b[f],j=O.edge(k,_);O.setEdge(k,_,Math.max(I(p,g,f),j||0))}f=g})}),O}function t(p,w){return Object.values(w).reduce((b,y)=>{let O=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;Object.entries(y).forEach(([L,f])=>{let g=x(p,L)/2;O=Math.max(f+g,O),C=Math.min(f-g,C)});const I=O-C;return I<b[0]&&(b=[I,y]),b},[Number.POSITIVE_INFINITY,null])[1]}function r(p,w){let b=Object.values(w),y=c.applyWithChunking(Math.min,b),O=c.applyWithChunking(Math.max,b);["u","d"].forEach(C=>{["l","r"].forEach(I=>{let L=C+I,f=p[L];if(f===w)return;let g=Object.values(f),_=y-c.applyWithChunking(Math.min,g);I!=="l"&&(_=O-c.applyWithChunking(Math.max,g)),_&&(p[L]=c.mapValues(f,k=>k+_))})})}function h(p,w){return c.mapValues(p.ul,(b,y)=>{if(w)return p[w.toLowerCase()][y];{let O=Object.values(p).map(C=>C[y]).sort((C,I)=>C-I);return(O[1]+O[2])/2}})}function m(p){let w=c.buildLayerMatrix(p),b=Object.assign(l(p,w),d(p,w)),y={},O;["u","d"].forEach(I=>{O=I==="u"?w:Object.values(w).reverse(),["l","r"].forEach(L=>{L==="r"&&(O=O.map(k=>Object.values(k).reverse()));let f=(I==="u"?p.predecessors:p.successors).bind(p),g=s(p,O,b,f),_=n(p,O,g.root,g.align,L==="r");L==="r"&&(_=c.mapValues(_,k=>-k)),y[I+L]=_})});let C=t(p,y);return r(y,C),h(y,p.graph().align)}function E(p,w,b){return(y,O,C)=>{let I=y.node(O),L=y.node(C),f=0,g;if(f+=I.width/2,Object.hasOwn(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":g=-I.width/2;break;case"r":g=I.width/2;break}if(g&&(f+=b?g:-g),g=0,f+=(I.dummy?w:p)/2,f+=(L.dummy?w:p)/2,f+=L.width/2,Object.hasOwn(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":g=L.width/2;break;case"r":g=-L.width/2;break}return g&&(f+=b?g:-g),g=0,f}}function x(p,w){return p.node(w).width}return Xe}var Qe,Ut;function Xr(){if(Ut)return Qe;Ut=1;let u=V(),c=Ur().positionX;Qe=l;function l(a){a=u.asNonCompoundGraph(a),d(a),Object.entries(c(a)).forEach(([i,e])=>a.node(i).x=e)}function d(a){let i=u.buildLayerMatrix(a),e=a.graph().ranksep,s=0;i.forEach(n=>{const o=n.reduce((t,r)=>{const h=a.node(r).height;return t>h?t:h},0);n.forEach(t=>a.node(t).y=s+o/2),s+=o+e})}return Qe}var Ke,Xt;function Qr(){if(Xt)return Ke;Xt=1;let u=Lr(),c=qr(),l=Tr(),d=V().normalizeRanks,a=Pr(),i=V().removeEmptyRanks,e=Mr(),s=Dr(),n=Fr(),o=$r(),t=Xr(),r=V(),h=U().Graph;Ke=m;function m(v,N){let R=N&&N.debugTiming?r.time:r.notime;R("layout",()=>{let q=R(" buildLayoutGraph",()=>f(v));R(" runLayout",()=>E(q,R,N)),R(" updateInputGraph",()=>x(v,q))})}function E(v,N,R){N(" makeSpaceForEdgeLabels",()=>g(v)),N(" removeSelfEdges",()=>J(v)),N(" acyclic",()=>u.run(v)),N(" nestingGraph.run",()=>e.run(v)),N(" rank",()=>l(r.asNonCompoundGraph(v))),N(" injectEdgeLabelProxies",()=>_(v)),N(" removeEmptyRanks",()=>i(v)),N(" nestingGraph.cleanup",()=>e.cleanup(v)),N(" normalizeRanks",()=>d(v)),N(" assignRankMinMax",()=>k(v)),N(" removeEdgeLabelProxies",()=>j(v)),N(" normalize.run",()=>c.run(v)),N(" parentDummyChains",()=>a(v)),N(" addBorderSegments",()=>s(v)),N(" order",()=>o(v,R)),N(" insertSelfEdges",()=>ie(v)),N(" adjustCoordinateSystem",()=>n.adjust(v)),N(" position",()=>t(v)),N(" positionSelfEdges",()=>ae(v)),N(" removeBorderNodes",()=>z(v)),N(" normalize.undo",()=>c.undo(v)),N(" fixupEdgeLabelCoords",()=>D(v)),N(" undoCoordinateSystem",()=>n.undo(v)),N(" translateGraph",()=>S(v)),N(" assignNodeIntersects",()=>T(v)),N(" reversePoints",()=>H(v)),N(" acyclic.undo",()=>u.undo(v))}function x(v,N){v.nodes().forEach(R=>{let q=v.node(R),P=N.node(R);q&&(q.x=P.x,q.y=P.y,q.rank=P.rank,N.children(R).length&&(q.width=P.width,q.height=P.height))}),v.edges().forEach(R=>{let q=v.edge(R),P=N.edge(R);q.points=P.points,Object.hasOwn(P,"x")&&(q.x=P.x,q.y=P.y)}),v.graph().width=N.graph().width,v.graph().height=N.graph().height}let p=["nodesep","edgesep","ranksep","marginx","marginy"],w={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],y=["width","height","rank"],O={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],I={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function f(v){let N=new h({multigraph:!0,compound:!0}),R=oe(v.graph());return N.setGraph(Object.assign({},w,se(R,p),r.pick(R,b))),v.nodes().forEach(q=>{let P=oe(v.node(q));const F=se(P,y);Object.keys(O).forEach(G=>{F[G]===void 0&&(F[G]=O[G])}),N.setNode(q,F),N.setParent(q,v.parent(q))}),v.edges().forEach(q=>{let P=oe(v.edge(q));N.setEdge(q,Object.assign({},I,se(P,C),r.pick(P,L)))}),N}function g(v){let N=v.graph();N.ranksep/=2,v.edges().forEach(R=>{let q=v.edge(R);q.minlen*=2,q.labelpos.toLowerCase()!=="c"&&(N.rankdir==="TB"||N.rankdir==="BT"?q.width+=q.labeloffset:q.height+=q.labeloffset)})}function _(v){v.edges().forEach(N=>{let R=v.edge(N);if(R.width&&R.height){let q=v.node(N.v),F={rank:(v.node(N.w).rank-q.rank)/2+q.rank,e:N};r.addDummyNode(v,"edge-proxy",F,"_ep")}})}function k(v){let N=0;v.nodes().forEach(R=>{let q=v.node(R);q.borderTop&&(q.minRank=v.node(q.borderTop).rank,q.maxRank=v.node(q.borderBottom).rank,N=Math.max(N,q.maxRank))}),v.graph().maxRank=N}function j(v){v.nodes().forEach(N=>{let R=v.node(N);R.dummy==="edge-proxy"&&(v.edge(R.e).labelRank=R.rank,v.removeNode(N))})}function S(v){let N=Number.POSITIVE_INFINITY,R=0,q=Number.POSITIVE_INFINITY,P=0,F=v.graph(),G=F.marginx||0,Y=F.marginy||0;function nt($){let W=$.x,Q=$.y,it=$.width,at=$.height;N=Math.min(N,W-it/2),R=Math.max(R,W+it/2),q=Math.min(q,Q-at/2),P=Math.max(P,Q+at/2)}v.nodes().forEach($=>nt(v.node($))),v.edges().forEach($=>{let W=v.edge($);Object.hasOwn(W,"x")&&nt(W)}),N-=G,q-=Y,v.nodes().forEach($=>{let W=v.node($);W.x-=N,W.y-=q}),v.edges().forEach($=>{let W=v.edge($);W.points.forEach(Q=>{Q.x-=N,Q.y-=q}),Object.hasOwn(W,"x")&&(W.x-=N),Object.hasOwn(W,"y")&&(W.y-=q)}),F.width=R-N+G,F.height=P-q+Y}function T(v){v.edges().forEach(N=>{let R=v.edge(N),q=v.node(N.v),P=v.node(N.w),F,G;R.points?(F=R.points[0],G=R.points[R.points.length-1]):(R.points=[],F=P,G=q),R.points.unshift(r.intersectRect(q,F)),R.points.push(r.intersectRect(P,G))})}function D(v){v.edges().forEach(N=>{let R=v.edge(N);if(Object.hasOwn(R,"x"))switch((R.labelpos==="l"||R.labelpos==="r")&&(R.width-=R.labeloffset),R.labelpos){case"l":R.x-=R.width/2+R.labeloffset;break;case"r":R.x+=R.width/2+R.labeloffset;break}})}function H(v){v.edges().forEach(N=>{let R=v.edge(N);R.reversed&&R.points.reverse()})}function z(v){v.nodes().forEach(N=>{if(v.children(N).length){let R=v.node(N),q=v.node(R.borderTop),P=v.node(R.borderBottom),F=v.node(R.borderLeft[R.borderLeft.length-1]),G=v.node(R.borderRight[R.borderRight.length-1]);R.width=Math.abs(G.x-F.x),R.height=Math.abs(P.y-q.y),R.x=F.x+R.width/2,R.y=q.y+R.height/2}}),v.nodes().forEach(N=>{v.node(N).dummy==="border"&&v.removeNode(N)})}function J(v){v.edges().forEach(N=>{if(N.v===N.w){var R=v.node(N.v);R.selfEdges||(R.selfEdges=[]),R.selfEdges.push({e:N,label:v.edge(N)}),v.removeEdge(N)}})}function ie(v){var N=r.buildLayerMatrix(v);N.forEach(R=>{var q=0;R.forEach((P,F)=>{var G=v.node(P);G.order=F+q,(G.selfEdges||[]).forEach(Y=>{r.addDummyNode(v,"selfedge",{width:Y.label.width,height:Y.label.height,rank:G.rank,order:F+ ++q,e:Y.e,label:Y.label},"_se")}),delete G.selfEdges})})}function ae(v){v.nodes().forEach(N=>{var R=v.node(N);if(R.dummy==="selfedge"){var q=v.node(R.e.v),P=q.x+q.width/2,F=q.y,G=R.x-P,Y=q.height/2;v.setEdge(R.e,R.label),v.removeNode(N),R.label.points=[{x:P+2*G/3,y:F-Y},{x:P+5*G/6,y:F-Y},{x:P+G,y:F},{x:P+5*G/6,y:F+Y},{x:P+2*G/3,y:F+Y}],R.label.x=R.x,R.label.y=R.y}})}function se(v,N){return r.mapValues(r.pick(v,N),Number)}function oe(v){var N={};return v&&Object.entries(v).forEach(([R,q])=>{typeof R=="string"&&(R=R.toLowerCase()),N[R]=q}),N}return Ke}var Je,Qt;function Kr(){if(Qt)return Je;Qt=1;let u=V(),c=U().Graph;Je={debugOrdering:l};function l(d){let a=u.buildLayerMatrix(d),i=new c({compound:!0,multigraph:!0}).setGraph({});return d.nodes().forEach(e=>{i.setNode(e,{label:e}),i.setParent(e,"layer"+d.node(e).rank)}),d.edges().forEach(e=>i.setEdge(e.v,e.w,{},e.name)),a.forEach((e,s)=>{let n="layer"+s;i.setNode(n,{rank:"same"}),e.reduce((o,t)=>(i.setEdge(o,t,{style:"invis"}),t))}),i}return Je}var Ze,Kt;function Jr(){return Kt||(Kt=1,Ze="1.1.8"),Ze}var et,Jt;function Zr(){return Jt||(Jt=1,et={graphlib:U(),layout:Qr(),debug:Kr(),util:{time:V().time,notime:V().notime},version:Jr()}),et}var en=Zr();const Zt=br(en);function lr(u){var c,l,d="";if(typeof u=="string"||typeof u=="number")d+=u;else if(typeof u=="object")if(Array.isArray(u)){var a=u.length;for(c=0;c<a;c++)u[c]&&(l=lr(u[c]))&&(d&&(d+=" "),d+=l)}else for(l in u)u[l]&&(d&&(d+=" "),d+=l);return d}function te(){for(var u,c,l=0,d="",a=arguments.length;l<a;l++)(u=arguments[l])&&(c=lr(u))&&(d&&(d+=" "),d+=c);return d}const ur=A.createContext({tables:{},setTable:()=>{},animatedEdges:[],addAnimatedEdges:()=>{},removeAnimatedEdges:()=>{},refs:[]}),cr=()=>{const u=A.useContext(ur);if(!u)throw new Error("useDbmlRendererContext must be used within a DbmlRendererContext");return u},Z=u=>`table-${u.id}`,tn=u=>{const{schema:c,id:l}=u;return`relation-${c.id}-${l}`};var hr={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},er=A.createContext&&A.createContext(hr),rn=["attr","size","title"];function nn(u,c){if(u==null)return{};var l=an(u,c),d,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(u);for(a=0;a<i.length;a++)d=i[a],!(c.indexOf(d)>=0)&&Object.prototype.propertyIsEnumerable.call(u,d)&&(l[d]=u[d])}return l}function an(u,c){if(u==null)return{};var l={};for(var d in u)if(Object.prototype.hasOwnProperty.call(u,d)){if(c.indexOf(d)>=0)continue;l[d]=u[d]}return l}function re(){return re=Object.assign?Object.assign.bind():function(u){for(var c=1;c<arguments.length;c++){var l=arguments[c];for(var d in l)Object.prototype.hasOwnProperty.call(l,d)&&(u[d]=l[d])}return u},re.apply(this,arguments)}function tr(u,c){var l=Object.keys(u);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(u);c&&(d=d.filter(function(a){return Object.getOwnPropertyDescriptor(u,a).enumerable})),l.push.apply(l,d)}return l}function ne(u){for(var c=1;c<arguments.length;c++){var l=arguments[c]!=null?arguments[c]:{};c%2?tr(Object(l),!0).forEach(function(d){sn(u,d,l[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(u,Object.getOwnPropertyDescriptors(l)):tr(Object(l)).forEach(function(d){Object.defineProperty(u,d,Object.getOwnPropertyDescriptor(l,d))})}return u}function sn(u,c,l){return c=on(c),c in u?Object.defineProperty(u,c,{value:l,enumerable:!0,configurable:!0,writable:!0}):u[c]=l,u}function on(u){var c=dn(u,"string");return typeof c=="symbol"?c:c+""}function dn(u,c){if(typeof u!="object"||!u)return u;var l=u[Symbol.toPrimitive];if(l!==void 0){var d=l.call(u,c);if(typeof d!="object")return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return(c==="string"?String:Number)(u)}function fr(u){return u&&u.map((c,l)=>A.createElement(c.tag,ne({key:l},c.attr),fr(c.child)))}function pr(u){return c=>A.createElement(ln,re({attr:ne({},u.attr)},c),fr(u.child))}function ln(u){var c=l=>{var{attr:d,size:a,title:i}=u,e=nn(u,rn),s=a||l.size||"1em",n;return l.className&&(n=l.className),u.className&&(n=(n?n+" ":"")+u.className),A.createElement("svg",re({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},l.attr,d,e,{className:n,style:ne(ne({color:u.color||l.color},l.style),u.style),height:s,width:s,xmlns:"http://www.w3.org/2000/svg"}),i&&A.createElement("title",null,i),u.children)};return er!==void 0?A.createElement(er.Consumer,null,l=>c(l)):c(hr)}function un(u){return pr({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M336 352c97.2 0 176-78.8 176-176S433.2 0 336 0S160 78.8 160 176c0 18.7 2.9 36.8 8.3 53.7L7 391c-4.5 4.5-7 10.6-7 17l0 80c0 13.3 10.7 24 24 24l80 0c13.3 0 24-10.7 24-24l0-40 40 0c13.3 0 24-10.7 24-24l0-40 40 0c6.4 0 12.5-2.5 17-7l33.3-33.3c16.9 5.4 35 8.3 53.7 8.3zM376 96a40 40 0 1 1 0 80 40 40 0 1 1 0-80z"},child:[]}]})(u)}function cn(u){return pr({attr:{viewBox:"0 0 448 512"},child:[{tag:"path",attr:{d:"M64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l224 0 0-112c0-26.5 21.5-48 48-48l112 0 0-224c0-35.3-28.7-64-64-64L64 32zM448 352l-45.3 0L336 352c-8.8 0-16 7.2-16 16l0 66.7 0 45.3 32-32 64-64 32-32z"},child:[]}]})(u)}const hn="_base_2tvbf_1",fn="_relation-one_2tvbf_15",pn="_relation-many_2tvbf_19",mn="_left_2tvbf_23",bn="_right_2tvbf_27",K={base:hn,relationOne:fn,relationMany:pn,left:mn,right:bn},gn={1:K.relationOne,"*":K.relationMany},vn={left:K.left,right:K.right},wn=u=>{const{relation:c,position:l,...d}=u,a=gn[c],i=vn[l];return M.jsx(X.Handle,{...d,position:l,className:te(K.base,i,a)})},En="_field-container_9xmax_1",_n="_field_9xmax_1",yn="_field-highlighted_9xmax_27",kn="_field-name_9xmax_32",On="_nowrap_9xmax_38",Nn="_label_9xmax_44",xn="_field-name-pk_9xmax_48",jn="_properties_9xmax_63",Cn="_data-type_9xmax_69",Rn="_details_9xmax_73",In="_details-field-name_9xmax_82",Ln="_details-content_9xmax_88",qn="_enum-list_9xmax_94",Sn="_icon_9xmax_104",B={fieldContainer:En,field:_n,fieldHighlighted:yn,fieldName:kn,nowrap:On,label:Nn,fieldNamePk:xn,properties:jn,dataType:Cn,details:Rn,detailsFieldName:In,detailsContent:Ln,enumList:qn,icon:Sn},Tn=u=>{const{field:c}=u,{name:l,type:d,not_null:a,pk:i,note:e,id:s,_enum:n,dbdefault:o}=c,t=X.useEdges(),r=`field-${s}-`,h=t.filter(C=>C.sourceHandle?.startsWith(r)||C.targetHandle?.startsWith(r)),[m,E]=A.useState(!1),{animatedEdges:x,addAnimatedEdges:p,removeAnimatedEdges:w}=cr(),b=h.map(C=>{const I=/field-\d+-(source|target)-(left|right)/,L=C.sourceHandle?.startsWith(r),{sourceHandle:f,targetHandle:g}=C,_=L?f:g,[,k,j]=_?.match(I)||[],S=C.data?.ref;if(!S)return null;const[T,D]=S.endpoints,z=k==="target"?D:T;return M.jsx(wn,{id:_,type:k,position:j==="left"?X.Position.Left:X.Position.Right,relation:z.relation},C.id)}),y=!!e||!!n||!!o;A.useEffect(()=>{m?p(h):w(h)},[m]);const O=A.useMemo(()=>x.some(C=>h.some(I=>I.id===C.id)),[x,h]);return M.jsxs("div",{className:B.fieldContainer,children:[M.jsxs("button",{className:te(B.field,O&&B.fieldHighlighted),type:"button",onMouseEnter:()=>{E(!0)},onMouseLeave:()=>{E(!1)},children:[M.jsx("div",{className:B.label,children:M.jsxs("span",{className:te(B.fieldName,i&&B.fieldNamePk),title:e,children:[l,i&&M.jsx(un,{className:B.icon}),e&&M.jsx(cn,{className:B.icon})]})}),b,M.jsxs("div",{className:B.properties,children:[M.jsx("span",{className:B.dataType,children:M.jsx("code",{children:d?.type_name})}),!!n&&M.jsx("span",{title:"Enum",children:"E"}),a&&M.jsx("span",{title:"Not null",children:"NN"})]})]}),y&&m&&M.jsxs("aside",{className:B.details,children:[M.jsx("div",{className:B.detailsFieldName,children:l}),M.jsxs("div",{className:B.detailsContent,children:[n&&M.jsxs("div",{children:[M.jsxs("div",{className:B.nowrap,children:["ENUM ",n.name]}),M.jsx("ul",{className:B.enumList,children:n.values.map(C=>M.jsx("li",{children:M.jsx("code",{children:C.name})},C.id))})]}),e&&M.jsx("div",{children:e}),o&&M.jsxs("div",{className:B.nowrap,children:["DEFAULT ",M.jsx("code",{children:o?.value})]})]})]})]})},Pn="_table_u74q5_1",Mn="_header_u74q5_9",rr={table:Pn,header:Mn},Dn=u=>{const{data:{table:c}}=u,[l,d]=A.useState(!1),a=A.useRef(null),{setTable:i}=cr(),{fields:e,name:s,schema:n}=c,o=Z(c);return A.useEffect(()=>{if(!a.current||!l)return;const{clientHeight:t,clientWidth:r}=a.current;i(o,{width:r,height:t})},[l]),A.useEffect(()=>{d(!0)},[]),M.jsxs("div",{className:rr.table,ref:a,children:[M.jsx("div",{className:rr.header,children:`${n.name}.${s}`}),e.map(t=>M.jsx(Tn,{field:t},t.id))]})},Fn="_container_ym2nb_1",An="_edge_ym2nb_6",Gn="_edge-animated_ym2nb_10",tt={container:Fn,edge:An,edgeAnimated:Gn},Vn=172,Bn=36,Wn={table:Dn},Hn=u=>{const{content:c}=u,[l,d]=A.useState({}),[a,i]=A.useState([]),e=A.useRef(null),s=A.useMemo(()=>{try{return mr.Parser.parse(c,"dbmlv2")}catch(p){return console.error(p),null}},[c]),n=A.useRef(null),[o,t,r]=X.useNodesState([]),[h,m]=X.useEdgesState([]),E=A.useCallback(p=>p.schemas.reduce(({nodes:b,edges:y},O)=>{const C=O.tables.map(L=>{const f=Z(L),{width:g,height:_}=l[f]||{};return{id:f,type:"table",width:g,height:_,position:{x:0,y:0},data:{table:L},draggable:!0}}),I=O.refs.map(L=>{const{endpoints:f}=L,[g,_]=f,{id:k,table:j}=g.fields[0],{id:S,table:T}=_.fields[0],D=`field-${k}-source`,H=`field-${S}-target`,z=tn(L),J=a.some(ae=>ae.id===z),ie=te(tt.edge,J&&tt.edgeAnimated);return{id:z,source:Z(j),target:Z(T),sourceHandle:D,targetHandle:H,type:"step",data:{ref:L},animated:J,className:ie}});return{nodes:b.concat(C),edges:y.concat(I)}},{nodes:[],edges:[]}),[l,a]),x=A.useCallback((p,w,b="TB")=>{const y=new Zt.graphlib.Graph().setDefaultEdgeLabel(()=>({}));y.setGraph({rankdir:b,nodesep:150,ranksep:150}),p.forEach(L=>{const f=l[L.id]||{width:Vn,height:Bn};y.setNode(L.id,f)}),w.forEach(L=>{y.setEdge(L.source,L.target)}),Zt.layout(y);const O=p.map(L=>{const f=y.node(L.id);return{...L,position:{x:f.x,y:f.y}}}),C=L=>O.find(f=>L===f.id),I=w.map(L=>{const{target:f,source:g}=L,_=C(g),k=C(f);if(!_||!k)return console.error(`cant find source or target node, source: ${g} target: ${f}`),L;const{x:j}=_.position,{x:S}=k.position,T={...L};return j>=S?(T.sourceHandle=`${L.sourceHandle}-left`,T.targetHandle=`${L.targetHandle}-right`):j<S&&(T.sourceHandle=`${L.sourceHandle}-right`,T.targetHandle=`${L.targetHandle}-left`),T});return{nodes:O,edges:I}},[l]);return A.useEffect(()=>{if(!s){t([]);return}const{nodes:p,edges:w}=E(s),{nodes:b,edges:y}=x(p,w);t(b),m(y)},[s,E,x,m,t]),M.jsx(ur,{value:{tables:l,setTable:(p,w)=>{d(b=>({...b,[p]:w}))},refs:h,animatedEdges:a,addAnimatedEdges:p=>{i(w=>[...w,...p])},removeAnimatedEdges:p=>{const w=p.map(b=>b.id);i(b=>b.filter(y=>!w.includes(y.id)))}},children:M.jsx("div",{className:tt.container,children:M.jsxs(X.ReactFlow,{nodes:o,onNodesChange:r,edges:h,fitView:!0,ref:n,nodeTypes:Wn,colorMode:"system",onInit:p=>{e.current=p},children:[M.jsx(X.Background,{}),M.jsx(X.Controls,{}),M.jsx(X.MiniMap,{})]})})})};exports.DbmlRenderer=Hn;
|