UNPKG

@xyflow/system

Version:

xyflow core system that powers React Flow and Svelte Flow.

1 lines 98.5 kB
!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:()=>"[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:t=>`Node type "${t}" 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: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."},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}=B(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,N(t)),o=!0)})),o?M(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}=B(n),{x:i,y:a}=n.internals.positionAbsolute;return v(t,[[i,a],[i+o,a+r]],e)}const w=(t,e,n)=>t<e?y(Math.abs(t-e),1,e)/e:t>n?-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)}),P=({x:t,y:e,width:n,height:o})=>({x:t,y:e,x2:t+n,y2:e+o}),M=({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}},N=(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)}},z=(t,e)=>M(b(P(t),P(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),A=(t,e)=>{},I=(t,e=[1,1])=>({x:e[0]*Math.round(t.x/e[0]),y:e[1]*Math.round(t.y/e[1])}),T=({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},$=({x:t,y:e},[n,o,r])=>({x:t*r+n,y:e*r+o});function C(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(`[React Flow] The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}const H=(t,e,n,o,r,i)=>{const a=function(t,e,n){if("string"==typeof t||"number"==typeof t){const o=C(t,n),r=C(t,e);return{top:o,right:r,bottom:o,left:r,x:2*r,y:2*o}}if("object"==typeof t){const o=C(t.top??t.y??0,n),r=C(t.bottom??t.y??0,n),i=C(t.left??t.x??0,e),a=C(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,[e,n,o]),{x:u,y:c}=$({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 B(t){return{width:t.measured?.width??t.width??t.initialWidth??0,height:t.measured?.height??t.height??t.initialHeight??0}}function L(t,{snapGrid:e=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:a}=q(t),s=T({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 R=t=>({width:t.offsetWidth,height:t.offsetHeight}),X=t=>t?.getRootNode?.()||window?.document,Y=["INPUT","SELECT","TEXTAREA"];const V=t=>"clientX"in t,q=(t,e)=>{const n=V(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)}},Z=(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,...R(e)}})):null};function G({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 j(t,e){return t>=0?.5*t:25*e*Math.sqrt(-t)}function W({pos:e,x1:n,y1:o,x2:r,y2:i,c:a}){switch(e){case t.Position.Left:return[n-j(n-r,a),o];case t.Position.Right:return[n+j(r-n,a),o];case t.Position.Top:return[n,o-j(o-i,a)];case t.Position.Bottom:return[n,o+j(i-o,a)]}}function F({sourceX:t,sourceY:e,targetX:n,targetY:o}){const r=Math.abs(n-t)/2,i=n<t?n+r:n-r,a=Math.abs(o-e)/2;return[i,o<e?o+a:o-a,r,a]}const K=({source:t,sourceHandle:e,target:n,targetHandle:o})=>`xy-edge__${t}${e||""}-${n}${o||""}`;const U={[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}},Q=({source:e,sourcePosition:n=t.Position.Bottom,target:o})=>n===t.Position.Left||n===t.Position.Right?e.x<o.x?{x:1,y:0}:{x:-1,y:0}:e.y<o.y?{x:0,y:1}:{x:0,y:-1},J=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function tt(t){return t&&!(!t.internals.handleBounds&&!t.handles?.length)&&!!(t.measured.width||t.width||t.initialWidth)}function et(t){if(!t)return null;const e=[],n=[];for(const o of t)o.width=o.width??1,o.height=o.height??1,"source"===o.type?e.push(o):"target"===o.type&&n.push(o);return{source:e,target:n}}function nt(e,n,o=t.Position.Left,r=!1){const i=(n?.x??0)+e.internals.positionAbsolute.x,a=(n?.y??0)+e.internals.positionAbsolute.y,{width:s,height:u}=n??B(e);if(r)return{x:i+s/2,y:a+u/2};switch(n?.position??o){case t.Position.Top:return{x:i+s/2,y:a};case t.Position.Right:return{x:i+s,y:a+u/2};case t.Position.Bottom:return{x:i+s/2,y:a+u};case t.Position.Left:return{x:i,y:a+u/2}}}function ot(t,e){return t&&(e?t.find((t=>t.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=1e3,ut=10,ct={nodeOrigin:[0,0],nodeExtent:n,elevateNodesOnSelect:!0,defaults:{}},lt={...ct,checkEquality:!0};function ht(t,e){const n={...t};for(const t in e)void 0!==e[t]&&(n[t]=e[t]);return n}function dt(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 ft(t,e,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:s}=ht(ct,o),u=t.parentId,c=e.get(u);if(!c)return void console.warn(`Parent node ${u} 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&&!c.parentId&&void 0===c.internals.rootParentIndex&&(c.internals.rootParentIndex=++r.i,c.internals.z=c.internals.z+r.i*ut),r&&void 0!==c.internals.rootParentIndex&&(r.i=c.internals.rootParentIndex);const l=i?st:0,{x:h,y:d,z:p}=function(t,e,n,o,r){const{x:i,y:a}=e.internals.positionAbsolute,s=B(t),u=f(t,n),c=D(t.extent)?v(u,t.extent,s):u;let l=v({x:i+c.x,y:a+c.y},o,s);"parent"===t.extent&&(l=x(l,s,e));const h=pt(t,r),d=e.internals.z??0;return{x:l.x,y:l.y,z:d>=h?d+1:h}}(t,c,a,s,l),{positionAbsolute:g}=t.internals,m=h!==g.x||d!==g.y;(m||p!==t.internals.z)&&e.set(t.id,{...t,internals:{...t.internals,positionAbsolute:m?{x:h,y:d}:g,z:p}})}function pt(t,e){return(k(t.zIndex)?t.zIndex:0)+(t.selected?e:0)}function gt(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=z(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=B(i),c=i.origin??o,l=e.x<s.x?Math.round(Math.abs(s.x-e.x)):0,h=e.y<s.y?Math.round(Math.abs(s.y-e.y)):0,d=Math.max(u.width,Math.round(e.width)),f=Math.max(u.height,Math.round(e.height)),p=(d-u.width)*c[0],g=(f-u.height)*c[1];(l>0||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<e.width||u.height<e.height||l||h)&&r.push({id:a,type:"dimensions",setAttributes:!0,dimensions:{width:d+(l?c[0]*l-p:0),height:f+(h?c[1]*h-g:0)}})})),r}function mt(t,e,n,o,r,i){let a=r;const s=o.get(a)||new Map;o.set(a,s.set(n,e)),a=`${r}-${t}`;const u=o.get(a)||new Map;if(o.set(a,u.set(n,e)),i){a=`${r}-${t}-${i}`;const s=o.get(a)||new Map;o.set(a,s.set(n,e))}}var yt={value:()=>{}};function vt(){for(var t,e=0,n=arguments.length,o={};e<n;++e){if(!(t=arguments[e]+"")||t in o||/[\s.]/.test(t))throw new Error("illegal type: "+t);o[t]=[]}return new xt(o)}function xt(t){this._=t}function wt(t,e){for(var n,o=0,r=t.length;o<r;++o)if((n=t[o]).name===e)return n.value}function _t(t,e,n){for(var o=0,r=t.length;o<r;++o)if(t[o].name===e){t[o]=yt,t=t.slice(0,o).concat(t.slice(o+1));break}return null!=n&&t.push({name:e,value:n}),t}xt.prototype=vt.prototype={constructor:xt,on:function(t,e){var n,o,r=this._,i=(o=r,(t+"").trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");if(n>=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(;++a<s;)if(n=(t=i[a]).type)r[n]=_t(r[n],t.name,e);else if(null==e)for(n in r)r[n]=_t(r[n],t.name,null);return this}for(;++a<s;)if((n=(t=i[a]).type)&&(n=wt(r[n],t.name)))return n},copy:function(){var t={},e=this._;for(var n in e)t[n]=e[n].slice();return new xt(t)},call:function(t,e){if((n=arguments.length-2)>0)for(var n,o,r=new Array(n),i=0;i<n;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(i=0,n=(o=this._[t]).length;i<n;++i)o[i].value.apply(e,r)},apply:function(t,e,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var o=this._[t],r=0,i=o.length;r<i;++r)o[r].value.apply(e,n)}};var bt="http://www.w3.org/1999/xhtml",Pt={svg:"http://www.w3.org/2000/svg",xhtml:bt,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Mt(t){var e=t+="",n=e.indexOf(":");return n>=0&&"xmlns"!==(e=t.slice(0,n))&&(t=t.slice(n+1)),Pt.hasOwnProperty(e)?{space:Pt[e],local:t}:t}function Et(t){return function(){var e=this.ownerDocument,n=this.namespaceURI;return n===bt&&e.documentElement.namespaceURI===bt?e.createElement(t):e.createElementNS(n,t)}}function Nt(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function zt(t){var e=Mt(t);return(e.local?Nt:Et)(e)}function St(){}function kt(t){return null==t?St:function(){return this.querySelector(t)}}function At(){return[]}function It(t){return null==t?At:function(){return this.querySelectorAll(t)}}function Tt(t){return function(){return null==(e=t.apply(this,arguments))?[]:Array.isArray(e)?e:Array.from(e);var e}}function $t(t){return function(){return this.matches(t)}}function Ct(t){return function(e){return e.matches(t)}}var Ht=Array.prototype.find;function Ot(){return this.firstElementChild}var Dt=Array.prototype.filter;function Bt(){return Array.from(this.children)}function Lt(t){return new Array(t.length)}function Rt(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;s<c;++s)(a=e[s])?(a.__data__=i[s],o[s]=a):n[s]=new Rt(t,i[s]);for(;s<u;++s)(a=e[s])&&(r[s]=a)}function Yt(t,e,n,o,r,i,a){var s,u,c,l=new Map,h=e.length,d=i.length,f=new Array(h);for(s=0;s<h;++s)(u=e[s])&&(f[s]=c=a.call(u,u.__data__,s,e)+"",l.has(c)?r[s]=u:l.set(c,u));for(s=0;s<d;++s)c=a.call(t,i[s],s,i)+"",(u=l.get(c))?(o[s]=u,u.__data__=i[s],l.delete(c)):n[s]=new Rt(t,i[s]);for(s=0;s<h;++s)(u=e[s])&&l.get(f[s])===u&&(r[s]=u)}function Vt(t){return t.__data__}function qt(t){return"object"==typeof t&&"length"in t?t:Array.from(t)}function Zt(t,e){return t<e?-1:t>e?1:t>=e?0:NaN}function Gt(t){return function(){this.removeAttribute(t)}}function jt(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Wt(t,e){return function(){this.setAttribute(t,e)}}function Ft(t,e){return function(){this.setAttributeNS(t.space,t.local,e)}}function Kt(t,e){return function(){var n=e.apply(this,arguments);null==n?this.removeAttribute(t):this.setAttribute(t,n)}}function Ut(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 Qt(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Jt(t){return function(){this.style.removeProperty(t)}}function te(t,e,n){return function(){this.style.setProperty(t,e,n)}}function ee(t,e,n){return function(){var o=e.apply(this,arguments);null==o?this.style.removeProperty(t):this.style.setProperty(t,o,n)}}function ne(t,e){return t.style.getPropertyValue(e)||Qt(t).getComputedStyle(t,null).getPropertyValue(e)}function oe(t){return function(){delete this[t]}}function re(t,e){return function(){this[t]=e}}function ie(t,e){return function(){var n=e.apply(this,arguments);null==n?delete this[t]:this[t]=n}}function ae(t){return t.trim().split(/^|\s+/)}function se(t){return t.classList||new ue(t)}function ue(t){this._node=t,this._names=ae(t.getAttribute("class")||"")}function ce(t,e){for(var n=se(t),o=-1,r=e.length;++o<r;)n.add(e[o])}function le(t,e){for(var n=se(t),o=-1,r=e.length;++o<r;)n.remove(e[o])}function he(t){return function(){ce(this,t)}}function de(t){return function(){le(this,t)}}function fe(t,e){return function(){(e.apply(this,arguments)?ce:le)(this,t)}}function pe(){this.textContent=""}function ge(t){return function(){this.textContent=t}}function me(t){return function(){var e=t.apply(this,arguments);this.textContent=null==e?"":e}}function ye(){this.innerHTML=""}function ve(t){return function(){this.innerHTML=t}}function xe(t){return function(){var e=t.apply(this,arguments);this.innerHTML=null==e?"":e}}function we(){this.nextSibling&&this.parentNode.appendChild(this)}function _e(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function be(){return null}function Pe(){var t=this.parentNode;t&&t.removeChild(this)}function Me(){var t=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ee(){var t=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(t,this.nextSibling):t}function Ne(t){return function(){var e=this.__on;if(e){for(var n,o=0,r=-1,i=e.length;o<i;++o)n=e[o],t.type&&n.type!==t.type||n.name!==t.name?e[++r]=n:this.removeEventListener(n.type,n.listener,n.options);++r?e.length=r:delete this.__on}}}function ze(t,e,n){return function(){var o,r=this.__on,i=function(t){return function(e){t.call(this,e,this.__data__)}}(e);if(r)for(var a=0,s=r.length;a<s;++a)if((o=r[a]).type===t.type&&o.name===t.name)return this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=i,o.options=n),void(o.value=e);this.addEventListener(t.type,i,n),o={type:t.type,name:t.name,value:e,listener:i,options:n},r?r.push(o):this.__on=[o]}}function Se(t,e,n){var o=Qt(t),r=o.CustomEvent;"function"==typeof r?r=new r(e,n):(r=o.document.createEvent("Event"),n?(r.initEvent(e,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(e,!1,!1)),t.dispatchEvent(r)}function ke(t,e){return function(){return Se(this,t,e)}}function Ae(t,e){return function(){return Se(this,t,e.apply(this,arguments))}}Rt.prototype={constructor:Rt,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,e){return this._parent.insertBefore(t,e)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}},ue.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var e=this._names.indexOf(t);e>=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 Te(t,e){this._groups=t,this._parents=e}function $e(){return new Te([[document.documentElement]],Ie)}function Ce(t){return"string"==typeof t?new Te([[document.querySelector(t)]],[document.documentElement]):new Te([[t]],Ie)}function He(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]}Te.prototype=$e.prototype={constructor:Te,select:function(t){"function"!=typeof t&&(t=kt(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r<n;++r)for(var i,a,s=e[r],u=s.length,c=o[r]=new Array(u),l=0;l<u;++l)(i=s[l])&&(a=t.call(i,i.__data__,l,s))&&("__data__"in i&&(a.__data__=i.__data__),c[l]=a);return new Te(o,this._parents)},selectAll:function(t){t="function"==typeof t?Tt(t):It(t);for(var e=this._groups,n=e.length,o=[],r=[],i=0;i<n;++i)for(var a,s=e[i],u=s.length,c=0;c<u;++c)(a=s[c])&&(o.push(t.call(a,a.__data__,c,s)),r.push(a));return new Te(o,r)},selectChild:function(t){return this.select(null==t?Ot:function(t){return function(){return Ht.call(this.children,t)}}("function"==typeof t?t:Ct(t)))},selectChildren:function(t){return this.selectAll(null==t?Bt:function(t){return function(){return Dt.call(this.children,t)}}("function"==typeof t?t:Ct(t)))},filter:function(t){"function"!=typeof t&&(t=$t(t));for(var e=this._groups,n=e.length,o=new Array(n),r=0;r<n;++r)for(var i,a=e[r],s=a.length,u=o[r]=[],c=0;c<s;++c)(i=a[c])&&t.call(i,i.__data__,c,a)&&u.push(i);return new Te(o,this._parents)},data:function(t,e){if(!arguments.length)return Array.from(this,Vt);var n,o=e?Yt:Xt,r=this._parents,i=this._groups;"function"!=typeof t&&(n=t,t=function(){return n});for(var a=i.length,s=new Array(a),u=new Array(a),c=new Array(a),l=0;l<a;++l){var h=r[l],d=i[l],f=d.length,p=qt(t.call(h,h&&h.__data__,l,r)),g=p.length,m=u[l]=new Array(g),y=s[l]=new Array(g);o(h,d,m,y,c[l]=new Array(f),p,e);for(var v,x,w=0,_=0;w<g;++w)if(v=m[w]){for(w>=_&&(_=w+1);!(x=y[_])&&++_<g;);v._next=x||null}}return(s=new Te(s,r))._enter=u,s._exit=c,s},enter:function(){return new Te(this._enter||this._groups.map(Lt),this._parents)},exit:function(){return new Te(this._exit||this._groups.map(Lt),this._parents)},join:function(t,e,n){var o=this.enter(),r=this,i=this.exit();return"function"==typeof t?(o=t(o))&&(o=o.selection()):o=o.append(t+""),null!=e&&(r=e(r))&&(r=r.selection()),null==n?i.remove():n(i),o&&r?o.merge(r).order():r},merge:function(t){for(var e=t.selection?t.selection():t,n=this._groups,o=e._groups,r=n.length,i=o.length,a=Math.min(r,i),s=new Array(r),u=0;u<a;++u)for(var c,l=n[u],h=o[u],d=l.length,f=s[u]=new Array(d),p=0;p<d;++p)(c=l[p]||h[p])&&(f[p]=c);for(;u<r;++u)s[u]=n[u];return new Te(s,this._parents)},selection:function(){return this},order:function(){for(var t=this._groups,e=-1,n=t.length;++e<n;)for(var o,r=t[e],i=r.length-1,a=r[i];--i>=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=Zt);for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var a,s=n[i],u=s.length,c=r[i]=new Array(u),l=0;l<u;++l)(a=s[l])&&(c[l]=a);c.sort(e)}return new Te(r,this._parents).order()},call:function(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this},nodes:function(){return Array.from(this)},node:function(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var o=t[e],r=0,i=o.length;r<i;++r){var a=o[r];if(a)return a}return null},size:function(){let t=0;for(const e of this)++t;return t},empty:function(){return!this.node()},each:function(t){for(var e=this._groups,n=0,o=e.length;n<o;++n)for(var r,i=e[n],a=0,s=i.length;a<s;++a)(r=i[a])&&t.call(r,r.__data__,a,i);return this},attr:function(t,e){var n=Mt(t);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((null==e?n.local?jt:Gt:"function"==typeof e?n.local?Ut:Kt:n.local?Ft:Wt)(n,e))},style:function(t,e,n){return arguments.length>1?this.each((null==e?Jt:"function"==typeof e?ee:te)(t,e,null==n?"":n)):ne(this.node(),t)},property:function(t,e){return arguments.length>1?this.each((null==e?oe:"function"==typeof e?ie:re)(t,e)):this.node()[t]},classed:function(t,e){var n=ae(t+"");if(arguments.length<2){for(var o=se(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each(("function"==typeof e?fe:e?he:de)(n,e))},text:function(t){return arguments.length?this.each(null==t?pe:("function"==typeof t?me:ge)(t)):this.node().textContent},html:function(t){return arguments.length?this.each(null==t?ye:("function"==typeof t?xe:ve)(t)):this.node().innerHTML},raise:function(){return this.each(we)},lower:function(){return this.each(_e)},append:function(t){var e="function"==typeof t?t:zt(t);return this.select((function(){return this.appendChild(e.apply(this,arguments))}))},insert:function(t,e){var n="function"==typeof t?t:zt(t),o=null==e?be:"function"==typeof e?e:kt(e);return this.select((function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)}))},remove:function(){return this.each(Pe)},clone:function(t){return this.select(t?Ee:Me)},datum:function(t){return arguments.length?this.property("__data__",t):this.node().__data__},on:function(t,e,n){var o,r,i=function(t){return t.trim().split(/^|\s+/).map((function(t){var e="",n=t.indexOf(".");return n>=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:Ne,o=0;o<a;++o)this.each(s(i[o],e,n));return this}var s=this.node().__on;if(s)for(var u,c=0,l=s.length;c<l;++c)for(o=0,u=s[c];o<a;++o)if((r=i[o]).type===u.type&&r.name===u.name)return u.value},dispatch:function(t,e){return this.each(("function"==typeof e?Ae:ke)(t,e))},[Symbol.iterator]:function*(){for(var t=this._groups,e=0,n=t.length;e<n;++e)for(var o,r=t[e],i=0,a=r.length;i<a;++i)(o=r[i])&&(yield o)}};const Oe={passive:!1},De={capture:!0,passive:!1};function Be(t){t.stopImmediatePropagation()}function Le(t){t.preventDefault(),t.stopImmediatePropagation()}function Re(t){var e=t.document.documentElement,n=Ce(t).on("dragstart.drag",Le,De);"onselectstart"in e?n.on("selectstart.drag",Le,De):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Xe(t,e){var n=t.document.documentElement,o=Ce(t).on("dragstart.drag",null);e&&(o.on("click.drag",Le,De),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}var Ye=t=>()=>t;function Ve(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 qe(t){return!t.ctrlKey&&!t.button}function Ze(){return this.parentNode}function Ge(t,e){return null==e?{x:t.x,y:t.y}:e}function je(){return navigator.maxTouchPoints||"ontouchstart"in this}function We(){var t,e,n,o,r=qe,i=Ze,a=Ge,s=je,u={},c=vt("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&&(Ce(a.view).on("mousemove.drag",p,De).on("mouseup.drag",g,De),Re(a.view),Be(a),n=!1,t=a.clientX,e=a.clientY,u("start",a))}}function p(o){if(Le(o),!n){var r=o.clientX-t,i=o.clientY-e;n=r*r+i*i>h}u.mouse("drag",o)}function g(t){Ce(t.view).on("mousemove.drag mouseup.drag",null),Xe(t.view,n),Le(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;n<u;++n)(o=x(this,s,t,e,a[n].identifier,a[n]))&&(Be(t),o("start",t,a[n]))}}function y(t){var e,n,o=t.changedTouches,r=o.length;for(e=0;e<r;++e)(n=u[o[e].identifier])&&(Le(t),n("drag",t,o[e]))}function v(t){var e,n,r=t.changedTouches,i=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),e=0;e<i;++e)(n=u[r[e].identifier])&&(Be(t),n("end",t,r[e]))}function x(t,e,n,o,r,i){var s,h,f,p=c.copy(),g=He(i||n,e);if(null!=(f=a.call(t,new Ve("beforestart",{sourceEvent:n,target:d,identifier:r,active:l,x:g[0],y:g[1],dx:0,dy:0,dispatch:p}),o)))return s=f.x-g[0]||0,h=f.y-g[1]||0,function n(i,a,c){var m,y=g;switch(i){case"start":u[r]=n,m=l++;break;case"end":delete u[r],--l;case"drag":g=He(c||a,e),m=l}p.call(i,t,new Ve(i,{sourceEvent:a,subject:f,target:d,identifier:r,active:m,x:g[0]+s,y:g[1]+h,dx:g[0]-y[0],dy:g[1]-y[1],dispatch:p}),o)}}return d.filter=function(t){return arguments.length?(r="function"==typeof t?t:Ye(!!t),d):r},d.container=function(t){return arguments.length?(i="function"==typeof t?t:Ye(t),d):i},d.subject=function(t){return arguments.length?(a="function"==typeof t?t:Ye(t),d):a},d.touchable=function(t){return arguments.length?(s="function"==typeof t?t:Ye(!!t),d):s},d.on=function(){var t=c.on.apply(c,arguments);return t===c?d:t},d.clickDistance=function(t){return arguments.length?(h=(t=+t)*t,d):Math.sqrt(h)},d}function Fe(t,e){if(!t.parentId)return!1;const n=e.get(t.parentId);return!!n&&(!!n.selected||Fe(n,e))}function Ke(t,e,n){let o=t;do{if(o?.matches?.(e))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function Ue({nodeId:t,dragItems:e,nodeLookup:n,dragging:o=!0}){const r=[];for(const[t,i]of e){const e=n.get(t)?.internals.userNode;e&&r.push({...e,position:i.position,dragging:o})}if(!t)return[r[0],r];const i=n.get(t)?.internals.userNode;return[i?{...i,position:e.get(t)?.position||i.position,dragging:o}:r[0],r]}Ve.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};const Qe=250;function Je(t,e,n,o){let r=[],i=1/0;const a=function(t,e,n){const o=[],r={x:t.x-n,y:t.y-n,width:2*n,height:2*n};for(const t of e.values())S(r,E(t))>0&&o.push(t);return o}(t,n,e+Qe);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||(c<i?(r=[{...s,x:a,y:u}],i=c):c===i&&r.push({...s,x:a,y:u}))}}if(!r.length)return null;if(r.length>1){const t="source"===o.type?"target":"source";return r.find((e=>e.type===t))??r[0]}return r[0]}function tn(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 en(t,e){return t||(e?.classList.contains("target")?"target":e?.classList.contains("source")?"source":null)}const nn=()=>!0;function on(e,{handle:n,connectionMode:o,fromNodeId:r,fromHandleId:i,fromType:a,doc:s,lib:u,flowId:c,isValidConnection:l=nn,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}=q(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=en(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=tn(n,e,a,h,o,!0)}return v}const rn={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=nn,onReconnectEnd:w,updateConnection:b,getTransform:P,getFromHandle:M,autoPanSpeed:E,dragThreshold:N=1,handleDomNode:z}){const S=X(e.target);let k,A=0;const{x:I,y:C}=q(e),H=en(a,z),O=u?.getBoundingClientRect();let D=!1;if(!O||!H)return;const B=tn(i,H,r,c,n);if(!B)return;let L=q(e,O),R=!1,Y=null,V=!1,Z=null;function G(){if(!d||!O)return;const[t,e]=_(L,O,E);p({x:t,y:e}),A=requestAnimationFrame(G)}const j={...B,nodeId:i,type:H,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};function K(){D=!0,b(F),m?.(e,{nodeId:i,handleId:r,handleType:H})}function U(t){if(!D){const{x:e,y:n}=q(t),o=e-I,r=n-C;if(!(o*o+r*r>N*N))return;K()}if(!M()||!j)return void Q(t);const e=P();L=q(t,O),k=Je(T(L,e,!1,[1,1]),o,c,j),R||(G(),R=!0);const a=on(t,{handle:k,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:s?"target":"source",isValidConnection:x,doc:S,lib:h,flowId:f,nodeLookup:c});Z=a.handleDomNode,Y=a.connection,V=function(t,e){let n=null;return e?n=!0:t&&!e&&(n=!1),n}(!!k,a.isValid);const u={...F,isValid:V,to:a.toHandle&&V?$({x:a.toHandle.x,y:a.toHandle.y},e):L,toHandle:a.toHandle,toPosition:V&&a.toHandle?a.toHandle.position:l[j.position],toNode:a.toHandle?c.get(a.toHandle.nodeId):null};V&&k&&F.toHandle&&u.toHandle&&F.toHandle.type===u.toHandle.type&&F.toHandle.nodeId===u.toHandle.nodeId&&F.toHandle.id===u.toHandle.id&&F.to.x===u.to.x&&F.to.y===u.to.y||(b(u),F=u)}function Q(t){if(!("touches"in t&&t.touches.length>0)){if(D){(k||Z)&&Y&&V&&y?.(Y);const{inProgress:e,...n}=F,o={...n,toPosition:F.toHandle?F.toPosition:null};v?.(t,o),a&&w?.(t,o)}g(),cancelAnimationFrame(A),R=!1,V=!1,Y=null,Z=null,S.removeEventListener("mousemove",U),S.removeEventListener("mouseup",Q),S.removeEventListener("touchmove",U),S.removeEventListener("touchend",Q)}}0===N&&K(),S.addEventListener("mousemove",U),S.addEventListener("mouseup",Q),S.addEventListener("touchmove",U),S.addEventListener("touchend",Q)},isValid:on};function an(t,e,n){t.prototype=e.prototype=n,n.constructor=t}function sn(t,e){var n=Object.create(t.prototype);for(var o in e)n[o]=e[o];return n}function un(){}var cn=.7,ln=1/cn,hn="\\s*([+-]?\\d+)\\s*",dn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",fn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",pn=/^#([0-9a-f]{3,8})$/,gn=new RegExp(`^rgb\\(${hn},${hn},${hn}\\)$`),mn=new RegExp(`^rgb\\(${fn},${fn},${fn}\\)$`),yn=new RegExp(`^rgba\\(${hn},${hn},${hn},${dn}\\)$`),vn=new RegExp(`^rgba\\(${fn},${fn},${fn},${dn}\\)$`),xn=new RegExp(`^hsl\\(${dn},${fn},${fn}\\)$`),wn=new RegExp(`^hsla\\(${dn},${fn},${fn},${dn}\\)$`),_n={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 bn(){return this.rgb().formatHex()}function Pn(){return this.rgb().formatRgb()}function Mn(t){var e,n;return t=(t+"").trim().toLowerCase(),(e=pn.exec(t))?(n=e[1].length,e=parseInt(e[1],16),6===n?En(e):3===n?new Sn(e>>8&15|e>>4&240,e>>4&15|240&e,(15&e)<<4|15&e,1):8===n?Nn(e>>24&255,e>>16&255,e>>8&255,(255&e)/255):4===n?Nn(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=gn.exec(t))?new Sn(e[1],e[2],e[3],1):(e=mn.exec(t))?new Sn(255*e[1]/100,255*e[2]/100,255*e[3]/100,1):(e=yn.exec(t))?Nn(e[1],e[2],e[3],e[4]):(e=vn.exec(t))?Nn(255*e[1]/100,255*e[2]/100,255*e[3]/100,e[4]):(e=xn.exec(t))?Cn(e[1],e[2]/100,e[3]/100,1):(e=wn.exec(t))?Cn(e[1],e[2]/100,e[3]/100,e[4]):_n.hasOwnProperty(t)?En(_n[t]):"transparent"===t?new Sn(NaN,NaN,NaN,0):null}function En(t){return new Sn(t>>16&255,t>>8&255,255&t,1)}function Nn(t,e,n,o){return o<=0&&(t=e=n=NaN),new Sn(t,e,n,o)}function zn(t,e,n,o){return 1===arguments.length?((r=t)instanceof un||(r=Mn(r)),r?new Sn((r=r.rgb()).r,r.g,r.b,r.opacity):new Sn):new Sn(t,e,n,null==o?1:o);var r}function Sn(t,e,n,o){this.r=+t,this.g=+e,this.b=+n,this.opacity=+o}function kn(){return`#${$n(this.r)}${$n(this.g)}${$n(this.b)}`}function An(){const t=In(this.opacity);return`${1===t?"rgb(":"rgba("}${Tn(this.r)}, ${Tn(this.g)}, ${Tn(this.b)}${1===t?")":`, ${t})`}`}function In(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Tn(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function $n(t){return((t=Tn(t))<16?"0":"")+t.toString(16)}function Cn(t,e,n,o){return o<=0?t=e=n=NaN:n<=0||n>=1?t=e=NaN:e<=0&&(t=NaN),new On(t,e,n,o)}function Hn(t){if(t instanceof On)return new On(t.h,t.s,t.l,t.opacity);if(t instanceof un||(t=Mn(t)),!t)return new On;if(t instanceof On)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*(n<o):n===i?(o-e)/s+2:(e-n)/s+4,s/=u<.5?i+r:2-i-r,a*=60):s=u>0&&u<1?0:a,new On(a,s,u,t.opacity)}function On(t,e,n,o){this.h=+t,this.s=+e,this.l=+n,this.opacity=+o}function Dn(t){return(t=(t||0)%360)<0?t+360:t}function Bn(t){return Math.max(0,Math.min(1,t||0))}function Ln(t,e,n){return 255*(t<60?e+(n-e)*t/60:t<180?n:t<240?e+(n-e)*(240-t)/60:e)}an(un,Mn,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:bn,formatHex:bn,formatHex8:function(){return this.rgb().formatHex8()},formatHsl:function(){return Hn(this).formatHsl()},formatRgb:Pn,toString:Pn}),an(Sn,zn,sn(un,{brighter(t){return t=null==t?ln:Math.pow(ln,t),new Sn(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=null==t?cn:Math.pow(cn,t),new Sn(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Sn(Tn(this.r),Tn(this.g),Tn(this.b),In(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:kn,formatHex:kn,formatHex8:function(){return`#${$n(this.r)}${$n(this.g)}${$n(this.b)}${$n(255*(isNaN(this.opacity)?1:this.opacity))}`},formatRgb:An,toString:An})),an(On,(function(t,e,n,o){return 1===arguments.length?Hn(t):new On(t,e,n,null==o?1:o)}),sn(un,{brighter(t){return t=null==t?ln:Math.pow(ln,t),new On(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=null==t?cn:Math.pow(cn,t),new On(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 Sn(Ln(t>=240?t-240:t+120,r,o),Ln(t,r,o),Ln(t<120?t+240:t-120,r,o),this.opacity)},clamp(){return new On(Dn(this.h),Bn(this.s),Bn(this.l),In(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=In(this.opacity);return`${1===t?"hsl(":"hsla("}${Dn(this.h)}, ${100*Bn(this.s)}%, ${100*Bn(this.l)}%${1===t?")":`, ${t})`}`}}));var Rn=t=>()=>t;function Xn(t){return 1==(t=+t)?Yn: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):Rn(isNaN(e)?n:e)}}function Yn(t,e){var n=e-t;return n?function(t,e){return function(n){return t+n*e}}(t,n):Rn(isNaN(t)?e:t)}var Vn=function t(e){var n=Xn(e);function o(t,e){var o=n((t=zn(t)).r,(e=zn(e)).r),r=n(t.g,e.g),i=n(t.b,e.b),a=Yn(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 qn(t,e){e||(e=[]);var n,o=t?Math.min(e.length,t.length):0,r=e.slice();return function(i){for(n=0;n<o;++n)r[n]=t[n]*(1-i)+e[n]*i;return r}}function Zn(t,e){var n,o=e?e.length:0,r=t?Math.min(o,t.length):0,i=new Array(r),a=new Array(o);for(n=0;n<r;++n)i[n]=Qn(t[n],e[n]);for(;n<o;++n)a[n]=e[n];return function(t){for(n=0;n<r;++n)a[n]=i[n](t);return a}}function Gn(t,e){var n=new Date;return t=+t,e=+e,function(o){return n.setTime(t*(1-o)+e*o),n}}function jn(t,e){return t=+t,e=+e,function(n){return t*(1-n)+e*n}}function Wn(t,e){var n,o={},r={};for(n in null!==t&&"object"==typeof t||(t={}),null!==e&&"object"==typeof e||(e={}),e)n in t?o[n]=Qn(t[n],e[n]):r[n]=e[n];return function(t){for(n in o)r[n]=o[n](t);return r}}var Fn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Kn=new RegExp(Fn.source,"g");function Un(t,e){var n,o,r,i=Fn.lastIndex=Kn.lastIndex=0,a=-1,s=[],u=[];for(t+="",e+="";(n=Fn.exec(t))&&(o=Kn.exec(e));)(r=o.index)>i&&(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:jn(n,o)})),i=Kn.lastIndex;return i<e.length&&(r=e.slice(i),s[a]?s[a]+=r:s[++a]=r),s.length<2?u[0]?function(t){return function(e){return t(e)+""}}(u[0].x):function(t){return function(){return t}}(e):(e=u.length,function(t){for(var n,o=0;o<e;++o)s[(n=u[o]).i]=n.x(t);return s.join("")})}function Qn(t,e){var n,o,r=typeof e;return null==e||"boolean"===r?Rn(e):("number"===r?jn:"string"===r?(n=Mn(e))?(e=n,Vn):Un:e instanceof Mn?Vn:e instanceof Date?Gn:(o=e,!ArrayBuffer.isView(o)||o instanceof DataView?Array.isArray(e)?Zn:"function"!=typeof e.valueOf&&"function"!=typeof e.toString||isNaN(e)?Wn:jn:qn))(t,e)}var Jn,to=180/Math.PI,eo={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function no(t,e,n,o,r,i){var a,s,u;return(a=Math.sqrt(t*t+e*e))&&(t/=a,e/=a),(u=t*n+e*o)&&(n-=t*u,o-=e*u),(s=Math.sqrt(n*n+o*o))&&(n/=s,o/=s,u/=s),t*o<e*n&&(t=-t,e=-e,u=-u,a=-a),{translateX:r,translateY:i,rotate:Math.atan2(e,t)*to,skewX:Math.atan(u)*to,scaleX:a,scaleY:s}}function oo(t,e,n,o){function r(t){return t.length?t.pop()+" ":""}return function(i,a){var s=[],u=[];return i=t(i),a=t(a),function(t,o,r,i,a,s){if(t!==r||o!==i){var u=a.push("translate(",null,e,null,n);s.push({i:u-4,x:jn(t,r)},{i:u-2,x:jn(o,i)})}else(r||i)&&a.push("translate("+r+e+i+n)}(i.translateX,i.translateY,a.translateX,a.translateY,s,u),function(t,e,n,i){t!==e?(t-e>180?e+=360:e-t>180&&(t+=360),i.push({i:n.push(r(n)+"rotate(",null,o)-2,x:jn(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:jn(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:jn(t,n)},{i:s-2,x:jn(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<o;)s[(e=u[n]).i]=e.x(t);return s.join("")}}}var ro=oo((function(t){const e=new("function"==typeof DOMMatrix?DOMMatrix:WebKitCSSMatrix)(t+"");return e.isIdentity?eo:no(e.a,e.b,e.c,e.d,e.e,e.f)}),"px, ","px)","deg)"),io=oo((function(t){return null==t?eo:(Jn||(Jn=document.createElementNS("http://www.w3.org/2000/svg","g")),Jn.setAttribute("transform",t),(t=Jn.transform.baseVal.consolidate())?no((t=t.matrix).a,t.b,t.c,t.d,t.e,t.f):eo)}),", ",")",")");function ao(t){return((t=Math.exp(t))+1/t)/2}var so,uo,co=function t(e,n,o){function r(t,r){var i,a,s=t[0],u=t[1],c=t[2],l=r[0],h=r[1],d=r[2],f=l-s,p=h-u,g=f*f+p*p;if(g<1e-12)a=Math.log(d/c)/e,i=function(t){return[s+t*f,u+t*p,c*Math.exp(e*t*a)]};else{var m=Math.sqrt(g),y=(d*d-c*c+o*g)/(2*c*n*m),v=(d*d-c*c-o*g)/(2*d*n*m),x=Math.log(Math.sqrt(y*y+1)-y),w=Math.log(Math.sqrt(v*v+1)-v);a=(w-x)/e,i=function(t){var o,r=t*a,i=ao(x),l=c/(n*m)*(i*(o=e*r+x,((o=Math.exp(2*o))-1)/(o+1))-function(t){return((t=Math.exp(t))-1/t)/2}(x));return[s+l*f,u+l*p,c*i/ao(e*r+x)]}}return i.duration=1e3*a*e/Math.SQRT2,i}return r.rho=function(e){var n=Math.max(.001,+e),o=n*n;return t(n,o,o*o)},r}(Math.SQRT2,2,4),lo=0,ho=0,fo=0,po=1e3,go=0,mo=0,yo=0,vo="object"==typeof performance&&performance.now?performance:Date,xo="object"==typeof window&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function wo(){return mo||(xo(_o),mo=vo.now()+yo)}function _o(){mo=0}function bo(){this._call=this._time=this._next=null}function Po(t,e,n){var o=new bo;return o.restart(t,e,n),o}function Mo(){mo=(go=vo.now())+yo,lo=ho=0;try{!function(){wo(),++lo;for(var t,e=so;e;)(t=mo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--lo}()}finally{lo=0,function(){var t,e,n=so,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:so=e);uo=t,No(o)}(),mo=0}}function Eo(){var t=vo.now(),e=t-go;e>po&&(yo-=e,go=t)}function No(t){lo||(ho&&(ho=clearTimeout(ho)),t-mo>24?(t<1/0&&(ho=setTimeout(Mo,t-vo.now()-yo)),fo&&(fo=clearInterval(fo))):(fo||(go=vo.now(),fo=setInterval(Eo,po)),lo=1,xo(Mo)))}function zo(t,e,n){var o=new bo;return e=null==e?0:+e,o.restart((n=>{o.stop(),t(n+e)}),e,n),o}bo.prototype=Po.prototype={constructor:bo,restart:function(t,e,n){if("function"!=typeof t)throw new TypeError("callback is not a function");n=(null==n?wo():+n)+(null==e?0:+e),this._next||uo===this||(uo?uo._next=this:so=this,uo=this),this._call=t,this._time=n,No()},stop:function(){this._call&&(this._call=null,this._time=1/0,No())}};var So=vt("start","end","cancel","interrupt"),ko=[],Ao=0,Io=1,To=2,$o=3,Co=4,Ho=5,Oo=6;function Do(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=Io,n.timer.restart(a,n.delay,n.time),n.delay<=t&&a(t-n.delay)}function a(i){var c,l,h,d;if(n.state!==Io)return u();for(c in r)if((d=r[c]).name===n.name){if(d.state===$o)return zo(a);d.state===Co?(d.state=Oo,d.timer.stop(),d.on.call("interrupt",t,t.__data__,d.index,d.group),delete r[c]):+c<e&&(d.state=Oo,d.timer.stop(),d.on.call("cancel",t,t.__data__,d.index,d.group),delete r[c])}if(zo((function(){n.state===$o&&(n.state=Co,n.timer.restart(s,n.delay,n.time),s(i))})),n.state=To,n.on.call("start",t,t.__data__,n.index,n.group),n.state===To){for(n.state=$o,o=new Array(h=n.tween.length),c=0,l=-1;c<h;++c)(d=n.tween[c].value.call(t,t.__data__,n.index,n.group))&&(o[++l]=d);