markdown-agent-studio 0.2.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/LICENSE +21 -0
- package/README.md +80 -0
- package/bin/markdown-agent-studio.js +282 -0
- package/dist/assets/index-C7HrwdLI.js +1188 -0
- package/dist/assets/index-DKT7U-mY.css +1 -0
- package/dist/assets/vendor-flow-DOjU6Ffq.js +7 -0
- package/dist/assets/vendor-google-eZp-A-GY.js +2 -0
- package/dist/assets/vendor-markdown-DmDC9MiR.js +37 -0
- package/dist/assets/vendor-monaco-DeQXaAoV.js +11 -0
- package/dist/assets/vendor-react-l0sNRNKZ.js +1 -0
- package/dist/index.html +22 -0
- package/dist/vite.svg +1 -0
- package/index.d.ts +4 -0
- package/index.js +8 -0
- package/package.json +117 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
function Pr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function kg(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if(typeof t=="function"){var n=function o(){var r=!1;try{r=this instanceof o}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};n.prototype=t.prototype}else n={};return Object.defineProperty(n,"__esModule",{value:!0}),Object.keys(e).forEach(function(o){var r=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(n,o,r.get?r:{enumerable:!0,get:function(){return e[o]}})}),n}var pn={exports:{}},ot={};var vo;function _a(){if(vo)return ot;vo=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(o,r,i){var s=null;if(i!==void 0&&(s=""+i),r.key!==void 0&&(s=""+r.key),"key"in r){i={};for(var c in r)c!=="key"&&(i[c]=r[c])}else i=r;return r=i.ref,{$$typeof:e,type:o,key:s,ref:r!==void 0?r:null,props:i}}return ot.Fragment=t,ot.jsx=n,ot.jsxs=n,ot}var _o;function Ea(){return _o||(_o=1,pn.exports=_a()),pn.exports}var D=Ea(),mn={exports:{}},U={};var Eo;function ba(){if(Eo)return U;Eo=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),r=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),s=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),a=Symbol.for("react.memo"),l=Symbol.for("react.lazy"),f=Symbol.for("react.activity"),d=Symbol.iterator;function g(m){return m===null||typeof m!="object"?null:(m=d&&m[d]||m["@@iterator"],typeof m=="function"?m:null)}var p={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},w=Object.assign,v={};function y(m,b,B){this.props=m,this.context=b,this.refs=v,this.updater=B||p}y.prototype.isReactComponent={},y.prototype.setState=function(m,b){if(typeof m!="object"&&typeof m!="function"&&m!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,m,b,"setState")},y.prototype.forceUpdate=function(m){this.updater.enqueueForceUpdate(this,m,"forceUpdate")};function N(){}N.prototype=y.prototype;function h(m,b,B){this.props=m,this.context=b,this.refs=v,this.updater=B||p}var x=h.prototype=new N;x.constructor=h,w(x,y.prototype),x.isPureReactComponent=!0;var M=Array.isArray;function S(){}var E={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function R(m,b,B){var O=B.ref;return{$$typeof:e,type:m,key:b,ref:O!==void 0?O:null,props:B}}function F(m,b){return R(m.type,b,m.props)}function T(m){return typeof m=="object"&&m!==null&&m.$$typeof===e}function H(m){var b={"=":"=0",":":"=2"};return"$"+m.replace(/[=:]/g,function(B){return b[B]})}var V=/\/+/g;function _(m,b){return typeof m=="object"&&m!==null&&m.key!=null?H(""+m.key):b.toString(36)}function I(m){switch(m.status){case"fulfilled":return m.value;case"rejected":throw m.reason;default:switch(typeof m.status=="string"?m.then(S,S):(m.status="pending",m.then(function(b){m.status==="pending"&&(m.status="fulfilled",m.value=b)},function(b){m.status==="pending"&&(m.status="rejected",m.reason=b)})),m.status){case"fulfilled":return m.value;case"rejected":throw m.reason}}throw m}function C(m,b,B,O,Y){var W=typeof m;(W==="undefined"||W==="boolean")&&(m=null);var X=!1;if(m===null)X=!0;else switch(W){case"bigint":case"string":case"number":X=!0;break;case"object":switch(m.$$typeof){case e:case t:X=!0;break;case l:return X=m._init,C(X(m._payload),b,B,O,Y)}}if(X)return Y=Y(m),X=O===""?"."+_(m,0):O,M(Y)?(B="",X!=null&&(B=X.replace(V,"$&/")+"/"),C(Y,b,B,"",function(Q){return Q})):Y!=null&&(T(Y)&&(Y=F(Y,B+(Y.key==null||m&&m.key===Y.key?"":(""+Y.key).replace(V,"$&/")+"/")+X)),b.push(Y)),1;X=0;var j=O===""?".":O+":";if(M(m))for(var Z=0;Z<m.length;Z++)O=m[Z],W=j+_(O,Z),X+=C(O,b,B,W,Y);else if(Z=g(m),typeof Z=="function")for(m=Z.call(m),Z=0;!(O=m.next()).done;)O=O.value,W=j+_(O,Z++),X+=C(O,b,B,W,Y);else if(W==="object"){if(typeof m.then=="function")return C(I(m),b,B,O,Y);throw b=String(m),Error("Objects are not valid as a React child (found: "+(b==="[object Object]"?"object with keys {"+Object.keys(m).join(", ")+"}":b)+"). If you meant to render a collection of children, use an array instead.")}return X}function k(m,b,B){if(m==null)return m;var O=[],Y=0;return C(m,O,"","",function(W){return b.call(B,W,Y++)}),O}function A(m){if(m._status===-1){var b=m._result;b=b(),b.then(function(B){(m._status===0||m._status===-1)&&(m._status=1,m._result=B)},function(B){(m._status===0||m._status===-1)&&(m._status=2,m._result=B)}),m._status===-1&&(m._status=0,m._result=b)}if(m._status===1)return m._result.default;throw m._result}var P=typeof reportError=="function"?reportError:function(m){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var b=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof m=="object"&&m!==null&&typeof m.message=="string"?String(m.message):String(m),error:m});if(!window.dispatchEvent(b))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",m);return}console.error(m)},L={map:k,forEach:function(m,b,B){k(m,function(){b.apply(this,arguments)},B)},count:function(m){var b=0;return k(m,function(){b++}),b},toArray:function(m){return k(m,function(b){return b})||[]},only:function(m){if(!T(m))throw Error("React.Children.only expected to receive a single React element child.");return m}};return U.Activity=f,U.Children=L,U.Component=y,U.Fragment=n,U.Profiler=r,U.PureComponent=h,U.StrictMode=o,U.Suspense=u,U.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=E,U.__COMPILER_RUNTIME={__proto__:null,c:function(m){return E.H.useMemoCache(m)}},U.cache=function(m){return function(){return m.apply(null,arguments)}},U.cacheSignal=function(){return null},U.cloneElement=function(m,b,B){if(m==null)throw Error("The argument must be a React element, but you passed "+m+".");var O=w({},m.props),Y=m.key;if(b!=null)for(W in b.key!==void 0&&(Y=""+b.key),b)!$.call(b,W)||W==="key"||W==="__self"||W==="__source"||W==="ref"&&b.ref===void 0||(O[W]=b[W]);var W=arguments.length-2;if(W===1)O.children=B;else if(1<W){for(var X=Array(W),j=0;j<W;j++)X[j]=arguments[j+2];O.children=X}return R(m.type,Y,O)},U.createContext=function(m){return m={$$typeof:s,_currentValue:m,_currentValue2:m,_threadCount:0,Provider:null,Consumer:null},m.Provider=m,m.Consumer={$$typeof:i,_context:m},m},U.createElement=function(m,b,B){var O,Y={},W=null;if(b!=null)for(O in b.key!==void 0&&(W=""+b.key),b)$.call(b,O)&&O!=="key"&&O!=="__self"&&O!=="__source"&&(Y[O]=b[O]);var X=arguments.length-2;if(X===1)Y.children=B;else if(1<X){for(var j=Array(X),Z=0;Z<X;Z++)j[Z]=arguments[Z+2];Y.children=j}if(m&&m.defaultProps)for(O in X=m.defaultProps,X)Y[O]===void 0&&(Y[O]=X[O]);return R(m,W,Y)},U.createRef=function(){return{current:null}},U.forwardRef=function(m){return{$$typeof:c,render:m}},U.isValidElement=T,U.lazy=function(m){return{$$typeof:l,_payload:{_status:-1,_result:m},_init:A}},U.memo=function(m,b){return{$$typeof:a,type:m,compare:b===void 0?null:b}},U.startTransition=function(m){var b=E.T,B={};E.T=B;try{var O=m(),Y=E.S;Y!==null&&Y(B,O),typeof O=="object"&&O!==null&&typeof O.then=="function"&&O.then(S,P)}catch(W){P(W)}finally{b!==null&&B.types!==null&&(b.types=B.types),E.T=b}},U.unstable_useCacheRefresh=function(){return E.H.useCacheRefresh()},U.use=function(m){return E.H.use(m)},U.useActionState=function(m,b,B){return E.H.useActionState(m,b,B)},U.useCallback=function(m,b){return E.H.useCallback(m,b)},U.useContext=function(m){return E.H.useContext(m)},U.useDebugValue=function(){},U.useDeferredValue=function(m,b){return E.H.useDeferredValue(m,b)},U.useEffect=function(m,b){return E.H.useEffect(m,b)},U.useEffectEvent=function(m){return E.H.useEffectEvent(m)},U.useId=function(){return E.H.useId()},U.useImperativeHandle=function(m,b,B){return E.H.useImperativeHandle(m,b,B)},U.useInsertionEffect=function(m,b){return E.H.useInsertionEffect(m,b)},U.useLayoutEffect=function(m,b){return E.H.useLayoutEffect(m,b)},U.useMemo=function(m,b){return E.H.useMemo(m,b)},U.useOptimistic=function(m,b){return E.H.useOptimistic(m,b)},U.useReducer=function(m,b,B){return E.H.useReducer(m,b,B)},U.useRef=function(m){return E.H.useRef(m)},U.useState=function(m){return E.H.useState(m)},U.useSyncExternalStore=function(m,b,B){return E.H.useSyncExternalStore(m,b,B)},U.useTransition=function(){return E.H.useTransition()},U.version="19.2.4",U}var bo;function Qt(){return bo||(bo=1,mn.exports=ba()),mn.exports}var z=Qt();const Sa=Pr(z);var yn={exports:{}},ce={};var So;function Na(){if(So)return ce;So=1;var e=Qt();function t(u){var a="https://react.dev/errors/"+u;if(1<arguments.length){a+="?args[]="+encodeURIComponent(arguments[1]);for(var l=2;l<arguments.length;l++)a+="&args[]="+encodeURIComponent(arguments[l])}return"Minified React error #"+u+"; visit "+a+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function n(){}var o={d:{f:n,r:function(){throw Error(t(522))},D:n,C:n,L:n,m:n,X:n,S:n,M:n},p:0,findDOMNode:null},r=Symbol.for("react.portal");function i(u,a,l){var f=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:r,key:f==null?null:""+f,children:u,containerInfo:a,implementation:l}}var s=e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(u,a){if(u==="font")return"";if(typeof a=="string")return a==="use-credentials"?a:""}return ce.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=o,ce.createPortal=function(u,a){var l=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)throw Error(t(299));return i(u,a,null,l)},ce.flushSync=function(u){var a=s.T,l=o.p;try{if(s.T=null,o.p=2,u)return u()}finally{s.T=a,o.p=l,o.d.f()}},ce.preconnect=function(u,a){typeof u=="string"&&(a?(a=a.crossOrigin,a=typeof a=="string"?a==="use-credentials"?a:"":void 0):a=null,o.d.C(u,a))},ce.prefetchDNS=function(u){typeof u=="string"&&o.d.D(u)},ce.preinit=function(u,a){if(typeof u=="string"&&a&&typeof a.as=="string"){var l=a.as,f=c(l,a.crossOrigin),d=typeof a.integrity=="string"?a.integrity:void 0,g=typeof a.fetchPriority=="string"?a.fetchPriority:void 0;l==="style"?o.d.S(u,typeof a.precedence=="string"?a.precedence:void 0,{crossOrigin:f,integrity:d,fetchPriority:g}):l==="script"&&o.d.X(u,{crossOrigin:f,integrity:d,fetchPriority:g,nonce:typeof a.nonce=="string"?a.nonce:void 0})}},ce.preinitModule=function(u,a){if(typeof u=="string")if(typeof a=="object"&&a!==null){if(a.as==null||a.as==="script"){var l=c(a.as,a.crossOrigin);o.d.M(u,{crossOrigin:l,integrity:typeof a.integrity=="string"?a.integrity:void 0,nonce:typeof a.nonce=="string"?a.nonce:void 0})}}else a==null&&o.d.M(u)},ce.preload=function(u,a){if(typeof u=="string"&&typeof a=="object"&&a!==null&&typeof a.as=="string"){var l=a.as,f=c(l,a.crossOrigin);o.d.L(u,l,{crossOrigin:f,integrity:typeof a.integrity=="string"?a.integrity:void 0,nonce:typeof a.nonce=="string"?a.nonce:void 0,type:typeof a.type=="string"?a.type:void 0,fetchPriority:typeof a.fetchPriority=="string"?a.fetchPriority:void 0,referrerPolicy:typeof a.referrerPolicy=="string"?a.referrerPolicy:void 0,imageSrcSet:typeof a.imageSrcSet=="string"?a.imageSrcSet:void 0,imageSizes:typeof a.imageSizes=="string"?a.imageSizes:void 0,media:typeof a.media=="string"?a.media:void 0})}},ce.preloadModule=function(u,a){if(typeof u=="string")if(a){var l=c(a.as,a.crossOrigin);o.d.m(u,{as:typeof a.as=="string"&&a.as!=="script"?a.as:void 0,crossOrigin:l,integrity:typeof a.integrity=="string"?a.integrity:void 0})}else o.d.m(u)},ce.requestFormReset=function(u){o.d.r(u)},ce.unstable_batchedUpdates=function(u,a){return u(a)},ce.useFormState=function(u,a,l){return s.H.useFormState(u,a,l)},ce.useFormStatus=function(){return s.H.useHostTransitionStatus()},ce.version="19.2.4",ce}var No;function Ca(){if(No)return yn.exports;No=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),yn.exports=Na(),yn.exports}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 Ma={value:()=>{}};function Jt(){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 Dt(n)}function Dt(e){this._=e}function Ia(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}})}Dt.prototype=Jt.prototype={constructor:Dt,on:function(e,t){var n=this._,o=Ia(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Aa(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]=Co(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Co(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 Dt(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 Aa(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Co(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=Ma,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var Tn="http://www.w3.org/1999/xhtml";const Mo={svg:"http://www.w3.org/2000/svg",xhtml:Tn,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function en(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Mo.hasOwnProperty(t)?{space:Mo[t],local:e}:e}function ka(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Tn&&t.documentElement.namespaceURI===Tn?t.createElement(e):t.createElementNS(n,e)}}function Ta(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Rr(e){var t=en(e);return(t.local?Ta:ka)(t)}function Pa(){}function Xn(e){return e==null?Pa:function(){return this.querySelector(e)}}function Ra(e){typeof e!="function"&&(e=Xn(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,c=o[r]=new Array(s),u,a,l=0;l<s;++l)(u=i[l])&&(a=e.call(u,u.__data__,l,i))&&("__data__"in u&&(a.__data__=u.__data__),c[l]=a);return new fe(o,this._parents)}function $a(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Da(){return[]}function $r(e){return e==null?Da:function(){return this.querySelectorAll(e)}}function Ha(e){return function(){return $a(e.apply(this,arguments))}}function za(e){typeof e=="function"?e=Ha(e):e=$r(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],c=s.length,u,a=0;a<c;++a)(u=s[a])&&(o.push(e.call(u,u.__data__,a,s)),r.push(u));return new fe(o,r)}function Dr(e){return function(){return this.matches(e)}}function Hr(e){return function(t){return t.matches(e)}}var Oa=Array.prototype.find;function La(e){return function(){return Oa.call(this.children,e)}}function Va(){return this.firstElementChild}function Ba(e){return this.select(e==null?Va:La(typeof e=="function"?e:Hr(e)))}var ja=Array.prototype.filter;function Fa(){return Array.from(this.children)}function Ya(e){return function(){return ja.call(this.children,e)}}function Xa(e){return this.selectAll(e==null?Fa:Ya(typeof e=="function"?e:Hr(e)))}function Za(e){typeof e!="function"&&(e=Dr(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,c=o[r]=[],u,a=0;a<s;++a)(u=i[a])&&e.call(u,u.__data__,a,i)&&c.push(u);return new fe(o,this._parents)}function zr(e){return new Array(e.length)}function Wa(){return new fe(this._enter||this._groups.map(zr),this._parents)}function Vt(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Vt.prototype={constructor:Vt,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 qa(e){return function(){return e}}function Ga(e,t,n,o,r,i){for(var s=0,c,u=t.length,a=i.length;s<a;++s)(c=t[s])?(c.__data__=i[s],o[s]=c):n[s]=new Vt(e,i[s]);for(;s<u;++s)(c=t[s])&&(r[s]=c)}function Ua(e,t,n,o,r,i,s){var c,u,a=new Map,l=t.length,f=i.length,d=new Array(l),g;for(c=0;c<l;++c)(u=t[c])&&(d[c]=g=s.call(u,u.__data__,c,t)+"",a.has(g)?r[c]=u:a.set(g,u));for(c=0;c<f;++c)g=s.call(e,i[c],c,i)+"",(u=a.get(g))?(o[c]=u,u.__data__=i[c],a.delete(g)):n[c]=new Vt(e,i[c]);for(c=0;c<l;++c)(u=t[c])&&a.get(d[c])===u&&(r[c]=u)}function Ka(e){return e.__data__}function Qa(e,t){if(!arguments.length)return Array.from(this,Ka);var n=t?Ua:Ga,o=this._parents,r=this._groups;typeof e!="function"&&(e=qa(e));for(var i=r.length,s=new Array(i),c=new Array(i),u=new Array(i),a=0;a<i;++a){var l=o[a],f=r[a],d=f.length,g=Ja(e.call(l,l&&l.__data__,a,o)),p=g.length,w=c[a]=new Array(p),v=s[a]=new Array(p),y=u[a]=new Array(d);n(l,f,w,v,y,g,t);for(var N=0,h=0,x,M;N<p;++N)if(x=w[N]){for(N>=h&&(h=N+1);!(M=v[h])&&++h<p;);x._next=M||null}}return s=new fe(s,o),s._enter=c,s._exit=u,s}function Ja(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function ec(){return new fe(this._exit||this._groups.map(zr),this._parents)}function tc(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 nc(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),c=new Array(r),u=0;u<s;++u)for(var a=n[u],l=o[u],f=a.length,d=c[u]=new Array(f),g,p=0;p<f;++p)(g=a[p]||l[p])&&(d[p]=g);for(;u<r;++u)c[u]=n[u];return new fe(c,this._parents)}function oc(){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 rc(e){e||(e=ic);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],c=s.length,u=r[i]=new Array(c),a,l=0;l<c;++l)(a=s[l])&&(u[l]=a);u.sort(t)}return new fe(r,this._parents).order()}function ic(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function sc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function ac(){return Array.from(this)}function cc(){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 uc(){let e=0;for(const t of this)++e;return e}function lc(){return!this.node()}function fc(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,c;i<s;++i)(c=r[i])&&e.call(c,c.__data__,i,r);return this}function dc(e){return function(){this.removeAttribute(e)}}function hc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function gc(e,t){return function(){this.setAttribute(e,t)}}function pc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function mc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function yc(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 xc(e,t){var n=en(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?hc:dc:typeof t=="function"?n.local?yc:mc:n.local?pc:gc)(n,t))}function Or(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function wc(e){return function(){this.style.removeProperty(e)}}function vc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function _c(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function Ec(e,t,n){return arguments.length>1?this.each((t==null?wc:typeof t=="function"?_c:vc)(e,t,n??"")):Ze(this.node(),e)}function Ze(e,t){return e.style.getPropertyValue(t)||Or(e).getComputedStyle(e,null).getPropertyValue(t)}function bc(e){return function(){delete this[e]}}function Sc(e,t){return function(){this[e]=t}}function Nc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Cc(e,t){return arguments.length>1?this.each((t==null?bc:typeof t=="function"?Nc:Sc)(e,t)):this.node()[e]}function Lr(e){return e.trim().split(/^|\s+/)}function Zn(e){return e.classList||new Vr(e)}function Vr(e){this._node=e,this._names=Lr(e.getAttribute("class")||"")}Vr.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 Br(e,t){for(var n=Zn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function jr(e,t){for(var n=Zn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function Mc(e){return function(){Br(this,e)}}function Ic(e){return function(){jr(this,e)}}function Ac(e,t){return function(){(t.apply(this,arguments)?Br:jr)(this,e)}}function kc(e,t){var n=Lr(e+"");if(arguments.length<2){for(var o=Zn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Ac:t?Mc:Ic)(n,t))}function Tc(){this.textContent=""}function Pc(e){return function(){this.textContent=e}}function Rc(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function $c(e){return arguments.length?this.each(e==null?Tc:(typeof e=="function"?Rc:Pc)(e)):this.node().textContent}function Dc(){this.innerHTML=""}function Hc(e){return function(){this.innerHTML=e}}function zc(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Oc(e){return arguments.length?this.each(e==null?Dc:(typeof e=="function"?zc:Hc)(e)):this.node().innerHTML}function Lc(){this.nextSibling&&this.parentNode.appendChild(this)}function Vc(){return this.each(Lc)}function Bc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jc(){return this.each(Bc)}function Fc(e){var t=typeof e=="function"?e:Rr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Yc(){return null}function Xc(e,t){var n=typeof e=="function"?e:Rr(e),o=t==null?Yc:typeof t=="function"?t:Xn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Zc(){var e=this.parentNode;e&&e.removeChild(this)}function Wc(){return this.each(Zc)}function qc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Gc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Uc(e){return this.select(e?Gc:qc)}function Kc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Qc(e){return function(t){e.call(this,t,this.__data__)}}function Jc(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 eu(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 tu(e,t,n){return function(){var o=this.__on,r,i=Qc(t);if(o){for(var s=0,c=o.length;s<c;++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 nu(e,t,n){var o=Jc(e+""),r,i=o.length,s;if(arguments.length<2){var c=this.node().__on;if(c){for(var u=0,a=c.length,l;u<a;++u)for(r=0,l=c[u];r<i;++r)if((s=o[r]).type===l.type&&s.name===l.name)return l.value}return}for(c=t?tu:eu,r=0;r<i;++r)this.each(c(o[r],t,n));return this}function Fr(e,t,n){var o=Or(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 ou(e,t){return function(){return Fr(this,e,t)}}function ru(e,t){return function(){return Fr(this,e,t.apply(this,arguments))}}function iu(e,t){return this.each((typeof t=="function"?ru:ou)(e,t))}function*su(){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 Yr=[null];function fe(e,t){this._groups=e,this._parents=t}function wt(){return new fe([[document.documentElement]],Yr)}function au(){return this}fe.prototype=wt.prototype={constructor:fe,select:Ra,selectAll:za,selectChild:Ba,selectChildren:Xa,filter:Za,data:Qa,enter:Wa,exit:ec,join:tc,merge:nc,selection:au,order:oc,sort:rc,call:sc,nodes:ac,node:cc,size:uc,empty:lc,each:fc,attr:xc,style:Ec,property:Cc,classed:kc,text:$c,html:Oc,raise:Vc,lower:jc,append:Fc,insert:Xc,remove:Wc,clone:Uc,datum:Kc,on:nu,dispatch:iu,[Symbol.iterator]:su};function le(e){return typeof e=="string"?new fe([[document.querySelector(e)]],[document.documentElement]):new fe([[e]],Yr)}function cu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=cu(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 uu={passive:!1},lt={capture:!0,passive:!1};function xn(e){e.stopImmediatePropagation()}function Ye(e){e.preventDefault(),e.stopImmediatePropagation()}function Xr(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",Ye,lt);"onselectstart"in t?n.on("selectstart.drag",Ye,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Zr(e,t){var n=e.document.documentElement,o=le(e).on("dragstart.drag",null);t&&(o.on("click.drag",Ye,lt),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 Ct=e=>()=>e;function Pn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:c,dx:u,dy:a,dispatch:l}){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:c,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:a,enumerable:!0,configurable:!0},_:{value:l}})}Pn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function lu(e){return!e.ctrlKey&&!e.button}function fu(){return this.parentNode}function du(e,t){return t??{x:e.x,y:e.y}}function hu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Wr(){var e=lu,t=fu,n=du,o=hu,r={},i=Jt("start","drag","end"),s=0,c,u,a,l,f=0;function d(x){x.on("mousedown.drag",g).filter(o).on("touchstart.drag",v).on("touchmove.drag",y,uu).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(x,M){if(!(l||!e.call(this,x,M))){var S=h(this,t.call(this,x,M),x,M,"mouse");S&&(le(x.view).on("mousemove.drag",p,lt).on("mouseup.drag",w,lt),Xr(x.view),xn(x),a=!1,c=x.clientX,u=x.clientY,S("start",x))}}function p(x){if(Ye(x),!a){var M=x.clientX-c,S=x.clientY-u;a=M*M+S*S>f}r.mouse("drag",x)}function w(x){le(x.view).on("mousemove.drag mouseup.drag",null),Zr(x.view,a),Ye(x),r.mouse("end",x)}function v(x,M){if(e.call(this,x,M)){var S=x.changedTouches,E=t.call(this,x,M),$=S.length,R,F;for(R=0;R<$;++R)(F=h(this,E,x,M,S[R].identifier,S[R]))&&(xn(x),F("start",x,S[R]))}}function y(x){var M=x.changedTouches,S=M.length,E,$;for(E=0;E<S;++E)($=r[M[E].identifier])&&(Ye(x),$("drag",x,M[E]))}function N(x){var M=x.changedTouches,S=M.length,E,$;for(l&&clearTimeout(l),l=setTimeout(function(){l=null},500),E=0;E<S;++E)($=r[M[E].identifier])&&(xn(x),$("end",x,M[E]))}function h(x,M,S,E,$,R){var F=i.copy(),T=de(R||S,M),H,V,_;if((_=n.call(x,new Pn("beforestart",{sourceEvent:S,target:d,identifier:$,active:s,x:T[0],y:T[1],dx:0,dy:0,dispatch:F}),E))!=null)return H=_.x-T[0]||0,V=_.y-T[1]||0,function I(C,k,A){var P=T,L;switch(C){case"start":r[$]=I,L=s++;break;case"end":delete r[$],--s;case"drag":T=de(A||k,M),L=s;break}F.call(C,x,new Pn(C,{sourceEvent:k,subject:_,target:d,identifier:$,active:L,x:T[0]+H,y:T[1]+V,dx:T[0]-P[0],dy:T[1]-P[1],dispatch:F}),E)}}return d.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Ct(!!x),d):e},d.container=function(x){return arguments.length?(t=typeof x=="function"?x:Ct(x),d):t},d.subject=function(x){return arguments.length?(n=typeof x=="function"?x:Ct(x),d):n},d.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:Ct(!!x),d):o},d.on=function(){var x=i.on.apply(i,arguments);return x===i?d:x},d.clickDistance=function(x){return arguments.length?(f=(x=+x)*x,d):Math.sqrt(f)},d}function Wn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function qr(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function vt(){}var ft=.7,Bt=1/ft,Xe="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xe="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",gu=/^#([0-9a-f]{3,8})$/,pu=new RegExp(`^rgb\\(${Xe},${Xe},${Xe}\\)$`),mu=new RegExp(`^rgb\\(${xe},${xe},${xe}\\)$`),yu=new RegExp(`^rgba\\(${Xe},${Xe},${Xe},${dt}\\)$`),xu=new RegExp(`^rgba\\(${xe},${xe},${xe},${dt}\\)$`),wu=new RegExp(`^hsl\\(${dt},${xe},${xe}\\)$`),vu=new RegExp(`^hsla\\(${dt},${xe},${xe},${dt}\\)$`),Io={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};Wn(vt,He,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ao,formatHex:Ao,formatHex8:_u,formatHsl:Eu,formatRgb:ko,toString:ko});function Ao(){return this.rgb().formatHex()}function _u(){return this.rgb().formatHex8()}function Eu(){return Gr(this).formatHsl()}function ko(){return this.rgb().formatRgb()}function He(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=gu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?To(t):n===3?new ue(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mt(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=pu.exec(e))?new ue(t[1],t[2],t[3],1):(t=mu.exec(e))?new ue(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=yu.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=xu.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=wu.exec(e))?$o(t[1],t[2]/100,t[3]/100,1):(t=vu.exec(e))?$o(t[1],t[2]/100,t[3]/100,t[4]):Io.hasOwnProperty(e)?To(Io[e]):e==="transparent"?new ue(NaN,NaN,NaN,0):null}function To(e){return new ue(e>>16&255,e>>8&255,e&255,1)}function Mt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ue(e,t,n,o)}function bu(e){return e instanceof vt||(e=He(e)),e?(e=e.rgb(),new ue(e.r,e.g,e.b,e.opacity)):new ue}function Rn(e,t,n,o){return arguments.length===1?bu(e):new ue(e,t,n,o??1)}function ue(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Wn(ue,Rn,qr(vt,{brighter(e){return e=e==null?Bt:Math.pow(Bt,e),new ue(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,e),new ue(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ue($e(this.r),$e(this.g),$e(this.b),jt(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:Po,formatHex:Po,formatHex8:Su,formatRgb:Ro,toString:Ro}));function Po(){return`#${Re(this.r)}${Re(this.g)}${Re(this.b)}`}function Su(){return`#${Re(this.r)}${Re(this.g)}${Re(this.b)}${Re((isNaN(this.opacity)?1:this.opacity)*255)}`}function Ro(){const e=jt(this.opacity);return`${e===1?"rgb(":"rgba("}${$e(this.r)}, ${$e(this.g)}, ${$e(this.b)}${e===1?")":`, ${e})`}`}function jt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function $e(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Re(e){return e=$e(e),(e<16?"0":"")+e.toString(16)}function $o(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new he(e,t,n,o)}function Gr(e){if(e instanceof he)return new he(e.h,e.s,e.l,e.opacity);if(e instanceof vt||(e=He(e)),!e)return new he;if(e instanceof he)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,c=i-r,u=(i+r)/2;return c?(t===i?s=(n-o)/c+(n<o)*6:n===i?s=(o-t)/c+2:s=(t-n)/c+4,c/=u<.5?i+r:2-i-r,s*=60):c=u>0&&u<1?0:s,new he(s,c,u,e.opacity)}function Nu(e,t,n,o){return arguments.length===1?Gr(e):new he(e,t,n,o??1)}function he(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Wn(he,Nu,qr(vt,{brighter(e){return e=e==null?Bt:Math.pow(Bt,e),new he(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ft:Math.pow(ft,e),new he(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 ue(wn(e>=240?e-240:e+120,r,o),wn(e,r,o),wn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new he(Do(this.h),It(this.s),It(this.l),jt(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=jt(this.opacity);return`${e===1?"hsl(":"hsla("}${Do(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Do(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function wn(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 qn=e=>()=>e;function Cu(e,t){return function(n){return e+n*t}}function Mu(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 Iu(e){return(e=+e)==1?Ur:function(t,n){return n-t?Mu(t,n,e):qn(isNaN(t)?n:t)}}function Ur(e,t){var n=t-e;return n?Cu(e,n):qn(isNaN(e)?t:e)}const Ft=(function e(t){var n=Iu(t);function o(r,i){var s=n((r=Rn(r)).r,(i=Rn(i)).r),c=n(r.g,i.g),u=n(r.b,i.b),a=Ur(r.opacity,i.opacity);return function(l){return r.r=s(l),r.g=c(l),r.b=u(l),r.opacity=a(l),r+""}}return o.gamma=e,o})(1);function Au(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 ku(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Tu(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]=ct(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(c){for(s=0;s<o;++s)i[s]=r[s](c);return i}}function Pu(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function ye(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Ru(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]=ct(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var $n=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,vn=new RegExp($n.source,"g");function $u(e){return function(){return e}}function Du(e){return function(t){return e(t)+""}}function Kr(e,t){var n=$n.lastIndex=vn.lastIndex=0,o,r,i,s=-1,c=[],u=[];for(e=e+"",t=t+"";(o=$n.exec(e))&&(r=vn.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),c[s]?c[s]+=i:c[++s]=i),(o=o[0])===(r=r[0])?c[s]?c[s]+=r:c[++s]=r:(c[++s]=null,u.push({i:s,x:ye(o,r)})),n=vn.lastIndex;return n<t.length&&(i=t.slice(n),c[s]?c[s]+=i:c[++s]=i),c.length<2?u[0]?Du(u[0].x):$u(t):(t=u.length,function(a){for(var l=0,f;l<t;++l)c[(f=u[l]).i]=f.x(a);return c.join("")})}function ct(e,t){var n=typeof t,o;return t==null||n==="boolean"?qn(t):(n==="number"?ye:n==="string"?(o=He(t))?(t=o,Ft):Kr:t instanceof He?Ft:t instanceof Date?Pu:ku(t)?Au:Array.isArray(t)?Tu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Ru:ye)(e,t)}var Ho=180/Math.PI,Dn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Qr(e,t,n,o,r,i){var s,c,u;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(u=e*n+t*o)&&(n-=e*u,o-=t*u),(c=Math.sqrt(n*n+o*o))&&(n/=c,o/=c,u/=c),e*o<t*n&&(e=-e,t=-t,u=-u,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Ho,skewX:Math.atan(u)*Ho,scaleX:s,scaleY:c}}var At;function Hu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Dn:Qr(t.a,t.b,t.c,t.d,t.e,t.f)}function zu(e){return e==null||(At||(At=document.createElementNS("http://www.w3.org/2000/svg","g")),At.setAttribute("transform",e),!(e=At.transform.baseVal.consolidate()))?Dn:(e=e.matrix,Qr(e.a,e.b,e.c,e.d,e.e,e.f))}function Jr(e,t,n,o){function r(a){return a.length?a.pop()+" ":""}function i(a,l,f,d,g,p){if(a!==f||l!==d){var w=g.push("translate(",null,t,null,n);p.push({i:w-4,x:ye(a,f)},{i:w-2,x:ye(l,d)})}else(f||d)&&g.push("translate("+f+t+d+n)}function s(a,l,f,d){a!==l?(a-l>180?l+=360:l-a>180&&(a+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:ye(a,l)})):l&&f.push(r(f)+"rotate("+l+o)}function c(a,l,f,d){a!==l?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:ye(a,l)}):l&&f.push(r(f)+"skewX("+l+o)}function u(a,l,f,d,g,p){if(a!==f||l!==d){var w=g.push(r(g)+"scale(",null,",",null,")");p.push({i:w-4,x:ye(a,f)},{i:w-2,x:ye(l,d)})}else(f!==1||d!==1)&&g.push(r(g)+"scale("+f+","+d+")")}return function(a,l){var f=[],d=[];return a=e(a),l=e(l),i(a.translateX,a.translateY,l.translateX,l.translateY,f,d),s(a.rotate,l.rotate,f,d),c(a.skewX,l.skewX,f,d),u(a.scaleX,a.scaleY,l.scaleX,l.scaleY,f,d),a=l=null,function(g){for(var p=-1,w=d.length,v;++p<w;)f[(v=d[p]).i]=v.x(g);return f.join("")}}}var Ou=Jr(Hu,"px, ","px)","deg)"),Lu=Jr(zu,", ",")",")"),Vu=1e-12;function zo(e){return((e=Math.exp(e))+1/e)/2}function Bu(e){return((e=Math.exp(e))-1/e)/2}function ju(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ht=(function e(t,n,o){function r(i,s){var c=i[0],u=i[1],a=i[2],l=s[0],f=s[1],d=s[2],g=l-c,p=f-u,w=g*g+p*p,v,y;if(w<Vu)y=Math.log(d/a)/t,v=function(E){return[c+E*g,u+E*p,a*Math.exp(t*E*y)]};else{var N=Math.sqrt(w),h=(d*d-a*a+o*w)/(2*a*n*N),x=(d*d-a*a-o*w)/(2*d*n*N),M=Math.log(Math.sqrt(h*h+1)-h),S=Math.log(Math.sqrt(x*x+1)-x);y=(S-M)/t,v=function(E){var $=E*y,R=zo(M),F=a/(n*N)*(R*ju(t*$+M)-Bu(M));return[c+F*g,u+F*p,a*R/zo(t*$+M)]}}return v.duration=y*1e3*t/Math.SQRT2,v}return r.rho=function(i){var s=Math.max(.001,+i),c=s*s,u=c*c;return e(s,c,u)},r})(Math.SQRT2,2,4);var We=0,st=0,rt=0,ei=1e3,Yt,at,Xt=0,ze=0,tn=0,ht=typeof performance=="object"&&performance.now?performance:Date,ti=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Gn(){return ze||(ti(Fu),ze=ht.now()+tn)}function Fu(){ze=0}function Zt(){this._call=this._time=this._next=null}Zt.prototype=ni.prototype={constructor:Zt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Gn():+n)+(t==null?0:+t),!this._next&&at!==this&&(at?at._next=this:Yt=this,at=this),this._call=e,this._time=n,Hn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Hn())}};function ni(e,t,n){var o=new Zt;return o.restart(e,t,n),o}function Yu(){Gn(),++We;for(var e=Yt,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--We}function Oo(){ze=(Xt=ht.now())+tn,We=st=0;try{Yu()}finally{We=0,Zu(),ze=0}}function Xu(){var e=ht.now(),t=e-Xt;t>ei&&(tn-=t,Xt=e)}function Zu(){for(var e,t=Yt,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:Yt=n);at=e,Hn(o)}function Hn(e){if(!We){st&&(st=clearTimeout(st));var t=e-ze;t>24?(e<1/0&&(st=setTimeout(Oo,e-ht.now()-tn)),rt&&(rt=clearInterval(rt))):(rt||(Xt=ht.now(),rt=setInterval(Xu,ei)),We=1,ti(Oo))}}function Lo(e,t,n){var o=new Zt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Wu=Jt("start","end","cancel","interrupt"),qu=[],oi=0,Vo=1,zn=2,zt=3,Bo=4,On=5,Ot=6;function nn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Gu(e,n,{name:t,index:o,group:r,on:Wu,tween:qu,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:oi})}function Un(e,t){var n=me(e,t);if(n.state>oi)throw new Error("too late; already scheduled");return n}function ve(e,t){var n=me(e,t);if(n.state>zt)throw new Error("too late; already running");return n}function me(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Gu(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=ni(i,0,n.time);function i(a){n.state=Vo,n.timer.restart(s,n.delay,n.time),n.delay<=a&&s(a-n.delay)}function s(a){var l,f,d,g;if(n.state!==Vo)return u();for(l in o)if(g=o[l],g.name===n.name){if(g.state===zt)return Lo(s);g.state===Bo?(g.state=Ot,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete o[l]):+l<t&&(g.state=Ot,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete o[l])}if(Lo(function(){n.state===zt&&(n.state=Bo,n.timer.restart(c,n.delay,n.time),c(a))}),n.state=zn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===zn){for(n.state=zt,r=new Array(d=n.tween.length),l=0,f=-1;l<d;++l)(g=n.tween[l].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=g);r.length=f+1}}function c(a){for(var l=a<n.duration?n.ease.call(null,a/n.duration):(n.timer.restart(u),n.state=On,1),f=-1,d=r.length;++f<d;)r[f].call(e,l);n.state===On&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Ot,n.timer.stop(),delete o[t];for(var a in o)return;delete e.__transition}}function Lt(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>zn&&o.state<On,o.state=Ot,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Uu(e){return this.each(function(){Lt(this,e)})}function Ku(e,t){var n,o;return function(){var r=ve(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,c=o.length;s<c;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function Qu(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=ve(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var c={name:t,value:n},u=0,a=r.length;u<a;++u)if(r[u].name===t){r[u]=c;break}u===a&&r.push(c)}i.tween=r}}function Ju(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=me(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?Ku:Qu)(n,e,t))}function Kn(e,t,n){var o=e._id;return e.each(function(){var r=ve(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return me(r,o).value[t]}}function ri(e,t){var n;return(typeof t=="number"?ye:t instanceof He?Ft:(n=He(t))?(t=n,Ft):Kr)(e,t)}function el(e){return function(){this.removeAttribute(e)}}function tl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nl(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 ol(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 rl(e,t,n){var o,r,i;return function(){var s,c=n(this),u;return c==null?void this.removeAttribute(e):(s=this.getAttribute(e),u=c+"",s===u?null:s===o&&u===r?i:(r=u,i=t(o=s,c)))}}function il(e,t,n){var o,r,i;return function(){var s,c=n(this),u;return c==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),u=c+"",s===u?null:s===o&&u===r?i:(r=u,i=t(o=s,c)))}}function sl(e,t){var n=en(e),o=n==="transform"?Lu:ri;return this.attrTween(e,typeof t=="function"?(n.local?il:rl)(n,o,Kn(this,"attr."+e,t)):t==null?(n.local?tl:el)(n):(n.local?ol:nl)(n,o,t))}function al(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function cl(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ul(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&cl(e,i)),n}return r._value=t,r}function ll(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&al(e,i)),n}return r._value=t,r}function fl(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=en(e);return this.tween(n,(o.local?ul:ll)(o,t))}function dl(e,t){return function(){Un(this,e).delay=+t.apply(this,arguments)}}function hl(e,t){return t=+t,function(){Un(this,e).delay=t}}function gl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?dl:hl)(t,e)):me(this.node(),t).delay}function pl(e,t){return function(){ve(this,e).duration=+t.apply(this,arguments)}}function ml(e,t){return t=+t,function(){ve(this,e).duration=t}}function yl(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?pl:ml)(t,e)):me(this.node(),t).duration}function xl(e,t){if(typeof t!="function")throw new Error;return function(){ve(this,e).ease=t}}function wl(e){var t=this._id;return arguments.length?this.each(xl(t,e)):me(this.node(),t).ease}function vl(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;ve(this,e).ease=n}}function _l(e){if(typeof e!="function")throw new Error;return this.each(vl(this._id,e))}function El(e){typeof e!="function"&&(e=Dr(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,c=o[r]=[],u,a=0;a<s;++a)(u=i[a])&&e.call(u,u.__data__,a,i)&&c.push(u);return new Se(o,this._parents,this._name,this._id)}function bl(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),c=0;c<i;++c)for(var u=t[c],a=n[c],l=u.length,f=s[c]=new Array(l),d,g=0;g<l;++g)(d=u[g]||a[g])&&(f[g]=d);for(;c<o;++c)s[c]=t[c];return new Se(s,this._parents,this._name,this._id)}function Sl(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 Nl(e,t,n){var o,r,i=Sl(t)?Un:ve;return function(){var s=i(this,e),c=s.on;c!==o&&(r=(o=c).copy()).on(t,n),s.on=r}}function Cl(e,t){var n=this._id;return arguments.length<2?me(this.node(),n).on.on(e):this.each(Nl(n,e,t))}function Ml(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Il(){return this.on("end.remove",Ml(this._id))}function Al(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Xn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var c=o[s],u=c.length,a=i[s]=new Array(u),l,f,d=0;d<u;++d)(l=c[d])&&(f=e.call(l,l.__data__,d,c))&&("__data__"in l&&(f.__data__=l.__data__),a[d]=f,nn(a[d],t,n,d,a,me(l,n)));return new Se(i,this._parents,t,n)}function kl(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$r(e));for(var o=this._groups,r=o.length,i=[],s=[],c=0;c<r;++c)for(var u=o[c],a=u.length,l,f=0;f<a;++f)if(l=u[f]){for(var d=e.call(l,l.__data__,f,u),g,p=me(l,n),w=0,v=d.length;w<v;++w)(g=d[w])&&nn(g,t,n,w,d,p);i.push(d),s.push(l)}return new Se(i,s,t,n)}var Tl=wt.prototype.constructor;function Pl(){return new Tl(this._groups,this._parents)}function Rl(e,t){var n,o,r;return function(){var i=Ze(this,e),s=(this.style.removeProperty(e),Ze(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function ii(e){return function(){this.style.removeProperty(e)}}function $l(e,t,n){var o,r=n+"",i;return function(){var s=Ze(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function Dl(e,t,n){var o,r,i;return function(){var s=Ze(this,e),c=n(this),u=c+"";return c==null&&(u=c=(this.style.removeProperty(e),Ze(this,e))),s===u?null:s===o&&u===r?i:(r=u,i=t(o=s,c))}}function Hl(e,t){var n,o,r,i="style."+t,s="end."+i,c;return function(){var u=ve(this,e),a=u.on,l=u.value[i]==null?c||(c=ii(t)):void 0;(a!==n||r!==l)&&(o=(n=a).copy()).on(s,r=l),u.on=o}}function zl(e,t,n){var o=(e+="")=="transform"?Ou:ri;return t==null?this.styleTween(e,Rl(e,o)).on("end.style."+e,ii(e)):typeof t=="function"?this.styleTween(e,Dl(e,o,Kn(this,"style."+e,t))).each(Hl(this._id,e)):this.styleTween(e,$l(e,o,t),n).on("end.style."+e,null)}function Ol(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Ll(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Ol(e,s,n)),o}return i._value=t,i}function Vl(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,Ll(e,t,n??""))}function Bl(e){return function(){this.textContent=e}}function jl(e){return function(){var t=e(this);this.textContent=t??""}}function Fl(e){return this.tween("text",typeof e=="function"?jl(Kn(this,"text",e)):Bl(e==null?"":e+""))}function Yl(e){return function(t){this.textContent=e.call(this,t)}}function Xl(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Yl(r)),t}return o._value=e,o}function Zl(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,Xl(e))}function Wl(){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],c=s.length,u,a=0;a<c;++a)if(u=s[a]){var l=me(u,t);nn(u,e,n,a,s,{time:l.time+l.delay+l.duration,delay:0,duration:l.duration,ease:l.ease})}return new Se(o,this._parents,e,n)}function ql(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var c={value:s},u={value:function(){--r===0&&i()}};n.each(function(){var a=ve(this,o),l=a.on;l!==e&&(t=(e=l).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(u)),a.on=t}),r===0&&i()})}var Gl=0;function Se(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function si(){return++Gl}var Ee=wt.prototype;Se.prototype={constructor:Se,select:Al,selectAll:kl,selectChild:Ee.selectChild,selectChildren:Ee.selectChildren,filter:El,merge:bl,selection:Pl,transition:Wl,call:Ee.call,nodes:Ee.nodes,node:Ee.node,size:Ee.size,empty:Ee.empty,each:Ee.each,on:Cl,attr:sl,attrTween:fl,style:zl,styleTween:Vl,text:Fl,textTween:Zl,remove:Il,tween:Ju,delay:gl,duration:yl,ease:wl,easeVarying:_l,end:ql,[Symbol.iterator]:Ee[Symbol.iterator]};function Ul(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Kl={time:null,delay:0,duration:250,ease:Ul};function Ql(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 Jl(e){var t,n;e instanceof Se?(t=e._id,e=e._name):(t=si(),(n=Kl).time=Gn(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],c=s.length,u,a=0;a<c;++a)(u=s[a])&&nn(u,e,t,a,s,n||Ql(u,t));return new Se(o,this._parents,e,t)}wt.prototype.interrupt=Uu;wt.prototype.transition=Jl;const kt=e=>()=>e;function ef(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 be(e,t,n){this.k=e,this.x=t,this.y=n}be.prototype={constructor:be,scale:function(e){return e===1?this:new be(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new be(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 on=new be(1,0,0);ai.prototype=be.prototype;function ai(e){for(;!e.__zoom;)if(!(e=e.parentNode))return on;return e.__zoom}function _n(e){e.stopImmediatePropagation()}function it(e){e.preventDefault(),e.stopImmediatePropagation()}function tf(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function nf(){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 jo(){return this.__zoom||on}function of(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function rf(){return navigator.maxTouchPoints||"ontouchstart"in this}function sf(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 ci(){var e=tf,t=nf,n=sf,o=of,r=rf,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],c=250,u=Ht,a=Jt("start","zoom","end"),l,f,d,g=500,p=150,w=0,v=10;function y(_){_.property("__zoom",jo).on("wheel.zoom",$,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",F).filter(r).on("touchstart.zoom",T).on("touchmove.zoom",H).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(_,I,C,k){var A=_.selection?_.selection():_;A.property("__zoom",jo),_!==A?M(_,I,C,k):A.interrupt().each(function(){S(this,arguments).event(k).start().zoom(null,typeof I=="function"?I.apply(this,arguments):I).end()})},y.scaleBy=function(_,I,C,k){y.scaleTo(_,function(){var A=this.__zoom.k,P=typeof I=="function"?I.apply(this,arguments):I;return A*P},C,k)},y.scaleTo=function(_,I,C,k){y.transform(_,function(){var A=t.apply(this,arguments),P=this.__zoom,L=C==null?x(A):typeof C=="function"?C.apply(this,arguments):C,m=P.invert(L),b=typeof I=="function"?I.apply(this,arguments):I;return n(h(N(P,b),L,m),A,s)},C,k)},y.translateBy=function(_,I,C,k){y.transform(_,function(){return n(this.__zoom.translate(typeof I=="function"?I.apply(this,arguments):I,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,k)},y.translateTo=function(_,I,C,k,A){y.transform(_,function(){var P=t.apply(this,arguments),L=this.__zoom,m=k==null?x(P):typeof k=="function"?k.apply(this,arguments):k;return n(on.translate(m[0],m[1]).scale(L.k).translate(typeof I=="function"?-I.apply(this,arguments):-I,typeof C=="function"?-C.apply(this,arguments):-C),P,s)},k,A)};function N(_,I){return I=Math.max(i[0],Math.min(i[1],I)),I===_.k?_:new be(I,_.x,_.y)}function h(_,I,C){var k=I[0]-C[0]*_.k,A=I[1]-C[1]*_.k;return k===_.x&&A===_.y?_:new be(_.k,k,A)}function x(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function M(_,I,C,k){_.on("start.zoom",function(){S(this,arguments).event(k).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(k).end()}).tween("zoom",function(){var A=this,P=arguments,L=S(A,P).event(k),m=t.apply(A,P),b=C==null?x(m):typeof C=="function"?C.apply(A,P):C,B=Math.max(m[1][0]-m[0][0],m[1][1]-m[0][1]),O=A.__zoom,Y=typeof I=="function"?I.apply(A,P):I,W=u(O.invert(b).concat(B/O.k),Y.invert(b).concat(B/Y.k));return function(X){if(X===1)X=Y;else{var j=W(X),Z=B/j[2];X=new be(Z,b[0]-j[0]*Z,b[1]-j[1]*Z)}L.zoom(null,X)}})}function S(_,I,C){return!C&&_.__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=le(this.that).datum();a.call(_,this.that,new ef(_,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:a}),I)}};function $(_,...I){if(!e.apply(this,arguments))return;var C=S(this,I).event(_),k=this.__zoom,A=Math.max(i[0],Math.min(i[1],k.k*Math.pow(2,o.apply(this,arguments)))),P=de(_);if(C.wheel)(C.mouse[0][0]!==P[0]||C.mouse[0][1]!==P[1])&&(C.mouse[1]=k.invert(C.mouse[0]=P)),clearTimeout(C.wheel);else{if(k.k===A)return;C.mouse=[P,k.invert(P)],Lt(this),C.start()}it(_),C.wheel=setTimeout(L,p),C.zoom("mouse",n(h(N(k,A),C.mouse[0],C.mouse[1]),C.extent,s));function L(){C.wheel=null,C.end()}}function R(_,...I){if(d||!e.apply(this,arguments))return;var C=_.currentTarget,k=S(this,I,!0).event(_),A=le(_.view).on("mousemove.zoom",b,!0).on("mouseup.zoom",B,!0),P=de(_,C),L=_.clientX,m=_.clientY;Xr(_.view),_n(_),k.mouse=[P,this.__zoom.invert(P)],Lt(this),k.start();function b(O){if(it(O),!k.moved){var Y=O.clientX-L,W=O.clientY-m;k.moved=Y*Y+W*W>w}k.event(O).zoom("mouse",n(h(k.that.__zoom,k.mouse[0]=de(O,C),k.mouse[1]),k.extent,s))}function B(O){A.on("mousemove.zoom mouseup.zoom",null),Zr(O.view,k.moved),it(O),k.event(O).end()}}function F(_,...I){if(e.apply(this,arguments)){var C=this.__zoom,k=de(_.changedTouches?_.changedTouches[0]:_,this),A=C.invert(k),P=C.k*(_.shiftKey?.5:2),L=n(h(N(C,P),k,A),t.apply(this,I),s);it(_),c>0?le(this).transition().duration(c).call(M,L,k,_):le(this).call(y.transform,L,k,_)}}function T(_,...I){if(e.apply(this,arguments)){var C=_.touches,k=C.length,A=S(this,I,_.changedTouches.length===k).event(_),P,L,m,b;for(_n(_),L=0;L<k;++L)m=C[L],b=de(m,this),b=[b,this.__zoom.invert(b),m.identifier],A.touch0?!A.touch1&&A.touch0[2]!==b[2]&&(A.touch1=b,A.taps=0):(A.touch0=b,P=!0,A.taps=1+!!l);l&&(l=clearTimeout(l)),P&&(A.taps<2&&(f=b[0],l=setTimeout(function(){l=null},g)),Lt(this),A.start())}}function H(_,...I){if(this.__zooming){var C=S(this,I).event(_),k=_.changedTouches,A=k.length,P,L,m,b;for(it(_),P=0;P<A;++P)L=k[P],m=de(L,this),C.touch0&&C.touch0[2]===L.identifier?C.touch0[0]=m:C.touch1&&C.touch1[2]===L.identifier&&(C.touch1[0]=m);if(L=C.that.__zoom,C.touch1){var B=C.touch0[0],O=C.touch0[1],Y=C.touch1[0],W=C.touch1[1],X=(X=Y[0]-B[0])*X+(X=Y[1]-B[1])*X,j=(j=W[0]-O[0])*j+(j=W[1]-O[1])*j;L=N(L,Math.sqrt(X/j)),m=[(B[0]+Y[0])/2,(B[1]+Y[1])/2],b=[(O[0]+W[0])/2,(O[1]+W[1])/2]}else if(C.touch0)m=C.touch0[0],b=C.touch0[1];else return;C.zoom("touch",n(h(L,m,b),C.extent,s))}}function V(_,...I){if(this.__zooming){var C=S(this,I).event(_),k=_.changedTouches,A=k.length,P,L;for(_n(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},g),P=0;P<A;++P)L=k[P],C.touch0&&C.touch0[2]===L.identifier?delete C.touch0:C.touch1&&C.touch1[2]===L.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(L=de(L,this),Math.hypot(f[0]-L[0],f[1]-L[1])<v)){var m=le(this).on("dblclick.zoom");m&&m.apply(this,arguments)}}}return y.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:kt(+_),y):o},y.filter=function(_){return arguments.length?(e=typeof _=="function"?_:kt(!!_),y):e},y.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:kt(!!_),y):r},y.extent=function(_){return arguments.length?(t=typeof _=="function"?_:kt([[+_[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?(c=+_,y):c},y.interpolate=function(_){return arguments.length?(u=_,y):u},y.on=function(){var _=a.on.apply(a,arguments);return _===a?y:_},y.clickDistance=function(_){return arguments.length?(w=(_=+_)*_,y):Math.sqrt(w)},y.tapDistance=function(_){return arguments.length?(v=+_,y):v},y}const we={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle: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."},gt=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ui=["Enter"," ","Escape"],li={"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 qe;(function(e){e.Strict="strict",e.Loose="loose"})(qe||(qe={}));var De;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(De||(De={}));var pt;(function(e){e.Partial="partial",e.Full="full"})(pt||(pt={}));const fi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ae;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ae||(Ae={}));var Wt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Wt||(Wt={}));var q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(q||(q={}));const Fo={[q.Left]:q.Right,[q.Right]:q.Left,[q.Top]:q.Bottom,[q.Bottom]:q.Top};function di(e){return e===null?null:e?"valid":"invalid"}const hi=e=>"id"in e&&"source"in e&&"target"in e,af=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Qn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),_t=(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}},cf=(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):Qn(r)?r:t.nodeLookup.get(r.id));const c=s?qt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return rn(o,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return sn(n)},Et=(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=rn(n,qt(r)),o=!0)}),o?sn(n):{x:0,y:0,width:0,height:0}},Jn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const c={...St(t,[n,o,r]),width:t.width/r,height:t.height/r},u=[];for(const a of e.values()){const{measured:l,selectable:f=!0,hidden:d=!1}=a;if(s&&!f||d)continue;const g=l.width??a.width??a.initialWidth??null,p=l.height??a.height??a.initialHeight??null,w=mt(c,Ue(a)),v=(g??0)*(p??0),y=i&&w>0;(!a.internals.handleBounds||y||w>=v||a.dragging)&&u.push(a)}return u},uf=(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 lf(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function ff({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const c=lf(e,s),u=Et(c),a=eo(u,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(a,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function gi({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),c=s.parentId?n.get(s.parentId):void 0,{x:u,y:a}=c?c.internals.positionAbsolute:{x:0,y:0},l=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!c)i?.("005",we.error005());else{const g=c.measured.width,p=c.measured.height;g&&p&&(f=[[u,a],[u+g,a+p]])}else c&&Ke(s.extent)&&(f=[[s.extent[0][0]+u,s.extent[0][1]+a],[s.extent[1][0]+u,s.extent[1][1]+a]]);const d=Ke(f)?Oe(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",we.error015()),{position:{x:d.x-u+(s.measured.width??0)*l[0],y:d.y-a+(s.measured.height??0)*l[1]},positionAbsolute:d}}async function df({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const g=i.has(d.id),p=!g&&d.parentId&&s.find(w=>w.id===d.parentId);(g||p)&&s.push(d)}const c=new Set(t.map(d=>d.id)),u=o.filter(d=>d.deletable!==!1),l=uf(s,u);for(const d of u)c.has(d.id)&&!l.find(p=>p.id===d.id)&&l.push(d);if(!r)return{edges:l,nodes:s};const f=await r({nodes:s,edges:l});return typeof f=="boolean"?f?{edges:l,nodes:s}:{edges:[],nodes:[]}:f}const Ge=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Oe=(e={x:0,y:0},t,n)=>({x:Ge(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ge(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 Oe(e,[[i,s],[i+o,s+r]],t)}const Yo=(e,t,n)=>e<t?Ge(Math.abs(e-t),1,t)/t:e>n?-Ge(Math.abs(e-n),1,t)/t:0,mi=(e,t,n=15,o=40)=>{const r=Yo(e.x,o,t.width-o)*n,i=Yo(e.y,o,t.height-o)*n;return[r,i]},rn=(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)}),Ln=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),sn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ue=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:_t(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}},qt=(e,t=[0,0])=>{const{x:n,y:o}=Qn(e)?e.internals.positionAbsolute:_t(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)}},yi=(e,t)=>sn(rn(Ln(e),Ln(t))),mt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},Xo=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),hf=(e,t)=>{},bt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),St=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const c={x:(e-n)/r,y:(t-o)/r};return i?bt(c,s):c},Gt=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Be(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function gf(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Be(e,n),r=Be(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Be(e.top??e.y??0,n),r=Be(e.bottom??e.y??0,n),i=Be(e.left??e.x??0,t),s=Be(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 pf(e,t,n,o,r,i){const{x:s,y:c}=Gt(e,[t,n,o]),{x:u,y:a}=Gt({x:e.x+e.width,y:e.y+e.height},[t,n,o]),l=r-u,f=i-a;return{left:Math.floor(s),top:Math.floor(c),right:Math.floor(l),bottom:Math.floor(f)}}const eo=(e,t,n,o,r,i)=>{const s=gf(i,t,n),c=(t-s.x)/e.width,u=(n-s.y)/e.height,a=Math.min(c,u),l=Ge(a,o,r),f=e.x+e.width/2,d=e.y+e.height/2,g=t/2-f*l,p=n/2-d*l,w=pf(e,g,p,l,t,n),v={left:Math.min(w.left-s.left,0),top:Math.min(w.top-s.top,0),right:Math.min(w.right-s.right,0),bottom:Math.min(w.bottom-s.bottom,0)};return{x:g-v.left+v.right,y:p-v.top+v.bottom,zoom:l}},yt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ke(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 to(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function xi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const c=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*c[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*c[1]}return i}function Zo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function mf(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function yf(e){return{...li,...e||{}}}function ut(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=pe(e),c=St({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:u,y:a}=n?bt(c,t):c;return{xSnapped:u,ySnapped:a,...c}}const no=e=>({width:e.offsetWidth,height:e.offsetHeight}),wi=e=>e?.getRootNode?.()||window?.document,xf=["INPUT","SELECT","TEXTAREA"];function vi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:xf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const _i=e=>"clientX"in e,pe=(e,t)=>{const n=_i(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)}},Wo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const c=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(c.left-n.left)/o,y:(c.top-n.top)/o,...no(s)}})};function Ei({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:c}){const u=e*.125+r*.375+s*.375+n*.125,a=t*.125+i*.375+c*.375+o*.125,l=Math.abs(u-e),f=Math.abs(a-t);return[u,a,l,f]}function Tt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function qo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case q.Left:return[t-Tt(t-o,i),n];case q.Right:return[t+Tt(o-t,i),n];case q.Top:return[t,n-Tt(n-r,i)];case q.Bottom:return[t,n+Tt(r-n,i)]}}function bi({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:o,targetY:r,targetPosition:i=q.Top,curvature:s=.25}){const[c,u]=qo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[a,l]=qo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,g,p]=Ei({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:c,sourceControlY:u,targetControlX:a,targetControlY:l});return[`M${e},${t} C${c},${u} ${a},${l} ${o},${r}`,f,d,g,p]}function Si({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,c=o<t?o+s:o-s;return[i,c,r,s]}function wf({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,c=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+c}function vf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=rn(qt(e),qt(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 mt(s,sn(i))>0}const _f=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Ef=(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)),bf=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||_f;let r;return hi(e)?r={...e}:r={...e,id:o(e)},Ef(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Ni({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,c]=Si({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,c]}const Go={[q.Left]:{x:-1,y:0},[q.Right]:{x:1,y:0},[q.Top]:{x:0,y:-1},[q.Bottom]:{x:0,y:1}},Sf=({source:e,sourcePosition:t=q.Bottom,target:n})=>t===q.Left||t===q.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},Uo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Nf({source:e,sourcePosition:t=q.Bottom,target:n,targetPosition:o=q.Top,center:r,offset:i,stepPosition:s}){const c=Go[t],u=Go[o],a={x:e.x+c.x*i,y:e.y+c.y*i},l={x:n.x+u.x*i,y:n.y+u.y*i},f=Sf({source:a,sourcePosition:t,target:l}),d=f.x!==0?"x":"y",g=f[d];let p=[],w,v;const y={x:0,y:0},N={x:0,y:0},[,,h,x]=Si({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[d]*u[d]===-1){d==="x"?(w=r.x??a.x+(l.x-a.x)*s,v=r.y??(a.y+l.y)/2):(w=r.x??(a.x+l.x)/2,v=r.y??a.y+(l.y-a.y)*s);const S=[{x:w,y:a.y},{x:w,y:l.y}],E=[{x:a.x,y:v},{x:l.x,y:v}];c[d]===g?p=d==="x"?S:E:p=d==="x"?E:S}else{const S=[{x:a.x,y:l.y}],E=[{x:l.x,y:a.y}];if(d==="x"?p=c.x===g?E:S:p=c.y===g?S:E,t===o){const H=Math.abs(e[d]-n[d]);if(H<=i){const V=Math.min(i-1,i-H);c[d]===g?y[d]=(a[d]>e[d]?-1:1)*V:N[d]=(l[d]>n[d]?-1:1)*V}}if(t!==o){const H=d==="x"?"y":"x",V=c[d]===u[H],_=a[H]>l[H],I=a[H]<l[H];(c[d]===1&&(!V&&_||V&&I)||c[d]!==1&&(!V&&I||V&&_))&&(p=d==="x"?S:E)}const $={x:a.x+y.x,y:a.y+y.y},R={x:l.x+N.x,y:l.y+N.y},F=Math.max(Math.abs($.x-p[0].x),Math.abs(R.x-p[0].x)),T=Math.max(Math.abs($.y-p[0].y),Math.abs(R.y-p[0].y));F>=T?(w=($.x+R.x)/2,v=p[0].y):(w=p[0].x,v=($.y+R.y)/2)}return[[e,{x:a.x+y.x,y:a.y+y.y},...p,{x:l.x+N.x,y:l.y+N.y},n],w,v,h,x]}function Cf(e,t,n,o){const r=Math.min(Uo(e,t)/2,Uo(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 a=e.x<n.x?-1:1,l=e.y<n.y?1:-1;return`L ${i+r*a},${s}Q ${i},${s} ${i},${s+r*l}`}const c=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${i},${s+r*u}Q ${i},${s} ${i+r*c},${s}`}function Vn({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:o,targetY:r,targetPosition:i=q.Top,borderRadius:s=5,centerX:c,centerY:u,offset:a=20,stepPosition:l=.5}){const[f,d,g,p,w]=Nf({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:c,y:u},offset:a,stepPosition:l});return[f.reduce((y,N,h)=>{let x="";return h>0&&h<f.length-1?x=Cf(f[h-1],N,f[h+1],s):x=`${h===0?"M":"L"}${N.x} ${N.y}`,y+=x,y},""),d,g,p,w]}function Ko(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Mf(e){const{sourceNode:t,targetNode:n}=e;if(!Ko(t)||!Ko(n))return null;const o=t.internals.handleBounds||Qo(t.handles),r=n.internals.handleBounds||Qo(n.handles),i=Jo(o?.source??[],e.sourceHandle),s=Jo(e.connectionMode===qe.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",we.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=i?.position||q.Bottom,u=s?.position||q.Top,a=Le(t,i,c),l=Le(n,s,u);return{sourceX:a.x,sourceY:a.y,targetX:l.x,targetY:l.y,sourcePosition:c,targetPosition:u}}function Qo(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 Le(e,t,n=q.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:c}=t??Ne(e);if(o)return{x:r+s/2,y:i+c/2};switch(t?.position??n){case q.Top:return{x:r+s/2,y:i};case q.Right:return{x:r+s,y:i+c/2};case q.Bottom:return{x:r+s/2,y:i+c};case q.Left:return{x:r,y:i+c/2}}}function Jo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Bn(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function If(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,c)=>([c.markerStart||o,c.markerEnd||r].forEach(u=>{if(u&&typeof u=="object"){const a=Bn(u,t);i.has(a)||(s.push({id:a,color:u.color||n,...u}),i.add(a))}}),s),[]).sort((s,c)=>s.id.localeCompare(c.id))}const Ci=1e3,Af=10,oo={nodeOrigin:[0,0],nodeExtent:gt,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},kf={...oo,checkEquality:!0};function ro(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Tf(e,t,n){const o=ro(oo,n);for(const r of e.values())if(r.parentId)so(r,e,t,o);else{const i=_t(r,o.nodeOrigin),s=Ke(r.extent)?r.extent:o.nodeExtent,c=Oe(i,s,Ne(r));r.internals.positionAbsolute=c}}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 io(e){return e==="manual"}function jn(e,t,n,o={}){const r=ro(kf,o),i={i:0},s=new Map(t),c=r?.elevateNodesOnSelect&&!io(r.zIndexMode)?Ci:0;let u=e.length>0;t.clear(),n.clear();for(const a of e){let l=s.get(a.id);if(r.checkEquality&&a===l?.internals.userNode)t.set(a.id,l);else{const f=_t(a,r.nodeOrigin),d=Ke(a.extent)?a.extent:r.nodeExtent,g=Oe(f,d,Ne(a));l={...r.defaults,...a,measured:{width:a.measured?.width,height:a.measured?.height},internals:{positionAbsolute:g,handleBounds:Pf(a,l),z:Mi(a,c,r.zIndexMode),userNode:a}},t.set(a.id,l)}(l.measured===void 0||l.measured.width===void 0||l.measured.height===void 0)&&!l.hidden&&(u=!1),a.parentId&&so(l,t,n,o,i)}return u}function Rf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function so(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:c,zIndexMode:u}=ro(oo,o),a=e.parentId,l=t.get(a);if(!l){console.warn(`Parent node ${a} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Rf(e,n),r&&!l.parentId&&l.internals.rootParentIndex===void 0&&u==="auto"&&(l.internals.rootParentIndex=++r.i,l.internals.z=l.internals.z+r.i*Af),r&&l.internals.rootParentIndex!==void 0&&(r.i=l.internals.rootParentIndex);const f=i&&!io(u)?Ci:0,{x:d,y:g,z:p}=$f(e,l,s,c,f,u),{positionAbsolute:w}=e.internals,v=d!==w.x||g!==w.y;(v||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:v?{x:d,y:g}:w,z:p}})}function Mi(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return io(n)?o:o+(e.selected?t:0)}function $f(e,t,n,o,r,i){const{x:s,y:c}=t.internals.positionAbsolute,u=Ne(e),a=_t(e,n),l=Ke(e.extent)?Oe(a,e.extent,u):a;let f=Oe({x:s+l.x,y:c+l.y},o,u);e.extent==="parent"&&(f=pi(f,u,t));const d=Mi(e,r,i),g=t.internals.z??0;return{x:f.x,y:f.y,z:g>=d?g+1:d}}function ao(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const c=t.get(s.parentId);if(!c)continue;const u=i.get(s.parentId)?.expandedRect??Ue(c),a=yi(u,s.rect);i.set(s.parentId,{expandedRect:a,parent:c})}return i.size>0&&i.forEach(({expandedRect:s,parent:c},u)=>{const a=c.internals.positionAbsolute,l=Ne(c),f=c.origin??o,d=s.x<a.x?Math.round(Math.abs(a.x-s.x)):0,g=s.y<a.y?Math.round(Math.abs(a.y-s.y)):0,p=Math.max(l.width,Math.round(s.width)),w=Math.max(l.height,Math.round(s.height)),v=(p-l.width)*f[0],y=(w-l.height)*f[1];(d>0||g>0||v||y)&&(r.push({id:u,type:"position",position:{x:c.position.x-d+v,y:c.position.y-g+y}}),n.get(u)?.forEach(N=>{e.some(h=>h.id===N.id)||r.push({id:N.id,type:"position",position:{x:N.position.x+d,y:N.position.y+g}})})),(l.width<s.width||l.height<s.height||d||g)&&r.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:p+(d?f[0]*d-v:0),height:w+(g?f[1]*g-y:0)}})}),r}function Df(e,t,n,o,r,i,s){const c=o?.querySelector(".xyflow__viewport");let u=!1;if(!c)return{changes:[],updatedInternals:u};const a=[],l=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(l.transform),d=[];for(const g of e.values()){const p=t.get(g.id);if(!p)continue;if(p.hidden){t.set(p.id,{...p,internals:{...p.internals,handleBounds:void 0}}),u=!0;continue}const w=no(g.nodeElement),v=p.measured.width!==w.width||p.measured.height!==w.height;if(!!(w.width&&w.height&&(v||!p.internals.handleBounds||g.force))){const N=g.nodeElement.getBoundingClientRect(),h=Ke(p.extent)?p.extent:i;let{positionAbsolute:x}=p.internals;p.parentId&&p.extent==="parent"?x=pi(x,w,t.get(p.parentId)):h&&(x=Oe(x,h,w));const M={...p,measured:w,internals:{...p.internals,positionAbsolute:x,handleBounds:{source:Wo("source",g.nodeElement,N,f,p.id),target:Wo("target",g.nodeElement,N,f,p.id)}}};t.set(p.id,M),p.parentId&&so(M,t,n,{nodeOrigin:r,zIndexMode:s}),u=!0,v&&(a.push({id:p.id,type:"dimensions",dimensions:w}),p.expandParent&&p.parentId&&d.push({id:p.id,parentId:p.parentId,rect:Ue(M,r)}))}}if(d.length>0){const g=ao(d,t,n,r);a.push(...g)}return{changes:a,updatedInternals:u}}async function Hf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),c=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(c)}function er(e,t,n,o,r,i){let s=r;const c=o.get(s)||new Map;o.set(s,c.set(n,t)),s=`${r}-${e}`;const u=o.get(s)||new Map;if(o.set(s,u.set(n,t)),i){s=`${r}-${e}-${i}`;const a=o.get(s)||new Map;o.set(s,a.set(n,t))}}function Ii(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:c=null}=o,u={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:c},a=`${r}-${s}--${i}-${c}`,l=`${i}-${c}--${r}-${s}`;er("source",u,l,e,r,s),er("target",u,a,e,i,c),t.set(o.id,o)}}function Ai(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ai(n,t):!1}function tr(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 zf(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Ai(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const c=e.get(i);c&&r.set(i,{id:i,position:c.position||{x:0,y:0},distance:{x:n.x-c.internals.positionAbsolute.x,y:n.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return r}function En({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,c]of t){const u=n.get(s)?.internals.userNode;u&&r.push({...u,position:c.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 Of({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=bt(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Lf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,c=new Map,u=!1,a={x:0,y:0},l=null,f=!1,d=null,g=!1,p=!1,w=null;function v({noDragClassName:N,handleSelector:h,domNode:x,isSelectable:M,nodeId:S,nodeClickDistance:E=0}){d=le(x);function $({x:H,y:V}){const{nodeLookup:_,nodeExtent:I,snapGrid:C,snapToGrid:k,nodeOrigin:A,onNodeDrag:P,onSelectionDrag:L,onError:m,updateNodePositions:b}=t();i={x:H,y:V};let B=!1;const O=c.size>1,Y=O&&I?Ln(Et(c)):null,W=O&&k?Of({dragItems:c,snapGrid:C,x:H,y:V}):null;for(const[X,j]of c){if(!_.has(X))continue;let Z={x:H-j.distance.x,y:V-j.distance.y};k&&(Z=W?{x:Math.round(Z.x+W.x),y:Math.round(Z.y+W.y)}:bt(Z,C));let Q=null;if(O&&I&&!j.extent&&Y){const{positionAbsolute:K}=j.internals,te=K.x-Y.x+I[0][0],oe=K.x+j.measured.width-Y.x2+I[1][0],ne=K.y-Y.y+I[0][1],ae=K.y+j.measured.height-Y.y2+I[1][1];Q=[[te,ne],[oe,ae]]}const{position:J,positionAbsolute:G}=gi({nodeId:X,nextPosition:Z,nodeLookup:_,nodeExtent:Q||I,nodeOrigin:A,onError:m});B=B||j.position.x!==J.x||j.position.y!==J.y,j.position=J,j.internals.positionAbsolute=G}if(p=p||B,!!B&&(b(c,!0),w&&(o||P||!S&&L))){const[X,j]=En({nodeId:S,dragItems:c,nodeLookup:_});o?.(w,c,X,j),P?.(w,X,j),S||L?.(w,j)}}async function R(){if(!l)return;const{transform:H,panBy:V,autoPanSpeed:_,autoPanOnNodeDrag:I}=t();if(!I){u=!1,cancelAnimationFrame(s);return}const[C,k]=mi(a,l,_);(C!==0||k!==0)&&(i.x=(i.x??0)-C/H[2],i.y=(i.y??0)-k/H[2],await V({x:C,y:k})&&$(i)),s=requestAnimationFrame(R)}function F(H){const{nodeLookup:V,multiSelectionActive:_,nodesDraggable:I,transform:C,snapGrid:k,snapToGrid:A,selectNodesOnDrag:P,onNodeDragStart:L,onSelectionDragStart:m,unselectNodesAndEdges:b}=t();f=!0,(!P||!M)&&!_&&S&&(V.get(S)?.selected||b()),M&&P&&S&&e?.(S);const B=ut(H.sourceEvent,{transform:C,snapGrid:k,snapToGrid:A,containerBounds:l});if(i=B,c=zf(V,I,B,S),c.size>0&&(n||L||!S&&m)){const[O,Y]=En({nodeId:S,dragItems:c,nodeLookup:V});n?.(H.sourceEvent,c,O,Y),L?.(H.sourceEvent,O,Y),S||m?.(H.sourceEvent,Y)}}const T=Wr().clickDistance(E).on("start",H=>{const{domNode:V,nodeDragThreshold:_,transform:I,snapGrid:C,snapToGrid:k}=t();l=V?.getBoundingClientRect()||null,g=!1,p=!1,w=H.sourceEvent,_===0&&F(H),i=ut(H.sourceEvent,{transform:I,snapGrid:C,snapToGrid:k,containerBounds:l}),a=pe(H.sourceEvent,l)}).on("drag",H=>{const{autoPanOnNodeDrag:V,transform:_,snapGrid:I,snapToGrid:C,nodeDragThreshold:k,nodeLookup:A}=t(),P=ut(H.sourceEvent,{transform:_,snapGrid:I,snapToGrid:C,containerBounds:l});if(w=H.sourceEvent,(H.sourceEvent.type==="touchmove"&&H.sourceEvent.touches.length>1||S&&!A.has(S))&&(g=!0),!g){if(!u&&V&&f&&(u=!0,R()),!f){const L=pe(H.sourceEvent,l),m=L.x-a.x,b=L.y-a.y;Math.sqrt(m*m+b*b)>k&&F(H)}(i.x!==P.xSnapped||i.y!==P.ySnapped)&&c&&f&&(a=pe(H.sourceEvent,l),$(P))}}).on("end",H=>{if(!(!f||g)&&(u=!1,f=!1,cancelAnimationFrame(s),c.size>0)){const{nodeLookup:V,updateNodePositions:_,onNodeDragStop:I,onSelectionDragStop:C}=t();if(p&&(_(c,!1),p=!1),r||I||!S&&C){const[k,A]=En({nodeId:S,dragItems:c,nodeLookup:V,dragging:!1});r?.(H.sourceEvent,c,k,A),I?.(H.sourceEvent,k,A),S||C?.(H.sourceEvent,A)}}}).filter(H=>{const V=H.target;return!H.button&&(!N||!tr(V,`.${N}`,x))&&(!h||tr(V,h,x))});d.call(T)}function y(){d?.on(".drag",null)}return{update:v,destroy:y}}function Vf(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())mt(r,Ue(i))>0&&o.push(i);return o}const Bf=250;function jf(e,t,n,o){let r=[],i=1/0;const s=Vf(e,n,t+Bf);for(const c of s){const u=[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]];for(const a of u){if(o.nodeId===a.nodeId&&o.type===a.type&&o.id===a.id)continue;const{x:l,y:f}=Le(c,a,a.position,!0),d=Math.sqrt(Math.pow(l-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...a,x:l,y:f}],i=d):d===i&&r.push({...a,x:l,y:f}))}}if(!r.length)return null;if(r.length>1){const c=o.type==="source"?"target":"source";return r.find(u=>u.type===c)??r[0]}return r[0]}function ki(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const c=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],u=(n?c?.find(a=>a.id===n):c?.[0])??null;return u&&i?{...u,...Le(s,u,u.position,!0)}:u}function Ti(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Ff(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Pi=()=>!0;function Yf(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:c,nodeLookup:u,lib:a,autoPanOnConnect:l,flowId:f,panBy:d,cancelConnection:g,onConnectStart:p,onConnect:w,onConnectEnd:v,isValidConnection:y=Pi,onReconnectEnd:N,updateConnection:h,getTransform:x,getFromHandle:M,autoPanSpeed:S,dragThreshold:E=1,handleDomNode:$}){const R=wi(e.target);let F=0,T;const{x:H,y:V}=pe(e),_=Ti(i,$),I=c?.getBoundingClientRect();let C=!1;if(!I||!_)return;const k=ki(r,_,o,u,t);if(!k)return;let A=pe(e,I),P=!1,L=null,m=!1,b=null;function B(){if(!l||!I)return;const[J,G]=mi(A,I,S);d({x:J,y:G}),F=requestAnimationFrame(B)}const O={...k,nodeId:r,type:_,position:k.position},Y=u.get(r);let X={inProgress:!0,isValid:null,from:Le(Y,O,q.Left,!0),fromHandle:O,fromPosition:O.position,fromNode:Y,to:A,toHandle:null,toPosition:Fo[O.position],toNode:null,pointer:A};function j(){C=!0,h(X),p?.(e,{nodeId:r,handleId:o,handleType:_})}E===0&&j();function Z(J){if(!C){const{x:ae,y:Ce}=pe(J),_e=ae-H,Te=Ce-V;if(!(_e*_e+Te*Te>E*E))return;j()}if(!M()||!O){Q(J);return}const G=x();A=pe(J,I),T=jf(St(A,G,!1,[1,1]),n,u,O),P||(B(),P=!0);const K=Ri(J,{handle:T,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:y,doc:R,lib:a,flowId:f,nodeLookup:u});b=K.handleDomNode,L=K.connection,m=Ff(!!T,K.isValid);const te=u.get(r),oe=te?Le(te,O,q.Left,!0):X.from,ne={...X,from:oe,isValid:m,to:K.toHandle&&m?Gt({x:K.toHandle.x,y:K.toHandle.y},G):A,toHandle:K.toHandle,toPosition:m&&K.toHandle?K.toHandle.position:Fo[O.position],toNode:K.toHandle?u.get(K.toHandle.nodeId):null,pointer:A};h(ne),X=ne}function Q(J){if(!("touches"in J&&J.touches.length>0)){if(C){(T||b)&&L&&m&&w?.(L);const{inProgress:G,...K}=X,te={...K,toPosition:X.toHandle?X.toPosition:null};v?.(J,te),i&&N?.(J,te)}g(),cancelAnimationFrame(F),P=!1,m=!1,L=null,b=null,R.removeEventListener("mousemove",Z),R.removeEventListener("mouseup",Q),R.removeEventListener("touchmove",Z),R.removeEventListener("touchend",Q)}}R.addEventListener("mousemove",Z),R.addEventListener("mouseup",Q),R.addEventListener("touchmove",Z),R.addEventListener("touchend",Q)}function Ri(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:c,flowId:u,isValidConnection:a=Pi,nodeLookup:l}){const f=i==="target",d=t?s.querySelector(`.${c}-flow__handle[data-id="${u}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:g,y:p}=pe(e),w=s.elementFromPoint(g,p),v=w?.classList.contains(`${c}-flow__handle`)?w:d,y={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const N=Ti(void 0,v),h=v.getAttribute("data-nodeid"),x=v.getAttribute("data-handleid"),M=v.classList.contains("connectable"),S=v.classList.contains("connectableend");if(!h||!N)return y;const E={source:f?h:o,sourceHandle:f?x:r,target:f?o:h,targetHandle:f?r:x};y.connection=E;const R=M&&S&&(n===qe.Strict?f&&N==="source"||!f&&N==="target":h!==o||x!==r);y.isValid=R&&a(E),y.toHandle=ki(h,N,x,l,n,!0)}return y}const Fn={onPointerDown:Yf,isValid:Ri};function Xf({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=le(e);function i({translateExtent:c,width:u,height:a,zoomStep:l=1,pannable:f=!0,zoomable:d=!0,inversePan:g=!1}){const p=h=>{if(h.sourceEvent.type!=="wheel"||!t)return;const x=n(),M=h.sourceEvent.ctrlKey&&yt()?10:1,S=-h.sourceEvent.deltaY*(h.sourceEvent.deltaMode===1?.05:h.sourceEvent.deltaMode?1:.002)*l,E=x[2]*Math.pow(2,S*M);t.scaleTo(E)};let w=[0,0];const v=h=>{(h.sourceEvent.type==="mousedown"||h.sourceEvent.type==="touchstart")&&(w=[h.sourceEvent.clientX??h.sourceEvent.touches[0].clientX,h.sourceEvent.clientY??h.sourceEvent.touches[0].clientY])},y=h=>{const x=n();if(h.sourceEvent.type!=="mousemove"&&h.sourceEvent.type!=="touchmove"||!t)return;const M=[h.sourceEvent.clientX??h.sourceEvent.touches[0].clientX,h.sourceEvent.clientY??h.sourceEvent.touches[0].clientY],S=[M[0]-w[0],M[1]-w[1]];w=M;const E=o()*Math.max(x[2],Math.log(x[2]))*(g?-1:1),$={x:x[0]-S[0]*E,y:x[1]-S[1]*E},R=[[0,0],[u,a]];t.setViewportConstrained({x:$.x,y:$.y,zoom:x[2]},R,c)},N=ci().on("start",v).on("zoom",f?y:null).on("zoom.wheel",d?p:null);r.call(N,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:de}}const an=e=>({x:e.x,y:e.y,zoom:e.k}),bn=({x:e,y:t,zoom:n})=>on.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),$i=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Zf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Sn=(e,t=0,n=Zf,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Di=e=>{const t=e.ctrlKey&&yt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Wf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:c,onPanZoom:u,onPanZoomEnd:a}){return l=>{if(je(l,t))return l.ctrlKey&&l.preventDefault(),!1;l.preventDefault(),l.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(l.ctrlKey&&s){const v=de(l),y=Di(l),N=f*Math.pow(2,y);o.scaleTo(n,N,v,l);return}const d=l.deltaMode===1?20:1;let g=r===De.Vertical?0:l.deltaX*d,p=r===De.Horizontal?0:l.deltaY*d;!yt()&&l.shiftKey&&r!==De.Vertical&&(g=l.deltaY*d,p=0),o.translateBy(n,-(g/f)*i,-(p/f)*i,{internal:!0});const w=an(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u?.(l,w),e.panScrollTimeout=setTimeout(()=>{a?.(l,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c?.(l,w))}}function qf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,c=je(o,e);if(o.ctrlKey&&i&&c&&o.preventDefault(),s||c)return null;o.preventDefault(),n.call(this,o,r)}}function Gf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=an(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 Uf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&$i(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,an(i.transform))}}function Kf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&$i(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const c=an(s.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,c)},n?150:0)}}}function Qf({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:c,noPanClassName:u,lib:a,connectionInProgress:l}){return f=>{const d=e||t,g=n&&f.ctrlKey,p=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(je(f,`${a}-flow__node`)||je(f,`${a}-flow__edge`)))return!0;if(!o&&!d&&!r&&!i&&!n||s||l&&!p||je(f,c)&&p||je(f,u)&&(!p||r&&p&&!e)||!n&&f.ctrlKey&&p)return!1;if(!n&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!d&&!r&&!g&&p||!o&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(o)&&!o.includes(f.button)&&f.type==="mousedown")return!1;const w=Array.isArray(o)&&o.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||p)&&w}}function Jf({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:c,onDraggingChange:u}){const a={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},l=e.getBoundingClientRect(),f=ci().scaleExtent([t,n]).translateExtent(o),d=le(e).call(f);N({x:r.x,y:r.y,zoom:Ge(r.zoom,t,n)},[[0,0],[l.width,l.height]],o);const g=d.on("wheel.zoom"),p=d.on("dblclick.zoom");f.wheelDelta(Di);function w(T,H){return d?new Promise(V=>{f?.interpolate(H?.interpolate==="linear"?ct:Ht).transform(Sn(d,H?.duration,H?.ease,()=>V(!0)),T)}):Promise.resolve(!1)}function v({noWheelClassName:T,noPanClassName:H,onPaneContextMenu:V,userSelectionActive:_,panOnScroll:I,panOnDrag:C,panOnScrollMode:k,panOnScrollSpeed:A,preventScrolling:P,zoomOnPinch:L,zoomOnScroll:m,zoomOnDoubleClick:b,zoomActivationKeyPressed:B,lib:O,onTransformChange:Y,connectionInProgress:W,paneClickDistance:X,selectionOnDrag:j}){_&&!a.isZoomingOrPanning&&y();const Z=I&&!B&&!_;f.clickDistance(j?1/0:!ge(X)||X<0?0:X);const Q=Z?Wf({zoomPanValues:a,noWheelClassName:T,d3Selection:d,d3Zoom:f,panOnScrollMode:k,panOnScrollSpeed:A,zoomOnPinch:L,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:c}):qf({noWheelClassName:T,preventScrolling:P,d3ZoomHandler:g});if(d.on("wheel.zoom",Q,{passive:!1}),!_){const G=Gf({zoomPanValues:a,onDraggingChange:u,onPanZoomStart:s});f.on("start",G);const K=Uf({zoomPanValues:a,panOnDrag:C,onPaneContextMenu:!!V,onPanZoom:i,onTransformChange:Y});f.on("zoom",K);const te=Kf({zoomPanValues:a,panOnDrag:C,panOnScroll:I,onPaneContextMenu:V,onPanZoomEnd:c,onDraggingChange:u});f.on("end",te)}const J=Qf({zoomActivationKeyPressed:B,panOnDrag:C,zoomOnScroll:m,panOnScroll:I,zoomOnDoubleClick:b,zoomOnPinch:L,userSelectionActive:_,noPanClassName:H,noWheelClassName:T,lib:O,connectionInProgress:W});f.filter(J),b?d.on("dblclick.zoom",p):d.on("dblclick.zoom",null)}function y(){f.on("zoom",null)}async function N(T,H,V){const _=bn(T),I=f?.constrain()(_,H,V);return I&&await w(I),new Promise(C=>C(I))}async function h(T,H){const V=bn(T);return await w(V,H),new Promise(_=>_(V))}function x(T){if(d){const H=bn(T),V=d.property("__zoom");(V.k!==T.zoom||V.x!==T.x||V.y!==T.y)&&f?.transform(d,H,null,{sync:!0})}}function M(){const T=d?ai(d.node()):{x:0,y:0,k:1};return{x:T.x,y:T.y,zoom:T.k}}function S(T,H){return d?new Promise(V=>{f?.interpolate(H?.interpolate==="linear"?ct:Ht).scaleTo(Sn(d,H?.duration,H?.ease,()=>V(!0)),T)}):Promise.resolve(!1)}function E(T,H){return d?new Promise(V=>{f?.interpolate(H?.interpolate==="linear"?ct:Ht).scaleBy(Sn(d,H?.duration,H?.ease,()=>V(!0)),T)}):Promise.resolve(!1)}function $(T){f?.scaleExtent(T)}function R(T){f?.translateExtent(T)}function F(T){const H=!ge(T)||T<0?0:T;f?.clickDistance(H)}return{update:v,destroy:y,setViewport:h,setViewportConstrained:N,getViewport:M,scaleTo:S,scaleBy:E,setScaleExtent:$,setTranslateExtent:R,syncViewport:x,setClickDistance:F}}var Qe;(function(e){e.Line="line",e.Handle="handle"})(Qe||(Qe={}));function ed({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,c=n-o,u=[s>0?1:s<0?-1:0,c>0?1:c<0?-1:0];return s&&r&&(u[0]=u[0]*-1),c&&i&&(u[1]=u[1]*-1),u}function nr(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 Me(e,t){return Math.max(0,t-e)}function Ie(e,t){return Math.max(0,e-t)}function Pt(e,t,n){return Math.max(0,t-e,e-n)}function or(e,t){return e?!t:t}function td(e,t,n,o,r,i,s,c){let{affectsX:u,affectsY:a}=t;const{isHorizontal:l,isVertical:f}=t,d=l&&f,{xSnapped:g,ySnapped:p}=n,{minWidth:w,maxWidth:v,minHeight:y,maxHeight:N}=o,{x:h,y:x,width:M,height:S,aspectRatio:E}=e;let $=Math.floor(l?g-e.pointerX:0),R=Math.floor(f?p-e.pointerY:0);const F=M+(u?-$:$),T=S+(a?-R:R),H=-i[0]*M,V=-i[1]*S;let _=Pt(F,w,v),I=Pt(T,y,N);if(s){let A=0,P=0;u&&$<0?A=Me(h+$+H,s[0][0]):!u&&$>0&&(A=Ie(h+F+H,s[1][0])),a&&R<0?P=Me(x+R+V,s[0][1]):!a&&R>0&&(P=Ie(x+T+V,s[1][1])),_=Math.max(_,A),I=Math.max(I,P)}if(c){let A=0,P=0;u&&$>0?A=Ie(h+$,c[0][0]):!u&&$<0&&(A=Me(h+F,c[1][0])),a&&R>0?P=Ie(x+R,c[0][1]):!a&&R<0&&(P=Me(x+T,c[1][1])),_=Math.max(_,A),I=Math.max(I,P)}if(r){if(l){const A=Pt(F/E,y,N)*E;if(_=Math.max(_,A),s){let P=0;!u&&!a||u&&!a&&d?P=Ie(x+V+F/E,s[1][1])*E:P=Me(x+V+(u?$:-$)/E,s[0][1])*E,_=Math.max(_,P)}if(c){let P=0;!u&&!a||u&&!a&&d?P=Me(x+F/E,c[1][1])*E:P=Ie(x+(u?$:-$)/E,c[0][1])*E,_=Math.max(_,P)}}if(f){const A=Pt(T*E,w,v)/E;if(I=Math.max(I,A),s){let P=0;!u&&!a||a&&!u&&d?P=Ie(h+T*E+H,s[1][0])/E:P=Me(h+(a?R:-R)*E+H,s[0][0])/E,I=Math.max(I,P)}if(c){let P=0;!u&&!a||a&&!u&&d?P=Me(h+T*E,c[1][0])/E:P=Ie(h+(a?R:-R)*E,c[0][0])/E,I=Math.max(I,P)}}}R=R+(R<0?I:-I),$=$+($<0?_:-_),r&&(d?F>T*E?R=(or(u,a)?-$:$)/E:$=(or(u,a)?-R:R)*E:l?(R=$/E,a=u):($=R*E,u=a));const C=u?h+$:h,k=a?x+R:x;return{width:M+(u?-$:$),height:S+(a?-R:R),x:i[0]*$*(u?-1:1)+C,y:i[1]*R*(a?-1:1)+k}}const Hi={width:0,height:0,x:0,y:0},nd={...Hi,pointerX:0,pointerY:0,aspectRatio:1};function od(e){return[[0,0],[e.measured.width,e.measured.height]]}function rd(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,c=n[0]*i,u=n[1]*s;return[[o-c,r-u],[o+i-c,r+s-u]]}function id({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:nr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:a,boundaries:l,keepAspectRatio:f,resizeDirection:d,onResizeStart:g,onResize:p,onResizeEnd:w,shouldResize:v}){let y={...Hi},N={...nd};s={boundaries:l,resizeDirection:d,keepAspectRatio:f,controlDirection:nr(a)};let h,x=null,M=[],S,E,$,R=!1;const F=Wr().on("start",T=>{const{nodeLookup:H,transform:V,snapGrid:_,snapToGrid:I,nodeOrigin:C,paneDomNode:k}=n();if(h=H.get(t),!h)return;x=k?.getBoundingClientRect()??null;const{xSnapped:A,ySnapped:P}=ut(T.sourceEvent,{transform:V,snapGrid:_,snapToGrid:I,containerBounds:x});y={width:h.measured.width??0,height:h.measured.height??0,x:h.position.x??0,y:h.position.y??0},N={...y,pointerX:A,pointerY:P,aspectRatio:y.width/y.height},S=void 0,h.parentId&&(h.extent==="parent"||h.expandParent)&&(S=H.get(h.parentId),E=S&&h.extent==="parent"?od(S):void 0),M=[],$=void 0;for(const[L,m]of H)if(m.parentId===t&&(M.push({id:L,position:{...m.position},extent:m.extent}),m.extent==="parent"||m.expandParent)){const b=rd(m,h,m.origin??C);$?$=[[Math.min(b[0][0],$[0][0]),Math.min(b[0][1],$[0][1])],[Math.max(b[1][0],$[1][0]),Math.max(b[1][1],$[1][1])]]:$=b}g?.(T,{...y})}).on("drag",T=>{const{transform:H,snapGrid:V,snapToGrid:_,nodeOrigin:I}=n(),C=ut(T.sourceEvent,{transform:H,snapGrid:V,snapToGrid:_,containerBounds:x}),k=[];if(!h)return;const{x:A,y:P,width:L,height:m}=y,b={},B=h.origin??I,{width:O,height:Y,x:W,y:X}=td(N,s.controlDirection,C,s.boundaries,s.keepAspectRatio,B,E,$),j=O!==L,Z=Y!==m,Q=W!==A&&j,J=X!==P&&Z;if(!Q&&!J&&!j&&!Z)return;if((Q||J||B[0]===1||B[1]===1)&&(b.x=Q?W:y.x,b.y=J?X:y.y,y.x=b.x,y.y=b.y,M.length>0)){const oe=W-A,ne=X-P;for(const ae of M)ae.position={x:ae.position.x-oe+B[0]*(O-L),y:ae.position.y-ne+B[1]*(Y-m)},k.push(ae)}if((j||Z)&&(b.width=j&&(!s.resizeDirection||s.resizeDirection==="horizontal")?O:y.width,b.height=Z&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:y.height,y.width=b.width,y.height=b.height),S&&h.expandParent){const oe=B[0]*(b.width??0);b.x&&b.x<oe&&(y.x=oe,N.x=N.x-(b.x-oe));const ne=B[1]*(b.height??0);b.y&&b.y<ne&&(y.y=ne,N.y=N.y-(b.y-ne))}const G=ed({width:y.width,prevWidth:L,height:y.height,prevHeight:m,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),K={...y,direction:G};v?.(T,K)!==!1&&(R=!0,p?.(T,K),o(b,k))}).on("end",T=>{R&&(w?.(T,{...y}),r?.({...y}),R=!1)});i.call(F)}function u(){i.on(".drag",null)}return{update:c,destroy:u}}var Nn={exports:{}},Cn={},Mn={exports:{}},In={};var rr;function sd(){if(rr)return In;rr=1;var e=Qt();function t(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function c(f,d){var g=d(),p=o({inst:{value:g,getSnapshot:d}}),w=p[0].inst,v=p[1];return i(function(){w.value=g,w.getSnapshot=d,u(w)&&v({inst:w})},[f,g,d]),r(function(){return u(w)&&v({inst:w}),f(function(){u(w)&&v({inst:w})})},[f]),s(g),g}function u(f){var d=f.getSnapshot;f=f.value;try{var g=d();return!n(f,g)}catch{return!0}}function a(f,d){return d()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?a:c;return In.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:l,In}var ir;function ad(){return ir||(ir=1,Mn.exports=sd()),Mn.exports}var sr;function cd(){if(sr)return Cn;sr=1;var e=Qt(),t=ad();function n(a,l){return a===l&&(a!==0||1/a===1/l)||a!==a&&l!==l}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,c=e.useMemo,u=e.useDebugValue;return Cn.useSyncExternalStoreWithSelector=function(a,l,f,d,g){var p=i(null);if(p.current===null){var w={hasValue:!1,value:null};p.current=w}else w=p.current;p=c(function(){function y(S){if(!N){if(N=!0,h=S,S=d(S),g!==void 0&&w.hasValue){var E=w.value;if(g(E,S))return x=E}return x=S}if(E=x,o(h,S))return E;var $=d(S);return g!==void 0&&g(E,$)?(h=S,E):(h=S,x=$)}var N=!1,h,x,M=f===void 0?null:f;return[function(){return y(l())},M===null?void 0:function(){return y(M())}]},[l,f,d,g]);var v=r(a,p[0],p[1]);return s(function(){w.hasValue=!0,w.value=v},[v]),u(v),v},Cn}var ar;function ud(){return ar||(ar=1,Nn.exports=cd()),Nn.exports}var ld=ud();const fd=Pr(ld),dd={},cr=e=>{let t;const n=new Set,o=(l,f)=>{const d=typeof l=="function"?l(t):l;if(!Object.is(d,t)){const g=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(p=>p(t,g))}},r=()=>t,u={setState:o,getState:r,getInitialState:()=>a,subscribe:l=>(n.add(l),()=>n.delete(l)),destroy:()=>{(dd?"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()}},a=t=e(o,r,u);return u},hd=e=>e?cr(e):cr,{useDebugValue:gd}=Sa,{useSyncExternalStoreWithSelector:pd}=fd,md=e=>e;function zi(e,t=md,n){const o=pd(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return gd(o),o}const ur=(e,t)=>{const n=hd(e),o=(r,i=t)=>zi(n,r,i);return Object.assign(o,n),o},yd=(e,t)=>e?ur(e,t):ur;function re(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[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}Ca();const cn=z.createContext(null),xd=cn.Provider,Oi=we.error001();function ee(e,t){const n=z.useContext(cn);if(n===null)throw new Error(Oi);return zi(n,e,t)}function ie(){const e=z.useContext(cn);if(e===null)throw new Error(Oi);return z.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const lr={display:"none"},wd={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Li="react-flow__node-desc",Vi="react-flow__edge-desc",vd="react-flow__aria-live",_d=e=>e.ariaLiveMessage,Ed=e=>e.ariaLabelConfig;function bd({rfId:e}){const t=ee(_d);return D.jsx("div",{id:`${vd}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:wd,children:t})}function Sd({rfId:e,disableKeyboardA11y:t}){const n=ee(Ed);return D.jsxs(D.Fragment,{children:[D.jsx("div",{id:`${Li}-${e}`,style:lr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),D.jsx("div",{id:`${Vi}-${e}`,style:lr,children:n["edge.a11yDescription.default"]}),!t&&D.jsx(bd,{rfId:e})]})}const un=z.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return D.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});un.displayName="Panel";function Nd({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:D.jsx(un,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:D.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Cd=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}},Rt=e=>e.id;function Md(e,t){return re(e.selectedNodes.map(Rt),t.selectedNodes.map(Rt))&&re(e.selectedEdges.map(Rt),t.selectedEdges.map(Rt))}function Id({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=ee(Cd,Md);return z.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Ad=e=>!!e.onSelectionChangeHandlers;function kd({onSelectionChange:e}){const t=ee(Ad);return e||t?D.jsx(Id,{onSelectionChange:e}):null}const Bi=[0,0],Td={x:0,y:0,zoom:1},Pd=["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"],fr=[...Pd,"rfId"],Rd=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}),dr={translateExtent:gt,nodeOrigin:Bi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function $d(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:c,setDefaultNodesAndEdges:u}=ee(Rd,re),a=ie();z.useEffect(()=>(u(e.defaultNodes,e.defaultEdges),()=>{l.current=dr,c()}),[]);const l=z.useRef(dr);return z.useEffect(()=>{for(const f of fr){const d=e[f],g=l.current[f];d!==g&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?a.setState({ariaLabelConfig:yf(d)}):f==="fitView"?a.setState({fitViewQueued:d}):f==="fitViewOptions"?a.setState({fitViewOptions:d}):a.setState({[f]:d})))}l.current=e},fr.map(f=>e[f])),null}function hr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Dd(e){const[t,n]=z.useState(e==="system"?null:e);return z.useEffect(()=>{if(e!=="system"){n(e);return}const o=hr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:hr()?.matches?"dark":"light"}const gr=typeof document<"u"?document:null;function xt(e=null,t={target:gr,actInsideInputWithModifier:!0}){const[n,o]=z.useState(!1),r=z.useRef(!1),i=z.useRef(new Set([])),[s,c]=z.useMemo(()=>{if(e!==null){const a=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
|
|
2
|
+
`).replace(`
|
|
3
|
+
|
|
4
|
+
`,`
|
|
5
|
+
+`).split(`
|
|
6
|
+
`)),l=a.reduce((f,d)=>f.concat(...d),[]);return[a,l]}return[[],[]]},[e]);return z.useEffect(()=>{const u=t?.target??gr,a=t?.actInsideInputWithModifier??!0;if(e!==null){const l=g=>{if(r.current=g.ctrlKey||g.metaKey||g.shiftKey||g.altKey,(!r.current||r.current&&!a)&&vi(g))return!1;const w=mr(g.code,c);if(i.current.add(g[w]),pr(s,i.current,!1)){const v=g.composedPath?.()?.[0]||g.target,y=v?.nodeName==="BUTTON"||v?.nodeName==="A";t.preventDefault!==!1&&(r.current||!y)&&g.preventDefault(),o(!0)}},f=g=>{const p=mr(g.code,c);pr(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(g[p]),g.key==="Meta"&&i.current.clear(),r.current=!1},d=()=>{i.current.clear(),o(!1)};return u?.addEventListener("keydown",l),u?.addEventListener("keyup",f),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{u?.removeEventListener("keydown",l),u?.removeEventListener("keyup",f),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,o]),n}function pr(e,t,n){return e.filter(o=>n||o.length===t.size).some(o=>o.every(r=>t.has(r)))}function mr(e,t){return t.includes(e)?"code":"key"}const Hd=()=>{const e=ie();return z.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:o}=e.getState();return o?o.scaleTo(t,{duration:n?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[o,r,i],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??o,y:t.y??r,zoom:t.zoom??i},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},setCenter:async(t,n,o)=>e.getState().setCenter(t,n,o),fitBounds:async(t,n)=>{const{width:o,height:r,minZoom:i,maxZoom:s,panZoom:c}=e.getState(),u=eo(t,o,r,i,s,n?.padding??.1);return c?(await c.setViewport(u,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:o,snapGrid:r,snapToGrid:i,domNode:s}=e.getState();if(!s)return t;const{x:c,y:u}=s.getBoundingClientRect(),a={x:t.x-c,y:t.y-u},l=n.snapGrid??r,f=n.snapToGrid??i;return St(a,o,f,l)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:i}=o.getBoundingClientRect(),s=Gt(t,n);return{x:s.x+r,y:s.y+i}}}),[])};function ji(e,t){const n=[],o=new Map,r=[];for(const i of e)if(i.type==="add"){r.push(i);continue}else if(i.type==="remove"||i.type==="replace")o.set(i.id,[i]);else{const s=o.get(i.id);s?s.push(i):o.set(i.id,[i])}for(const i of t){const s=o.get(i.id);if(!s){n.push(i);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){n.push({...s[0].item});continue}const c={...i};for(const u of s)zd(u,c);n.push(c)}return r.length&&r.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function zd(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Fi(e,t){return ji(e,t)}function Yi(e,t){return ji(e,t)}function Pe(e,t){return{id:e,type:"select",selected:t}}function Fe(e,t=new Set,n=!1){const o=[];for(const[r,i]of e){const s=t.has(r);!(i.selected===void 0&&!s)&&i.selected!==s&&(n&&(i.selected=s),o.push(Pe(i.id,s)))}return o}function yr({items:e=[],lookup:t}){const n=[],o=new Map(e.map(r=>[r.id,r]));for(const[r,i]of e.entries()){const s=t.get(i.id),c=s?.internals?.userNode??s;c!==void 0&&c!==i&&n.push({id:i.id,item:i,type:"replace"}),c===void 0&&n.push({item:i,type:"add",index:r})}for(const[r]of t)o.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function xr(e){return{id:e.id,type:"remove"}}const wr=e=>af(e),Od=e=>hi(e);function Xi(e){return z.forwardRef(e)}const Ld=typeof window<"u"?z.useLayoutEffect:z.useEffect;function vr(e){const[t,n]=z.useState(BigInt(0)),[o]=z.useState(()=>Vd(()=>n(r=>r+BigInt(1))));return Ld(()=>{const r=o.get();r.length&&(e(r),o.reset())},[t]),o}function Vd(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Zi=z.createContext(null);function Bd({children:e}){const t=ie(),n=z.useCallback(c=>{const{nodes:u=[],setNodes:a,hasDefaultNodes:l,onNodesChange:f,nodeLookup:d,fitViewQueued:g,onNodesChangeMiddlewareMap:p}=t.getState();let w=u;for(const y of c)w=typeof y=="function"?y(w):y;let v=yr({items:w,lookup:d});for(const y of p.values())v=y(v);l&&a(w),v.length>0?f?.(v):g&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:N,setNodes:h}=t.getState();y&&h(N)})},[]),o=vr(n),r=z.useCallback(c=>{const{edges:u=[],setEdges:a,hasDefaultEdges:l,onEdgesChange:f,edgeLookup:d}=t.getState();let g=u;for(const p of c)g=typeof p=="function"?p(g):p;l?a(g):f&&f(yr({items:g,lookup:d}))},[]),i=vr(r),s=z.useMemo(()=>({nodeQueue:o,edgeQueue:i}),[]);return D.jsx(Zi.Provider,{value:s,children:e})}function jd(){const e=z.useContext(Zi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Fd=e=>!!e.panZoom;function co(){const e=Hd(),t=ie(),n=jd(),o=ee(Fd),r=z.useMemo(()=>{const i=f=>t.getState().nodeLookup.get(f),s=f=>{n.nodeQueue.push(f)},c=f=>{n.edgeQueue.push(f)},u=f=>{const{nodeLookup:d,nodeOrigin:g}=t.getState(),p=wr(f)?f:d.get(f.id),w=p.parentId?xi(p.position,p.measured,p.parentId,d,g):p.position,v={...p,position:w,width:p.measured?.width??p.width,height:p.measured?.height??p.height};return Ue(v)},a=(f,d,g={replace:!1})=>{s(p=>p.map(w=>{if(w.id===f){const v=typeof d=="function"?d(w):d;return g.replace&&wr(v)?v:{...w,...v}}return w}))},l=(f,d,g={replace:!1})=>{c(p=>p.map(w=>{if(w.id===f){const v=typeof d=="function"?d(w):d;return g.replace&&Od(v)?v:{...w,...v}}return w}))};return{getNodes:()=>t.getState().nodes.map(f=>({...f})),getNode:f=>i(f)?.internals.userNode,getInternalNode:i,getEdges:()=>{const{edges:f=[]}=t.getState();return f.map(d=>({...d}))},getEdge:f=>t.getState().edgeLookup.get(f),setNodes:s,setEdges:c,addNodes:f=>{const d=Array.isArray(f)?f:[f];n.nodeQueue.push(g=>[...g,...d])},addEdges:f=>{const d=Array.isArray(f)?f:[f];n.edgeQueue.push(g=>[...g,...d])},toObject:()=>{const{nodes:f=[],edges:d=[],transform:g}=t.getState(),[p,w,v]=g;return{nodes:f.map(y=>({...y})),edges:d.map(y=>({...y})),viewport:{x:p,y:w,zoom:v}}},deleteElements:async({nodes:f=[],edges:d=[]})=>{const{nodes:g,edges:p,onNodesDelete:w,onEdgesDelete:v,triggerNodeChanges:y,triggerEdgeChanges:N,onDelete:h,onBeforeDelete:x}=t.getState(),{nodes:M,edges:S}=await df({nodesToRemove:f,edgesToRemove:d,nodes:g,edges:p,onBeforeDelete:x}),E=S.length>0,$=M.length>0;if(E){const R=S.map(xr);v?.(S),N(R)}if($){const R=M.map(xr);w?.(M),y(R)}return($||E)&&h?.({nodes:M,edges:S}),{deletedNodes:M,deletedEdges:S}},getIntersectingNodes:(f,d=!0,g)=>{const p=Xo(f),w=p?f:u(f),v=g!==void 0;return w?(g||t.getState().nodes).filter(y=>{const N=t.getState().nodeLookup.get(y.id);if(N&&!p&&(y.id===f.id||!N.internals.positionAbsolute))return!1;const h=Ue(v?y:N),x=mt(h,w);return d&&x>0||x>=h.width*h.height||x>=w.width*w.height}):[]},isNodeIntersecting:(f,d,g=!0)=>{const w=Xo(f)?f:u(f);if(!w)return!1;const v=mt(w,d);return g&&v>0||v>=d.width*d.height||v>=w.width*w.height},updateNode:a,updateNodeData:(f,d,g={replace:!1})=>{a(f,p=>{const w=typeof d=="function"?d(p):d;return g.replace?{...p,data:w}:{...p,data:{...p.data,...w}}},g)},updateEdge:l,updateEdgeData:(f,d,g={replace:!1})=>{l(f,p=>{const w=typeof d=="function"?d(p):d;return g.replace?{...p,data:w}:{...p,data:{...p.data,...w}}},g)},getNodesBounds:f=>{const{nodeLookup:d,nodeOrigin:g}=t.getState();return cf(f,{nodeLookup:d,nodeOrigin:g})},getHandleConnections:({type:f,id:d,nodeId:g})=>Array.from(t.getState().connectionLookup.get(`${g}-${f}${d?`-${d}`:""}`)?.values()??[]),getNodeConnections:({type:f,handleId:d,nodeId:g})=>Array.from(t.getState().connectionLookup.get(`${g}${f?d?`-${f}-${d}`:`-${f}`:""}`)?.values()??[]),fitView:async f=>{const d=t.getState().fitViewResolver??mf();return t.setState({fitViewQueued:!0,fitViewOptions:f,fitViewResolver:d}),n.nodeQueue.push(g=>[...g]),d.promise}}},[]);return z.useMemo(()=>({...r,...e,viewportInitialized:o}),[o])}const _r=e=>e.selected,Yd=typeof window<"u"?window:void 0;function Xd({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ie(),{deleteElements:o}=co(),r=xt(e,{actInsideInputWithModifier:!1}),i=xt(t,{target:Yd});z.useEffect(()=>{if(r){const{edges:s,nodes:c}=n.getState();o({nodes:c.filter(_r),edges:s.filter(_r)}),n.setState({nodesSelectionActive:!1})}},[r]),z.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function Zd(e){const t=ie();z.useEffect(()=>{const n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;const o=no(e.current);(o.height===0||o.width===0)&&t.getState().onError?.("004",we.error004()),t.setState({width:o.width||500,height:o.height||500})};if(e.current){n(),window.addEventListener("resize",n);const o=new ResizeObserver(()=>n());return o.observe(e.current),()=>{window.removeEventListener("resize",n),o&&e.current&&o.unobserve(e.current)}}},[])}const ln={position:"absolute",width:"100%",height:"100%",top:0,left:0},Wd=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function qd({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:o=!1,panOnScrollSpeed:r=.5,panOnScrollMode:i=De.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:u,translateExtent:a,minZoom:l,maxZoom:f,zoomActivationKeyCode:d,preventScrolling:g=!0,children:p,noWheelClassName:w,noPanClassName:v,onViewportChange:y,isControlledViewport:N,paneClickDistance:h,selectionOnDrag:x}){const M=ie(),S=z.useRef(null),{userSelectionActive:E,lib:$,connectionInProgress:R}=ee(Wd,re),F=xt(d),T=z.useRef();Zd(S);const H=z.useCallback(V=>{y?.({x:V[0],y:V[1],zoom:V[2]}),N||M.setState({transform:V})},[y,N]);return z.useEffect(()=>{if(S.current){T.current=Jf({domNode:S.current,minZoom:l,maxZoom:f,translateExtent:a,viewport:u,onDraggingChange:C=>M.setState(k=>k.paneDragging===C?k:{paneDragging:C}),onPanZoomStart:(C,k)=>{const{onViewportChangeStart:A,onMoveStart:P}=M.getState();P?.(C,k),A?.(k)},onPanZoom:(C,k)=>{const{onViewportChange:A,onMove:P}=M.getState();P?.(C,k),A?.(k)},onPanZoomEnd:(C,k)=>{const{onViewportChangeEnd:A,onMoveEnd:P}=M.getState();P?.(C,k),A?.(k)}});const{x:V,y:_,zoom:I}=T.current.getViewport();return M.setState({panZoom:T.current,transform:[V,_,I],domNode:S.current.closest(".react-flow")}),()=>{T.current?.destroy()}}},[]),z.useEffect(()=>{T.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:o,panOnScrollSpeed:r,panOnScrollMode:i,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:F,preventScrolling:g,noPanClassName:v,userSelectionActive:E,noWheelClassName:w,lib:$,onTransformChange:H,connectionInProgress:R,selectionOnDrag:x,paneClickDistance:h})},[e,t,n,o,r,i,s,c,F,g,v,E,w,$,H,R,x,h]),D.jsx("div",{className:"react-flow__renderer",ref:S,style:ln,children:p})}const Gd=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Ud(){const{userSelectionActive:e,userSelectionRect:t}=ee(Gd,re);return e&&t?D.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const An=(e,t)=>n=>{n.target===t.current&&e?.(n)},Kd=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Qd({isSelecting:e,selectionKeyPressed:t,selectionMode:n=pt.Full,panOnDrag:o,paneClickDistance:r,selectionOnDrag:i,onSelectionStart:s,onSelectionEnd:c,onPaneClick:u,onPaneContextMenu:a,onPaneScroll:l,onPaneMouseEnter:f,onPaneMouseMove:d,onPaneMouseLeave:g,children:p}){const w=ie(),{userSelectionActive:v,elementsSelectable:y,dragging:N,connectionInProgress:h}=ee(Kd,re),x=y&&(e||v),M=z.useRef(null),S=z.useRef(),E=z.useRef(new Set),$=z.useRef(new Set),R=z.useRef(!1),F=A=>{if(R.current||h){R.current=!1;return}u?.(A),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},T=A=>{if(Array.isArray(o)&&o?.includes(2)){A.preventDefault();return}a?.(A)},H=l?A=>l(A):void 0,V=A=>{R.current&&(A.stopPropagation(),R.current=!1)},_=A=>{const{domNode:P}=w.getState();if(S.current=P?.getBoundingClientRect(),!S.current)return;const L=A.target===M.current;if(!L&&!!A.target.closest(".nokey")||!e||!(i&&L||t)||A.button!==0||!A.isPrimary)return;A.target?.setPointerCapture?.(A.pointerId),R.current=!1;const{x:B,y:O}=pe(A.nativeEvent,S.current);w.setState({userSelectionRect:{width:0,height:0,startX:B,startY:O,x:B,y:O}}),L||(A.stopPropagation(),A.preventDefault())},I=A=>{const{userSelectionRect:P,transform:L,nodeLookup:m,edgeLookup:b,connectionLookup:B,triggerNodeChanges:O,triggerEdgeChanges:Y,defaultEdgeOptions:W,resetSelectedElements:X}=w.getState();if(!S.current||!P)return;const{x:j,y:Z}=pe(A.nativeEvent,S.current),{startX:Q,startY:J}=P;if(!R.current){const ne=t?0:r;if(Math.hypot(j-Q,Z-J)<=ne)return;X(),s?.(A)}R.current=!0;const G={startX:Q,startY:J,x:j<Q?j:Q,y:Z<J?Z:J,width:Math.abs(j-Q),height:Math.abs(Z-J)},K=E.current,te=$.current;E.current=new Set(Jn(m,G,L,n===pt.Partial,!0).map(ne=>ne.id)),$.current=new Set;const oe=W?.selectable??!0;for(const ne of E.current){const ae=B.get(ne);if(ae)for(const{edgeId:Ce}of ae.values()){const _e=b.get(Ce);_e&&(_e.selectable??oe)&&$.current.add(Ce)}}if(!Zo(K,E.current)){const ne=Fe(m,E.current,!0);O(ne)}if(!Zo(te,$.current)){const ne=Fe(b,$.current);Y(ne)}w.setState({userSelectionRect:G,userSelectionActive:!0,nodesSelectionActive:!1})},C=A=>{A.button===0&&(A.target?.releasePointerCapture?.(A.pointerId),!v&&A.target===M.current&&w.getState().userSelectionRect&&F?.(A),w.setState({userSelectionActive:!1,userSelectionRect:null}),R.current&&(c?.(A),w.setState({nodesSelectionActive:E.current.size>0})))},k=o===!0||Array.isArray(o)&&o.includes(0);return D.jsxs("div",{className:se(["react-flow__pane",{draggable:k,dragging:N,selection:e}]),onClick:x?void 0:An(F,M),onContextMenu:An(T,M),onWheel:An(H,M),onPointerEnter:x?void 0:f,onPointerMove:x?I:d,onPointerUp:x?C:void 0,onPointerDownCapture:x?_:void 0,onClickCapture:x?V:void 0,onPointerLeave:g,ref:M,style:ln,children:[p,D.jsx(Ud,{})]})}function Yn({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:s,nodeLookup:c,onError:u}=t.getState(),a=c.get(e);if(!a){u?.("012",we.error012(e));return}t.setState({nodesSelectionActive:!1}),a.selected?(n||a.selected&&s)&&(i({nodes:[a],edges:[]}),requestAnimationFrame(()=>o?.current?.blur())):r([e])}function Wi({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:i,nodeClickDistance:s}){const c=ie(),[u,a]=z.useState(!1),l=z.useRef();return z.useEffect(()=>{l.current=Lf({getStoreItems:()=>c.getState(),onNodeMouseDown:f=>{Yn({id:f,store:c,nodeRef:e})},onDragStart:()=>{a(!0)},onDragStop:()=>{a(!1)}})},[]),z.useEffect(()=>{if(!(t||!e.current||!l.current))return l.current.update({noDragClassName:n,handleSelector:o,domNode:e.current,isSelectable:i,nodeId:r,nodeClickDistance:s}),()=>{l.current?.destroy()}},[n,o,t,i,e,r,s]),u}const Jd=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function qi(){const e=ie();return z.useCallback(n=>{const{nodeExtent:o,snapToGrid:r,snapGrid:i,nodesDraggable:s,onError:c,updateNodePositions:u,nodeLookup:a,nodeOrigin:l}=e.getState(),f=new Map,d=Jd(s),g=r?i[0]:5,p=r?i[1]:5,w=n.direction.x*g*n.factor,v=n.direction.y*p*n.factor;for(const[,y]of a){if(!d(y))continue;let N={x:y.internals.positionAbsolute.x+w,y:y.internals.positionAbsolute.y+v};r&&(N=bt(N,i));const{position:h,positionAbsolute:x}=gi({nodeId:y.id,nextPosition:N,nodeLookup:a,nodeExtent:o,nodeOrigin:l,onError:c});y.position=h,y.internals.positionAbsolute=x,f.set(y.id,y)}u(f)},[])}const uo=z.createContext(null),eh=uo.Provider;uo.Consumer;const Gi=()=>z.useContext(uo),th=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),nh=(e,t,n)=>o=>{const{connectionClickStartHandle:r,connectionMode:i,connection:s}=o,{fromHandle:c,toHandle:u,isValid:a}=s,l=u?.nodeId===e&&u?.id===t&&u?.type===n;return{connectingFrom:c?.nodeId===e&&c?.id===t&&c?.type===n,connectingTo:l,clickConnecting:r?.nodeId===e&&r?.id===t&&r?.type===n,isPossibleEndHandle:i===qe.Strict?c?.type!==n:e!==c?.nodeId||t!==c?.id,connectionInProcess:!!c,clickConnectionInProcess:!!r,valid:l&&a}};function oh({type:e="source",position:t=q.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:i=!0,id:s,onConnect:c,children:u,className:a,onMouseDown:l,onTouchStart:f,...d},g){const p=s||null,w=e==="target",v=ie(),y=Gi(),{connectOnClick:N,noPanClassName:h,rfId:x}=ee(th,re),{connectingFrom:M,connectingTo:S,clickConnecting:E,isPossibleEndHandle:$,connectionInProcess:R,clickConnectionInProcess:F,valid:T}=ee(nh(y,p,e),re);y||v.getState().onError?.("010",we.error010());const H=I=>{const{defaultEdgeOptions:C,onConnect:k,hasDefaultEdges:A}=v.getState(),P={...C,...I};if(A){const{edges:L,setEdges:m}=v.getState();m(bf(P,L))}k?.(P),c?.(P)},V=I=>{if(!y)return;const C=_i(I.nativeEvent);if(r&&(C&&I.button===0||!C)){const k=v.getState();Fn.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:k.autoPanOnConnect,connectionMode:k.connectionMode,connectionRadius:k.connectionRadius,domNode:k.domNode,nodeLookup:k.nodeLookup,lib:k.lib,isTarget:w,handleId:p,nodeId:y,flowId:k.rfId,panBy:k.panBy,cancelConnection:k.cancelConnection,onConnectStart:k.onConnectStart,onConnectEnd:(...A)=>v.getState().onConnectEnd?.(...A),updateConnection:k.updateConnection,onConnect:H,isValidConnection:n||((...A)=>v.getState().isValidConnection?.(...A)??!0),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:k.autoPanSpeed,dragThreshold:k.connectionDragThreshold})}C?l?.(I):f?.(I)},_=I=>{const{onClickConnectStart:C,onClickConnectEnd:k,connectionClickStartHandle:A,connectionMode:P,isValidConnection:L,lib:m,rfId:b,nodeLookup:B,connection:O}=v.getState();if(!y||!A&&!r)return;if(!A){C?.(I.nativeEvent,{nodeId:y,handleId:p,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,id:p}});return}const Y=wi(I.target),W=n||L,{connection:X,isValid:j}=Fn.isValid(I.nativeEvent,{handle:{nodeId:y,id:p,type:e},connectionMode:P,fromNodeId:A.nodeId,fromHandleId:A.id||null,fromType:A.type,isValidConnection:W,flowId:b,doc:Y,lib:m,nodeLookup:B});j&&X&&H(X);const Z=structuredClone(O);delete Z.inProgress,Z.toPosition=Z.toHandle?Z.toHandle.position:null,k?.(I,Z),v.setState({connectionClickStartHandle:null})};return D.jsx("div",{"data-handleid":p,"data-nodeid":y,"data-handlepos":t,"data-id":`${x}-${y}-${p}-${e}`,className:se(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",h,a,{source:!w,target:w,connectable:o,connectablestart:r,connectableend:i,clickconnecting:E,connectingfrom:M,connectingto:S,valid:T,connectionindicator:o&&(!R||$)&&(R||F?i:r)}]),onMouseDown:V,onTouchStart:V,onClick:N?_:void 0,ref:g,...d,children:u})}const Ut=z.memo(Xi(oh));function rh({data:e,isConnectable:t,sourcePosition:n=q.Bottom}){return D.jsxs(D.Fragment,{children:[e?.label,D.jsx(Ut,{type:"source",position:n,isConnectable:t})]})}function ih({data:e,isConnectable:t,targetPosition:n=q.Top,sourcePosition:o=q.Bottom}){return D.jsxs(D.Fragment,{children:[D.jsx(Ut,{type:"target",position:n,isConnectable:t}),e?.label,D.jsx(Ut,{type:"source",position:o,isConnectable:t})]})}function sh(){return null}function ah({data:e,isConnectable:t,targetPosition:n=q.Top}){return D.jsxs(D.Fragment,{children:[D.jsx(Ut,{type:"target",position:n,isConnectable:t}),e?.label]})}const Kt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Er={input:rh,default:ih,output:ah,group:sh};function ch(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}const uh=e=>{const{width:t,height:n,x:o,y:r}=Et(e.nodeLookup,{filter:i=>!!i.selected});return{width:ge(t)?t:null,height:ge(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${o}px,${r}px)`}};function lh({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=ie(),{width:r,height:i,transformString:s,userSelectionActive:c}=ee(uh,re),u=qi(),a=z.useRef(null);z.useEffect(()=>{n||a.current?.focus({preventScroll:!0})},[n]);const l=!c&&r!==null&&i!==null;if(Wi({nodeRef:a,disabled:!l}),!l)return null;const f=e?g=>{const p=o.getState().nodes.filter(w=>w.selected);e(g,p)}:void 0,d=g=>{Object.prototype.hasOwnProperty.call(Kt,g.key)&&(g.preventDefault(),u({direction:Kt[g.key],factor:g.shiftKey?4:1}))};return D.jsx("div",{className:se(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:D.jsx("div",{ref:a,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:r,height:i}})})}const br=typeof window<"u"?window:void 0,fh=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Ui({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,paneClickDistance:c,deleteKeyCode:u,selectionKeyCode:a,selectionOnDrag:l,selectionMode:f,onSelectionStart:d,onSelectionEnd:g,multiSelectionKeyCode:p,panActivationKeyCode:w,zoomActivationKeyCode:v,elementsSelectable:y,zoomOnScroll:N,zoomOnPinch:h,panOnScroll:x,panOnScrollSpeed:M,panOnScrollMode:S,zoomOnDoubleClick:E,panOnDrag:$,defaultViewport:R,translateExtent:F,minZoom:T,maxZoom:H,preventScrolling:V,onSelectionContextMenu:_,noWheelClassName:I,noPanClassName:C,disableKeyboardA11y:k,onViewportChange:A,isControlledViewport:P}){const{nodesSelectionActive:L,userSelectionActive:m}=ee(fh,re),b=xt(a,{target:br}),B=xt(w,{target:br}),O=B||$,Y=B||x,W=l&&O!==!0,X=b||m||W;return Xd({deleteKeyCode:u,multiSelectionKeyCode:p}),D.jsx(qd,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:N,zoomOnPinch:h,panOnScroll:Y,panOnScrollSpeed:M,panOnScrollMode:S,zoomOnDoubleClick:E,panOnDrag:!b&&O,defaultViewport:R,translateExtent:F,minZoom:T,maxZoom:H,zoomActivationKeyCode:v,preventScrolling:V,noWheelClassName:I,noPanClassName:C,onViewportChange:A,isControlledViewport:P,paneClickDistance:c,selectionOnDrag:W,children:D.jsxs(Qd,{onSelectionStart:d,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:O,isSelecting:!!X,selectionMode:f,selectionKeyPressed:b,paneClickDistance:c,selectionOnDrag:W,children:[e,L&&D.jsx(lh,{onSelectionContextMenu:_,noPanClassName:C,disableKeyboardA11y:k})]})})}Ui.displayName="FlowRenderer";const dh=z.memo(Ui),hh=e=>t=>e?Jn(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function gh(e){return ee(z.useCallback(hh(e),[e]),re)}const ph=e=>e.updateNodeInternals;function mh(){const e=ee(ph),[t]=z.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const o=new Map;n.forEach(r=>{const i=r.target.getAttribute("data-id");o.set(i,{id:i,nodeElement:r.target,force:!0})}),e(o)}));return z.useEffect(()=>()=>{t?.disconnect()},[t]),t}function yh({node:e,nodeType:t,hasDimensions:n,resizeObserver:o}){const r=ie(),i=z.useRef(null),s=z.useRef(null),c=z.useRef(e.sourcePosition),u=z.useRef(e.targetPosition),a=z.useRef(t),l=n&&!!e.internals.handleBounds;return z.useEffect(()=>{i.current&&!e.hidden&&(!l||s.current!==i.current)&&(s.current&&o?.unobserve(s.current),o?.observe(i.current),s.current=i.current)},[l,e.hidden]),z.useEffect(()=>()=>{s.current&&(o?.unobserve(s.current),s.current=null)},[]),z.useEffect(()=>{if(i.current){const f=a.current!==t,d=c.current!==e.sourcePosition,g=u.current!==e.targetPosition;(f||d||g)&&(a.current=t,c.current=e.sourcePosition,u.current=e.targetPosition,r.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function xh({id:e,onClick:t,onMouseEnter:n,onMouseMove:o,onMouseLeave:r,onContextMenu:i,onDoubleClick:s,nodesDraggable:c,elementsSelectable:u,nodesConnectable:a,nodesFocusable:l,resizeObserver:f,noDragClassName:d,noPanClassName:g,disableKeyboardA11y:p,rfId:w,nodeTypes:v,nodeClickDistance:y,onError:N}){const{node:h,internals:x,isParent:M}=ee(j=>{const Z=j.nodeLookup.get(e),Q=j.parentLookup.has(e);return{node:Z,internals:Z.internals,isParent:Q}},re);let S=h.type||"default",E=v?.[S]||Er[S];E===void 0&&(N?.("003",we.error003(S)),S="default",E=v?.default||Er.default);const $=!!(h.draggable||c&&typeof h.draggable>"u"),R=!!(h.selectable||u&&typeof h.selectable>"u"),F=!!(h.connectable||a&&typeof h.connectable>"u"),T=!!(h.focusable||l&&typeof h.focusable>"u"),H=ie(),V=to(h),_=yh({node:h,nodeType:S,hasDimensions:V,resizeObserver:f}),I=Wi({nodeRef:_,disabled:h.hidden||!$,noDragClassName:d,handleSelector:h.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:y}),C=qi();if(h.hidden)return null;const k=Ne(h),A=ch(h),P=R||$||t||n||o||r,L=n?j=>n(j,{...x.userNode}):void 0,m=o?j=>o(j,{...x.userNode}):void 0,b=r?j=>r(j,{...x.userNode}):void 0,B=i?j=>i(j,{...x.userNode}):void 0,O=s?j=>s(j,{...x.userNode}):void 0,Y=j=>{const{selectNodesOnDrag:Z,nodeDragThreshold:Q}=H.getState();R&&(!Z||!$||Q>0)&&Yn({id:e,store:H,nodeRef:_}),t&&t(j,{...x.userNode})},W=j=>{if(!(vi(j.nativeEvent)||p)){if(ui.includes(j.key)&&R){const Z=j.key==="Escape";Yn({id:e,store:H,unselect:Z,nodeRef:_})}else if($&&h.selected&&Object.prototype.hasOwnProperty.call(Kt,j.key)){j.preventDefault();const{ariaLabelConfig:Z}=H.getState();H.setState({ariaLiveMessage:Z["node.a11yDescription.ariaLiveMessage"]({direction:j.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),C({direction:Kt[j.key],factor:j.shiftKey?4:1})}}},X=()=>{if(p||!_.current?.matches(":focus-visible"))return;const{transform:j,width:Z,height:Q,autoPanOnNodeFocus:J,setCenter:G}=H.getState();if(!J)return;Jn(new Map([[e,h]]),{x:0,y:0,width:Z,height:Q},j,!0).length>0||G(h.position.x+k.width/2,h.position.y+k.height/2,{zoom:j[2]})};return D.jsx("div",{className:se(["react-flow__node",`react-flow__node-${S}`,{[g]:$},h.className,{selected:h.selected,selectable:R,parent:M,draggable:$,dragging:I}]),ref:_,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:P?"all":"none",visibility:V?"visible":"hidden",...h.style,...A},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:L,onMouseMove:m,onMouseLeave:b,onContextMenu:B,onClick:Y,onDoubleClick:O,onKeyDown:T?W:void 0,tabIndex:T?0:void 0,onFocus:T?X:void 0,role:h.ariaRole??(T?"group":void 0),"aria-roledescription":"node","aria-describedby":p?void 0:`${Li}-${w}`,"aria-label":h.ariaLabel,...h.domAttributes,children:D.jsx(eh,{value:e,children:D.jsx(E,{id:e,data:h.data,type:S,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:h.selected??!1,selectable:R,draggable:$,deletable:h.deletable??!0,isConnectable:F,sourcePosition:h.sourcePosition,targetPosition:h.targetPosition,dragging:I,dragHandle:h.dragHandle,zIndex:x.z,parentId:h.parentId,...k})})})}var wh=z.memo(xh);const vh=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ki(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,onError:i}=ee(vh,re),s=gh(e.onlyRenderVisibleElements),c=mh();return D.jsx("div",{className:"react-flow__nodes",style:ln,children:s.map(u=>D.jsx(wh,{id:u,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:c,nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},u))})}Ki.displayName="NodeRenderer";const _h=z.memo(Ki);function Eh(e){return ee(z.useCallback(n=>{if(!e)return n.edges.map(r=>r.id);const o=[];if(n.width&&n.height)for(const r of n.edges){const i=n.nodeLookup.get(r.source),s=n.nodeLookup.get(r.target);i&&s&&vf({sourceNode:i,targetNode:s,width:n.width,height:n.height,transform:n.transform})&&o.push(r.id)}return o},[e]),re)}const bh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return D.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Sh=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return D.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Sr={[Wt.Arrow]:bh,[Wt.ArrowClosed]:Sh};function Nh(e){const t=ie();return z.useMemo(()=>Object.prototype.hasOwnProperty.call(Sr,e)?Sr[e]:(t.getState().onError?.("009",we.error009(e)),null),[e])}const Ch=({id:e,type:t,color:n,width:o=12.5,height:r=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:c="auto-start-reverse"})=>{const u=Nh(t);return u?D.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:c,refX:"0",refY:"0",children:D.jsx(u,{color:n,strokeWidth:s})}):null},Qi=({defaultColor:e,rfId:t})=>{const n=ee(i=>i.edges),o=ee(i=>i.defaultEdgeOptions),r=z.useMemo(()=>If(n,{id:t,defaultColor:e,defaultMarkerStart:o?.markerStart,defaultMarkerEnd:o?.markerEnd}),[n,o,t,e]);return r.length?D.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:D.jsx("defs",{children:r.map(i=>D.jsx(Ch,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};Qi.displayName="MarkerDefinitions";var Mh=z.memo(Qi);function Ji({x:e,y:t,label:n,labelStyle:o,labelShowBg:r=!0,labelBgStyle:i,labelBgPadding:s=[2,4],labelBgBorderRadius:c=2,children:u,className:a,...l}){const[f,d]=z.useState({x:1,y:0,width:0,height:0}),g=se(["react-flow__edge-textwrapper",a]),p=z.useRef(null);return z.useEffect(()=>{if(p.current){const w=p.current.getBBox();d({x:w.x,y:w.y,width:w.width,height:w.height})}},[n]),n?D.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:g,visibility:f.width?"visible":"hidden",...l,children:[r&&D.jsx("rect",{width:f.width+2*s[0],x:-s[0],y:-s[1],height:f.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:c,ry:c}),D.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:p,style:o,children:n}),u]}):null}Ji.displayName="EdgeText";const Ih=z.memo(Ji);function fn({path:e,labelX:t,labelY:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:u,interactionWidth:a=20,...l}){return D.jsxs(D.Fragment,{children:[D.jsx("path",{...l,d:e,fill:"none",className:se(["react-flow__edge-path",l.className])}),a?D.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:a,className:"react-flow__edge-interaction"}):null,o&&ge(t)&&ge(n)?D.jsx(Ih,{x:t,y:n,label:o,labelStyle:r,labelShowBg:i,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:u}):null]})}function Nr({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===q.Left||e===q.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function es({sourceX:e,sourceY:t,sourcePosition:n=q.Bottom,targetX:o,targetY:r,targetPosition:i=q.Top}){const[s,c]=Nr({pos:n,x1:e,y1:t,x2:o,y2:r}),[u,a]=Nr({pos:i,x1:o,y1:r,x2:e,y2:t}),[l,f,d,g]=Ei({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:c,targetControlX:u,targetControlY:a});return[`M${e},${t} C${s},${c} ${u},${a} ${o},${r}`,l,f,d,g]}function ts(e){return z.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s,targetPosition:c,label:u,labelStyle:a,labelShowBg:l,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:g,style:p,markerEnd:w,markerStart:v,interactionWidth:y})=>{const[N,h,x]=es({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:c}),M=e.isInternal?void 0:t;return D.jsx(fn,{id:M,path:N,labelX:h,labelY:x,label:u,labelStyle:a,labelShowBg:l,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:g,style:p,markerEnd:w,markerStart:v,interactionWidth:y})})}const Ah=ts({isInternal:!1}),ns=ts({isInternal:!0});Ah.displayName="SimpleBezierEdge";ns.displayName="SimpleBezierEdgeInternal";function os(e){return z.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:c,labelShowBg:u,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:f,style:d,sourcePosition:g=q.Bottom,targetPosition:p=q.Top,markerEnd:w,markerStart:v,pathOptions:y,interactionWidth:N})=>{const[h,x,M]=Vn({sourceX:n,sourceY:o,sourcePosition:g,targetX:r,targetY:i,targetPosition:p,borderRadius:y?.borderRadius,offset:y?.offset,stepPosition:y?.stepPosition}),S=e.isInternal?void 0:t;return D.jsx(fn,{id:S,path:h,labelX:x,labelY:M,label:s,labelStyle:c,labelShowBg:u,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:f,style:d,markerEnd:w,markerStart:v,interactionWidth:N})})}const rs=os({isInternal:!1}),is=os({isInternal:!0});rs.displayName="SmoothStepEdge";is.displayName="SmoothStepEdgeInternal";function ss(e){return z.memo(({id:t,...n})=>{const o=e.isInternal?void 0:t;return D.jsx(rs,{...n,id:o,pathOptions:z.useMemo(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}const kh=ss({isInternal:!1}),as=ss({isInternal:!0});kh.displayName="StepEdge";as.displayName="StepEdgeInternal";function cs(e){return z.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,label:s,labelStyle:c,labelShowBg:u,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:f,style:d,markerEnd:g,markerStart:p,interactionWidth:w})=>{const[v,y,N]=Ni({sourceX:n,sourceY:o,targetX:r,targetY:i}),h=e.isInternal?void 0:t;return D.jsx(fn,{id:h,path:v,labelX:y,labelY:N,label:s,labelStyle:c,labelShowBg:u,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:f,style:d,markerEnd:g,markerStart:p,interactionWidth:w})})}const Th=cs({isInternal:!1}),us=cs({isInternal:!0});Th.displayName="StraightEdge";us.displayName="StraightEdgeInternal";function ls(e){return z.memo(({id:t,sourceX:n,sourceY:o,targetX:r,targetY:i,sourcePosition:s=q.Bottom,targetPosition:c=q.Top,label:u,labelStyle:a,labelShowBg:l,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:g,style:p,markerEnd:w,markerStart:v,pathOptions:y,interactionWidth:N})=>{const[h,x,M]=bi({sourceX:n,sourceY:o,sourcePosition:s,targetX:r,targetY:i,targetPosition:c,curvature:y?.curvature}),S=e.isInternal?void 0:t;return D.jsx(fn,{id:S,path:h,labelX:x,labelY:M,label:u,labelStyle:a,labelShowBg:l,labelBgStyle:f,labelBgPadding:d,labelBgBorderRadius:g,style:p,markerEnd:w,markerStart:v,interactionWidth:N})})}const Ph=ls({isInternal:!1}),fs=ls({isInternal:!0});Ph.displayName="BezierEdge";fs.displayName="BezierEdgeInternal";const Cr={default:fs,straight:us,step:as,smoothstep:is,simplebezier:ns},Mr={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Rh=(e,t,n)=>n===q.Left?e-t:n===q.Right?e+t:e,$h=(e,t,n)=>n===q.Top?e-t:n===q.Bottom?e+t:e,Ir="react-flow__edgeupdater";function Ar({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:i,onMouseOut:s,type:c}){return D.jsx("circle",{onMouseDown:r,onMouseEnter:i,onMouseOut:s,className:se([Ir,`${Ir}-${c}`]),cx:Rh(t,o,e),cy:$h(n,o,e),r:o,stroke:"transparent",fill:"transparent"})}function Dh({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:o,sourceY:r,targetX:i,targetY:s,sourcePosition:c,targetPosition:u,onReconnect:a,onReconnectStart:l,onReconnectEnd:f,setReconnecting:d,setUpdateHover:g}){const p=ie(),w=(x,M)=>{if(x.button!==0)return;const{autoPanOnConnect:S,domNode:E,connectionMode:$,connectionRadius:R,lib:F,onConnectStart:T,cancelConnection:H,nodeLookup:V,rfId:_,panBy:I,updateConnection:C}=p.getState(),k=M.type==="target",A=(m,b)=>{d(!1),f?.(m,n,M.type,b)},P=m=>a?.(n,m),L=(m,b)=>{d(!0),l?.(x,n,M.type),T?.(m,b)};Fn.onPointerDown(x.nativeEvent,{autoPanOnConnect:S,connectionMode:$,connectionRadius:R,domNode:E,handleId:M.id,nodeId:M.nodeId,nodeLookup:V,isTarget:k,edgeUpdaterType:M.type,lib:F,flowId:_,cancelConnection:H,panBy:I,isValidConnection:(...m)=>p.getState().isValidConnection?.(...m)??!0,onConnect:P,onConnectStart:L,onConnectEnd:(...m)=>p.getState().onConnectEnd?.(...m),onReconnectEnd:A,updateConnection:C,getTransform:()=>p.getState().transform,getFromHandle:()=>p.getState().connection.fromHandle,dragThreshold:p.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},v=x=>w(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=x=>w(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),N=()=>g(!0),h=()=>g(!1);return D.jsxs(D.Fragment,{children:[(e===!0||e==="source")&&D.jsx(Ar,{position:c,centerX:o,centerY:r,radius:t,onMouseDown:v,onMouseEnter:N,onMouseOut:h,type:"source"}),(e===!0||e==="target")&&D.jsx(Ar,{position:u,centerX:i,centerY:s,radius:t,onMouseDown:y,onMouseEnter:N,onMouseOut:h,type:"target"})]})}function Hh({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:o,onClick:r,onDoubleClick:i,onContextMenu:s,onMouseEnter:c,onMouseMove:u,onMouseLeave:a,reconnectRadius:l,onReconnect:f,onReconnectStart:d,onReconnectEnd:g,rfId:p,edgeTypes:w,noPanClassName:v,onError:y,disableKeyboardA11y:N}){let h=ee(G=>G.edgeLookup.get(e));const x=ee(G=>G.defaultEdgeOptions);h=x?{...x,...h}:h;let M=h.type||"default",S=w?.[M]||Cr[M];S===void 0&&(y?.("011",we.error011(M)),M="default",S=w?.default||Cr.default);const E=!!(h.focusable||t&&typeof h.focusable>"u"),$=typeof f<"u"&&(h.reconnectable||n&&typeof h.reconnectable>"u"),R=!!(h.selectable||o&&typeof h.selectable>"u"),F=z.useRef(null),[T,H]=z.useState(!1),[V,_]=z.useState(!1),I=ie(),{zIndex:C,sourceX:k,sourceY:A,targetX:P,targetY:L,sourcePosition:m,targetPosition:b}=ee(z.useCallback(G=>{const K=G.nodeLookup.get(h.source),te=G.nodeLookup.get(h.target);if(!K||!te)return{zIndex:h.zIndex,...Mr};const oe=Mf({id:e,sourceNode:K,targetNode:te,sourceHandle:h.sourceHandle||null,targetHandle:h.targetHandle||null,connectionMode:G.connectionMode,onError:y});return{zIndex:wf({selected:h.selected,zIndex:h.zIndex,sourceNode:K,targetNode:te,elevateOnSelect:G.elevateEdgesOnSelect,zIndexMode:G.zIndexMode}),...oe||Mr}},[h.source,h.target,h.sourceHandle,h.targetHandle,h.selected,h.zIndex]),re),B=z.useMemo(()=>h.markerStart?`url('#${Bn(h.markerStart,p)}')`:void 0,[h.markerStart,p]),O=z.useMemo(()=>h.markerEnd?`url('#${Bn(h.markerEnd,p)}')`:void 0,[h.markerEnd,p]);if(h.hidden||k===null||A===null||P===null||L===null)return null;const Y=G=>{const{addSelectedEdges:K,unselectNodesAndEdges:te,multiSelectionActive:oe}=I.getState();R&&(I.setState({nodesSelectionActive:!1}),h.selected&&oe?(te({nodes:[],edges:[h]}),F.current?.blur()):K([e])),r&&r(G,h)},W=i?G=>{i(G,{...h})}:void 0,X=s?G=>{s(G,{...h})}:void 0,j=c?G=>{c(G,{...h})}:void 0,Z=u?G=>{u(G,{...h})}:void 0,Q=a?G=>{a(G,{...h})}:void 0,J=G=>{if(!N&&ui.includes(G.key)&&R){const{unselectNodesAndEdges:K,addSelectedEdges:te}=I.getState();G.key==="Escape"?(F.current?.blur(),K({edges:[h]})):te([e])}};return D.jsx("svg",{style:{zIndex:C},children:D.jsxs("g",{className:se(["react-flow__edge",`react-flow__edge-${M}`,h.className,v,{selected:h.selected,animated:h.animated,inactive:!R&&!r,updating:T,selectable:R}]),onClick:Y,onDoubleClick:W,onContextMenu:X,onMouseEnter:j,onMouseMove:Z,onMouseLeave:Q,onKeyDown:E?J:void 0,tabIndex:E?0:void 0,role:h.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":h.ariaLabel===null?void 0:h.ariaLabel||`Edge from ${h.source} to ${h.target}`,"aria-describedby":E?`${Vi}-${p}`:void 0,ref:F,...h.domAttributes,children:[!V&&D.jsx(S,{id:e,source:h.source,target:h.target,type:h.type,selected:h.selected,animated:h.animated,selectable:R,deletable:h.deletable??!0,label:h.label,labelStyle:h.labelStyle,labelShowBg:h.labelShowBg,labelBgStyle:h.labelBgStyle,labelBgPadding:h.labelBgPadding,labelBgBorderRadius:h.labelBgBorderRadius,sourceX:k,sourceY:A,targetX:P,targetY:L,sourcePosition:m,targetPosition:b,data:h.data,style:h.style,sourceHandleId:h.sourceHandle,targetHandleId:h.targetHandle,markerStart:B,markerEnd:O,pathOptions:"pathOptions"in h?h.pathOptions:void 0,interactionWidth:h.interactionWidth}),$&&D.jsx(Dh,{edge:h,isReconnectable:$,reconnectRadius:l,onReconnect:f,onReconnectStart:d,onReconnectEnd:g,sourceX:k,sourceY:A,targetX:P,targetY:L,sourcePosition:m,targetPosition:b,setUpdateHover:H,setReconnecting:_})]})})}var zh=z.memo(Hh);const Oh=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ds({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:o,noPanClassName:r,onReconnect:i,onEdgeContextMenu:s,onEdgeMouseEnter:c,onEdgeMouseMove:u,onEdgeMouseLeave:a,onEdgeClick:l,reconnectRadius:f,onEdgeDoubleClick:d,onReconnectStart:g,onReconnectEnd:p,disableKeyboardA11y:w}){const{edgesFocusable:v,edgesReconnectable:y,elementsSelectable:N,onError:h}=ee(Oh,re),x=Eh(t);return D.jsxs("div",{className:"react-flow__edges",children:[D.jsx(Mh,{defaultColor:e,rfId:n}),x.map(M=>D.jsx(zh,{id:M,edgesFocusable:v,edgesReconnectable:y,elementsSelectable:N,noPanClassName:r,onReconnect:i,onContextMenu:s,onMouseEnter:c,onMouseMove:u,onMouseLeave:a,onClick:l,reconnectRadius:f,onDoubleClick:d,onReconnectStart:g,onReconnectEnd:p,rfId:n,onError:h,edgeTypes:o,disableKeyboardA11y:w},M))]})}ds.displayName="EdgeRenderer";const Lh=z.memo(ds),Vh=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Bh({children:e}){const t=ee(Vh);return D.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function jh(e){const t=co(),n=z.useRef(!1);z.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Fh=e=>e.panZoom?.syncViewport;function Yh(e){const t=ee(Fh),n=ie();return z.useEffect(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Xh(e){return e.connection.inProgress?{...e.connection,to:St(e.connection.to,e.transform)}:{...e.connection}}function Zh(e){return Xh}function Wh(e){const t=Zh();return ee(t,re)}const qh=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Gh({containerStyle:e,style:t,type:n,component:o}){const{nodesConnectable:r,width:i,height:s,isValid:c,inProgress:u}=ee(qh,re);return!(i&&r&&u)?null:D.jsx("svg",{style:e,width:i,height:s,className:"react-flow__connectionline react-flow__container",children:D.jsx("g",{className:se(["react-flow__connection",di(c)]),children:D.jsx(hs,{style:t,type:n,CustomComponent:o,isValid:c})})})}const hs=({style:e,type:t=Ae.Bezier,CustomComponent:n,isValid:o})=>{const{inProgress:r,from:i,fromNode:s,fromHandle:c,fromPosition:u,to:a,toNode:l,toHandle:f,toPosition:d,pointer:g}=Wh();if(!r)return;if(n)return D.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:c,fromX:i.x,fromY:i.y,toX:a.x,toY:a.y,fromPosition:u,toPosition:d,connectionStatus:di(o),toNode:l,toHandle:f,pointer:g});let p="";const w={sourceX:i.x,sourceY:i.y,sourcePosition:u,targetX:a.x,targetY:a.y,targetPosition:d};switch(t){case Ae.Bezier:[p]=bi(w);break;case Ae.SimpleBezier:[p]=es(w);break;case Ae.Step:[p]=Vn({...w,borderRadius:0});break;case Ae.SmoothStep:[p]=Vn(w);break;default:[p]=Ni(w)}return D.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};hs.displayName="ConnectionLine";const Uh={};function kr(e=Uh){z.useRef(e),ie(),z.useEffect(()=>{},[e])}function Kh(){ie(),z.useRef(!1),z.useEffect(()=>{},[])}function gs({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:o,onEdgeClick:r,onNodeDoubleClick:i,onEdgeDoubleClick:s,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:a,onNodeContextMenu:l,onSelectionContextMenu:f,onSelectionStart:d,onSelectionEnd:g,connectionLineType:p,connectionLineStyle:w,connectionLineComponent:v,connectionLineContainerStyle:y,selectionKeyCode:N,selectionOnDrag:h,selectionMode:x,multiSelectionKeyCode:M,panActivationKeyCode:S,zoomActivationKeyCode:E,deleteKeyCode:$,onlyRenderVisibleElements:R,elementsSelectable:F,defaultViewport:T,translateExtent:H,minZoom:V,maxZoom:_,preventScrolling:I,defaultMarkerColor:C,zoomOnScroll:k,zoomOnPinch:A,panOnScroll:P,panOnScrollSpeed:L,panOnScrollMode:m,zoomOnDoubleClick:b,panOnDrag:B,onPaneClick:O,onPaneMouseEnter:Y,onPaneMouseMove:W,onPaneMouseLeave:X,onPaneScroll:j,onPaneContextMenu:Z,paneClickDistance:Q,nodeClickDistance:J,onEdgeContextMenu:G,onEdgeMouseEnter:K,onEdgeMouseMove:te,onEdgeMouseLeave:oe,reconnectRadius:ne,onReconnect:ae,onReconnectStart:Ce,onReconnectEnd:_e,noDragClassName:Te,noWheelClassName:Je,noPanClassName:et,disableKeyboardA11y:tt,nodeExtent:dn,rfId:Nt,viewport:Ve,onViewportChange:nt}){return kr(e),kr(t),Kh(),jh(n),Yh(Ve),D.jsx(dh,{onPaneClick:O,onPaneMouseEnter:Y,onPaneMouseMove:W,onPaneMouseLeave:X,onPaneContextMenu:Z,onPaneScroll:j,paneClickDistance:Q,deleteKeyCode:$,selectionKeyCode:N,selectionOnDrag:h,selectionMode:x,onSelectionStart:d,onSelectionEnd:g,multiSelectionKeyCode:M,panActivationKeyCode:S,zoomActivationKeyCode:E,elementsSelectable:F,zoomOnScroll:k,zoomOnPinch:A,zoomOnDoubleClick:b,panOnScroll:P,panOnScrollSpeed:L,panOnScrollMode:m,panOnDrag:B,defaultViewport:T,translateExtent:H,minZoom:V,maxZoom:_,onSelectionContextMenu:f,preventScrolling:I,noDragClassName:Te,noWheelClassName:Je,noPanClassName:et,disableKeyboardA11y:tt,onViewportChange:nt,isControlledViewport:!!Ve,children:D.jsxs(Bh,{children:[D.jsx(Lh,{edgeTypes:t,onEdgeClick:r,onEdgeDoubleClick:s,onReconnect:ae,onReconnectStart:Ce,onReconnectEnd:_e,onlyRenderVisibleElements:R,onEdgeContextMenu:G,onEdgeMouseEnter:K,onEdgeMouseMove:te,onEdgeMouseLeave:oe,reconnectRadius:ne,defaultMarkerColor:C,noPanClassName:et,disableKeyboardA11y:tt,rfId:Nt}),D.jsx(Gh,{style:w,type:p,component:v,containerStyle:y}),D.jsx("div",{className:"react-flow__edgelabel-renderer"}),D.jsx(_h,{nodeTypes:e,onNodeClick:o,onNodeDoubleClick:i,onNodeMouseEnter:c,onNodeMouseMove:u,onNodeMouseLeave:a,onNodeContextMenu:l,nodeClickDistance:J,onlyRenderVisibleElements:R,noPanClassName:et,noDragClassName:Te,disableKeyboardA11y:tt,nodeExtent:dn,rfId:Nt}),D.jsx("div",{className:"react-flow__viewport-portal"})]})})}gs.displayName="GraphView";const Qh=z.memo(gs),Tr=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:c,minZoom:u=.5,maxZoom:a=2,nodeOrigin:l,nodeExtent:f,zIndexMode:d="basic"}={})=>{const g=new Map,p=new Map,w=new Map,v=new Map,y=o??t??[],N=n??e??[],h=l??[0,0],x=f??gt;Ii(w,v,y);const M=jn(N,g,p,{nodeOrigin:h,nodeExtent:x,zIndexMode:d});let S=[0,0,1];if(s&&r&&i){const E=Et(g,{filter:T=>!!((T.width||T.initialWidth)&&(T.height||T.initialHeight))}),{x:$,y:R,zoom:F}=eo(E,r,i,u,a,c?.padding??.1);S=[$,R,F]}return{rfId:"1",width:r??0,height:i??0,transform:S,nodes:N,nodesInitialized:M,nodeLookup:g,parentLookup:p,edges:y,edgeLookup:v,connectionLookup:w,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:o!==void 0,panZoom:null,minZoom:u,maxZoom:a,translateExtent:gt,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:qe.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:h,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:c,fitViewResolver:null,connection:{...fi},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:hf,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:li,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Jh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:s,fitViewOptions:c,minZoom:u,maxZoom:a,nodeOrigin:l,nodeExtent:f,zIndexMode:d})=>yd((g,p)=>{async function w(){const{nodeLookup:v,panZoom:y,fitViewOptions:N,fitViewResolver:h,width:x,height:M,minZoom:S,maxZoom:E}=p();y&&(await ff({nodes:v,width:x,height:M,panZoom:y,minZoom:S,maxZoom:E},N),h?.resolve(!0),g({fitViewResolver:null}))}return{...Tr({nodes:e,edges:t,width:r,height:i,fitView:s,fitViewOptions:c,minZoom:u,maxZoom:a,nodeOrigin:l,nodeExtent:f,defaultNodes:n,defaultEdges:o,zIndexMode:d}),setNodes:v=>{const{nodeLookup:y,parentLookup:N,nodeOrigin:h,elevateNodesOnSelect:x,fitViewQueued:M,zIndexMode:S}=p(),E=jn(v,y,N,{nodeOrigin:h,nodeExtent:f,elevateNodesOnSelect:x,checkEquality:!0,zIndexMode:S});M&&E?(w(),g({nodes:v,nodesInitialized:E,fitViewQueued:!1,fitViewOptions:void 0})):g({nodes:v,nodesInitialized:E})},setEdges:v=>{const{connectionLookup:y,edgeLookup:N}=p();Ii(y,N,v),g({edges:v})},setDefaultNodesAndEdges:(v,y)=>{if(v){const{setNodes:N}=p();N(v),g({hasDefaultNodes:!0})}if(y){const{setEdges:N}=p();N(y),g({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:y,nodeLookup:N,parentLookup:h,domNode:x,nodeOrigin:M,nodeExtent:S,debug:E,fitViewQueued:$,zIndexMode:R}=p(),{changes:F,updatedInternals:T}=Df(v,N,h,x,M,S,R);T&&(Tf(N,h,{nodeOrigin:M,nodeExtent:S,zIndexMode:R}),$?(w(),g({fitViewQueued:!1,fitViewOptions:void 0})):g({}),F?.length>0&&(E&&console.log("React Flow: trigger node changes",F),y?.(F)))},updateNodePositions:(v,y=!1)=>{const N=[];let h=[];const{nodeLookup:x,triggerNodeChanges:M,connection:S,updateConnection:E,onNodesChangeMiddlewareMap:$}=p();for(const[R,F]of v){const T=x.get(R),H=!!(T?.expandParent&&T?.parentId&&F?.position),V={id:R,type:"position",position:H?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:y};if(T&&S.inProgress&&S.fromNode.id===T.id){const _=Le(T,S.fromHandle,q.Left,!0);E({...S,from:_})}H&&T.parentId&&N.push({id:R,parentId:T.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),h.push(V)}if(N.length>0){const{parentLookup:R,nodeOrigin:F}=p(),T=ao(N,x,R,F);h.push(...T)}for(const R of $.values())h=R(h);M(h)},triggerNodeChanges:v=>{const{onNodesChange:y,setNodes:N,nodes:h,hasDefaultNodes:x,debug:M}=p();if(v?.length){if(x){const S=Fi(v,h);N(S)}M&&console.log("React Flow: trigger node changes",v),y?.(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:y,setEdges:N,edges:h,hasDefaultEdges:x,debug:M}=p();if(v?.length){if(x){const S=Yi(v,h);N(S)}M&&console.log("React Flow: trigger edge changes",v),y?.(v)}},addSelectedNodes:v=>{const{multiSelectionActive:y,edgeLookup:N,nodeLookup:h,triggerNodeChanges:x,triggerEdgeChanges:M}=p();if(y){const S=v.map(E=>Pe(E,!0));x(S);return}x(Fe(h,new Set([...v]),!0)),M(Fe(N))},addSelectedEdges:v=>{const{multiSelectionActive:y,edgeLookup:N,nodeLookup:h,triggerNodeChanges:x,triggerEdgeChanges:M}=p();if(y){const S=v.map(E=>Pe(E,!0));M(S);return}M(Fe(N,new Set([...v]))),x(Fe(h,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:y}={})=>{const{edges:N,nodes:h,nodeLookup:x,triggerNodeChanges:M,triggerEdgeChanges:S}=p(),E=v||h,$=y||N,R=[];for(const T of E){if(!T.selected)continue;const H=x.get(T.id);H&&(H.selected=!1),R.push(Pe(T.id,!1))}const F=[];for(const T of $)T.selected&&F.push(Pe(T.id,!1));M(R),S(F)},setMinZoom:v=>{const{panZoom:y,maxZoom:N}=p();y?.setScaleExtent([v,N]),g({minZoom:v})},setMaxZoom:v=>{const{panZoom:y,minZoom:N}=p();y?.setScaleExtent([N,v]),g({maxZoom:v})},setTranslateExtent:v=>{p().panZoom?.setTranslateExtent(v),g({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:y,triggerNodeChanges:N,triggerEdgeChanges:h,elementsSelectable:x}=p();if(!x)return;const M=y.reduce((E,$)=>$.selected?[...E,Pe($.id,!1)]:E,[]),S=v.reduce((E,$)=>$.selected?[...E,Pe($.id,!1)]:E,[]);N(M),h(S)},setNodeExtent:v=>{const{nodes:y,nodeLookup:N,parentLookup:h,nodeOrigin:x,elevateNodesOnSelect:M,nodeExtent:S,zIndexMode:E}=p();v[0][0]===S[0][0]&&v[0][1]===S[0][1]&&v[1][0]===S[1][0]&&v[1][1]===S[1][1]||(jn(y,N,h,{nodeOrigin:x,nodeExtent:v,elevateNodesOnSelect:M,checkEquality:!1,zIndexMode:E}),g({nodeExtent:v}))},panBy:v=>{const{transform:y,width:N,height:h,panZoom:x,translateExtent:M}=p();return Hf({delta:v,panZoom:x,transform:y,translateExtent:M,width:N,height:h})},setCenter:async(v,y,N)=>{const{width:h,height:x,maxZoom:M,panZoom:S}=p();if(!S)return Promise.resolve(!1);const E=typeof N?.zoom<"u"?N.zoom:M;return await S.setViewport({x:h/2-v*E,y:x/2-y*E,zoom:E},{duration:N?.duration,ease:N?.ease,interpolate:N?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{g({connection:{...fi}})},updateConnection:v=>{g({connection:v})},reset:()=>g({...Tr()})}},Object.is);function eg({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:i,initialMinZoom:s,initialMaxZoom:c,initialFitViewOptions:u,fitView:a,nodeOrigin:l,nodeExtent:f,zIndexMode:d,children:g}){const[p]=z.useState(()=>Jh({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,width:r,height:i,fitView:a,minZoom:s,maxZoom:c,fitViewOptions:u,nodeOrigin:l,nodeExtent:f,zIndexMode:d}));return D.jsx(xd,{value:p,children:D.jsx(Bd,{children:g})})}function tg({children:e,nodes:t,edges:n,defaultNodes:o,defaultEdges:r,width:i,height:s,fitView:c,fitViewOptions:u,minZoom:a,maxZoom:l,nodeOrigin:f,nodeExtent:d,zIndexMode:g}){return z.useContext(cn)?D.jsx(D.Fragment,{children:e}):D.jsx(eg,{initialNodes:t,initialEdges:n,defaultNodes:o,defaultEdges:r,initialWidth:i,initialHeight:s,fitView:c,initialFitViewOptions:u,initialMinZoom:a,initialMaxZoom:l,nodeOrigin:f,nodeExtent:d,zIndexMode:g,children:e})}const ng={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function og({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:i,edgeTypes:s,onNodeClick:c,onEdgeClick:u,onInit:a,onMove:l,onMoveStart:f,onMoveEnd:d,onConnect:g,onConnectStart:p,onConnectEnd:w,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:N,onNodeMouseMove:h,onNodeMouseLeave:x,onNodeContextMenu:M,onNodeDoubleClick:S,onNodeDragStart:E,onNodeDrag:$,onNodeDragStop:R,onNodesDelete:F,onEdgesDelete:T,onDelete:H,onSelectionChange:V,onSelectionDragStart:_,onSelectionDrag:I,onSelectionDragStop:C,onSelectionContextMenu:k,onSelectionStart:A,onSelectionEnd:P,onBeforeDelete:L,connectionMode:m,connectionLineType:b=Ae.Bezier,connectionLineStyle:B,connectionLineComponent:O,connectionLineContainerStyle:Y,deleteKeyCode:W="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:j=!1,selectionMode:Z=pt.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:J=yt()?"Meta":"Control",zoomActivationKeyCode:G=yt()?"Meta":"Control",snapToGrid:K,snapGrid:te,onlyRenderVisibleElements:oe=!1,selectNodesOnDrag:ne,nodesDraggable:ae,autoPanOnNodeFocus:Ce,nodesConnectable:_e,nodesFocusable:Te,nodeOrigin:Je=Bi,edgesFocusable:et,edgesReconnectable:tt,elementsSelectable:dn=!0,defaultViewport:Nt=Td,minZoom:Ve=.5,maxZoom:nt=2,translateExtent:lo=gt,preventScrolling:xs=!0,nodeExtent:hn,defaultMarkerColor:ws="#b1b1b7",zoomOnScroll:vs=!0,zoomOnPinch:_s=!0,panOnScroll:Es=!1,panOnScrollSpeed:bs=.5,panOnScrollMode:Ss=De.Free,zoomOnDoubleClick:Ns=!0,panOnDrag:Cs=!0,onPaneClick:Ms,onPaneMouseEnter:Is,onPaneMouseMove:As,onPaneMouseLeave:ks,onPaneScroll:Ts,onPaneContextMenu:Ps,paneClickDistance:Rs=1,nodeClickDistance:$s=0,children:Ds,onReconnect:Hs,onReconnectStart:zs,onReconnectEnd:Os,onEdgeContextMenu:Ls,onEdgeDoubleClick:Vs,onEdgeMouseEnter:Bs,onEdgeMouseMove:js,onEdgeMouseLeave:Fs,reconnectRadius:Ys=10,onNodesChange:Xs,onEdgesChange:Zs,noDragClassName:Ws="nodrag",noWheelClassName:qs="nowheel",noPanClassName:fo="nopan",fitView:ho,fitViewOptions:go,connectOnClick:Gs,attributionPosition:Us,proOptions:Ks,defaultEdgeOptions:Qs,elevateNodesOnSelect:Js=!0,elevateEdgesOnSelect:ea=!1,disableKeyboardA11y:po=!1,autoPanOnConnect:ta,autoPanOnNodeDrag:na,autoPanSpeed:oa,connectionRadius:ra,isValidConnection:ia,onError:sa,style:aa,id:mo,nodeDragThreshold:ca,connectionDragThreshold:ua,viewport:la,onViewportChange:fa,width:da,height:ha,colorMode:ga="light",debug:pa,onScroll:yo,ariaLabelConfig:ma,zIndexMode:xo="basic",...ya},xa){const gn=mo||"1",wa=Dd(ga),va=z.useCallback(wo=>{wo.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),yo?.(wo)},[yo]);return D.jsx("div",{"data-testid":"rf__wrapper",...ya,onScroll:va,style:{...aa,...ng},ref:xa,className:se(["react-flow",r,wa]),id:mo,role:"application",children:D.jsxs(tg,{nodes:e,edges:t,width:da,height:ha,fitView:ho,fitViewOptions:go,minZoom:Ve,maxZoom:nt,nodeOrigin:Je,nodeExtent:hn,zIndexMode:xo,children:[D.jsx(Qh,{onInit:a,onNodeClick:c,onEdgeClick:u,onNodeMouseEnter:N,onNodeMouseMove:h,onNodeMouseLeave:x,onNodeContextMenu:M,onNodeDoubleClick:S,nodeTypes:i,edgeTypes:s,connectionLineType:b,connectionLineStyle:B,connectionLineComponent:O,connectionLineContainerStyle:Y,selectionKeyCode:X,selectionOnDrag:j,selectionMode:Z,deleteKeyCode:W,multiSelectionKeyCode:J,panActivationKeyCode:Q,zoomActivationKeyCode:G,onlyRenderVisibleElements:oe,defaultViewport:Nt,translateExtent:lo,minZoom:Ve,maxZoom:nt,preventScrolling:xs,zoomOnScroll:vs,zoomOnPinch:_s,zoomOnDoubleClick:Ns,panOnScroll:Es,panOnScrollSpeed:bs,panOnScrollMode:Ss,panOnDrag:Cs,onPaneClick:Ms,onPaneMouseEnter:Is,onPaneMouseMove:As,onPaneMouseLeave:ks,onPaneScroll:Ts,onPaneContextMenu:Ps,paneClickDistance:Rs,nodeClickDistance:$s,onSelectionContextMenu:k,onSelectionStart:A,onSelectionEnd:P,onReconnect:Hs,onReconnectStart:zs,onReconnectEnd:Os,onEdgeContextMenu:Ls,onEdgeDoubleClick:Vs,onEdgeMouseEnter:Bs,onEdgeMouseMove:js,onEdgeMouseLeave:Fs,reconnectRadius:Ys,defaultMarkerColor:ws,noDragClassName:Ws,noWheelClassName:qs,noPanClassName:fo,rfId:gn,disableKeyboardA11y:po,nodeExtent:hn,viewport:la,onViewportChange:fa}),D.jsx($d,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:g,onConnectStart:p,onConnectEnd:w,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:ae,autoPanOnNodeFocus:Ce,nodesConnectable:_e,nodesFocusable:Te,edgesFocusable:et,edgesReconnectable:tt,elementsSelectable:dn,elevateNodesOnSelect:Js,elevateEdgesOnSelect:ea,minZoom:Ve,maxZoom:nt,nodeExtent:hn,onNodesChange:Xs,onEdgesChange:Zs,snapToGrid:K,snapGrid:te,connectionMode:m,translateExtent:lo,connectOnClick:Gs,defaultEdgeOptions:Qs,fitView:ho,fitViewOptions:go,onNodesDelete:F,onEdgesDelete:T,onDelete:H,onNodeDragStart:E,onNodeDrag:$,onNodeDragStop:R,onSelectionDrag:I,onSelectionDragStart:_,onSelectionDragStop:C,onMove:l,onMoveStart:f,onMoveEnd:d,noPanClassName:fo,nodeOrigin:Je,rfId:gn,autoPanOnConnect:ta,autoPanOnNodeDrag:na,autoPanSpeed:oa,onError:sa,connectionRadius:ra,isValidConnection:ia,selectNodesOnDrag:ne,nodeDragThreshold:ca,connectionDragThreshold:ua,onBeforeDelete:L,debug:pa,ariaLabelConfig:ma,zIndexMode:xo}),D.jsx(kd,{onSelectionChange:V}),Ds,D.jsx(Nd,{proOptions:Ks,position:Us}),D.jsx(Sd,{rfId:gn,disableKeyboardA11y:po})]})})}var Tg=Xi(og);function Pg(e){const[t,n]=z.useState(e),o=z.useCallback(r=>n(i=>Fi(r,i)),[]);return[t,n,o]}function Rg(e){const[t,n]=z.useState(e),o=z.useCallback(r=>n(i=>Yi(r,i)),[]);return[t,n,o]}const rg=e=>t=>{if(!e.includeHiddenNodes)return t.nodesInitialized;if(t.nodeLookup.size===0)return!1;for(const[,{internals:n}]of t.nodeLookup)if(n.handleBounds===void 0||!to(n.userNode))return!1;return!0};function $g(e={includeHiddenNodes:!1}){return ee(rg(e))}function ig({dimensions:e,lineWidth:t,variant:n,className:o}){return D.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:se(["react-flow__background-pattern",n,o])})}function sg({radius:e,className:t}){return D.jsx("circle",{cx:e,cy:e,r:e,className:se(["react-flow__background-pattern","dots",t])})}var ke;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ke||(ke={}));const ag={[ke.Dots]:1,[ke.Lines]:1,[ke.Cross]:6},cg=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ps({id:e,variant:t=ke.Dots,gap:n=20,size:o,lineWidth:r=1,offset:i=0,color:s,bgColor:c,style:u,className:a,patternClassName:l}){const f=z.useRef(null),{transform:d,patternId:g}=ee(cg,re),p=o||ag[t],w=t===ke.Dots,v=t===ke.Cross,y=Array.isArray(n)?n:[n,n],N=[y[0]*d[2]||1,y[1]*d[2]||1],h=p*d[2],x=Array.isArray(i)?i:[i,i],M=v?[h,h]:N,S=[x[0]*d[2]||1+M[0]/2,x[1]*d[2]||1+M[1]/2],E=`${g}${e||""}`;return D.jsxs("svg",{className:se(["react-flow__background",a]),style:{...u,...ln,"--xy-background-color-props":c,"--xy-background-pattern-color-props":s},ref:f,"data-testid":"rf__background",children:[D.jsx("pattern",{id:E,x:d[0]%N[0],y:d[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${S[0]},-${S[1]})`,children:w?D.jsx(sg,{radius:h/2,className:l}):D.jsx(ig,{dimensions:M,lineWidth:r,variant:t,className:l})}),D.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}ps.displayName="Background";const Dg=z.memo(ps);function ug(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:D.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function lg(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:D.jsx("path",{d:"M0 0h32v4.2H0z"})})}function fg(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:D.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function dg(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:D.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function hg(){return D.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:D.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function $t({children:e,className:t,...n}){return D.jsx("button",{type:"button",className:se(["react-flow__controls-button",t]),...n,children:e})}const gg=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function ms({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:i,onZoomOut:s,onFitView:c,onInteractiveChange:u,className:a,children:l,position:f="bottom-left",orientation:d="vertical","aria-label":g}){const p=ie(),{isInteractive:w,minZoomReached:v,maxZoomReached:y,ariaLabelConfig:N}=ee(gg,re),{zoomIn:h,zoomOut:x,fitView:M}=co(),S=()=>{h(),i?.()},E=()=>{x(),s?.()},$=()=>{M(r),c?.()},R=()=>{p.setState({nodesDraggable:!w,nodesConnectable:!w,elementsSelectable:!w}),u?.(!w)},F=d==="horizontal"?"horizontal":"vertical";return D.jsxs(un,{className:se(["react-flow__controls",F,a]),position:f,style:e,"data-testid":"rf__controls","aria-label":g??N["controls.ariaLabel"],children:[t&&D.jsxs(D.Fragment,{children:[D.jsx($t,{onClick:S,className:"react-flow__controls-zoomin",title:N["controls.zoomIn.ariaLabel"],"aria-label":N["controls.zoomIn.ariaLabel"],disabled:y,children:D.jsx(ug,{})}),D.jsx($t,{onClick:E,className:"react-flow__controls-zoomout",title:N["controls.zoomOut.ariaLabel"],"aria-label":N["controls.zoomOut.ariaLabel"],disabled:v,children:D.jsx(lg,{})})]}),n&&D.jsx($t,{className:"react-flow__controls-fitview",onClick:$,title:N["controls.fitView.ariaLabel"],"aria-label":N["controls.fitView.ariaLabel"],children:D.jsx(fg,{})}),o&&D.jsx($t,{className:"react-flow__controls-interactive",onClick:R,title:N["controls.interactive.ariaLabel"],"aria-label":N["controls.interactive.ariaLabel"],children:w?D.jsx(hg,{}):D.jsx(dg,{})}),l]})}ms.displayName="Controls";const Hg=z.memo(ms);function pg({id:e,x:t,y:n,width:o,height:r,style:i,color:s,strokeColor:c,strokeWidth:u,className:a,borderRadius:l,shapeRendering:f,selected:d,onClick:g}){const{background:p,backgroundColor:w}=i||{},v=s||p||w;return D.jsx("rect",{className:se(["react-flow__minimap-node",{selected:d},a]),x:t,y:n,rx:l,ry:l,width:o,height:r,style:{fill:v,stroke:c,strokeWidth:u},shapeRendering:f,onClick:g?y=>g(y,e):void 0})}const mg=z.memo(pg),yg=e=>e.nodes.map(t=>t.id),kn=e=>e instanceof Function?e:()=>e;function xg({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:o=5,nodeStrokeWidth:r,nodeComponent:i=mg,onClick:s}){const c=ee(yg,re),u=kn(t),a=kn(e),l=kn(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return D.jsx(D.Fragment,{children:c.map(d=>D.jsx(vg,{id:d,nodeColorFunc:u,nodeStrokeColorFunc:a,nodeClassNameFunc:l,nodeBorderRadius:o,nodeStrokeWidth:r,NodeComponent:i,onClick:s,shapeRendering:f},d))})}function wg({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:o,nodeBorderRadius:r,nodeStrokeWidth:i,shapeRendering:s,NodeComponent:c,onClick:u}){const{node:a,x:l,y:f,width:d,height:g}=ee(p=>{const w=p.nodeLookup.get(e);if(!w)return{node:void 0,x:0,y:0,width:0,height:0};const v=w.internals.userNode,{x:y,y:N}=w.internals.positionAbsolute,{width:h,height:x}=Ne(v);return{node:v,x:y,y:N,width:h,height:x}},re);return!a||a.hidden||!to(a)?null:D.jsx(c,{x:l,y:f,width:d,height:g,style:a.style,selected:!!a.selected,className:o(a),color:t(a),borderRadius:r,strokeColor:n(a),strokeWidth:i,shapeRendering:s,onClick:u,id:a.id})}const vg=z.memo(wg);var _g=z.memo(xg);const Eg=200,bg=150,Sg=e=>!e.hidden,Ng=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?yi(Et(e.nodeLookup,{filter:Sg}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Cg="react-flow__minimap-desc";function ys({style:e,className:t,nodeStrokeColor:n,nodeColor:o,nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:s,nodeComponent:c,bgColor:u,maskColor:a,maskStrokeColor:l,maskStrokeWidth:f,position:d="bottom-right",onClick:g,onNodeClick:p,pannable:w=!1,zoomable:v=!1,ariaLabel:y,inversePan:N,zoomStep:h=1,offsetScale:x=5}){const M=ie(),S=z.useRef(null),{boundingRect:E,viewBB:$,rfId:R,panZoom:F,translateExtent:T,flowWidth:H,flowHeight:V,ariaLabelConfig:_}=ee(Ng,re),I=e?.width??Eg,C=e?.height??bg,k=E.width/I,A=E.height/C,P=Math.max(k,A),L=P*I,m=P*C,b=x*P,B=E.x-(L-E.width)/2-b,O=E.y-(m-E.height)/2-b,Y=L+b*2,W=m+b*2,X=`${Cg}-${R}`,j=z.useRef(0),Z=z.useRef();j.current=P,z.useEffect(()=>{if(S.current&&F)return Z.current=Xf({domNode:S.current,panZoom:F,getTransform:()=>M.getState().transform,getViewScale:()=>j.current}),()=>{Z.current?.destroy()}},[F]),z.useEffect(()=>{Z.current?.update({translateExtent:T,width:H,height:V,inversePan:N,pannable:w,zoomStep:h,zoomable:v})},[w,v,N,h,T,H,V]);const Q=g?K=>{const[te,oe]=Z.current?.pointer(K)||[0,0];g(K,{x:te,y:oe})}:void 0,J=p?z.useCallback((K,te)=>{const oe=M.getState().nodeLookup.get(te).internals.userNode;p(K,oe)},[]):void 0,G=y??_["minimap.ariaLabel"];return D.jsx(un,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-mask-stroke-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-width-props":typeof f=="number"?f*P:void 0,"--xy-minimap-node-background-color-props":typeof o=="string"?o:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:se(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:D.jsxs("svg",{width:I,height:C,viewBox:`${B} ${O} ${Y} ${W}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":X,ref:S,onClick:Q,children:[G&&D.jsx("title",{id:X,children:G}),D.jsx(_g,{onClick:J,nodeColor:o,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:r,nodeStrokeWidth:s,nodeComponent:c}),D.jsx("path",{className:"react-flow__minimap-mask",d:`M${B-b},${O-b}h${Y+b*2}v${W+b*2}h${-Y-b*2}z
|
|
7
|
+
M${$.x},${$.y}h${$.width}v${$.height}h${-$.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ys.displayName="MiniMap";const zg=z.memo(ys),Mg=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Ig={[Qe.Line]:"right",[Qe.Handle]:"bottom-right"};function Ag({nodeId:e,position:t,variant:n=Qe.Handle,className:o,style:r=void 0,children:i,color:s,minWidth:c=10,minHeight:u=10,maxWidth:a=Number.MAX_VALUE,maxHeight:l=Number.MAX_VALUE,keepAspectRatio:f=!1,resizeDirection:d,autoScale:g=!0,shouldResize:p,onResizeStart:w,onResize:v,onResizeEnd:y}){const N=Gi(),h=typeof e=="string"?e:N,x=ie(),M=z.useRef(null),S=n===Qe.Handle,E=ee(z.useCallback(Mg(S&&g),[S,g]),re),$=z.useRef(null),R=t??Ig[n];z.useEffect(()=>{if(!(!M.current||!h))return $.current||($.current=id({domNode:M.current,nodeId:h,getStoreItems:()=>{const{nodeLookup:T,transform:H,snapGrid:V,snapToGrid:_,nodeOrigin:I,domNode:C}=x.getState();return{nodeLookup:T,transform:H,snapGrid:V,snapToGrid:_,nodeOrigin:I,paneDomNode:C}},onChange:(T,H)=>{const{triggerNodeChanges:V,nodeLookup:_,parentLookup:I,nodeOrigin:C}=x.getState(),k=[],A={x:T.x,y:T.y},P=_.get(h);if(P&&P.expandParent&&P.parentId){const L=P.origin??C,m=T.width??P.measured.width??0,b=T.height??P.measured.height??0,B={id:P.id,parentId:P.parentId,rect:{width:m,height:b,...xi({x:T.x??P.position.x,y:T.y??P.position.y},{width:m,height:b},P.parentId,_,L)}},O=ao([B],_,I,C);k.push(...O),A.x=T.x?Math.max(L[0]*m,T.x):void 0,A.y=T.y?Math.max(L[1]*b,T.y):void 0}if(A.x!==void 0&&A.y!==void 0){const L={id:h,type:"position",position:{...A}};k.push(L)}if(T.width!==void 0&&T.height!==void 0){const m={id:h,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:T.width,height:T.height}};k.push(m)}for(const L of H){const m={...L,type:"position"};k.push(m)}V(k)},onEnd:({width:T,height:H})=>{const V={id:h,type:"dimensions",resizing:!1,dimensions:{width:T,height:H}};x.getState().triggerNodeChanges([V])}})),$.current.update({controlPosition:R,boundaries:{minWidth:c,minHeight:u,maxWidth:a,maxHeight:l},keepAspectRatio:f,resizeDirection:d,onResizeStart:w,onResize:v,onResizeEnd:y,shouldResize:p}),()=>{$.current?.destroy()}},[R,c,u,a,l,f,w,v,y,p]);const F=R.split("-");return D.jsx("div",{className:se(["react-flow__resize-control","nodrag",...F,n,o]),ref:M,style:{...r,scale:E,...s&&{[S?"backgroundColor":"borderColor"]:s}},children:i})}z.memo(Ag);export{Dg as B,Hg as C,Ut as H,Wt as M,q as P,Sa as R,Qt as a,Ca as b,kg as c,eg as d,Pg as e,Rg as f,Pr as g,$g as h,Tg as i,D as j,ke as k,zg as l,z as r,co as u};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var T;(function(t){t.STRING="string",t.NUMBER="number",t.INTEGER="integer",t.BOOLEAN="boolean",t.ARRAY="array",t.OBJECT="object"})(T||(T={}));var m;(function(t){t.LANGUAGE_UNSPECIFIED="language_unspecified",t.PYTHON="python"})(m||(m={}));var w;(function(t){t.OUTCOME_UNSPECIFIED="outcome_unspecified",t.OUTCOME_OK="outcome_ok",t.OUTCOME_FAILED="outcome_failed",t.OUTCOME_DEADLINE_EXCEEDED="outcome_deadline_exceeded"})(w||(w={}));const b=["user","model","function","system"];var M;(function(t){t.HARM_CATEGORY_UNSPECIFIED="HARM_CATEGORY_UNSPECIFIED",t.HARM_CATEGORY_HATE_SPEECH="HARM_CATEGORY_HATE_SPEECH",t.HARM_CATEGORY_SEXUALLY_EXPLICIT="HARM_CATEGORY_SEXUALLY_EXPLICIT",t.HARM_CATEGORY_HARASSMENT="HARM_CATEGORY_HARASSMENT",t.HARM_CATEGORY_DANGEROUS_CONTENT="HARM_CATEGORY_DANGEROUS_CONTENT",t.HARM_CATEGORY_CIVIC_INTEGRITY="HARM_CATEGORY_CIVIC_INTEGRITY"})(M||(M={}));var L;(function(t){t.HARM_BLOCK_THRESHOLD_UNSPECIFIED="HARM_BLOCK_THRESHOLD_UNSPECIFIED",t.BLOCK_LOW_AND_ABOVE="BLOCK_LOW_AND_ABOVE",t.BLOCK_MEDIUM_AND_ABOVE="BLOCK_MEDIUM_AND_ABOVE",t.BLOCK_ONLY_HIGH="BLOCK_ONLY_HIGH",t.BLOCK_NONE="BLOCK_NONE"})(L||(L={}));var D;(function(t){t.HARM_PROBABILITY_UNSPECIFIED="HARM_PROBABILITY_UNSPECIFIED",t.NEGLIGIBLE="NEGLIGIBLE",t.LOW="LOW",t.MEDIUM="MEDIUM",t.HIGH="HIGH"})(D||(D={}));var G;(function(t){t.BLOCKED_REASON_UNSPECIFIED="BLOCKED_REASON_UNSPECIFIED",t.SAFETY="SAFETY",t.OTHER="OTHER"})(G||(G={}));var R;(function(t){t.FINISH_REASON_UNSPECIFIED="FINISH_REASON_UNSPECIFIED",t.STOP="STOP",t.MAX_TOKENS="MAX_TOKENS",t.SAFETY="SAFETY",t.RECITATION="RECITATION",t.LANGUAGE="LANGUAGE",t.BLOCKLIST="BLOCKLIST",t.PROHIBITED_CONTENT="PROHIBITED_CONTENT",t.SPII="SPII",t.MALFORMED_FUNCTION_CALL="MALFORMED_FUNCTION_CALL",t.OTHER="OTHER"})(R||(R={}));var x;(function(t){t.TASK_TYPE_UNSPECIFIED="TASK_TYPE_UNSPECIFIED",t.RETRIEVAL_QUERY="RETRIEVAL_QUERY",t.RETRIEVAL_DOCUMENT="RETRIEVAL_DOCUMENT",t.SEMANTIC_SIMILARITY="SEMANTIC_SIMILARITY",t.CLASSIFICATION="CLASSIFICATION",t.CLUSTERING="CLUSTERING"})(x||(x={}));var U;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.AUTO="AUTO",t.ANY="ANY",t.NONE="NONE"})(U||(U={}));var H;(function(t){t.MODE_UNSPECIFIED="MODE_UNSPECIFIED",t.MODE_DYNAMIC="MODE_DYNAMIC"})(H||(H={}));class u extends Error{constructor(e){super(`[GoogleGenerativeAI Error]: ${e}`)}}class I extends u{constructor(e,n){super(e),this.response=n}}class q extends u{constructor(e,n,s,o){super(e),this.status=n,this.statusText=s,this.errorDetails=o}}class E extends u{}class P extends u{}const X="https://generativelanguage.googleapis.com",Q="v1beta",z="0.24.1",Z="genai-js";var C;(function(t){t.GENERATE_CONTENT="generateContent",t.STREAM_GENERATE_CONTENT="streamGenerateContent",t.COUNT_TOKENS="countTokens",t.EMBED_CONTENT="embedContent",t.BATCH_EMBED_CONTENTS="batchEmbedContents"})(C||(C={}));class tt{constructor(e,n,s,o,i){this.model=e,this.task=n,this.apiKey=s,this.stream=o,this.requestOptions=i}toString(){var e,n;const s=((e=this.requestOptions)===null||e===void 0?void 0:e.apiVersion)||Q;let i=`${((n=this.requestOptions)===null||n===void 0?void 0:n.baseUrl)||X}/${s}/${this.model}:${this.task}`;return this.stream&&(i+="?alt=sse"),i}}function et(t){const e=[];return t?.apiClient&&e.push(t.apiClient),e.push(`${Z}/${z}`),e.join(" ")}async function nt(t){var e;const n=new Headers;n.append("Content-Type","application/json"),n.append("x-goog-api-client",et(t.requestOptions)),n.append("x-goog-api-key",t.apiKey);let s=(e=t.requestOptions)===null||e===void 0?void 0:e.customHeaders;if(s){if(!(s instanceof Headers))try{s=new Headers(s)}catch(o){throw new E(`unable to convert customHeaders value ${JSON.stringify(s)} to Headers: ${o.message}`)}for(const[o,i]of s.entries()){if(o==="x-goog-api-key")throw new E(`Cannot set reserved header name ${o}`);if(o==="x-goog-api-client")throw new E(`Header name ${o} can only be set using the apiClient field`);n.append(o,i)}}return n}async function st(t,e,n,s,o,i){const a=new tt(t,e,n,s,i);return{url:a.toString(),fetchOptions:Object.assign(Object.assign({},rt(i)),{method:"POST",headers:await nt(a),body:o})}}async function y(t,e,n,s,o,i={},a=fetch){const{url:r,fetchOptions:d}=await st(t,e,n,s,o,i);return ot(r,d,a)}async function ot(t,e,n=fetch){let s;try{s=await n(t,e)}catch(o){it(o,t)}return s.ok||await at(s,t),s}function it(t,e){let n=t;throw n.name==="AbortError"?(n=new P(`Request aborted when fetching ${e.toString()}: ${t.message}`),n.stack=t.stack):t instanceof q||t instanceof E||(n=new u(`Error fetching from ${e.toString()}: ${t.message}`),n.stack=t.stack),n}async function at(t,e){let n="",s;try{const o=await t.json();n=o.error.message,o.error.details&&(n+=` ${JSON.stringify(o.error.details)}`,s=o.error.details)}catch{}throw new q(`Error fetching from ${e.toString()}: [${t.status} ${t.statusText}] ${n}`,t.status,t.statusText,s)}function rt(t){const e={};if(t?.signal!==void 0||t?.timeout>=0){const n=new AbortController;t?.timeout>=0&&setTimeout(()=>n.abort(),t.timeout),t?.signal&&t.signal.addEventListener("abort",()=>{n.abort()}),e.signal=n.signal}return e}function N(t){return t.text=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning text from the first candidate only. Access response.candidates directly to use the other candidates.`),S(t.candidates[0]))throw new I(`${g(t)}`,t);return ct(t)}else if(t.promptFeedback)throw new I(`Text not available. ${g(t)}`,t);return""},t.functionCall=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),S(t.candidates[0]))throw new I(`${g(t)}`,t);return console.warn("response.functionCall() is deprecated. Use response.functionCalls() instead."),F(t)[0]}else if(t.promptFeedback)throw new I(`Function call not available. ${g(t)}`,t)},t.functionCalls=()=>{if(t.candidates&&t.candidates.length>0){if(t.candidates.length>1&&console.warn(`This response had ${t.candidates.length} candidates. Returning function calls from the first candidate only. Access response.candidates directly to use the other candidates.`),S(t.candidates[0]))throw new I(`${g(t)}`,t);return F(t)}else if(t.promptFeedback)throw new I(`Function call not available. ${g(t)}`,t)},t}function ct(t){var e,n,s,o;const i=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(o=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||o===void 0?void 0:o.parts)a.text&&i.push(a.text),a.executableCode&&i.push("\n```"+a.executableCode.language+`
|
|
2
|
+
`+a.executableCode.code+"\n```\n"),a.codeExecutionResult&&i.push("\n```\n"+a.codeExecutionResult.output+"\n```\n");return i.length>0?i.join(""):""}function F(t){var e,n,s,o;const i=[];if(!((n=(e=t.candidates)===null||e===void 0?void 0:e[0].content)===null||n===void 0)&&n.parts)for(const a of(o=(s=t.candidates)===null||s===void 0?void 0:s[0].content)===null||o===void 0?void 0:o.parts)a.functionCall&&i.push(a.functionCall);if(i.length>0)return i}const dt=[R.RECITATION,R.SAFETY,R.LANGUAGE];function S(t){return!!t.finishReason&&dt.includes(t.finishReason)}function g(t){var e,n,s;let o="";if((!t.candidates||t.candidates.length===0)&&t.promptFeedback)o+="Response was blocked",!((e=t.promptFeedback)===null||e===void 0)&&e.blockReason&&(o+=` due to ${t.promptFeedback.blockReason}`),!((n=t.promptFeedback)===null||n===void 0)&&n.blockReasonMessage&&(o+=`: ${t.promptFeedback.blockReasonMessage}`);else if(!((s=t.candidates)===null||s===void 0)&&s[0]){const i=t.candidates[0];S(i)&&(o+=`Candidate was blocked due to ${i.finishReason}`,i.finishMessage&&(o+=`: ${i.finishMessage}`))}return o}function p(t){return this instanceof p?(this.v=t,this):new p(t)}function lt(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n.apply(t,e||[]),o,i=[];return o={},a("next"),a("throw"),a("return"),o[Symbol.asyncIterator]=function(){return this},o;function a(l){s[l]&&(o[l]=function(c){return new Promise(function(f,O){i.push([l,c,f,O])>1||r(l,c)})})}function r(l,c){try{d(s[l](c))}catch(f){v(i[0][3],f)}}function d(l){l.value instanceof p?Promise.resolve(l.value.v).then(h,_):v(i[0][2],l)}function h(l){r("next",l)}function _(l){r("throw",l)}function v(l,c){l(c),i.shift(),i.length&&r(i[0][0],i[0][1])}}const $=/^data\: (.*)(?:\n\n|\r\r|\r\n\r\n)/;function ut(t){const e=t.body.pipeThrough(new TextDecoderStream("utf8",{fatal:!0})),n=gt(e),[s,o]=n.tee();return{stream:ht(s),response:ft(o)}}async function ft(t){const e=[],n=t.getReader();for(;;){const{done:s,value:o}=await n.read();if(s)return N(Et(e));e.push(o)}}function ht(t){return lt(this,arguments,function*(){const n=t.getReader();for(;;){const{value:s,done:o}=yield p(n.read());if(o)break;yield yield p(N(s))}})}function gt(t){const e=t.getReader();return new ReadableStream({start(s){let o="";return i();function i(){return e.read().then(({value:a,done:r})=>{if(r){if(o.trim()){s.error(new u("Failed to parse stream"));return}s.close();return}o+=a;let d=o.match($),h;for(;d;){try{h=JSON.parse(d[1])}catch{s.error(new u(`Error parsing JSON response: "${d[1]}"`));return}s.enqueue(h),o=o.substring(d[0].length),d=o.match($)}return i()}).catch(a=>{let r=a;throw r.stack=a.stack,r.name==="AbortError"?r=new P("Request aborted when reading from the stream"):r=new u("Error reading from the stream"),r})}}})}function Et(t){const e=t[t.length-1],n={promptFeedback:e?.promptFeedback};for(const s of t){if(s.candidates){let o=0;for(const i of s.candidates)if(n.candidates||(n.candidates=[]),n.candidates[o]||(n.candidates[o]={index:o}),n.candidates[o].citationMetadata=i.citationMetadata,n.candidates[o].groundingMetadata=i.groundingMetadata,n.candidates[o].finishReason=i.finishReason,n.candidates[o].finishMessage=i.finishMessage,n.candidates[o].safetyRatings=i.safetyRatings,i.content&&i.content.parts){n.candidates[o].content||(n.candidates[o].content={role:i.content.role||"user",parts:[]});const a={};for(const r of i.content.parts)r.text&&(a.text=r.text),r.functionCall&&(a.functionCall=r.functionCall),r.executableCode&&(a.executableCode=r.executableCode),r.codeExecutionResult&&(a.codeExecutionResult=r.codeExecutionResult),Object.keys(a).length===0&&(a.text=""),n.candidates[o].content.parts.push(a)}o++}s.usageMetadata&&(n.usageMetadata=s.usageMetadata)}return n}async function V(t,e,n,s){const o=await y(e,C.STREAM_GENERATE_CONTENT,t,!0,JSON.stringify(n),s);return ut(o)}async function J(t,e,n,s){const i=await(await y(e,C.GENERATE_CONTENT,t,!1,JSON.stringify(n),s)).json();return{response:N(i)}}function W(t){if(t!=null){if(typeof t=="string")return{role:"system",parts:[{text:t}]};if(t.text)return{role:"system",parts:[t]};if(t.parts)return t.role?t:{role:"system",parts:t.parts}}}function A(t){let e=[];if(typeof t=="string")e=[{text:t}];else for(const n of t)typeof n=="string"?e.push({text:n}):e.push(n);return Ct(e)}function Ct(t){const e={role:"user",parts:[]},n={role:"function",parts:[]};let s=!1,o=!1;for(const i of t)"functionResponse"in i?(n.parts.push(i),o=!0):(e.parts.push(i),s=!0);if(s&&o)throw new u("Within a single message, FunctionResponse cannot be mixed with other type of part in the request for sending chat message.");if(!s&&!o)throw new u("No content is provided for sending chat message.");return s?e:n}function _t(t,e){var n;let s={model:e?.model,generationConfig:e?.generationConfig,safetySettings:e?.safetySettings,tools:e?.tools,toolConfig:e?.toolConfig,systemInstruction:e?.systemInstruction,cachedContent:(n=e?.cachedContent)===null||n===void 0?void 0:n.name,contents:[]};const o=t.generateContentRequest!=null;if(t.contents){if(o)throw new E("CountTokensRequest must have one of contents or generateContentRequest, not both.");s.contents=t.contents}else if(o)s=Object.assign(Object.assign({},s),t.generateContentRequest);else{const i=A(t);s.contents=[i]}return{generateContentRequest:s}}function j(t){let e;return t.contents?e=t:e={contents:[A(t)]},t.systemInstruction&&(e.systemInstruction=W(t.systemInstruction)),e}function vt(t){return typeof t=="string"||Array.isArray(t)?{content:A(t)}:t}const K=["text","inlineData","functionCall","functionResponse","executableCode","codeExecutionResult"],Ot={user:["text","inlineData"],function:["functionResponse"],model:["text","functionCall","executableCode","codeExecutionResult"],system:["text"]};function It(t){let e=!1;for(const n of t){const{role:s,parts:o}=n;if(!e&&s!=="user")throw new u(`First content should be with role 'user', got ${s}`);if(!b.includes(s))throw new u(`Each item should include role field. Got ${s} but valid roles are: ${JSON.stringify(b)}`);if(!Array.isArray(o))throw new u("Content should have 'parts' property with an array of Parts");if(o.length===0)throw new u("Each Content should have at least one part");const i={text:0,inlineData:0,functionCall:0,functionResponse:0,fileData:0,executableCode:0,codeExecutionResult:0};for(const r of o)for(const d of K)d in r&&(i[d]+=1);const a=Ot[s];for(const r of K)if(!a.includes(r)&&i[r]>0)throw new u(`Content with role '${s}' can't contain '${r}' part`);e=!0}}function Y(t){var e;if(t.candidates===void 0||t.candidates.length===0)return!1;const n=(e=t.candidates[0])===null||e===void 0?void 0:e.content;if(n===void 0||n.parts===void 0||n.parts.length===0)return!1;for(const s of n.parts)if(s===void 0||Object.keys(s).length===0||s.text!==void 0&&s.text==="")return!1;return!0}const B="SILENT_ERROR";class Rt{constructor(e,n,s,o={}){this.model=n,this.params=s,this._requestOptions=o,this._history=[],this._sendPromise=Promise.resolve(),this._apiKey=e,s?.history&&(It(s.history),this._history=s.history)}async getHistory(){return await this._sendPromise,this._history}async sendMessage(e,n={}){var s,o,i,a,r,d;await this._sendPromise;const h=A(e),_={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(o=this.params)===null||o===void 0?void 0:o.generationConfig,tools:(i=this.params)===null||i===void 0?void 0:i.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(r=this.params)===null||r===void 0?void 0:r.systemInstruction,cachedContent:(d=this.params)===null||d===void 0?void 0:d.cachedContent,contents:[...this._history,h]},v=Object.assign(Object.assign({},this._requestOptions),n);let l;return this._sendPromise=this._sendPromise.then(()=>J(this._apiKey,this.model,_,v)).then(c=>{var f;if(Y(c.response)){this._history.push(h);const O=Object.assign({parts:[],role:"model"},(f=c.response.candidates)===null||f===void 0?void 0:f[0].content);this._history.push(O)}else{const O=g(c.response);O&&console.warn(`sendMessage() was unsuccessful. ${O}. Inspect response object for details.`)}l=c}).catch(c=>{throw this._sendPromise=Promise.resolve(),c}),await this._sendPromise,l}async sendMessageStream(e,n={}){var s,o,i,a,r,d;await this._sendPromise;const h=A(e),_={safetySettings:(s=this.params)===null||s===void 0?void 0:s.safetySettings,generationConfig:(o=this.params)===null||o===void 0?void 0:o.generationConfig,tools:(i=this.params)===null||i===void 0?void 0:i.tools,toolConfig:(a=this.params)===null||a===void 0?void 0:a.toolConfig,systemInstruction:(r=this.params)===null||r===void 0?void 0:r.systemInstruction,cachedContent:(d=this.params)===null||d===void 0?void 0:d.cachedContent,contents:[...this._history,h]},v=Object.assign(Object.assign({},this._requestOptions),n),l=V(this._apiKey,this.model,_,v);return this._sendPromise=this._sendPromise.then(()=>l).catch(c=>{throw new Error(B)}).then(c=>c.response).then(c=>{if(Y(c)){this._history.push(h);const f=Object.assign({},c.candidates[0].content);f.role||(f.role="model"),this._history.push(f)}else{const f=g(c);f&&console.warn(`sendMessageStream() was unsuccessful. ${f}. Inspect response object for details.`)}}).catch(c=>{c.message!==B&&console.error(c)}),l}}async function pt(t,e,n,s){return(await y(e,C.COUNT_TOKENS,t,!1,JSON.stringify(n),s)).json()}async function At(t,e,n,s){return(await y(e,C.EMBED_CONTENT,t,!1,JSON.stringify(n),s)).json()}async function yt(t,e,n,s){const o=n.requests.map(a=>Object.assign(Object.assign({},a),{model:e}));return(await y(e,C.BATCH_EMBED_CONTENTS,t,!1,JSON.stringify({requests:o}),s)).json()}class k{constructor(e,n,s={}){this.apiKey=e,this._requestOptions=s,n.model.includes("/")?this.model=n.model:this.model=`models/${n.model}`,this.generationConfig=n.generationConfig||{},this.safetySettings=n.safetySettings||[],this.tools=n.tools,this.toolConfig=n.toolConfig,this.systemInstruction=W(n.systemInstruction),this.cachedContent=n.cachedContent}async generateContent(e,n={}){var s;const o=j(e),i=Object.assign(Object.assign({},this._requestOptions),n);return J(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},o),i)}async generateContentStream(e,n={}){var s;const o=j(e),i=Object.assign(Object.assign({},this._requestOptions),n);return V(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(s=this.cachedContent)===null||s===void 0?void 0:s.name},o),i)}startChat(e){var n;return new Rt(this.apiKey,this.model,Object.assign({generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:(n=this.cachedContent)===null||n===void 0?void 0:n.name},e),this._requestOptions)}async countTokens(e,n={}){const s=_t(e,{model:this.model,generationConfig:this.generationConfig,safetySettings:this.safetySettings,tools:this.tools,toolConfig:this.toolConfig,systemInstruction:this.systemInstruction,cachedContent:this.cachedContent}),o=Object.assign(Object.assign({},this._requestOptions),n);return pt(this.apiKey,this.model,s,o)}async embedContent(e,n={}){const s=vt(e),o=Object.assign(Object.assign({},this._requestOptions),n);return At(this.apiKey,this.model,s,o)}async batchEmbedContents(e,n={}){const s=Object.assign(Object.assign({},this._requestOptions),n);return yt(this.apiKey,this.model,e,s)}}class St{constructor(e){this.apiKey=e}getGenerativeModel(e,n){if(!e.model)throw new u("Must provide a model name. Example: genai.getGenerativeModel({ model: 'my-model-name' })");return new k(this.apiKey,e,n)}getGenerativeModelFromCachedContent(e,n,s){if(!e.name)throw new E("Cached content must contain a `name` field.");if(!e.model)throw new E("Cached content must contain a `model` field.");const o=["model","systemInstruction"];for(const a of o)if(n?.[a]&&e[a]&&n?.[a]!==e[a]){if(a==="model"){const r=n.model.startsWith("models/")?n.model.replace("models/",""):n.model,d=e.model.startsWith("models/")?e.model.replace("models/",""):e.model;if(r===d)continue}throw new E(`Different value for "${a}" specified in modelParams (${n[a]}) and cachedContent (${e[a]})`)}const i=Object.assign(Object.assign({},n),{model:e.model,tools:e.tools,toolConfig:e.toolConfig,systemInstruction:e.systemInstruction,cachedContent:e});return new k(this.apiKey,i,s)}}export{G as BlockReason,Rt as ChatSession,H as DynamicRetrievalMode,m as ExecutableCodeLanguage,R as FinishReason,U as FunctionCallingMode,k as GenerativeModel,St as GoogleGenerativeAI,P as GoogleGenerativeAIAbortError,u as GoogleGenerativeAIError,q as GoogleGenerativeAIFetchError,E as GoogleGenerativeAIRequestInputError,I as GoogleGenerativeAIResponseError,L as HarmBlockThreshold,M as HarmCategory,D as HarmProbability,w as Outcome,b as POSSIBLE_ROLES,T as SchemaType,x as TaskType};
|