ima2-gen 3.8.2 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/commands/gen.js +10 -0
- package/docs/migration/runtime-test-inventory.md +5 -1
- package/lib/alphaDecode.js +18 -0
- package/lib/atlasCloudImageAdapter.js +6 -1
- package/lib/backgroundPresets.js +28 -1
- package/lib/generatePipeline.js +74 -5
- package/lib/imageBackgroundParam.js +108 -0
- package/lib/promptImport/gptImageHints.js +4 -1
- package/lib/responsesFallback.js +8 -2
- package/lib/responsesImageAdapter.js +10 -1
- package/package.json +2 -2
- package/routes/video.js +7 -0
- package/skills/ima2/SKILL.md +28 -4
- package/skills/ima2-front/references/asset-requirements.md +23 -8
- package/skills/ima2-uiux/SKILL.md +15 -4
- package/ui/dist/.vite/manifest.json +32 -32
- package/ui/dist/assets/{AgentWorkspace-bUd5NsQ_.js → AgentWorkspace-fcIXiWV6.js} +1 -1
- package/ui/dist/assets/AssetGenWorkspace-CqXyN9at.js +2 -0
- package/ui/dist/assets/{AssetsWorkspace-DO_wfFQB.js → AssetsWorkspace-xwHFVOb7.js} +1 -1
- package/ui/dist/assets/{CardNewsWorkspace-D3M0w8pg.js → CardNewsWorkspace-ltdjG40R.js} +1 -1
- package/ui/dist/assets/{GenerationRequestLogPanel-WvSV0yXP.js → GenerationRequestLogPanel-B68EUfUg.js} +1 -1
- package/ui/dist/assets/{HomeWorkspace-BGCBf9iK.js → HomeWorkspace-BBOG_aNm.js} +1 -1
- package/ui/dist/assets/KeyingPanel-Bv0n_bhk.js +1 -0
- package/ui/dist/assets/{NodeCanvas-DwbR2nol.js → NodeCanvas-VwdctvAW.js} +1 -1
- package/ui/dist/assets/{PromptBuilderPanel-KSH3ChjC.js → PromptBuilderPanel-BBMpF_3Q.js} +1 -1
- package/ui/dist/assets/{PromptImportDialog-CjHiCEo9.js → PromptImportDialog-D4QYbRfH.js} +2 -2
- package/ui/dist/assets/{PromptImportDiscoverySection-CWU-vKyM.js → PromptImportDiscoverySection-Bx7BeTFh.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-_zRnJGkJ.js → PromptImportFolderSection-Bwf60URx.js} +1 -1
- package/ui/dist/assets/{PromptLibraryPanel-64VN4nml.js → PromptLibraryPanel-mNG2wZkQ.js} +2 -2
- package/ui/dist/assets/{SettingsWorkspace-DZMNEpuq.js → SettingsWorkspace-DA5tIa0Q.js} +1 -1
- package/ui/dist/assets/{SpriteRecipeWorkspace-Y6GqpVHs.js → SpriteRecipeWorkspace-Da9qTQX0.js} +1 -1
- package/ui/dist/assets/{index-CFixfKaC.js → index-Bv1Yrz8W.js} +3 -3
- package/ui/dist/assets/{index-waPOg2eb.css → index-C0nfanMr.css} +1 -1
- package/ui/dist/assets/{index-XXtoj9ME.js → index-CxEuSZMC.js} +16 -16
- package/ui/dist/assets/{pptxgen.es-hCJot2gG.js → pptxgen.es-BE4CSd5F.js} +1 -1
- package/ui/dist/assets/{useAgentDialogFocus-PWmMjerz.js → useAgentDialogFocus-R64NV-ZZ.js} +1 -1
- package/ui/dist/index.html +2 -2
- package/ui/dist/assets/AssetGenWorkspace-8fK-K64E.js +0 -2
- package/ui/dist/assets/KeyingPanel-CEBLIhhu.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as Gr,g as qa,R as Ua,a as N,j as p,u as ae,b as Q,i as Vt,S as Ka,f as Qa,c as Ja,d as ec,n as tc,e as nc,w as oc,h as rc,k as qr,l as ic,m as sc,o as ac,p as cc,q as Ct,s as lc}from"./index-XXtoj9ME.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var uc={value:()=>{}};function an(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Ft(n)}function Ft(e){this._=e}function dc(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,o=dc(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=fc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Ao(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ao(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ft(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function fc(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Ao(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=uc,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var zn="http://www.w3.org/1999/xhtml";const Po={svg:"http://www.w3.org/2000/svg",xhtml:zn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Po.hasOwnProperty(t)?{space:Po[t],local:e}:e}function hc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zn&&t.documentElement.namespaceURI===zn?t.createElement(e):t.createElementNS(n,e)}}function pc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ur(e){var t=cn(e);return(t.local?pc:hc)(t)}function gc(){}function oo(e){return e==null?gc:function(){return this.querySelector(e)}}function mc(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new de(o,this._parents)}function yc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function xc(){return[]}function Kr(e){return e==null?xc:function(){return this.querySelectorAll(e)}}function wc(e){return function(){return yc(e.apply(this,arguments))}}function vc(e){typeof e=="function"?e=wc(e):e=Kr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new de(o,r)}function Qr(e){return function(){return this.matches(e)}}function Jr(e){return function(t){return t.matches(e)}}var bc=Array.prototype.find;function _c(e){return function(){return bc.call(this.children,e)}}function Sc(){return this.firstElementChild}function Nc(e){return this.select(e==null?Sc:_c(typeof e=="function"?e:Jr(e)))}var Ec=Array.prototype.filter;function Cc(){return Array.from(this.children)}function Ic(e){return function(){return Ec.call(this.children,e)}}function kc(e){return this.selectAll(e==null?Cc:Ic(typeof e=="function"?e:Jr(e)))}function Mc(e){typeof e!="function"&&(e=Qr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new de(o,this._parents)}function ei(e){return new Array(e.length)}function Tc(){return new de(this._enter||this._groups.map(ei),this._parents)}function qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}qt.prototype={constructor:qt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Ac(e){return function(){return e}}function Pc(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new qt(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function Dc(e,t,n,o,r,i,s){var a,c,l=new Map,u=t.length,d=i.length,f=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(f[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?r[a]=c:l.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(o[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new qt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(r[a]=c)}function $c(e){return e.__data__}function jc(e,t){if(!arguments.length)return Array.from(this,$c);var n=t?Dc:Pc,o=this._parents,r=this._groups;typeof e!="function"&&(e=Ac(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=o[l],d=r[l],f=d.length,h=Rc(e.call(u,u&&u.__data__,l,o)),m=h.length,b=a[l]=new Array(m),x=s[l]=new Array(m),y=c[l]=new Array(f);n(u,d,b,x,y,h,t);for(var w=0,g=0,v,C;w<m;++w)if(v=b[w]){for(w>=g&&(g=w+1);!(C=x[g])&&++g<m;);v._next=C||null}}return s=new de(s,o),s._enter=a,s._exit=c,s}function Rc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hc(){return new de(this._exit||this._groups.map(ei),this._parents)}function Oc(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function zc(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),c=0;c<s;++c)for(var l=n[c],u=o[c],d=l.length,f=a[c]=new Array(d),h,m=0;m<d;++m)(h=l[m]||u[m])&&(f[m]=h);for(;c<r;++c)a[c]=n[c];return new de(a,this._parents)}function Lc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Bc(e){e||(e=Vc);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,c=r[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new de(r,this._parents).order()}function Vc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Fc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Yc(){return Array.from(this)}function Xc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function Wc(){let e=0;for(const t of this)++e;return e}function Zc(){return!this.node()}function Gc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function qc(e){return function(){this.removeAttribute(e)}}function Uc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Kc(e,t){return function(){this.setAttribute(e,t)}}function Qc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Jc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function el(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function tl(e,t){var n=cn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Uc:qc:typeof t=="function"?n.local?el:Jc:n.local?Qc:Kc)(n,t))}function ti(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function nl(e){return function(){this.style.removeProperty(e)}}function ol(e,t,n){return function(){this.style.setProperty(e,t,n)}}function rl(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function il(e,t,n){return arguments.length>1?this.each((t==null?nl:typeof t=="function"?rl:ol)(e,t,n??"")):ot(this.node(),e)}function ot(e,t){return e.style.getPropertyValue(t)||ti(e).getComputedStyle(e,null).getPropertyValue(t)}function sl(e){return function(){delete this[e]}}function al(e,t){return function(){this[e]=t}}function cl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function ll(e,t){return arguments.length>1?this.each((t==null?sl:typeof t=="function"?cl:al)(e,t)):this.node()[e]}function ni(e){return e.trim().split(/^|\s+/)}function ro(e){return e.classList||new oi(e)}function oi(e){this._node=e,this._names=ni(e.getAttribute("class")||"")}oi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ri(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function ii(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function ul(e){return function(){ri(this,e)}}function dl(e){return function(){ii(this,e)}}function fl(e,t){return function(){(t.apply(this,arguments)?ri:ii)(this,e)}}function hl(e,t){var n=ni(e+"");if(arguments.length<2){for(var o=ro(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?fl:t?ul:dl)(n,t))}function pl(){this.textContent=""}function gl(e){return function(){this.textContent=e}}function ml(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function yl(e){return arguments.length?this.each(e==null?pl:(typeof e=="function"?ml:gl)(e)):this.node().textContent}function xl(){this.innerHTML=""}function wl(e){return function(){this.innerHTML=e}}function vl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function bl(e){return arguments.length?this.each(e==null?xl:(typeof e=="function"?vl:wl)(e)):this.node().innerHTML}function _l(){this.nextSibling&&this.parentNode.appendChild(this)}function Sl(){return this.each(_l)}function Nl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function El(){return this.each(Nl)}function Cl(e){var t=typeof e=="function"?e:Ur(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Il(){return null}function kl(e,t){var n=typeof e=="function"?e:Ur(e),o=t==null?Il:typeof t=="function"?t:oo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Ml(){var e=this.parentNode;e&&e.removeChild(this)}function Tl(){return this.each(Ml)}function Al(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Pl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Dl(e){return this.select(e?Pl:Al)}function $l(e){return arguments.length?this.property("__data__",e):this.node().__data__}function jl(e){return function(t){e.call(this,t,this.__data__)}}function Rl(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Hl(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Ol(e,t,n){return function(){var o=this.__on,r,i=jl(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function zl(e,t,n){var o=Rl(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Ol:Hl,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function si(e,t,n){var o=ti(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Ll(e,t){return function(){return si(this,e,t)}}function Bl(e,t){return function(){return si(this,e,t.apply(this,arguments))}}function Vl(e,t){return this.each((typeof t=="function"?Bl:Ll)(e,t))}function*Fl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var ai=[null];function de(e,t){this._groups=e,this._parents=t}function It(){return new de([[document.documentElement]],ai)}function Yl(){return this}de.prototype=It.prototype={constructor:de,select:mc,selectAll:vc,selectChild:Nc,selectChildren:kc,filter:Mc,data:jc,enter:Tc,exit:Hc,join:Oc,merge:zc,selection:Yl,order:Lc,sort:Bc,call:Fc,nodes:Yc,node:Xc,size:Wc,empty:Zc,each:Gc,attr:tl,style:il,property:ll,classed:hl,text:yl,html:bl,raise:Sl,lower:El,append:Cl,insert:kl,remove:Tl,clone:Dl,datum:$l,on:zl,dispatch:Vl,[Symbol.iterator]:Fl};function ue(e){return typeof e=="string"?new de([[document.querySelector(e)]],[document.documentElement]):new de([[e]],ai)}function Xl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=Xl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const Wl={passive:!1},yt={capture:!0,passive:!1};function Sn(e){e.stopImmediatePropagation()}function tt(e){e.preventDefault(),e.stopImmediatePropagation()}function ci(e){var t=e.document.documentElement,n=ue(e).on("dragstart.drag",tt,yt);"onselectstart"in t?n.on("selectstart.drag",tt,yt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function li(e,t){var n=e.document.documentElement,o=ue(e).on("dragstart.drag",null);t&&(o.on("click.drag",tt,yt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Dt=e=>()=>e;function Ln(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Ln.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Zl(e){return!e.ctrlKey&&!e.button}function Gl(){return this.parentNode}function ql(e,t){return t??{x:e.x,y:e.y}}function Ul(){return navigator.maxTouchPoints||"ontouchstart"in this}function ui(){var e=Zl,t=Gl,n=ql,o=Ul,r={},i=an("start","drag","end"),s=0,a,c,l,u,d=0;function f(v){v.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",y,Wl).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,C){if(!(u||!e.call(this,v,C))){var S=g(this,t.call(this,v,C),v,C,"mouse");S&&(ue(v.view).on("mousemove.drag",m,yt).on("mouseup.drag",b,yt),ci(v.view),Sn(v),l=!1,a=v.clientX,c=v.clientY,S("start",v))}}function m(v){if(tt(v),!l){var C=v.clientX-a,S=v.clientY-c;l=C*C+S*S>d}r.mouse("drag",v)}function b(v){ue(v.view).on("mousemove.drag mouseup.drag",null),li(v.view,l),tt(v),r.mouse("end",v)}function x(v,C){if(e.call(this,v,C)){var S=v.changedTouches,E=t.call(this,v,C),M=S.length,P,z;for(P=0;P<M;++P)(z=g(this,E,v,C,S[P].identifier,S[P]))&&(Sn(v),z("start",v,S[P]))}}function y(v){var C=v.changedTouches,S=C.length,E,M;for(E=0;E<S;++E)(M=r[C[E].identifier])&&(tt(v),M("drag",v,C[E]))}function w(v){var C=v.changedTouches,S=C.length,E,M;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),E=0;E<S;++E)(M=r[C[E].identifier])&&(Sn(v),M("end",v,C[E]))}function g(v,C,S,E,M,P){var z=i.copy(),T=he(P||S,C),O,H,_;if((_=n.call(v,new Ln("beforestart",{sourceEvent:S,target:f,identifier:M,active:s,x:T[0],y:T[1],dx:0,dy:0,dispatch:z}),E))!=null)return O=_.x-T[0]||0,H=_.y-T[1]||0,function I(k,A,j){var $=T,V;switch(k){case"start":r[M]=I,V=s++;break;case"end":delete r[M],--s;case"drag":T=he(j||A,C),V=s;break}z.call(k,v,new Ln(k,{sourceEvent:A,subject:_,target:f,identifier:M,active:V,x:T[0]+O,y:T[1]+H,dx:T[0]-$[0],dy:T[1]-$[1],dispatch:z}),E)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Dt(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:Dt(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:Dt(v),f):n},f.touchable=function(v){return arguments.length?(o=typeof v=="function"?v:Dt(!!v),f):o},f.on=function(){var v=i.on.apply(i,arguments);return v===i?f:v},f.clickDistance=function(v){return arguments.length?(d=(v=+v)*v,f):Math.sqrt(d)},f}function io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function di(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function kt(){}var xt=.7,Ut=1/xt,nt="\\s*([+-]?\\d+)\\s*",wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Kl=/^#([0-9a-f]{3,8})$/,Ql=new RegExp(`^rgb\\(${nt},${nt},${nt}\\)$`),Jl=new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`),eu=new RegExp(`^rgba\\(${nt},${nt},${nt},${wt}\\)$`),tu=new RegExp(`^rgba\\(${_e},${_e},${_e},${wt}\\)$`),nu=new RegExp(`^hsl\\(${wt},${_e},${_e}\\)$`),ou=new RegExp(`^hsla\\(${wt},${_e},${_e},${wt}\\)$`),Do={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};io(kt,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$o,formatHex:$o,formatHex8:ru,formatHsl:iu,formatRgb:jo,toString:jo});function $o(){return this.rgb().formatHex()}function ru(){return this.rgb().formatHex8()}function iu(){return fi(this).formatHsl()}function jo(){return this.rgb().formatRgb()}function Ye(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Kl.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ro(t):n===3?new le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$t(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$t(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Ql.exec(e))?new le(t[1],t[2],t[3],1):(t=Jl.exec(e))?new le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=eu.exec(e))?$t(t[1],t[2],t[3],t[4]):(t=tu.exec(e))?$t(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=nu.exec(e))?zo(t[1],t[2]/100,t[3]/100,1):(t=ou.exec(e))?zo(t[1],t[2]/100,t[3]/100,t[4]):Do.hasOwnProperty(e)?Ro(Do[e]):e==="transparent"?new le(NaN,NaN,NaN,0):null}function Ro(e){return new le(e>>16&255,e>>8&255,e&255,1)}function $t(e,t,n,o){return o<=0&&(e=t=n=NaN),new le(e,t,n,o)}function su(e){return e instanceof kt||(e=Ye(e)),e?(e=e.rgb(),new le(e.r,e.g,e.b,e.opacity)):new le}function Bn(e,t,n,o){return arguments.length===1?su(e):new le(e,t,n,o??1)}function le(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}io(le,Bn,di(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new le(Ve(this.r),Ve(this.g),Ve(this.b),Kt(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:Ho,formatHex:Ho,formatHex8:au,formatRgb:Oo,toString:Oo}));function Ho(){return`#${Be(this.r)}${Be(this.g)}${Be(this.b)}`}function au(){return`#${Be(this.r)}${Be(this.g)}${Be(this.b)}${Be((isNaN(this.opacity)?1:this.opacity)*255)}`}function Oo(){const e=Kt(this.opacity);return`${e===1?"rgb(":"rgba("}${Ve(this.r)}, ${Ve(this.g)}, ${Ve(this.b)}${e===1?")":`, ${e})`}`}function Kt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ve(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Be(e){return e=Ve(e),(e<16?"0":"")+e.toString(16)}function zo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new pe(e,t,n,o)}function fi(e){if(e instanceof pe)return new pe(e.h,e.s,e.l,e.opacity);if(e instanceof kt||(e=Ye(e)),!e)return new pe;if(e instanceof pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,c=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new pe(s,a,c,e.opacity)}function cu(e,t,n,o){return arguments.length===1?fi(e):new pe(e,t,n,o??1)}function pe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}io(pe,cu,di(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new pe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new le(Nn(e>=240?e-240:e+120,r,o),Nn(e,r,o),Nn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new pe(Lo(this.h),jt(this.s),jt(this.l),Kt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Kt(this.opacity);return`${e===1?"hsl(":"hsla("}${Lo(this.h)}, ${jt(this.s)*100}%, ${jt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Lo(e){return e=(e||0)%360,e<0?e+360:e}function jt(e){return Math.max(0,Math.min(1,e||0))}function Nn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const so=e=>()=>e;function lu(e,t){return function(n){return e+n*t}}function uu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function du(e){return(e=+e)==1?hi:function(t,n){return n-t?uu(t,n,e):so(isNaN(t)?n:t)}}function hi(e,t){var n=t-e;return n?lu(e,n):so(isNaN(e)?t:e)}const Qt=(function e(t){var n=du(t);function o(r,i){var s=n((r=Bn(r)).r,(i=Bn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=hi(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return o.gamma=e,o})(1);function fu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function hu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function pu(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=pt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function gu(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function be(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function mu(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=pt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Vn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,En=new RegExp(Vn.source,"g");function yu(e){return function(){return e}}function xu(e){return function(t){return e(t)+""}}function pi(e,t){var n=Vn.lastIndex=En.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=Vn.exec(e))&&(r=En.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:be(o,r)})),n=En.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?xu(c[0].x):yu(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)a[(d=c[u]).i]=d.x(l);return a.join("")})}function pt(e,t){var n=typeof t,o;return t==null||n==="boolean"?so(t):(n==="number"?be:n==="string"?(o=Ye(t))?(t=o,Qt):pi:t instanceof Ye?Qt:t instanceof Date?gu:hu(t)?fu:Array.isArray(t)?pu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?mu:be)(e,t)}var Bo=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gi(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Bo,skewX:Math.atan(c)*Bo,scaleX:s,scaleY:a}}var Rt;function wu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:gi(t.a,t.b,t.c,t.d,t.e,t.f)}function vu(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Fn:(e=e.matrix,gi(e.a,e.b,e.c,e.d,e.e,e.f))}function mi(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,u,d,f,h,m){if(l!==d||u!==f){var b=h.push("translate(",null,t,null,n);m.push({i:b-4,x:be(l,d)},{i:b-2,x:be(u,f)})}else(d||f)&&h.push("translate("+d+t+f+n)}function s(l,u,d,f){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),f.push({i:d.push(r(d)+"rotate(",null,o)-2,x:be(l,u)})):u&&d.push(r(d)+"rotate("+u+o)}function a(l,u,d,f){l!==u?f.push({i:d.push(r(d)+"skewX(",null,o)-2,x:be(l,u)}):u&&d.push(r(d)+"skewX("+u+o)}function c(l,u,d,f,h,m){if(l!==d||u!==f){var b=h.push(r(h)+"scale(",null,",",null,")");m.push({i:b-4,x:be(l,d)},{i:b-2,x:be(u,f)})}else(d!==1||f!==1)&&h.push(r(h)+"scale("+d+","+f+")")}return function(l,u){var d=[],f=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,d,f),s(l.rotate,u.rotate,d,f),a(l.skewX,u.skewX,d,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,f),l=u=null,function(h){for(var m=-1,b=f.length,x;++m<b;)d[(x=f[m]).i]=x.x(h);return d.join("")}}}var bu=mi(wu,"px, ","px)","deg)"),_u=mi(vu,", ",")",")"),Su=1e-12;function Vo(e){return((e=Math.exp(e))+1/e)/2}function Nu(e){return((e=Math.exp(e))-1/e)/2}function Eu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yt=(function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],d=s[1],f=s[2],h=u-a,m=d-c,b=h*h+m*m,x,y;if(b<Su)y=Math.log(f/l)/t,x=function(E){return[a+E*h,c+E*m,l*Math.exp(t*E*y)]};else{var w=Math.sqrt(b),g=(f*f-l*l+o*b)/(2*l*n*w),v=(f*f-l*l-o*b)/(2*f*n*w),C=Math.log(Math.sqrt(g*g+1)-g),S=Math.log(Math.sqrt(v*v+1)-v);y=(S-C)/t,x=function(E){var M=E*y,P=Vo(C),z=l/(n*w)*(P*Eu(t*M+C)-Nu(C));return[a+z*h,c+z*m,l*P/Vo(t*M+C)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r})(Math.SQRT2,2,4);var rt=0,ft=0,lt=0,yi=1e3,Jt,ht,en=0,Xe=0,ln=0,vt=typeof performance=="object"&&performance.now?performance:Date,xi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return Xe||(xi(Cu),Xe=vt.now()+ln)}function Cu(){Xe=0}function tn(){this._call=this._time=this._next=null}tn.prototype=wi.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ao():+n)+(t==null?0:+t),!this._next&&ht!==this&&(ht?ht._next=this:Jt=this,ht=this),this._call=e,this._time=n,Yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yn())}};function wi(e,t,n){var o=new tn;return o.restart(e,t,n),o}function Iu(){ao(),++rt;for(var e=Jt,t;e;)(t=Xe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--rt}function Fo(){Xe=(en=vt.now())+ln,rt=ft=0;try{Iu()}finally{rt=0,Mu(),Xe=0}}function ku(){var e=vt.now(),t=e-en;t>yi&&(ln-=t,en=e)}function Mu(){for(var e,t=Jt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);ht=e,Yn(o)}function Yn(e){if(!rt){ft&&(ft=clearTimeout(ft));var t=e-Xe;t>24?(e<1/0&&(ft=setTimeout(Fo,e-vt.now()-ln)),lt&&(lt=clearInterval(lt))):(lt||(en=vt.now(),lt=setInterval(ku,yi)),rt=1,xi(Fo))}}function Yo(e,t,n){var o=new tn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Tu=an("start","end","cancel","interrupt"),Au=[],vi=0,Xo=1,Xn=2,Xt=3,Wo=4,Wn=5,Wt=6;function un(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Pu(e,n,{name:t,index:o,group:r,on:Tu,tween:Au,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vi})}function co(e,t){var n=xe(e,t);if(n.state>vi)throw new Error("too late; already scheduled");return n}function Se(e,t){var n=xe(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Pu(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=wi(i,0,n.time);function i(l){n.state=Xo,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,d,f,h;if(n.state!==Xo)return c();for(u in o)if(h=o[u],h.name===n.name){if(h.state===Xt)return Yo(s);h.state===Wo?(h.state=Wt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[u]):+u<t&&(h.state=Wt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[u])}if(Yo(function(){n.state===Xt&&(n.state=Wo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Xn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xn){for(n.state=Xt,r=new Array(f=n.tween.length),u=0,d=-1;u<f;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++d]=h);r.length=d+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wn,1),d=-1,f=r.length;++d<f;)r[d].call(e,u);n.state===Wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wt,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Zt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>Xn&&o.state<Wn,o.state=Wt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Du(e){return this.each(function(){Zt(this,e)})}function $u(e,t){var n,o;return function(){var r=Se(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function ju(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Se(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function Ru(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=xe(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?$u:ju)(n,e,t))}function lo(e,t,n){var o=e._id;return e.each(function(){var r=Se(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return xe(r,o).value[t]}}function bi(e,t){var n;return(typeof t=="number"?be:t instanceof Ye?Qt:(n=Ye(t))?(t=n,Qt):pi)(e,t)}function Hu(e){return function(){this.removeAttribute(e)}}function Ou(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Lu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Bu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Vu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Fu(e,t){var n=cn(e),o=n==="transform"?_u:bi;return this.attrTween(e,typeof t=="function"?(n.local?Vu:Bu)(n,o,lo(this,"attr."+e,t)):t==null?(n.local?Ou:Hu)(n):(n.local?Lu:zu)(n,o,t))}function Yu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Xu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Wu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Xu(e,i)),n}return r._value=t,r}function Zu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Yu(e,i)),n}return r._value=t,r}function Gu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=cn(e);return this.tween(n,(o.local?Wu:Zu)(o,t))}function qu(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function Uu(e,t){return t=+t,function(){co(this,e).delay=t}}function Ku(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?qu:Uu)(t,e)):xe(this.node(),t).delay}function Qu(e,t){return function(){Se(this,e).duration=+t.apply(this,arguments)}}function Ju(e,t){return t=+t,function(){Se(this,e).duration=t}}function ed(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Qu:Ju)(t,e)):xe(this.node(),t).duration}function td(e,t){if(typeof t!="function")throw new Error;return function(){Se(this,e).ease=t}}function nd(e){var t=this._id;return arguments.length?this.each(td(t,e)):xe(this.node(),t).ease}function od(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Se(this,e).ease=n}}function rd(e){if(typeof e!="function")throw new Error;return this.each(od(this._id,e))}function id(e){typeof e!="function"&&(e=Qr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Pe(o,this._parents,this._name,this._id)}function sd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,d=s[a]=new Array(u),f,h=0;h<u;++h)(f=c[h]||l[h])&&(d[h]=f);for(;a<o;++a)s[a]=t[a];return new Pe(s,this._parents,this._name,this._id)}function ad(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function cd(e,t,n){var o,r,i=ad(t)?co:Se;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function ld(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(cd(n,e,t))}function ud(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function dd(){return this.on("end.remove",ud(this._id))}function fd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oo(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),u,d,f=0;f<c;++f)(u=a[f])&&(d=e.call(u,u.__data__,f,a))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d,un(l[f],t,n,f,l,xe(u,n)));return new Pe(i,this._parents,t,n)}function hd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Kr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),h,m=xe(u,n),b=0,x=f.length;b<x;++b)(h=f[b])&&un(h,t,n,b,f,m);i.push(f),s.push(u)}return new Pe(i,s,t,n)}var pd=It.prototype.constructor;function gd(){return new pd(this._groups,this._parents)}function md(e,t){var n,o,r;return function(){var i=ot(this,e),s=(this.style.removeProperty(e),ot(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function _i(e){return function(){this.style.removeProperty(e)}}function yd(e,t,n){var o,r=n+"",i;return function(){var s=ot(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function xd(e,t,n){var o,r,i;return function(){var s=ot(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),ot(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function wd(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=Se(this,e),l=c.on,u=c.value[i]==null?a||(a=_i(t)):void 0;(l!==n||r!==u)&&(o=(n=l).copy()).on(s,r=u),c.on=o}}function vd(e,t,n){var o=(e+="")=="transform"?bu:bi;return t==null?this.styleTween(e,md(e,o)).on("end.style."+e,_i(e)):typeof t=="function"?this.styleTween(e,xd(e,o,lo(this,"style."+e,t))).each(wd(this._id,e)):this.styleTween(e,yd(e,o,t),n).on("end.style."+e,null)}function bd(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function _d(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&bd(e,s,n)),o}return i._value=t,i}function Sd(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,_d(e,t,n??""))}function Nd(e){return function(){this.textContent=e}}function Ed(e){return function(){var t=e(this);this.textContent=t??""}}function Cd(e){return this.tween("text",typeof e=="function"?Ed(lo(this,"text",e)):Nd(e==null?"":e+""))}function Id(e){return function(t){this.textContent=e.call(this,t)}}function kd(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Id(r)),t}return o._value=e,o}function Md(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,kd(e))}function Td(){for(var e=this._name,t=this._id,n=Si(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=xe(c,t);un(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Pe(o,this._parents,e,n)}function Ad(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=Se(this,o),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var Pd=0;function Pe(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Si(){return++Pd}var Me=It.prototype;Pe.prototype={constructor:Pe,select:fd,selectAll:hd,selectChild:Me.selectChild,selectChildren:Me.selectChildren,filter:id,merge:sd,selection:gd,transition:Td,call:Me.call,nodes:Me.nodes,node:Me.node,size:Me.size,empty:Me.empty,each:Me.each,on:ld,attr:Fu,attrTween:Gu,style:vd,styleTween:Sd,text:Cd,textTween:Md,remove:dd,tween:Ru,delay:Ku,duration:ed,ease:nd,easeVarying:rd,end:Ad,[Symbol.iterator]:Me[Symbol.iterator]};function Dd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var $d={time:null,delay:0,duration:250,ease:Dd};function jd(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Rd(e){var t,n;e instanceof Pe?(t=e._id,e=e._name):(t=Si(),(n=$d).time=ao(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&un(c,e,t,l,s,n||jd(c,t));return new Pe(o,this._parents,e,t)}It.prototype.interrupt=Du;It.prototype.transition=Rd;const Ht=e=>()=>e;function Hd(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Te(e,t,n){this.k=e,this.x=t,this.y=n}Te.prototype={constructor:Te,scale:function(e){return e===1?this:new Te(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Te(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var dn=new Te(1,0,0);Ni.prototype=Te.prototype;function Ni(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}function Cn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function Od(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function zd(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Zo(){return this.__zoom||dn}function Ld(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Bd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Ei(){var e=Od,t=zd,n=Vd,o=Ld,r=Bd,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Yt,l=an("start","zoom","end"),u,d,f,h=500,m=150,b=0,x=10;function y(_){_.property("__zoom",Zo).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",z).filter(r).on("touchstart.zoom",T).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,I,k,A){var j=_.selection?_.selection():_;j.property("__zoom",Zo),_!==j?C(_,I,k,A):j.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},y.scaleBy=function(_,I,k,A){y.scaleTo(_,function(){var j=this.__zoom.k,$=typeof I=="function"?I.apply(this,arguments):I;return j*$},k,A)},y.scaleTo=function(_,I,k,A){y.transform(_,function(){var j=t.apply(this,arguments),$=this.__zoom,V=k==null?v(j):typeof k=="function"?k.apply(this,arguments):k,B=$.invert(V),L=typeof I=="function"?I.apply(this,arguments):I;return n(g(w($,L),V,B),j,s)},k,A)},y.translateBy=function(_,I,k,A){y.transform(_,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),s)},null,A)},y.translateTo=function(_,I,k,A,j){y.transform(_,function(){var $=t.apply(this,arguments),V=this.__zoom,B=A==null?v($):typeof A=="function"?A.apply(this,arguments):A;return n(dn.translate(B[0],B[1]).scale(V.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof k=="function"?-k.apply(this,arguments):-k),$,s)},A,j)};function w(_,I){return I=Math.max(i[0],Math.min(i[1],I)),I===_.k?_:new Te(I,_.x,_.y)}function g(_,I,k){var A=I[0]-k[0]*_.k,j=I[1]-k[1]*_.k;return A===_.x&&j===_.y?_:new Te(_.k,A,j)}function v(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function C(_,I,k,A){_.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var j=this,$=arguments,V=S(j,$).event(A),B=t.apply(j,$),L=k==null?v(B):typeof k=="function"?k.apply(j,$):k,W=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),Y=j.__zoom,Z=typeof I=="function"?I.apply(j,$):I,J=c(Y.invert(L).concat(W/Y.k),Z.invert(L).concat(W/Z.k));return function(R){if(R===1)R=Z;else{var D=J(R),F=W/D[2];R=new Te(F,L[0]-D[0]*F,L[1]-D[1]*F)}V.zoom(null,R)}})}function S(_,I,k){return!k&&_.__zooming||new E(_,I)}function E(_,I){this.that=_,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,I),this.taps=0}E.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,I){return this.mouse&&_!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var I=ue(this.that).datum();l.call(_,this.that,new Hd(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),I)}};function M(_,...I){if(!e.apply(this,arguments))return;var k=S(this,I).event(_),A=this.__zoom,j=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,o.apply(this,arguments)))),$=he(_);if(k.wheel)(k.mouse[0][0]!==$[0]||k.mouse[0][1]!==$[1])&&(k.mouse[1]=A.invert(k.mouse[0]=$)),clearTimeout(k.wheel);else{if(A.k===j)return;k.mouse=[$,A.invert($)],Zt(this),k.start()}ut(_),k.wheel=setTimeout(V,m),k.zoom("mouse",n(g(w(A,j),k.mouse[0],k.mouse[1]),k.extent,s));function V(){k.wheel=null,k.end()}}function P(_,...I){if(f||!e.apply(this,arguments))return;var k=_.currentTarget,A=S(this,I,!0).event(_),j=ue(_.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",W,!0),$=he(_,k),V=_.clientX,B=_.clientY;ci(_.view),Cn(_),A.mouse=[$,this.__zoom.invert($)],Zt(this),A.start();function L(Y){if(ut(Y),!A.moved){var Z=Y.clientX-V,J=Y.clientY-B;A.moved=Z*Z+J*J>b}A.event(Y).zoom("mouse",n(g(A.that.__zoom,A.mouse[0]=he(Y,k),A.mouse[1]),A.extent,s))}function W(Y){j.on("mousemove.zoom mouseup.zoom",null),li(Y.view,A.moved),ut(Y),A.event(Y).end()}}function z(_,...I){if(e.apply(this,arguments)){var k=this.__zoom,A=he(_.changedTouches?_.changedTouches[0]:_,this),j=k.invert(A),$=k.k*(_.shiftKey?.5:2),V=n(g(w(k,$),A,j),t.apply(this,I),s);ut(_),a>0?ue(this).transition().duration(a).call(C,V,A,_):ue(this).call(y.transform,V,A,_)}}function T(_,...I){if(e.apply(this,arguments)){var k=_.touches,A=k.length,j=S(this,I,_.changedTouches.length===A).event(_),$,V,B,L;for(Cn(_),V=0;V<A;++V)B=k[V],L=he(B,this),L=[L,this.__zoom.invert(L),B.identifier],j.touch0?!j.touch1&&j.touch0[2]!==L[2]&&(j.touch1=L,j.taps=0):(j.touch0=L,$=!0,j.taps=1+!!u);u&&(u=clearTimeout(u)),$&&(j.taps<2&&(d=L[0],u=setTimeout(function(){u=null},h)),Zt(this),j.start())}}function O(_,...I){if(this.__zooming){var k=S(this,I).event(_),A=_.changedTouches,j=A.length,$,V,B,L;for(ut(_),$=0;$<j;++$)V=A[$],B=he(V,this),k.touch0&&k.touch0[2]===V.identifier?k.touch0[0]=B:k.touch1&&k.touch1[2]===V.identifier&&(k.touch1[0]=B);if(V=k.that.__zoom,k.touch1){var W=k.touch0[0],Y=k.touch0[1],Z=k.touch1[0],J=k.touch1[1],R=(R=Z[0]-W[0])*R+(R=Z[1]-W[1])*R,D=(D=J[0]-Y[0])*D+(D=J[1]-Y[1])*D;V=w(V,Math.sqrt(R/D)),B=[(W[0]+Z[0])/2,(W[1]+Z[1])/2],L=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(k.touch0)B=k.touch0[0],L=k.touch0[1];else return;k.zoom("touch",n(g(V,B,L),k.extent,s))}}function H(_,...I){if(this.__zooming){var k=S(this,I).event(_),A=_.changedTouches,j=A.length,$,V;for(Cn(_),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),$=0;$<j;++$)V=A[$],k.touch0&&k.touch0[2]===V.identifier?delete k.touch0:k.touch1&&k.touch1[2]===V.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(V=he(V,this),Math.hypot(d[0]-V[0],d[1]-V[1])<x)){var B=ue(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:Ht(+_),y):o},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Ht(!!_),y):e},y.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Ht(!!_),y):r},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:Ht([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),y):t},y.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],y):[i[0],i[1]]},y.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(_){return arguments.length?(n=_,y):n},y.duration=function(_){return arguments.length?(a=+_,y):a},y.interpolate=function(_){return arguments.length?(c=_,y):c},y.on=function(){var _=l.on.apply(l,arguments);return _===l?y:_},y.clickDistance=function(_){return arguments.length?(b=(_=+_)*_,y):Math.sqrt(b)},y.tapDistance=function(_){return arguments.length?(x=+_,y):x},y}const ye={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}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:e=>`Node type "${e}" 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:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},bt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ci=["Enter"," ","Escape"],Ii={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var We;(function(e){e.Strict="strict",e.Loose="loose"})(We||(We={}));var Fe;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Fe||(Fe={}));var _t;(function(e){e.Partial="partial",e.Full="full"})(_t||(_t={}));const ki={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var je;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(je||(je={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Go={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function Mi(e){return e===null?null:e?"valid":"invalid"}const Ti=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Fd=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uo=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mt=(e,t=[0,0])=>{const{width:n,height:o}=Ne(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Yd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):uo(r)?r:t.nodeLookup.get(r.id));const a=s?on(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return fn(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return hn(n)},Tt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=fn(n,on(r)),o=!0)}),o?hn(n):{x:0,y:0,width:0,height:0}},fo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/r,c=(t.y-o)/r,l=t.width/r,u=t.height/r,d=[];for(const f of e.values()){const{measured:h,selectable:m=!0,hidden:b=!1}=f;if(s&&!m||b)continue;const x=h.width??f.width??f.initialWidth??0,y=h.height??f.height??f.initialHeight??0,{x:w,y:g}=f.internals.positionAbsolute,v=$i(a,c,l,u,w,g,x,y),C=x*y,S=i&&v>0;(!f.internals.handleBounds||S||v>=C||f.dragging)&&d.push(f)}return d},Xd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function Wd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:a}=Ne(r);i=s>0&&a>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function Zd({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const a=Wd(e,s),c=Tt(a),l=po(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!0}function Ai({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let d=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const h=a.measured.width,m=a.measured.height;h&&m&&(d=[[c,l],[c+h,l+m]])}else a&&Ge(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const f=Ge(d)?Ze(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:f.x-c+(s.measured.width??0)*u[0],y:f.y-l+(s.measured.height??0)*u[1]},positionAbsolute:f}}async function Gd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),m=!h&&f.parentId&&s.find(b=>b.id===f.parentId);(h||m)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=o.filter(f=>f.deletable!==!1),u=Xd(s,c);for(const f of c)a.has(f.id)&&!u.find(m=>m.id===f.id)&&u.push(f);if(!r)return{edges:u,nodes:s};const d=await r({nodes:s,edges:u});return typeof d=="boolean"?d?{edges:u,nodes:s}:{edges:[],nodes:[]}:d}const it=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ze=(e={x:0,y:0},t,n)=>({x:it(e.x,t[0][0],t[1][0]-(n?.width??0)),y:it(e.y,t[0][1],t[1][1]-(n?.height??0))});function Pi(e,t,n){const{width:o,height:r}=Ne(n),{x:i,y:s}=n.internals.positionAbsolute;return Ze(e,[[i,s],[i+o,s+r]],t)}const qo=(e,t,n)=>e<t?it(Math.abs(e-t),1,t)/t:e>n?-it(Math.abs(e-n),1,t)/t:0,ho=(e,t,n=15,o=40)=>{const r=qo(e.x,o,t.width-o)*n,i=qo(e.y,o,t.height-o)*n;return[r,i]},fn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),hn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),St=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},on=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Di=(e,t)=>hn(fn(Zn(e),Zn(t))),$i=(e,t,n,o,r,i,s,a)=>{const c=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,i+a)-Math.max(t,i));return Math.ceil(c*l)},rn=(e,t)=>$i(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Uo=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ji=(e,t)=>(n,o)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?At(a,s):a},st=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Ke(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function qd(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Ke(e,n),r=Ke(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Ke(e.top??e.y??0,n),r=Ke(e.bottom??e.y??0,n),i=Ke(e.left??e.x??0,t),s=Ke(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ud(e,t,n,o,r,i){const{x:s,y:a}=st(e,[t,n,o]),{x:c,y:l}=st({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-c,d=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(d)}}const po=(e,t,n,o,r,i)=>{const s=qd(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=it(l,o,r),d=e.x+e.width/2,f=e.y+e.height/2,h=t/2-d*u,m=n/2-f*u,b=Ud(e,h,m,u,t,n),x={left:Math.min(b.left-s.left,0),top:Math.min(b.top-s.top,0),right:Math.min(b.right-s.right,0),bottom:Math.min(b.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:m-x.top+x.bottom,zoom:u}},Nt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ge(e){return e!=null&&e!=="parent"}function Ne(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ri(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Hi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Ko(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Kd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Qd(e){return{...Ii,...e||{}}}function gt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=me(e),a=Pt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const go=e=>({width:e.offsetWidth,height:e.offsetHeight}),Oi=e=>e?.getRootNode?.()||window?.document,Jd=["INPUT","SELECT","TEXTAREA"];function zi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Jd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Li=e=>"clientX"in e,me=(e,t)=>{const n=Li(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Qo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...go(s)}})};function Bi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,u=Math.abs(c-e),d=Math.abs(l-t);return[c,l,u,d]}function Ot(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Ot(t-o,i),n];case X.Right:return[t+Ot(o-t,i),n];case X.Top:return[t,n-Ot(n-r,i)];case X.Bottom:return[t,n+Ot(r-n,i)]}}function Vi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Jo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,u]=Jo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[d,f,h,m]=Bi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${o},${r}`,d,f,h,m]}function Fi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function ef({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function tf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=fn(on(e),on(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return rn(s,hn(i))>0}const nf=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,of=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),rf=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",ye.error006()),t;const o=n.getEdgeId||nf;let r;return Ti(e)?r={...e}:r={...e,id:o(e)},of(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Yi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Fi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const er={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},sf=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},tr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function af({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=er[t],c=er[o],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},d=sf({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let m=[],b,x;const y={x:0,y:0},w={x:0,y:0},[,,g,v]=Fi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(b=r.x??l.x+(u.x-l.x)*s,x=r.y??(l.y+u.y)/2):(b=r.x??(l.x+u.x)/2,x=r.y??l.y+(u.y-l.y)*s);const M=[{x:b,y:l.y},{x:b,y:u.y}],P=[{x:l.x,y:x},{x:u.x,y:x}];a[f]===h?m=f==="x"?M:P:m=f==="x"?P:M}else{const M=[{x:l.x,y:u.y}],P=[{x:u.x,y:l.y}];if(f==="x"?m=a.x===h?P:M:m=a.y===h?M:P,t===o){const _=Math.abs(e[f]-n[f]);if(_<=i){const I=Math.min(i-1,i-_);a[f]===h?y[f]=(l[f]>e[f]?-1:1)*I:w[f]=(u[f]>n[f]?-1:1)*I}}if(t!==o){const _=f==="x"?"y":"x",I=a[f]===c[_],k=l[_]>u[_],A=l[_]<u[_];(a[f]===1&&(!I&&k||I&&A)||a[f]!==1&&(!I&&A||I&&k))&&(m=f==="x"?M:P)}const z={x:l.x+y.x,y:l.y+y.y},T={x:u.x+w.x,y:u.y+w.y},O=Math.max(Math.abs(z.x-m[0].x),Math.abs(T.x-m[0].x)),H=Math.max(Math.abs(z.y-m[0].y),Math.abs(T.y-m[0].y));O>=H?(b=(z.x+T.x)/2,x=m[0].y):(b=m[0].x,x=(z.y+T.y)/2)}const C={x:l.x+y.x,y:l.y+y.y},S={x:u.x+w.x,y:u.y+w.y};return[[e,...C.x!==m[0].x||C.y!==m[0].y?[C]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],b,x,g,v]}function cf(e,t,n,o){const r=Math.min(tr(e,t)/2,tr(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Gn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[d,f,h,m,b]=af({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let x=`M${d[0].x} ${d[0].y}`;for(let y=1;y<d.length-1;y++)x+=cf(d[y-1],d[y],d[y+1],s);return x+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[x,f,h,m,b]}function nr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function lf(e){const{sourceNode:t,targetNode:n}=e;if(!nr(t)||!nr(n))return null;const o=t.internals.handleBounds||or(t.handles),r=n.internals.handleBounds||or(n.handles),i=rr(o?.source??[],e.sourceHandle),s=rr(e.connectionMode===We.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",ye.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,c=s?.position||X.Top,l=qe(t,i,a),u=qe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function or(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function qe(e,t,n=X.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??Ne(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function rr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function qn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function uf(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const l=qn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Xi=1e3,df=10,mo={nodeOrigin:[0,0],nodeExtent:bt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ff={...mo,checkEquality:!0};function yo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function hf(e,t,n){const o=yo(mo,n);for(const r of e.values())if(r.parentId)wo(r,e,t,o);else{const i=Mt(r,o.nodeOrigin),s=Ge(r.extent)?r.extent:o.nodeExtent,a=Ze(i,s,Ne(r));r.internals.positionAbsolute=a}}function pf(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function xo(e){return e==="manual"}function Un(e,t,n,o={}){const r=yo(ff,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!xo(r.zIndexMode)?Xi:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const u of e){let d=s.get(u.id);if(r.checkEquality&&u===d?.internals.userNode)t.set(u.id,d);else{const f=Mt(u,r.nodeOrigin),h=Ge(u.extent)?u.extent:r.nodeExtent,m=Ze(f,h,Ne(u));d={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:pf(u,d),z:Wi(u,a,r.zIndexMode),userNode:u}},t.set(u.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),u.parentId&&wo(d,t,n,o,i),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function gf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function wo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yo(mo,o),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}gf(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*df),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const d=i&&!xo(c)?Xi:0,{x:f,y:h,z:m}=mf(e,u,s,a,d,c),{positionAbsolute:b}=e.internals,x=f!==b.x||h!==b.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:b,z:m}})}function Wi(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return xo(n)?o:o+(e.selected?t:0)}function mf(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=Ne(e),l=Mt(e,n),u=Ge(e.extent)?Ze(l,e.extent,c):l;let d=Ze({x:s+u.x,y:a+u.y},o,c);e.extent==="parent"&&(d=Pi(d,c,t));const f=Wi(e,r,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function vo(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const c=i.get(s.parentId)?.expandedRect??St(a),l=Di(c,s.rect);i.set(s.parentId,{expandedRect:l,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const l=a.internals.positionAbsolute,u=Ne(a),d=a.origin??o,f=s.x<l.x?Math.round(Math.abs(l.x-s.x)):0,h=s.y<l.y?Math.round(Math.abs(l.y-s.y)):0,m=Math.max(u.width,Math.round(s.width)),b=Math.max(u.height,Math.round(s.height)),x=(m-u.width)*d[0],y=(b-u.height)*d[1];(f>0||h>0||x||y)&&(r.push({id:c,type:"position",position:{x:a.position.x-f+x,y:a.position.y-h+y}}),n.get(c)?.forEach(w=>{e.some(g=>g.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+f,y:w.position.y+h}})})),(u.width<s.width||u.height<s.height||f||h)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:m+(f?d[0]*f-x:0),height:b+(h?d[1]*h-y:0)}})}),r}function yf(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const h of e.values()){const m=t.get(h.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),c=!0;continue}const b=go(h.nodeElement),x=m.measured.width!==b.width||m.measured.height!==b.height;if(!!(b.width&&b.height&&(x||!m.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),g=Ge(m.extent)?m.extent:i;let{positionAbsolute:v}=m.internals;if(m.parentId&&m.extent==="parent"){const S=t.get(m.parentId);S&&(v=Pi(v,b,S))}else g&&(v=Ze(v,g,b));const C={...m,measured:b,internals:{...m.internals,positionAbsolute:v,handleBounds:{source:Qo("source",h.nodeElement,w,d,m.id),target:Qo("target",h.nodeElement,w,d,m.id)}}};t.set(m.id,C),m.parentId&&wo(C,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,x&&(l.push({id:m.id,type:"dimensions",dimensions:b}),m.expandParent&&m.parentId&&f.push({id:m.id,parentId:m.parentId,rect:St(C,r)}))}}if(f.length>0){const h=vo(f,t,n,r);l.push(...h)}return{changes:l,updatedInternals:c}}async function xf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function ir(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function Zi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;ir("source",c,u,e,r,s),ir("target",c,l,e,i,a),t.set(o.id,o)}}function Gi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Gi(n,t):!1}function sr(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function wf(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Gi(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function vf({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function bf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,h=!1,m=!1,b=null;function x({noDragClassName:w,handleSelector:g,domNode:v,isSelectable:C,nodeId:S,nodeClickDistance:E=0}){f=ue(v);function M({x:O,y:H}){const{nodeLookup:_,nodeExtent:I,snapGrid:k,snapToGrid:A,nodeOrigin:j,onNodeDrag:$,onSelectionDrag:V,onError:B,updateNodePositions:L}=t();i={x:O,y:H};let W=!1;const Y=a.size>1,Z=Y&&I?Zn(Tt(a)):null,J=Y&&A?vf({dragItems:a,snapGrid:k,x:O,y:H}):null;for(const[R,D]of a){if(!_.has(R))continue;let F={x:O-D.distance.x,y:H-D.distance.y};A&&(F=J?{x:Math.round(F.x+J.x),y:Math.round(F.y+J.y)}:At(F,k));let q=null;if(Y&&I&&!D.extent&&Z){const{positionAbsolute:U}=D.internals,ee=U.x-Z.x+I[0][0],ne=U.x+D.measured.width-Z.x2+I[1][0],re=U.y-Z.y+I[0][1],ce=U.y+D.measured.height-Z.y2+I[1][1];q=[[ee,re],[ne,ce]]}const{position:K,positionAbsolute:G}=Ai({nodeId:R,nextPosition:F,nodeLookup:_,nodeExtent:q||I,nodeOrigin:j,onError:B});W=W||D.position.x!==K.x||D.position.y!==K.y,D.position=K,D.internals.positionAbsolute=G}if(m=m||W,!!W&&(L(a,!0),b&&(o||$||!S&&V))){const[R,D]=In({nodeId:S,dragItems:a,nodeLookup:_});o?.(b,a,R,D),$?.(b,R,D),S||V?.(b,D)}}async function P(){if(!u)return;const{transform:O,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:I}=t();if(!I){c=!1,cancelAnimationFrame(s);return}const[k,A]=ho(l,u,_);(k!==0||A!==0)&&(i.x=(i.x??0)-k/O[2],i.y=(i.y??0)-A/O[2],await H({x:k,y:A})&&M(i)),s=requestAnimationFrame(P)}function z(O){const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:I,transform:k,snapGrid:A,snapToGrid:j,selectNodesOnDrag:$,onNodeDragStart:V,onSelectionDragStart:B,unselectNodesAndEdges:L}=t();d=!0,(!$||!C)&&!_&&S&&(H.get(S)?.selected||L()),C&&$&&S&&e?.(S);const W=gt(O.sourceEvent,{transform:k,snapGrid:A,snapToGrid:j,containerBounds:u});if(i=W,a=wf(H,I,W,S),a.size>0&&(n||V||!S&&B)){const[Y,Z]=In({nodeId:S,dragItems:a,nodeLookup:H});n?.(O.sourceEvent,a,Y,Z),V?.(O.sourceEvent,Y,Z),S||B?.(O.sourceEvent,Z)}}const T=ui().clickDistance(E).on("start",O=>{const{domNode:H,nodeDragThreshold:_,transform:I,snapGrid:k,snapToGrid:A}=t();u=H?.getBoundingClientRect()||null,h=!1,m=!1,b=O.sourceEvent,_===0&&z(O),i=gt(O.sourceEvent,{transform:I,snapGrid:k,snapToGrid:A,containerBounds:u}),l=me(O.sourceEvent,u)}).on("drag",O=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:I,snapToGrid:k,nodeDragThreshold:A,nodeLookup:j}=t(),$=gt(O.sourceEvent,{transform:_,snapGrid:I,snapToGrid:k,containerBounds:u});if(b=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||S&&!j.has(S))&&(h=!0),!h){if(!c&&H&&d&&(c=!0,P()),!d){const V=me(O.sourceEvent,u),B=V.x-l.x,L=V.y-l.y;Math.sqrt(B*B+L*L)>A&&z(O)}(i.x!==$.xSnapped||i.y!==$.ySnapped)&&a&&d&&(l=me(O.sourceEvent,u),M($))}}).on("end",O=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:I,onSelectionDragStop:k}=t();if(m&&(_(a,!1),m=!1),r||I||!S&&k){const[A,j]=In({nodeId:S,dragItems:a,nodeLookup:H,dragging:!1});r?.(O.sourceEvent,a,A,j),I?.(O.sourceEvent,A,j),S||k?.(O.sourceEvent,j)}}}).filter(O=>{const H=O.target;return!O.button&&(!w||!sr(H,`.${w}`,v))&&(!g||sr(H,g,v))});f.call(T)}function y(){f?.on(".drag",null)}return{update:x,destroy:y}}function _f(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())rn(r,St(i))>0&&o.push(i);return o}const Sf=250;function Nf(e,t,n,o){let r=[],i=1/0;const s=_f(e,n,t+Sf);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const l of c){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:u,y:d}=qe(a,l,l.position,!0),f=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(d-e.y,2));f>t||(f<i?(r=[{...l,x:u,y:d}],i=f):f===i&&r.push({...l,x:u,y:d}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function qi(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?a?.find(l=>l.id===n):a?.[0])??null;return c&&i?{...c,...qe(s,c,c.position,!0)}:c}function Ui(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Ef(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ki=()=>!0;function Cf(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:h,onConnectStart:m,onConnect:b,onConnectEnd:x,isValidConnection:y=Ki,onReconnectEnd:w,updateConnection:g,getTransform:v,getFromHandle:C,autoPanSpeed:S,dragThreshold:E=1,handleDomNode:M}){const P=Oi(e.target);let z=0,T;const{x:O,y:H}=me(e),_=Ui(i,M),I=a?.getBoundingClientRect();let k=!1;if(!I||!_)return;const A=qi(r,_,o,c,t);if(!A)return;let j=me(e,I),$=!1,V=null,B=!1,L=null;function W(){if(!u||!I)return;const[K,G]=ho(j,I,S);f({x:K,y:G}),z=requestAnimationFrame(W)}const Y={...A,nodeId:r,type:_,position:A.position},Z=c.get(r);let R={inProgress:!0,isValid:null,from:qe(Z,Y,X.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:Z,to:j,toHandle:null,toPosition:Go[Y.position],toNode:null,pointer:j};function D(){k=!0,g(R),m?.(e,{nodeId:r,handleId:o,handleType:_})}E===0&&D();function F(K){if(!k){const{x:ce,y:Ee}=me(K),we=ce-O,ve=Ee-H;if(!(we*we+ve*ve>E*E))return;D()}if(!C()||!Y){q(K);return}const G=v();j=me(K,I),T=Nf(Pt(j,G,!1,[1,1]),n,c,Y),$||(W(),$=!0);const U=Qi(K,{handle:T,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:P,lib:l,flowId:d,nodeLookup:c});L=U.handleDomNode,V=U.connection,B=Ef(!!T,U.isValid);const ee=c.get(r),ne=ee?qe(ee,Y,X.Left,!0):R.from,re={...R,from:ne,isValid:B,to:U.toHandle&&B?st({x:U.toHandle.x,y:U.toHandle.y},G):j,toHandle:U.toHandle,toPosition:B&&U.toHandle?U.toHandle.position:Go[Y.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null,pointer:j};g(re),R=re}function q(K){if(!("touches"in K&&K.touches.length>0)){if(k){(T||L)&&V&&B&&b?.(V);const{inProgress:G,...U}=R,ee={...U,toPosition:R.toHandle?R.toPosition:null};x?.(K,ee),i&&w?.(K,ee)}h(),cancelAnimationFrame(z),$=!1,B=!1,V=null,L=null,P.removeEventListener("mousemove",F),P.removeEventListener("mouseup",q),P.removeEventListener("touchmove",F),P.removeEventListener("touchend",q)}}P.addEventListener("mousemove",F),P.addEventListener("mouseup",q),P.addEventListener("touchmove",F),P.addEventListener("touchend",q)}function Qi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=Ki,nodeLookup:u}){const d=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:m}=me(e),b=s.elementFromPoint(h,m),x=b?.classList.contains(`${a}-flow__handle`)?b:f,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=Ui(void 0,x),g=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),C=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!g||!w)return y;const E={source:d?g:o,sourceHandle:d?v:r,target:d?o:g,targetHandle:d?r:v};y.connection=E;const P=C&&S&&(n===We.Strict?d&&w==="source"||!d&&w==="target":g!==o||v!==r);y.isValid=P&&l(E),y.toHandle=qi(g,w,v,u,n,!0)}return y}const Kn={onPointerDown:Cf,isValid:Qi};function If({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ue(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:d=!0,zoomable:f=!0,inversePan:h=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const v=n(),C=g.sourceEvent.ctrlKey&&Nt()?10:1,S=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,E=v[2]*Math.pow(2,S*C);t.scaleTo(E)};let b=[0,0];const x=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(b=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const v=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const C=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],S=[C[0]-b[0],C[1]-b[1]];b=C;const E=o()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),M={x:v[0]-S[0]*E,y:v[1]-S[1]*E},P=[[0,0],[c,l]];t.setViewportConstrained({x:M.x,y:M.y,zoom:v[2]},P,a)},w=Ei().on("start",x).on("zoom",d?y:null).on("zoom.wheel",f?m:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:he}}const pn=e=>({x:e.x,y:e.y,zoom:e.k}),kn=({x:e,y:t,zoom:n})=>dn.translate(e,t).scale(n),Qe=(e,t)=>e.target.closest(`.${t}`),Ji=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Mn=(e,t=0,n=kf,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},es=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Mf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Qe(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(u.ctrlKey&&s){const x=he(u),y=es(u),w=d*Math.pow(2,y);o.scaleTo(n,w,x,u);return}const f=u.deltaMode===1?20:1;let h=r===Fe.Vertical?0:u.deltaX*f,m=r===Fe.Horizontal?0:u.deltaY*f;!Nt()&&u.shiftKey&&r!==Fe.Vertical&&(h=u.deltaY*f,m=0),o.translateBy(n,-(h/d)*i,-(m/d)*i,{internal:!0});const b=pn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,b):(e.isPanScrolling=!0,a?.(u,b)),e.panScrollTimeout=setTimeout(()=>{l?.(u,b),e.isPanScrolling=!1},150)}}function Tf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Qe(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Af({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=pn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Pf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ji(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,pn(i.transform))}}function Df({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ji(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=pn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function $f({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{const f=e||t,h=n&&d.ctrlKey,m=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Qe(d,`${l}-flow__node`)||Qe(d,`${l}-flow__edge`)))return!0;if(!o&&!f&&!r&&!i&&!n||s||u&&!m||Qe(d,a)&&m||Qe(d,c)&&(!m||r&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!r&&!h&&m||!o&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(o)&&!o.includes(d.button)&&d.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&b}}function jf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(H=>{const _=H[0];_&&(d=[[0,0],[_.contentRect.width,_.contentRect.height]])}):null)?.observe(e);const h=Ei().extent(()=>d).scaleExtent([t,n]).translateExtent(o),m=ue(e).call(h);v({x:r.x,y:r.y,zoom:it(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const b=m.on("wheel.zoom"),x=m.on("dblclick.zoom");h.wheelDelta(es);async function y(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).transform(Mn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function w({noWheelClassName:H,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:k,panOnScroll:A,panOnDrag:j,panOnScrollMode:$,panOnScrollSpeed:V,preventScrolling:B,zoomOnPinch:L,zoomOnScroll:W,zoomOnDoubleClick:Y,zoomActivationKeyPressed:Z,lib:J,onTransformChange:R,connectionInProgress:D,paneClickDistance:F,selectionOnDrag:q}){k&&!l.isZoomingOrPanning&&g();const K=A&&!Z&&!k;h.clickDistance(q?1/0:!ge(F)||F<0?0:F);const G=K?Mf({zoomPanValues:l,noWheelClassName:H,d3Selection:m,d3Zoom:h,panOnScrollMode:$,panOnScrollSpeed:V,zoomOnPinch:L,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Tf({noWheelClassName:H,preventScrolling:B,d3ZoomHandler:b});m.on("wheel.zoom",G,{passive:!1});const U=Af({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",U);const ee=Pf({zoomPanValues:l,panOnDrag:j,onPaneContextMenu:!!I,onPanZoom:i,onTransformChange:R});h.on("zoom",ee);const ne=Df({zoomPanValues:l,panOnDrag:j,panOnScroll:A,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=$f({zoomActivationKeyPressed:Z,panOnDrag:j,zoomOnScroll:W,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:L,userSelectionActive:k,noPanClassName:_,noWheelClassName:H,lib:J,connectionInProgress:D});h.filter(re),Y?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function g(){h.on("zoom",null)}async function v(H,_,I){const k=kn(H),A=h?.constrain()(k,_,I);return A&&await y(A),A}async function C(H,_){const I=kn(H);return await y(I,_),I}function S(H){if(m){const _=kn(H),I=m.property("__zoom");(I.k!==H.zoom||I.x!==H.x||I.y!==H.y)&&h?.transform(m,_,null,{sync:!0})}}function E(){const H=m?Ni(m.node()):{x:0,y:0,k:1};return{x:H.x,y:H.y,zoom:H.k}}async function M(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleTo(Mn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}async function P(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleBy(Mn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function z(H){h?.scaleExtent(H)}function T(H){h?.translateExtent(H)}function O(H){const _=!ge(H)||H<0?0:H;h?.clickDistance(_)}return{update:w,destroy:g,setViewport:C,setViewportConstrained:v,getViewport:E,scaleTo:M,scaleBy:P,setScaleExtent:z,setTranslateExtent:T,syncViewport:S,setClickDistance:O}}var at;(function(e){e.Line="line",e.Handle="handle"})(at||(at={}));function Rf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function ar(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function De(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function zt(e,t,n){return Math.max(0,t-e,e-n)}function cr(e,t){return e?!t:t}function Hf(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:h,ySnapped:m}=n,{minWidth:b,maxWidth:x,minHeight:y,maxHeight:w}=o,{x:g,y:v,width:C,height:S,aspectRatio:E}=e;let M=Math.floor(u?h-e.pointerX:0),P=Math.floor(d?m-e.pointerY:0);const z=C+(c?-M:M),T=S+(l?-P:P),O=-i[0]*C,H=-i[1]*S;let _=zt(z,b,x),I=zt(T,y,w);if(s){let j=0,$=0;c&&M<0?j=De(g+M+O,s[0][0]):!c&&M>0&&(j=$e(g+z+O,s[1][0])),l&&P<0?$=De(v+P+H,s[0][1]):!l&&P>0&&($=$e(v+T+H,s[1][1])),_=Math.max(_,j),I=Math.max(I,$)}if(a){let j=0,$=0;c&&M>0?j=$e(g+M,a[0][0]):!c&&M<0&&(j=De(g+z,a[1][0])),l&&P>0?$=$e(v+P,a[0][1]):!l&&P<0&&($=De(v+T,a[1][1])),_=Math.max(_,j),I=Math.max(I,$)}if(r){if(u){const j=zt(z/E,y,w)*E;if(_=Math.max(_,j),s){let $=0;!c&&!l||c&&!l&&f?$=$e(v+H+z/E,s[1][1])*E:$=De(v+H+(c?M:-M)/E,s[0][1])*E,_=Math.max(_,$)}if(a){let $=0;!c&&!l||c&&!l&&f?$=De(v+z/E,a[1][1])*E:$=$e(v+(c?M:-M)/E,a[0][1])*E,_=Math.max(_,$)}}if(d){const j=zt(T*E,b,x)/E;if(I=Math.max(I,j),s){let $=0;!c&&!l||l&&!c&&f?$=$e(g+T*E+O,s[1][0])/E:$=De(g+(l?P:-P)*E+O,s[0][0])/E,I=Math.max(I,$)}if(a){let $=0;!c&&!l||l&&!c&&f?$=De(g+T*E,a[1][0])/E:$=$e(g+(l?P:-P)*E,a[0][0])/E,I=Math.max(I,$)}}}P=P+(P<0?I:-I),M=M+(M<0?_:-_),r&&(f?z>T*E?P=(cr(c,l)?-M:M)/E:M=(cr(c,l)?-P:P)*E:u?(P=M/E,l=c):(M=P*E,c=l));const k=c?g+M:g,A=l?v+P:v;return{width:C+(c?-M:M),height:S+(l?-P:P),x:i[0]*M*(c?-1:1)+k,y:i[1]*P*(l?-1:1)+A}}const ts={width:0,height:0,x:0,y:0},Of={...ts,pointerX:0,pointerY:0,aspectRatio:1};function zf(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Lf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ue(e);let s={controlDirection:ar("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:m,onResizeEnd:b,shouldResize:x}){let y={...ts},w={...Of};s={boundaries:u,resizeDirection:f,keepAspectRatio:d,controlDirection:ar(l)};let g,v=null,C=[],S,E,M,P=!1;const z=ui().on("start",T=>{const{nodeLookup:O,transform:H,snapGrid:_,snapToGrid:I,nodeOrigin:k,paneDomNode:A}=n();if(g=O.get(t),!g)return;v=A?.getBoundingClientRect()??null;const{xSnapped:j,ySnapped:$}=gt(T.sourceEvent,{transform:H,snapGrid:_,snapToGrid:I,containerBounds:v});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},w={...y,pointerX:j,pointerY:$,aspectRatio:y.width/y.height},S=void 0,E=Ge(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(S=O.get(g.parentId)),S&&g.extent==="parent"&&(E=[[0,0],[S.measured.width,S.measured.height]]),C=[],M=void 0;for(const[V,B]of O)if(B.parentId===t&&(C.push({id:V,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const L=zf(B,g,B.origin??k);M?M=[[Math.min(L[0][0],M[0][0]),Math.min(L[0][1],M[0][1])],[Math.max(L[1][0],M[1][0]),Math.max(L[1][1],M[1][1])]]:M=L}h?.(T,{...y})}).on("drag",T=>{const{transform:O,snapGrid:H,snapToGrid:_,nodeOrigin:I}=n(),k=gt(T.sourceEvent,{transform:O,snapGrid:H,snapToGrid:_,containerBounds:v}),A=[];if(!g)return;const{x:j,y:$,width:V,height:B}=y,L={},W=g.origin??I,{width:Y,height:Z,x:J,y:R}=Hf(w,s.controlDirection,k,s.boundaries,s.keepAspectRatio,W,E,M),D=Y!==V,F=Z!==B,q=J!==j&&D,K=R!==$&&F;if(!q&&!K&&!D&&!F)return;if((q||K||W[0]===1||W[1]===1)&&(L.x=q?J:y.x,L.y=K?R:y.y,y.x=L.x,y.y=L.y,C.length>0)){const ne=J-j,re=R-$;for(const ce of C)ce.position={x:ce.position.x-ne+W[0]*(Y-V),y:ce.position.y-re+W[1]*(Z-B)},A.push(ce)}if((D||F)&&(L.width=D&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:y.width,L.height=F&&(!s.resizeDirection||s.resizeDirection==="vertical")?Z:y.height,y.width=L.width,y.height=L.height),S&&g.expandParent){const ne=W[0]*(L.width??0);L.x&&L.x<ne&&(y.x=ne,w.x=w.x-(L.x-ne));const re=W[1]*(L.height??0);L.y&&L.y<re&&(y.y=re,w.y=w.y-(L.y-re))}const G=Rf({width:y.width,prevWidth:V,height:y.height,prevHeight:B,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...y,direction:G};x?.(T,U)!==!1&&(P=!0,m?.(T,U),o(L,A))}).on("end",T=>{P&&(b?.(T,{...y}),r?.({...y}),P=!1)});i.call(z)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var Tn={exports:{}},An={},Pn={exports:{}},Dn={};var lr;function Bf(){if(lr)return Dn;lr=1;var e=Gr();function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(d,f){var h=f(),m=o({inst:{value:h,getSnapshot:f}}),b=m[0].inst,x=m[1];return i(function(){b.value=h,b.getSnapshot=f,c(b)&&x({inst:b})},[d,h,f]),r(function(){return c(b)&&x({inst:b}),d(function(){c(b)&&x({inst:b})})},[d]),s(h),h}function c(d){var f=d.getSnapshot;d=d.value;try{var h=f();return!n(d,h)}catch{return!0}}function l(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Dn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Dn}var ur;function Vf(){return ur||(ur=1,Pn.exports=Bf()),Pn.exports}var dr;function Ff(){if(dr)return An;dr=1;var e=Gr(),t=Vf();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return An.useSyncExternalStoreWithSelector=function(l,u,d,f,h){var m=i(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=a(function(){function y(S){if(!w){if(w=!0,g=S,S=f(S),h!==void 0&&b.hasValue){var E=b.value;if(h(E,S))return v=E}return v=S}if(E=v,o(g,S))return E;var M=f(S);return h!==void 0&&h(E,M)?(g=S,E):(g=S,v=M)}var w=!1,g,v,C=d===void 0?null:d;return[function(){return y(u())},C===null?void 0:function(){return y(C())}]},[u,d,f,h]);var x=r(l,m[0],m[1]);return s(function(){b.hasValue=!0,b.value=x},[x]),c(x),x},An}var fr;function Yf(){return fr||(fr=1,Tn.exports=Ff()),Tn.exports}var Xf=Yf();const Wf=qa(Xf),Zf={},hr=e=>{let t;const n=new Set,o=(u,d)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(m=>m(t,h))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Zf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,c);return c},Gf=e=>e?hr(e):hr,{useDebugValue:qf}=Ua,{useSyncExternalStoreWithSelector:Uf}=Wf,Kf=e=>e;function ns(e,t=Kf,n){const o=Uf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return qf(o),o}const pr=(e,t)=>{const n=Gf(e),o=(r,i=t)=>ns(n,r,i);return Object.assign(o,n),o},Qf=(e,t)=>e?pr(e,t):pr;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const gn=N.createContext(null),Jf=gn.Provider,os=ye.error001("react");function te(e,t){const n=N.useContext(gn);if(n===null)throw new Error(os);return ns(n,e,t)}function oe(){const e=N.useContext(gn);if(e===null)throw new Error(os);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gr={display:"none"},eh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},rs="react-flow__node-desc",is="react-flow__edge-desc",th="react-flow__aria-live",nh=e=>e.ariaLiveMessage,oh=e=>e.ariaLabelConfig;function rh({rfId:e}){const t=te(nh);return p.jsx("div",{id:`${th}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:eh,children:t})}function ih({rfId:e,disableKeyboardA11y:t}){const n=te(oh);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${rs}-${e}`,style:gr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${is}-${e}`,style:gr,children:n["edge.a11yDescription.default"]}),!t&&p.jsx(rh,{rfId:e})]})}const Ue=N.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return p.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Ue.displayName="Panel";const mr="https://reactflow.dev?utm_source=attribution";function sh({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:p.jsx(Ue,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${mr}`,children:p.jsx("a",{href:mr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const ah=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Lt=e=>e.id;function ch(e,t){return ie(e.selectedNodes.map(Lt),t.selectedNodes.map(Lt))&&ie(e.selectedEdges.map(Lt),t.selectedEdges.map(Lt))}function lh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:o}=te(ah,ch);return N.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const uh=e=>!!e.onSelectionChangeHandlers;function dh({onSelectionChange:e}){const t=te(uh);return e||t?p.jsx(lh,{onSelectionChange:e}):null}const ss=[0,0],fh={x:0,y:0,zoom:1},hh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],yr=[...hh,"rfId"],ph=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),xr={translateExtent:bt,nodeOrigin:ss,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function gh(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(ph,ie),l=oe();N.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=xr,a()}),[]);const u=N.useRef(xr);return N.useEffect(()=>{for(const d of yr){const f=e[d],h=u.current[d];f!==h&&(typeof e[d]>"u"||(d==="nodes"?t(f):d==="edges"?n(f):d==="minZoom"?o(f):d==="maxZoom"?r(f):d==="translateExtent"?i(f):d==="nodeExtent"?s(f):d==="ariaLabelConfig"?l.setState({ariaLabelConfig:Qd(f)}):d==="fitView"?l.setState({fitViewQueued:f}):d==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[d]:f})))}u.current=e},yr.map(d=>e[d])),null}function wr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function mh(e){const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const o=wr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:wr()?.matches?"dark":"light"}const vr=typeof document<"u"?document:null;function Et(e=null,t={target:vr,actInsideInputWithModifier:!0}){const[n,o]=N.useState(!1),r=N.useRef(!1),i=N.useRef(new Set([])),[s,a]=N.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
1
|
+
import{r as Gr,g as qa,R as Ua,a as N,j as p,u as ae,b as Q,i as Vt,S as Ka,f as Qa,c as Ja,d as ec,n as tc,e as nc,w as oc,h as rc,k as qr,l as ic,m as sc,o as ac,p as cc,q as Ct,s as lc}from"./index-CxEuSZMC.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var uc={value:()=>{}};function an(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Ft(n)}function Ft(e){this._=e}function dc(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,o=dc(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=fc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Ao(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Ao(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ft(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function fc(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Ao(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=uc,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var zn="http://www.w3.org/1999/xhtml";const Po={svg:"http://www.w3.org/2000/svg",xhtml:zn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Po.hasOwnProperty(t)?{space:Po[t],local:e}:e}function hc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===zn&&t.documentElement.namespaceURI===zn?t.createElement(e):t.createElementNS(n,e)}}function pc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Ur(e){var t=cn(e);return(t.local?pc:hc)(t)}function gc(){}function oo(e){return e==null?gc:function(){return this.querySelector(e)}}function mc(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new de(o,this._parents)}function yc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function xc(){return[]}function Kr(e){return e==null?xc:function(){return this.querySelectorAll(e)}}function wc(e){return function(){return yc(e.apply(this,arguments))}}function vc(e){typeof e=="function"?e=wc(e):e=Kr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new de(o,r)}function Qr(e){return function(){return this.matches(e)}}function Jr(e){return function(t){return t.matches(e)}}var bc=Array.prototype.find;function _c(e){return function(){return bc.call(this.children,e)}}function Sc(){return this.firstElementChild}function Nc(e){return this.select(e==null?Sc:_c(typeof e=="function"?e:Jr(e)))}var Ec=Array.prototype.filter;function Cc(){return Array.from(this.children)}function Ic(e){return function(){return Ec.call(this.children,e)}}function kc(e){return this.selectAll(e==null?Cc:Ic(typeof e=="function"?e:Jr(e)))}function Mc(e){typeof e!="function"&&(e=Qr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new de(o,this._parents)}function ei(e){return new Array(e.length)}function Tc(){return new de(this._enter||this._groups.map(ei),this._parents)}function qt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}qt.prototype={constructor:qt,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Ac(e){return function(){return e}}function Pc(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new qt(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function Dc(e,t,n,o,r,i,s){var a,c,l=new Map,u=t.length,d=i.length,f=new Array(u),h;for(a=0;a<u;++a)(c=t[a])&&(f[a]=h=s.call(c,c.__data__,a,t)+"",l.has(h)?r[a]=c:l.set(h,c));for(a=0;a<d;++a)h=s.call(e,i[a],a,i)+"",(c=l.get(h))?(o[a]=c,c.__data__=i[a],l.delete(h)):n[a]=new qt(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(f[a])===c&&(r[a]=c)}function $c(e){return e.__data__}function jc(e,t){if(!arguments.length)return Array.from(this,$c);var n=t?Dc:Pc,o=this._parents,r=this._groups;typeof e!="function"&&(e=Ac(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=o[l],d=r[l],f=d.length,h=Rc(e.call(u,u&&u.__data__,l,o)),m=h.length,b=a[l]=new Array(m),x=s[l]=new Array(m),y=c[l]=new Array(f);n(u,d,b,x,y,h,t);for(var w=0,g=0,v,C;w<m;++w)if(v=b[w]){for(w>=g&&(g=w+1);!(C=x[g])&&++g<m;);v._next=C||null}}return s=new de(s,o),s._enter=a,s._exit=c,s}function Rc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Hc(){return new de(this._exit||this._groups.map(ei),this._parents)}function Oc(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function zc(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),c=0;c<s;++c)for(var l=n[c],u=o[c],d=l.length,f=a[c]=new Array(d),h,m=0;m<d;++m)(h=l[m]||u[m])&&(f[m]=h);for(;c<r;++c)a[c]=n[c];return new de(a,this._parents)}function Lc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Bc(e){e||(e=Vc);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,c=r[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new de(r,this._parents).order()}function Vc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Fc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Yc(){return Array.from(this)}function Xc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function Wc(){let e=0;for(const t of this)++e;return e}function Zc(){return!this.node()}function Gc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function qc(e){return function(){this.removeAttribute(e)}}function Uc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Kc(e,t){return function(){this.setAttribute(e,t)}}function Qc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Jc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function el(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function tl(e,t){var n=cn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?Uc:qc:typeof t=="function"?n.local?el:Jc:n.local?Qc:Kc)(n,t))}function ti(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function nl(e){return function(){this.style.removeProperty(e)}}function ol(e,t,n){return function(){this.style.setProperty(e,t,n)}}function rl(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function il(e,t,n){return arguments.length>1?this.each((t==null?nl:typeof t=="function"?rl:ol)(e,t,n??"")):ot(this.node(),e)}function ot(e,t){return e.style.getPropertyValue(t)||ti(e).getComputedStyle(e,null).getPropertyValue(t)}function sl(e){return function(){delete this[e]}}function al(e,t){return function(){this[e]=t}}function cl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function ll(e,t){return arguments.length>1?this.each((t==null?sl:typeof t=="function"?cl:al)(e,t)):this.node()[e]}function ni(e){return e.trim().split(/^|\s+/)}function ro(e){return e.classList||new oi(e)}function oi(e){this._node=e,this._names=ni(e.getAttribute("class")||"")}oi.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ri(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function ii(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function ul(e){return function(){ri(this,e)}}function dl(e){return function(){ii(this,e)}}function fl(e,t){return function(){(t.apply(this,arguments)?ri:ii)(this,e)}}function hl(e,t){var n=ni(e+"");if(arguments.length<2){for(var o=ro(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?fl:t?ul:dl)(n,t))}function pl(){this.textContent=""}function gl(e){return function(){this.textContent=e}}function ml(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function yl(e){return arguments.length?this.each(e==null?pl:(typeof e=="function"?ml:gl)(e)):this.node().textContent}function xl(){this.innerHTML=""}function wl(e){return function(){this.innerHTML=e}}function vl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function bl(e){return arguments.length?this.each(e==null?xl:(typeof e=="function"?vl:wl)(e)):this.node().innerHTML}function _l(){this.nextSibling&&this.parentNode.appendChild(this)}function Sl(){return this.each(_l)}function Nl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function El(){return this.each(Nl)}function Cl(e){var t=typeof e=="function"?e:Ur(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Il(){return null}function kl(e,t){var n=typeof e=="function"?e:Ur(e),o=t==null?Il:typeof t=="function"?t:oo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Ml(){var e=this.parentNode;e&&e.removeChild(this)}function Tl(){return this.each(Ml)}function Al(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Pl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Dl(e){return this.select(e?Pl:Al)}function $l(e){return arguments.length?this.property("__data__",e):this.node().__data__}function jl(e){return function(t){e.call(this,t,this.__data__)}}function Rl(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Hl(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Ol(e,t,n){return function(){var o=this.__on,r,i=jl(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function zl(e,t,n){var o=Rl(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Ol:Hl,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function si(e,t,n){var o=ti(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Ll(e,t){return function(){return si(this,e,t)}}function Bl(e,t){return function(){return si(this,e,t.apply(this,arguments))}}function Vl(e,t){return this.each((typeof t=="function"?Bl:Ll)(e,t))}function*Fl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var ai=[null];function de(e,t){this._groups=e,this._parents=t}function It(){return new de([[document.documentElement]],ai)}function Yl(){return this}de.prototype=It.prototype={constructor:de,select:mc,selectAll:vc,selectChild:Nc,selectChildren:kc,filter:Mc,data:jc,enter:Tc,exit:Hc,join:Oc,merge:zc,selection:Yl,order:Lc,sort:Bc,call:Fc,nodes:Yc,node:Xc,size:Wc,empty:Zc,each:Gc,attr:tl,style:il,property:ll,classed:hl,text:yl,html:bl,raise:Sl,lower:El,append:Cl,insert:kl,remove:Tl,clone:Dl,datum:$l,on:zl,dispatch:Vl,[Symbol.iterator]:Fl};function ue(e){return typeof e=="string"?new de([[document.querySelector(e)]],[document.documentElement]):new de([[e]],ai)}function Xl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=Xl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const Wl={passive:!1},yt={capture:!0,passive:!1};function Sn(e){e.stopImmediatePropagation()}function tt(e){e.preventDefault(),e.stopImmediatePropagation()}function ci(e){var t=e.document.documentElement,n=ue(e).on("dragstart.drag",tt,yt);"onselectstart"in t?n.on("selectstart.drag",tt,yt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function li(e,t){var n=e.document.documentElement,o=ue(e).on("dragstart.drag",null);t&&(o.on("click.drag",tt,yt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Dt=e=>()=>e;function Ln(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Ln.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Zl(e){return!e.ctrlKey&&!e.button}function Gl(){return this.parentNode}function ql(e,t){return t??{x:e.x,y:e.y}}function Ul(){return navigator.maxTouchPoints||"ontouchstart"in this}function ui(){var e=Zl,t=Gl,n=ql,o=Ul,r={},i=an("start","drag","end"),s=0,a,c,l,u,d=0;function f(v){v.on("mousedown.drag",h).filter(o).on("touchstart.drag",x).on("touchmove.drag",y,Wl).on("touchend.drag touchcancel.drag",w).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(v,C){if(!(u||!e.call(this,v,C))){var S=g(this,t.call(this,v,C),v,C,"mouse");S&&(ue(v.view).on("mousemove.drag",m,yt).on("mouseup.drag",b,yt),ci(v.view),Sn(v),l=!1,a=v.clientX,c=v.clientY,S("start",v))}}function m(v){if(tt(v),!l){var C=v.clientX-a,S=v.clientY-c;l=C*C+S*S>d}r.mouse("drag",v)}function b(v){ue(v.view).on("mousemove.drag mouseup.drag",null),li(v.view,l),tt(v),r.mouse("end",v)}function x(v,C){if(e.call(this,v,C)){var S=v.changedTouches,E=t.call(this,v,C),M=S.length,P,z;for(P=0;P<M;++P)(z=g(this,E,v,C,S[P].identifier,S[P]))&&(Sn(v),z("start",v,S[P]))}}function y(v){var C=v.changedTouches,S=C.length,E,M;for(E=0;E<S;++E)(M=r[C[E].identifier])&&(tt(v),M("drag",v,C[E]))}function w(v){var C=v.changedTouches,S=C.length,E,M;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),E=0;E<S;++E)(M=r[C[E].identifier])&&(Sn(v),M("end",v,C[E]))}function g(v,C,S,E,M,P){var z=i.copy(),T=he(P||S,C),O,H,_;if((_=n.call(v,new Ln("beforestart",{sourceEvent:S,target:f,identifier:M,active:s,x:T[0],y:T[1],dx:0,dy:0,dispatch:z}),E))!=null)return O=_.x-T[0]||0,H=_.y-T[1]||0,function I(k,A,j){var $=T,V;switch(k){case"start":r[M]=I,V=s++;break;case"end":delete r[M],--s;case"drag":T=he(j||A,C),V=s;break}z.call(k,v,new Ln(k,{sourceEvent:A,subject:_,target:f,identifier:M,active:V,x:T[0]+O,y:T[1]+H,dx:T[0]-$[0],dy:T[1]-$[1],dispatch:z}),E)}}return f.filter=function(v){return arguments.length?(e=typeof v=="function"?v:Dt(!!v),f):e},f.container=function(v){return arguments.length?(t=typeof v=="function"?v:Dt(v),f):t},f.subject=function(v){return arguments.length?(n=typeof v=="function"?v:Dt(v),f):n},f.touchable=function(v){return arguments.length?(o=typeof v=="function"?v:Dt(!!v),f):o},f.on=function(){var v=i.on.apply(i,arguments);return v===i?f:v},f.clickDistance=function(v){return arguments.length?(d=(v=+v)*v,f):Math.sqrt(d)},f}function io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function di(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function kt(){}var xt=.7,Ut=1/xt,nt="\\s*([+-]?\\d+)\\s*",wt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",_e="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Kl=/^#([0-9a-f]{3,8})$/,Ql=new RegExp(`^rgb\\(${nt},${nt},${nt}\\)$`),Jl=new RegExp(`^rgb\\(${_e},${_e},${_e}\\)$`),eu=new RegExp(`^rgba\\(${nt},${nt},${nt},${wt}\\)$`),tu=new RegExp(`^rgba\\(${_e},${_e},${_e},${wt}\\)$`),nu=new RegExp(`^hsl\\(${wt},${_e},${_e}\\)$`),ou=new RegExp(`^hsla\\(${wt},${_e},${_e},${wt}\\)$`),Do={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};io(kt,Ye,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$o,formatHex:$o,formatHex8:ru,formatHsl:iu,formatRgb:jo,toString:jo});function $o(){return this.rgb().formatHex()}function ru(){return this.rgb().formatHex8()}function iu(){return fi(this).formatHsl()}function jo(){return this.rgb().formatRgb()}function Ye(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Kl.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ro(t):n===3?new le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$t(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$t(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=Ql.exec(e))?new le(t[1],t[2],t[3],1):(t=Jl.exec(e))?new le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=eu.exec(e))?$t(t[1],t[2],t[3],t[4]):(t=tu.exec(e))?$t(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=nu.exec(e))?zo(t[1],t[2]/100,t[3]/100,1):(t=ou.exec(e))?zo(t[1],t[2]/100,t[3]/100,t[4]):Do.hasOwnProperty(e)?Ro(Do[e]):e==="transparent"?new le(NaN,NaN,NaN,0):null}function Ro(e){return new le(e>>16&255,e>>8&255,e&255,1)}function $t(e,t,n,o){return o<=0&&(e=t=n=NaN),new le(e,t,n,o)}function su(e){return e instanceof kt||(e=Ye(e)),e?(e=e.rgb(),new le(e.r,e.g,e.b,e.opacity)):new le}function Bn(e,t,n,o){return arguments.length===1?su(e):new le(e,t,n,o??1)}function le(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}io(le,Bn,di(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new le(Ve(this.r),Ve(this.g),Ve(this.b),Kt(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:Ho,formatHex:Ho,formatHex8:au,formatRgb:Oo,toString:Oo}));function Ho(){return`#${Be(this.r)}${Be(this.g)}${Be(this.b)}`}function au(){return`#${Be(this.r)}${Be(this.g)}${Be(this.b)}${Be((isNaN(this.opacity)?1:this.opacity)*255)}`}function Oo(){const e=Kt(this.opacity);return`${e===1?"rgb(":"rgba("}${Ve(this.r)}, ${Ve(this.g)}, ${Ve(this.b)}${e===1?")":`, ${e})`}`}function Kt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ve(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Be(e){return e=Ve(e),(e<16?"0":"")+e.toString(16)}function zo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new pe(e,t,n,o)}function fi(e){if(e instanceof pe)return new pe(e.h,e.s,e.l,e.opacity);if(e instanceof kt||(e=Ye(e)),!e)return new pe;if(e instanceof pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,c=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new pe(s,a,c,e.opacity)}function cu(e,t,n,o){return arguments.length===1?fi(e):new pe(e,t,n,o??1)}function pe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}io(pe,cu,di(kt,{brighter(e){return e=e==null?Ut:Math.pow(Ut,e),new pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?xt:Math.pow(xt,e),new pe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new le(Nn(e>=240?e-240:e+120,r,o),Nn(e,r,o),Nn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new pe(Lo(this.h),jt(this.s),jt(this.l),Kt(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Kt(this.opacity);return`${e===1?"hsl(":"hsla("}${Lo(this.h)}, ${jt(this.s)*100}%, ${jt(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Lo(e){return e=(e||0)%360,e<0?e+360:e}function jt(e){return Math.max(0,Math.min(1,e||0))}function Nn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const so=e=>()=>e;function lu(e,t){return function(n){return e+n*t}}function uu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function du(e){return(e=+e)==1?hi:function(t,n){return n-t?uu(t,n,e):so(isNaN(t)?n:t)}}function hi(e,t){var n=t-e;return n?lu(e,n):so(isNaN(e)?t:e)}const Qt=(function e(t){var n=du(t);function o(r,i){var s=n((r=Bn(r)).r,(i=Bn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=hi(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return o.gamma=e,o})(1);function fu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function hu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function pu(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=pt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function gu(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function be(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function mu(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=pt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Vn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,En=new RegExp(Vn.source,"g");function yu(e){return function(){return e}}function xu(e){return function(t){return e(t)+""}}function pi(e,t){var n=Vn.lastIndex=En.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=Vn.exec(e))&&(r=En.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:be(o,r)})),n=En.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?xu(c[0].x):yu(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)a[(d=c[u]).i]=d.x(l);return a.join("")})}function pt(e,t){var n=typeof t,o;return t==null||n==="boolean"?so(t):(n==="number"?be:n==="string"?(o=Ye(t))?(t=o,Qt):pi:t instanceof Ye?Qt:t instanceof Date?gu:hu(t)?fu:Array.isArray(t)?pu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?mu:be)(e,t)}var Bo=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function gi(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Bo,skewX:Math.atan(c)*Bo,scaleX:s,scaleY:a}}var Rt;function wu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:gi(t.a,t.b,t.c,t.d,t.e,t.f)}function vu(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Fn:(e=e.matrix,gi(e.a,e.b,e.c,e.d,e.e,e.f))}function mi(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,u,d,f,h,m){if(l!==d||u!==f){var b=h.push("translate(",null,t,null,n);m.push({i:b-4,x:be(l,d)},{i:b-2,x:be(u,f)})}else(d||f)&&h.push("translate("+d+t+f+n)}function s(l,u,d,f){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),f.push({i:d.push(r(d)+"rotate(",null,o)-2,x:be(l,u)})):u&&d.push(r(d)+"rotate("+u+o)}function a(l,u,d,f){l!==u?f.push({i:d.push(r(d)+"skewX(",null,o)-2,x:be(l,u)}):u&&d.push(r(d)+"skewX("+u+o)}function c(l,u,d,f,h,m){if(l!==d||u!==f){var b=h.push(r(h)+"scale(",null,",",null,")");m.push({i:b-4,x:be(l,d)},{i:b-2,x:be(u,f)})}else(d!==1||f!==1)&&h.push(r(h)+"scale("+d+","+f+")")}return function(l,u){var d=[],f=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,d,f),s(l.rotate,u.rotate,d,f),a(l.skewX,u.skewX,d,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,f),l=u=null,function(h){for(var m=-1,b=f.length,x;++m<b;)d[(x=f[m]).i]=x.x(h);return d.join("")}}}var bu=mi(wu,"px, ","px)","deg)"),_u=mi(vu,", ",")",")"),Su=1e-12;function Vo(e){return((e=Math.exp(e))+1/e)/2}function Nu(e){return((e=Math.exp(e))-1/e)/2}function Eu(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yt=(function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],d=s[1],f=s[2],h=u-a,m=d-c,b=h*h+m*m,x,y;if(b<Su)y=Math.log(f/l)/t,x=function(E){return[a+E*h,c+E*m,l*Math.exp(t*E*y)]};else{var w=Math.sqrt(b),g=(f*f-l*l+o*b)/(2*l*n*w),v=(f*f-l*l-o*b)/(2*f*n*w),C=Math.log(Math.sqrt(g*g+1)-g),S=Math.log(Math.sqrt(v*v+1)-v);y=(S-C)/t,x=function(E){var M=E*y,P=Vo(C),z=l/(n*w)*(P*Eu(t*M+C)-Nu(C));return[a+z*h,c+z*m,l*P/Vo(t*M+C)]}}return x.duration=y*1e3*t/Math.SQRT2,x}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r})(Math.SQRT2,2,4);var rt=0,ft=0,lt=0,yi=1e3,Jt,ht,en=0,Xe=0,ln=0,vt=typeof performance=="object"&&performance.now?performance:Date,xi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return Xe||(xi(Cu),Xe=vt.now()+ln)}function Cu(){Xe=0}function tn(){this._call=this._time=this._next=null}tn.prototype=wi.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ao():+n)+(t==null?0:+t),!this._next&&ht!==this&&(ht?ht._next=this:Jt=this,ht=this),this._call=e,this._time=n,Yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yn())}};function wi(e,t,n){var o=new tn;return o.restart(e,t,n),o}function Iu(){ao(),++rt;for(var e=Jt,t;e;)(t=Xe-e._time)>=0&&e._call.call(void 0,t),e=e._next;--rt}function Fo(){Xe=(en=vt.now())+ln,rt=ft=0;try{Iu()}finally{rt=0,Mu(),Xe=0}}function ku(){var e=vt.now(),t=e-en;t>yi&&(ln-=t,en=e)}function Mu(){for(var e,t=Jt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);ht=e,Yn(o)}function Yn(e){if(!rt){ft&&(ft=clearTimeout(ft));var t=e-Xe;t>24?(e<1/0&&(ft=setTimeout(Fo,e-vt.now()-ln)),lt&&(lt=clearInterval(lt))):(lt||(en=vt.now(),lt=setInterval(ku,yi)),rt=1,xi(Fo))}}function Yo(e,t,n){var o=new tn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Tu=an("start","end","cancel","interrupt"),Au=[],vi=0,Xo=1,Xn=2,Xt=3,Wo=4,Wn=5,Wt=6;function un(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Pu(e,n,{name:t,index:o,group:r,on:Tu,tween:Au,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:vi})}function co(e,t){var n=xe(e,t);if(n.state>vi)throw new Error("too late; already scheduled");return n}function Se(e,t){var n=xe(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Pu(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=wi(i,0,n.time);function i(l){n.state=Xo,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,d,f,h;if(n.state!==Xo)return c();for(u in o)if(h=o[u],h.name===n.name){if(h.state===Xt)return Yo(s);h.state===Wo?(h.state=Wt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[u]):+u<t&&(h.state=Wt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[u])}if(Yo(function(){n.state===Xt&&(n.state=Wo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Xn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xn){for(n.state=Xt,r=new Array(f=n.tween.length),u=0,d=-1;u<f;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++d]=h);r.length=d+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wn,1),d=-1,f=r.length;++d<f;)r[d].call(e,u);n.state===Wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wt,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Zt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>Xn&&o.state<Wn,o.state=Wt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Du(e){return this.each(function(){Zt(this,e)})}function $u(e,t){var n,o;return function(){var r=Se(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function ju(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Se(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function Ru(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=xe(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?$u:ju)(n,e,t))}function lo(e,t,n){var o=e._id;return e.each(function(){var r=Se(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return xe(r,o).value[t]}}function bi(e,t){var n;return(typeof t=="number"?be:t instanceof Ye?Qt:(n=Ye(t))?(t=n,Qt):pi)(e,t)}function Hu(e){return function(){this.removeAttribute(e)}}function Ou(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Lu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Bu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Vu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Fu(e,t){var n=cn(e),o=n==="transform"?_u:bi;return this.attrTween(e,typeof t=="function"?(n.local?Vu:Bu)(n,o,lo(this,"attr."+e,t)):t==null?(n.local?Ou:Hu)(n):(n.local?Lu:zu)(n,o,t))}function Yu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Xu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Wu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Xu(e,i)),n}return r._value=t,r}function Zu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Yu(e,i)),n}return r._value=t,r}function Gu(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=cn(e);return this.tween(n,(o.local?Wu:Zu)(o,t))}function qu(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function Uu(e,t){return t=+t,function(){co(this,e).delay=t}}function Ku(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?qu:Uu)(t,e)):xe(this.node(),t).delay}function Qu(e,t){return function(){Se(this,e).duration=+t.apply(this,arguments)}}function Ju(e,t){return t=+t,function(){Se(this,e).duration=t}}function ed(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?Qu:Ju)(t,e)):xe(this.node(),t).duration}function td(e,t){if(typeof t!="function")throw new Error;return function(){Se(this,e).ease=t}}function nd(e){var t=this._id;return arguments.length?this.each(td(t,e)):xe(this.node(),t).ease}function od(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Se(this,e).ease=n}}function rd(e){if(typeof e!="function")throw new Error;return this.each(od(this._id,e))}function id(e){typeof e!="function"&&(e=Qr(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Pe(o,this._parents,this._name,this._id)}function sd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,d=s[a]=new Array(u),f,h=0;h<u;++h)(f=c[h]||l[h])&&(d[h]=f);for(;a<o;++a)s[a]=t[a];return new Pe(s,this._parents,this._name,this._id)}function ad(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function cd(e,t,n){var o,r,i=ad(t)?co:Se;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function ld(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(cd(n,e,t))}function ud(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function dd(){return this.on("end.remove",ud(this._id))}function fd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oo(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),u,d,f=0;f<c;++f)(u=a[f])&&(d=e.call(u,u.__data__,f,a))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d,un(l[f],t,n,f,l,xe(u,n)));return new Pe(i,this._parents,t,n)}function hd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Kr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),h,m=xe(u,n),b=0,x=f.length;b<x;++b)(h=f[b])&&un(h,t,n,b,f,m);i.push(f),s.push(u)}return new Pe(i,s,t,n)}var pd=It.prototype.constructor;function gd(){return new pd(this._groups,this._parents)}function md(e,t){var n,o,r;return function(){var i=ot(this,e),s=(this.style.removeProperty(e),ot(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function _i(e){return function(){this.style.removeProperty(e)}}function yd(e,t,n){var o,r=n+"",i;return function(){var s=ot(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function xd(e,t,n){var o,r,i;return function(){var s=ot(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),ot(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function wd(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=Se(this,e),l=c.on,u=c.value[i]==null?a||(a=_i(t)):void 0;(l!==n||r!==u)&&(o=(n=l).copy()).on(s,r=u),c.on=o}}function vd(e,t,n){var o=(e+="")=="transform"?bu:bi;return t==null?this.styleTween(e,md(e,o)).on("end.style."+e,_i(e)):typeof t=="function"?this.styleTween(e,xd(e,o,lo(this,"style."+e,t))).each(wd(this._id,e)):this.styleTween(e,yd(e,o,t),n).on("end.style."+e,null)}function bd(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function _d(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&bd(e,s,n)),o}return i._value=t,i}function Sd(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,_d(e,t,n??""))}function Nd(e){return function(){this.textContent=e}}function Ed(e){return function(){var t=e(this);this.textContent=t??""}}function Cd(e){return this.tween("text",typeof e=="function"?Ed(lo(this,"text",e)):Nd(e==null?"":e+""))}function Id(e){return function(t){this.textContent=e.call(this,t)}}function kd(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Id(r)),t}return o._value=e,o}function Md(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,kd(e))}function Td(){for(var e=this._name,t=this._id,n=Si(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=xe(c,t);un(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Pe(o,this._parents,e,n)}function Ad(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=Se(this,o),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var Pd=0;function Pe(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Si(){return++Pd}var Me=It.prototype;Pe.prototype={constructor:Pe,select:fd,selectAll:hd,selectChild:Me.selectChild,selectChildren:Me.selectChildren,filter:id,merge:sd,selection:gd,transition:Td,call:Me.call,nodes:Me.nodes,node:Me.node,size:Me.size,empty:Me.empty,each:Me.each,on:ld,attr:Fu,attrTween:Gu,style:vd,styleTween:Sd,text:Cd,textTween:Md,remove:dd,tween:Ru,delay:Ku,duration:ed,ease:nd,easeVarying:rd,end:Ad,[Symbol.iterator]:Me[Symbol.iterator]};function Dd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var $d={time:null,delay:0,duration:250,ease:Dd};function jd(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Rd(e){var t,n;e instanceof Pe?(t=e._id,e=e._name):(t=Si(),(n=$d).time=ao(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&un(c,e,t,l,s,n||jd(c,t));return new Pe(o,this._parents,e,t)}It.prototype.interrupt=Du;It.prototype.transition=Rd;const Ht=e=>()=>e;function Hd(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Te(e,t,n){this.k=e,this.x=t,this.y=n}Te.prototype={constructor:Te,scale:function(e){return e===1?this:new Te(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Te(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var dn=new Te(1,0,0);Ni.prototype=Te.prototype;function Ni(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}function Cn(e){e.stopImmediatePropagation()}function ut(e){e.preventDefault(),e.stopImmediatePropagation()}function Od(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function zd(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Zo(){return this.__zoom||dn}function Ld(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Bd(){return navigator.maxTouchPoints||"ontouchstart"in this}function Vd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function Ei(){var e=Od,t=zd,n=Vd,o=Ld,r=Bd,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Yt,l=an("start","zoom","end"),u,d,f,h=500,m=150,b=0,x=10;function y(_){_.property("__zoom",Zo).on("wheel.zoom",M,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",z).filter(r).on("touchstart.zoom",T).on("touchmove.zoom",O).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,I,k,A){var j=_.selection?_.selection():_;j.property("__zoom",Zo),_!==j?C(_,I,k,A):j.interrupt().each(function(){S(this,arguments).event(A).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},y.scaleBy=function(_,I,k,A){y.scaleTo(_,function(){var j=this.__zoom.k,$=typeof I=="function"?I.apply(this,arguments):I;return j*$},k,A)},y.scaleTo=function(_,I,k,A){y.transform(_,function(){var j=t.apply(this,arguments),$=this.__zoom,V=k==null?v(j):typeof k=="function"?k.apply(this,arguments):k,B=$.invert(V),L=typeof I=="function"?I.apply(this,arguments):I;return n(g(w($,L),V,B),j,s)},k,A)},y.translateBy=function(_,I,k,A){y.transform(_,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),s)},null,A)},y.translateTo=function(_,I,k,A,j){y.transform(_,function(){var $=t.apply(this,arguments),V=this.__zoom,B=A==null?v($):typeof A=="function"?A.apply(this,arguments):A;return n(dn.translate(B[0],B[1]).scale(V.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof k=="function"?-k.apply(this,arguments):-k),$,s)},A,j)};function w(_,I){return I=Math.max(i[0],Math.min(i[1],I)),I===_.k?_:new Te(I,_.x,_.y)}function g(_,I,k){var A=I[0]-k[0]*_.k,j=I[1]-k[1]*_.k;return A===_.x&&j===_.y?_:new Te(_.k,A,j)}function v(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function C(_,I,k,A){_.on("start.zoom",function(){S(this,arguments).event(A).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(A).end()}).tween("zoom",function(){var j=this,$=arguments,V=S(j,$).event(A),B=t.apply(j,$),L=k==null?v(B):typeof k=="function"?k.apply(j,$):k,W=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),Y=j.__zoom,Z=typeof I=="function"?I.apply(j,$):I,J=c(Y.invert(L).concat(W/Y.k),Z.invert(L).concat(W/Z.k));return function(R){if(R===1)R=Z;else{var D=J(R),F=W/D[2];R=new Te(F,L[0]-D[0]*F,L[1]-D[1]*F)}V.zoom(null,R)}})}function S(_,I,k){return!k&&_.__zooming||new E(_,I)}function E(_,I){this.that=_,this.args=I,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,I),this.taps=0}E.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,I){return this.mouse&&_!=="mouse"&&(this.mouse[1]=I.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=I.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=I.invert(this.touch1[0])),this.that.__zoom=I,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var I=ue(this.that).datum();l.call(_,this.that,new Hd(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:l}),I)}};function M(_,...I){if(!e.apply(this,arguments))return;var k=S(this,I).event(_),A=this.__zoom,j=Math.max(i[0],Math.min(i[1],A.k*Math.pow(2,o.apply(this,arguments)))),$=he(_);if(k.wheel)(k.mouse[0][0]!==$[0]||k.mouse[0][1]!==$[1])&&(k.mouse[1]=A.invert(k.mouse[0]=$)),clearTimeout(k.wheel);else{if(A.k===j)return;k.mouse=[$,A.invert($)],Zt(this),k.start()}ut(_),k.wheel=setTimeout(V,m),k.zoom("mouse",n(g(w(A,j),k.mouse[0],k.mouse[1]),k.extent,s));function V(){k.wheel=null,k.end()}}function P(_,...I){if(f||!e.apply(this,arguments))return;var k=_.currentTarget,A=S(this,I,!0).event(_),j=ue(_.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",W,!0),$=he(_,k),V=_.clientX,B=_.clientY;ci(_.view),Cn(_),A.mouse=[$,this.__zoom.invert($)],Zt(this),A.start();function L(Y){if(ut(Y),!A.moved){var Z=Y.clientX-V,J=Y.clientY-B;A.moved=Z*Z+J*J>b}A.event(Y).zoom("mouse",n(g(A.that.__zoom,A.mouse[0]=he(Y,k),A.mouse[1]),A.extent,s))}function W(Y){j.on("mousemove.zoom mouseup.zoom",null),li(Y.view,A.moved),ut(Y),A.event(Y).end()}}function z(_,...I){if(e.apply(this,arguments)){var k=this.__zoom,A=he(_.changedTouches?_.changedTouches[0]:_,this),j=k.invert(A),$=k.k*(_.shiftKey?.5:2),V=n(g(w(k,$),A,j),t.apply(this,I),s);ut(_),a>0?ue(this).transition().duration(a).call(C,V,A,_):ue(this).call(y.transform,V,A,_)}}function T(_,...I){if(e.apply(this,arguments)){var k=_.touches,A=k.length,j=S(this,I,_.changedTouches.length===A).event(_),$,V,B,L;for(Cn(_),V=0;V<A;++V)B=k[V],L=he(B,this),L=[L,this.__zoom.invert(L),B.identifier],j.touch0?!j.touch1&&j.touch0[2]!==L[2]&&(j.touch1=L,j.taps=0):(j.touch0=L,$=!0,j.taps=1+!!u);u&&(u=clearTimeout(u)),$&&(j.taps<2&&(d=L[0],u=setTimeout(function(){u=null},h)),Zt(this),j.start())}}function O(_,...I){if(this.__zooming){var k=S(this,I).event(_),A=_.changedTouches,j=A.length,$,V,B,L;for(ut(_),$=0;$<j;++$)V=A[$],B=he(V,this),k.touch0&&k.touch0[2]===V.identifier?k.touch0[0]=B:k.touch1&&k.touch1[2]===V.identifier&&(k.touch1[0]=B);if(V=k.that.__zoom,k.touch1){var W=k.touch0[0],Y=k.touch0[1],Z=k.touch1[0],J=k.touch1[1],R=(R=Z[0]-W[0])*R+(R=Z[1]-W[1])*R,D=(D=J[0]-Y[0])*D+(D=J[1]-Y[1])*D;V=w(V,Math.sqrt(R/D)),B=[(W[0]+Z[0])/2,(W[1]+Z[1])/2],L=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(k.touch0)B=k.touch0[0],L=k.touch0[1];else return;k.zoom("touch",n(g(V,B,L),k.extent,s))}}function H(_,...I){if(this.__zooming){var k=S(this,I).event(_),A=_.changedTouches,j=A.length,$,V;for(Cn(_),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),$=0;$<j;++$)V=A[$],k.touch0&&k.touch0[2]===V.identifier?delete k.touch0:k.touch1&&k.touch1[2]===V.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(V=he(V,this),Math.hypot(d[0]-V[0],d[1]-V[1])<x)){var B=ue(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:Ht(+_),y):o},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Ht(!!_),y):e},y.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Ht(!!_),y):r},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:Ht([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),y):t},y.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],y):[i[0],i[1]]},y.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],y):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},y.constrain=function(_){return arguments.length?(n=_,y):n},y.duration=function(_){return arguments.length?(a=+_,y):a},y.interpolate=function(_){return arguments.length?(c=_,y):c},y.on=function(){var _=l.on.apply(l,arguments);return _===l?y:_},y.clickDistance=function(_){return arguments.length?(b=(_=+_)*_,y):Math.sqrt(b)},y.tapDistance=function(_){return arguments.length?(x=+_,y):x},y}const ye={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}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:e=>`Node type "${e}" 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:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},bt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ci=["Enter"," ","Escape"],Ii={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var We;(function(e){e.Strict="strict",e.Loose="loose"})(We||(We={}));var Fe;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Fe||(Fe={}));var _t;(function(e){e.Partial="partial",e.Full="full"})(_t||(_t={}));const ki={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var je;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(je||(je={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Go={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function Mi(e){return e===null?null:e?"valid":"invalid"}const Ti=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Fd=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uo=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mt=(e,t=[0,0])=>{const{width:n,height:o}=Ne(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Yd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):uo(r)?r:t.nodeLookup.get(r.id));const a=s?on(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return fn(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return hn(n)},Tt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=fn(n,on(r)),o=!0)}),o?hn(n):{x:0,y:0,width:0,height:0}},fo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/r,c=(t.y-o)/r,l=t.width/r,u=t.height/r,d=[];for(const f of e.values()){const{measured:h,selectable:m=!0,hidden:b=!1}=f;if(s&&!m||b)continue;const x=h.width??f.width??f.initialWidth??0,y=h.height??f.height??f.initialHeight??0,{x:w,y:g}=f.internals.positionAbsolute,v=$i(a,c,l,u,w,g,x,y),C=x*y,S=i&&v>0;(!f.internals.handleBounds||S||v>=C||f.dragging)&&d.push(f)}return d},Xd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function Wd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:a}=Ne(r);i=s>0&&a>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function Zd({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const a=Wd(e,s),c=Tt(a),l=po(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!0}function Ai({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let d=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const h=a.measured.width,m=a.measured.height;h&&m&&(d=[[c,l],[c+h,l+m]])}else a&&Ge(s.extent)&&(d=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const f=Ge(d)?Ze(t,d,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:f.x-c+(s.measured.width??0)*u[0],y:f.y-l+(s.measured.height??0)*u[1]},positionAbsolute:f}}async function Gd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),m=!h&&f.parentId&&s.find(b=>b.id===f.parentId);(h||m)&&s.push(f)}const a=new Set(t.map(f=>f.id)),c=o.filter(f=>f.deletable!==!1),u=Xd(s,c);for(const f of c)a.has(f.id)&&!u.find(m=>m.id===f.id)&&u.push(f);if(!r)return{edges:u,nodes:s};const d=await r({nodes:s,edges:u});return typeof d=="boolean"?d?{edges:u,nodes:s}:{edges:[],nodes:[]}:d}const it=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ze=(e={x:0,y:0},t,n)=>({x:it(e.x,t[0][0],t[1][0]-(n?.width??0)),y:it(e.y,t[0][1],t[1][1]-(n?.height??0))});function Pi(e,t,n){const{width:o,height:r}=Ne(n),{x:i,y:s}=n.internals.positionAbsolute;return Ze(e,[[i,s],[i+o,s+r]],t)}const qo=(e,t,n)=>e<t?it(Math.abs(e-t),1,t)/t:e>n?-it(Math.abs(e-n),1,t)/t:0,ho=(e,t,n=15,o=40)=>{const r=qo(e.x,o,t.width-o)*n,i=qo(e.y,o,t.height-o)*n;return[r,i]},fn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),hn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),St=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},on=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},Di=(e,t)=>hn(fn(Zn(e),Zn(t))),$i=(e,t,n,o,r,i,s,a)=>{const c=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,i+a)-Math.max(t,i));return Math.ceil(c*l)},rn=(e,t)=>$i(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Uo=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),ji=(e,t)=>(n,o)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?At(a,s):a},st=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Ke(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function qd(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Ke(e,n),r=Ke(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Ke(e.top??e.y??0,n),r=Ke(e.bottom??e.y??0,n),i=Ke(e.left??e.x??0,t),s=Ke(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ud(e,t,n,o,r,i){const{x:s,y:a}=st(e,[t,n,o]),{x:c,y:l}=st({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-c,d=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(d)}}const po=(e,t,n,o,r,i)=>{const s=qd(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=it(l,o,r),d=e.x+e.width/2,f=e.y+e.height/2,h=t/2-d*u,m=n/2-f*u,b=Ud(e,h,m,u,t,n),x={left:Math.min(b.left-s.left,0),top:Math.min(b.top-s.top,0),right:Math.min(b.right-s.right,0),bottom:Math.min(b.bottom-s.bottom,0)};return{x:h-x.left+x.right,y:m-x.top+x.bottom,zoom:u}},Nt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ge(e){return e!=null&&e!=="parent"}function Ne(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ri(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Hi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Ko(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Kd(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function Qd(e){return{...Ii,...e||{}}}function gt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=me(e),a=Pt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const go=e=>({width:e.offsetWidth,height:e.offsetHeight}),Oi=e=>e?.getRootNode?.()||window?.document,Jd=["INPUT","SELECT","TEXTAREA"];function zi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:Jd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Li=e=>"clientX"in e,me=(e,t)=>{const n=Li(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Qo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...go(s)}})};function Bi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,u=Math.abs(c-e),d=Math.abs(l-t);return[c,l,u,d]}function Ot(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Jo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Ot(t-o,i),n];case X.Right:return[t+Ot(o-t,i),n];case X.Top:return[t,n-Ot(n-r,i)];case X.Bottom:return[t,n+Ot(r-n,i)]}}function Vi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=Jo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,u]=Jo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[d,f,h,m]=Bi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${o},${r}`,d,f,h,m]}function Fi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function ef({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function tf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=fn(on(e),on(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return rn(s,hn(i))>0}const nf=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,of=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),rf=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",ye.error006()),t;const o=n.getEdgeId||nf;let r;return Ti(e)?r={...e}:r={...e,id:o(e)},of(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Yi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Fi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const er={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},sf=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},tr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function af({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=er[t],c=er[o],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},d=sf({source:l,sourcePosition:t,target:u}),f=d.x!==0?"x":"y",h=d[f];let m=[],b,x;const y={x:0,y:0},w={x:0,y:0},[,,g,v]=Fi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(b=r.x??l.x+(u.x-l.x)*s,x=r.y??(l.y+u.y)/2):(b=r.x??(l.x+u.x)/2,x=r.y??l.y+(u.y-l.y)*s);const M=[{x:b,y:l.y},{x:b,y:u.y}],P=[{x:l.x,y:x},{x:u.x,y:x}];a[f]===h?m=f==="x"?M:P:m=f==="x"?P:M}else{const M=[{x:l.x,y:u.y}],P=[{x:u.x,y:l.y}];if(f==="x"?m=a.x===h?P:M:m=a.y===h?M:P,t===o){const _=Math.abs(e[f]-n[f]);if(_<=i){const I=Math.min(i-1,i-_);a[f]===h?y[f]=(l[f]>e[f]?-1:1)*I:w[f]=(u[f]>n[f]?-1:1)*I}}if(t!==o){const _=f==="x"?"y":"x",I=a[f]===c[_],k=l[_]>u[_],A=l[_]<u[_];(a[f]===1&&(!I&&k||I&&A)||a[f]!==1&&(!I&&A||I&&k))&&(m=f==="x"?M:P)}const z={x:l.x+y.x,y:l.y+y.y},T={x:u.x+w.x,y:u.y+w.y},O=Math.max(Math.abs(z.x-m[0].x),Math.abs(T.x-m[0].x)),H=Math.max(Math.abs(z.y-m[0].y),Math.abs(T.y-m[0].y));O>=H?(b=(z.x+T.x)/2,x=m[0].y):(b=m[0].x,x=(z.y+T.y)/2)}const C={x:l.x+y.x,y:l.y+y.y},S={x:u.x+w.x,y:u.y+w.y};return[[e,...C.x!==m[0].x||C.y!==m[0].y?[C]:[],...m,...S.x!==m[m.length-1].x||S.y!==m[m.length-1].y?[S]:[],n],b,x,g,v]}function cf(e,t,n,o){const r=Math.min(tr(e,t)/2,tr(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Gn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[d,f,h,m,b]=af({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let x=`M${d[0].x} ${d[0].y}`;for(let y=1;y<d.length-1;y++)x+=cf(d[y-1],d[y],d[y+1],s);return x+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[x,f,h,m,b]}function nr(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function lf(e){const{sourceNode:t,targetNode:n}=e;if(!nr(t)||!nr(n))return null;const o=t.internals.handleBounds||or(t.handles),r=n.internals.handleBounds||or(n.handles),i=rr(o?.source??[],e.sourceHandle),s=rr(e.connectionMode===We.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",ye.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,c=s?.position||X.Top,l=qe(t,i,a),u=qe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function or(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function qe(e,t,n=X.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??Ne(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function rr(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function qn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function uf(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const l=qn(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Xi=1e3,df=10,mo={nodeOrigin:[0,0],nodeExtent:bt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ff={...mo,checkEquality:!0};function yo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function hf(e,t,n){const o=yo(mo,n);for(const r of e.values())if(r.parentId)wo(r,e,t,o);else{const i=Mt(r,o.nodeOrigin),s=Ge(r.extent)?r.extent:o.nodeExtent,a=Ze(i,s,Ne(r));r.internals.positionAbsolute=a}}function pf(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function xo(e){return e==="manual"}function Un(e,t,n,o={}){const r=yo(ff,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!xo(r.zIndexMode)?Xi:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const u of e){let d=s.get(u.id);if(r.checkEquality&&u===d?.internals.userNode)t.set(u.id,d);else{const f=Mt(u,r.nodeOrigin),h=Ge(u.extent)?u.extent:r.nodeExtent,m=Ze(f,h,Ne(u));d={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:m,handleBounds:pf(u,d),z:Wi(u,a,r.zIndexMode),userNode:u}},t.set(u.id,d)}(d.measured===void 0||d.measured.width===void 0||d.measured.height===void 0)&&!d.hidden&&(c=!1),u.parentId&&wo(d,t,n,o,i),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function gf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function wo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yo(mo,o),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}gf(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*df),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const d=i&&!xo(c)?Xi:0,{x:f,y:h,z:m}=mf(e,u,s,a,d,c),{positionAbsolute:b}=e.internals,x=f!==b.x||h!==b.y;(x||m!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:x?{x:f,y:h}:b,z:m}})}function Wi(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return xo(n)?o:o+(e.selected?t:0)}function mf(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=Ne(e),l=Mt(e,n),u=Ge(e.extent)?Ze(l,e.extent,c):l;let d=Ze({x:s+u.x,y:a+u.y},o,c);e.extent==="parent"&&(d=Pi(d,c,t));const f=Wi(e,r,i),h=t.internals.z??0;return{x:d.x,y:d.y,z:h>=f?h+1:f}}function vo(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const c=i.get(s.parentId)?.expandedRect??St(a),l=Di(c,s.rect);i.set(s.parentId,{expandedRect:l,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const l=a.internals.positionAbsolute,u=Ne(a),d=a.origin??o,f=s.x<l.x?Math.round(Math.abs(l.x-s.x)):0,h=s.y<l.y?Math.round(Math.abs(l.y-s.y)):0,m=Math.max(u.width,Math.round(s.width)),b=Math.max(u.height,Math.round(s.height)),x=(m-u.width)*d[0],y=(b-u.height)*d[1];(f>0||h>0||x||y)&&(r.push({id:c,type:"position",position:{x:a.position.x-f+x,y:a.position.y-h+y}}),n.get(c)?.forEach(w=>{e.some(g=>g.id===w.id)||r.push({id:w.id,type:"position",position:{x:w.position.x+f,y:w.position.y+h}})})),(u.width<s.width||u.height<s.height||f||h)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:m+(f?d[0]*f-x:0),height:b+(h?d[1]*h-y:0)}})}),r}function yf(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(const h of e.values()){const m=t.get(h.id);if(!m)continue;if(m.hidden){t.set(m.id,{...m,internals:{...m.internals,handleBounds:void 0}}),c=!0;continue}const b=go(h.nodeElement),x=m.measured.width!==b.width||m.measured.height!==b.height;if(!!(b.width&&b.height&&(x||!m.internals.handleBounds||h.force))){const w=h.nodeElement.getBoundingClientRect(),g=Ge(m.extent)?m.extent:i;let{positionAbsolute:v}=m.internals;if(m.parentId&&m.extent==="parent"){const S=t.get(m.parentId);S&&(v=Pi(v,b,S))}else g&&(v=Ze(v,g,b));const C={...m,measured:b,internals:{...m.internals,positionAbsolute:v,handleBounds:{source:Qo("source",h.nodeElement,w,d,m.id),target:Qo("target",h.nodeElement,w,d,m.id)}}};t.set(m.id,C),m.parentId&&wo(C,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,x&&(l.push({id:m.id,type:"dimensions",dimensions:b}),m.expandParent&&m.parentId&&f.push({id:m.id,parentId:m.parentId,rect:St(C,r)}))}}if(f.length>0){const h=vo(f,t,n,r);l.push(...h)}return{changes:l,updatedInternals:c}}async function xf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function ir(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function Zi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;ir("source",c,u,e,r,s),ir("target",c,l,e,i,a),t.set(o.id,o)}}function Gi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Gi(n,t):!1}function sr(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function wf(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Gi(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function vf({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function bf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,h=!1,m=!1,b=null;function x({noDragClassName:w,handleSelector:g,domNode:v,isSelectable:C,nodeId:S,nodeClickDistance:E=0}){f=ue(v);function M({x:O,y:H}){const{nodeLookup:_,nodeExtent:I,snapGrid:k,snapToGrid:A,nodeOrigin:j,onNodeDrag:$,onSelectionDrag:V,onError:B,updateNodePositions:L}=t();i={x:O,y:H};let W=!1;const Y=a.size>1,Z=Y&&I?Zn(Tt(a)):null,J=Y&&A?vf({dragItems:a,snapGrid:k,x:O,y:H}):null;for(const[R,D]of a){if(!_.has(R))continue;let F={x:O-D.distance.x,y:H-D.distance.y};A&&(F=J?{x:Math.round(F.x+J.x),y:Math.round(F.y+J.y)}:At(F,k));let q=null;if(Y&&I&&!D.extent&&Z){const{positionAbsolute:U}=D.internals,ee=U.x-Z.x+I[0][0],ne=U.x+D.measured.width-Z.x2+I[1][0],re=U.y-Z.y+I[0][1],ce=U.y+D.measured.height-Z.y2+I[1][1];q=[[ee,re],[ne,ce]]}const{position:K,positionAbsolute:G}=Ai({nodeId:R,nextPosition:F,nodeLookup:_,nodeExtent:q||I,nodeOrigin:j,onError:B});W=W||D.position.x!==K.x||D.position.y!==K.y,D.position=K,D.internals.positionAbsolute=G}if(m=m||W,!!W&&(L(a,!0),b&&(o||$||!S&&V))){const[R,D]=In({nodeId:S,dragItems:a,nodeLookup:_});o?.(b,a,R,D),$?.(b,R,D),S||V?.(b,D)}}async function P(){if(!u)return;const{transform:O,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:I}=t();if(!I){c=!1,cancelAnimationFrame(s);return}const[k,A]=ho(l,u,_);(k!==0||A!==0)&&(i.x=(i.x??0)-k/O[2],i.y=(i.y??0)-A/O[2],await H({x:k,y:A})&&M(i)),s=requestAnimationFrame(P)}function z(O){const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:I,transform:k,snapGrid:A,snapToGrid:j,selectNodesOnDrag:$,onNodeDragStart:V,onSelectionDragStart:B,unselectNodesAndEdges:L}=t();d=!0,(!$||!C)&&!_&&S&&(H.get(S)?.selected||L()),C&&$&&S&&e?.(S);const W=gt(O.sourceEvent,{transform:k,snapGrid:A,snapToGrid:j,containerBounds:u});if(i=W,a=wf(H,I,W,S),a.size>0&&(n||V||!S&&B)){const[Y,Z]=In({nodeId:S,dragItems:a,nodeLookup:H});n?.(O.sourceEvent,a,Y,Z),V?.(O.sourceEvent,Y,Z),S||B?.(O.sourceEvent,Z)}}const T=ui().clickDistance(E).on("start",O=>{const{domNode:H,nodeDragThreshold:_,transform:I,snapGrid:k,snapToGrid:A}=t();u=H?.getBoundingClientRect()||null,h=!1,m=!1,b=O.sourceEvent,_===0&&z(O),i=gt(O.sourceEvent,{transform:I,snapGrid:k,snapToGrid:A,containerBounds:u}),l=me(O.sourceEvent,u)}).on("drag",O=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:I,snapToGrid:k,nodeDragThreshold:A,nodeLookup:j}=t(),$=gt(O.sourceEvent,{transform:_,snapGrid:I,snapToGrid:k,containerBounds:u});if(b=O.sourceEvent,(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1||S&&!j.has(S))&&(h=!0),!h){if(!c&&H&&d&&(c=!0,P()),!d){const V=me(O.sourceEvent,u),B=V.x-l.x,L=V.y-l.y;Math.sqrt(B*B+L*L)>A&&z(O)}(i.x!==$.xSnapped||i.y!==$.ySnapped)&&a&&d&&(l=me(O.sourceEvent,u),M($))}}).on("end",O=>{if(!d||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,d=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:I,onSelectionDragStop:k}=t();if(m&&(_(a,!1),m=!1),r||I||!S&&k){const[A,j]=In({nodeId:S,dragItems:a,nodeLookup:H,dragging:!1});r?.(O.sourceEvent,a,A,j),I?.(O.sourceEvent,A,j),S||k?.(O.sourceEvent,j)}}}).filter(O=>{const H=O.target;return!O.button&&(!w||!sr(H,`.${w}`,v))&&(!g||sr(H,g,v))});f.call(T)}function y(){f?.on(".drag",null)}return{update:x,destroy:y}}function _f(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())rn(r,St(i))>0&&o.push(i);return o}const Sf=250;function Nf(e,t,n,o){let r=[],i=1/0;const s=_f(e,n,t+Sf);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const l of c){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:u,y:d}=qe(a,l,l.position,!0),f=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(d-e.y,2));f>t||(f<i?(r=[{...l,x:u,y:d}],i=f):f===i&&r.push({...l,x:u,y:d}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function qi(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?a?.find(l=>l.id===n):a?.[0])??null;return c&&i?{...c,...qe(s,c,c.position,!0)}:c}function Ui(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Ef(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Ki=()=>!0;function Cf(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:h,onConnectStart:m,onConnect:b,onConnectEnd:x,isValidConnection:y=Ki,onReconnectEnd:w,updateConnection:g,getTransform:v,getFromHandle:C,autoPanSpeed:S,dragThreshold:E=1,handleDomNode:M}){const P=Oi(e.target);let z=0,T;const{x:O,y:H}=me(e),_=Ui(i,M),I=a?.getBoundingClientRect();let k=!1;if(!I||!_)return;const A=qi(r,_,o,c,t);if(!A)return;let j=me(e,I),$=!1,V=null,B=!1,L=null;function W(){if(!u||!I)return;const[K,G]=ho(j,I,S);f({x:K,y:G}),z=requestAnimationFrame(W)}const Y={...A,nodeId:r,type:_,position:A.position},Z=c.get(r);let R={inProgress:!0,isValid:null,from:qe(Z,Y,X.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:Z,to:j,toHandle:null,toPosition:Go[Y.position],toNode:null,pointer:j};function D(){k=!0,g(R),m?.(e,{nodeId:r,handleId:o,handleType:_})}E===0&&D();function F(K){if(!k){const{x:ce,y:Ee}=me(K),we=ce-O,ve=Ee-H;if(!(we*we+ve*ve>E*E))return;D()}if(!C()||!Y){q(K);return}const G=v();j=me(K,I),T=Nf(Pt(j,G,!1,[1,1]),n,c,Y),$||(W(),$=!0);const U=Qi(K,{handle:T,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:P,lib:l,flowId:d,nodeLookup:c});L=U.handleDomNode,V=U.connection,B=Ef(!!T,U.isValid);const ee=c.get(r),ne=ee?qe(ee,Y,X.Left,!0):R.from,re={...R,from:ne,isValid:B,to:U.toHandle&&B?st({x:U.toHandle.x,y:U.toHandle.y},G):j,toHandle:U.toHandle,toPosition:B&&U.toHandle?U.toHandle.position:Go[Y.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null,pointer:j};g(re),R=re}function q(K){if(!("touches"in K&&K.touches.length>0)){if(k){(T||L)&&V&&B&&b?.(V);const{inProgress:G,...U}=R,ee={...U,toPosition:R.toHandle?R.toPosition:null};x?.(K,ee),i&&w?.(K,ee)}h(),cancelAnimationFrame(z),$=!1,B=!1,V=null,L=null,P.removeEventListener("mousemove",F),P.removeEventListener("mouseup",q),P.removeEventListener("touchmove",F),P.removeEventListener("touchend",q)}}P.addEventListener("mousemove",F),P.addEventListener("mouseup",q),P.addEventListener("touchmove",F),P.addEventListener("touchend",q)}function Qi(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=Ki,nodeLookup:u}){const d=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:m}=me(e),b=s.elementFromPoint(h,m),x=b?.classList.contains(`${a}-flow__handle`)?b:f,y={handleDomNode:x,isValid:!1,connection:null,toHandle:null};if(x){const w=Ui(void 0,x),g=x.getAttribute("data-nodeid"),v=x.getAttribute("data-handleid"),C=x.classList.contains("connectable"),S=x.classList.contains("connectableend");if(!g||!w)return y;const E={source:d?g:o,sourceHandle:d?v:r,target:d?o:g,targetHandle:d?r:v};y.connection=E;const P=C&&S&&(n===We.Strict?d&&w==="source"||!d&&w==="target":g!==o||v!==r);y.isValid=P&&l(E),y.toHandle=qi(g,w,v,u,n,!0)}return y}const Kn={onPointerDown:Cf,isValid:Qi};function If({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ue(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:d=!0,zoomable:f=!0,inversePan:h=!1}){const m=g=>{if(g.sourceEvent.type!=="wheel"||!t)return;const v=n(),C=g.sourceEvent.ctrlKey&&Nt()?10:1,S=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*u,E=v[2]*Math.pow(2,S*C);t.scaleTo(E)};let b=[0,0];const x=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(b=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},y=g=>{const v=n();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!t)return;const C=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],S=[C[0]-b[0],C[1]-b[1]];b=C;const E=o()*Math.max(v[2],Math.log(v[2]))*(h?-1:1),M={x:v[0]-S[0]*E,y:v[1]-S[1]*E},P=[[0,0],[c,l]];t.setViewportConstrained({x:M.x,y:M.y,zoom:v[2]},P,a)},w=Ei().on("start",x).on("zoom",d?y:null).on("zoom.wheel",f?m:null);r.call(w,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:he}}const pn=e=>({x:e.x,y:e.y,zoom:e.k}),kn=({x:e,y:t,zoom:n})=>dn.translate(e,t).scale(n),Qe=(e,t)=>e.target.closest(`.${t}`),Ji=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Mn=(e,t=0,n=kf,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},es=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Mf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Qe(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(u.ctrlKey&&s){const x=he(u),y=es(u),w=d*Math.pow(2,y);o.scaleTo(n,w,x,u);return}const f=u.deltaMode===1?20:1;let h=r===Fe.Vertical?0:u.deltaX*f,m=r===Fe.Horizontal?0:u.deltaY*f;!Nt()&&u.shiftKey&&r!==Fe.Vertical&&(h=u.deltaY*f,m=0),o.translateBy(n,-(h/d)*i,-(m/d)*i,{internal:!0});const b=pn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,b):(e.isPanScrolling=!0,a?.(u,b)),e.panScrollTimeout=setTimeout(()=>{l?.(u,b),e.isPanScrolling=!1},150)}}function Tf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=Qe(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Af({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=pn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function Pf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Ji(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,pn(i.transform))}}function Df({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Ji(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=pn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function $f({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:u}){return d=>{const f=e||t,h=n&&d.ctrlKey,m=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(Qe(d,`${l}-flow__node`)||Qe(d,`${l}-flow__edge`)))return!0;if(!o&&!f&&!r&&!i&&!n||s||u&&!m||Qe(d,a)&&m||Qe(d,c)&&(!m||r&&m&&!e)||!n&&d.ctrlKey&&m)return!1;if(!n&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!f&&!r&&!h&&m||!o&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(o)&&!o.includes(d.button)&&d.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||m)&&b}}function jf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let d=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(H=>{const _=H[0];_&&(d=[[0,0],[_.contentRect.width,_.contentRect.height]])}):null)?.observe(e);const h=Ei().extent(()=>d).scaleExtent([t,n]).translateExtent(o),m=ue(e).call(h);v({x:r.x,y:r.y,zoom:it(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const b=m.on("wheel.zoom"),x=m.on("dblclick.zoom");h.wheelDelta(es);async function y(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).transform(Mn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function w({noWheelClassName:H,noPanClassName:_,onPaneContextMenu:I,userSelectionActive:k,panOnScroll:A,panOnDrag:j,panOnScrollMode:$,panOnScrollSpeed:V,preventScrolling:B,zoomOnPinch:L,zoomOnScroll:W,zoomOnDoubleClick:Y,zoomActivationKeyPressed:Z,lib:J,onTransformChange:R,connectionInProgress:D,paneClickDistance:F,selectionOnDrag:q}){k&&!l.isZoomingOrPanning&&g();const K=A&&!Z&&!k;h.clickDistance(q?1/0:!ge(F)||F<0?0:F);const G=K?Mf({zoomPanValues:l,noWheelClassName:H,d3Selection:m,d3Zoom:h,panOnScrollMode:$,panOnScrollSpeed:V,zoomOnPinch:L,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Tf({noWheelClassName:H,preventScrolling:B,d3ZoomHandler:b});m.on("wheel.zoom",G,{passive:!1});const U=Af({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});h.on("start",U);const ee=Pf({zoomPanValues:l,panOnDrag:j,onPaneContextMenu:!!I,onPanZoom:i,onTransformChange:R});h.on("zoom",ee);const ne=Df({zoomPanValues:l,panOnDrag:j,panOnScroll:A,onPaneContextMenu:I,onPanZoomEnd:a,onDraggingChange:c});h.on("end",ne);const re=$f({zoomActivationKeyPressed:Z,panOnDrag:j,zoomOnScroll:W,panOnScroll:A,zoomOnDoubleClick:Y,zoomOnPinch:L,userSelectionActive:k,noPanClassName:_,noWheelClassName:H,lib:J,connectionInProgress:D});h.filter(re),Y?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function g(){h.on("zoom",null)}async function v(H,_,I){const k=kn(H),A=h?.constrain()(k,_,I);return A&&await y(A),A}async function C(H,_){const I=kn(H);return await y(I,_),I}function S(H){if(m){const _=kn(H),I=m.property("__zoom");(I.k!==H.zoom||I.x!==H.x||I.y!==H.y)&&h?.transform(m,_,null,{sync:!0})}}function E(){const H=m?Ni(m.node()):{x:0,y:0,k:1};return{x:H.x,y:H.y,zoom:H.k}}async function M(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleTo(Mn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}async function P(H,_){return m?new Promise(I=>{h?.interpolate(_?.interpolate==="linear"?pt:Yt).scaleBy(Mn(m,_?.duration,_?.ease,()=>I(!0)),H)}):!1}function z(H){h?.scaleExtent(H)}function T(H){h?.translateExtent(H)}function O(H){const _=!ge(H)||H<0?0:H;h?.clickDistance(_)}return{update:w,destroy:g,setViewport:C,setViewportConstrained:v,getViewport:E,scaleTo:M,scaleBy:P,setScaleExtent:z,setTranslateExtent:T,syncViewport:S,setClickDistance:O}}var at;(function(e){e.Line="line",e.Handle="handle"})(at||(at={}));function Rf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function ar(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function De(e,t){return Math.max(0,t-e)}function $e(e,t){return Math.max(0,e-t)}function zt(e,t,n){return Math.max(0,t-e,e-n)}function cr(e,t){return e?!t:t}function Hf(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:h,ySnapped:m}=n,{minWidth:b,maxWidth:x,minHeight:y,maxHeight:w}=o,{x:g,y:v,width:C,height:S,aspectRatio:E}=e;let M=Math.floor(u?h-e.pointerX:0),P=Math.floor(d?m-e.pointerY:0);const z=C+(c?-M:M),T=S+(l?-P:P),O=-i[0]*C,H=-i[1]*S;let _=zt(z,b,x),I=zt(T,y,w);if(s){let j=0,$=0;c&&M<0?j=De(g+M+O,s[0][0]):!c&&M>0&&(j=$e(g+z+O,s[1][0])),l&&P<0?$=De(v+P+H,s[0][1]):!l&&P>0&&($=$e(v+T+H,s[1][1])),_=Math.max(_,j),I=Math.max(I,$)}if(a){let j=0,$=0;c&&M>0?j=$e(g+M,a[0][0]):!c&&M<0&&(j=De(g+z,a[1][0])),l&&P>0?$=$e(v+P,a[0][1]):!l&&P<0&&($=De(v+T,a[1][1])),_=Math.max(_,j),I=Math.max(I,$)}if(r){if(u){const j=zt(z/E,y,w)*E;if(_=Math.max(_,j),s){let $=0;!c&&!l||c&&!l&&f?$=$e(v+H+z/E,s[1][1])*E:$=De(v+H+(c?M:-M)/E,s[0][1])*E,_=Math.max(_,$)}if(a){let $=0;!c&&!l||c&&!l&&f?$=De(v+z/E,a[1][1])*E:$=$e(v+(c?M:-M)/E,a[0][1])*E,_=Math.max(_,$)}}if(d){const j=zt(T*E,b,x)/E;if(I=Math.max(I,j),s){let $=0;!c&&!l||l&&!c&&f?$=$e(g+T*E+O,s[1][0])/E:$=De(g+(l?P:-P)*E+O,s[0][0])/E,I=Math.max(I,$)}if(a){let $=0;!c&&!l||l&&!c&&f?$=De(g+T*E,a[1][0])/E:$=$e(g+(l?P:-P)*E,a[0][0])/E,I=Math.max(I,$)}}}P=P+(P<0?I:-I),M=M+(M<0?_:-_),r&&(f?z>T*E?P=(cr(c,l)?-M:M)/E:M=(cr(c,l)?-P:P)*E:u?(P=M/E,l=c):(M=P*E,c=l));const k=c?g+M:g,A=l?v+P:v;return{width:C+(c?-M:M),height:S+(l?-P:P),x:i[0]*M*(c?-1:1)+k,y:i[1]*P*(l?-1:1)+A}}const ts={width:0,height:0,x:0,y:0},Of={...ts,pointerX:0,pointerY:0,aspectRatio:1};function zf(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Lf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ue(e);let s={controlDirection:ar("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:m,onResizeEnd:b,shouldResize:x}){let y={...ts},w={...Of};s={boundaries:u,resizeDirection:f,keepAspectRatio:d,controlDirection:ar(l)};let g,v=null,C=[],S,E,M,P=!1;const z=ui().on("start",T=>{const{nodeLookup:O,transform:H,snapGrid:_,snapToGrid:I,nodeOrigin:k,paneDomNode:A}=n();if(g=O.get(t),!g)return;v=A?.getBoundingClientRect()??null;const{xSnapped:j,ySnapped:$}=gt(T.sourceEvent,{transform:H,snapGrid:_,snapToGrid:I,containerBounds:v});y={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},w={...y,pointerX:j,pointerY:$,aspectRatio:y.width/y.height},S=void 0,E=Ge(g.extent)?g.extent:void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(S=O.get(g.parentId)),S&&g.extent==="parent"&&(E=[[0,0],[S.measured.width,S.measured.height]]),C=[],M=void 0;for(const[V,B]of O)if(B.parentId===t&&(C.push({id:V,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const L=zf(B,g,B.origin??k);M?M=[[Math.min(L[0][0],M[0][0]),Math.min(L[0][1],M[0][1])],[Math.max(L[1][0],M[1][0]),Math.max(L[1][1],M[1][1])]]:M=L}h?.(T,{...y})}).on("drag",T=>{const{transform:O,snapGrid:H,snapToGrid:_,nodeOrigin:I}=n(),k=gt(T.sourceEvent,{transform:O,snapGrid:H,snapToGrid:_,containerBounds:v}),A=[];if(!g)return;const{x:j,y:$,width:V,height:B}=y,L={},W=g.origin??I,{width:Y,height:Z,x:J,y:R}=Hf(w,s.controlDirection,k,s.boundaries,s.keepAspectRatio,W,E,M),D=Y!==V,F=Z!==B,q=J!==j&&D,K=R!==$&&F;if(!q&&!K&&!D&&!F)return;if((q||K||W[0]===1||W[1]===1)&&(L.x=q?J:y.x,L.y=K?R:y.y,y.x=L.x,y.y=L.y,C.length>0)){const ne=J-j,re=R-$;for(const ce of C)ce.position={x:ce.position.x-ne+W[0]*(Y-V),y:ce.position.y-re+W[1]*(Z-B)},A.push(ce)}if((D||F)&&(L.width=D&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:y.width,L.height=F&&(!s.resizeDirection||s.resizeDirection==="vertical")?Z:y.height,y.width=L.width,y.height=L.height),S&&g.expandParent){const ne=W[0]*(L.width??0);L.x&&L.x<ne&&(y.x=ne,w.x=w.x-(L.x-ne));const re=W[1]*(L.height??0);L.y&&L.y<re&&(y.y=re,w.y=w.y-(L.y-re))}const G=Rf({width:y.width,prevWidth:V,height:y.height,prevHeight:B,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),U={...y,direction:G};x?.(T,U)!==!1&&(P=!0,m?.(T,U),o(L,A))}).on("end",T=>{P&&(b?.(T,{...y}),r?.({...y}),P=!1)});i.call(z)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var Tn={exports:{}},An={},Pn={exports:{}},Dn={};var lr;function Bf(){if(lr)return Dn;lr=1;var e=Gr();function t(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(d,f){var h=f(),m=o({inst:{value:h,getSnapshot:f}}),b=m[0].inst,x=m[1];return i(function(){b.value=h,b.getSnapshot=f,c(b)&&x({inst:b})},[d,h,f]),r(function(){return c(b)&&x({inst:b}),d(function(){c(b)&&x({inst:b})})},[d]),s(h),h}function c(d){var f=d.getSnapshot;d=d.value;try{var h=f();return!n(d,h)}catch{return!0}}function l(d,f){return f()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Dn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Dn}var ur;function Vf(){return ur||(ur=1,Pn.exports=Bf()),Pn.exports}var dr;function Ff(){if(dr)return An;dr=1;var e=Gr(),t=Vf();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return An.useSyncExternalStoreWithSelector=function(l,u,d,f,h){var m=i(null);if(m.current===null){var b={hasValue:!1,value:null};m.current=b}else b=m.current;m=a(function(){function y(S){if(!w){if(w=!0,g=S,S=f(S),h!==void 0&&b.hasValue){var E=b.value;if(h(E,S))return v=E}return v=S}if(E=v,o(g,S))return E;var M=f(S);return h!==void 0&&h(E,M)?(g=S,E):(g=S,v=M)}var w=!1,g,v,C=d===void 0?null:d;return[function(){return y(u())},C===null?void 0:function(){return y(C())}]},[u,d,f,h]);var x=r(l,m[0],m[1]);return s(function(){b.hasValue=!0,b.value=x},[x]),c(x),x},An}var fr;function Yf(){return fr||(fr=1,Tn.exports=Ff()),Tn.exports}var Xf=Yf();const Wf=qa(Xf),Zf={},hr=e=>{let t;const n=new Set,o=(u,d)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(m=>m(t,h))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(Zf?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,c);return c},Gf=e=>e?hr(e):hr,{useDebugValue:qf}=Ua,{useSyncExternalStoreWithSelector:Uf}=Wf,Kf=e=>e;function ns(e,t=Kf,n){const o=Uf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return qf(o),o}const pr=(e,t)=>{const n=Gf(e),o=(r,i=t)=>ns(n,r,i);return Object.assign(o,n),o},Qf=(e,t)=>e?pr(e,t):pr;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const gn=N.createContext(null),Jf=gn.Provider,os=ye.error001("react");function te(e,t){const n=N.useContext(gn);if(n===null)throw new Error(os);return ns(n,e,t)}function oe(){const e=N.useContext(gn);if(e===null)throw new Error(os);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const gr={display:"none"},eh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},rs="react-flow__node-desc",is="react-flow__edge-desc",th="react-flow__aria-live",nh=e=>e.ariaLiveMessage,oh=e=>e.ariaLabelConfig;function rh({rfId:e}){const t=te(nh);return p.jsx("div",{id:`${th}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:eh,children:t})}function ih({rfId:e,disableKeyboardA11y:t}){const n=te(oh);return p.jsxs(p.Fragment,{children:[p.jsx("div",{id:`${rs}-${e}`,style:gr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),p.jsx("div",{id:`${is}-${e}`,style:gr,children:n["edge.a11yDescription.default"]}),!t&&p.jsx(rh,{rfId:e})]})}const Ue=N.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return p.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Ue.displayName="Panel";const mr="https://reactflow.dev?utm_source=attribution";function sh({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:p.jsx(Ue,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${mr}`,children:p.jsx("a",{href:mr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const ah=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},Lt=e=>e.id;function ch(e,t){return ie(e.selectedNodes.map(Lt),t.selectedNodes.map(Lt))&&ie(e.selectedEdges.map(Lt),t.selectedEdges.map(Lt))}function lh({onSelectionChange:e}){const t=oe(),{selectedNodes:n,selectedEdges:o}=te(ah,ch);return N.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const uh=e=>!!e.onSelectionChangeHandlers;function dh({onSelectionChange:e}){const t=te(uh);return e||t?p.jsx(lh,{onSelectionChange:e}):null}const ss=[0,0],fh={x:0,y:0,zoom:1},hh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],yr=[...hh,"rfId"],ph=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),xr={translateExtent:bt,nodeOrigin:ss,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function gh(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(ph,ie),l=oe();N.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=xr,a()}),[]);const u=N.useRef(xr);return N.useEffect(()=>{for(const d of yr){const f=e[d],h=u.current[d];f!==h&&(typeof e[d]>"u"||(d==="nodes"?t(f):d==="edges"?n(f):d==="minZoom"?o(f):d==="maxZoom"?r(f):d==="translateExtent"?i(f):d==="nodeExtent"?s(f):d==="ariaLabelConfig"?l.setState({ariaLabelConfig:Qd(f)}):d==="fitView"?l.setState({fitViewQueued:f}):d==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[d]:f})))}u.current=e},yr.map(d=>e[d])),null}function wr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function mh(e){const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const o=wr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:wr()?.matches?"dark":"light"}const vr=typeof document<"u"?document:null;function Et(e=null,t={target:vr,actInsideInputWithModifier:!0}){const[n,o]=N.useState(!1),r=N.useRef(!1),i=N.useRef(new Set([])),[s,a]=N.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{aG as S,aH as M,aI as v,b as u,u as f,j as t,t as T,a as j}from"./index-
|
|
1
|
+
import{aG as S,aH as M,aI as v,b as u,u as f,j as t,t as T,a as j}from"./index-CxEuSZMC.js";function E(e){return e.filename??e.url??e.image}let A=0;function y(){return`pb_${Date.now()}_${++A}`}async function C(e){const n=y(),r=e.type.startsWith("image/")?"image":"file";if(r==="image"){const s=await new Promise((o,d)=>{const l=new FileReader;l.onload=()=>o(l.result),l.onerror=()=>d(l.error??new Error(v("modal.attachmentReadFailed"))),l.readAsDataURL(e)});return{id:n,kind:r,name:e.name,mimeType:e.type,size:e.size,dataUrl:s}}return{id:n,kind:r,name:e.name,mimeType:e.type,size:e.size}}const m=S()((e,n)=>({messages:[],scope:{kind:"draft"},draft:"",model:"gpt-5.6-luna",loading:!1,attachments:[],error:null,setDraft:r=>e({draft:r}),setModel:r=>e({model:r}),clearMessages:()=>e({messages:[],error:null}),clearImageScope:()=>e({scope:{kind:"draft"}}),setScopeFromImage:r=>{const s=E(r);e({scope:{kind:"image",imageKey:s}})},addAttachments:async r=>{try{const s=await Promise.all(r.map(C));e(o=>({attachments:[...o.attachments,...s],error:null}))}catch{e({error:v("modal.attachmentReadFailed")})}},removeAttachment:r=>{e(s=>({attachments:s.attachments.filter(o=>o.id!==r)}))},sendMessage:async r=>{const{draft:s,attachments:o,model:d,messages:l}=n(),p=s.trim()||(o.length>0?"Use the attached file as context and help with the prompt":"");if(!p&&o.length===0)return;const i={id:y(),role:"user",content:p,attachments:o.length>0?[...o]:void 0};e(c=>({messages:[...c.messages,i],draft:"",attachments:[],loading:!0,error:null}));try{const c=[...l,i].map(x=>({role:x.role,content:x.content,attachments:x.attachments?.map(h=>({kind:h.kind,name:h.name,mimeType:h.mimeType,size:h.size,dataUrl:h.dataUrl,text:h.text}))})),g=await M({model:d,messages:c,context:r}),_={id:y(),role:"assistant",content:g.message.content};e(x=>({messages:[...x.messages,_],loading:!1}))}catch(c){const g=c instanceof Error?c.message:"Prompt builder request failed";e({loading:!1,error:g})}}}));function k(e){return e?.filename??e?.url??e?.image??null}function F(e){const n=e.split(/[\\/]/).pop()??e;return n.length<=32?n:`${n.slice(0,14)}...${n.slice(-12)}`}function K(){const e=m(i=>i.scope),n=m(i=>i.clearImageScope),r=u(i=>i.currentImage),s=u(i=>i.history),{t:o}=f();if(e.kind==="draft")return t.jsx("span",{className:"prompt-builder__scope",children:o("promptBuilder.scopeDraft")});const l=k(r)===e.imageKey?r:s.find(i=>k(i)===e.imageKey)??null;if(!l)return t.jsx("span",{className:"prompt-builder__scope",children:o("promptBuilder.scopeDraft")});const p=o("promptBuilder.scopeImage",{name:F(e.imageKey)||o("promptBuilder.scopeImageFallback")});return t.jsxs("div",{className:"prompt-builder__scope-card",children:[t.jsx("img",{className:"prompt-builder__scope-thumb",src:l.thumb||l.url||l.image,alt:""}),t.jsx("span",{className:"prompt-builder__scope-name",children:p}),t.jsx("button",{type:"button",className:"prompt-builder__scope-remove",onClick:n,"aria-label":o("promptBuilder.removeScopeImage"),title:o("promptBuilder.removeScopeImage"),children:"×"})]})}const D=["gpt-5.6-luna","gpt-5.6-terra","gpt-5.6-sol","gpt-5.5","gpt-5.4","gpt-5.4-mini"],$=D.map(e=>({value:e,label:e}));function R(){const e=m(s=>s.model),n=m(s=>s.setModel),{t:r}=f();return t.jsx(T,{className:"prompt-builder__model-picker",items:$,value:e,onChange:n,ariaLabel:r("promptBuilder.model"),portal:!0})}const w={"Brief Intent Summary":"summary","Final Prompt - Korean":"ko","Final Prompt - English":"en",Notes:"notes"},z=/^(Brief Intent Summary|Final Prompt - Korean|Final Prompt - English|Notes):\s*(.*)$/gim;function U(e){const n=e.trim();return(n.match(/^```(?:[a-zA-Z0-9_-]+)?\s*([\s\S]*?)\s*```$/)?.[1]??n).trim()}function L(e){const n={},r=Array.from(e.matchAll(z));for(let s=0;s<r.length;s+=1){const o=r[s],d=o[1]??"",l=w[d];if(!l||typeof o.index!="number")continue;const p=o[2]?.trim()??"",i=o.index+o[0].length,c=r[s+1]?.index??e.length,g=U([p,e.slice(i,c)].filter(Boolean).join(`
|
|
2
2
|
`));g&&(n[l]=g)}return n}function G(e){const n=L(e),r=[];return n.ko&&r.push({language:"ko",heading:"Final Prompt - Korean",text:n.ko}),n.en&&r.push({language:"en",heading:"Final Prompt - English",text:n.en}),r.length===0?null:{summary:n.summary,prompts:r,notes:n.notes}}function O({messageId:e,prompt:n}){const r=u(c=>c.setPrompt),s=u(c=>c.insertPromptToComposer),o=u(c=>c.showToast),{t:d}=f(),l=n.language==="ko"?d("promptBuilder.finalKoreanPrompt"):d("promptBuilder.finalEnglishPrompt"),p=()=>{r(n.text),o(d("promptBuilder.applied"))},i=()=>{s({id:`builder_${e}_${n.language}`,name:l,text:n.text,placement:"after"}),o(d("promptBuilder.inserted"))};return t.jsxs("section",{className:"prompt-builder__structured-card","aria-label":l,children:[t.jsxs("div",{className:"prompt-builder__structured-card-header",children:[t.jsx("strong",{children:l}),t.jsx("span",{children:n.language.toUpperCase()})]}),t.jsx("p",{children:n.text}),t.jsxs("div",{className:"prompt-builder__structured-actions",children:[t.jsx("button",{type:"button",onClick:p,children:d("promptBuilder.applyToPrompt")}),t.jsx("button",{type:"button",onClick:i,children:d("promptBuilder.insertAsBlock")})]})]})}function q(e){return e.kind==="image"?"IMG":e.kind==="text"?"TXT":"FILE"}function H({message:e}){const{t:n}=f(),r=e.role==="assistant"?G(e.content):null;return t.jsxs("article",{className:`prompt-builder__message prompt-builder__message--${e.role}`,children:[t.jsx("div",{className:"prompt-builder__message-role",children:e.role==="user"?n("promptBuilder.user"):n("promptBuilder.assistant")}),r?t.jsxs("div",{className:"prompt-builder__structured-prompts",children:[r.summary?t.jsx("p",{className:"prompt-builder__structured-summary",children:r.summary}):null,r.prompts.map(s=>t.jsx(O,{messageId:e.id,prompt:s},`${e.id}-${s.language}`)),r.notes?t.jsx("p",{className:"prompt-builder__structured-notes",children:r.notes}):null]}):t.jsx("p",{children:e.content}),e.attachments&&e.attachments.length>0?t.jsx("div",{className:"prompt-builder__message-attachments",children:e.attachments.map(s=>t.jsxs("span",{className:"prompt-builder__message-attachment",children:[s.kind==="image"&&s.dataUrl?t.jsx("img",{src:s.dataUrl,alt:""}):t.jsx("span",{children:q(s)}),t.jsx("em",{children:s.name})]},s.id))}):null]})}function X(){const e=m(o=>o.messages),n=m(o=>o.loading),r=j.useRef(null),{t:s}=f();return j.useEffect(()=>{const o=r.current;o&&(o.scrollTop=o.scrollHeight)},[e.length,n]),t.jsxs("div",{ref:r,className:"prompt-builder__messages",children:[e.length===0&&t.jsx("div",{className:"prompt-builder__empty",children:s("promptBuilder.empty")}),e.map(o=>t.jsx(H,{message:o},o.id)),n&&t.jsxs("div",{className:"prompt-builder__thinking",role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"prompt-builder__thinking-dots","aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),t.jsx("span",{children:s("promptBuilder.thinking")})]})]})}function W(e){return e.kind==="image"?"IMG":e.kind==="text"?"TXT":"FILE"}function Y(){const e=m(s=>s.attachments),n=m(s=>s.removeAttachment),{t:r}=f();return e.length===0?null:t.jsx("div",{className:"prompt-builder__attachments",children:e.map(s=>t.jsxs("span",{className:"prompt-builder__attachment",children:[s.kind==="image"&&s.dataUrl?t.jsx("img",{src:s.dataUrl,alt:""}):t.jsx("span",{children:W(s)}),t.jsx("em",{children:s.name}),t.jsx("button",{type:"button",onClick:()=>n(s.id),"aria-label":r("promptBuilder.removeAttachment",{name:s.name}),title:r("promptBuilder.removeAttachment",{name:s.name}),children:"×"})]},s.id))})}function Z(){const e=m(a=>a.draft),n=m(a=>a.setDraft),r=m(a=>a.loading),s=m(a=>a.addAttachments),o=m(a=>a.sendMessage),d=m(a=>a.messages),l=m(a=>a.clearMessages),p=m(a=>a.attachments),i=u(a=>a.prompt),c=u(a=>a.insertedPrompts),g=u(a=>a.quality),_=u(a=>a.getResolvedSize),x=u(a=>a.currentImage),h=j.useRef(null),{t:b}=f(),B=()=>{!e.trim()&&p.length===0||r||o({currentPrompt:i,insertedPrompts:c.map(a=>({name:a.name,text:a.text})),settings:{quality:g,size:_()},currentResultPrompt:x?.prompt??null})},N=a=>{a.length!==0&&s(a)},I=a=>{const P=Array.from(a.clipboardData?.files??[]);P.length!==0&&(a.preventDefault(),N(P))};return t.jsxs("div",{className:"prompt-builder__composer",children:[t.jsx(Y,{}),t.jsx("textarea",{value:e,placeholder:b("promptBuilder.placeholder"),onChange:a=>n(a.target.value),onPaste:I,onKeyDown:a=>{a.key==="Enter"&&(a.ctrlKey||a.metaKey)&&(a.preventDefault(),B())}}),t.jsx("input",{ref:h,type:"file",multiple:!0,hidden:!0,onChange:a=>{N(Array.from(a.target.files??[])),a.target.value=""}}),t.jsxs("div",{className:"prompt-builder__composer-actions",children:[t.jsx("button",{type:"button",className:"prompt-builder__attach",onClick:()=>h.current?.click(),disabled:r,"aria-label":b("promptBuilder.attach"),title:b("promptBuilder.attach"),children:"+"}),t.jsx("button",{type:"button",className:"prompt-builder__clear",onClick:l,disabled:d.length===0||r,children:b("promptBuilder.clear")}),t.jsx("button",{type:"button",className:"prompt-builder__send",onClick:B,disabled:!e.trim()&&p.length===0||r,children:b(r?"promptBuilder.sending":"promptBuilder.send")})]})]})}function Q({variant:e="panel"}){const{t:n}=f();return t.jsxs("section",{className:`prompt-builder prompt-builder--${e}`,"aria-label":n("promptBuilder.title"),children:[t.jsxs("div",{className:"prompt-builder__header",children:[t.jsxs("div",{children:[t.jsx("span",{className:"section-title",children:n("promptBuilder.title")}),t.jsx(K,{})]}),t.jsx("div",{className:"prompt-builder__header-actions",children:t.jsx(R,{})})]}),t.jsx(X,{}),t.jsx(Z,{})]})}export{Q as PromptBuilderPanel};
|