!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).XYFlowSystem={})}(this,function(t){"use strict";const e={error001:(t="react")=>`Seems like you have not used zustand provider as an ancestor. Help: https://${t}flow.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:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The 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:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:e,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${t} handle id: "${"source"===t?n:o}", edge id: ${e}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/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.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},n=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],o={"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:t,x:e,y:n})=>`Moved selected node ${t}. New position, x: ${e}, 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 r,i,a;t.ConnectionMode=void 0,(r=t.ConnectionMode||(t.ConnectionMode={})).Strict="strict",r.Loose="loose",t.PanOnScrollMode=void 0,(i=t.PanOnScrollMode||(t.PanOnScrollMode={})).Free="free",i.Vertical="vertical",i.Horizontal="horizontal",t.SelectionMode=void 0,(a=t.SelectionMode||(t.SelectionMode={})).Partial="partial",a.Full="full";var s,u,c;t.ConnectionLineType=void 0,(s=t.ConnectionLineType||(t.ConnectionLineType={})).Bezier="default",s.Straight="straight",s.Step="step",s.SmoothStep="smoothstep",s.SimpleBezier="simplebezier",t.MarkerType=void 0,(u=t.MarkerType||(t.MarkerType={})).Arrow="arrow",u.ArrowClosed="arrowclosed",t.Position=void 0,(c=t.Position||(t.Position={})).Left="left",c.Top="top",c.Right="right",c.Bottom="bottom";const l={[t.Position.Left]:t.Position.Right,[t.Position.Right]:t.Position.Left,[t.Position.Top]:t.Position.Bottom,[t.Position.Bottom]:t.Position.Top};const h=t=>"id"in t&&"source"in t&&"target"in t,d=t=>"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),f=(t,e=[0,0])=>{const{width:n,height:o}=H(t),r=t.origin??e,i=n*r[0],a=o*r[1];return{x:t.position.x-i,y:t.position.y-a}},p=(t,e={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return t.forEach(t=>{(void 0===e.filter||e.filter(t))&&(n=b(n,z(t)),o=!0)}),o?P(n):{x:0,y:0,width:0,height:0}},g=(t,e)=>{const n=new Set;return t.forEach(t=>{n.add(t.id)}),e.filter(t=>n.has(t.source)||n.has(t.target))};function m({nodeId:t,nextPosition:n,nodeLookup:o,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){const s=o.get(t),u=s.parentId?o.get(s.parentId):void 0,{x:c,y:l}=u?u.internals.positionAbsolute:{x:0,y:0},h=s.origin??r;let d=s.extent||i;if("parent"!==s.extent||s.expandParent)u&&D(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);else if(u){const t=u.measured.width,e=u.measured.height;t&&e&&(d=[[c,l],[c+t,l+e]])}else a?.("005",e.error005());const f=D(d)?v(n,d,s.measured):n;return void 0!==s.measured.width&&void 0!==s.measured.height||a?.("015",e.error015()),{position:{x:f.x-c+(s.measured.width??0)*h[0],y:f.y-l+(s.measured.height??0)*h[1]},positionAbsolute:f}}const y=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),v=(t={x:0,y:0},e,n)=>({x:y(t.x,e[0][0],e[1][0]-(n?.width??0)),y:y(t.y,e[0][1],e[1][1]-(n?.height??0))});function x(t,e,n){const{width:o,height:r}=H(n),{x:i,y:a}=n.internals.positionAbsolute;return v(t,[[i,a],[i+o,a+r]],e)}const w=(t,e,n)=>tn?-y(Math.abs(t-n),1,e)/e:0,_=(t,e,n=15,o=40)=>[w(t.x,o,e.width-o)*n,w(t.y,o,e.height-o)*n],b=(t,e)=>({x:Math.min(t.x,e.x),y:Math.min(t.y,e.y),x2:Math.max(t.x2,e.x2),y2:Math.max(t.y2,e.y2)}),M=({x:t,y:e,width:n,height:o})=>({x:t,y:e,x2:t+n,y2:e+o}),P=({x:t,y:e,x2:n,y2:o})=>({x:t,y:e,width:n-t,height:o-e}),E=(t,e=[0,0])=>{const{x:n,y:o}=d(t)?t.internals.positionAbsolute:f(t,e);return{x:n,y:o,width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}},z=(t,e=[0,0])=>{const{x:n,y:o}=d(t)?t.internals.positionAbsolute:f(t,e);return{x:n,y:o,x2:n+(t.measured?.width??t.width??t.initialWidth??0),y2:o+(t.measured?.height??t.height??t.initialHeight??0)}},N=(t,e)=>P(b(M(t),M(e))),S=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),o=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*o)},k=t=>!isNaN(t)&&isFinite(t),I=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),A=({x:t,y:e},[n,o,r],i=!1,a=[1,1])=>{const s={x:(t-n)/r,y:(e-o)/r};return i?I(s,a):s},T=({x:t,y:e},[n,o,r])=>({x:t*r+n,y:e*r+o});function $(t,e){if("number"==typeof t)return Math.floor(.5*(e-e/(1+t)));if("string"==typeof t&&t.endsWith("px")){const e=parseFloat(t);if(!Number.isNaN(e))return Math.floor(e)}if("string"==typeof t&&t.endsWith("%")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(e*n*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}const C=(t,e,n,o,r,i)=>{const a=function(t,e,n){if("string"==typeof t||"number"==typeof t){const o=$(t,n),r=$(t,e);return{top:o,right:r,bottom:o,left:r,x:2*r,y:2*o}}if("object"==typeof t){const o=$(t.top??t.y??0,n),r=$(t.bottom??t.y??0,n),i=$(t.left??t.x??0,e),a=$(t.right??t.x??0,e);return{top:o,right:a,bottom:r,left:i,x:i+a,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}(i,e,n),s=(e-a.x)/t.width,u=(n-a.y)/t.height,c=Math.min(s,u),l=y(c,o,r),h=e/2-(t.x+t.width/2)*l,d=n/2-(t.y+t.height/2)*l,f=function(t,e,n,o,r,i){const{x:a,y:s}=T(t,[e,n,o]),{x:u,y:c}=T({x:t.x+t.width,y:t.y+t.height},[e,n,o]),l=r-u,h=i-c;return{left:Math.floor(a),top:Math.floor(s),right:Math.floor(l),bottom:Math.floor(h)}}(t,h,d,l,e,n),p=Math.min(f.left-a.left,0),g=Math.min(f.top-a.top,0);return{x:h-p+Math.min(f.right-a.right,0),y:d-g+Math.min(f.bottom-a.bottom,0),zoom:l}},O=()=>"undefined"!=typeof navigator&&navigator?.userAgent?.indexOf("Mac")>=0;function D(t){return null!=t&&"parent"!==t}function H(t){return{width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}}function B(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:a}=V(t),s=A({x:i-(r?.left??0),y:a-(r?.top??0)},o),{x:u,y:c}=n?I(s,e):s;return{xSnapped:u,ySnapped:c,...s}}const L=t=>({width:t.offsetWidth,height:t.offsetHeight}),X=t=>t?.getRootNode?.()||window?.document,Y=["INPUT","SELECT","TEXTAREA"];const R=t=>"clientX"in t,V=(t,e)=>{const n=R(t),o=n?t.clientX:t.touches?.[0].clientX,r=n?t.clientY:t.touches?.[0].clientY;return{x:o-(e?.left??0),y:r-(e?.top??0)}},q=(t,e,n,o,r)=>{const i=e.querySelectorAll(`.${t}`);return i&&i.length?Array.from(i).map(e=>{const i=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),type:t,nodeId:r,position:e.getAttribute("data-handlepos"),x:(i.left-n.left)/o,y:(i.top-n.top)/o,...L(e)}}):null};function Z({sourceX:t,sourceY:e,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:a,targetControlY:s}){const u=.125*t+.375*r+.375*a+.125*n,c=.125*e+.375*i+.375*s+.125*o;return[u,c,Math.abs(u-t),Math.abs(c-e)]}function G(t,e){return t>=0?.5*t:25*e*Math.sqrt(-t)}function j({pos:e,x1:n,y1:o,x2:r,y2:i,c:a}){switch(e){case t.Position.Left:return[n-G(n-r,a),o];case t.Position.Right:return[n+G(r-n,a),o];case t.Position.Top:return[n,o-G(o-i,a)];case t.Position.Bottom:return[n,o+G(i-o,a)]}}function W({sourceX:t,sourceY:e,targetX:n,targetY:o}){const r=Math.abs(n-t)/2,i=n`xy-edge__${t}${e||""}-${n}${o||""}`;const K={[t.Position.Left]:{x:-1,y:0},[t.Position.Right]:{x:1,y:0},[t.Position.Top]:{x:0,y:-1},[t.Position.Bottom]:{x:0,y:1}},U=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function Q({source:e,sourcePosition:n=t.Position.Bottom,target:o,targetPosition:r=t.Position.Top,center:i,offset:a,stepPosition:s}){const u=K[n],c=K[r],l={x:e.x+u.x*a,y:e.y+u.y*a},h={x:o.x+c.x*a,y:o.y+c.y*a},d=(({source:e,sourcePosition:n=t.Position.Bottom,target:o})=>n===t.Position.Left||n===t.Position.Right?e.xe[f]?-1:1)*n:x[f]=(h[f]>o[f]?-1:1)*n}}if(n!==r){const e="x"===f?"y":"x",n=u[f]===c[e],o=l[e]>h[e],r=l[e]=Math.max(Math.abs(s.y-y[0].y),Math.abs(d.y-y[0].y))?(g=(s.x+d.x)/2,m=y[0].y):(g=y[0].x,m=(s.y+d.y)/2)}const b={x:l.x+v.x,y:l.y+v.y},M={x:h.x+x.x,y:h.y+x.y};return[[e,...b.x!==y[0].x||b.y!==y[0].y?[b]:[],...y,...M.x!==y[y.length-1].x||M.y!==y[y.length-1].y?[M]:[],o],g,m,w,_]}function J(t,e,n,o){const r=Math.min(U(t,e)/2,U(e,n)/2,o),{x:i,y:a}=e;if(t.x===i&&i===n.x||t.y===a&&a===n.y)return`L${i} ${a}`;if(t.y===a){return`L ${i+r*(t.xt.id===e):t[0])||null}function rt(t,e){if(!t)return"";if("string"==typeof t)return t;return`${e?`${e}__`:""}${Object.keys(t).sort().map(e=>`${e}=${t[e]}`).join("&")}`}const it={left:0,center:50,right:100},at={top:0,center:50,bottom:100};const st={nodeOrigin:[0,0],nodeExtent:n,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ut={...st,checkEquality:!0};function ct(t,e){const n={...t};for(const t in e)void 0!==e[t]&&(n[t]=e[t]);return n}function lt(t,e){if(!t.handles)return t.measured?e?.internals.handleBounds:void 0;const n=[],o=[];for(const e of t.handles){const r={id:e.id,width:e.width??1,height:e.height??1,nodeId:t.id,x:e.x,y:e.y,position:e.position,type:e.type};"source"===e.type?n.push(r):"target"===e.type&&o.push(r)}return{source:n,target:o}}function ht(t){return"manual"===t}function dt(t,e,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:s,zIndexMode:u}=ct(st,o),c=t.parentId,l=e.get(c);if(!l)return void console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);!function(t,e){if(!t.parentId)return;const n=e.get(t.parentId);n?n.set(t.id,t):e.set(t.parentId,new Map([[t.id,t]]))}(t,n),r&&!l.parentId&&void 0===l.internals.rootParentIndex&&"auto"===u&&(l.internals.rootParentIndex=++r.i,l.internals.z=l.internals.z+10*r.i),r&&void 0!==l.internals.rootParentIndex&&(r.i=l.internals.rootParentIndex);const h=i&&!ht(u)?1e3:0,{x:d,y:p,z:g}=function(t,e,n,o,r,i){const{x:a,y:s}=e.internals.positionAbsolute,u=H(t),c=f(t,n),l=D(t.extent)?v(c,t.extent,u):c;let h=v({x:a+l.x,y:s+l.y},o,u);"parent"===t.extent&&(h=x(h,u,e));const d=ft(t,r,i),p=e.internals.z??0;return{x:h.x,y:h.y,z:p>=d?p+1:d}}(t,l,a,s,h,u),{positionAbsolute:m}=t.internals,y=d!==m.x||p!==m.y;(y||g!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:y?{x:d,y:p}:m,z:g}})}function ft(t,e,n){const o=k(t.zIndex)?t.zIndex:0;return ht(n)?o:o+(t.selected?e:0)}function pt(t,e,n,o=[0,0]){const r=[],i=new Map;for(const n of t){const t=e.get(n.parentId);if(!t)continue;const o=i.get(n.parentId)?.expandedRect??E(t),r=N(o,n.rect);i.set(n.parentId,{expandedRect:r,parent:t})}return i.size>0&&i.forEach(({expandedRect:e,parent:i},a)=>{const s=i.internals.positionAbsolute,u=H(i),c=i.origin??o,l=e.x0||h>0||p||g)&&(r.push({id:a,type:"position",position:{x:i.position.x-l+p,y:i.position.y-h+g}}),n.get(a)?.forEach(e=>{t.some(t=>t.id===e.id)||r.push({id:e.id,type:"position",position:{x:e.position.x+l,y:e.position.y+h}})})),(u.width{}};function yt(){for(var t,e=0,n=arguments.length,o={};e=0&&(e=t.slice(n+1),t=t.slice(0,n)),t&&!o.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})),a=-1,s=i.length;if(!(arguments.length<2)){if(null!=e&&"function"!=typeof e)throw new Error("invalid callback: "+e);for(;++a0)for(var n,o,r=new Array(n),i=0;i=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),bt.hasOwnProperty(e)?{space:bt[e],local:t}:t}function Pt(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===_t&&e.documentElement.namespaceURI===_t?e.createElement(t):e.createElementNS(n,t)}}function Et(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function zt(t){var e=Mt(t);return(e.local?Et:Pt)(e)}function Nt(){}function St(t){return null==t?Nt:function(){return this.querySelector(t)}}function kt(){return[]}function It(t){return null==t?kt:function(){return this.querySelectorAll(t)}}function At(t){return function(){return null==(e=t.apply(this,arguments))?[]:Array.isArray(e)?e:Array.from(e);var e}}function Tt(t){return function(){return this.matches(t)}}function $t(t){return function(e){return e.matches(t)}}var Ct=Array.prototype.find;function Ot(){return this.firstElementChild}var Dt=Array.prototype.filter;function Ht(){return Array.from(this.children)}function Bt(t){return new Array(t.length)}function Lt(t,e){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=e}function Xt(t,e,n,o,r,i){for(var a,s=0,u=e.length,c=i.length;se?1:t>=e?0:NaN}function Zt(t){return function(){this.removeAttribute(t)}}function Gt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function jt(t,e){return function(){this.setAttribute(t,e)}}function Wt(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Ft(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function Kt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Ut(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Qt(t){return function(){this.style.removeProperty(t)}}function Jt(t,e,n){return function(){this.style.setProperty(t,e,n)}}function te(t,e,n){return function(){var o=e.apply(this,arguments);null==o?this.style.removeProperty(t):this.style.setProperty(t,o,n)}}function ee(t,e){return t.style.getPropertyValue(e)||Ut(t).getComputedStyle(t,null).getPropertyValue(e)}function ne(t){return function(){delete this[t]}}function oe(t,e){return function(){this[t]=e}}function re(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function ie(t){return t.trim().split(/^|\s+/)}function ae(t){return t.classList||new se(t)}function se(t){this._node=t,this._names=ie(t.getAttribute("class")||"")}function ue(t,e){for(var n=ae(t),o=-1,r=e.length;++o=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var Ie=[null];function Ae(t,e){this._groups=t,this._parents=e}function Te(){return new Ae([[document.documentElement]],Ie)}function $e(t){return"string"==typeof t?new Ae([[document.querySelector(t)]],[document.documentElement]):new Ae([[t]],Ie)}function Ce(t,e){if(t=function(t){let e;for(;e=t.sourceEvent;)t=e;return t}(t),void 0===e&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=t.clientX,o.y=t.clientY,[(o=o.matrixTransform(e.getScreenCTM().inverse())).x,o.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}Ae.prototype=Te.prototype={constructor:Ae,select:function(t){"function"!=typeof t&&(t=St(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r=_&&(_=w+1);!(x=y[_])&&++_=0;)(o=r[i])&&(a&&4^o.compareDocumentPosition(a)&&a.parentNode.insertBefore(o,a),a=o);return this},sort:function(t){function e(e,n){return e&&n?t(e.__data__,n.__data__):!e-!n}t||(t=qt);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i1?this.each((null==e?Qt:"function"==typeof e?te:Jt)(t,e,null==n?"":n)):ee(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?ne:"function"==typeof e?re:oe)(t,e)):this.node()[t]},classed:function(t,e){var n=ie(t+"");if(arguments.length<2){for(var o=ae(this.node()),r=-1,i=n.length;++r=0&&(e=t.slice(n+1),t=t.slice(0,n)),{type:t,name:e}})}(t+""),a=i.length;if(!(arguments.length<2)){for(s=e?ze:Ee,o=0;o()=>t;function Re(t,{sourceEvent:e,subject:n,target:o,identifier:r,active:i,x:a,y:s,dx:u,dy:c,dispatch:l}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:l}})}function Ve(t){return!t.ctrlKey&&!t.button}function qe(){return this.parentNode}function Ze(t,e){return null==e?{x:t.x,y:t.y}:e}function Ge(){return navigator.maxTouchPoints||"ontouchstart"in this}function je(){var t,e,n,o,r=Ve,i=qe,a=Ze,s=Ge,u={},c=yt("start","drag","end"),l=0,h=0;function d(t){t.on("mousedown.drag",f).filter(s).on("touchstart.drag",m).on("touchmove.drag",y,Oe).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(a,s){if(!o&&r.call(this,a,s)){var u=x(this,i.call(this,a,s),a,s,"mouse");u&&($e(a.view).on("mousemove.drag",p,De).on("mouseup.drag",g,De),Le(a.view),He(a),n=!1,t=a.clientX,e=a.clientY,u("start",a))}}function p(o){if(Be(o),!n){var r=o.clientX-t,i=o.clientY-e;n=r*r+i*i>h}u.mouse("drag",o)}function g(t){$e(t.view).on("mousemove.drag mouseup.drag",null),Xe(t.view,n),Be(t),u.mouse("end",t)}function m(t,e){if(r.call(this,t,e)){var n,o,a=t.changedTouches,s=i.call(this,t,e),u=a.length;for(n=0;n0&&o.push(t);return o}(t,n,e+250);for(const n of a){const a=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(const s of a){if(o.nodeId===s.nodeId&&o.type===s.type&&o.id===s.id)continue;const{x:a,y:u}=nt(n,s,s.position,!0),c=Math.sqrt(Math.pow(a-t.x,2)+Math.pow(u-t.y,2));c>e||(c1){const t="source"===o.type?"target":"source";return r.find(e=>e.type===t)??r[0]}return r[0]}function Qe(t,e,n,o,r,i=!1){const a=o.get(t);if(!a)return null;const s="strict"===r?a.internals.handleBounds?.[e]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],u=(n?s?.find(t=>t.id===n):s?.[0])??null;return u&&i?{...u,...nt(a,u,u.position,!0)}:u}function Je(t,e){return t||(e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null)}const tn=()=>!0;function en(e,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:a,doc:s,lib:u,flowId:c,isValidConnection:l=tn,nodeLookup:h}){const d="target"===a,f=n?s.querySelector(`.${u}-flow__handle[data-id="${c}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:p,y:g}=V(e),m=s.elementFromPoint(p,g),y=m?.classList.contains(`${u}-flow__handle`)?m:f,v={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const e=Je(void 0,y),n=y.getAttribute("data-nodeid"),a=y.getAttribute("data-handleid"),s=y.classList.contains("connectable"),u=y.classList.contains("connectableend");if(!n||!e)return v;const c={source:d?n:r,sourceHandle:d?a:i,target:d?r:n,targetHandle:d?i:a};v.connection=c;const f=s&&u&&(o===t.ConnectionMode.Strict?d&&"source"===e||!d&&"target"===e:n!==r||a!==i);v.isValid=f&&l(c),v.toHandle=Qe(n,e,a,h,o,!0)}return v}const nn={onPointerDown:function(e,{connectionMode:n,connectionRadius:o,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:s,domNode:u,nodeLookup:c,lib:h,autoPanOnConnect:d,flowId:f,panBy:p,cancelConnection:g,onConnectStart:m,onConnect:y,onConnectEnd:v,isValidConnection:x=tn,onReconnectEnd:w,updateConnection:b,getTransform:M,getFromHandle:P,autoPanSpeed:E,dragThreshold:z=1,handleDomNode:N}){const S=X(e.target);let k,I=0;const{x:$,y:C}=V(e),O=Je(a,N),D=u?.getBoundingClientRect();let H=!1;if(!D||!O)return;const B=Qe(i,O,r,c,n);if(!B)return;let L=V(e,D),Y=!1,R=null,q=!1,Z=null;function G(){if(!d||!D)return;const[t,e]=_(L,D,E);p({x:t,y:e}),I=requestAnimationFrame(G)}const j={...B,nodeId:i,type:O,position:B.position},W=c.get(i);let F={inProgress:!0,isValid:null,from:nt(W,j,t.Position.Left,!0),fromHandle:j,fromPosition:j.position,fromNode:W,to:L,toHandle:null,toPosition:l[j.position],toNode:null,pointer:L};function K(){H=!0,b(F),m?.(e,{nodeId:i,handleId:r,handleType:O})}function U(e){if(!H){const{x:t,y:n}=V(e),o=t-$,r=n-C;if(!(o*o+r*r>z*z))return;K()}if(!P()||!j)return void Q(e);const a=M();L=V(e,D),k=Ue(A(L,a,!1,[1,1]),o,c,j),Y||(G(),Y=!0);const u=en(e,{handle:k,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:s?"target":"source",isValidConnection:x,doc:S,lib:h,flowId:f,nodeLookup:c});Z=u.handleDomNode,R=u.connection,q=function(t,e){let n=null;return e?n=!0:t&&!e&&(n=!1),n}(!!k,u.isValid);const d=c.get(i),p=d?nt(d,j,t.Position.Left,!0):F.from,g={...F,from:p,isValid:q,to:u.toHandle&&q?T({x:u.toHandle.x,y:u.toHandle.y},a):L,toHandle:u.toHandle,toPosition:q&&u.toHandle?u.toHandle.position:l[j.position],toNode:u.toHandle?c.get(u.toHandle.nodeId):null,pointer:L};b(g),F=g}function Q(t){if(!("touches"in t&&t.touches.length>0)){if(H){(k||Z)&&R&&q&&y?.(R);const{inProgress:e,...n}=F,o={...n,toPosition:F.toHandle?F.toPosition:null};v?.(t,o),a&&w?.(t,o)}g(),cancelAnimationFrame(I),Y=!1,q=!1,R=null,Z=null,S.removeEventListener("mousemove",U),S.removeEventListener("mouseup",Q),S.removeEventListener("touchmove",U),S.removeEventListener("touchend",Q)}}0===z&&K(),S.addEventListener("mousemove",U),S.addEventListener("mouseup",Q),S.addEventListener("touchmove",U),S.addEventListener("touchend",Q)},isValid:en};function on(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function rn(t,e){var n=Object.create(t.prototype);for(var o in e)n[o]=e[o];return n}function an(){}var sn=.7,un=1/sn,cn="\\s*([+-]?\\d+)\\s*",ln="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",hn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",dn=/^#([0-9a-f]{3,8})$/,fn=new RegExp(`^rgb\\(${cn},${cn},${cn}\\)$`),pn=new RegExp(`^rgb\\(${hn},${hn},${hn}\\)$`),gn=new RegExp(`^rgba\\(${cn},${cn},${cn},${ln}\\)$`),mn=new RegExp(`^rgba\\(${hn},${hn},${hn},${ln}\\)$`),yn=new RegExp(`^hsl\\(${ln},${hn},${hn}\\)$`),vn=new RegExp(`^hsla\\(${ln},${hn},${hn},${ln}\\)$`),xn={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};function wn(){return this.rgb().formatHex()}function _n(){return this.rgb().formatRgb()}function bn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=dn.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?Mn(e):3===n?new zn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Pn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Pn(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|240&e,((15&e)<<4|15&e)/255):null):(e=fn.exec(t))?new zn(e[1],e[2],e[3],1):(e=pn.exec(t))?new zn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=gn.exec(t))?Pn(e[1],e[2],e[3],e[4]):(e=mn.exec(t))?Pn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=yn.exec(t))?Tn(e[1],e[2]/100,e[3]/100,1):(e=vn.exec(t))?Tn(e[1],e[2]/100,e[3]/100,e[4]):xn.hasOwnProperty(t)?Mn(xn[t]):"transparent"===t?new zn(NaN,NaN,NaN,0):null}function Mn(t){return new zn(t>>16&255,t>>8&255,255&t,1)}function Pn(t,e,n,o){return o<=0&&(t=e=n=NaN),new zn(t,e,n,o)}function En(t,e,n,o){return 1===arguments.length?((r=t)instanceof an||(r=bn(r)),r?new zn((r=r.rgb()).r,r.g,r.b,r.opacity):new zn):new zn(t,e,n,null==o?1:o);var r}function zn(t,e,n,o){this.r=+t,this.g=+e,this.b=+n,this.opacity=+o}function Nn(){return`#${An(this.r)}${An(this.g)}${An(this.b)}`}function Sn(){const t=kn(this.opacity);return`${1===t?"rgb(":"rgba("}${In(this.r)}, ${In(this.g)}, ${In(this.b)}${1===t?")":`, ${t})`}`}function kn(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function In(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function An(t){return((t=In(t))<16?"0":"")+t.toString(16)}function Tn(t,e,n,o){return o<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new Cn(t,e,n,o)}function $n(t){if(t instanceof Cn)return new Cn(t.h,t.s,t.l,t.opacity);if(t instanceof an||(t=bn(t)),!t)return new Cn;if(t instanceof Cn)return t;var e=(t=t.rgb()).r/255,n=t.g/255,o=t.b/255,r=Math.min(e,n,o),i=Math.max(e,n,o),a=NaN,s=i-r,u=(i+r)/2;return s?(a=e===i?(n-o)/s+6*(n0&&u<1?0:a,new Cn(a,s,u,t.opacity)}function Cn(t,e,n,o){this.h=+t,this.s=+e,this.l=+n,this.opacity=+o}function On(t){return(t=(t||0)%360)<0?t+360:t}function Dn(t){return Math.max(0,Math.min(1,t||0))}function Hn(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}on(an,bn,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:wn,formatHex:wn,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return $n(this).formatHsl()},formatRgb:_n,toString:_n}),on(zn,En,rn(an,{brighter(t){return t=null==t?un:Math.pow(un,t),new zn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?sn:Math.pow(sn,t),new zn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new zn(In(this.r),In(this.g),In(this.b),kn(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:Nn,formatHex:Nn,formatHex8:function(){return`#${An(this.r)}${An(this.g)}${An(this.b)}${An(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:Sn,toString:Sn})),on(Cn,function(t,e,n,o){return 1===arguments.length?$n(t):new Cn(t,e,n,null==o?1:o)},rn(an,{brighter(t){return t=null==t?un:Math.pow(un,t),new Cn(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?sn:Math.pow(sn,t),new Cn(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+360*(this.h<0),e=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*e,r=2*n-o;return new zn(Hn(t>=240?t-240:t+120,r,o),Hn(t,r,o),Hn(t<120?t+240:t-120,r,o),this.opacity)},clamp(){return new Cn(On(this.h),Dn(this.s),Dn(this.l),kn(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 t=kn(this.opacity);return`${1===t?"hsl(":"hsla("}${On(this.h)}, ${100*Dn(this.s)}%, ${100*Dn(this.l)}%${1===t?")":`, ${t})`}`}}));var Bn=t=>()=>t;function Ln(t){return 1===(t=+t)?Xn:function(e,n){return n-e?function(t,e,n){return t=Math.pow(t,n),e=Math.pow(e,n)-t,n=1/n,function(o){return Math.pow(t+o*e,n)}}(e,n,t):Bn(isNaN(e)?n:e)}}function Xn(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Bn(isNaN(t)?e:t)}var Yn=function t(e){var n=Ln(e);function o(t,e){var o=n((t=En(t)).r,(e=En(e)).r),r=n(t.g,e.g),i=n(t.b,e.b),a=Xn(t.opacity,e.opacity);return function(e){return t.r=o(e),t.g=r(e),t.b=i(e),t.opacity=a(e),t+""}}return o.gamma=t,o}(1);function Rn(t,e){e||(e=[]);var n,o=t?Math.min(e.length,t.length):0,r=e.slice();return function(i){for(n=0;ni&&(r=e.slice(i,r),s[a]?s[a]+=r:s[++a]=r),(n=n[0])===(o=o[0])?s[a]?s[a]+=o:s[++a]=o:(s[++a]=null,u.push({i:a,x:Zn(n,o)})),i=Wn.lastIndex;return i180?e+=360:e-t>180&&(t+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:Zn(t,e)})):e&&n.push(r(n)+"rotate("+e+o)}(i.rotate,a.rotate,s,u),function(t,e,n,i){t!==e?i.push({i:n.push(r(n)+"skewX(",null,o)-2,x:Zn(t,e)}):e&&n.push(r(n)+"skewX("+e+o)}(i.skewX,a.skewX,s,u),function(t,e,n,o,i,a){if(t!==n||e!==o){var s=i.push(r(i)+"scale(",null,",",null,")");a.push({i:s-4,x:Zn(t,n)},{i:s-2,x:Zn(e,o)})}else 1===n&&1===o||i.push(r(i)+"scale("+n+","+o+")")}(i.scaleX,i.scaleY,a.scaleX,a.scaleY,s,u),i=a=null,function(t){for(var e,n=-1,o=u.length;++n=0&&e._call.call(void 0,t),e=e._next;--uo}()}finally{uo=0,function(){var t,e,n=io,o=1/0;for(;n;)n._call?(o>n._time&&(o=n._time),t=n,n=n._next):(e=n._next,n._next=null,n=t?t._next=e:io=e);ao=t,Mo(o)}(),fo=0}}function bo(){var t=go.now(),e=t-ho;e>1e3&&(po-=e,ho=t)}function Mo(t){uo||(co&&(co=clearTimeout(co)),t-fo>24?(t<1/0&&(co=setTimeout(_o,t-go.now()-po)),lo&&(lo=clearInterval(lo))):(lo||(ho=go.now(),lo=setInterval(bo,1e3)),uo=1,mo(_o)))}function Po(t,e,n){var o=new xo;return e=null==e?0:+e,o.restart(n=>{o.stop(),t(n+e)},e,n),o}xo.prototype=wo.prototype={constructor:xo,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?yo():+n)+(null==e?0:+e),this._next||ao===this||(ao?ao._next=this:io=this,ao=this),this._call=t,this._time=n,Mo()},stop:function(){this._call&&(this._call=null,this._time=1/0,Mo())}};var Eo=yt("start","end","cancel","interrupt"),zo=[];function No(t,e,n,o,r,i){var a=t.__transition;if(a){if(n in a)return}else t.__transition={};!function(t,e,n){var o,r=t.__transition;function i(t){n.state=1,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(i){var c,l,h,d;if(1!==n.state)return u();for(c in r)if((d=r[c]).name===n.name){if(3===d.state)return Po(a);4===d.state?(d.state=6,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete r[c]):+c0)throw new Error("too late; already scheduled");return n}function ko(t,e){var n=Io(t,e);if(n.state>3)throw new Error("too late; already running");return n}function Io(t,e){var n=t.__transition;if(!n||!(n=n[e]))throw new Error("transition not found");return n}function Ao(t,e){var n,o,r,i=t.__transition,a=!0;if(i){for(r in e=null==e?null:e+"",i)(n=i[r]).name===e?(o=n.state>2&&n.state<5,n.state=6,n.timer.stop(),n.on.call(o?"interrupt":"cancel",t,t.__data__,n.index,n.group),delete i[r]):a=!1;a&&delete t.__transition}}function To(t,e){var n,o;return function(){var r=ko(this,t),i=r.tween;if(i!==n)for(var a=0,s=(o=n=i).length;a=0&&(t=t.slice(0,e)),!t||"start"===t})}(e)?So:ko;return function(){var a=i(this,t),s=a.on;s!==o&&(r=(o=s).copy()).on(e,n),a.on=r}}(n,t,e))},attr:function(t,e){var n=Mt(t),o="transform"===n?oo:Oo;return this.attrTween(t,"function"==typeof e?(n.local?Yo:Xo)(n,o,Co(this,"attr."+t,e)):null==e?(n.local?Ho:Do)(n):(n.local?Lo:Bo)(n,o,e))},attrTween:function(t,e){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(null==e)return this.tween(n,null);if("function"!=typeof e)throw new Error;var o=Mt(t);return this.tween(n,(o.local?Ro:Vo)(o,e))},style:function(t,e,n){var o="transform"==(t+="")?no:Oo;return null==e?this.styleTween(t,function(t,e){var n,o,r;return function(){var i=ee(this,t),a=(this.style.removeProperty(t),ee(this,t));return i===a?null:i===n&&a===o?r:r=e(n=i,o=a)}}(t,o)).on("end.style."+t,Fo(t)):"function"==typeof e?this.styleTween(t,function(t,e,n){var o,r,i;return function(){var a=ee(this,t),s=n(this),u=s+"";return null==s&&(this.style.removeProperty(t),u=s=ee(this,t)),a===u?null:a===o&&u===r?i:(r=u,i=e(o=a,s))}}(t,o,Co(this,"style."+t,e))).each(function(t,e){var n,o,r,i,a="style."+e,s="end."+a;return function(){var u=ko(this,t),c=u.on,l=null==u.value[a]?i||(i=Fo(e)):void 0;c===n&&r===l||(o=(n=c).copy()).on(s,r=l),u.on=o}}(this._id,t)):this.styleTween(t,function(t,e,n){var o,r,i=n+"";return function(){var a=ee(this,t);return a===i?null:a===o?r:r=e(o=a,n)}}(t,o,e),n).on("end.style."+t,null)},styleTween:function(t,e,n){var o="style."+(t+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(null==e)return this.tween(o,null);if("function"!=typeof e)throw new Error;return this.tween(o,function(t,e,n){var o,r;function i(){var i=e.apply(this,arguments);return i!==r&&(o=(r=i)&&function(t,e,n){return function(o){this.style.setProperty(t,e.call(this,o),n)}}(t,i,n)),o}return i._value=e,i}(t,e,null==n?"":n))},text:function(t){return this.tween("text","function"==typeof t?function(t){return function(){var e=t(this);this.textContent=null==e?"":e}}(Co(this,"text",t)):function(t){return function(){this.textContent=t}}(null==t?"":t+""))},textTween:function(t){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(null==t)return this.tween(e,null);if("function"!=typeof t)throw new Error;return this.tween(e,function(t){var e,n;function o(){var o=t.apply(this,arguments);return o!==n&&(e=(n=o)&&function(t){return function(e){this.textContent=t.call(this,e)}}(o)),e}return o._value=t,o}(t))},remove:function(){return this.on("end.remove",function(t){return function(){var e=this.parentNode;for(var n in this.__transition)if(+n!==t)return;e&&e.removeChild(this)}}(this._id))},tween:function(t,e){var n=this._id;if(t+="",arguments.length<2){for(var o,r=Io(this.node(),n).tween,i=0,a=r.length;i()=>t;function or(t,{sourceEvent:e,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function rr(t,e,n){this.k=t,this.x=e,this.y=n}rr.prototype={constructor:rr,scale:function(t){return 1===t?this:new rr(this.k*t,this.x,this.y)},translate:function(t,e){return 0===t&0===e?this:new rr(this.k,this.x+this.k*t,this.y+this.k*e)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ir=new rr(1,0,0);function ar(t){for(;!t.__zoom;)if(!(t=t.parentNode))return ir;return t.__zoom}function sr(t){t.stopImmediatePropagation()}function ur(t){t.preventDefault(),t.stopImmediatePropagation()}function cr(t){return!(t.ctrlKey&&"wheel"!==t.type||t.button)}function lr(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function hr(){return this.__zoom||ir}function dr(t){return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function fr(){return navigator.maxTouchPoints||"ontouchstart"in this}function pr(t,e,n){var o=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],i=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),a>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function gr(){var t,e,n,o=cr,r=lr,i=pr,a=dr,s=fr,u=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],l=250,h=so,d=yt("start","zoom","end"),f=0,p=10;function g(t){t.property("__zoom",hr).on("wheel.zoom",b,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",P).filter(s).on("touchstart.zoom",E).on("touchmove.zoom",z).on("touchend.zoom touchcancel.zoom",N).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(t,e){return(e=Math.max(u[0],Math.min(u[1],e)))===t.k?t:new rr(e,t.x,t.y)}function y(t,e,n){var o=e[0]-n[0]*t.k,r=e[1]-n[1]*t.k;return o===t.x&&r===t.y?t:new rr(t.k,o,r)}function v(t){return[(+t[0][0]+ +t[1][0])/2,(+t[0][1]+ +t[1][1])/2]}function x(t,e,n,o){t.on("start.zoom",function(){w(this,arguments).event(o).start()}).on("interrupt.zoom end.zoom",function(){w(this,arguments).event(o).end()}).tween("zoom",function(){var t=this,i=arguments,a=w(t,i).event(o),s=r.apply(t,i),u=null==n?v(s):"function"==typeof n?n.apply(t,i):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),l=t.__zoom,d="function"==typeof e?e.apply(t,i):e,f=h(l.invert(u).concat(c/l.k),d.invert(u).concat(c/d.k));return function(t){if(1===t)t=d;else{var e=f(t),n=c/e[2];t=new rr(n,u[0]-e[0]*n,u[1]-e[1]*n)}a.zoom(null,t)}})}function w(t,e,n){return!n&&t.__zooming||new _(t,e)}function _(t,e){this.that=t,this.args=e,this.active=0,this.sourceEvent=null,this.extent=r.apply(t,e),this.taps=0}function b(t,...e){if(o.apply(this,arguments)){var n=w(this,e).event(t),r=this.__zoom,s=Math.max(u[0],Math.min(u[1],r.k*Math.pow(2,a.apply(this,arguments)))),l=Ce(t);if(n.wheel)n.mouse[0][0]===l[0]&&n.mouse[0][1]===l[1]||(n.mouse[1]=r.invert(n.mouse[0]=l)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[l,r.invert(l)],Ao(this),n.start()}ur(t),n.wheel=setTimeout(function(){n.wheel=null,n.end()},150),n.zoom("mouse",i(y(m(r,s),n.mouse[0],n.mouse[1]),n.extent,c))}}function M(t,...e){if(!n&&o.apply(this,arguments)){var r=t.currentTarget,a=w(this,e,!0).event(t),s=$e(t.view).on("mousemove.zoom",function(t){if(ur(t),!a.moved){var e=t.clientX-l,n=t.clientY-h;a.moved=e*e+n*n>f}a.event(t).zoom("mouse",i(y(a.that.__zoom,a.mouse[0]=Ce(t,r),a.mouse[1]),a.extent,c))},!0).on("mouseup.zoom",function(t){s.on("mousemove.zoom mouseup.zoom",null),Xe(t.view,a.moved),ur(t),a.event(t).end()},!0),u=Ce(t,r),l=t.clientX,h=t.clientY;Le(t.view),sr(t),a.mouse=[u,this.__zoom.invert(u)],Ao(this),a.start()}}function P(t,...e){if(o.apply(this,arguments)){var n=this.__zoom,a=Ce(t.changedTouches?t.changedTouches[0]:t,this),s=n.invert(a),u=n.k*(t.shiftKey?.5:2),h=i(y(m(n,u),a,s),r.apply(this,e),c);ur(t),l>0?$e(this).transition().duration(l).call(x,h,a,t):$e(this).call(g.transform,h,a,t)}}function E(n,...r){if(o.apply(this,arguments)){var i,a,s,u,c=n.touches,l=c.length,h=w(this,r,n.changedTouches.length===l).event(n);for(sr(n),a=0;a({x:t.x,y:t.y,zoom:t.k}),yr=({x:t,y:e,zoom:n})=>ir.translate(t,e).scale(n),vr=(t,e)=>t.target.closest(`.${e}`),xr=(t,e)=>2===e&&Array.isArray(t)&&t.includes(2),wr=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,_r=(t,e=0,n=wr,o=()=>{})=>{const r="number"==typeof e&&e>0;return r||o(),r?t.transition().duration(e).ease(n).on("end",o):t},br=t=>{const e=t.ctrlKey&&O()?10:1;return-t.deltaY*(1===t.deltaMode?.05:t.deltaMode?1:.002)*e};var Mr;t.ResizeControlVariant=void 0,(Mr=t.ResizeControlVariant||(t.ResizeControlVariant={})).Line="line",Mr.Handle="handle";function Pr(t){return{isHorizontal:t.includes("right")||t.includes("left"),isVertical:t.includes("bottom")||t.includes("top"),affectsX:t.includes("left"),affectsY:t.includes("top")}}function Er(t,e){return Math.max(0,e-t)}function zr(t,e){return Math.max(0,t-e)}function Nr(t,e,n){return Math.max(0,e-t,t-n)}function Sr(t,e){return t?!e:e}const kr={width:0,height:0,x:0,y:0},Ir={...kr,pointerX:0,pointerY:0,aspectRatio:1};function Ar(t,e,n){const o=e.position.x+t.position.x,r=e.position.y+t.position.y,i=t.measured.width??0,a=t.measured.height??0,s=n[0]*i,u=n[1]*a;return[[o-s,r-u],[o+i-s,r+a-u]]}t.XYDrag=function({onNodeMouseDown:t,getStoreItems:e,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},a=0,s=new Map,u=!1,c={x:0,y:0},l=null,h=!1,d=null,f=!1,g=!1,y=null;return{update:function({noDragClassName:v,handleSelector:x,domNode:w,isSelectable:b,nodeId:P,nodeClickDistance:E=0}){function z({x:t,y:n}){const{nodeLookup:r,nodeExtent:a,snapGrid:u,snapToGrid:c,nodeOrigin:l,onNodeDrag:h,onSelectionDrag:d,onError:f,updateNodePositions:v}=e();i={x:t,y:n};let x=!1;const w=s.size>1,_=w&&a?M(p(s)):null,b=w&&c?function({dragItems:t,snapGrid:e,x:n,y:o}){const r=t.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},a=I(i,e);return{x:a.x-i.x,y:a.y-i.y}}({dragItems:s,snapGrid:u,x:t,y:n}):null;for(const[e,o]of s){if(!r.has(e))continue;let i={x:t-o.distance.x,y:n-o.distance.y};c&&(i=b?{x:Math.round(i.x+b.x),y:Math.round(i.y+b.y)}:I(i,u));let s=null;if(w&&a&&!o.extent&&_){const{positionAbsolute:t}=o.internals,e=t.x-_.x+a[0][0],n=t.x+o.measured.width-_.x2+a[1][0];s=[[e,t.y-_.y+a[0][1]],[n,t.y+o.measured.height-_.y2+a[1][1]]]}const{position:h,positionAbsolute:d}=m({nodeId:e,nextPosition:i,nodeLookup:r,nodeExtent:s||a,nodeOrigin:l,onError:f});x=x||o.position.x!==h.x||o.position.y!==h.y,o.position=h,o.internals.positionAbsolute=d}if(g=g||x,x&&(v(s,!0),y&&(o||h||!P&&d))){const[t,e]=Ke({nodeId:P,dragItems:s,nodeLookup:r});o?.(y,s,t,e),h?.(y,t,e),P||d?.(y,e)}}async function N(){if(!l)return;const{transform:t,panBy:n,autoPanSpeed:o,autoPanOnNodeDrag:r}=e();if(!r)return u=!1,void cancelAnimationFrame(a);const[s,h]=_(c,l,o);0===s&&0===h||(i.x=(i.x??0)-s/t[2],i.y=(i.y??0)-h/t[2],await n({x:s,y:h})&&z(i)),a=requestAnimationFrame(N)}function S(o){const{nodeLookup:r,multiSelectionActive:a,nodesDraggable:u,transform:c,snapGrid:d,snapToGrid:f,selectNodesOnDrag:p,onNodeDragStart:g,onSelectionDragStart:m,unselectNodesAndEdges:y}=e();h=!0,p&&b||a||!P||r.get(P)?.selected||y(),b&&p&&P&&t?.(P);const v=B(o.sourceEvent,{transform:c,snapGrid:d,snapToGrid:f,containerBounds:l});if(i=v,s=function(t,e,n,o){const r=new Map;for(const[i,a]of t)if((a.selected||a.id===o)&&(!a.parentId||!We(a,t))&&(a.draggable||e&&void 0===a.draggable)){const e=t.get(i);e&&r.set(i,{id:i,position:e.position||{x:0,y:0},distance:{x:n.x-e.internals.positionAbsolute.x,y:n.y-e.internals.positionAbsolute.y},extent:e.extent,parentId:e.parentId,origin:e.origin,expandParent:e.expandParent,internals:{positionAbsolute:e.internals.positionAbsolute||{x:0,y:0}},measured:{width:e.measured.width??0,height:e.measured.height??0}})}return r}(r,u,v,P),s.size>0&&(n||g||!P&&m)){const[t,e]=Ke({nodeId:P,dragItems:s,nodeLookup:r});n?.(o.sourceEvent,s,t,e),g?.(o.sourceEvent,t,e),P||m?.(o.sourceEvent,e)}}d=$e(w);const k=je().clickDistance(E).on("start",t=>{const{domNode:n,nodeDragThreshold:o,transform:r,snapGrid:a,snapToGrid:s}=e();l=n?.getBoundingClientRect()||null,f=!1,g=!1,y=t.sourceEvent,0===o&&S(t);const u=B(t.sourceEvent,{transform:r,snapGrid:a,snapToGrid:s,containerBounds:l});i=u,c=V(t.sourceEvent,l)}).on("drag",t=>{const{autoPanOnNodeDrag:n,transform:o,snapGrid:r,snapToGrid:a,nodeDragThreshold:d,nodeLookup:p}=e(),g=B(t.sourceEvent,{transform:o,snapGrid:r,snapToGrid:a,containerBounds:l});if(y=t.sourceEvent,("touchmove"===t.sourceEvent.type&&t.sourceEvent.touches.length>1||P&&!p.has(P))&&(f=!0),!f){if(!u&&n&&h&&(u=!0,N()),!h){const e=V(t.sourceEvent,l),n=e.x-c.x,o=e.y-c.y;Math.sqrt(n*n+o*o)>d&&S(t)}(i.x!==g.xSnapped||i.y!==g.ySnapped)&&s&&h&&(c=V(t.sourceEvent,l),z(g))}}).on("end",t=>{if(h&&!f){if(u=!1,h=!1,cancelAnimationFrame(a),s.size>0){const{nodeLookup:n,updateNodePositions:o,onNodeDragStop:i,onSelectionDragStop:a}=e();if(g&&(o(s,!1),g=!1),r||i||!P&&a){const[e,o]=Ke({nodeId:P,dragItems:s,nodeLookup:n,dragging:!1});r?.(t.sourceEvent,s,e,o),i?.(t.sourceEvent,e,o),P||a?.(t.sourceEvent,o)}}}else f&&s.size>0&&e().updateNodePositions(s,!1)}).filter(t=>{const e=t.target;return!t.button&&(!v||!Fe(e,`.${v}`,w))&&(!x||Fe(e,x,w))});d.call(k)},destroy:function(){d?.on(".drag",null)}}},t.XYHandle=nn,t.XYMinimap=function({domNode:t,panZoom:e,getTransform:n,getViewScale:o}){const r=$e(t);return{update:function({translateExtent:t,width:i,height:a,zoomStep:s=1,pannable:u=!0,zoomable:c=!0,inversePan:l=!1}){let h=[0,0];const d=gr().on("start",t=>{"mousedown"!==t.sourceEvent.type&&"touchstart"!==t.sourceEvent.type||(h=[t.sourceEvent.clientX??t.sourceEvent.touches[0].clientX,t.sourceEvent.clientY??t.sourceEvent.touches[0].clientY])}).on("zoom",u?r=>{const s=n();if("mousemove"!==r.sourceEvent.type&&"touchmove"!==r.sourceEvent.type||!e)return;const u=[r.sourceEvent.clientX??r.sourceEvent.touches[0].clientX,r.sourceEvent.clientY??r.sourceEvent.touches[0].clientY],c=[u[0]-h[0],u[1]-h[1]];h=u;const d=o()*Math.max(s[2],Math.log(s[2]))*(l?-1:1),f={x:s[0]-c[0]*d,y:s[1]-c[1]*d},p=[[0,0],[i,a]];e.setViewportConstrained({x:f.x,y:f.y,zoom:s[2]},p,t)}:null).on("zoom.wheel",c?t=>{if("wheel"!==t.sourceEvent.type||!e)return;const o=n(),r=t.sourceEvent.ctrlKey&&O()?10:1,i=-t.sourceEvent.deltaY*(1===t.sourceEvent.deltaMode?.05:t.sourceEvent.deltaMode?1:.002)*s,a=o[2]*Math.pow(2,i*r);e.scaleTo(a)}:null);r.call(d,{})},destroy:function(){r.on("zoom",null)},pointer:Ce}},t.XYPanZoom=function({domNode:e,minZoom:n,maxZoom:o,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:s,onPanZoomEnd:u,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),d=gr().scaleExtent([n,o]).translateExtent(r),f=$e(e).call(d);x({x:i.x,y:i.y,zoom:y(i.zoom,n,o)},[[0,0],[h.width,h.height]],r);const p=f.on("wheel.zoom"),g=f.on("dblclick.zoom");async function m(t,e){return!!f&&new Promise(n=>{d?.interpolate("linear"===e?.interpolate?Kn:so).transform(_r(f,e?.duration,e?.ease,()=>n(!0)),t)})}function v(){d.on("zoom",null)}async function x(t,e,n){const o=yr(t),r=d?.constrain()(o,e,n);return r&&await m(r),r}return d.wheelDelta(br),{update:function({noWheelClassName:e,noPanClassName:n,onPaneContextMenu:o,userSelectionActive:r,panOnScroll:i,panOnDrag:h,panOnScrollMode:m,panOnScrollSpeed:y,preventScrolling:x,zoomOnPinch:w,zoomOnScroll:_,zoomOnDoubleClick:b,zoomActivationKeyPressed:M,lib:P,onTransformChange:E,connectionInProgress:z,paneClickDistance:N,selectionOnDrag:S}){r&&!l.isZoomingOrPanning&&v();const I=i&&!M&&!r;d.clickDistance(S?1/0:!k(N)||N<0?0:N);const A=I?function({zoomPanValues:e,noWheelClassName:n,d3Selection:o,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:s,onPanZoomStart:u,onPanZoom:c,onPanZoomEnd:l}){return h=>{if(vr(h,n))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const d=o.property("__zoom").k||1;if(h.ctrlKey&&s){const t=Ce(h),e=br(h),n=d*Math.pow(2,e);return void r.scaleTo(o,n,t,h)}const f=1===h.deltaMode?20:1;let p=i===t.PanOnScrollMode.Vertical?0:h.deltaX*f,g=i===t.PanOnScrollMode.Horizontal?0:h.deltaY*f;!O()&&h.shiftKey&&i!==t.PanOnScrollMode.Vertical&&(p=h.deltaY*f,g=0),r.translateBy(o,-p/d*a,-g/d*a,{internal:!0});const m=mr(o.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c?.(h,m),e.panScrollTimeout=setTimeout(()=>{l?.(h,m),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,u?.(h,m))}}({zoomPanValues:l,noWheelClassName:e,d3Selection:f,d3Zoom:d,panOnScrollMode:m,panOnScrollSpeed:y,zoomOnPinch:w,onPanZoomStart:s,onPanZoom:a,onPanZoomEnd:u}):function({noWheelClassName:t,preventScrolling:e,d3ZoomHandler:n}){return function(o,r){const i="wheel"===o.type,a=!e&&i&&!o.ctrlKey,s=vr(o,t);if(o.ctrlKey&&i&&s&&o.preventDefault(),a||s)return null;o.preventDefault(),n.call(this,o,r)}}({noWheelClassName:e,preventScrolling:x,d3ZoomHandler:p});f.on("wheel.zoom",A,{passive:!1});const T=function({zoomPanValues:t,onDraggingChange:e,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=mr(o.transform);t.mouseButton=o.sourceEvent?.button||0,t.isZoomingOrPanning=!0,t.prevViewport=r,"mousedown"===o.sourceEvent?.type&&e(!0),n&&n?.(o.sourceEvent,r)}}({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});d.on("start",T);const $=function({zoomPanValues:t,panOnDrag:e,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{t.usedRightMouseButton=!(!n||!xr(e,t.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,mr(i.transform))}}({zoomPanValues:l,panOnDrag:h,onPaneContextMenu:!!o,onPanZoom:a,onTransformChange:E});d.on("zoom",$);const C=function({zoomPanValues:t,panOnDrag:e,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return a=>{if(!a.sourceEvent?.internal&&(t.isZoomingOrPanning=!1,i&&xr(e,t.mouseButton??0)&&!t.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),t.usedRightMouseButton=!1,o(!1),r)){const e=mr(a.transform);t.prevViewport=e,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{r?.(a.sourceEvent,e)},n?150:0)}}}({zoomPanValues:l,panOnDrag:h,panOnScroll:i,onPaneContextMenu:o,onPanZoomEnd:u,onDraggingChange:c});d.on("end",C);const D=function({zoomActivationKeyPressed:t,zoomOnScroll:e,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:s,noPanClassName:u,lib:c,connectionInProgress:l}){return h=>{const d=t||e,f=n&&h.ctrlKey,p="wheel"===h.type;if(1===h.button&&"mousedown"===h.type&&(vr(h,`${c}-flow__node`)||vr(h,`${c}-flow__edge`)))return!0;if(!(o||d||r||i||n))return!1;if(a)return!1;if(l&&!p)return!1;if(vr(h,s)&&p)return!1;if(vr(h,u)&&(!p||r&&p&&!t))return!1;if(!n&&h.ctrlKey&&p)return!1;if(!n&&"touchstart"===h.type&&h.touches?.length>1)return h.preventDefault(),!1;if(!d&&!r&&!f&&p)return!1;if(!o&&("mousedown"===h.type||"touchstart"===h.type))return!1;if(Array.isArray(o)&&!o.includes(h.button)&&"mousedown"===h.type)return!1;const g=Array.isArray(o)&&o.includes(h.button)||!h.button||h.button<=1;return(!h.ctrlKey||p)&&g}}({zoomActivationKeyPressed:M,panOnDrag:h,zoomOnScroll:_,panOnScroll:i,zoomOnDoubleClick:b,zoomOnPinch:w,userSelectionActive:r,noPanClassName:n,noWheelClassName:e,lib:P,connectionInProgress:z});d.filter(D),b?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)},destroy:v,setViewport:async function(t,e){const n=yr(t);return await m(n,e),n},setViewportConstrained:x,getViewport:function(){const t=f?ar(f.node()):{x:0,y:0,k:1};return{x:t.x,y:t.y,zoom:t.k}},scaleTo:async function(t,e){return!!f&&new Promise(n=>{d?.interpolate("linear"===e?.interpolate?Kn:so).scaleTo(_r(f,e?.duration,e?.ease,()=>n(!0)),t)})},scaleBy:async function(t,e){return!!f&&new Promise(n=>{d?.interpolate("linear"===e?.interpolate?Kn:so).scaleBy(_r(f,e?.duration,e?.ease,()=>n(!0)),t)})},setScaleExtent:function(t){d?.scaleExtent(t)},setTranslateExtent:function(t){d?.translateExtent(t)},syncViewport:function(t){if(f){const e=yr(t),n=f.property("__zoom");n.k===t.zoom&&n.x===t.x&&n.y===t.y||d?.transform(f,e,null,{sync:!0})}},setClickDistance:function(t){const e=!k(t)||t<0?0:t;d?.clickDistance(e)}}},t.XYResizer=function({domNode:t,nodeId:e,getStoreItems:n,onChange:o,onEnd:r}){const i=$e(t);let a={controlDirection:Pr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};return{update:function({controlPosition:t,boundaries:s,keepAspectRatio:u,resizeDirection:c,onResizeStart:l,onResize:h,onResizeEnd:d,shouldResize:f}){let p,g={...kr},m={...Ir};a={boundaries:s,resizeDirection:c,keepAspectRatio:u,controlDirection:Pr(t)};let y,v,x,w=null,_=[],b=!1;const M=je().on("start",t=>{const{nodeLookup:o,transform:r,snapGrid:i,snapToGrid:a,nodeOrigin:s,paneDomNode:u}=n();if(p=o.get(e),!p)return;w=u?.getBoundingClientRect()??null;const{xSnapped:c,ySnapped:h}=B(t.sourceEvent,{transform:r,snapGrid:i,snapToGrid:a,containerBounds:w});g={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},m={...g,pointerX:c,pointerY:h,aspectRatio:g.width/g.height},y=void 0,v=D(p.extent)?p.extent:void 0,p.parentId&&("parent"===p.extent||p.expandParent)&&(y=o.get(p.parentId)),y&&"parent"===p.extent&&(v=[[0,0],[y.measured.width,y.measured.height]]),_=[],x=void 0;for(const[t,n]of o)if(n.parentId===e&&(_.push({id:t,position:{...n.position},extent:n.extent}),"parent"===n.extent||n.expandParent)){const t=Ar(n,p,n.origin??s);x=x?[[Math.min(t[0][0],x[0][0]),Math.min(t[0][1],x[0][1])],[Math.max(t[1][0],x[1][0]),Math.max(t[1][1],x[1][1])]]:t}l?.(t,{...g})}).on("drag",t=>{const{transform:e,snapGrid:r,snapToGrid:i,nodeOrigin:s}=n(),u=B(t.sourceEvent,{transform:e,snapGrid:r,snapToGrid:i,containerBounds:w}),c=[];if(!p)return;const{x:l,y:d,width:M,height:P}=g,E={},z=p.origin??s,{width:N,height:S,x:k,y:I}=function(t,e,n,o,r,i,a,s){let{affectsX:u,affectsY:c}=e;const{isHorizontal:l,isVertical:h}=e,d=l&&h,{xSnapped:f,ySnapped:p}=n,{minWidth:g,maxWidth:m,minHeight:y,maxHeight:v}=o,{x:x,y:w,width:_,height:b,aspectRatio:M}=t;let P=Math.floor(l?f-t.pointerX:0),E=Math.floor(h?p-t.pointerY:0);const z=_+(u?-P:P),N=b+(c?-E:E),S=-i[0]*_,k=-i[1]*b;let I=Nr(z,g,m),A=Nr(N,y,v);if(a){let t=0,e=0;u&&P<0?t=Er(x+P+S,a[0][0]):!u&&P>0&&(t=zr(x+z+S,a[1][0])),c&&E<0?e=Er(w+E+k,a[0][1]):!c&&E>0&&(e=zr(w+N+k,a[1][1])),I=Math.max(I,t),A=Math.max(A,e)}if(s){let t=0,e=0;u&&P>0?t=zr(x+P,s[0][0]):!u&&P<0&&(t=Er(x+z,s[1][0])),c&&E>0?e=zr(w+E,s[0][1]):!c&&E<0&&(e=Er(w+N,s[1][1])),I=Math.max(I,t),A=Math.max(A,e)}if(r){if(l){const t=Nr(z/M,y,v)*M;if(I=Math.max(I,t),a){let t=0;t=!u&&!c||u&&!c&&d?zr(w+k+z/M,a[1][1])*M:Er(w+k+(u?P:-P)/M,a[0][1])*M,I=Math.max(I,t)}if(s){let t=0;t=!u&&!c||u&&!c&&d?Er(w+z/M,s[1][1])*M:zr(w+(u?P:-P)/M,s[0][1])*M,I=Math.max(I,t)}}if(h){const t=Nr(N*M,g,m)/M;if(A=Math.max(A,t),a){let t=0;t=!u&&!c||c&&!u&&d?zr(x+N*M+S,a[1][0])/M:Er(x+(c?E:-E)*M+S,a[0][0])/M,A=Math.max(A,t)}if(s){let t=0;t=!u&&!c||c&&!u&&d?Er(x+N*M,s[1][0])/M:zr(x+(c?E:-E)*M,s[0][0])/M,A=Math.max(A,t)}}}E+=E<0?A:-A,P+=P<0?I:-I,r&&(d?z>N*M?E=(Sr(u,c)?-P:P)/M:P=(Sr(u,c)?-E:E)*M:l?(E=P/M,c=u):(P=E*M,u=c));const T=u?x+P:x,$=c?w+E:w;return{width:_+(u?-P:P),height:b+(c?-E:E),x:i[0]*P*(u?-1:1)+T,y:i[1]*E*(c?-1:1)+$}}(m,a.controlDirection,u,a.boundaries,a.keepAspectRatio,z,v,x),A=N!==M,T=S!==P,$=k!==l&&A,C=I!==d&&T;if(!($||C||A||T))return;if(($||C||1===z[0]||1===z[1])&&(E.x=$?k:g.x,E.y=C?I:g.y,g.x=E.x,g.y=E.y,_.length>0)){const t=k-l,e=I-d;for(const n of _)n.position={x:n.position.x-t+z[0]*(N-M),y:n.position.y-e+z[1]*(S-P)},c.push(n)}if((A||T)&&(E.width=!A||a.resizeDirection&&"horizontal"!==a.resizeDirection?g.width:N,E.height=!T||a.resizeDirection&&"vertical"!==a.resizeDirection?g.height:S,g.width=E.width,g.height=E.height),y&&p.expandParent){const t=z[0]*(E.width??0);E.x&&E.x0?1:a<0?-1:0,s>0?1:s<0?-1:0];return a&&r&&(u[0]=-1*u[0]),s&&i&&(u[1]=-1*u[1]),u}({width:g.width,prevWidth:M,height:g.height,prevHeight:P,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),D={...g,direction:O},H=f?.(t,D);!1!==H&&(b=!0,h?.(t,D),o(E,c))}).on("end",t=>{b&&(d?.(t,{...g}),r?.({...g}),b=!1)});i.call(M)},destroy:function(){i.on(".drag",null)}}},t.XY_RESIZER_HANDLE_POSITIONS=["top-left","top-right","bottom-left","bottom-right"],t.XY_RESIZER_LINE_POSITIONS=["top","right","bottom","left"],t.addEdge=(t,n,o={})=>{if(!t.source||!t.target)return o.onError?.("006",e.error006()),n;const r=o.getEdgeId||F;let i;return i=h(t)?{...t}:{...t,id:r(t)},((t,e)=>e.some(e=>!(e.source!==t.source||e.target!==t.target||e.sourceHandle!==t.sourceHandle&&(e.sourceHandle||t.sourceHandle)||e.targetHandle!==t.targetHandle&&(e.targetHandle||t.targetHandle))))(i,n)?n:(null===i.sourceHandle&&delete i.sourceHandle,null===i.targetHandle&&delete i.targetHandle,n.concat(i))},t.adoptUserNodes=function(t,e,n,o={}){const r=ct(ut,o),i={i:0},a=new Map(e),s=r?.elevateNodesOnSelect&&!ht(r.zIndexMode)?1e3:0;let u=t.length>0,c=!1;e.clear(),n.clear();for(const l of t){let t=a.get(l.id);if(r.checkEquality&&l===t?.internals.userNode)e.set(l.id,t);else{const n=f(l,r.nodeOrigin),o=D(l.extent)?l.extent:r.nodeExtent,i=v(n,o,H(l));t={...r.defaults,...l,measured:{width:l.measured?.width,height:l.measured?.height},internals:{positionAbsolute:i,handleBounds:lt(l,t),z:ft(l,s,r.zIndexMode),userNode:l}},e.set(l.id,t)}void 0!==t.measured&&void 0!==t.measured.width&&void 0!==t.measured.height||t.hidden||(u=!1),l.parentId&&dt(t,e,n,o,i),c||=l.selected??!1}return{nodesInitialized:u,hasSelectedNodes:c}},t.areConnectionMapsEqual=function(t,e){if(!t&&!e)return!0;if(!t||!e||t.size!==e.size)return!1;if(!t.size&&!e.size)return!0;for(const n of t.keys())if(!e.has(n))return!1;return!0},t.areSetsEqual=function(t,e){if(t.size!==e.size)return!1;for(const n of t)if(!e.has(n))return!1;return!0},t.boxToRect=P,t.calcAutoPan=_,t.calculateNodePosition=m,t.clamp=y,t.clampPosition=v,t.clampPositionToParent=x,t.createDevWarn=(t,e)=>(t,e)=>{},t.createMarkerIds=function(t,{id:e,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return t.reduce((t,a)=>([a.markerStart||o,a.markerEnd||r].forEach(o=>{if(o&&"object"==typeof o){const r=rt(o,e);i.has(r)||(t.push({id:r,color:o.color||n,...o}),i.add(r))}}),t),[]).sort((t,e)=>t.id.localeCompare(e.id))},t.defaultAriaLabelConfig=o,t.elementSelectionKeys=["Enter"," ","Escape"],t.errorMessages=e,t.evaluateAbsolutePosition=function(t,e={width:0,height:0},n,o,r){const i={...t},a=o.get(n);if(a){const t=a.origin||r;i.x+=a.internals.positionAbsolute.x-(e.width??0)*t[0],i.y+=a.internals.positionAbsolute.y-(e.height??0)*t[1]}return i},t.fitViewport=async function({nodes:t,width:e,height:n,panZoom:o,minZoom:r,maxZoom:i},a){if(0===t.size)return!0;const s=function(t,e){const n=new Map,o=e?.nodes?new Set(e.nodes.map(t=>t.id)):null;return t.forEach(t=>{!t.measured.width||!t.measured.height||!e?.includeHiddenNodes&&t.hidden||o&&!o.has(t.id)||n.set(t.id,t)}),n}(t,a),u=p(s),c=C(u,e,n,a?.minZoom??r,a?.maxZoom??i,a?.padding??.1);return await o.setViewport(c,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),!0},t.getBezierEdgeCenter=Z,t.getBezierPath=function({sourceX:e,sourceY:n,sourcePosition:o=t.Position.Bottom,targetX:r,targetY:i,targetPosition:a=t.Position.Top,curvature:s=.25}){const[u,c]=j({pos:o,x1:e,y1:n,x2:r,y2:i,c:s}),[l,h]=j({pos:a,x1:r,y1:i,x2:e,y2:n,c:s}),[d,f,p,g]=Z({sourceX:e,sourceY:n,targetX:r,targetY:i,sourceControlX:u,sourceControlY:c,targetControlX:l,targetControlY:h});return[`M${e},${n} C${u},${c} ${l},${h} ${r},${i}`,d,f,p,g]},t.getBoundsOfBoxes=b,t.getBoundsOfRects=N,t.getConnectedEdges=g,t.getConnectionStatus=function(t){return null===t?null:t?"valid":"invalid"},t.getDimensions=L,t.getEdgeCenter=W,t.getEdgeId=F,t.getEdgePosition=function(n){const{sourceNode:o,targetNode:r}=n;if(!tt(o)||!tt(r))return null;const i=o.internals.handleBounds||et(o.handles),a=r.internals.handleBounds||et(r.handles),s=ot(i?.source??[],n.sourceHandle),u=ot(n.connectionMode===t.ConnectionMode.Strict?a?.target??[]:(a?.target??[]).concat(a?.source??[]),n.targetHandle);if(!s||!u)return n.onError?.("008",e.error008(s?"target":"source",{id:n.id,sourceHandle:n.sourceHandle,targetHandle:n.targetHandle})),null;const c=s?.position||t.Position.Bottom,l=u?.position||t.Position.Top,h=nt(o,s,c),d=nt(r,u,l);return{sourceX:h.x,sourceY:h.y,targetX:d.x,targetY:d.y,sourcePosition:c,targetPosition:l}},t.getEdgeToolbarTransform=function(t,e,n,o="center",r="center"){return`translate(${t}px, ${e}px) scale(${1/n}) translate(${-(it[o]??50)}%, ${-(at[r]??50)}%)`},t.getElementsToRemove=async function({nodesToRemove:t=[],edgesToRemove:e=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(t.map(t=>t.id)),a=[];for(const t of n){if(!1===t.deletable)continue;const e=i.has(t.id),n=!e&&t.parentId&&a.find(e=>e.id===t.parentId);(e||n)&&a.push(t)}const s=new Set(e.map(t=>t.id)),u=o.filter(t=>!1!==t.deletable),c=g(a,u);for(const t of u){s.has(t.id)&&!c.find(e=>e.id===t.id)&&c.push(t)}if(!r)return{edges:c,nodes:a};const l=await r({nodes:a,edges:c});return"boolean"==typeof l?l?{edges:c,nodes:a}:{edges:[],nodes:[]}:l},t.getElevatedEdgeZIndex=function({sourceNode:t,targetNode:e,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){return"manual"===i?o:(r&&n?o+1e3:o)+Math.max(t.parentId||r&&t.selected?t.internals.z:0,e.parentId||r&&e.selected?e.internals.z:0)},t.getEventPosition=V,t.getHandleBounds=q,t.getHandlePosition=nt,t.getHostForElement=X,t.getIncomers=(t,e,n)=>{if(!t.id)return[];const o=new Set;return n.forEach(e=>{e.target===t.id&&o.add(e.source)}),e.filter(t=>o.has(t.id))},t.getInternalNodesBounds=p,t.getMarkerId=rt,t.getNodeDimensions=H,t.getNodePositionWithOrigin=f,t.getNodeToolbarTransform=function(e,n,o,r,i){let a=.5;"start"===i?a=0:"end"===i&&(a=1);let s=[(e.x+e.width*a)*n.zoom+n.x,e.y*n.zoom+n.y-r],u=[-100*a,-100];switch(o){case t.Position.Right:s=[(e.x+e.width)*n.zoom+n.x+r,(e.y+e.height*a)*n.zoom+n.y],u=[0,-100*a];break;case t.Position.Bottom:s[1]=(e.y+e.height)*n.zoom+n.y+r,u[1]=0;break;case t.Position.Left:s=[e.x*n.zoom+n.x-r,(e.y+e.height*a)*n.zoom+n.y],u=[-100,-100*a]}return`translate(${s[0]}px, ${s[1]}px) translate(${u[0]}%, ${u[1]}%)`},t.getNodesBounds=(t,e={nodeOrigin:[0,0]})=>{if(0===t.length)return{x:0,y:0,width:0,height:0};const n=t.reduce((t,n)=>{const o="string"==typeof n;let r=e.nodeLookup||o?void 0:n;e.nodeLookup&&(r=o?e.nodeLookup.get(n):d(n)?n:e.nodeLookup.get(n.id));const i=r?z(r,e.nodeOrigin):{x:0,y:0,x2:0,y2:0};return b(t,i)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return P(n)},t.getNodesInside=(t,e,[n,o,r]=[0,0,1],i=!1,a=!1)=>{const s={...A(e,[n,o,r]),width:e.width/r,height:e.height/r},u=[];for(const e of t.values()){const{measured:t,selectable:n=!0,hidden:o=!1}=e;if(a&&!n||o)continue;const r=t.width??e.width??e.initialWidth??null,c=t.height??e.height??e.initialHeight??null,l=S(s,E(e)),h=(r??0)*(c??0),d=i&&l>0;(!e.internals.handleBounds||d||l>=h||e.dragging)&&u.push(e)}return u},t.getOutgoers=(t,e,n)=>{if(!t.id)return[];const o=new Set;return n.forEach(e=>{e.source===t.id&&o.add(e.target)}),e.filter(t=>o.has(t.id))},t.getOverlappingArea=S,t.getPointerPosition=B,t.getSmoothStepPath=function({sourceX:e,sourceY:n,sourcePosition:o=t.Position.Bottom,targetX:r,targetY:i,targetPosition:a=t.Position.Top,borderRadius:s=5,centerX:u,centerY:c,offset:l=20,stepPosition:h=.5}){const[d,f,p,g,m]=Q({source:{x:e,y:n},sourcePosition:o,target:{x:r,y:i},targetPosition:a,center:{x:u,y:c},offset:l,stepPosition:h});let y=`M${d[0].x} ${d[0].y}`;for(let t=1;t{e?.has(n)||o.push(t)}),o.length&&n(o)},t.handleExpandParent=pt,t.infiniteExtent=n,t.initialConnection={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},t.isCoordinateExtent=D,t.isEdgeBase=h,t.isEdgeVisible=function({sourceNode:t,targetNode:e,width:n,height:o,transform:r}){const i=b(z(t),z(e));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return S(a,P(i))>0},t.isInputDOMNode=function(t){const e=t.composedPath?.()?.[0]||t.target;return 1===e?.nodeType&&(Y.includes(e.nodeName)||e.hasAttribute("contenteditable")||!!e.closest(".nokey"))},t.isInternalNodeBase=d,t.isMacOs=O,t.isManualZIndexMode=ht,t.isMouseEvent=R,t.isNodeBase=t=>"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),t.isNumeric=k,t.isRectObject=t=>k(t.width)&&k(t.height)&&k(t.x)&&k(t.y),t.mergeAriaLabelConfig=function(t){return{...o,...t||{}}},t.nodeHasDimensions=function(t){return void 0!==(t.measured?.width??t.width??t.initialWidth)&&void 0!==(t.measured?.height??t.height??t.initialHeight)},t.nodeToBox=z,t.nodeToRect=E,t.oppositePosition=l,t.panBy=async function({delta:t,panZoom:e,transform:n,translateExtent:o,width:r,height:i}){if(!e||!t.x&&!t.y)return!1;const a=await e.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[r,i]],o);return!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2])},t.pointToRendererPoint=A,t.reconnectEdge=(t,n,o,r={shouldReplaceId:!0})=>{const{id:i,...a}=t;if(!n.source||!n.target)return r.onError?.("006",e.error006()),o;if(!o.find(e=>e.id===t.id))return r.onError?.("007",e.error007(i)),o;const s=r.getEdgeId||F,u={...a,id:r.shouldReplaceId?s(n):i,source:n.source,target:n.target,sourceHandle:n.sourceHandle,targetHandle:n.targetHandle};return o.filter(t=>t.id!==i).concat(u)},t.rectToBox=M,t.rendererPointToPoint=T,t.shallowNodeData=function(t,e){if(null===t||null===e)return!1;const n=Array.isArray(t)?t:[t],o=Array.isArray(e)?e:[e];if(n.length!==o.length)return!1;for(let t=0;t0){const t=pt(d,e,n,r);c.push(...t)}return{changes:c,updatedInternals:u}},t.withResolvers=function(){let t,e;return{promise:new Promise((n,o)=>{t=n,e=o}),resolve:t,reject:e}}});