import{a as D,r as S,u as Dn,j as p,b as gr,c as Pi,f as ri,g as L0}from"./query-Bw69rE6b.js";import{r as Ev,e as P0}from"./react-CQKYBN-P.js";import{d as rt,b as En,M as Di,N as Jl,D as D0,C as j0,a6 as $0,a7 as Pe,a as fr,B as Et,U as Sv,X as Wr,Y as Yr,A as z0,a8 as F0,a9 as H0,aa as U0,q as ed,j as td,ab as B0,ac as G0,g as Cv,S as Nv,a4 as V0,Q as K0,p as W0,ad as Y0}from"./index-CoUu6FiM.js";import{P as X0}from"./PageHeader-qtVByY5c.js";import{M as ar}from"./Modal-t7k2CeNu.js";import{u as Z0,B as Q0,L as J0}from"./with-selector-DmmuW8RZ.js";import{A as Yd}from"./AlertDialog-IkMNJ6QG.js";import{T as e_}from"./table-BgcaxH7z.js";import{D as t_}from"./download-C1IJ2Fiw.js";import{U as Sl}from"./upload-DvIhupK8.js";import{A as n_}from"./arrow-down-to-line-CCt3pyba.js";import{C as Av}from"./code-xml-CnSqwYLd.js";/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const r_=[["path",{d:"m2 16 4.039-9.69a.5.5 0 0 1 .923 0L11 16",key:"d5nyq2"}],["path",{d:"M22 9v7",key:"pvm9v3"}],["path",{d:"M3.304 13h6.392",key:"1q3zxz"}],["circle",{cx:"18.5",cy:"12.5",r:"3.5",key:"z97x68"}]],i_=rt("case-sensitive",r_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const a_=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]],o_=rt("columns-3",a_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const s_=[["path",{d:"M14 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"1l7d7l"}],["path",{d:"M19 3a1 1 0 0 1 1 1v5a1 1 0 0 1-1 1",key:"9955pe"}],["path",{d:"m7 15 3 3",key:"4hkfgk"}],["path",{d:"m7 21 3-3H5a2 2 0 0 1-2-2v-2",key:"1xljwe"}],["rect",{x:"14",y:"14",width:"7",height:"7",rx:"1",key:"1cdgtw"}],["rect",{x:"3",y:"3",width:"7",height:"7",rx:"1",key:"zi3rio"}]],Tv=rt("combine",s_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const c_=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],u_=rt("file-code-corner",c_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const l_=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],d_=rt("file-plus",l_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const f_=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],h_=rt("folder-open",f_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const p_=[["path",{d:"M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z",key:"sc7q7i"}]],kv=rt("funnel",p_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const g_=[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]],m_=rt("grip-vertical",g_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const y_=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Rv=rt("image",y_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const v_=[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]],b_=rt("layout-grid",v_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const x_=[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]],__=rt("network",x_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const w_=[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]],E_=rt("redo-2",w_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const S_=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],C_=rt("save",S_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const N_=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],A_=rt("share-2",N_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const T_=[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]],k_=rt("star",T_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const R_=[["path",{d:"M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z",key:"1dfntj"}],["path",{d:"M15 3v5a1 1 0 0 0 1 1h5",key:"6s6qgf"}]],I_=rt("sticky-note",R_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const M_=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Iv=rt("type",M_);/**
 * @license lucide-react v0.577.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const q_=[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]],O_=rt("undo-2",q_);function ot(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=ot(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const L_={},Xd=e=>{let t;const n=new Set,r=(u,d)=>{const f=typeof u=="function"?u(t):u;if(!Object.is(f,t)){const h=t;t=d??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},i=()=>t,c={setState:r,getState:i,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(L_?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(r,i,c);return c},P_=e=>e?Xd(e):Xd,{useDebugValue:D_}=D,{useSyncExternalStoreWithSelector:j_}=Z0,$_=e=>e;function Mv(e,t=$_,n){const r=j_(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return D_(r),r}const Zd=(e,t)=>{const n=P_(e),r=(i,a=t)=>Mv(n,i,a);return Object.assign(r,n),r},z_=(e,t)=>e?Zd(e,t):Zd;function bt(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var F_={value:()=>{}};function ji(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new yi(n)}function yi(e){this._=e}function H_(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}yi.prototype=ji.prototype={constructor:yi,on:function(e,t){var n=this._,r=H_(e+"",n),i,a=-1,o=r.length;if(arguments.length<2){for(;++a<o;)if((i=(e=r[a]).type)&&(i=U_(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++a<o;)if(i=(e=r[a]).type)n[i]=Qd(n[i],e.name,t);else if(t==null)for(i in n)n[i]=Qd(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new yi(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,a;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(a=this._[e],r=0,i=a.length;r<i;++r)a[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,a=r.length;i<a;++i)r[i].value.apply(t,n)}};function U_(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function Qd(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=F_,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Cl="http://www.w3.org/1999/xhtml";const Jd={svg:"http://www.w3.org/2000/svg",xhtml:Cl,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function $i(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Jd.hasOwnProperty(t)?{space:Jd[t],local:e}:e}function B_(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cl&&t.documentElement.namespaceURI===Cl?t.createElement(e):t.createElementNS(n,e)}}function G_(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function qv(e){var t=$i(e);return(t.local?G_:B_)(t)}function V_(){}function nd(e){return e==null?V_:function(){return this.querySelector(e)}}function K_(e){typeof e!="function"&&(e=nd(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=new Array(o),c,l,u=0;u<o;++u)(c=a[u])&&(l=e.call(c,c.__data__,u,a))&&("__data__"in c&&(l.__data__=c.__data__),s[u]=l);return new Ct(r,this._parents)}function W_(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Y_(){return[]}function Ov(e){return e==null?Y_:function(){return this.querySelectorAll(e)}}function X_(e){return function(){return W_(e.apply(this,arguments))}}function Z_(e){typeof e=="function"?e=X_(e):e=Ov(e);for(var t=this._groups,n=t.length,r=[],i=[],a=0;a<n;++a)for(var o=t[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&(r.push(e.call(c,c.__data__,l,o)),i.push(c));return new Ct(r,i)}function Lv(e){return function(){return this.matches(e)}}function Pv(e){return function(t){return t.matches(e)}}var Q_=Array.prototype.find;function J_(e){return function(){return Q_.call(this.children,e)}}function e1(){return this.firstElementChild}function t1(e){return this.select(e==null?e1:J_(typeof e=="function"?e:Pv(e)))}var n1=Array.prototype.filter;function r1(){return Array.from(this.children)}function i1(e){return function(){return n1.call(this.children,e)}}function a1(e){return this.selectAll(e==null?r1:i1(typeof e=="function"?e:Pv(e)))}function o1(e){typeof e!="function"&&(e=Lv(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new Ct(r,this._parents)}function Dv(e){return new Array(e.length)}function s1(){return new Ct(this._enter||this._groups.map(Dv),this._parents)}function _i(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}_i.prototype={constructor:_i,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 c1(e){return function(){return e}}function u1(e,t,n,r,i,a){for(var o=0,s,c=t.length,l=a.length;o<l;++o)(s=t[o])?(s.__data__=a[o],r[o]=s):n[o]=new _i(e,a[o]);for(;o<c;++o)(s=t[o])&&(i[o]=s)}function l1(e,t,n,r,i,a,o){var s,c,l=new Map,u=t.length,d=a.length,f=new Array(u),h;for(s=0;s<u;++s)(c=t[s])&&(f[s]=h=o.call(c,c.__data__,s,t)+"",l.has(h)?i[s]=c:l.set(h,c));for(s=0;s<d;++s)h=o.call(e,a[s],s,a)+"",(c=l.get(h))?(r[s]=c,c.__data__=a[s],l.delete(h)):n[s]=new _i(e,a[s]);for(s=0;s<u;++s)(c=t[s])&&l.get(f[s])===c&&(i[s]=c)}function d1(e){return e.__data__}function f1(e,t){if(!arguments.length)return Array.from(this,d1);var n=t?l1:u1,r=this._parents,i=this._groups;typeof e!="function"&&(e=c1(e));for(var a=i.length,o=new Array(a),s=new Array(a),c=new Array(a),l=0;l<a;++l){var u=r[l],d=i[l],f=d.length,h=h1(e.call(u,u&&u.__data__,l,r)),g=h.length,m=s[l]=new Array(g),y=o[l]=new Array(g),v=c[l]=new Array(f);n(u,d,m,y,v,h,t);for(var b=0,E=0,_,T;b<g;++b)if(_=m[b]){for(b>=E&&(E=b+1);!(T=y[E])&&++E<g;);_._next=T||null}}return o=new Ct(o,r),o._enter=s,o._exit=c,o}function h1(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function p1(){return new Ct(this._exit||this._groups.map(Dv),this._parents)}function g1(e,t,n){var r=this.enter(),i=this,a=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?a.remove():n(a),r&&i?r.merge(i).order():i}function m1(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,a=r.length,o=Math.min(i,a),s=new Array(i),c=0;c<o;++c)for(var l=n[c],u=r[c],d=l.length,f=s[c]=new Array(d),h,g=0;g<d;++g)(h=l[g]||u[g])&&(f[g]=h);for(;c<i;++c)s[c]=n[c];return new Ct(s,this._parents)}function y1(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,a=r[i],o;--i>=0;)(o=r[i])&&(a&&o.compareDocumentPosition(a)^4&&a.parentNode.insertBefore(o,a),a=o);return this}function v1(e){e||(e=b1);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,r=n.length,i=new Array(r),a=0;a<r;++a){for(var o=n[a],s=o.length,c=i[a]=new Array(s),l,u=0;u<s;++u)(l=o[u])&&(c[u]=l);c.sort(t)}return new Ct(i,this._parents).order()}function b1(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function x1(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function _1(){return Array.from(this)}function w1(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length;i<a;++i){var o=r[i];if(o)return o}return null}function E1(){let e=0;for(const t of this)++e;return e}function S1(){return!this.node()}function C1(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],a=0,o=i.length,s;a<o;++a)(s=i[a])&&e.call(s,s.__data__,a,i);return this}function N1(e){return function(){this.removeAttribute(e)}}function A1(e){return function(){this.removeAttributeNS(e.space,e.local)}}function T1(e,t){return function(){this.setAttribute(e,t)}}function k1(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function R1(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function I1(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 M1(e,t){var n=$i(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?A1:N1:typeof t=="function"?n.local?I1:R1:n.local?k1:T1)(n,t))}function jv(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function q1(e){return function(){this.style.removeProperty(e)}}function O1(e,t,n){return function(){this.style.setProperty(e,t,n)}}function L1(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function P1(e,t,n){return arguments.length>1?this.each((t==null?q1:typeof t=="function"?L1:O1)(e,t,n??"")):hr(this.node(),e)}function hr(e,t){return e.style.getPropertyValue(t)||jv(e).getComputedStyle(e,null).getPropertyValue(t)}function D1(e){return function(){delete this[e]}}function j1(e,t){return function(){this[e]=t}}function $1(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function z1(e,t){return arguments.length>1?this.each((t==null?D1:typeof t=="function"?$1:j1)(e,t)):this.node()[e]}function $v(e){return e.trim().split(/^|\s+/)}function rd(e){return e.classList||new zv(e)}function zv(e){this._node=e,this._names=$v(e.getAttribute("class")||"")}zv.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 Fv(e,t){for(var n=rd(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Hv(e,t){for(var n=rd(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function F1(e){return function(){Fv(this,e)}}function H1(e){return function(){Hv(this,e)}}function U1(e,t){return function(){(t.apply(this,arguments)?Fv:Hv)(this,e)}}function B1(e,t){var n=$v(e+"");if(arguments.length<2){for(var r=rd(this.node()),i=-1,a=n.length;++i<a;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?U1:t?F1:H1)(n,t))}function G1(){this.textContent=""}function V1(e){return function(){this.textContent=e}}function K1(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function W1(e){return arguments.length?this.each(e==null?G1:(typeof e=="function"?K1:V1)(e)):this.node().textContent}function Y1(){this.innerHTML=""}function X1(e){return function(){this.innerHTML=e}}function Z1(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Q1(e){return arguments.length?this.each(e==null?Y1:(typeof e=="function"?Z1:X1)(e)):this.node().innerHTML}function J1(){this.nextSibling&&this.parentNode.appendChild(this)}function ew(){return this.each(J1)}function tw(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function nw(){return this.each(tw)}function rw(e){var t=typeof e=="function"?e:qv(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function iw(){return null}function aw(e,t){var n=typeof e=="function"?e:qv(e),r=t==null?iw:typeof t=="function"?t:nd(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function ow(){var e=this.parentNode;e&&e.removeChild(this)}function sw(){return this.each(ow)}function cw(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function uw(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function lw(e){return this.select(e?uw:cw)}function dw(e){return arguments.length?this.property("__data__",e):this.node().__data__}function fw(e){return function(t){e.call(this,t,this.__data__)}}function hw(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function pw(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,a;n<i;++n)a=t[n],(!e.type||a.type===e.type)&&a.name===e.name?this.removeEventListener(a.type,a.listener,a.options):t[++r]=a;++r?t.length=r:delete this.__on}}}function gw(e,t,n){return function(){var r=this.__on,i,a=fw(t);if(r){for(var o=0,s=r.length;o<s;++o)if((i=r[o]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=a,i.options=n),i.value=t;return}}this.addEventListener(e.type,a,n),i={type:e.type,name:e.name,value:t,listener:a,options:n},r?r.push(i):this.__on=[i]}}function mw(e,t,n){var r=hw(e+""),i,a=r.length,o;if(arguments.length<2){var s=this.node().__on;if(s){for(var c=0,l=s.length,u;c<l;++c)for(i=0,u=s[c];i<a;++i)if((o=r[i]).type===u.type&&o.name===u.name)return u.value}return}for(s=t?gw:pw,i=0;i<a;++i)this.each(s(r[i],t,n));return this}function Uv(e,t,n){var r=jv(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function yw(e,t){return function(){return Uv(this,e,t)}}function vw(e,t){return function(){return Uv(this,e,t.apply(this,arguments))}}function bw(e,t){return this.each((typeof t=="function"?vw:yw)(e,t))}function*xw(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,a=r.length,o;i<a;++i)(o=r[i])&&(yield o)}var Bv=[null];function Ct(e,t){this._groups=e,this._parents=t}function Xr(){return new Ct([[document.documentElement]],Bv)}function _w(){return this}Ct.prototype=Xr.prototype={constructor:Ct,select:K_,selectAll:Z_,selectChild:t1,selectChildren:a1,filter:o1,data:f1,enter:s1,exit:p1,join:g1,merge:m1,selection:_w,order:y1,sort:v1,call:x1,nodes:_1,node:w1,size:E1,empty:S1,each:C1,attr:M1,style:P1,property:z1,classed:B1,text:W1,html:Q1,raise:ew,lower:nw,append:rw,insert:aw,remove:sw,clone:lw,datum:dw,on:mw,dispatch:bw,[Symbol.iterator]:xw};function Tt(e){return typeof e=="string"?new Ct([[document.querySelector(e)]],[document.documentElement]):new Ct([[e]],Bv)}function ww(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ht(e,t){if(e=ww(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ew={passive:!1},Fr={capture:!0,passive:!1};function pa(e){e.stopImmediatePropagation()}function sr(e){e.preventDefault(),e.stopImmediatePropagation()}function Gv(e){var t=e.document.documentElement,n=Tt(e).on("dragstart.drag",sr,Fr);"onselectstart"in t?n.on("selectstart.drag",sr,Fr):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Vv(e,t){var n=e.document.documentElement,r=Tt(e).on("dragstart.drag",null);t&&(r.on("click.drag",sr,Fr),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const ii=e=>()=>e;function Nl(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}Nl.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Sw(e){return!e.ctrlKey&&!e.button}function Cw(){return this.parentNode}function Nw(e,t){return t??{x:e.x,y:e.y}}function Aw(){return navigator.maxTouchPoints||"ontouchstart"in this}function Kv(){var e=Sw,t=Cw,n=Nw,r=Aw,i={},a=ji("start","drag","end"),o=0,s,c,l,u,d=0;function f(_){_.on("mousedown.drag",h).filter(r).on("touchstart.drag",y).on("touchmove.drag",v,Ew).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(_,T){if(!(u||!e.call(this,_,T))){var N=E(this,t.call(this,_,T),_,T,"mouse");N&&(Tt(_.view).on("mousemove.drag",g,Fr).on("mouseup.drag",m,Fr),Gv(_.view),pa(_),l=!1,s=_.clientX,c=_.clientY,N("start",_))}}function g(_){if(sr(_),!l){var T=_.clientX-s,N=_.clientY-c;l=T*T+N*N>d}i.mouse("drag",_)}function m(_){Tt(_.view).on("mousemove.drag mouseup.drag",null),Vv(_.view,l),sr(_),i.mouse("end",_)}function y(_,T){if(e.call(this,_,T)){var N=_.changedTouches,q=t.call(this,_,T),L=N.length,O,R;for(O=0;O<L;++O)(R=E(this,q,_,T,N[O].identifier,N[O]))&&(pa(_),R("start",_,N[O]))}}function v(_){var T=_.changedTouches,N=T.length,q,L;for(q=0;q<N;++q)(L=i[T[q].identifier])&&(sr(_),L("drag",_,T[q]))}function b(_){var T=_.changedTouches,N=T.length,q,L;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),q=0;q<N;++q)(L=i[T[q].identifier])&&(pa(_),L("end",_,T[q]))}function E(_,T,N,q,L,O){var R=a.copy(),I=Ht(O||N,T),G,H,x;if((x=n.call(_,new Nl("beforestart",{sourceEvent:N,target:f,identifier:L,active:o,x:I[0],y:I[1],dx:0,dy:0,dispatch:R}),q))!=null)return G=x.x-I[0]||0,H=x.y-I[1]||0,function M(k,z,P){var C=I,j;switch(k){case"start":i[L]=M,j=o++;break;case"end":delete i[L],--o;case"drag":I=Ht(P||z,T),j=o;break}R.call(k,_,new Nl(k,{sourceEvent:z,subject:x,target:f,identifier:L,active:j,x:I[0]+G,y:I[1]+H,dx:I[0]-C[0],dy:I[1]-C[1],dispatch:R}),q)}}return f.filter=function(_){return arguments.length?(e=typeof _=="function"?_:ii(!!_),f):e},f.container=function(_){return arguments.length?(t=typeof _=="function"?_:ii(_),f):t},f.subject=function(_){return arguments.length?(n=typeof _=="function"?_:ii(_),f):n},f.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:ii(!!_),f):r},f.on=function(){var _=a.on.apply(a,arguments);return _===a?f:_},f.clickDistance=function(_){return arguments.length?(d=(_=+_)*_,f):Math.sqrt(d)},f}function id(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Wv(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Zr(){}var Hr=.7,wi=1/Hr,cr="\\s*([+-]?\\d+)\\s*",Ur="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Bt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Tw=/^#([0-9a-f]{3,8})$/,kw=new RegExp(`^rgb\\(${cr},${cr},${cr}\\)$`),Rw=new RegExp(`^rgb\\(${Bt},${Bt},${Bt}\\)$`),Iw=new RegExp(`^rgba\\(${cr},${cr},${cr},${Ur}\\)$`),Mw=new RegExp(`^rgba\\(${Bt},${Bt},${Bt},${Ur}\\)$`),qw=new RegExp(`^hsl\\(${Ur},${Bt},${Bt}\\)$`),Ow=new RegExp(`^hsla\\(${Ur},${Bt},${Bt},${Ur}\\)$`),ef={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};id(Zr,Br,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:tf,formatHex:tf,formatHex8:Lw,formatHsl:Pw,formatRgb:nf,toString:nf});function tf(){return this.rgb().formatHex()}function Lw(){return this.rgb().formatHex8()}function Pw(){return Yv(this).formatHsl()}function nf(){return this.rgb().formatRgb()}function Br(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Tw.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?rf(t):n===3?new yt(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ai(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ai(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=kw.exec(e))?new yt(t[1],t[2],t[3],1):(t=Rw.exec(e))?new yt(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Iw.exec(e))?ai(t[1],t[2],t[3],t[4]):(t=Mw.exec(e))?ai(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=qw.exec(e))?sf(t[1],t[2]/100,t[3]/100,1):(t=Ow.exec(e))?sf(t[1],t[2]/100,t[3]/100,t[4]):ef.hasOwnProperty(e)?rf(ef[e]):e==="transparent"?new yt(NaN,NaN,NaN,0):null}function rf(e){return new yt(e>>16&255,e>>8&255,e&255,1)}function ai(e,t,n,r){return r<=0&&(e=t=n=NaN),new yt(e,t,n,r)}function Dw(e){return e instanceof Zr||(e=Br(e)),e?(e=e.rgb(),new yt(e.r,e.g,e.b,e.opacity)):new yt}function Al(e,t,n,r){return arguments.length===1?Dw(e):new yt(e,t,n,r??1)}function yt(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}id(yt,Al,Wv(Zr,{brighter(e){return e=e==null?wi:Math.pow(wi,e),new yt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Hr:Math.pow(Hr,e),new yt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new yt(On(this.r),On(this.g),On(this.b),Ei(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:af,formatHex:af,formatHex8:jw,formatRgb:of,toString:of}));function af(){return`#${In(this.r)}${In(this.g)}${In(this.b)}`}function jw(){return`#${In(this.r)}${In(this.g)}${In(this.b)}${In((isNaN(this.opacity)?1:this.opacity)*255)}`}function of(){const e=Ei(this.opacity);return`${e===1?"rgb(":"rgba("}${On(this.r)}, ${On(this.g)}, ${On(this.b)}${e===1?")":`, ${e})`}`}function Ei(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function On(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function In(e){return e=On(e),(e<16?"0":"")+e.toString(16)}function sf(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Lt(e,t,n,r)}function Yv(e){if(e instanceof Lt)return new Lt(e.h,e.s,e.l,e.opacity);if(e instanceof Zr||(e=Br(e)),!e)return new Lt;if(e instanceof Lt)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),a=Math.max(t,n,r),o=NaN,s=a-i,c=(a+i)/2;return s?(t===a?o=(n-r)/s+(n<r)*6:n===a?o=(r-t)/s+2:o=(t-n)/s+4,s/=c<.5?a+i:2-a-i,o*=60):s=c>0&&c<1?0:o,new Lt(o,s,c,e.opacity)}function $w(e,t,n,r){return arguments.length===1?Yv(e):new Lt(e,t,n,r??1)}function Lt(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}id(Lt,$w,Wv(Zr,{brighter(e){return e=e==null?wi:Math.pow(wi,e),new Lt(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Hr:Math.pow(Hr,e),new Lt(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new yt(ga(e>=240?e-240:e+120,i,r),ga(e,i,r),ga(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Lt(cf(this.h),oi(this.s),oi(this.l),Ei(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=Ei(this.opacity);return`${e===1?"hsl(":"hsla("}${cf(this.h)}, ${oi(this.s)*100}%, ${oi(this.l)*100}%${e===1?")":`, ${e})`}`}}));function cf(e){return e=(e||0)%360,e<0?e+360:e}function oi(e){return Math.max(0,Math.min(1,e||0))}function ga(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 Xv=e=>()=>e;function zw(e,t){return function(n){return e+n*t}}function Fw(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function Hw(e){return(e=+e)==1?Zv:function(t,n){return n-t?Fw(t,n,e):Xv(isNaN(t)?n:t)}}function Zv(e,t){var n=t-e;return n?zw(e,n):Xv(isNaN(e)?t:e)}const uf=function e(t){var n=Hw(t);function r(i,a){var o=n((i=Al(i)).r,(a=Al(a)).r),s=n(i.g,a.g),c=n(i.b,a.b),l=Zv(i.opacity,a.opacity);return function(u){return i.r=o(u),i.g=s(u),i.b=c(u),i.opacity=l(u),i+""}}return r.gamma=e,r}(1);function fn(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Tl=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ma=new RegExp(Tl.source,"g");function Uw(e){return function(){return e}}function Bw(e){return function(t){return e(t)+""}}function Gw(e,t){var n=Tl.lastIndex=ma.lastIndex=0,r,i,a,o=-1,s=[],c=[];for(e=e+"",t=t+"";(r=Tl.exec(e))&&(i=ma.exec(t));)(a=i.index)>n&&(a=t.slice(n,a),s[o]?s[o]+=a:s[++o]=a),(r=r[0])===(i=i[0])?s[o]?s[o]+=i:s[++o]=i:(s[++o]=null,c.push({i:o,x:fn(r,i)})),n=ma.lastIndex;return n<t.length&&(a=t.slice(n),s[o]?s[o]+=a:s[++o]=a),s.length<2?c[0]?Bw(c[0].x):Uw(t):(t=c.length,function(l){for(var u=0,d;u<t;++u)s[(d=c[u]).i]=d.x(l);return s.join("")})}var lf=180/Math.PI,kl={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Qv(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*lf,skewX:Math.atan(c)*lf,scaleX:o,scaleY:s}}var si;function Vw(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?kl:Qv(t.a,t.b,t.c,t.d,t.e,t.f)}function Kw(e){return e==null||(si||(si=document.createElementNS("http://www.w3.org/2000/svg","g")),si.setAttribute("transform",e),!(e=si.transform.baseVal.consolidate()))?kl:(e=e.matrix,Qv(e.a,e.b,e.c,e.d,e.e,e.f))}function Jv(e,t,n,r){function i(l){return l.length?l.pop()+" ":""}function a(l,u,d,f,h,g){if(l!==d||u!==f){var m=h.push("translate(",null,t,null,n);g.push({i:m-4,x:fn(l,d)},{i:m-2,x:fn(u,f)})}else(d||f)&&h.push("translate("+d+t+f+n)}function o(l,u,d,f){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),f.push({i:d.push(i(d)+"rotate(",null,r)-2,x:fn(l,u)})):u&&d.push(i(d)+"rotate("+u+r)}function s(l,u,d,f){l!==u?f.push({i:d.push(i(d)+"skewX(",null,r)-2,x:fn(l,u)}):u&&d.push(i(d)+"skewX("+u+r)}function c(l,u,d,f,h,g){if(l!==d||u!==f){var m=h.push(i(h)+"scale(",null,",",null,")");g.push({i:m-4,x:fn(l,d)},{i:m-2,x:fn(u,f)})}else(d!==1||f!==1)&&h.push(i(h)+"scale("+d+","+f+")")}return function(l,u){var d=[],f=[];return l=e(l),u=e(u),a(l.translateX,l.translateY,u.translateX,u.translateY,d,f),o(l.rotate,u.rotate,d,f),s(l.skewX,u.skewX,d,f),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,d,f),l=u=null,function(h){for(var g=-1,m=f.length,y;++g<m;)d[(y=f[g]).i]=y.x(h);return d.join("")}}}var Ww=Jv(Vw,"px, ","px)","deg)"),Yw=Jv(Kw,", ",")",")"),Xw=1e-12;function df(e){return((e=Math.exp(e))+1/e)/2}function Zw(e){return((e=Math.exp(e))-1/e)/2}function Qw(e){return((e=Math.exp(2*e))-1)/(e+1)}const Jw=function e(t,n,r){function i(a,o){var s=a[0],c=a[1],l=a[2],u=o[0],d=o[1],f=o[2],h=u-s,g=d-c,m=h*h+g*g,y,v;if(m<Xw)v=Math.log(f/l)/t,y=function(q){return[s+q*h,c+q*g,l*Math.exp(t*q*v)]};else{var b=Math.sqrt(m),E=(f*f-l*l+r*m)/(2*l*n*b),_=(f*f-l*l-r*m)/(2*f*n*b),T=Math.log(Math.sqrt(E*E+1)-E),N=Math.log(Math.sqrt(_*_+1)-_);v=(N-T)/t,y=function(q){var L=q*v,O=df(T),R=l/(n*b)*(O*Qw(t*L+T)-Zw(T));return[s+R*h,c+R*g,l*O/df(t*L+T)]}}return y.duration=v*1e3*t/Math.SQRT2,y}return i.rho=function(a){var o=Math.max(.001,+a),s=o*o,c=s*s;return e(o,s,c)},i}(Math.SQRT2,2,4);var pr=0,Rr=0,Er=0,eb=1e3,Si,Ir,Ci=0,Ln=0,zi=0,Gr=typeof performance=="object"&&performance.now?performance:Date,tb=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ad(){return Ln||(tb(eE),Ln=Gr.now()+zi)}function eE(){Ln=0}function Ni(){this._call=this._time=this._next=null}Ni.prototype=nb.prototype={constructor:Ni,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ad():+n)+(t==null?0:+t),!this._next&&Ir!==this&&(Ir?Ir._next=this:Si=this,Ir=this),this._call=e,this._time=n,Rl()},stop:function(){this._call&&(this._call=null,this._time=1/0,Rl())}};function nb(e,t,n){var r=new Ni;return r.restart(e,t,n),r}function tE(){ad(),++pr;for(var e=Si,t;e;)(t=Ln-e._time)>=0&&e._call.call(void 0,t),e=e._next;--pr}function ff(){Ln=(Ci=Gr.now())+zi,pr=Rr=0;try{tE()}finally{pr=0,rE(),Ln=0}}function nE(){var e=Gr.now(),t=e-Ci;t>eb&&(zi-=t,Ci=e)}function rE(){for(var e,t=Si,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Si=n);Ir=e,Rl(r)}function Rl(e){if(!pr){Rr&&(Rr=clearTimeout(Rr));var t=e-Ln;t>24?(e<1/0&&(Rr=setTimeout(ff,e-Gr.now()-zi)),Er&&(Er=clearInterval(Er))):(Er||(Ci=Gr.now(),Er=setInterval(nE,eb)),pr=1,tb(ff))}}function hf(e,t,n){var r=new Ni;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var iE=ji("start","end","cancel","interrupt"),aE=[],rb=0,pf=1,Il=2,vi=3,gf=4,Ml=5,bi=6;function Fi(e,t,n,r,i,a){var o=e.__transition;if(!o)e.__transition={};else if(n in o)return;oE(e,n,{name:t,index:r,group:i,on:iE,tween:aE,time:a.time,delay:a.delay,duration:a.duration,ease:a.ease,timer:null,state:rb})}function od(e,t){var n=Dt(e,t);if(n.state>rb)throw new Error("too late; already scheduled");return n}function Gt(e,t){var n=Dt(e,t);if(n.state>vi)throw new Error("too late; already running");return n}function Dt(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function oE(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=nb(a,0,n.time);function a(l){n.state=pf,n.timer.restart(o,n.delay,n.time),n.delay<=l&&o(l-n.delay)}function o(l){var u,d,f,h;if(n.state!==pf)return c();for(u in r)if(h=r[u],h.name===n.name){if(h.state===vi)return hf(o);h.state===gf?(h.state=bi,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[u]):+u<t&&(h.state=bi,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[u])}if(hf(function(){n.state===vi&&(n.state=gf,n.timer.restart(s,n.delay,n.time),s(l))}),n.state=Il,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Il){for(n.state=vi,i=new Array(f=n.tween.length),u=0,d=-1;u<f;++u)(h=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(i[++d]=h);i.length=d+1}}function s(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Ml,1),d=-1,f=i.length;++d<f;)i[d].call(e,u);n.state===Ml&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=bi,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function xi(e,t){var n=e.__transition,r,i,a=!0,o;if(n){t=t==null?null:t+"";for(o in n){if((r=n[o]).name!==t){a=!1;continue}i=r.state>Il&&r.state<Ml,r.state=bi,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[o]}a&&delete e.__transition}}function sE(e){return this.each(function(){xi(this,e)})}function cE(e,t){var n,r;return function(){var i=Gt(this,e),a=i.tween;if(a!==n){r=n=a;for(var o=0,s=r.length;o<s;++o)if(r[o].name===t){r=r.slice(),r.splice(o,1);break}}i.tween=r}}function uE(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var a=Gt(this,e),o=a.tween;if(o!==r){i=(r=o).slice();for(var s={name:t,value:n},c=0,l=i.length;c<l;++c)if(i[c].name===t){i[c]=s;break}c===l&&i.push(s)}a.tween=i}}function lE(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Dt(this.node(),n).tween,i=0,a=r.length,o;i<a;++i)if((o=r[i]).name===e)return o.value;return null}return this.each((t==null?cE:uE)(n,e,t))}function sd(e,t,n){var r=e._id;return e.each(function(){var i=Gt(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return Dt(i,r).value[t]}}function ib(e,t){var n;return(typeof t=="number"?fn:t instanceof Br?uf:(n=Br(t))?(t=n,uf):Gw)(e,t)}function dE(e){return function(){this.removeAttribute(e)}}function fE(e){return function(){this.removeAttributeNS(e.space,e.local)}}function hE(e,t,n){var r,i=n+"",a;return function(){var o=this.getAttribute(e);return o===i?null:o===r?a:a=t(r=o,n)}}function pE(e,t,n){var r,i=n+"",a;return function(){var o=this.getAttributeNS(e.space,e.local);return o===i?null:o===r?a:a=t(r=o,n)}}function gE(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttribute(e):(o=this.getAttribute(e),c=s+"",o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function mE(e,t,n){var r,i,a;return function(){var o,s=n(this),c;return s==null?void this.removeAttributeNS(e.space,e.local):(o=this.getAttributeNS(e.space,e.local),c=s+"",o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s)))}}function yE(e,t){var n=$i(e),r=n==="transform"?Yw:ib;return this.attrTween(e,typeof t=="function"?(n.local?mE:gE)(n,r,sd(this,"attr."+e,t)):t==null?(n.local?fE:dE)(n):(n.local?pE:hE)(n,r,t))}function vE(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function bE(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function xE(e,t){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&bE(e,a)),n}return i._value=t,i}function _E(e,t){var n,r;function i(){var a=t.apply(this,arguments);return a!==r&&(n=(r=a)&&vE(e,a)),n}return i._value=t,i}function wE(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=$i(e);return this.tween(n,(r.local?xE:_E)(r,t))}function EE(e,t){return function(){od(this,e).delay=+t.apply(this,arguments)}}function SE(e,t){return t=+t,function(){od(this,e).delay=t}}function CE(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?EE:SE)(t,e)):Dt(this.node(),t).delay}function NE(e,t){return function(){Gt(this,e).duration=+t.apply(this,arguments)}}function AE(e,t){return t=+t,function(){Gt(this,e).duration=t}}function TE(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?NE:AE)(t,e)):Dt(this.node(),t).duration}function kE(e,t){if(typeof t!="function")throw new Error;return function(){Gt(this,e).ease=t}}function RE(e){var t=this._id;return arguments.length?this.each(kE(t,e)):Dt(this.node(),t).ease}function IE(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Gt(this,e).ease=n}}function ME(e){if(typeof e!="function")throw new Error;return this.each(IE(this._id,e))}function qE(e){typeof e!="function"&&(e=Lv(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var a=t[i],o=a.length,s=r[i]=[],c,l=0;l<o;++l)(c=a[l])&&e.call(c,c.__data__,l,a)&&s.push(c);return new an(r,this._parents,this._name,this._id)}function OE(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,a=Math.min(r,i),o=new Array(r),s=0;s<a;++s)for(var c=t[s],l=n[s],u=c.length,d=o[s]=new Array(u),f,h=0;h<u;++h)(f=c[h]||l[h])&&(d[h]=f);for(;s<r;++s)o[s]=t[s];return new an(o,this._parents,this._name,this._id)}function LE(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 PE(e,t,n){var r,i,a=LE(t)?od:Gt;return function(){var o=a(this,e),s=o.on;s!==r&&(i=(r=s).copy()).on(t,n),o.on=i}}function DE(e,t){var n=this._id;return arguments.length<2?Dt(this.node(),n).on.on(e):this.each(PE(n,e,t))}function jE(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function $E(){return this.on("end.remove",jE(this._id))}function zE(e){var t=this._name,n=this._id;typeof e!="function"&&(e=nd(e));for(var r=this._groups,i=r.length,a=new Array(i),o=0;o<i;++o)for(var s=r[o],c=s.length,l=a[o]=new Array(c),u,d,f=0;f<c;++f)(u=s[f])&&(d=e.call(u,u.__data__,f,s))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d,Fi(l[f],t,n,f,l,Dt(u,n)));return new an(a,this._parents,t,n)}function FE(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ov(e));for(var r=this._groups,i=r.length,a=[],o=[],s=0;s<i;++s)for(var c=r[s],l=c.length,u,d=0;d<l;++d)if(u=c[d]){for(var f=e.call(u,u.__data__,d,c),h,g=Dt(u,n),m=0,y=f.length;m<y;++m)(h=f[m])&&Fi(h,t,n,m,f,g);a.push(f),o.push(u)}return new an(a,o,t,n)}var HE=Xr.prototype.constructor;function UE(){return new HE(this._groups,this._parents)}function BE(e,t){var n,r,i;return function(){var a=hr(this,e),o=(this.style.removeProperty(e),hr(this,e));return a===o?null:a===n&&o===r?i:i=t(n=a,r=o)}}function ab(e){return function(){this.style.removeProperty(e)}}function GE(e,t,n){var r,i=n+"",a;return function(){var o=hr(this,e);return o===i?null:o===r?a:a=t(r=o,n)}}function VE(e,t,n){var r,i,a;return function(){var o=hr(this,e),s=n(this),c=s+"";return s==null&&(c=s=(this.style.removeProperty(e),hr(this,e))),o===c?null:o===r&&c===i?a:(i=c,a=t(r=o,s))}}function KE(e,t){var n,r,i,a="style."+t,o="end."+a,s;return function(){var c=Gt(this,e),l=c.on,u=c.value[a]==null?s||(s=ab(t)):void 0;(l!==n||i!==u)&&(r=(n=l).copy()).on(o,i=u),c.on=r}}function WE(e,t,n){var r=(e+="")=="transform"?Ww:ib;return t==null?this.styleTween(e,BE(e,r)).on("end.style."+e,ab(e)):typeof t=="function"?this.styleTween(e,VE(e,r,sd(this,"style."+e,t))).each(KE(this._id,e)):this.styleTween(e,GE(e,r,t),n).on("end.style."+e,null)}function YE(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function XE(e,t,n){var r,i;function a(){var o=t.apply(this,arguments);return o!==i&&(r=(i=o)&&YE(e,o,n)),r}return a._value=t,a}function ZE(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,XE(e,t,n??""))}function QE(e){return function(){this.textContent=e}}function JE(e){return function(){var t=e(this);this.textContent=t??""}}function eS(e){return this.tween("text",typeof e=="function"?JE(sd(this,"text",e)):QE(e==null?"":e+""))}function tS(e){return function(t){this.textContent=e.call(this,t)}}function nS(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&tS(i)),t}return r._value=e,r}function rS(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,nS(e))}function iS(){for(var e=this._name,t=this._id,n=ob(),r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)if(c=o[l]){var u=Dt(c,t);Fi(c,e,n,l,o,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new an(r,this._parents,e,n)}function aS(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(a,o){var s={value:o},c={value:function(){--i===0&&a()}};n.each(function(){var l=Gt(this,r),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(c)),l.on=t}),i===0&&a()})}var oS=0;function an(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ob(){return++oS}var Qt=Xr.prototype;an.prototype={constructor:an,select:zE,selectAll:FE,selectChild:Qt.selectChild,selectChildren:Qt.selectChildren,filter:qE,merge:OE,selection:UE,transition:iS,call:Qt.call,nodes:Qt.nodes,node:Qt.node,size:Qt.size,empty:Qt.empty,each:Qt.each,on:DE,attr:yE,attrTween:wE,style:WE,styleTween:ZE,text:eS,textTween:rS,remove:$E,tween:lE,delay:CE,duration:TE,ease:RE,easeVarying:ME,end:aS,[Symbol.iterator]:Qt[Symbol.iterator]};function sS(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var cS={time:null,delay:0,duration:250,ease:sS};function uS(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 lS(e){var t,n;e instanceof an?(t=e._id,e=e._name):(t=ob(),(n=cS).time=ad(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,a=0;a<i;++a)for(var o=r[a],s=o.length,c,l=0;l<s;++l)(c=o[l])&&Fi(c,e,t,l,o,n||uS(c,t));return new an(r,this._parents,e,t)}Xr.prototype.interrupt=sE;Xr.prototype.transition=lS;const ci=e=>()=>e;function dS(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function en(e,t,n){this.k=e,this.x=t,this.y=n}en.prototype={constructor:en,scale:function(e){return e===1?this:new en(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new en(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 mn=new en(1,0,0);en.prototype;function ya(e){e.stopImmediatePropagation()}function Sr(e){e.preventDefault(),e.stopImmediatePropagation()}function fS(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function hS(){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 mf(){return this.__zoom||mn}function pS(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function gS(){return navigator.maxTouchPoints||"ontouchstart"in this}function mS(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],o=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),o>a?(a+o)/2:Math.min(0,a)||Math.max(0,o))}function yS(){var e=fS,t=hS,n=mS,r=pS,i=gS,a=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],s=250,c=Jw,l=ji("start","zoom","end"),u,d,f,h=500,g=150,m=0,y=10;function v(x){x.property("__zoom",mf).on("wheel.zoom",L,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",R).filter(i).on("touchstart.zoom",I).on("touchmove.zoom",G).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(x,M,k,z){var P=x.selection?x.selection():x;P.property("__zoom",mf),x!==P?T(x,M,k,z):P.interrupt().each(function(){N(this,arguments).event(z).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},v.scaleBy=function(x,M,k,z){v.scaleTo(x,function(){var P=this.__zoom.k,C=typeof M=="function"?M.apply(this,arguments):M;return P*C},k,z)},v.scaleTo=function(x,M,k,z){v.transform(x,function(){var P=t.apply(this,arguments),C=this.__zoom,j=k==null?_(P):typeof k=="function"?k.apply(this,arguments):k,$=C.invert(j),U=typeof M=="function"?M.apply(this,arguments):M;return n(E(b(C,U),j,$),P,o)},k,z)},v.translateBy=function(x,M,k,z){v.transform(x,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof k=="function"?k.apply(this,arguments):k),t.apply(this,arguments),o)},null,z)},v.translateTo=function(x,M,k,z,P){v.transform(x,function(){var C=t.apply(this,arguments),j=this.__zoom,$=z==null?_(C):typeof z=="function"?z.apply(this,arguments):z;return n(mn.translate($[0],$[1]).scale(j.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof k=="function"?-k.apply(this,arguments):-k),C,o)},z,P)};function b(x,M){return M=Math.max(a[0],Math.min(a[1],M)),M===x.k?x:new en(M,x.x,x.y)}function E(x,M,k){var z=M[0]-k[0]*x.k,P=M[1]-k[1]*x.k;return z===x.x&&P===x.y?x:new en(x.k,z,P)}function _(x){return[(+x[0][0]+ +x[1][0])/2,(+x[0][1]+ +x[1][1])/2]}function T(x,M,k,z){x.on("start.zoom",function(){N(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(z).end()}).tween("zoom",function(){var P=this,C=arguments,j=N(P,C).event(z),$=t.apply(P,C),U=k==null?_($):typeof k=="function"?k.apply(P,C):k,K=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),V=P.__zoom,se=typeof M=="function"?M.apply(P,C):M,re=c(V.invert(U).concat(K/V.k),se.invert(U).concat(K/se.k));return function(de){if(de===1)de=se;else{var ie=re(de),he=K/ie[2];de=new en(he,U[0]-ie[0]*he,U[1]-ie[1]*he)}j.zoom(null,de)}})}function N(x,M,k){return!k&&x.__zooming||new q(x,M)}function q(x,M){this.that=x,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(x,M),this.taps=0}q.prototype={event:function(x){return x&&(this.sourceEvent=x),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(x,M){return this.mouse&&x!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&x!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&x!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(x){var M=Tt(this.that).datum();l.call(x,this.that,new dS(x,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:l}),M)}};function L(x,...M){if(!e.apply(this,arguments))return;var k=N(this,M).event(x),z=this.__zoom,P=Math.max(a[0],Math.min(a[1],z.k*Math.pow(2,r.apply(this,arguments)))),C=Ht(x);if(k.wheel)(k.mouse[0][0]!==C[0]||k.mouse[0][1]!==C[1])&&(k.mouse[1]=z.invert(k.mouse[0]=C)),clearTimeout(k.wheel);else{if(z.k===P)return;k.mouse=[C,z.invert(C)],xi(this),k.start()}Sr(x),k.wheel=setTimeout(j,g),k.zoom("mouse",n(E(b(z,P),k.mouse[0],k.mouse[1]),k.extent,o));function j(){k.wheel=null,k.end()}}function O(x,...M){if(f||!e.apply(this,arguments))return;var k=x.currentTarget,z=N(this,M,!0).event(x),P=Tt(x.view).on("mousemove.zoom",U,!0).on("mouseup.zoom",K,!0),C=Ht(x,k),j=x.clientX,$=x.clientY;Gv(x.view),ya(x),z.mouse=[C,this.__zoom.invert(C)],xi(this),z.start();function U(V){if(Sr(V),!z.moved){var se=V.clientX-j,re=V.clientY-$;z.moved=se*se+re*re>m}z.event(V).zoom("mouse",n(E(z.that.__zoom,z.mouse[0]=Ht(V,k),z.mouse[1]),z.extent,o))}function K(V){P.on("mousemove.zoom mouseup.zoom",null),Vv(V.view,z.moved),Sr(V),z.event(V).end()}}function R(x,...M){if(e.apply(this,arguments)){var k=this.__zoom,z=Ht(x.changedTouches?x.changedTouches[0]:x,this),P=k.invert(z),C=k.k*(x.shiftKey?.5:2),j=n(E(b(k,C),z,P),t.apply(this,M),o);Sr(x),s>0?Tt(this).transition().duration(s).call(T,j,z,x):Tt(this).call(v.transform,j,z,x)}}function I(x,...M){if(e.apply(this,arguments)){var k=x.touches,z=k.length,P=N(this,M,x.changedTouches.length===z).event(x),C,j,$,U;for(ya(x),j=0;j<z;++j)$=k[j],U=Ht($,this),U=[U,this.__zoom.invert(U),$.identifier],P.touch0?!P.touch1&&P.touch0[2]!==U[2]&&(P.touch1=U,P.taps=0):(P.touch0=U,C=!0,P.taps=1+!!u);u&&(u=clearTimeout(u)),C&&(P.taps<2&&(d=U[0],u=setTimeout(function(){u=null},h)),xi(this),P.start())}}function G(x,...M){if(this.__zooming){var k=N(this,M).event(x),z=x.changedTouches,P=z.length,C,j,$,U;for(Sr(x),C=0;C<P;++C)j=z[C],$=Ht(j,this),k.touch0&&k.touch0[2]===j.identifier?k.touch0[0]=$:k.touch1&&k.touch1[2]===j.identifier&&(k.touch1[0]=$);if(j=k.that.__zoom,k.touch1){var K=k.touch0[0],V=k.touch0[1],se=k.touch1[0],re=k.touch1[1],de=(de=se[0]-K[0])*de+(de=se[1]-K[1])*de,ie=(ie=re[0]-V[0])*ie+(ie=re[1]-V[1])*ie;j=b(j,Math.sqrt(de/ie)),$=[(K[0]+se[0])/2,(K[1]+se[1])/2],U=[(V[0]+re[0])/2,(V[1]+re[1])/2]}else if(k.touch0)$=k.touch0[0],U=k.touch0[1];else return;k.zoom("touch",n(E(j,$,U),k.extent,o))}}function H(x,...M){if(this.__zooming){var k=N(this,M).event(x),z=x.changedTouches,P=z.length,C,j;for(ya(x),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),C=0;C<P;++C)j=z[C],k.touch0&&k.touch0[2]===j.identifier?delete k.touch0:k.touch1&&k.touch1[2]===j.identifier&&delete k.touch1;if(k.touch1&&!k.touch0&&(k.touch0=k.touch1,delete k.touch1),k.touch0)k.touch0[1]=this.__zoom.invert(k.touch0[0]);else if(k.end(),k.taps===2&&(j=Ht(j,this),Math.hypot(d[0]-j[0],d[1]-j[1])<y)){var $=Tt(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return v.wheelDelta=function(x){return arguments.length?(r=typeof x=="function"?x:ci(+x),v):r},v.filter=function(x){return arguments.length?(e=typeof x=="function"?x:ci(!!x),v):e},v.touchable=function(x){return arguments.length?(i=typeof x=="function"?x:ci(!!x),v):i},v.extent=function(x){return arguments.length?(t=typeof x=="function"?x:ci([[+x[0][0],+x[0][1]],[+x[1][0],+x[1][1]]]),v):t},v.scaleExtent=function(x){return arguments.length?(a[0]=+x[0],a[1]=+x[1],v):[a[0],a[1]]},v.translateExtent=function(x){return arguments.length?(o[0][0]=+x[0][0],o[1][0]=+x[1][0],o[0][1]=+x[0][1],o[1][1]=+x[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(x){return arguments.length?(n=x,v):n},v.duration=function(x){return arguments.length?(s=+x,v):s},v.interpolate=function(x){return arguments.length?(c=x,v):c},v.on=function(){var x=l.on.apply(l,arguments);return x===l?v:x},v.clickDistance=function(x){return arguments.length?(m=(x=+x)*x,v):Math.sqrt(m)},v.tapDistance=function(x){return arguments.length?(y=+x,v):y},v}const Hi=S.createContext(null),vS=Hi.Provider,on={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,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,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.`},sb=on.error001();function Se(e,t){const n=S.useContext(Hi);if(n===null)throw new Error(sb);return Mv(n,e,t)}const Je=()=>{const e=S.useContext(Hi);if(e===null)throw new Error(sb);return S.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},bS=e=>e.userSelectionActive?"none":"all";function cb({position:e,children:t,className:n,style:r,...i}){const a=Se(bS),o=`${e}`.split("-");return D.createElement("div",{className:ot(["react-flow__panel",n,...o]),style:{...r,pointerEvents:a},...i},t)}function xS({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:D.createElement(cb,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},D.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const _S=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:a={},labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u})=>{const d=S.useRef(null),[f,h]=S.useState({x:0,y:0,width:0,height:0}),g=ot(["react-flow__edge-textwrapper",l]);return S.useEffect(()=>{if(d.current){const m=d.current.getBBox();h({x:m.x,y:m.y,width:m.width,height:m.height})}},[n]),typeof n>"u"||!n?null:D.createElement("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:g,visibility:f.width?"visible":"hidden",...u},i&&D.createElement("rect",{width:f.width+2*o[0],x:-o[0],y:-o[1],height:f.height+2*o[1],className:"react-flow__edge-textbg",style:a,rx:s,ry:s}),D.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:d,style:r},n),c)};var wS=S.memo(_S);const cd=e=>({width:e.offsetWidth,height:e.offsetHeight}),_n=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ud=(e={x:0,y:0},t)=>({x:_n(e.x,t[0][0],t[1][0]),y:_n(e.y,t[0][1],t[1][1])}),yf=(e,t,n)=>e<t?_n(Math.abs(e-t),1,50)/50:e>n?-_n(Math.abs(e-n),1,50)/50:0,ub=(e,t)=>{const n=yf(e.x,35,t.width-35)*20,r=yf(e.y,35,t.height-35)*20;return[n,r]},lb=e=>e.getRootNode?.()||window?.document,ES=(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)}),ld=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),SS=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),vf=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),ql=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},CS=e=>kt(e.width)&&kt(e.height)&&kt(e.x)&&kt(e.y),kt=e=>!isNaN(e)&&isFinite(e),Me=Symbol.for("internals"),db=["Enter"," ","Escape"],NS=(e,t)=>{},AS=e=>"nativeEvent"in e;function Ol(e){const n=(AS(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n?.nodeName)||n?.hasAttribute("contenteditable")||!!n?.closest(".nokey")}const fb=e=>"clientX"in e,yn=(e,t)=>{const n=fb(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},Ai=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0,mr=({id:e,path:t,labelX:n,labelY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:h=20})=>D.createElement(D.Fragment,null,D.createElement("path",{id:e,style:u,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:f}),h&&D.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),i&&kt(n)&&kt(r)?D.createElement(wS,{x:n,y:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l}):null);mr.displayName="BaseEdge";function Cr(e,t,n){return n===void 0?n:r=>{const i=t().edges.find(a=>a.id===e);i&&n(r,{...i})}}function hb({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2,s=r<t?r+o:r-o;return[a,s,i,o]}function pb({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){const c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125,u=Math.abs(c-e),d=Math.abs(l-t);return[c,l,u,d]}var Pn;(function(e){e.Strict="strict",e.Loose="loose"})(Pn||(Pn={}));var Mn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Mn||(Mn={}));var Vr;(function(e){e.Partial="partial",e.Full="full"})(Vr||(Vr={}));var pn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(pn||(pn={}));var Ti;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ti||(Ti={}));var Y;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Y||(Y={}));function bf({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Y.Left||e===Y.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function gb({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top}){const[o,s]=bf({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=bf({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,h]=pb({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,h]}const dd=S.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=Y.Bottom,targetPosition:a=Y.Top,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:m})=>{const[y,v,b]=gb({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:a});return D.createElement(mr,{path:y,labelX:v,labelY:b,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:m})});dd.displayName="SimpleBezierEdge";const xf={[Y.Left]:{x:-1,y:0},[Y.Right]:{x:1,y:0},[Y.Top]:{x:0,y:-1},[Y.Bottom]:{x:0,y:1}},TS=({source:e,sourcePosition:t=Y.Bottom,target:n})=>t===Y.Left||t===Y.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},_f=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function kS({source:e,sourcePosition:t=Y.Bottom,target:n,targetPosition:r=Y.Top,center:i,offset:a}){const o=xf[t],s=xf[r],c={x:e.x+o.x*a,y:e.y+o.y*a},l={x:n.x+s.x*a,y:n.y+s.y*a},u=TS({source:c,sourcePosition:t,target:l}),d=u.x!==0?"x":"y",f=u[d];let h=[],g,m;const y={x:0,y:0},v={x:0,y:0},[b,E,_,T]=hb({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(o[d]*s[d]===-1){g=i.x??b,m=i.y??E;const q=[{x:g,y:c.y},{x:g,y:l.y}],L=[{x:c.x,y:m},{x:l.x,y:m}];o[d]===f?h=d==="x"?q:L:h=d==="x"?L:q}else{const q=[{x:c.x,y:l.y}],L=[{x:l.x,y:c.y}];if(d==="x"?h=o.x===f?L:q:h=o.y===f?q:L,t===r){const H=Math.abs(e[d]-n[d]);if(H<=a){const x=Math.min(a-1,a-H);o[d]===f?y[d]=(c[d]>e[d]?-1:1)*x:v[d]=(l[d]>n[d]?-1:1)*x}}if(t!==r){const H=d==="x"?"y":"x",x=o[d]===s[H],M=c[H]>l[H],k=c[H]<l[H];(o[d]===1&&(!x&&M||x&&k)||o[d]!==1&&(!x&&k||x&&M))&&(h=d==="x"?q:L)}const O={x:c.x+y.x,y:c.y+y.y},R={x:l.x+v.x,y:l.y+v.y},I=Math.max(Math.abs(O.x-h[0].x),Math.abs(R.x-h[0].x)),G=Math.max(Math.abs(O.y-h[0].y),Math.abs(R.y-h[0].y));I>=G?(g=(O.x+R.x)/2,m=h[0].y):(g=h[0].x,m=(O.y+R.y)/2)}return[[e,{x:c.x+y.x,y:c.y+y.y},...h,{x:l.x+v.x,y:l.y+v.y},n],g,m,_,T]}function RS(e,t,n,r){const i=Math.min(_f(e,t)/2,_f(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${a+i*l},${o}Q ${a},${o} ${a},${o+i*u}`}const s=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${a},${o+i*c}Q ${a},${o} ${a+i*s},${o}`}function Ll({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20}){const[u,d,f,h,g]=kS({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l});return[u.reduce((y,v,b)=>{let E="";return b>0&&b<u.length-1?E=RS(u[b-1],v,u[b+1],o):E=`${b===0?"M":"L"}${v.x} ${v.y}`,y+=E,y},""),d,f,h,g]}const Ui=S.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,sourcePosition:d=Y.Bottom,targetPosition:f=Y.Top,markerEnd:h,markerStart:g,pathOptions:m,interactionWidth:y})=>{const[v,b,E]=Ll({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:f,borderRadius:m?.borderRadius,offset:m?.offset});return D.createElement(mr,{path:v,labelX:b,labelY:E,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:h,markerStart:g,interactionWidth:y})});Ui.displayName="SmoothStepEdge";const fd=S.memo(e=>D.createElement(Ui,{...e,pathOptions:S.useMemo(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));fd.displayName="StepEdge";function IS({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,a,o,s]=hb({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}const hd=S.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:h})=>{const[g,m,y]=IS({sourceX:e,sourceY:t,targetX:n,targetY:r});return D.createElement(mr,{path:g,labelX:m,labelY:y,label:i,labelStyle:a,labelShowBg:o,labelBgStyle:s,labelBgPadding:c,labelBgBorderRadius:l,style:u,markerEnd:d,markerStart:f,interactionWidth:h})});hd.displayName="StraightEdge";function ui(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function wf({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case Y.Left:return[t-ui(t-r,a),n];case Y.Right:return[t+ui(r-t,a),n];case Y.Top:return[t,n-ui(n-i,a)];case Y.Bottom:return[t,n+ui(i-n,a)]}}function pd({sourceX:e,sourceY:t,sourcePosition:n=Y.Bottom,targetX:r,targetY:i,targetPosition:a=Y.Top,curvature:o=.25}){const[s,c]=wf({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=wf({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,h,g]=pb({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,h,g]}const ki=S.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=Y.Bottom,targetPosition:a=Y.Top,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,pathOptions:m,interactionWidth:y})=>{const[v,b,E]=pd({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:a,curvature:m?.curvature});return D.createElement(mr,{path:v,labelX:b,labelY:E,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:y})});ki.displayName="BezierEdge";const gd=S.createContext(null),MS=gd.Provider;gd.Consumer;const md=()=>S.useContext(gd),qS=e=>"id"in e&&"source"in e&&"target"in e,OS=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Pl=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,LS=(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)),mb=(e,t)=>{if(!e.source||!e.target)return t;let n;return qS(e)?n={...e}:n={...e,id:OS(e)},LS(n,t)?t:t.concat(n)},Dl=({x:e,y:t},[n,r,i],a,[o,s])=>{const c={x:(e-n)/i,y:(t-r)/i};return a?{x:o*Math.round(c.x/o),y:s*Math.round(c.y/s)}:c},yb=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),ur=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},Bi=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const{x:a,y:o}=ur(i,t).positionAbsolute;return ES(r,ld({x:a,y:o,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return SS(n)},vb=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1,s=[0,0])=>{const c={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},l=[];return e.forEach(u=>{const{width:d,height:f,selectable:h=!0,hidden:g=!1}=u;if(o&&!h||g)return!1;const{positionAbsolute:m}=ur(u,s),y={x:m.x,y:m.y,width:d||0,height:f||0},v=ql(c,y),b=typeof d>"u"||typeof f>"u"||d===null||f===null,E=a&&v>0,_=(d||0)*(f||0);(b||E||v>=_||u.dragging)&&l.push(u)}),l},bb=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},xb=(e,t,n,r,i,a=.1)=>{const o=t/(e.width*(1+a)),s=n/(e.height*(1+a)),c=Math.min(o,s),l=_n(c,r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,h=n/2-d*l;return{x:f,y:h,zoom:l}},kn=(e,t=0)=>e.transition().duration(t);function Ef(e,t,n,r){return(t[n]||[]).reduce((i,a)=>(`${e.id}-${a.id}-${n}`!==r&&i.push({id:a.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+a.x+a.width/2,y:(e.positionAbsolute?.y??0)+a.y+a.height/2}),i),[])}function PS(e,t,n,r,i,a){const{x:o,y:s}=yn(e),l=t.elementsFromPoint(o,s).find(g=>g.classList.contains("react-flow__handle"));if(l){const g=l.getAttribute("data-nodeid");if(g){const m=yd(void 0,l),y=l.getAttribute("data-handleid"),v=a({nodeId:g,id:y,type:m});if(v){const b=i.find(E=>E.nodeId===g&&E.type===m&&E.id===y);return{handle:{id:y,type:m,nodeId:g,x:b?.x||n.x,y:b?.y||n.y},validHandleResult:v}}}}let u=[],d=1/0;if(i.forEach(g=>{const m=Math.sqrt((g.x-n.x)**2+(g.y-n.y)**2);if(m<=r){const y=a(g);m<=d&&(m<d?u=[{handle:g,validHandleResult:y}]:m===d&&u.push({handle:g,validHandleResult:y}),d=m)}}),!u.length)return{handle:null,validHandleResult:_b()};if(u.length===1)return u[0];const f=u.some(({validHandleResult:g})=>g.isValid),h=u.some(({handle:g})=>g.type==="target");return u.find(({handle:g,validHandleResult:m})=>h?g.type==="target":f?m.isValid:!0)||u[0]}const DS={source:null,target:null,sourceHandle:null,targetHandle:null},_b=()=>({handleDomNode:null,isValid:!1,connection:DS,endHandle:null});function wb(e,t,n,r,i,a,o){const s=i==="target",c=o.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),l={..._b(),handleDomNode:c};if(c){const u=yd(void 0,c),d=c.getAttribute("data-nodeid"),f=c.getAttribute("data-handleid"),h=c.classList.contains("connectable"),g=c.classList.contains("connectableend"),m={source:s?d:n,sourceHandle:s?f:r,target:s?n:d,targetHandle:s?r:f};l.connection=m,h&&g&&(t===Pn.Strict?s&&u==="source"||!s&&u==="target":d!==n||f!==r)&&(l.endHandle={nodeId:d,handleId:f,type:u},l.isValid=a(m))}return l}function jS({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((i,a)=>{if(a[Me]){const{handleBounds:o}=a[Me];let s=[],c=[];o&&(s=Ef(a,o,"source",`${t}-${n}-${r}`),c=Ef(a,o,"target",`${t}-${n}-${r}`)),i.push(...s,...c)}return i},[])}function yd(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function va(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function $S(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function Eb({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:a,setState:o,isValidConnection:s,edgeUpdaterType:c,onReconnectEnd:l}){const u=lb(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:h,connectionRadius:g,onConnectStart:m,panBy:y,getNodes:v,cancelConnection:b}=a();let E=0,_;const{x:T,y:N}=yn(e),q=u?.elementFromPoint(T,N),L=yd(c,q),O=f?.getBoundingClientRect();if(!O||!L)return;let R,I=yn(e,O),G=!1,H=null,x=!1,M=null;const k=jS({nodes:v(),nodeId:n,handleId:t,handleType:L}),z=()=>{if(!h)return;const[j,$]=ub(I,O);y({x:j,y:$}),E=requestAnimationFrame(z)};o({connectionPosition:I,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:L,connectionStartHandle:{nodeId:n,handleId:t,type:L},connectionEndHandle:null}),m?.(e,{nodeId:n,handleId:t,handleType:L});function P(j){const{transform:$}=a();I=yn(j,O);const{handle:U,validHandleResult:K}=PS(j,u,Dl(I,$,!1,[1,1]),g,k,V=>wb(V,d,n,t,i?"target":"source",s,u));if(_=U,G||(z(),G=!0),M=K.handleDomNode,H=K.connection,x=K.isValid,o({connectionPosition:_&&x?yb({x:_.x,y:_.y},$):I,connectionStatus:$S(!!_,x),connectionEndHandle:K.endHandle}),!_&&!x&&!M)return va(R);H.source!==H.target&&M&&(va(R),R=M,M.classList.add("connecting","react-flow__handle-connecting"),M.classList.toggle("valid",x),M.classList.toggle("react-flow__handle-valid",x))}function C(j){(_||M)&&H&&x&&r?.(H),a().onConnectEnd?.(j),c&&l?.(j),va(R),b(),cancelAnimationFrame(E),G=!1,x=!1,H=null,M=null,u.removeEventListener("mousemove",P),u.removeEventListener("mouseup",C),u.removeEventListener("touchmove",P),u.removeEventListener("touchend",C)}u.addEventListener("mousemove",P),u.addEventListener("mouseup",C),u.addEventListener("touchmove",P),u.addEventListener("touchend",C)}const Sf=()=>!0,zS=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),FS=(e,t,n)=>r=>{const{connectionStartHandle:i,connectionEndHandle:a,connectionClickStartHandle:o}=r;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===n||a?.nodeId===e&&a?.handleId===t&&a?.type===n,clickConnecting:o?.nodeId===e&&o?.handleId===t&&o?.type===n}},Sb=S.forwardRef(({type:e="source",position:t=Y.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},h)=>{const g=o||null,m=e==="target",y=Je(),v=md(),{connectOnClick:b,noPanClassName:E}=Se(zS,bt),{connecting:_,clickConnecting:T}=Se(FS(v,g,e),bt);v||y.getState().onError?.("010",on.error010());const N=O=>{const{defaultEdgeOptions:R,onConnect:I,hasDefaultEdges:G}=y.getState(),H={...R,...O};if(G){const{edges:x,setEdges:M}=y.getState();M(mb(H,x))}I?.(H),s?.(H)},q=O=>{if(!v)return;const R=fb(O);i&&(R&&O.button===0||!R)&&Eb({event:O,handleId:g,nodeId:v,onConnect:N,isTarget:m,getState:y.getState,setState:y.setState,isValidConnection:n||y.getState().isValidConnection||Sf}),R?u?.(O):d?.(O)},L=O=>{const{onClickConnectStart:R,onClickConnectEnd:I,connectionClickStartHandle:G,connectionMode:H,isValidConnection:x}=y.getState();if(!v||!G&&!i)return;if(!G){R?.(O,{nodeId:v,handleId:g,handleType:e}),y.setState({connectionClickStartHandle:{nodeId:v,type:e,handleId:g}});return}const M=lb(O.target),k=n||x||Sf,{connection:z,isValid:P}=wb({nodeId:v,id:g,type:e},H,G.nodeId,G.handleId||null,G.type,k,M);P&&N(z),I?.(O),y.setState({connectionClickStartHandle:null})};return D.createElement("div",{"data-handleid":g,"data-nodeid":v,"data-handlepos":t,"data-id":`${v}-${g}-${e}`,className:ot(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",E,l,{source:!m,target:m,connectable:r,connectablestart:i,connectableend:a,connecting:T,connectionindicator:r&&(i&&!_||a&&_)}]),onMouseDown:q,onTouchStart:q,onClick:b?L:void 0,ref:h,...f},c)});Sb.displayName="Handle";var ut=S.memo(Sb);const Cb=({data:e,isConnectable:t,targetPosition:n=Y.Top,sourcePosition:r=Y.Bottom})=>D.createElement(D.Fragment,null,D.createElement(ut,{type:"target",position:n,isConnectable:t}),e?.label,D.createElement(ut,{type:"source",position:r,isConnectable:t}));Cb.displayName="DefaultNode";var jl=S.memo(Cb);const Nb=({data:e,isConnectable:t,sourcePosition:n=Y.Bottom})=>D.createElement(D.Fragment,null,e?.label,D.createElement(ut,{type:"source",position:n,isConnectable:t}));Nb.displayName="InputNode";var Ab=S.memo(Nb);const Tb=({data:e,isConnectable:t,targetPosition:n=Y.Top})=>D.createElement(D.Fragment,null,D.createElement(ut,{type:"target",position:n,isConnectable:t}),e?.label);Tb.displayName="OutputNode";var kb=S.memo(Tb);const vd=()=>null;vd.displayName="GroupNode";const HS=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),li=e=>e.id;function US(e,t){return bt(e.selectedNodes.map(li),t.selectedNodes.map(li))&&bt(e.selectedEdges.map(li),t.selectedEdges.map(li))}const Rb=S.memo(({onSelectionChange:e})=>{const t=Je(),{selectedNodes:n,selectedEdges:r}=Se(HS,US);return S.useEffect(()=>{const i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChange.forEach(a=>a(i))},[n,r,e]),null});Rb.displayName="SelectionListener";const BS=e=>!!e.onSelectionChange;function GS({onSelectionChange:e}){const t=Se(BS);return e||t?D.createElement(Rb,{onSelectionChange:e}):null}const VS=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Kn(e,t){S.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function be(e,t,n){S.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const KS=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:a,onConnectEnd:o,onClickConnectStart:s,onClickConnectEnd:c,nodesDraggable:l,nodesConnectable:u,nodesFocusable:d,edgesFocusable:f,edgesUpdatable:h,elevateNodesOnSelect:g,minZoom:m,maxZoom:y,nodeExtent:v,onNodesChange:b,onEdgesChange:E,elementsSelectable:_,connectionMode:T,snapGrid:N,snapToGrid:q,translateExtent:L,connectOnClick:O,defaultEdgeOptions:R,fitView:I,fitViewOptions:G,onNodesDelete:H,onEdgesDelete:x,onNodeDrag:M,onNodeDragStart:k,onNodeDragStop:z,onSelectionDrag:P,onSelectionDragStart:C,onSelectionDragStop:j,noPanClassName:$,nodeOrigin:U,rfId:K,autoPanOnConnect:V,autoPanOnNodeDrag:se,onError:re,connectionRadius:de,isValidConnection:ie,nodeDragThreshold:he})=>{const{setNodes:ue,setEdges:ve,setDefaultNodesAndEdges:qe,setMinZoom:Oe,setMaxZoom:Re,setTranslateExtent:te,setNodeExtent:we,reset:ee}=Se(VS,bt),W=Je();return S.useEffect(()=>{const pe=r?.map(et=>({...et,...R}));return qe(n,pe),()=>{ee()}},[]),be("defaultEdgeOptions",R,W.setState),be("connectionMode",T,W.setState),be("onConnect",i,W.setState),be("onConnectStart",a,W.setState),be("onConnectEnd",o,W.setState),be("onClickConnectStart",s,W.setState),be("onClickConnectEnd",c,W.setState),be("nodesDraggable",l,W.setState),be("nodesConnectable",u,W.setState),be("nodesFocusable",d,W.setState),be("edgesFocusable",f,W.setState),be("edgesUpdatable",h,W.setState),be("elementsSelectable",_,W.setState),be("elevateNodesOnSelect",g,W.setState),be("snapToGrid",q,W.setState),be("snapGrid",N,W.setState),be("onNodesChange",b,W.setState),be("onEdgesChange",E,W.setState),be("connectOnClick",O,W.setState),be("fitViewOnInit",I,W.setState),be("fitViewOnInitOptions",G,W.setState),be("onNodesDelete",H,W.setState),be("onEdgesDelete",x,W.setState),be("onNodeDrag",M,W.setState),be("onNodeDragStart",k,W.setState),be("onNodeDragStop",z,W.setState),be("onSelectionDrag",P,W.setState),be("onSelectionDragStart",C,W.setState),be("onSelectionDragStop",j,W.setState),be("noPanClassName",$,W.setState),be("nodeOrigin",U,W.setState),be("rfId",K,W.setState),be("autoPanOnConnect",V,W.setState),be("autoPanOnNodeDrag",se,W.setState),be("onError",re,W.setState),be("connectionRadius",de,W.setState),be("isValidConnection",ie,W.setState),be("nodeDragThreshold",he,W.setState),Kn(e,ue),Kn(t,ve),Kn(m,Oe),Kn(y,Re),Kn(L,te),Kn(v,we),null},Cf={display:"none"},WS={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ib="react-flow__node-desc",Mb="react-flow__edge-desc",YS="react-flow__aria-live",XS=e=>e.ariaLiveMessage;function ZS({rfId:e}){const t=Se(XS);return D.createElement("div",{id:`${YS}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:WS},t)}function QS({rfId:e,disableKeyboardA11y:t}){return D.createElement(D.Fragment,null,D.createElement("div",{id:`${Ib}-${e}`,style:Cf},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),D.createElement("div",{id:`${Mb}-${e}`,style:Cf},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&D.createElement(ZS,{rfId:e}))}var Kr=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=S.useState(!1),i=S.useRef(!1),a=S.useRef(new Set([])),[o,s]=S.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.split("+")),u=l.reduce((d,f)=>d.concat(...f),[]);return[l,u]}return[[],[]]},[e]);return S.useEffect(()=>{const c=typeof document<"u"?document:null,l=t?.target||c;if(e!==null){const u=h=>{if(i.current=h.ctrlKey||h.metaKey||h.shiftKey,(!i.current||i.current&&!t.actInsideInputWithModifier)&&Ol(h))return!1;const m=Af(h.code,s);a.current.add(h[m]),Nf(o,a.current,!1)&&(h.preventDefault(),r(!0))},d=h=>{if((!i.current||i.current&&!t.actInsideInputWithModifier)&&Ol(h))return!1;const m=Af(h.code,s);Nf(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(h[m]),h.key==="Meta"&&a.current.clear(),i.current=!1},f=()=>{a.current.clear(),r(!1)};return l?.addEventListener("keydown",u),l?.addEventListener("keyup",d),window.addEventListener("blur",f),()=>{l?.removeEventListener("keydown",u),l?.removeEventListener("keyup",d),window.removeEventListener("blur",f)}}},[e,r]),n};function Nf(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function Af(e,t){return t.includes(e)?"code":"key"}function qb(e,t,n,r){const i=e.parentNode||e.parentId;if(!i)return n;const a=t.get(i),o=ur(a,r);return qb(a,t,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(a[Me]?.z??0)>(n.z??0)?a[Me]?.z??0:n.z??0},r)}function Ob(e,t,n){e.forEach(r=>{const i=r.parentNode||r.parentId;if(i&&!e.has(i))throw new Error(`Parent node ${i} not found`);if(i||n?.[r.id]){const{x:a,y:o,z:s}=qb(r,e,{...r.position,z:r[Me]?.z??0},t);r.positionAbsolute={x:a,y:o},r[Me].z=s,n?.[r.id]&&(r[Me].isParent=!0)}})}function ba(e,t,n,r){const i=new Map,a={},o=r?1e3:0;return e.forEach(s=>{const c=(kt(s.zIndex)?s.zIndex:0)+(s.selected?o:0),l=t.get(s.id),u={...s,positionAbsolute:{x:s.position.x,y:s.position.y}},d=s.parentNode||s.parentId;d&&(a[d]=!0);const f=l?.type&&l?.type!==s.type;Object.defineProperty(u,Me,{enumerable:!1,value:{handleBounds:f?void 0:l?.[Me]?.handleBounds,z:c}}),i.set(s.id,u)}),Ob(i,n,a),i}function Lb(e,t={}){const{getNodes:n,width:r,height:i,minZoom:a,maxZoom:o,d3Zoom:s,d3Selection:c,fitViewOnInitDone:l,fitViewOnInit:u,nodeOrigin:d}=e(),f=t.initial&&!l&&u;if(s&&c&&(f||!t.initial)){const g=n().filter(y=>{const v=t.includeHiddenNodes?y.width&&y.height:!y.hidden;return t.nodes?.length?v&&t.nodes.some(b=>b.id===y.id):v}),m=g.every(y=>y.width&&y.height);if(g.length>0&&m){const y=Bi(g,d),{x:v,y:b,zoom:E}=xb(y,r,i,t.minZoom??a,t.maxZoom??o,t.padding??.1),_=mn.translate(v,b).scale(E);return typeof t.duration=="number"&&t.duration>0?s.transform(kn(c,t.duration),_):s.transform(c,_),!0}}return!1}function JS(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[Me]:r[Me],selected:n.selected})}),new Map(t)}function eC(e,t){return t.map(n=>{const r=e.find(i=>i.id===n.id);return r&&(n.selected=r.selected),n})}function di({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:i,edges:a,onNodesChange:o,onEdgesChange:s,hasDefaultNodes:c,hasDefaultEdges:l}=n();e?.length&&(c&&r({nodeInternals:JS(e,i)}),o?.(e)),t?.length&&(l&&r({edges:eC(t,a)}),s?.(t))}const Wn=()=>{},tC={zoomIn:Wn,zoomOut:Wn,zoomTo:Wn,getZoom:()=>1,setViewport:Wn,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Wn,fitBounds:Wn,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},nC=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),rC=()=>{const e=Je(),{d3Zoom:t,d3Selection:n}=Se(nC,bt);return S.useMemo(()=>n&&t?{zoomIn:i=>t.scaleBy(kn(n,i?.duration),1.2),zoomOut:i=>t.scaleBy(kn(n,i?.duration),1/1.2),zoomTo:(i,a)=>t.scaleTo(kn(n,a?.duration),i),getZoom:()=>e.getState().transform[2],setViewport:(i,a)=>{const[o,s,c]=e.getState().transform,l=mn.translate(i.x??o,i.y??s).scale(i.zoom??c);t.transform(kn(n,a?.duration),l)},getViewport:()=>{const[i,a,o]=e.getState().transform;return{x:i,y:a,zoom:o}},fitView:i=>Lb(e.getState,i),setCenter:(i,a,o)=>{const{width:s,height:c,maxZoom:l}=e.getState(),u=typeof o?.zoom<"u"?o.zoom:l,d=s/2-i*u,f=c/2-a*u,h=mn.translate(d,f).scale(u);t.transform(kn(n,o?.duration),h)},fitBounds:(i,a)=>{const{width:o,height:s,minZoom:c,maxZoom:l}=e.getState(),{x:u,y:d,zoom:f}=xb(i,o,s,c,l,a?.padding??.1),h=mn.translate(u,d).scale(f);t.transform(kn(n,a?.duration),h)},project:i=>{const{transform:a,snapToGrid:o,snapGrid:s}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Dl(i,a,o,s)},screenToFlowPosition:i=>{const{transform:a,snapToGrid:o,snapGrid:s,domNode:c}=e.getState();if(!c)return i;const{x:l,y:u}=c.getBoundingClientRect(),d={x:i.x-l,y:i.y-u};return Dl(d,a,o,s)},flowToScreenPosition:i=>{const{transform:a,domNode:o}=e.getState();if(!o)return i;const{x:s,y:c}=o.getBoundingClientRect(),l=yb(i,a);return{x:l.x+s,y:l.y+c}},viewportInitialized:!0}:tC,[t,n])};function jt(){const e=rC(),t=Je(),n=S.useCallback(()=>t.getState().getNodes().map(m=>({...m})),[]),r=S.useCallback(m=>t.getState().nodeInternals.get(m),[]),i=S.useCallback(()=>{const{edges:m=[]}=t.getState();return m.map(y=>({...y}))},[]),a=S.useCallback(m=>{const{edges:y=[]}=t.getState();return y.find(v=>v.id===m)},[]),o=S.useCallback(m=>{const{getNodes:y,setNodes:v,hasDefaultNodes:b,onNodesChange:E}=t.getState(),_=y(),T=typeof m=="function"?m(_):m;if(b)v(T);else if(E){const N=T.length===0?_.map(q=>({type:"remove",id:q.id})):T.map(q=>({item:q,type:"reset"}));E(N)}},[]),s=S.useCallback(m=>{const{edges:y=[],setEdges:v,hasDefaultEdges:b,onEdgesChange:E}=t.getState(),_=typeof m=="function"?m(y):m;if(b)v(_);else if(E){const T=_.length===0?y.map(N=>({type:"remove",id:N.id})):_.map(N=>({item:N,type:"reset"}));E(T)}},[]),c=S.useCallback(m=>{const y=Array.isArray(m)?m:[m],{getNodes:v,setNodes:b,hasDefaultNodes:E,onNodesChange:_}=t.getState();if(E){const N=[...v(),...y];b(N)}else if(_){const T=y.map(N=>({item:N,type:"add"}));_(T)}},[]),l=S.useCallback(m=>{const y=Array.isArray(m)?m:[m],{edges:v=[],setEdges:b,hasDefaultEdges:E,onEdgesChange:_}=t.getState();if(E)b([...v,...y]);else if(_){const T=y.map(N=>({item:N,type:"add"}));_(T)}},[]),u=S.useCallback(()=>{const{getNodes:m,edges:y=[],transform:v}=t.getState(),[b,E,_]=v;return{nodes:m().map(T=>({...T})),edges:y.map(T=>({...T})),viewport:{x:b,y:E,zoom:_}}},[]),d=S.useCallback(({nodes:m,edges:y})=>{const{nodeInternals:v,getNodes:b,edges:E,hasDefaultNodes:_,hasDefaultEdges:T,onNodesDelete:N,onEdgesDelete:q,onNodesChange:L,onEdgesChange:O}=t.getState(),R=(m||[]).map(M=>M.id),I=(y||[]).map(M=>M.id),G=b().reduce((M,k)=>{const z=k.parentNode||k.parentId,P=!R.includes(k.id)&&z&&M.find(j=>j.id===z);return(typeof k.deletable=="boolean"?k.deletable:!0)&&(R.includes(k.id)||P)&&M.push(k),M},[]),H=E.filter(M=>typeof M.deletable=="boolean"?M.deletable:!0),x=H.filter(M=>I.includes(M.id));if(G||x){const M=bb(G,H),k=[...x,...M],z=k.reduce((P,C)=>(P.includes(C.id)||P.push(C.id),P),[]);if((T||_)&&(T&&t.setState({edges:E.filter(P=>!z.includes(P.id))}),_&&(G.forEach(P=>{v.delete(P.id)}),t.setState({nodeInternals:new Map(v)}))),z.length>0&&(q?.(k),O&&O(z.map(P=>({id:P,type:"remove"})))),G.length>0&&(N?.(G),L)){const P=G.map(C=>({id:C.id,type:"remove"}));L(P)}}},[]),f=S.useCallback(m=>{const y=CS(m),v=y?null:t.getState().nodeInternals.get(m.id);return!y&&!v?[null,null,y]:[y?m:vf(v),v,y]},[]),h=S.useCallback((m,y=!0,v)=>{const[b,E,_]=f(m);return b?(v||t.getState().getNodes()).filter(T=>{if(!_&&(T.id===E.id||!T.positionAbsolute))return!1;const N=vf(T),q=ql(N,b);return y&&q>0||q>=b.width*b.height}):[]},[]),g=S.useCallback((m,y,v=!0)=>{const[b]=f(m);if(!b)return!1;const E=ql(b,y);return v&&E>0||E>=b.width*b.height},[]);return S.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:a,setNodes:o,setEdges:s,addNodes:c,addEdges:l,toObject:u,deleteElements:d,getIntersectingNodes:h,isNodeIntersecting:g}),[e,n,r,i,a,o,s,c,l,u,d,h,g])}const iC={actInsideInputWithModifier:!1};var aC=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Je(),{deleteElements:r}=jt(),i=Kr(e,iC),a=Kr(t);S.useEffect(()=>{if(i){const{edges:o,getNodes:s}=n.getState(),c=s().filter(u=>u.selected),l=o.filter(u=>u.selected);r({nodes:c,edges:l}),n.setState({nodesSelectionActive:!1})}},[i]),S.useEffect(()=>{n.setState({multiSelectionActive:a})},[a])};function oC(e){const t=Je();S.useEffect(()=>{let n;const r=()=>{if(!e.current)return;const i=cd(e.current);(i.height===0||i.width===0)&&t.getState().onError?.("004",on.error004()),t.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const bd={position:"absolute",width:"100%",height:"100%",top:0,left:0},sC=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,fi=e=>({x:e.x,y:e.y,zoom:e.k}),Yn=(e,t)=>e.target.closest(`.${t}`),Tf=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),kf=e=>{const t=e.ctrlKey&&Ai()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},cC=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),uC=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:a=!0,panOnScroll:o=!1,panOnScrollSpeed:s=.5,panOnScrollMode:c=Mn.Free,zoomOnDoubleClick:l=!0,elementsSelectable:u,panOnDrag:d=!0,defaultViewport:f,translateExtent:h,minZoom:g,maxZoom:m,zoomActivationKeyCode:y,preventScrolling:v=!0,children:b,noWheelClassName:E,noPanClassName:_})=>{const T=S.useRef(),N=Je(),q=S.useRef(!1),L=S.useRef(!1),O=S.useRef(null),R=S.useRef({x:0,y:0,zoom:0}),{d3Zoom:I,d3Selection:G,d3ZoomHandler:H,userSelectionActive:x}=Se(cC,bt),M=Kr(y),k=S.useRef(0),z=S.useRef(!1),P=S.useRef();return oC(O),S.useEffect(()=>{if(O.current){const C=O.current.getBoundingClientRect(),j=yS().scaleExtent([g,m]).translateExtent(h),$=Tt(O.current).call(j),U=mn.translate(f.x,f.y).scale(_n(f.zoom,g,m)),K=[[0,0],[C.width,C.height]],V=j.constrain()(U,K,h);j.transform($,V),j.wheelDelta(kf),N.setState({d3Zoom:j,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:O.current.closest(".react-flow")})}},[]),S.useEffect(()=>{G&&I&&(o&&!M&&!x?G.on("wheel.zoom",C=>{if(Yn(C,E))return!1;C.preventDefault(),C.stopImmediatePropagation();const j=G.property("__zoom").k||1;if(C.ctrlKey&&a){const ie=Ht(C),he=kf(C),ue=j*Math.pow(2,he);I.scaleTo(G,ue,ie,C);return}const $=C.deltaMode===1?20:1;let U=c===Mn.Vertical?0:C.deltaX*$,K=c===Mn.Horizontal?0:C.deltaY*$;!Ai()&&C.shiftKey&&c!==Mn.Vertical&&(U=C.deltaY*$,K=0),I.translateBy(G,-(U/j)*s,-(K/j)*s,{internal:!0});const V=fi(G.property("__zoom")),{onViewportChangeStart:se,onViewportChange:re,onViewportChangeEnd:de}=N.getState();clearTimeout(P.current),z.current||(z.current=!0,t?.(C,V),se?.(V)),z.current&&(e?.(C,V),re?.(V),P.current=setTimeout(()=>{n?.(C,V),de?.(V),z.current=!1},150))},{passive:!1}):typeof H<"u"&&G.on("wheel.zoom",function(C,j){if(!v&&C.type==="wheel"&&!C.ctrlKey||Yn(C,E))return null;C.preventDefault(),H.call(this,C,j)},{passive:!1}))},[x,o,c,G,I,H,M,a,v,E,t,e,n]),S.useEffect(()=>{I&&I.on("start",C=>{if(!C.sourceEvent||C.sourceEvent.internal)return null;k.current=C.sourceEvent?.button;const{onViewportChangeStart:j}=N.getState(),$=fi(C.transform);q.current=!0,R.current=$,C.sourceEvent?.type==="mousedown"&&N.setState({paneDragging:!0}),j?.($),t?.(C.sourceEvent,$)})},[I,t]),S.useEffect(()=>{I&&(x&&!q.current?I.on("zoom",null):x||I.on("zoom",C=>{const{onViewportChange:j}=N.getState();if(N.setState({transform:[C.transform.x,C.transform.y,C.transform.k]}),L.current=!!(r&&Tf(d,k.current??0)),(e||j)&&!C.sourceEvent?.internal){const $=fi(C.transform);j?.($),e?.(C.sourceEvent,$)}}))},[x,I,e,d,r]),S.useEffect(()=>{I&&I.on("end",C=>{if(!C.sourceEvent||C.sourceEvent.internal)return null;const{onViewportChangeEnd:j}=N.getState();if(q.current=!1,N.setState({paneDragging:!1}),r&&Tf(d,k.current??0)&&!L.current&&r(C.sourceEvent),L.current=!1,(n||j)&&sC(R.current,C.transform)){const $=fi(C.transform);R.current=$,clearTimeout(T.current),T.current=setTimeout(()=>{j?.($),n?.(C.sourceEvent,$)},o?150:0)}})},[I,o,d,n,r]),S.useEffect(()=>{I&&I.filter(C=>{const j=M||i,$=a&&C.ctrlKey;if((d===!0||Array.isArray(d)&&d.includes(1))&&C.button===1&&C.type==="mousedown"&&(Yn(C,"react-flow__node")||Yn(C,"react-flow__edge")))return!0;if(!d&&!j&&!o&&!l&&!a||x||!l&&C.type==="dblclick"||Yn(C,E)&&C.type==="wheel"||Yn(C,_)&&(C.type!=="wheel"||o&&C.type==="wheel"&&!M)||!a&&C.ctrlKey&&C.type==="wheel"||!j&&!o&&!$&&C.type==="wheel"||!d&&(C.type==="mousedown"||C.type==="touchstart")||Array.isArray(d)&&!d.includes(C.button)&&C.type==="mousedown")return!1;const U=Array.isArray(d)&&d.includes(C.button)||!C.button||C.button<=1;return(!C.ctrlKey||C.type==="wheel")&&U})},[x,I,i,a,o,l,d,u,M]),D.createElement("div",{className:"react-flow__renderer",ref:O,style:bd},b)},lC=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function dC(){const{userSelectionActive:e,userSelectionRect:t}=Se(lC,bt);return e&&t?D.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Rf(e,t){const n=t.parentNode||t.parentId,r=e.find(i=>i.id===n);if(r){const i=t.position.x+t.width-r.width,a=t.position.y+t.height-r.height;if(i>0||a>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,i>0&&(r.style.width+=i),a>0&&(r.style.height+=a),t.position.x<0){const o=Math.abs(t.position.x);r.position.x=r.position.x-o,r.style.width+=o,t.position.x=0}if(t.position.y<0){const o=Math.abs(t.position.y);r.position.y=r.position.y-o,r.style.height+=o,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function Pb(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,i)=>{const a=e.filter(s=>s.id===i.id);if(a.length===0)return r.push(i),r;const o={...i};for(const s of a)if(s)switch(s.type){case"select":{o.selected=s.selected;break}case"position":{typeof s.position<"u"&&(o.position=s.position),typeof s.positionAbsolute<"u"&&(o.positionAbsolute=s.positionAbsolute),typeof s.dragging<"u"&&(o.dragging=s.dragging),o.expandParent&&Rf(r,o);break}case"dimensions":{typeof s.dimensions<"u"&&(o.width=s.dimensions.width,o.height=s.dimensions.height),typeof s.updateStyle<"u"&&(o.style={...o.style||{},...s.dimensions}),typeof s.resizing=="boolean"&&(o.resizing=s.resizing),o.expandParent&&Rf(r,o);break}case"remove":return r}return r.push(o),r},n)}function Db(e,t){return Pb(e,t)}function fC(e,t){return Pb(e,t)}const hn=(e,t)=>({id:e,type:"select",selected:t});function or(e,t){return e.reduce((n,r)=>{const i=t.includes(r.id);return!r.selected&&i?(r.selected=!0,n.push(hn(r.id,!0))):r.selected&&!i&&(r.selected=!1,n.push(hn(r.id,!1))),n},[])}const xa=(e,t)=>n=>{n.target===t.current&&e?.(n)},hC=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),jb=S.memo(({isSelecting:e,selectionMode:t=Vr.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:a,onPaneContextMenu:o,onPaneScroll:s,onPaneMouseEnter:c,onPaneMouseMove:l,onPaneMouseLeave:u,children:d})=>{const f=S.useRef(null),h=Je(),g=S.useRef(0),m=S.useRef(0),y=S.useRef(),{userSelectionActive:v,elementsSelectable:b,dragging:E}=Se(hC,bt),_=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,m.current=0},T=H=>{a?.(H),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},N=H=>{if(Array.isArray(n)&&n?.includes(2)){H.preventDefault();return}o?.(H)},q=s?H=>s(H):void 0,L=H=>{const{resetSelectedElements:x,domNode:M}=h.getState();if(y.current=M?.getBoundingClientRect(),!b||!e||H.button!==0||H.target!==f.current||!y.current)return;const{x:k,y:z}=yn(H,y.current);x(),h.setState({userSelectionRect:{width:0,height:0,startX:k,startY:z,x:k,y:z}}),r?.(H)},O=H=>{const{userSelectionRect:x,nodeInternals:M,edges:k,transform:z,onNodesChange:P,onEdgesChange:C,nodeOrigin:j,getNodes:$}=h.getState();if(!e||!y.current||!x)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const U=yn(H,y.current),K=x.startX??0,V=x.startY??0,se={...x,x:U.x<K?U.x:K,y:U.y<V?U.y:V,width:Math.abs(U.x-K),height:Math.abs(U.y-V)},re=$(),de=vb(M,se,z,t===Vr.Partial,!0,j),ie=bb(de,k).map(ue=>ue.id),he=de.map(ue=>ue.id);if(g.current!==he.length){g.current=he.length;const ue=or(re,he);ue.length&&P?.(ue)}if(m.current!==ie.length){m.current=ie.length;const ue=or(k,ie);ue.length&&C?.(ue)}h.setState({userSelectionRect:se})},R=H=>{if(H.button!==0)return;const{userSelectionRect:x}=h.getState();!v&&x&&H.target===f.current&&T?.(H),h.setState({nodesSelectionActive:g.current>0}),_(),i?.(H)},I=H=>{v&&(h.setState({nodesSelectionActive:g.current>0}),i?.(H)),_()},G=b&&(e||v);return D.createElement("div",{className:ot(["react-flow__pane",{dragging:E,selection:e}]),onClick:G?void 0:xa(T,f),onContextMenu:xa(N,f),onWheel:xa(q,f),onMouseEnter:G?void 0:c,onMouseDown:G?L:void 0,onMouseMove:G?O:l,onMouseUp:G?R:void 0,onMouseLeave:G?I:u,ref:f,style:bd},d,D.createElement(dC,null))});jb.displayName="Pane";function $b(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:$b(r,t):!1}function If(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function pC(e,t,n,r){return Array.from(e.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||i.parentId||!$b(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>({id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:n.x-(i.positionAbsolute?.x??0),y:n.y-(i.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode||i.parentId,parentId:i.parentNode||i.parentId,width:i.width,height:i.height,expandParent:i.expandParent}))}function gC(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function zb(e,t,n,r,i=[0,0],a){const o=gC(e,e.extent||r);let s=o;const c=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(c&&e.width&&e.height){const d=n.get(c),{x:f,y:h}=ur(d,i).positionAbsolute;s=d&&kt(f)&&kt(h)&&kt(d.width)&&kt(d.height)?[[f+e.width*i[0],h+e.height*i[1]],[f+d.width-e.width+e.width*i[0],h+d.height-e.height+e.height*i[1]]]:s}else a?.("005",on.error005()),s=o;else if(e.extent&&c&&e.extent!=="parent"){const d=n.get(c),{x:f,y:h}=ur(d,i).positionAbsolute;s=[[e.extent[0][0]+f,e.extent[0][1]+h],[e.extent[1][0]+f,e.extent[1][1]+h]]}let l={x:0,y:0};if(c){const d=n.get(c);l=ur(d,i).positionAbsolute}const u=s&&s!=="parent"?ud(t,s):t;return{position:{x:u.x-l.x,y:u.y-l.y},positionAbsolute:u}}function _a({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(i=>({...n.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?r.find(i=>i.id===e):r[0],r]}const Mf=(e,t,n,r)=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const a=Array.from(i),o=t.getBoundingClientRect(),s={x:o.width*r[0],y:o.height*r[1]};return a.map(c=>{const l=c.getBoundingClientRect();return{id:c.getAttribute("data-handleid"),position:c.getAttribute("data-handlepos"),x:(l.left-o.left-s.x)/n,y:(l.top-o.top-s.y)/n,...cd(c)}})};function Nr(e,t,n){return n===void 0?n:r=>{const i=t().nodeInternals.get(e);i&&n(r,{...i})}}function $l({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeInternals:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.("012",on.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function Fb(){const e=Je();return S.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:i,snapToGrid:a}=e.getState(),o=n.touches?n.touches[0].clientX:n.clientX,s=n.touches?n.touches[0].clientY:n.clientY,c={x:(o-r[0])/r[2],y:(s-r[1])/r[2]};return{xSnapped:a?i[0]*Math.round(c.x/i[0]):c.x,ySnapped:a?i[1]*Math.round(c.y/i[1]):c.y,...c}},[])}function wa(e){return(t,n,r)=>e?.(t,r)}function Hb({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,selectNodesOnDrag:o}){const s=Je(),[c,l]=S.useState(!1),u=S.useRef([]),d=S.useRef({x:null,y:null}),f=S.useRef(0),h=S.useRef(null),g=S.useRef({x:0,y:0}),m=S.useRef(null),y=S.useRef(!1),v=S.useRef(!1),b=S.useRef(!1),E=Fb();return S.useEffect(()=>{if(e?.current){const _=Tt(e.current),T=({x:L,y:O})=>{const{nodeInternals:R,onNodeDrag:I,onSelectionDrag:G,updateNodePositions:H,nodeExtent:x,snapGrid:M,snapToGrid:k,nodeOrigin:z,onError:P}=s.getState();d.current={x:L,y:O};let C=!1,j={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&x){const U=Bi(u.current,z);j=ld(U)}if(u.current=u.current.map(U=>{const K={x:L-U.distance.x,y:O-U.distance.y};k&&(K.x=M[0]*Math.round(K.x/M[0]),K.y=M[1]*Math.round(K.y/M[1]));const V=[[x[0][0],x[0][1]],[x[1][0],x[1][1]]];u.current.length>1&&x&&!U.extent&&(V[0][0]=U.positionAbsolute.x-j.x+x[0][0],V[1][0]=U.positionAbsolute.x+(U.width??0)-j.x2+x[1][0],V[0][1]=U.positionAbsolute.y-j.y+x[0][1],V[1][1]=U.positionAbsolute.y+(U.height??0)-j.y2+x[1][1]);const se=zb(U,K,R,V,z,P);return C=C||U.position.x!==se.position.x||U.position.y!==se.position.y,U.position=se.position,U.positionAbsolute=se.positionAbsolute,U}),!C)return;H(u.current,!0,!0),l(!0);const $=i?I:wa(G);if($&&m.current){const[U,K]=_a({nodeId:i,dragItems:u.current,nodeInternals:R});$(m.current,U,K)}},N=()=>{if(!h.current)return;const[L,O]=ub(g.current,h.current);if(L!==0||O!==0){const{transform:R,panBy:I}=s.getState();d.current.x=(d.current.x??0)-L/R[2],d.current.y=(d.current.y??0)-O/R[2],I({x:L,y:O})&&T(d.current)}f.current=requestAnimationFrame(N)},q=L=>{const{nodeInternals:O,multiSelectionActive:R,nodesDraggable:I,unselectNodesAndEdges:G,onNodeDragStart:H,onSelectionDragStart:x}=s.getState();v.current=!0;const M=i?H:wa(x);(!o||!a)&&!R&&i&&(O.get(i)?.selected||G()),i&&a&&o&&$l({id:i,store:s,nodeRef:e});const k=E(L);if(d.current=k,u.current=pC(O,I,k,i),M&&u.current){const[z,P]=_a({nodeId:i,dragItems:u.current,nodeInternals:O});M(L.sourceEvent,z,P)}};if(t)_.on(".drag",null);else{const L=Kv().on("start",O=>{const{domNode:R,nodeDragThreshold:I}=s.getState();I===0&&q(O),b.current=!1;const G=E(O);d.current=G,h.current=R?.getBoundingClientRect()||null,g.current=yn(O.sourceEvent,h.current)}).on("drag",O=>{const R=E(O),{autoPanOnNodeDrag:I,nodeDragThreshold:G}=s.getState();if(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1&&(b.current=!0),!b.current){if(!y.current&&v.current&&I&&(y.current=!0,N()),!v.current){const H=R.xSnapped-(d?.current?.x??0),x=R.ySnapped-(d?.current?.y??0);Math.sqrt(H*H+x*x)>G&&q(O)}(d.current.x!==R.xSnapped||d.current.y!==R.ySnapped)&&u.current&&v.current&&(m.current=O.sourceEvent,g.current=yn(O.sourceEvent,h.current),T(R))}}).on("end",O=>{if(!(!v.current||b.current)&&(l(!1),y.current=!1,v.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:R,nodeInternals:I,onNodeDragStop:G,onSelectionDragStop:H}=s.getState(),x=i?G:wa(H);if(R(u.current,!1,!1),x){const[M,k]=_a({nodeId:i,dragItems:u.current,nodeInternals:I});x(O.sourceEvent,M,k)}}}).filter(O=>{const R=O.target;return!O.button&&(!n||!If(R,`.${n}`,e))&&(!r||If(R,r,e))});return _.call(L),()=>{_.on(".drag",null)}}}},[e,t,n,r,a,s,i,o,E]),c}function Ub(){const e=Je();return S.useCallback(n=>{const{nodeInternals:r,nodeExtent:i,updateNodePositions:a,getNodes:o,snapToGrid:s,snapGrid:c,onError:l,nodesDraggable:u}=e.getState(),d=o().filter(b=>b.selected&&(b.draggable||u&&typeof b.draggable>"u")),f=s?c[0]:5,h=s?c[1]:5,g=n.isShiftPressed?4:1,m=n.x*f*g,y=n.y*h*g,v=d.map(b=>{if(b.positionAbsolute){const E={x:b.positionAbsolute.x+m,y:b.positionAbsolute.y+y};s&&(E.x=c[0]*Math.round(E.x/c[0]),E.y=c[1]*Math.round(E.y/c[1]));const{positionAbsolute:_,position:T}=zb(b,E,r,i,void 0,l);b.position=T,b.positionAbsolute=_}return b});a(v,!0,!1)},[])}const lr={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Ar=e=>{const t=({id:n,type:r,data:i,xPos:a,yPos:o,xPosOrigin:s,yPosOrigin:c,selected:l,onClick:u,onMouseEnter:d,onMouseMove:f,onMouseLeave:h,onContextMenu:g,onDoubleClick:m,style:y,className:v,isDraggable:b,isSelectable:E,isConnectable:_,isFocusable:T,selectNodesOnDrag:N,sourcePosition:q,targetPosition:L,hidden:O,resizeObserver:R,dragHandle:I,zIndex:G,isParent:H,noDragClassName:x,noPanClassName:M,initialized:k,disableKeyboardA11y:z,ariaLabel:P,rfId:C,hasHandleBounds:j})=>{const $=Je(),U=S.useRef(null),K=S.useRef(null),V=S.useRef(q),se=S.useRef(L),re=S.useRef(r),de=E||b||u||d||f||h,ie=Ub(),he=Nr(n,$.getState,d),ue=Nr(n,$.getState,f),ve=Nr(n,$.getState,h),qe=Nr(n,$.getState,g),Oe=Nr(n,$.getState,m),Re=ee=>{const{nodeDragThreshold:W}=$.getState();if(E&&(!N||!b||W>0)&&$l({id:n,store:$,nodeRef:U}),u){const pe=$.getState().nodeInternals.get(n);pe&&u(ee,{...pe})}},te=ee=>{if(!Ol(ee)&&!z)if(db.includes(ee.key)&&E){const W=ee.key==="Escape";$l({id:n,store:$,unselect:W,nodeRef:U})}else b&&l&&Object.prototype.hasOwnProperty.call(lr,ee.key)&&($.setState({ariaLiveMessage:`Moved selected node ${ee.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~a}, y: ${~~o}`}),ie({x:lr[ee.key].x,y:lr[ee.key].y,isShiftPressed:ee.shiftKey}))};S.useEffect(()=>()=>{K.current&&(R?.unobserve(K.current),K.current=null)},[]),S.useEffect(()=>{if(U.current&&!O){const ee=U.current;(!k||!j||K.current!==ee)&&(K.current&&R?.unobserve(K.current),R?.observe(ee),K.current=ee)}},[O,k,j]),S.useEffect(()=>{const ee=re.current!==r,W=V.current!==q,pe=se.current!==L;U.current&&(ee||W||pe)&&(ee&&(re.current=r),W&&(V.current=q),pe&&(se.current=L),$.getState().updateNodeDimensions([{id:n,nodeElement:U.current,forceUpdate:!0}]))},[n,r,q,L]);const we=Hb({nodeRef:U,disabled:O||!b,noDragClassName:x,handleSelector:I,nodeId:n,isSelectable:E,selectNodesOnDrag:N});return O?null:D.createElement("div",{className:ot(["react-flow__node",`react-flow__node-${r}`,{[M]:b},v,{selected:l,selectable:E,parent:H,dragging:we}]),ref:U,style:{zIndex:G,transform:`translate(${s}px,${c}px)`,pointerEvents:de?"all":"none",visibility:k?"visible":"hidden",...y},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:he,onMouseMove:ue,onMouseLeave:ve,onContextMenu:qe,onClick:Re,onDoubleClick:Oe,onKeyDown:T?te:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":z?void 0:`${Ib}-${C}`,"aria-label":P},D.createElement(MS,{value:n},D.createElement(e,{id:n,data:i,type:r,xPos:a,yPos:o,selected:l,isConnectable:_,sourcePosition:q,targetPosition:L,dragging:we,dragHandle:I,zIndex:G})))};return t.displayName="NodeWrapper",S.memo(t)};const mC=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Bi(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function yC({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Je(),{width:i,height:a,x:o,y:s,transformString:c,userSelectionActive:l}=Se(mC,bt),u=Ub(),d=S.useRef(null);if(S.useEffect(()=>{n||d.current?.focus({preventScroll:!0})},[n]),Hb({nodeRef:d}),l||!i||!a)return null;const f=e?g=>{const m=r.getState().getNodes().filter(y=>y.selected);e(g,m)}:void 0,h=g=>{Object.prototype.hasOwnProperty.call(lr,g.key)&&u({x:lr[g.key].x,y:lr[g.key].y,isShiftPressed:g.shiftKey})};return D.createElement("div",{className:ot(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},D.createElement("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:i,height:a,top:s,left:o}}))}var vC=S.memo(yC);const bC=e=>e.nodesSelectionActive,Bb=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,deleteKeyCode:s,onMove:c,onMoveStart:l,onMoveEnd:u,selectionKeyCode:d,selectionOnDrag:f,selectionMode:h,onSelectionStart:g,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:E,zoomOnScroll:_,zoomOnPinch:T,panOnScroll:N,panOnScrollSpeed:q,panOnScrollMode:L,zoomOnDoubleClick:O,panOnDrag:R,defaultViewport:I,translateExtent:G,minZoom:H,maxZoom:x,preventScrolling:M,onSelectionContextMenu:k,noWheelClassName:z,noPanClassName:P,disableKeyboardA11y:C})=>{const j=Se(bC),$=Kr(d),U=Kr(v),K=U||R,V=U||N,se=$||f&&K!==!0;return aC({deleteKeyCode:s,multiSelectionKeyCode:y}),D.createElement(uC,{onMove:c,onMoveStart:l,onMoveEnd:u,onPaneContextMenu:a,elementsSelectable:E,zoomOnScroll:_,zoomOnPinch:T,panOnScroll:V,panOnScrollSpeed:q,panOnScrollMode:L,zoomOnDoubleClick:O,panOnDrag:!$&&K,defaultViewport:I,translateExtent:G,minZoom:H,maxZoom:x,zoomActivationKeyCode:b,preventScrolling:M,noWheelClassName:z,noPanClassName:P},D.createElement(jb,{onSelectionStart:g,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:K,isSelecting:!!se,selectionMode:h},e,j&&D.createElement(vC,{onSelectionContextMenu:k,noPanClassName:P,disableKeyboardA11y:C})))};Bb.displayName="FlowRenderer";var xC=S.memo(Bb);function _C(e){return Se(S.useCallback(n=>e?vb(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function wC(e){const t={input:Ar(e.input||Ab),default:Ar(e.default||jl),output:Ar(e.output||kb),group:Ar(e.group||vd)},n={},r=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,a)=>(i[a]=Ar(e[a]||jl),i),n);return{...t,...r}}const EC=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},SC=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Gb=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:a,onError:o}=Se(SC,bt),s=_C(e.onlyRenderVisibleElements),c=S.useRef(),l=S.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const u=new ResizeObserver(d=>{const f=d.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));a(f)});return c.current=u,u},[]);return S.useEffect(()=>()=>{c?.current?.disconnect()},[]),D.createElement("div",{className:"react-flow__nodes",style:bd},s.map(u=>{let d=u.type||"default";e.nodeTypes[d]||(o?.("003",on.error003(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,h=!!(u.draggable||t&&typeof u.draggable>"u"),g=!!(u.selectable||i&&typeof u.selectable>"u"),m=!!(u.connectable||n&&typeof u.connectable>"u"),y=!!(u.focusable||r&&typeof u.focusable>"u"),v=e.nodeExtent?ud(u.positionAbsolute,e.nodeExtent):u.positionAbsolute,b=v?.x??0,E=v?.y??0,_=EC({x:b,y:E,width:u.width??0,height:u.height??0,origin:e.nodeOrigin});return D.createElement(f,{key:u.id,id:u.id,className:u.className,style:u.style,type:d,data:u.data,sourcePosition:u.sourcePosition||Y.Bottom,targetPosition:u.targetPosition||Y.Top,hidden:u.hidden,xPos:b,yPos:E,xPosOrigin:_.x,yPosOrigin:_.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!u.selected,isDraggable:h,isSelectable:g,isConnectable:m,isFocusable:y,resizeObserver:l,dragHandle:u.dragHandle,zIndex:u[Me]?.z??0,isParent:!!u[Me]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!u.width&&!!u.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:u.ariaLabel,hasHandleBounds:!!u[Me]?.handleBounds})}))};Gb.displayName="NodeRenderer";var CC=S.memo(Gb);const NC=(e,t,n)=>n===Y.Left?e-t:n===Y.Right?e+t:e,AC=(e,t,n)=>n===Y.Top?e-t:n===Y.Bottom?e+t:e,qf="react-flow__edgeupdater",Of=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s})=>D.createElement("circle",{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:ot([qf,`${qf}-${s}`]),cx:NC(t,r,e),cy:AC(n,r,e),r,stroke:"transparent",fill:"transparent"}),TC=()=>!0;var Xn=e=>{const t=({id:n,className:r,type:i,data:a,onClick:o,onEdgeDoubleClick:s,selected:c,animated:l,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:m,style:y,source:v,target:b,sourceX:E,sourceY:_,targetX:T,targetY:N,sourcePosition:q,targetPosition:L,elementsSelectable:O,hidden:R,sourceHandleId:I,targetHandleId:G,onContextMenu:H,onMouseEnter:x,onMouseMove:M,onMouseLeave:k,reconnectRadius:z,onReconnect:P,onReconnectStart:C,onReconnectEnd:j,markerEnd:$,markerStart:U,rfId:K,ariaLabel:V,isFocusable:se,isReconnectable:re,pathOptions:de,interactionWidth:ie,disableKeyboardA11y:he})=>{const ue=S.useRef(null),[ve,qe]=S.useState(!1),[Oe,Re]=S.useState(!1),te=Je(),we=S.useMemo(()=>`url('#${Pl(U,K)}')`,[U,K]),ee=S.useMemo(()=>`url('#${Pl($,K)}')`,[$,K]);if(R)return null;const W=Ae=>{const{edges:Ze,addSelectedEdges:$e,unselectNodesAndEdges:Ke,multiSelectionActive:qt}=te.getState(),Qe=Ze.find(ht=>ht.id===n);Qe&&(O&&(te.setState({nodesSelectionActive:!1}),Qe.selected&&qt?(Ke({nodes:[],edges:[Qe]}),ue.current?.blur()):$e([n])),o&&o(Ae,Qe))},pe=Cr(n,te.getState,s),et=Cr(n,te.getState,H),je=Cr(n,te.getState,x),Ie=Cr(n,te.getState,M),xe=Cr(n,te.getState,k),Ce=(Ae,Ze)=>{if(Ae.button!==0)return;const{edges:$e,isValidConnection:Ke}=te.getState(),qt=Ze?b:v,Qe=(Ze?G:I)||null,ht=Ze?"target":"source",st=Ke||TC,Nt=Ze,Ot=$e.find(_t=>_t.id===n);Re(!0),C?.(Ae,Ot,ht);const Kt=_t=>{Re(!1),j?.(_t,Ot,ht)};Eb({event:Ae,handleId:Qe,nodeId:qt,onConnect:_t=>P?.(Ot,_t),isTarget:Nt,getState:te.getState,setState:te.setState,isValidConnection:st,edgeUpdaterType:ht,onReconnectEnd:Kt})},Le=Ae=>Ce(Ae,!0),Ge=Ae=>Ce(Ae,!1),ze=()=>qe(!0),Ne=()=>qe(!1),Fe=!O&&!o,Ve=Ae=>{if(!he&&db.includes(Ae.key)&&O){const{unselectNodesAndEdges:Ze,addSelectedEdges:$e,edges:Ke}=te.getState();Ae.key==="Escape"?(ue.current?.blur(),Ze({edges:[Ke.find(Qe=>Qe.id===n)]})):$e([n])}};return D.createElement("g",{className:ot(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:c,animated:l,inactive:Fe,updating:ve}]),onClick:W,onDoubleClick:pe,onContextMenu:et,onMouseEnter:je,onMouseMove:Ie,onMouseLeave:xe,onKeyDown:se?Ve:void 0,tabIndex:se?0:void 0,role:se?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${v} to ${b}`,"aria-describedby":se?`${Mb}-${K}`:void 0,ref:ue},!Oe&&D.createElement(e,{id:n,source:v,target:b,selected:c,animated:l,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:g,labelBgBorderRadius:m,data:a,style:y,sourceX:E,sourceY:_,targetX:T,targetY:N,sourcePosition:q,targetPosition:L,sourceHandleId:I,targetHandleId:G,markerStart:we,markerEnd:ee,pathOptions:de,interactionWidth:ie}),re&&D.createElement(D.Fragment,null,(re==="source"||re===!0)&&D.createElement(Of,{position:q,centerX:E,centerY:_,radius:z,onMouseDown:Le,onMouseEnter:ze,onMouseOut:Ne,type:"source"}),(re==="target"||re===!0)&&D.createElement(Of,{position:L,centerX:T,centerY:N,radius:z,onMouseDown:Ge,onMouseEnter:ze,onMouseOut:Ne,type:"target"})))};return t.displayName="EdgeWrapper",S.memo(t)};function kC(e){const t={default:Xn(e.default||ki),straight:Xn(e.bezier||hd),step:Xn(e.step||fd),smoothstep:Xn(e.step||Ui),simplebezier:Xn(e.simplebezier||dd)},n={},r=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,a)=>(i[a]=Xn(e[a]||ki),i),n);return{...t,...r}}function Lf(e,t,n=null){const r=(n?.x||0)+t.x,i=(n?.y||0)+t.y,a=n?.width||t.width,o=n?.height||t.height;switch(e){case Y.Top:return{x:r+a/2,y:i};case Y.Right:return{x:r+a,y:i+o/2};case Y.Bottom:return{x:r+a/2,y:i+o};case Y.Left:return{x:r,y:i+o/2}}}function Pf(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const RC=(e,t,n,r,i,a)=>{const o=Lf(n,e,t),s=Lf(a,r,i);return{sourceX:o.x,sourceY:o.y,targetX:s.x,targetY:s.y}};function IC({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:a,width:o,height:s,transform:c}){const l={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+a)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u=ld({x:(0-c[0])/c[2],y:(0-c[1])/c[2],width:o/c[2],height:s/c[2]}),d=Math.max(0,Math.min(u.x2,l.x2)-Math.max(u.x,l.x)),f=Math.max(0,Math.min(u.y2,l.y2)-Math.max(u.y,l.y));return Math.ceil(d*f)>0}function Df(e){const t=e?.[Me]?.handleBounds||null,n=t&&e?.width&&e?.height&&typeof e?.positionAbsolute?.x<"u"&&typeof e?.positionAbsolute?.y<"u";return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}const MC=[{level:0,isMaxLevel:!0,edges:[]}];function qC(e,t,n=!1){let r=-1;const i=e.reduce((o,s)=>{const c=kt(s.zIndex);let l=c?s.zIndex:0;if(n){const u=t.get(s.target),d=t.get(s.source),f=s.selected||u?.selected||d?.selected,h=Math.max(d?.[Me]?.z||0,u?.[Me]?.z||0,1e3);l=(c?s.zIndex:0)+(f?h:0)}return o[l]?o[l].push(s):o[l]=[s],r=l>r?l:r,o},{}),a=Object.entries(i).map(([o,s])=>{const c=+o;return{edges:s,level:c,isMaxLevel:c===r}});return a.length===0?MC:a}function OC(e,t,n){const r=Se(S.useCallback(i=>e?i.edges.filter(a=>{const o=t.get(a.source),s=t.get(a.target);return o?.width&&o?.height&&s?.width&&s?.height&&IC({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:s.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:s.width,targetHeight:s.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return qC(r,t,n)}const LC=({color:e="none",strokeWidth:t=1})=>D.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),PC=({color:e="none",strokeWidth:t=1})=>D.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),jf={[Ti.Arrow]:LC,[Ti.ArrowClosed]:PC};function DC(e){const t=Je();return S.useMemo(()=>Object.prototype.hasOwnProperty.call(jf,e)?jf[e]:(t.getState().onError?.("009",on.error009(e)),null),[e])}const jC=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a="strokeWidth",strokeWidth:o,orient:s="auto-start-reverse"})=>{const c=DC(t);return c?D.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:a,orient:s,refX:"0",refY:"0"},D.createElement(c,{color:n,strokeWidth:o})):null},$C=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((i,a)=>([a.markerStart,a.markerEnd].forEach(o=>{if(o&&typeof o=="object"){const s=Pl(o,t);r.includes(s)||(i.push({id:s,color:o.color||e,...o}),r.push(s))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))},Vb=({defaultColor:e,rfId:t})=>{const n=Se(S.useCallback($C({defaultColor:e,rfId:t}),[e,t]),(r,i)=>!(r.length!==i.length||r.some((a,o)=>a.id!==i[o].id)));return D.createElement("defs",null,n.map(r=>D.createElement(jC,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};Vb.displayName="MarkerDefinitions";var zC=S.memo(Vb);const FC=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Kb=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:g,reconnectRadius:m,children:y,disableKeyboardA11y:v})=>{const{edgesFocusable:b,edgesUpdatable:E,elementsSelectable:_,width:T,height:N,connectionMode:q,nodeInternals:L,onError:O}=Se(FC,bt),R=OC(t,L,n);return T?D.createElement(D.Fragment,null,R.map(({level:I,edges:G,isMaxLevel:H})=>D.createElement("svg",{key:I,style:{zIndex:I},width:T,height:N,className:"react-flow__edges react-flow__container"},H&&D.createElement(zC,{defaultColor:e,rfId:r}),D.createElement("g",null,G.map(x=>{const[M,k,z]=Df(L.get(x.source)),[P,C,j]=Df(L.get(x.target));if(!z||!j)return null;let $=x.type||"default";i[$]||(O?.("011",on.error011($)),$="default");const U=i[$]||i.default,K=q===Pn.Strict?C.target:(C.target??[]).concat(C.source??[]),V=Pf(k.source,x.sourceHandle),se=Pf(K,x.targetHandle),re=V?.position||Y.Bottom,de=se?.position||Y.Top,ie=!!(x.focusable||b&&typeof x.focusable>"u"),he=x.reconnectable||x.updatable,ue=typeof f<"u"&&(he||E&&typeof he>"u");if(!V||!se)return O?.("008",on.error008(V,x)),null;const{sourceX:ve,sourceY:qe,targetX:Oe,targetY:Re}=RC(M,V,re,P,se,de);return D.createElement(U,{key:x.id,id:x.id,className:ot([x.className,a]),type:$,data:x.data,selected:!!x.selected,animated:!!x.animated,hidden:!!x.hidden,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,style:x.style,source:x.source,target:x.target,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerEnd:x.markerEnd,markerStart:x.markerStart,sourceX:ve,sourceY:qe,targetX:Oe,targetY:Re,sourcePosition:re,targetPosition:de,elementsSelectable:_,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,onEdgeDoubleClick:d,onReconnect:f,onReconnectStart:h,onReconnectEnd:g,reconnectRadius:m,rfId:r,ariaLabel:x.ariaLabel,isFocusable:ie,isReconnectable:ue,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth,disableKeyboardA11y:v})})))),y):null};Kb.displayName="EdgeRenderer";var HC=S.memo(Kb);const UC=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function BC({children:e}){const t=Se(UC);return D.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function GC(e){const t=jt(),n=S.useRef(!1);S.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const VC={[Y.Left]:Y.Right,[Y.Right]:Y.Left,[Y.Top]:Y.Bottom,[Y.Bottom]:Y.Top},Wb=({nodeId:e,handleType:t,style:n,type:r=pn.Bezier,CustomComponent:i,connectionStatus:a})=>{const{fromNode:o,handleId:s,toX:c,toY:l,connectionMode:u}=Se(S.useCallback(N=>({fromNode:N.nodeInternals.get(e),handleId:N.connectionHandleId,toX:(N.connectionPosition.x-N.transform[0])/N.transform[2],toY:(N.connectionPosition.y-N.transform[1])/N.transform[2],connectionMode:N.connectionMode}),[e]),bt),d=o?.[Me]?.handleBounds;let f=d?.[t];if(u===Pn.Loose&&(f=f||d?.[t==="source"?"target":"source"]),!o||!f)return null;const h=s?f.find(N=>N.id===s):f[0],g=h?h.x+h.width/2:(o.width??0)/2,m=h?h.y+h.height/2:o.height??0,y=(o.positionAbsolute?.x??0)+g,v=(o.positionAbsolute?.y??0)+m,b=h?.position,E=b?VC[b]:null;if(!b||!E)return null;if(i)return D.createElement(i,{connectionLineType:r,connectionLineStyle:n,fromNode:o,fromHandle:h,fromX:y,fromY:v,toX:c,toY:l,fromPosition:b,toPosition:E,connectionStatus:a});let _="";const T={sourceX:y,sourceY:v,sourcePosition:b,targetX:c,targetY:l,targetPosition:E};return r===pn.Bezier?[_]=pd(T):r===pn.Step?[_]=Ll({...T,borderRadius:0}):r===pn.SmoothStep?[_]=Ll(T):r===pn.SimpleBezier?[_]=gb(T):_=`M${y},${v} ${c},${l}`,D.createElement("path",{d:_,fill:"none",className:"react-flow__connection-path",style:n})};Wb.displayName="ConnectionLine";const KC=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function WC({containerStyle:e,style:t,type:n,component:r}){const{nodeId:i,handleType:a,nodesConnectable:o,width:s,height:c,connectionStatus:l}=Se(KC,bt);return!(i&&a&&s&&o)?null:D.createElement("svg",{style:e,width:s,height:c,className:"react-flow__edges react-flow__connectionline react-flow__container"},D.createElement("g",{className:ot(["react-flow__connection",l])},D.createElement(Wb,{nodeId:i,handleType:a,style:t,type:n,CustomComponent:r,connectionStatus:l})))}function $f(e,t){return S.useRef(null),Je(),S.useMemo(()=>t(e),[e])}const Yb=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:a,onNodeClick:o,onEdgeClick:s,onNodeDoubleClick:c,onEdgeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,onSelectionContextMenu:g,onSelectionStart:m,onSelectionEnd:y,connectionLineType:v,connectionLineStyle:b,connectionLineComponent:E,connectionLineContainerStyle:_,selectionKeyCode:T,selectionOnDrag:N,selectionMode:q,multiSelectionKeyCode:L,panActivationKeyCode:O,zoomActivationKeyCode:R,deleteKeyCode:I,onlyRenderVisibleElements:G,elementsSelectable:H,selectNodesOnDrag:x,defaultViewport:M,translateExtent:k,minZoom:z,maxZoom:P,preventScrolling:C,defaultMarkerColor:j,zoomOnScroll:$,zoomOnPinch:U,panOnScroll:K,panOnScrollSpeed:V,panOnScrollMode:se,zoomOnDoubleClick:re,panOnDrag:de,onPaneClick:ie,onPaneMouseEnter:he,onPaneMouseMove:ue,onPaneMouseLeave:ve,onPaneScroll:qe,onPaneContextMenu:Oe,onEdgeContextMenu:Re,onEdgeMouseEnter:te,onEdgeMouseMove:we,onEdgeMouseLeave:ee,onReconnect:W,onReconnectStart:pe,onReconnectEnd:et,reconnectRadius:je,noDragClassName:Ie,noWheelClassName:xe,noPanClassName:Ce,elevateEdgesOnSelect:Le,disableKeyboardA11y:Ge,nodeOrigin:ze,nodeExtent:Ne,rfId:Fe})=>{const Ve=$f(e,wC),Ae=$f(t,kC);return GC(a),D.createElement(xC,{onPaneClick:ie,onPaneMouseEnter:he,onPaneMouseMove:ue,onPaneMouseLeave:ve,onPaneContextMenu:Oe,onPaneScroll:qe,deleteKeyCode:I,selectionKeyCode:T,selectionOnDrag:N,selectionMode:q,onSelectionStart:m,onSelectionEnd:y,multiSelectionKeyCode:L,panActivationKeyCode:O,zoomActivationKeyCode:R,elementsSelectable:H,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:$,zoomOnPinch:U,zoomOnDoubleClick:re,panOnScroll:K,panOnScrollSpeed:V,panOnScrollMode:se,panOnDrag:de,defaultViewport:M,translateExtent:k,minZoom:z,maxZoom:P,onSelectionContextMenu:g,preventScrolling:C,noDragClassName:Ie,noWheelClassName:xe,noPanClassName:Ce,disableKeyboardA11y:Ge},D.createElement(BC,null,D.createElement(HC,{edgeTypes:Ae,onEdgeClick:s,onEdgeDoubleClick:l,onlyRenderVisibleElements:G,onEdgeContextMenu:Re,onEdgeMouseEnter:te,onEdgeMouseMove:we,onEdgeMouseLeave:ee,onReconnect:W,onReconnectStart:pe,onReconnectEnd:et,reconnectRadius:je,defaultMarkerColor:j,noPanClassName:Ce,elevateEdgesOnSelect:!!Le,disableKeyboardA11y:Ge,rfId:Fe},D.createElement(WC,{style:b,type:v,component:E,containerStyle:_})),D.createElement("div",{className:"react-flow__edgelabel-renderer"}),D.createElement(CC,{nodeTypes:Ve,onNodeClick:o,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,selectNodesOnDrag:x,onlyRenderVisibleElements:G,noPanClassName:Ce,noDragClassName:Ie,disableKeyboardA11y:Ge,nodeOrigin:ze,nodeExtent:Ne,rfId:Fe})))};Yb.displayName="GraphView";var YC=S.memo(Yb);const zl=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ln={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:zl,nodeExtent:zl,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Pn.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:NS,isValidConnection:void 0},XC=()=>z_((e,t)=>({...ln,setNodes:n=>{const{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:a}=t();e({nodeInternals:ba(n,r,i,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(n,r)=>{const i=typeof n<"u",a=typeof r<"u",o=i?ba(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:o,edges:a?r:[],hasDefaultNodes:i,hasDefaultEdges:a})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:i,fitViewOnInit:a,fitViewOnInitDone:o,fitViewOnInitOptions:s,domNode:c,nodeOrigin:l}=t(),u=c?.querySelector(".react-flow__viewport");if(!u)return;const d=window.getComputedStyle(u),{m22:f}=new window.DOMMatrixReadOnly(d.transform),h=n.reduce((m,y)=>{const v=i.get(y.id);if(v?.hidden)i.set(v.id,{...v,[Me]:{...v[Me],handleBounds:void 0}});else if(v){const b=cd(y.nodeElement);!!(b.width&&b.height&&(v.width!==b.width||v.height!==b.height||y.forceUpdate))&&(i.set(v.id,{...v,[Me]:{...v[Me],handleBounds:{source:Mf(".source",y.nodeElement,f,l),target:Mf(".target",y.nodeElement,f,l)}},...b}),m.push({id:v.id,type:"dimensions",dimensions:b}))}return m},[]);Ob(i,l);const g=o||a&&!o&&Lb(t,{initial:!0,...s});e({nodeInternals:new Map(i),fitViewOnInitDone:g}),h?.length>0&&r?.(h)},updateNodePositions:(n,r=!0,i=!1)=>{const{triggerNodeChanges:a}=t(),o=n.map(s=>{const c={id:s.id,type:"position",dragging:i};return r&&(c.positionAbsolute=s.positionAbsolute,c.position=s.position),c});a(o)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:i,hasDefaultNodes:a,nodeOrigin:o,getNodes:s,elevateNodesOnSelect:c}=t();if(n?.length){if(a){const l=Db(n,s()),u=ba(l,i,o,c);e({nodeInternals:u})}r?.(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:i,getNodes:a}=t();let o,s=null;r?o=n.map(c=>hn(c,!0)):(o=or(a(),n),s=or(i,[])),di({changedNodes:o,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:i,getNodes:a}=t();let o,s=null;r?o=n.map(c=>hn(c,!0)):(o=or(i,n),s=or(a(),[])),di({changedNodes:s,changedEdges:o,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:i,getNodes:a}=t(),o=n||a(),s=r||i,c=o.map(u=>(u.selected=!1,hn(u.id,!1))),l=s.map(u=>hn(u.id,!1));di({changedNodes:c,changedEdges:l,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:i}=t();r?.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:i}=t();r?.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),a=r().filter(s=>s.selected).map(s=>hn(s.id,!1)),o=n.filter(s=>s.selected).map(s=>hn(s.id,!1));di({changedNodes:a,changedEdges:o,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(i=>{i.positionAbsolute=ud(i.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:i,height:a,d3Zoom:o,d3Selection:s,translateExtent:c}=t();if(!o||!s||!n.x&&!n.y)return!1;const l=mn.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),u=[[0,0],[i,a]],d=o?.constrain()(l,u,c);return o.transform(s,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>e({connectionNodeId:ln.connectionNodeId,connectionHandleId:ln.connectionHandleId,connectionHandleType:ln.connectionHandleType,connectionStatus:ln.connectionStatus,connectionStartHandle:ln.connectionStartHandle,connectionEndHandle:ln.connectionEndHandle}),reset:()=>e({...ln})}),Object.is),xd=({children:e})=>{const t=S.useRef(null);return t.current||(t.current=XC()),D.createElement(vS,{value:t.current},e)};xd.displayName="ReactFlowProvider";const Xb=({children:e})=>S.useContext(Hi)?D.createElement(D.Fragment,null,e):D.createElement(xd,null,e);Xb.displayName="ReactFlowWrapper";const ZC={input:Ab,default:jl,output:kb,group:vd},QC={default:ki,straight:hd,step:fd,smoothstep:Ui,simplebezier:dd},JC=[0,0],eN=[15,15],tN={x:0,y:0,zoom:1},nN={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Zb=S.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a=ZC,edgeTypes:o=QC,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:g,onConnectEnd:m,onClickConnectStart:y,onClickConnectEnd:v,onNodeMouseEnter:b,onNodeMouseMove:E,onNodeMouseLeave:_,onNodeContextMenu:T,onNodeDoubleClick:N,onNodeDragStart:q,onNodeDrag:L,onNodeDragStop:O,onNodesDelete:R,onEdgesDelete:I,onSelectionChange:G,onSelectionDragStart:H,onSelectionDrag:x,onSelectionDragStop:M,onSelectionContextMenu:k,onSelectionStart:z,onSelectionEnd:P,connectionMode:C=Pn.Strict,connectionLineType:j=pn.Bezier,connectionLineStyle:$,connectionLineComponent:U,connectionLineContainerStyle:K,deleteKeyCode:V="Backspace",selectionKeyCode:se="Shift",selectionOnDrag:re=!1,selectionMode:de=Vr.Full,panActivationKeyCode:ie="Space",multiSelectionKeyCode:he=Ai()?"Meta":"Control",zoomActivationKeyCode:ue=Ai()?"Meta":"Control",snapToGrid:ve=!1,snapGrid:qe=eN,onlyRenderVisibleElements:Oe=!1,selectNodesOnDrag:Re=!0,nodesDraggable:te,nodesConnectable:we,nodesFocusable:ee,nodeOrigin:W=JC,edgesFocusable:pe,edgesUpdatable:et,elementsSelectable:je,defaultViewport:Ie=tN,minZoom:xe=.5,maxZoom:Ce=2,translateExtent:Le=zl,preventScrolling:Ge=!0,nodeExtent:ze,defaultMarkerColor:Ne="#b1b1b7",zoomOnScroll:Fe=!0,zoomOnPinch:Ve=!0,panOnScroll:Ae=!1,panOnScrollSpeed:Ze=.5,panOnScrollMode:$e=Mn.Free,zoomOnDoubleClick:Ke=!0,panOnDrag:qt=!0,onPaneClick:Qe,onPaneMouseEnter:ht,onPaneMouseMove:st,onPaneMouseLeave:Nt,onPaneScroll:Ot,onPaneContextMenu:Kt,children:Un,onEdgeContextMenu:_t,onEdgeDoubleClick:Wt,onEdgeMouseEnter:Bn,onEdgeMouseMove:Yt,onEdgeMouseLeave:Gn,onEdgeUpdate:wr,onEdgeUpdateStart:A,onEdgeUpdateEnd:B,onReconnect:J,onReconnectStart:X,onReconnectEnd:Z,reconnectRadius:ae=10,edgeUpdaterRadius:_e=10,onNodesChange:oe,onEdgesChange:ce,noDragClassName:Te="nodrag",noWheelClassName:fe="nowheel",noPanClassName:it="nopan",fitView:pt=!1,fitViewOptions:gt,connectOnClick:ke=!0,attributionPosition:tt,proOptions:lt,defaultEdgeOptions:Ft,elevateNodesOnSelect:Vn=!0,elevateEdgesOnSelect:Cn=!1,disableKeyboardA11y:Nn=!1,autoPanOnConnect:An=!0,autoPanOnNodeDrag:Xt=!0,connectionRadius:ne=20,isValidConnection:w,onError:F,style:Q,id:me,nodeDragThreshold:He,...Ue},ct)=>{const At=me||"1";return D.createElement("div",{...Ue,style:{...Q,...nN},ref:ct,className:ot(["react-flow",i]),"data-testid":"rf__wrapper",id:me},D.createElement(Xb,null,D.createElement(YC,{onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:E,onNodeMouseLeave:_,onNodeContextMenu:T,onNodeDoubleClick:N,nodeTypes:a,edgeTypes:o,connectionLineType:j,connectionLineStyle:$,connectionLineComponent:U,connectionLineContainerStyle:K,selectionKeyCode:se,selectionOnDrag:re,selectionMode:de,deleteKeyCode:V,multiSelectionKeyCode:he,panActivationKeyCode:ie,zoomActivationKeyCode:ue,onlyRenderVisibleElements:Oe,selectNodesOnDrag:Re,defaultViewport:Ie,translateExtent:Le,minZoom:xe,maxZoom:Ce,preventScrolling:Ge,zoomOnScroll:Fe,zoomOnPinch:Ve,zoomOnDoubleClick:Ke,panOnScroll:Ae,panOnScrollSpeed:Ze,panOnScrollMode:$e,panOnDrag:qt,onPaneClick:Qe,onPaneMouseEnter:ht,onPaneMouseMove:st,onPaneMouseLeave:Nt,onPaneScroll:Ot,onPaneContextMenu:Kt,onSelectionContextMenu:k,onSelectionStart:z,onSelectionEnd:P,onEdgeContextMenu:_t,onEdgeDoubleClick:Wt,onEdgeMouseEnter:Bn,onEdgeMouseMove:Yt,onEdgeMouseLeave:Gn,onReconnect:J??wr,onReconnectStart:X??A,onReconnectEnd:Z??B,reconnectRadius:ae??_e,defaultMarkerColor:Ne,noDragClassName:Te,noWheelClassName:fe,noPanClassName:it,elevateEdgesOnSelect:Cn,rfId:At,disableKeyboardA11y:Nn,nodeOrigin:W,nodeExtent:ze}),D.createElement(KS,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:g,onConnectEnd:m,onClickConnectStart:y,onClickConnectEnd:v,nodesDraggable:te,nodesConnectable:we,nodesFocusable:ee,edgesFocusable:pe,edgesUpdatable:et,elementsSelectable:je,elevateNodesOnSelect:Vn,minZoom:xe,maxZoom:Ce,nodeExtent:ze,onNodesChange:oe,onEdgesChange:ce,snapToGrid:ve,snapGrid:qe,connectionMode:C,translateExtent:Le,connectOnClick:ke,defaultEdgeOptions:Ft,fitView:pt,fitViewOptions:gt,onNodesDelete:R,onEdgesDelete:I,onNodeDragStart:q,onNodeDrag:L,onNodeDragStop:O,onSelectionDrag:x,onSelectionDragStart:H,onSelectionDragStop:M,noPanClassName:it,nodeOrigin:W,rfId:At,autoPanOnConnect:An,autoPanOnNodeDrag:Xt,onError:F,connectionRadius:ne,isValidConnection:w,nodeDragThreshold:He}),D.createElement(GS,{onSelectionChange:G}),Un,D.createElement(xS,{proOptions:lt,position:tt}),D.createElement(QS,{rfId:At,disableKeyboardA11y:Nn})))});Zb.displayName="ReactFlow";const rN=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function zf({children:e}){const t=Se(rN);return t?Ev.createPortal(e,t):null}function iN(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}function aN(){return D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},D.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function oN(){return D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},D.createElement("path",{d:"M0 0h32v4.2H0z"}))}function sN(){return D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},D.createElement("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 cN(){return D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},D.createElement("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 uN(){return D.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},D.createElement("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"}))}const Mr=({children:e,className:t,...n})=>D.createElement("button",{type:"button",className:ot(["react-flow__controls-button",t]),...n},e);Mr.displayName="ControlButton";const lN=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Qb=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d="bottom-left"})=>{const f=Je(),[h,g]=S.useState(!1),{isInteractive:m,minZoomReached:y,maxZoomReached:v}=Se(lN,iN),{zoomIn:b,zoomOut:E,fitView:_}=jt();if(S.useEffect(()=>{g(!0)},[]),!h)return null;const T=()=>{b(),a?.()},N=()=>{E(),o?.()},q=()=>{_(i),s?.()},L=()=>{f.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),c?.(!m)};return D.createElement(cb,{className:ot(["react-flow__controls",l]),position:d,style:e,"data-testid":"rf__controls"},t&&D.createElement(D.Fragment,null,D.createElement(Mr,{onClick:T,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:v},D.createElement(aN,null)),D.createElement(Mr,{onClick:N,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:y},D.createElement(oN,null))),n&&D.createElement(Mr,{className:"react-flow__controls-fitview",onClick:q,title:"fit view","aria-label":"fit view"},D.createElement(sN,null)),r&&D.createElement(Mr,{className:"react-flow__controls-interactive",onClick:L,title:"toggle interactivity","aria-label":"toggle interactivity"},m?D.createElement(uN,null):D.createElement(cN,null)),u)};Qb.displayName="Controls";var dN=S.memo(Qb);function fN(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var Pt;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Pt||(Pt={}));function hN({color:e,dimensions:t,lineWidth:n}){return D.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function pN({color:e,radius:t}){return D.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const gN={[Pt.Dots]:"#91919a",[Pt.Lines]:"#eee",[Pt.Cross]:"#e2e2e2"},mN={[Pt.Dots]:1,[Pt.Lines]:1,[Pt.Cross]:6},yN=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Jb({id:e,variant:t=Pt.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=2,color:o,style:s,className:c}){const l=S.useRef(null),{transform:u,patternId:d}=Se(yN,fN),f=o||gN[t],h=r||mN[t],g=t===Pt.Dots,m=t===Pt.Cross,y=Array.isArray(n)?n:[n,n],v=[y[0]*u[2]||1,y[1]*u[2]||1],b=h*u[2],E=m?[b,b]:v,_=g?[b/a,b/a]:[E[0]/a,E[1]/a];return D.createElement("svg",{className:ot(["react-flow__background",c]),style:{...s,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:l,"data-testid":"rf__background"},D.createElement("pattern",{id:d+e,x:u[0]%v[0],y:u[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`},g?D.createElement(pN,{color:f,radius:b/a}):D.createElement(hN,{dimensions:E,color:f,lineWidth:i})),D.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`}))}Jb.displayName="Background";var vN=S.memo(Jb);function bN(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const xN=e=>e.domNode?.querySelector(".react-flow__renderer");function _N({children:e}){const t=Se(xN);return t?Ev.createPortal(e,t):null}const wN=(e,t)=>e?.positionAbsolute?.x===t?.positionAbsolute?.x&&e?.positionAbsolute?.y===t?.positionAbsolute?.y&&e?.width===t?.width&&e?.height===t?.height&&e?.selected===t?.selected&&e?.[Me]?.z===t?.[Me]?.z,EN=(e,t)=>e.length===t.length&&e.every((n,r)=>wN(n,t[r])),SN=e=>({transform:e.transform,nodeOrigin:e.nodeOrigin,selectedNodesCount:e.getNodes().filter(t=>t.selected).length});function CN(e,t,n,r,i){let a=.5;i==="start"?a=0:i==="end"&&(a=1);let o=[(e.x+e.width*a)*t[2]+t[0],e.y*t[2]+t[1]-r],s=[-100*a,-100];switch(n){case Y.Right:o=[(e.x+e.width)*t[2]+t[0]+r,(e.y+e.height*a)*t[2]+t[1]],s=[0,-100*a];break;case Y.Bottom:o[1]=(e.y+e.height)*t[2]+t[1]+r,s[1]=0;break;case Y.Left:o=[e.x*t[2]+t[0]-r,(e.y+e.height*a)*t[2]+t[1]],s=[-100,-100*a];break}return`translate(${o[0]}px, ${o[1]}px) translate(${s[0]}%, ${s[1]}%)`}function ex({nodeId:e,children:t,className:n,style:r,isVisible:i,position:a=Y.Top,offset:o=10,align:s="center",...c}){const l=md(),u=S.useCallback(E=>(Array.isArray(e)?e:[e||l||""]).reduce((T,N)=>{const q=E.nodeInternals.get(N);return q&&T.push(q),T},[]),[e,l]),d=Se(u,EN),{transform:f,nodeOrigin:h,selectedNodesCount:g}=Se(SN,bN);if(!(typeof i=="boolean"?i:d.length===1&&d[0].selected&&g===1)||!d.length)return null;const y=Bi(d,h),v=Math.max(...d.map(E=>(E[Me]?.z||1)+1)),b={position:"absolute",transform:CN(y,f,a,o,s),zIndex:v,...r};return D.createElement(_N,null,D.createElement("div",{style:b,className:ot(["react-flow__node-toolbar",n]),...c},t))}var dr;(function(e){e.Line="line",e.Handle="handle"})(dr||(dr={}));function NN({width:e,prevWidth:t,height:n,prevHeight:r,invertX:i,invertY:a}){const o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]=c[0]*-1),s&&a&&(c[1]=c[1]*-1),c}const tx={width:0,height:0,x:0,y:0},AN={...tx,pointerX:0,pointerY:0,aspectRatio:1};function TN({nodeId:e,position:t,variant:n=dr.Handle,className:r,style:i={},children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,shouldResize:f,onResizeStart:h,onResize:g,onResizeEnd:m}){const y=md(),v=typeof e=="string"?e:y,b=Je(),E=S.useRef(null),_=S.useRef(AN),T=S.useRef(tx),N=Fb(),q=n===dr.Line?"right":"bottom-right",L=t??q;S.useEffect(()=>{if(!E.current||!v)return;const G=Tt(E.current),H=L.includes("right")||L.includes("left"),x=L.includes("bottom")||L.includes("top"),M=L.includes("left"),k=L.includes("top"),z=Kv().on("start",P=>{const C=b.getState().nodeInternals.get(v),{xSnapped:j,ySnapped:$}=N(P);T.current={width:C?.width??0,height:C?.height??0,x:C?.position.x??0,y:C?.position.y??0},_.current={...T.current,pointerX:j,pointerY:$,aspectRatio:T.current.width/T.current.height},h?.(P,{...T.current})}).on("drag",P=>{const{nodeInternals:C,triggerNodeChanges:j}=b.getState(),{xSnapped:$,ySnapped:U}=N(P),K=C.get(v);if(K){const V=[],{pointerX:se,pointerY:re,width:de,height:ie,x:he,y:ue,aspectRatio:ve}=_.current,{x:qe,y:Oe,width:Re,height:te}=T.current,we=Math.floor(H?$-se:0),ee=Math.floor(x?U-re:0);let W=_n(de+(M?-we:we),s,l),pe=_n(ie+(k?-ee:ee),c,u);if(d){const Le=W/pe,Ge=H&&x,ze=H&&!x,Ne=x&&!H;W=Le<=ve&&Ge||Ne?pe*ve:W,pe=Le>ve&&Ge||ze?W/ve:pe,W>=l?(W=l,pe=l/ve):W<=s&&(W=s,pe=s/ve),pe>=u?(pe=u,W=u*ve):pe<=c&&(pe=c,W=c*ve)}const et=W!==Re,je=pe!==te;if(M||k){const Le=M?he-(W-de):he,Ge=k?ue-(pe-ie):ue,ze=Le!==qe&&et,Ne=Ge!==Oe&&je;if(ze||Ne){const Fe={id:K.id,type:"position",position:{x:ze?Le:qe,y:Ne?Ge:Oe}};V.push(Fe),T.current.x=Fe.position.x,T.current.y=Fe.position.y}}if(et||je){const Le={id:v,type:"dimensions",updateStyle:!0,resizing:!0,dimensions:{width:W,height:pe}};V.push(Le),T.current.width=W,T.current.height=pe}if(V.length===0)return;const Ie=NN({width:T.current.width,prevWidth:Re,height:T.current.height,prevHeight:te,invertX:M,invertY:k}),xe={...T.current,direction:Ie};if(f?.(P,xe)===!1)return;g?.(P,xe),j(V)}}).on("end",P=>{const C={id:v,type:"dimensions",resizing:!1};m?.(P,{...T.current}),b.getState().triggerNodeChanges([C])});return G.call(z),()=>{G.on(".drag",null)}},[v,L,s,c,l,u,d,N,h,g,m]);const O=L.split("-"),R=n===dr.Line?"borderColor":"backgroundColor",I=o?{...i,[R]:o}:i;return D.createElement("div",{className:ot(["react-flow__resize-control","nodrag",...O,n,r]),ref:E,style:I},a)}var Ff=S.memo(TN);const kN=["top-left","top-right","bottom-left","bottom-right"],RN=["top","right","bottom","left"];function Fl({nodeId:e,isVisible:t=!0,handleClassName:n,handleStyle:r,lineClassName:i,lineStyle:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,shouldResize:f,onResizeStart:h,onResize:g,onResizeEnd:m}){return t?D.createElement(D.Fragment,null,RN.map(y=>D.createElement(Ff,{key:y,className:i,style:a,nodeId:e,position:y,variant:dr.Line,color:o,minWidth:s,minHeight:c,maxWidth:l,maxHeight:u,onResizeStart:h,keepAspectRatio:d,shouldResize:f,onResize:g,onResizeEnd:m})),kN.map(y=>D.createElement(Ff,{key:y,className:n,style:r,nodeId:e,position:y,color:o,minWidth:s,minHeight:c,maxWidth:l,maxHeight:u,onResizeStart:h,keepAspectRatio:d,shouldResize:f,onResize:g,onResizeEnd:m}))):null}async function Hl(e){const t=new URLSearchParams({profile:e.profile});e.catalog&&t.set("catalog",e.catalog),e.database&&t.set("database",e.database);const n=`/api/live/schemas/${encodeURIComponent(e.schema)}/tables/${encodeURIComponent(e.table)}/columns?${t.toString()}`;try{return((await En(n)).columns||[]).map(i=>({name:String(i.name||""),dtype:String(i.dtype||"")}))}catch{return[]}}function _d(e){return`${e.profile}/${e.database}/${e.schema}/${e.table}`}function IN({selected:e,onChange:t}){const n=Dn({queryKey:["lineage","asset-picker","db-profiles"],queryFn:()=>En("/api/profiles/db"),staleTime:3e4});if(n.isLoading)return p.jsx(rn,{children:"Loading DB profiles…"});if(n.error)return p.jsx(Gi,{children:n.error.message});const r=n.data?.profiles??[];return r.length===0?p.jsx(rn,{children:"No DB profiles configured."}):p.jsx("div",{className:"space-y-2",children:r.map(i=>p.jsx(MN,{profile:i.name,backend:i.backend??"unknown",selected:e,onChange:t},i.name))})}function MN({profile:e,backend:t,selected:n,onChange:r}){const[i,a]=S.useState(!1),o=Array.from(n.keys()).filter(s=>s.startsWith(`${e}/`)).length;return p.jsxs("div",{className:"rounded-md border border-surface-border bg-surface",children:[p.jsxs("button",{type:"button",onClick:()=>a(s=>!s),className:"flex w-full items-center justify-between gap-2 px-3 py-2 text-sm",children:[p.jsxs("span",{className:"inline-flex min-w-0 items-center gap-1.5 font-medium text-ink",children:[i?p.jsx(Di,{size:14}):p.jsx(Jl,{size:14}),p.jsx(D0,{size:14}),p.jsx("span",{className:"truncate",children:e}),p.jsxs("span",{className:"text-[11px] text-fg-muted",children:["(",t,")"]})]}),o>0&&p.jsxs("span",{className:"rounded-full bg-accent-soft px-1.5 text-[10px] font-semibold text-accent-ink",children:[o," selected"]})]}),i&&p.jsx("div",{className:"border-t border-surface-border p-2",children:p.jsx(qN,{profile:e,backend:t,selected:n,onChange:r})})]})}function qN({profile:e,backend:t,selected:n,onChange:r}){const i=Dn({queryKey:["lineage","tree-cache",e,"databases"],queryFn:()=>fr.dbCacheTreeDatabases(e),staleTime:3e4});if(i.isLoading)return p.jsx(rn,{indent:1,children:"Loading…"});if(i.error)return p.jsx(Gi,{indent:1,children:i.error.message});if(!i.data?.synced)return p.jsx(rn,{indent:1,children:"Profile not synced."});const a=i.data.items;return a.length===0?p.jsx(rn,{indent:1,children:"No databases in cache."}):p.jsx("ul",{className:"space-y-0.5",children:a.map(o=>p.jsx(ON,{profile:e,backend:t,database:o.name,selected:n,onChange:r},o.name))})}function ON({profile:e,backend:t,database:n,selected:r,onChange:i}){const[a,o]=S.useState(!1),s=gr(),c=`${e}/${n}/`,l=Array.from(r.keys()).filter(f=>f.startsWith(c)),u=l.length===0?"off":"on";async function d(){if(l.length>0){const m=new Map(r);for(const y of l)m.delete(y);i(m);return}const f=await s.fetchQuery({queryKey:["lineage","tree-cache",e,n,"schemas"],queryFn:()=>fr.dbCacheTreeSchemas(e,n),staleTime:3e4});if(!f?.items)return;const h=await Promise.all(f.items.map(m=>s.fetchQuery({queryKey:["lineage","tree-cache",e,n,m.name,"tables"],queryFn:()=>fr.dbCacheTreeTables(e,n,m.name),staleTime:3e4}))),g=new Map(r);f.items.forEach((m,y)=>{const v=h[y]?.items??[];for(const b of v){const E={profile:e,backend:t,database:n,schema:m.name,table:b.name};g.set(_d(E),E)}}),i(g),o(!0)}return p.jsxs("li",{children:[p.jsx(wd,{indent:1,label:n,tristate:u,onToggleSelect:d,canExpand:!0,open:a,onToggleOpen:()=>o(f=>!f)}),a&&p.jsx(LN,{profile:e,backend:t,database:n,selected:r,onChange:i})]})}function LN({profile:e,backend:t,database:n,selected:r,onChange:i}){const a=Dn({queryKey:["lineage","tree-cache",e,n,"schemas"],queryFn:()=>fr.dbCacheTreeSchemas(e,n),staleTime:3e4});if(a.isLoading)return p.jsx(rn,{indent:2,children:"Loading schemas…"});if(a.error)return p.jsx(Gi,{indent:2,children:a.error.message});const o=a.data?.items??[];return o.length===0?p.jsx(rn,{indent:2,children:"No schemas in cache."}):p.jsx("ul",{className:"space-y-0.5",children:o.map(s=>p.jsx(PN,{profile:e,backend:t,database:n,schema:s.name,selected:r,onChange:i},s.name))})}function PN({profile:e,backend:t,database:n,schema:r,selected:i,onChange:a}){const[o,s]=S.useState(!1),c=gr(),l=`${e}/${n}/${r}/`,u=Array.from(i.keys()).filter(h=>h.startsWith(l)),d=u.length===0?"off":"on";async function f(){if(u.length>0){const m=new Map(i);for(const y of u)m.delete(y);a(m);return}const h=await c.fetchQuery({queryKey:["lineage","tree-cache",e,n,r,"tables"],queryFn:()=>fr.dbCacheTreeTables(e,n,r),staleTime:3e4});if(!h?.items)return;const g=new Map(i);for(const m of h.items){const y={profile:e,backend:t,database:n,schema:r,table:m.name};g.set(_d(y),y)}a(g),s(!0)}return p.jsxs("li",{children:[p.jsx(wd,{indent:2,label:r,tristate:d,onToggleSelect:f,canExpand:!0,open:o,onToggleOpen:()=>s(h=>!h)}),o&&p.jsx(DN,{profile:e,backend:t,database:n,schema:r,selected:i,onChange:a})]})}function DN({profile:e,backend:t,database:n,schema:r,selected:i,onChange:a}){const o=Dn({queryKey:["lineage","tree-cache",e,n,r,"tables"],queryFn:()=>fr.dbCacheTreeTables(e,n,r),staleTime:3e4});if(o.isLoading)return p.jsx(rn,{indent:3,children:"Loading tables…"});if(o.error)return p.jsx(Gi,{indent:3,children:o.error.message});const s=o.data?.items??[];return s.length===0?p.jsx(rn,{indent:3,children:"No tables in cache."}):p.jsx("ul",{className:"space-y-0.5",children:s.map(c=>{const l={profile:e,backend:t,database:n,schema:r,table:c.name},u=_d(l),d=i.has(u);return p.jsx("li",{children:p.jsx(wd,{indent:3,label:c.name,tristate:d?"on":"off",onToggleSelect:()=>{const f=new Map(i);d?f.delete(u):f.set(u,l),a(f)}})},c.name)})})}function wd({indent:e,label:t,tristate:n,onToggleSelect:r,canExpand:i,open:a,onToggleOpen:o}){return p.jsxs("div",{className:"flex items-center gap-1 rounded-sm px-1 py-0.5 text-[12.5px] hover:bg-surface-raised",style:{paddingLeft:4+e*14},children:[i?p.jsx("button",{type:"button",onClick:o,"aria-label":a?"Collapse":"Expand",className:"inline-flex h-4 w-4 items-center justify-center text-fg-muted hover:text-ink",children:a?p.jsx(Di,{size:11}):p.jsx(Jl,{size:11})}):p.jsx("span",{className:"inline-block h-4 w-4"}),p.jsxs("button",{type:"button",role:"checkbox","aria-checked":n==="on"?"true":n==="partial"?"mixed":"false",onClick:s=>{s.stopPropagation(),r()},className:Pe("inline-flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded border transition",n==="on"&&"border-accent-default bg-accent-default text-accent-ink",n==="partial"&&"border-accent-default bg-accent-soft text-accent-ink",n==="off"&&"border-surface-border bg-transparent text-transparent hover:border-ink/60"),children:[n==="on"&&p.jsx(j0,{size:10}),n==="partial"&&p.jsx($0,{size:10})]}),p.jsx("span",{className:"ml-1 truncate text-ink",children:t})]})}function rn({children:e,indent:t=0}){return p.jsx("div",{className:"text-[11px] text-fg-muted",style:{paddingLeft:4+t*14},children:e})}function Gi({children:e,indent:t=0}){return p.jsx("div",{className:"text-[11px] text-critical",style:{paddingLeft:4+t*14},children:e})}function jN({open:e,onClose:t,onPick:n,onBatchAdded:r}){const[i,a]=S.useState(()=>new Map),[o,s]=S.useState(!1);S.useEffect(()=>{e&&a(new Map)},[e]);const c=i.size,l=S.useMemo(()=>{if(c===0)return"";if(c===1){const d=Array.from(i.values())[0];return`${d.schema}.${d.table}`}return`${c} tables`},[c,i]);async function u(){if(!(o||c===0)){s(!0);try{for(const d of i.values())n({profile:d.profile,backend:d.backend,database:d.database,schema:d.schema,table:d.table,columns:[]});t(),r?.(c);for(const d of i.values())Hl({profile:d.profile,database:d.database,schema:d.schema,table:d.table}).then(f=>{f.length&&n({profile:d.profile,backend:d.backend,database:d.database,schema:d.schema,table:d.table,columns:f})}).catch(()=>{})}finally{s(!1)}}}return p.jsx(ar,{open:e,onClose:t,size:"md",title:p.jsxs("span",{className:"inline-flex items-center gap-2",children:[p.jsx(Sv,{size:14})," Add tables to canvas"]}),description:"Tick any number of tables across any DB profile — they all land on the canvas in one shot.",footer:p.jsxs("div",{className:"flex w-full items-center justify-between gap-2",children:[p.jsx("span",{className:"text-[11px] text-fg-muted",children:c>0?`Selected: ${l}`:"Nothing selected yet."}),p.jsxs("div",{className:"flex gap-2",children:[p.jsx(Et,{variant:"secondary",size:"sm",onClick:t,children:"Cancel"}),p.jsx(Et,{variant:"primary",size:"sm",disabled:c===0||o,loading:o,onClick:u,children:c>1?`Add ${c} tables`:"Add table"})]})]}),children:p.jsx("div",{className:"max-h-[480px] overflow-y-auto pr-1",children:p.jsx(IN,{selected:i,onChange:a})})})}function $N({open:e,onClose:t,nodes:n,onHighlight:r}){const[i,a]=S.useState("");S.useEffect(()=>{e&&a("")},[e]);const o=S.useMemo(()=>{const s=i.trim().toLowerCase();if(!s)return[];const c=[];for(const l of n){if(l.data.kind!=="table")continue;const u=l.data.fqn||l.id;for(const d of l.data.columns||[])d.name.toLowerCase().includes(s)&&c.push({nodeId:l.id,nodeLabel:u,column:d.name})}return c.slice(0,80)},[n,i]);return e?p.jsxs("div",{className:"fixed right-4 top-20 z-40 w-80 rounded-xl border border-amber-500/60 bg-surface-raised shadow-2xl",children:[p.jsxs("div",{className:"flex items-center gap-2 border-b border-surface-border px-3 py-2",children:[p.jsx("input",{autoFocus:!0,value:i,placeholder:"Track attribute by name…",onChange:s=>a(s.target.value),className:"flex-1 bg-transparent text-sm outline-none placeholder:text-fg-muted"}),p.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5 text-[10px] text-fg-muted",children:o.length}),p.jsx("button",{type:"button",onClick:t,"aria-label":"Close",className:"text-fg-muted hover:text-ink",children:p.jsx(Wr,{size:14})})]}),p.jsx("ul",{className:"max-h-72 overflow-y-auto text-[12px]",children:o.length===0?p.jsx("li",{className:"px-3 py-2 text-fg-muted",children:i.trim()?"No matches.":"Type to search columns…"}):o.map((s,c)=>p.jsx("li",{className:"flex cursor-pointer items-center justify-between gap-2 px-3 py-1.5 hover:bg-surface",onClick:()=>r(s.nodeId,s.column),children:p.jsxs("span",{className:"font-mono",children:[p.jsx("span",{className:"text-amber-300",children:s.column}),p.jsxs("span",{className:"text-fg-muted",children:[" · ",s.nodeLabel]})]})},`${s.nodeId}-${s.column}-${c}`))})]}):null}const zN=[{label:"Slate",value:"#e2e8f0"},{label:"Blue",value:"#60a5fa"},{label:"Green",value:"#4ade80"},{label:"Violet",value:"#c084fc"},{label:"Orange",value:"#fb923c"},{label:"Pink",value:"#f472b6"}],FN=["1:1","1:N","N:M"];function HN({x:e,y:t,styleColor:n,styleDashed:r,cardinality:i,fromColumn:a,toColumn:o,onChange:s,onDelete:c,onClose:l,onJumpToColumns:u}){const d=!!(a&&o),f={position:"absolute",transform:`translate(-50%, -120%) translate(${e}px, ${t}px)`,pointerEvents:"all",zIndex:30};return p.jsxs("div",{style:f,role:"dialog","aria-label":"Edit edge",className:"rounded-md border border-surface-border bg-surface-raised px-2 py-1.5 text-[11px] text-fg-muted shadow-xl",onClick:h=>h.stopPropagation(),onMouseDown:h=>h.stopPropagation(),children:[p.jsxs("div",{className:"flex items-center gap-1.5",children:[p.jsx("button",{type:"button",onClick:c,title:"Delete edge","aria-label":"Delete edge",className:"inline-flex h-6 w-6 items-center justify-center rounded text-fg-muted transition hover:bg-critical-soft hover:text-critical",children:p.jsx(Yr,{size:12})}),p.jsx("span",{className:"h-4 w-px bg-surface-border"}),p.jsxs("div",{className:"inline-flex overflow-hidden rounded border border-surface-border text-[10px]",children:[p.jsx("button",{type:"button",onClick:()=>s({styleDashed:!1}),"aria-pressed":r===!1,className:Pe("px-2 py-0.5 transition",r===!1?"bg-accent-soft text-accent-ink":"hover:bg-surface"),title:"Solid",children:"── solid"}),p.jsx("button",{type:"button",onClick:()=>s({styleDashed:!0}),"aria-pressed":r===!0,className:Pe("px-2 py-0.5 transition",r===!0?"bg-accent-soft text-accent-ink":"hover:bg-surface"),title:"Dashed",children:"┄ dashed"})]}),p.jsx("span",{className:"h-4 w-px bg-surface-border"}),p.jsx("div",{className:"flex items-center gap-1",children:zN.map(h=>p.jsx("button",{type:"button",onClick:()=>s({styleColor:h.value}),title:h.label,"aria-label":`Color: ${h.label}`,className:Pe("h-3.5 w-3.5 rounded-full border transition",n===h.value?"border-ink ring-1 ring-ink/40":"border-surface-border hover:border-ink/60"),style:{backgroundColor:h.value}},h.value))}),p.jsx("button",{type:"button",onClick:l,"aria-label":"Close edge editor",title:"Close",className:"ml-1 inline-flex h-6 w-6 items-center justify-center rounded text-fg-muted transition hover:bg-surface hover:text-ink",children:p.jsx(Wr,{size:12})})]}),p.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[p.jsx("span",{className:"text-[9.5px] uppercase tracking-wide text-fg-muted",children:"Cardinality"}),p.jsxs("div",{className:"inline-flex overflow-hidden rounded border border-surface-border text-[10px]",children:[p.jsx("button",{type:"button",onClick:()=>s({cardinality:null}),"aria-pressed":i===void 0,className:Pe("px-2 py-0.5 transition",i===void 0?"bg-accent-soft text-accent-ink":"hover:bg-surface"),title:"No marker",children:"none"}),FN.map(h=>p.jsx("button",{type:"button",onClick:()=>s({cardinality:h}),"aria-pressed":i===h,className:Pe("border-l border-surface-border px-2 py-0.5 transition",i===h?"bg-accent-soft text-accent-ink":"hover:bg-surface"),title:h,children:h},h))]})]}),d&&p.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[p.jsx("span",{className:"text-[9.5px] uppercase tracking-wide text-fg-muted",children:"Columns"}),p.jsxs("button",{type:"button",onClick:()=>u?.(),disabled:!u,title:"Open both tables and highlight these columns",className:Pe("inline-flex items-center gap-1 rounded border border-surface-border px-1.5 py-0.5 font-mono text-[10.5px] transition",u?"text-ink hover:bg-surface":"cursor-default text-fg-muted"),children:[p.jsx(o_,{size:10}),p.jsx("span",{className:"truncate",children:a}),p.jsx(z0,{size:9,className:"text-fg-muted"}),p.jsx("span",{className:"truncate",children:o})]})]})]})}const Ul={one:"lcv-marker-one",many:"lcv-marker-many"};function Hf(e,t){const n=e.x+e.width/2,r=e.y+e.height/2,i=t.x-n,a=t.y-r,o=Math.abs(i)/(e.width/2),s=Math.abs(a)/(e.height/2);return o>=s?i>=0?{x:e.x+e.width,y:r,pos:Y.Right}:{x:e.x,y:r,pos:Y.Left}:a>=0?{x:n,y:e.y+e.height,pos:Y.Bottom}:{x:n,y:e.y,pos:Y.Top}}function UN(e){return e?e==="1:1"?{source:Zn("one"),target:Zn("one")}:e==="1:N"?{source:Zn("one"),target:Zn("many")}:{source:Zn("many"),target:Zn("many")}:{source:void 0,target:void 0}}function Zn(e){return`url(#${Ul[e]})`}function BN({id:e,source:t,target:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,sourceHandleId:l,targetHandleId:u,data:d,selected:f,style:h}){const g=jt(),m=Se(S.useCallback(P=>{const C=P.nodeInternals.get(t),j=P.nodeInternals.get(n);if(!C||!j)return null;const $={x:C.positionAbsolute?.x??C.position?.x??0,y:C.positionAbsolute?.y??C.position?.y??0,width:C.width??240,height:C.height??140},U={x:j.positionAbsolute?.x??j.position?.x??0,y:j.positionAbsolute?.y??j.position?.y??0,width:j.width??240,height:j.height??140},K={x:$.x+$.width/2,y:$.y+$.height/2},V={x:U.x+U.width/2,y:U.y+U.height/2},se=C.data,re=j.data,de=!!se?.expanded&&!!re?.expanded,ie=C.handleBounds,he=j.handleBounds,ue=de&&l?ie?.source?.find(Re=>Re.id===l):void 0,ve=de&&u?he?.target?.find(Re=>Re.id===u):void 0,qe=ue?{x:$.x+ue.x+ue.width,y:$.y+ue.y+ue.height/2,pos:Y.Right}:Hf($,V),Oe=ve?{x:U.x+ve.x,y:U.y+ve.y+ve.height/2,pos:Y.Left}:Hf(U,K);return{src:qe,tgt:Oe}},[t,n,l,u])),[y,v]=S.useState(!1),b=m?.src.x??r,E=m?.src.y??i,_=m?.tgt.x??a,T=m?.tgt.y??o,N=m?.src.pos??s,q=m?.tgt.pos??c,[L,O,R]=pd({sourceX:b,sourceY:E,sourcePosition:N,targetX:_,targetY:T,targetPosition:q}),I=d?.cardinality,G=UN(I),H=!!f,x=S.useCallback(P=>{g.setEdges(j=>j.map($=>{if($.id!==e)return $;const U={...$.data||{}};"styleColor"in P&&(U.styleColor=P.styleColor??void 0),"styleDashed"in P&&(U.styleDashed=P.styleDashed??void 0),"cardinality"in P&&(U.cardinality=P.cardinality??void 0);const K={...$.style||{}};return U.styleColor&&(K.stroke=U.styleColor),U.styleDashed===!0?K.strokeDasharray="5 4":U.styleDashed===!1&&(K.strokeDasharray=void 0),{...$,data:U,style:K}}));const C=d?.edgeId;C&&F0(C,{style_color:"styleColor"in P?P.styleColor??null:void 0,style_dashed:"styleDashed"in P?P.styleDashed??null:void 0,cardinality:"cardinality"in P?P.cardinality??null:void 0}).catch(()=>{})},[d?.edgeId,e,g]),M=S.useCallback(()=>{const P=d?.edgeId;g.setEdges(C=>C.filter(j=>j.id!==e)),P&&H0(P).catch(()=>{})},[d?.edgeId,e,g]),k=S.useCallback(()=>{g.setEdges(P=>P.map(C=>C.id===e?{...C,selected:!1}:C))},[e,g]),z=S.useCallback(()=>{!l||!u||g.setNodes(P=>P.map(C=>{if(C.data.kind!=="table")return C;const j=C.data;return C.id===t?{...C,data:{...j,expanded:!0,forceExpandTick:(j.forceExpandTick??0)+1,tracedColumn:l}}:C.id===n?{...C,data:{...j,expanded:!0,forceExpandTick:(j.forceExpandTick??0)+1,tracedColumn:u}}:C}))},[g,t,l,n,u]);return p.jsxs(p.Fragment,{children:[p.jsx(mr,{id:e,path:L,style:h,markerStart:G.source,markerEnd:G.target}),p.jsx("path",{d:L,fill:"none",stroke:"transparent",strokeWidth:16,style:{pointerEvents:"stroke"},onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1)}),!H&&y&&d?.hoverLabel&&p.jsx(zf,{children:p.jsx("div",{className:"lcv-edge-label",style:{position:"absolute",transform:`translate(-50%, -50%) translate(${O}px, ${R}px)`,pointerEvents:"none"},children:d.hoverLabel})}),H&&p.jsx(zf,{children:p.jsx(HN,{x:O,y:R,styleColor:d?.styleColor,styleDashed:d?.styleDashed,cardinality:d?.cardinality,fromColumn:l??void 0,toColumn:u??void 0,onChange:x,onDelete:M,onClose:k,onJumpToColumns:z})})]})}const GN=S.memo(BN);function VN(){return p.jsx("svg",{"aria-hidden":!0,style:{position:"absolute",width:0,height:0},children:p.jsxs("defs",{children:[p.jsx("marker",{id:Ul.one,markerWidth:"10",markerHeight:"10",refX:"9",refY:"5",orient:"auto-start-reverse",markerUnits:"userSpaceOnUse",children:p.jsx("line",{x1:"5",y1:"0",x2:"5",y2:"10",stroke:"currentColor",strokeWidth:"1.2"})}),p.jsx("marker",{id:Ul.many,markerWidth:"12",markerHeight:"10",refX:"11",refY:"5",orient:"auto-start-reverse",markerUnits:"userSpaceOnUse",children:p.jsx("path",{d:"M 0 5 L 10 0 M 0 5 L 10 5 M 0 5 L 10 10",stroke:"currentColor",strokeWidth:"1.2",fill:"none"})})]})})}const KN={"column-edge":GN},Bl={str:"#60a5fa",int:"#4ade80",flt:"#2dd4bf",dat:"#fb923c",bool:"#c084fc",json:"#f472b6",uuid:"#a3a3a3",blob:"#94a3b8",unknown:"#737373"},Gl={filter:"#fb923c",join:"#a78bfa",aggregate:"#22d3ee",function:"#34d399",projection:"#94a3b8"},vn={fk:"#e2e8f0",view_ddl:"#60a5fa",query_log:"#4ade80",co_occur:"#94a3b8",lineage_llm:"#c084fc",name_match:"#737373",codebase:"#fb923c",lineage_manual:"#f5f4f2",unknown:"#a3a3a3"},Ea={amber:{bg:"rgba(251,191,36,0.16)",border:"#fbbf24"},rose:{bg:"rgba(244,114,182,0.16)",border:"#f472b6"},emerald:{bg:"rgba(52,211,153,0.16)",border:"#34d399"},sky:{bg:"rgba(56,189,248,0.16)",border:"#38bdf8"},violet:{bg:"rgba(167,139,250,0.16)",border:"#a78bfa"},slate:{bg:"rgba(148,163,184,0.16)",border:"#94a3b8"}};function nx(e){if(!e)return"unknown";const t=String(e).toLowerCase();return t.includes("char")||t.includes("text")||t.includes("string")?"str":t.includes("int")||t==="bigint"||t==="smallint"?"int":t.includes("float")||t.includes("double")||t.includes("decimal")||t.includes("numeric")||t.includes("real")?"flt":t.includes("date")||t.includes("time")||t.includes("stamp")?"dat":t.includes("bool")?"bool":t.includes("json")?"json":t.includes("uuid")?"uuid":t.includes("blob")||t.includes("bytea")||t.includes("binary")?"blob":"unknown"}function WN(e){const t=nx(e);return t==="unknown"?(e||"?").slice(0,4).toLowerCase():t}const Vl={fk:{label:"Foreign key",description:"Declared FK constraint extracted from catalog metadata.",deterministic:!0},view_ddl:{label:"View DDL",description:"Parsed from the view's CREATE statement.",deterministic:!0},query_log:{label:"Query log",description:"Observed in the warehouse query history.",deterministic:!0},codebase:{label:"Codebase",description:"Found by scanning the connected code repository.",deterministic:!0},co_occur:{label:"Co-occurrence",description:"Tables that show up together in audit queries.",deterministic:!1},lineage_llm:{label:"LLM estimate",description:"Proposed by an LLM; the percentage is its self-reported confidence.",deterministic:!1},name_match:{label:"Name match",description:"Heuristic column-name similarity — no schema evidence.",deterministic:!1},lineage_manual:{label:"Manual",description:"Drawn by you on the canvas.",deterministic:!0},unknown:{label:"Unknown",description:"Source extractor did not tag this edge.",deterministic:!1}};function YN(e){return Vl[e]??Vl.unknown}function XN(e){const t=YN(e.type),n=Math.round((e.confidence??0)*100),r=[];if(e.fromColumn&&e.toColumn&&r.push(`${e.fromColumn} → ${e.toColumn}`),r.push(t.label),t.deterministic)r.push("Deterministic source");else{const i=e.dashed?" (low)":"";r.push(`Confidence ${n}%${i}`)}return r.join(`
`)}const ZN=["fk","view_ddl","query_log","codebase","co_occur","lineage_llm","name_match","lineage_manual"];function QN(){const[e,t]=S.useState(!1),n=S.useRef(null);return S.useEffect(()=>{if(!e)return;function r(a){n.current&&(n.current.contains(a.target)||t(!1))}function i(a){a.key==="Escape"&&t(!1)}return document.addEventListener("mousedown",r),document.addEventListener("keydown",i),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("keydown",i)}},[e]),p.jsxs("div",{ref:n,className:"pointer-events-auto relative",children:[p.jsxs("button",{type:"button",onClick:()=>t(r=>!r),title:"Edge legend","aria-haspopup":"dialog","aria-expanded":e,className:Pe("inline-flex h-7 items-center gap-1.5 rounded-md border border-surface-border bg-surface-raised/90 px-2 text-[11px] text-fg-muted shadow transition","hover:bg-surface hover:text-ink",e&&"bg-surface text-ink"),children:[p.jsx(U0,{size:12}),p.jsx("span",{children:"Legend"})]}),e&&p.jsxs("div",{className:"absolute right-0 top-9 z-20 w-[280px] rounded-md border border-surface-border bg-surface-raised p-3 shadow-xl",children:[p.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[p.jsx("span",{className:"text-[11px] font-semibold uppercase tracking-wide text-fg-muted",children:"Edge legend"}),p.jsx("button",{type:"button",onClick:()=>t(!1),"aria-label":"Close legend",className:"text-fg-muted transition hover:text-ink",children:p.jsx(Wr,{size:12})})]}),p.jsx("ul",{className:"space-y-1.5",children:ZN.map(r=>{const i=Vl[r],a=vn[r]??vn.unknown;return i?p.jsxs("li",{className:"flex items-start gap-2",children:[p.jsx("span",{"aria-hidden":!0,className:"mt-1.5 inline-block h-[2px] w-5 shrink-0",style:{backgroundColor:a}}),p.jsxs("div",{className:"min-w-0",children:[p.jsx("div",{className:"text-[12px] text-ink",children:i.label}),p.jsx("div",{className:"text-[10.5px] text-fg-muted",children:i.description})]})]},r):null})}),p.jsxs("p",{className:"mt-3 border-t border-surface-border pt-2 text-[10.5px] text-fg-muted",children:[p.jsx("span",{className:"inline-block h-[2px] w-5 align-middle",style:{backgroundImage:"linear-gradient(to right, currentColor 60%, transparent 0)",backgroundSize:"5px 2px",backgroundRepeat:"repeat-x"}})," ","Dashed = name-match or LLM confidence under 70%."]})]})]})}function JN({open:e,onClose:t,nodes:n,onSelect:r}){const[i,a]=S.useState(""),[o,s]=S.useState(0);S.useEffect(()=>{e&&(a(""),s(0))},[e]);const c=S.useMemo(()=>{const l=i.trim().toLowerCase(),u=[];for(const d of n){let f="",h="";d.data.kind==="table"?(f=d.data.fqn,h=d.data.profile||"table"):d.data.kind==="operator"?(f=`${d.data.opKind}: ${d.data.expression||"—"}`,h="operator"):(f=d.data.text||"(empty note)",h="note"),(!l||f.toLowerCase().includes(l)||h.toLowerCase().includes(l))&&u.push({id:d.id,label:f,hint:h})}return u.slice(0,20)},[n,i]);return e?p.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/40 backdrop-blur-sm",onClick:t,children:p.jsxs("div",{className:"mt-24 w-full max-w-lg rounded-xl border border-surface-border bg-surface-raised shadow-2xl",onClick:l=>l.stopPropagation(),children:[p.jsxs("div",{className:"flex items-center gap-2 border-b border-surface-border px-3 py-2",children:[p.jsx(ed,{size:14,className:"text-fg-muted"}),p.jsx("input",{autoFocus:!0,value:i,placeholder:"Search canvas… (Cmd+K)",onChange:l=>a(l.target.value),onKeyDown:l=>{if(l.key==="ArrowDown")l.preventDefault(),s(u=>(u+1)%Math.max(c.length,1));else if(l.key==="ArrowUp")l.preventDefault(),s(u=>(u-1+c.length)%Math.max(c.length,1));else if(l.key==="Enter"){const u=c[o];u&&(r(u.id),t())}else l.key==="Escape"&&t()},className:"w-full bg-transparent text-sm outline-none placeholder:text-fg-muted"})]}),p.jsx("ul",{className:"max-h-80 overflow-y-auto",children:c.length===0?p.jsx("li",{className:"px-3 py-3 text-xs text-fg-muted",children:"No matches."}):c.map((l,u)=>p.jsxs("li",{className:"flex cursor-pointer items-center justify-between px-3 py-2 text-[12px] "+(u===o?"bg-accent-soft text-accent-ink":""),onMouseEnter:()=>s(u),onMouseDown:()=>{r(l.id),t()},children:[p.jsx("span",{className:"font-mono truncate",children:l.label}),p.jsx("span",{className:"ml-3 text-[10px] uppercase tracking-wide text-fg-muted",children:l.hint})]},l.id))})]})}):null}function eA(e){if(!e)return"";const t=Math.max(0,Math.floor(Date.now()/1e3-e));if(t<60)return"just now";const n=Math.floor(t/60);if(n<60)return`${n}m ago`;const r=Math.floor(n/60);if(r<24)return`${r}h ago`;const i=Math.floor(r/24);if(i<30)return`${i}d ago`;const a=Math.floor(i/30);return a<12?`${a}mo ago`:`${Math.floor(a/12)}y ago`}function tA({hasUnsavedWork:e,activeArtifactId:t,onPick:n,onActiveArtifactDeleted:r}){const i=td(),a=gr(),[o,s]=S.useState(!1),[c,l]=S.useState(null),[u,d]=S.useState(null),f=S.useRef(null),h=Pi({mutationFn:E=>B0(E.id),onSuccess:(E,_)=>{a.invalidateQueries({queryKey:["lineage-artifacts"]}),_.id===t&&r(),i.push({title:"Lineage deleted",description:`"${_.name}" removed.`,tone:"success"}),d(null)},onError:(E,_)=>{i.push({title:"Delete failed",description:`${_.name}: ${E.message}`,tone:"error"}),d(null)}}),g=Dn({queryKey:["lineage-artifacts"],queryFn:()=>G0(),staleTime:3e4});S.useEffect(()=>{if(!o)return;function E(_){f.current&&(f.current.contains(_.target)||s(!1))}return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[o]),S.useEffect(()=>{if(!o)return;function E(_){_.key==="Escape"&&s(!1)}return document.addEventListener("keydown",E),()=>document.removeEventListener("keydown",E)},[o]);const m=g.data?.artifacts??[],y=g.data?.count??0;function v(E){if(E.id===t){s(!1);return}if(e){l(E);return}n(E.id),s(!1)}function b(){c&&(n(c.id),l(null),s(!1))}return p.jsxs("div",{ref:f,className:"relative",children:[p.jsxs("button",{type:"button",onClick:()=>s(E=>!E),title:"Open saved lineage","aria-haspopup":"menu","aria-expanded":o,className:Pe("inline-flex h-8 items-center gap-1.5 rounded-md border border-surface-border px-2 text-[12px] text-fg-muted transition","hover:bg-surface hover:text-ink",o&&"bg-surface text-ink"),children:[p.jsx(h_,{size:13}),p.jsxs("span",{children:["Saved (",g.isLoading?"…":y,")"]}),p.jsx(Di,{size:12,className:Pe("transition",o&&"rotate-180")})]}),o&&p.jsxs("div",{role:"menu",className:"absolute left-0 top-9 z-20 w-[300px] overflow-hidden rounded-md border border-surface-border bg-surface-raised shadow-xl",children:[g.isLoading&&p.jsx("div",{className:"px-3 py-4 text-[12px] text-fg-muted",children:"Loading…"}),g.isError&&p.jsx("div",{className:"px-3 py-4 text-[12px] text-critical",children:"Could not load saved lineages."}),!g.isLoading&&!g.isError&&m.length===0&&p.jsx("div",{className:"px-3 py-4 text-[12px] text-fg-muted",children:"No saved lineages yet — Save (⌘S) anytime to populate."}),m.length>0&&p.jsx("ul",{className:"max-h-[320px] overflow-y-auto py-1",children:m.map(E=>{const _=E.id===t;return p.jsxs("li",{className:Pe("group flex items-stretch transition hover:bg-surface",_&&"bg-surface"),children:[p.jsxs("button",{type:"button",role:"menuitem",onClick:()=>v(E),className:"flex-1 min-w-0 px-3 py-2 text-left",children:[p.jsxs("div",{className:"flex items-center justify-between gap-2",children:[p.jsx("span",{className:"truncate text-[12.5px] font-medium text-ink",children:E.name}),_&&p.jsx("span",{className:"shrink-0 rounded border border-accent-default/40 bg-accent-soft px-1.5 py-0.5 text-[9.5px] uppercase tracking-wide text-accent-ink",children:"open"})]}),p.jsxs("div",{className:"mt-0.5 truncate text-[10.5px] text-fg-muted",children:[E.node_count," nodes · ",E.edge_count," edges ·"," ",E.db_profile||"no profile"," · saved"," ",eA(E.generated_at)]})]}),p.jsx("button",{type:"button","aria-label":`Delete ${E.name}`,title:"Delete this lineage",onClick:T=>{T.stopPropagation(),d(E)},className:"flex shrink-0 items-center px-3 text-fg-muted opacity-0 transition group-hover:opacity-100 hover:text-critical focus:opacity-100 focus:outline-none",children:p.jsx(Yr,{size:13})})]},E.id)})})]}),p.jsx(Yd,{open:c!==null,onClose:()=>l(null),onConfirm:b,title:"Discard current canvas?",description:c?`Opening "${c.name}" will replace the unsaved canvas you have on screen. Save first (⌘S) if you want to keep it.`:"",confirmLabel:"Discard and open",cancelLabel:"Keep editing"}),p.jsx(Yd,{open:u!==null,onClose:()=>h.isPending?void 0:d(null),onConfirm:()=>{u&&h.mutate(u)},title:"Delete saved lineage?",description:u?`"${u.name}" will be removed permanently — its nodes and comments go with it. The relationships themselves stay in the catalog so other canvases that surface them are unaffected. This cannot be undone.`:"",confirmLabel:"Delete forever",cancelLabel:"Keep it",tone:"danger",loading:h.isPending})]})}function We({label:e,shortcut:t,onClick:n,disabled:r,children:i,active:a}){return p.jsx("button",{type:"button",onClick:n,disabled:r,title:t?`${e} (${t})`:e,"aria-label":e,className:Pe("group relative inline-flex h-8 w-8 items-center justify-center rounded-md border border-transparent text-fg-muted transition","hover:border-surface-border hover:bg-surface hover:text-ink",r&&"cursor-not-allowed opacity-40 hover:bg-transparent hover:text-fg-muted",a&&"border-accent-default/50 bg-accent-soft text-accent-ink"),children:i})}function Tn(){return p.jsx("span",{className:"mx-1 h-5 w-px bg-surface-border"})}function nA(e){return p.jsxs("div",{className:"flex items-center gap-0.5 rounded-xl border border-surface-border bg-surface-raised px-2 py-1 shadow-lg",children:[p.jsx(tA,{hasUnsavedWork:e.hasUnsavedWork,activeArtifactId:e.activeArtifactId,onPick:e.onOpenSavedArtifact,onActiveArtifactDeleted:e.onActiveSavedArtifactDeleted}),p.jsx(We,{label:"New lineage",onClick:e.onNewLineage,children:p.jsx(d_,{size:15})}),p.jsx(Tn,{}),p.jsx(We,{label:"Add table",shortcut:"D",onClick:e.onAddTable,children:p.jsx(e_,{size:15})}),p.jsx(We,{label:"Add filter",shortcut:"F",onClick:e.onAddFilter,children:p.jsx(kv,{size:15})}),p.jsx(We,{label:"Add function",shortcut:"E",onClick:e.onAddFunction,children:p.jsx(u_,{size:15})}),p.jsx(We,{label:"Add group-by",shortcut:"G",onClick:e.onAddAggregate,children:p.jsx(Cv,{size:15})}),p.jsx(We,{label:"Add join",shortcut:"J",onClick:e.onAddJoin,children:p.jsx(Tv,{size:15})}),p.jsx(We,{label:"Add comment",shortcut:"C",onClick:e.onAddComment,children:p.jsx(I_,{size:15})}),p.jsx(We,{label:"Add text",shortcut:"T",onClick:e.onAddText,children:p.jsx(i_,{size:15})}),p.jsx(We,{label:"Add logo",shortcut:"I",onClick:e.onAddLogo,children:p.jsx(Rv,{size:15})}),p.jsx(Tn,{}),p.jsx(We,{label:"Undo",shortcut:"⌘Z",onClick:e.onUndo,disabled:!e.canUndo,children:p.jsx(O_,{size:15})}),p.jsx(We,{label:"Redo",shortcut:"⌘⇧Z",onClick:e.onRedo,disabled:!e.canRedo,children:p.jsx(E_,{size:15})}),p.jsx(Tn,{}),p.jsx(We,{label:"Auto-arrange",shortcut:"L",onClick:e.onAutoLayout,children:p.jsx(b_,{size:15})}),p.jsx(We,{label:"Discover related edges",onClick:e.onDiscoverRelated,children:p.jsx(__,{size:15})}),p.jsx(Tn,{}),p.jsxs("button",{type:"button",onClick:e.onGenerateAI,disabled:!e.primaryProfile||e.generating,className:Pe("inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-[12px] font-medium transition","bg-accent-default text-accent-ink hover:brightness-110",(!e.primaryProfile||e.generating)&&"cursor-not-allowed opacity-50"),title:"Generate lineage with AMX AI",children:[p.jsx(Nv,{size:14,className:e.generating?"animate-pulse":""}),e.generating?"Streaming…":"AI Generate"]}),p.jsx(Tn,{}),p.jsx(We,{label:"Search (⌘K)",shortcut:"⌘K",onClick:e.onSearch,children:p.jsx(ed,{size:15})}),p.jsx(We,{label:"Track attribute (⌘⇧F)",shortcut:"⌘⇧F",onClick:e.onTrackAttribute,children:p.jsx(Iv,{size:15})}),p.jsx(Tn,{}),p.jsx(We,{label:"Save canvas",shortcut:"⌘S",onClick:e.onSave,children:p.jsx(C_,{size:15})}),p.jsx(We,{label:"Export PNG",onClick:e.onExportPng,children:p.jsx(t_,{size:15})}),p.jsx(We,{label:"Share",onClick:e.onShare,children:p.jsx(A_,{size:15})}),p.jsx(Tn,{}),p.jsx(We,{label:"Import SQL",onClick:e.onImportSql,children:p.jsx(Sl,{size:15})}),p.jsx(We,{label:"Export SQL",onClick:e.onExportSql,children:p.jsx(n_,{size:15})}),p.jsxs("span",{className:"ml-2 flex items-center gap-1 rounded-md border border-surface-border px-2 py-1 text-[10px] uppercase tracking-wide text-fg-muted",children:[p.jsx(Sv,{size:10}),e.primaryProfile||"no profile"]})]})}function Ed(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Sa,Uf;function rA(){if(Uf)return Sa;Uf=1;function e(){this.__data__=[],this.size=0}return Sa=e,Sa}var Ca,Bf;function yr(){if(Bf)return Ca;Bf=1;function e(t,n){return t===n||t!==t&&n!==n}return Ca=e,Ca}var Na,Gf;function Vi(){if(Gf)return Na;Gf=1;var e=yr();function t(n,r){for(var i=n.length;i--;)if(e(n[i][0],r))return i;return-1}return Na=t,Na}var Aa,Vf;function iA(){if(Vf)return Aa;Vf=1;var e=Vi(),t=Array.prototype,n=t.splice;function r(i){var a=this.__data__,o=e(a,i);if(o<0)return!1;var s=a.length-1;return o==s?a.pop():n.call(a,o,1),--this.size,!0}return Aa=r,Aa}var Ta,Kf;function aA(){if(Kf)return Ta;Kf=1;var e=Vi();function t(n){var r=this.__data__,i=e(r,n);return i<0?void 0:r[i][1]}return Ta=t,Ta}var ka,Wf;function oA(){if(Wf)return ka;Wf=1;var e=Vi();function t(n){return e(this.__data__,n)>-1}return ka=t,ka}var Ra,Yf;function sA(){if(Yf)return Ra;Yf=1;var e=Vi();function t(n,r){var i=this.__data__,a=e(i,n);return a<0?(++this.size,i.push([n,r])):i[a][1]=r,this}return Ra=t,Ra}var Ia,Xf;function Ki(){if(Xf)return Ia;Xf=1;var e=rA(),t=iA(),n=aA(),r=oA(),i=sA();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var l=o[s];this.set(l[0],l[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,Ia=a,Ia}var Ma,Zf;function cA(){if(Zf)return Ma;Zf=1;var e=Ki();function t(){this.__data__=new e,this.size=0}return Ma=t,Ma}var qa,Qf;function uA(){if(Qf)return qa;Qf=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return qa=e,qa}var Oa,Jf;function lA(){if(Jf)return Oa;Jf=1;function e(t){return this.__data__.get(t)}return Oa=e,Oa}var La,eh;function dA(){if(eh)return La;eh=1;function e(t){return this.__data__.has(t)}return La=e,La}var Pa,th;function rx(){if(th)return Pa;th=1;var e=typeof ri=="object"&&ri&&ri.Object===Object&&ri;return Pa=e,Pa}var Da,nh;function $t(){if(nh)return Da;nh=1;var e=rx(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Da=n,Da}var ja,rh;function vr(){if(rh)return ja;rh=1;var e=$t(),t=e.Symbol;return ja=t,ja}var $a,ih;function fA(){if(ih)return $a;ih=1;var e=vr(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;function a(o){var s=n.call(o,i),c=o[i];try{o[i]=void 0;var l=!0}catch{}var u=r.call(o);return l&&(s?o[i]=c:delete o[i]),u}return $a=a,$a}var za,ah;function hA(){if(ah)return za;ah=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return za=n,za}var Fa,oh;function jn(){if(oh)return Fa;oh=1;var e=vr(),t=fA(),n=hA(),r="[object Null]",i="[object Undefined]",a=e?e.toStringTag:void 0;function o(s){return s==null?s===void 0?i:r:a&&a in Object(s)?t(s):n(s)}return Fa=o,Fa}var Ha,sh;function It(){if(sh)return Ha;sh=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Ha=e,Ha}var Ua,ch;function Qr(){if(ch)return Ua;ch=1;var e=jn(),t=It(),n="[object AsyncFunction]",r="[object Function]",i="[object GeneratorFunction]",a="[object Proxy]";function o(s){if(!t(s))return!1;var c=e(s);return c==r||c==i||c==n||c==a}return Ua=o,Ua}var Ba,uh;function pA(){if(uh)return Ba;uh=1;var e=$t(),t=e["__core-js_shared__"];return Ba=t,Ba}var Ga,lh;function gA(){if(lh)return Ga;lh=1;var e=pA(),t=function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""}();function n(r){return!!t&&t in r}return Ga=n,Ga}var Va,dh;function ix(){if(dh)return Va;dh=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return Va=n,Va}var Ka,fh;function mA(){if(fh)return Ka;fh=1;var e=Qr(),t=gA(),n=It(),r=ix(),i=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,c=o.toString,l=s.hasOwnProperty,u=RegExp("^"+c.call(l).replace(i,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function d(f){if(!n(f)||t(f))return!1;var h=e(f)?u:a;return h.test(r(f))}return Ka=d,Ka}var Wa,hh;function yA(){if(hh)return Wa;hh=1;function e(t,n){return t?.[n]}return Wa=e,Wa}var Ya,ph;function $n(){if(ph)return Ya;ph=1;var e=mA(),t=yA();function n(r,i){var a=t(r,i);return e(a)?a:void 0}return Ya=n,Ya}var Xa,gh;function Sd(){if(gh)return Xa;gh=1;var e=$n(),t=$t(),n=e(t,"Map");return Xa=n,Xa}var Za,mh;function Wi(){if(mh)return Za;mh=1;var e=$n(),t=e(Object,"create");return Za=t,Za}var Qa,yh;function vA(){if(yh)return Qa;yh=1;var e=Wi();function t(){this.__data__=e?e(null):{},this.size=0}return Qa=t,Qa}var Ja,vh;function bA(){if(vh)return Ja;vh=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Ja=e,Ja}var eo,bh;function xA(){if(bh)return eo;bh=1;var e=Wi(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function i(a){var o=this.__data__;if(e){var s=o[a];return s===t?void 0:s}return r.call(o,a)?o[a]:void 0}return eo=i,eo}var to,xh;function _A(){if(xh)return to;xh=1;var e=Wi(),t=Object.prototype,n=t.hasOwnProperty;function r(i){var a=this.__data__;return e?a[i]!==void 0:n.call(a,i)}return to=r,to}var no,_h;function wA(){if(_h)return no;_h=1;var e=Wi(),t="__lodash_hash_undefined__";function n(r,i){var a=this.__data__;return this.size+=this.has(r)?0:1,a[r]=e&&i===void 0?t:i,this}return no=n,no}var ro,wh;function EA(){if(wh)return ro;wh=1;var e=vA(),t=bA(),n=xA(),r=_A(),i=wA();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var l=o[s];this.set(l[0],l[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,ro=a,ro}var io,Eh;function SA(){if(Eh)return io;Eh=1;var e=EA(),t=Ki(),n=Sd();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return io=r,io}var ao,Sh;function CA(){if(Sh)return ao;Sh=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return ao=e,ao}var oo,Ch;function Yi(){if(Ch)return oo;Ch=1;var e=CA();function t(n,r){var i=n.__data__;return e(r)?i[typeof r=="string"?"string":"hash"]:i.map}return oo=t,oo}var so,Nh;function NA(){if(Nh)return so;Nh=1;var e=Yi();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return so=t,so}var co,Ah;function AA(){if(Ah)return co;Ah=1;var e=Yi();function t(n){return e(this,n).get(n)}return co=t,co}var uo,Th;function TA(){if(Th)return uo;Th=1;var e=Yi();function t(n){return e(this,n).has(n)}return uo=t,uo}var lo,kh;function kA(){if(kh)return lo;kh=1;var e=Yi();function t(n,r){var i=e(this,n),a=i.size;return i.set(n,r),this.size+=i.size==a?0:1,this}return lo=t,lo}var fo,Rh;function Cd(){if(Rh)return fo;Rh=1;var e=SA(),t=NA(),n=AA(),r=TA(),i=kA();function a(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var l=o[s];this.set(l[0],l[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=n,a.prototype.has=r,a.prototype.set=i,fo=a,fo}var ho,Ih;function RA(){if(Ih)return ho;Ih=1;var e=Ki(),t=Sd(),n=Cd(),r=200;function i(a,o){var s=this.__data__;if(s instanceof e){var c=s.__data__;if(!t||c.length<r-1)return c.push([a,o]),this.size=++s.size,this;s=this.__data__=new n(c)}return s.set(a,o),this.size=s.size,this}return ho=i,ho}var po,Mh;function Xi(){if(Mh)return po;Mh=1;var e=Ki(),t=cA(),n=uA(),r=lA(),i=dA(),a=RA();function o(s){var c=this.__data__=new e(s);this.size=c.size}return o.prototype.clear=t,o.prototype.delete=n,o.prototype.get=r,o.prototype.has=i,o.prototype.set=a,po=o,po}var go,qh;function Nd(){if(qh)return go;qh=1;function e(t,n){for(var r=-1,i=t==null?0:t.length;++r<i&&n(t[r],r,t)!==!1;);return t}return go=e,go}var mo,Oh;function ax(){if(Oh)return mo;Oh=1;var e=$n(),t=function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}}();return mo=t,mo}var yo,Lh;function Zi(){if(Lh)return yo;Lh=1;var e=ax();function t(n,r,i){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:i,writable:!0}):n[r]=i}return yo=t,yo}var vo,Ph;function Qi(){if(Ph)return vo;Ph=1;var e=Zi(),t=yr(),n=Object.prototype,r=n.hasOwnProperty;function i(a,o,s){var c=a[o];(!(r.call(a,o)&&t(c,s))||s===void 0&&!(o in a))&&e(a,o,s)}return vo=i,vo}var bo,Dh;function Jr(){if(Dh)return bo;Dh=1;var e=Qi(),t=Zi();function n(r,i,a,o){var s=!a;a||(a={});for(var c=-1,l=i.length;++c<l;){var u=i[c],d=o?o(a[u],r[u],u,a,r):void 0;d===void 0&&(d=r[u]),s?t(a,u,d):e(a,u,d)}return a}return bo=n,bo}var xo,jh;function IA(){if(jh)return xo;jh=1;function e(t,n){for(var r=-1,i=Array(t);++r<t;)i[r]=n(r);return i}return xo=e,xo}var _o,$h;function Vt(){if($h)return _o;$h=1;function e(t){return t!=null&&typeof t=="object"}return _o=e,_o}var wo,zh;function MA(){if(zh)return wo;zh=1;var e=jn(),t=Vt(),n="[object Arguments]";function r(i){return t(i)&&e(i)==n}return wo=r,wo}var Eo,Fh;function ei(){if(Fh)return Eo;Fh=1;var e=MA(),t=Vt(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,a=e(function(){return arguments}())?e:function(o){return t(o)&&r.call(o,"callee")&&!i.call(o,"callee")};return Eo=a,Eo}var So,Hh;function Xe(){if(Hh)return So;Hh=1;var e=Array.isArray;return So=e,So}var qr={exports:{}},Co,Uh;function qA(){if(Uh)return Co;Uh=1;function e(){return!1}return Co=e,Co}qr.exports;var Bh;function br(){return Bh||(Bh=1,function(e,t){var n=$t(),r=qA(),i=t&&!t.nodeType&&t,a=i&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===i,s=o?n.Buffer:void 0,c=s?s.isBuffer:void 0,l=c||r;e.exports=l}(qr,qr.exports)),qr.exports}var No,Gh;function Ji(){if(Gh)return No;Gh=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,i){var a=typeof r;return i=i??e,!!i&&(a=="number"||a!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<i}return No=n,No}var Ao,Vh;function Ad(){if(Vh)return Ao;Vh=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Ao=t,Ao}var To,Kh;function OA(){if(Kh)return To;Kh=1;var e=jn(),t=Ad(),n=Vt(),r="[object Arguments]",i="[object Array]",a="[object Boolean]",o="[object Date]",s="[object Error]",c="[object Function]",l="[object Map]",u="[object Number]",d="[object Object]",f="[object RegExp]",h="[object Set]",g="[object String]",m="[object WeakMap]",y="[object ArrayBuffer]",v="[object DataView]",b="[object Float32Array]",E="[object Float64Array]",_="[object Int8Array]",T="[object Int16Array]",N="[object Int32Array]",q="[object Uint8Array]",L="[object Uint8ClampedArray]",O="[object Uint16Array]",R="[object Uint32Array]",I={};I[b]=I[E]=I[_]=I[T]=I[N]=I[q]=I[L]=I[O]=I[R]=!0,I[r]=I[i]=I[y]=I[a]=I[v]=I[o]=I[s]=I[c]=I[l]=I[u]=I[d]=I[f]=I[h]=I[g]=I[m]=!1;function G(H){return n(H)&&t(H.length)&&!!I[e(H)]}return To=G,To}var ko,Wh;function ea(){if(Wh)return ko;Wh=1;function e(t){return function(n){return t(n)}}return ko=e,ko}var Or={exports:{}};Or.exports;var Yh;function Td(){return Yh||(Yh=1,function(e,t){var n=rx(),r=t&&!t.nodeType&&t,i=r&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===r,o=a&&n.process,s=function(){try{var c=i&&i.require&&i.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}}();e.exports=s}(Or,Or.exports)),Or.exports}var Ro,Xh;function ti(){if(Xh)return Ro;Xh=1;var e=OA(),t=ea(),n=Td(),r=n&&n.isTypedArray,i=r?t(r):e;return Ro=i,Ro}var Io,Zh;function ox(){if(Zh)return Io;Zh=1;var e=IA(),t=ei(),n=Xe(),r=br(),i=Ji(),a=ti(),o=Object.prototype,s=o.hasOwnProperty;function c(l,u){var d=n(l),f=!d&&t(l),h=!d&&!f&&r(l),g=!d&&!f&&!h&&a(l),m=d||f||h||g,y=m?e(l.length,String):[],v=y.length;for(var b in l)(u||s.call(l,b))&&!(m&&(b=="length"||h&&(b=="offset"||b=="parent")||g&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||i(b,v)))&&y.push(b);return y}return Io=c,Io}var Mo,Qh;function ta(){if(Qh)return Mo;Qh=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,i=typeof r=="function"&&r.prototype||e;return n===i}return Mo=t,Mo}var qo,Jh;function sx(){if(Jh)return qo;Jh=1;function e(t,n){return function(r){return t(n(r))}}return qo=e,qo}var Oo,ep;function LA(){if(ep)return Oo;ep=1;var e=sx(),t=e(Object.keys,Object);return Oo=t,Oo}var Lo,tp;function kd(){if(tp)return Lo;tp=1;var e=ta(),t=LA(),n=Object.prototype,r=n.hasOwnProperty;function i(a){if(!e(a))return t(a);var o=[];for(var s in Object(a))r.call(a,s)&&s!="constructor"&&o.push(s);return o}return Lo=i,Lo}var Po,np;function cn(){if(np)return Po;np=1;var e=Qr(),t=Ad();function n(r){return r!=null&&t(r.length)&&!e(r)}return Po=n,Po}var Do,rp;function Sn(){if(rp)return Do;rp=1;var e=ox(),t=kd(),n=cn();function r(i){return n(i)?e(i):t(i)}return Do=r,Do}var jo,ip;function PA(){if(ip)return jo;ip=1;var e=Jr(),t=Sn();function n(r,i){return r&&e(i,t(i),r)}return jo=n,jo}var $o,ap;function DA(){if(ap)return $o;ap=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return $o=e,$o}var zo,op;function jA(){if(op)return zo;op=1;var e=It(),t=ta(),n=DA(),r=Object.prototype,i=r.hasOwnProperty;function a(o){if(!e(o))return n(o);var s=t(o),c=[];for(var l in o)l=="constructor"&&(s||!i.call(o,l))||c.push(l);return c}return zo=a,zo}var Fo,sp;function zn(){if(sp)return Fo;sp=1;var e=ox(),t=jA(),n=cn();function r(i){return n(i)?e(i,!0):t(i)}return Fo=r,Fo}var Ho,cp;function $A(){if(cp)return Ho;cp=1;var e=Jr(),t=zn();function n(r,i){return r&&e(i,t(i),r)}return Ho=n,Ho}var Lr={exports:{}};Lr.exports;var up;function cx(){return up||(up=1,function(e,t){var n=$t(),r=t&&!t.nodeType&&t,i=r&&!0&&e&&!e.nodeType&&e,a=i&&i.exports===r,o=a?n.Buffer:void 0,s=o?o.allocUnsafe:void 0;function c(l,u){if(u)return l.slice();var d=l.length,f=s?s(d):new l.constructor(d);return l.copy(f),f}e.exports=c}(Lr,Lr.exports)),Lr.exports}var Uo,lp;function ux(){if(lp)return Uo;lp=1;function e(t,n){var r=-1,i=t.length;for(n||(n=Array(i));++r<i;)n[r]=t[r];return n}return Uo=e,Uo}var Bo,dp;function lx(){if(dp)return Bo;dp=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,a=0,o=[];++r<i;){var s=t[r];n(s,r,t)&&(o[a++]=s)}return o}return Bo=e,Bo}var Go,fp;function dx(){if(fp)return Go;fp=1;function e(){return[]}return Go=e,Go}var Vo,hp;function Rd(){if(hp)return Vo;hp=1;var e=lx(),t=dx(),n=Object.prototype,r=n.propertyIsEnumerable,i=Object.getOwnPropertySymbols,a=i?function(o){return o==null?[]:(o=Object(o),e(i(o),function(s){return r.call(o,s)}))}:t;return Vo=a,Vo}var Ko,pp;function zA(){if(pp)return Ko;pp=1;var e=Jr(),t=Rd();function n(r,i){return e(r,t(r),i)}return Ko=n,Ko}var Wo,gp;function Id(){if(gp)return Wo;gp=1;function e(t,n){for(var r=-1,i=n.length,a=t.length;++r<i;)t[a+r]=n[r];return t}return Wo=e,Wo}var Yo,mp;function na(){if(mp)return Yo;mp=1;var e=sx(),t=e(Object.getPrototypeOf,Object);return Yo=t,Yo}var Xo,yp;function fx(){if(yp)return Xo;yp=1;var e=Id(),t=na(),n=Rd(),r=dx(),i=Object.getOwnPropertySymbols,a=i?function(o){for(var s=[];o;)e(s,n(o)),o=t(o);return s}:r;return Xo=a,Xo}var Zo,vp;function FA(){if(vp)return Zo;vp=1;var e=Jr(),t=fx();function n(r,i){return e(r,t(r),i)}return Zo=n,Zo}var Qo,bp;function hx(){if(bp)return Qo;bp=1;var e=Id(),t=Xe();function n(r,i,a){var o=i(r);return t(r)?o:e(o,a(r))}return Qo=n,Qo}var Jo,xp;function px(){if(xp)return Jo;xp=1;var e=hx(),t=Rd(),n=Sn();function r(i){return e(i,n,t)}return Jo=r,Jo}var es,_p;function HA(){if(_p)return es;_p=1;var e=hx(),t=fx(),n=zn();function r(i){return e(i,n,t)}return es=r,es}var ts,wp;function UA(){if(wp)return ts;wp=1;var e=$n(),t=$t(),n=e(t,"DataView");return ts=n,ts}var ns,Ep;function BA(){if(Ep)return ns;Ep=1;var e=$n(),t=$t(),n=e(t,"Promise");return ns=n,ns}var rs,Sp;function gx(){if(Sp)return rs;Sp=1;var e=$n(),t=$t(),n=e(t,"Set");return rs=n,rs}var is,Cp;function GA(){if(Cp)return is;Cp=1;var e=$n(),t=$t(),n=e(t,"WeakMap");return is=n,is}var as,Np;function xr(){if(Np)return as;Np=1;var e=UA(),t=Sd(),n=BA(),r=gx(),i=GA(),a=jn(),o=ix(),s="[object Map]",c="[object Object]",l="[object Promise]",u="[object Set]",d="[object WeakMap]",f="[object DataView]",h=o(e),g=o(t),m=o(n),y=o(r),v=o(i),b=a;return(e&&b(new e(new ArrayBuffer(1)))!=f||t&&b(new t)!=s||n&&b(n.resolve())!=l||r&&b(new r)!=u||i&&b(new i)!=d)&&(b=function(E){var _=a(E),T=_==c?E.constructor:void 0,N=T?o(T):"";if(N)switch(N){case h:return f;case g:return s;case m:return l;case y:return u;case v:return d}return _}),as=b,as}var os,Ap;function VA(){if(Ap)return os;Ap=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var i=r.length,a=new r.constructor(i);return i&&typeof r[0]=="string"&&t.call(r,"index")&&(a.index=r.index,a.input=r.input),a}return os=n,os}var ss,Tp;function mx(){if(Tp)return ss;Tp=1;var e=$t(),t=e.Uint8Array;return ss=t,ss}var cs,kp;function Md(){if(kp)return cs;kp=1;var e=mx();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return cs=t,cs}var us,Rp;function KA(){if(Rp)return us;Rp=1;var e=Md();function t(n,r){var i=r?e(n.buffer):n.buffer;return new n.constructor(i,n.byteOffset,n.byteLength)}return us=t,us}var ls,Ip;function WA(){if(Ip)return ls;Ip=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return ls=t,ls}var ds,Mp;function YA(){if(Mp)return ds;Mp=1;var e=vr(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(i){return n?Object(n.call(i)):{}}return ds=r,ds}var fs,qp;function yx(){if(qp)return fs;qp=1;var e=Md();function t(n,r){var i=r?e(n.buffer):n.buffer;return new n.constructor(i,n.byteOffset,n.length)}return fs=t,fs}var hs,Op;function XA(){if(Op)return hs;Op=1;var e=Md(),t=KA(),n=WA(),r=YA(),i=yx(),a="[object Boolean]",o="[object Date]",s="[object Map]",c="[object Number]",l="[object RegExp]",u="[object Set]",d="[object String]",f="[object Symbol]",h="[object ArrayBuffer]",g="[object DataView]",m="[object Float32Array]",y="[object Float64Array]",v="[object Int8Array]",b="[object Int16Array]",E="[object Int32Array]",_="[object Uint8Array]",T="[object Uint8ClampedArray]",N="[object Uint16Array]",q="[object Uint32Array]";function L(O,R,I){var G=O.constructor;switch(R){case h:return e(O);case a:case o:return new G(+O);case g:return t(O,I);case m:case y:case v:case b:case E:case _:case T:case N:case q:return i(O,I);case s:return new G;case c:case d:return new G(O);case l:return n(O);case u:return new G;case f:return r(O)}}return hs=L,hs}var ps,Lp;function vx(){if(Lp)return ps;Lp=1;var e=It(),t=Object.create,n=function(){function r(){}return function(i){if(!e(i))return{};if(t)return t(i);r.prototype=i;var a=new r;return r.prototype=void 0,a}}();return ps=n,ps}var gs,Pp;function bx(){if(Pp)return gs;Pp=1;var e=vx(),t=na(),n=ta();function r(i){return typeof i.constructor=="function"&&!n(i)?e(t(i)):{}}return gs=r,gs}var ms,Dp;function ZA(){if(Dp)return ms;Dp=1;var e=xr(),t=Vt(),n="[object Map]";function r(i){return t(i)&&e(i)==n}return ms=r,ms}var ys,jp;function QA(){if(jp)return ys;jp=1;var e=ZA(),t=ea(),n=Td(),r=n&&n.isMap,i=r?t(r):e;return ys=i,ys}var vs,$p;function JA(){if($p)return vs;$p=1;var e=xr(),t=Vt(),n="[object Set]";function r(i){return t(i)&&e(i)==n}return vs=r,vs}var bs,zp;function eT(){if(zp)return bs;zp=1;var e=JA(),t=ea(),n=Td(),r=n&&n.isSet,i=r?t(r):e;return bs=i,bs}var xs,Fp;function xx(){if(Fp)return xs;Fp=1;var e=Xi(),t=Nd(),n=Qi(),r=PA(),i=$A(),a=cx(),o=ux(),s=zA(),c=FA(),l=px(),u=HA(),d=xr(),f=VA(),h=XA(),g=bx(),m=Xe(),y=br(),v=QA(),b=It(),E=eT(),_=Sn(),T=zn(),N=1,q=2,L=4,O="[object Arguments]",R="[object Array]",I="[object Boolean]",G="[object Date]",H="[object Error]",x="[object Function]",M="[object GeneratorFunction]",k="[object Map]",z="[object Number]",P="[object Object]",C="[object RegExp]",j="[object Set]",$="[object String]",U="[object Symbol]",K="[object WeakMap]",V="[object ArrayBuffer]",se="[object DataView]",re="[object Float32Array]",de="[object Float64Array]",ie="[object Int8Array]",he="[object Int16Array]",ue="[object Int32Array]",ve="[object Uint8Array]",qe="[object Uint8ClampedArray]",Oe="[object Uint16Array]",Re="[object Uint32Array]",te={};te[O]=te[R]=te[V]=te[se]=te[I]=te[G]=te[re]=te[de]=te[ie]=te[he]=te[ue]=te[k]=te[z]=te[P]=te[C]=te[j]=te[$]=te[U]=te[ve]=te[qe]=te[Oe]=te[Re]=!0,te[H]=te[x]=te[K]=!1;function we(ee,W,pe,et,je,Ie){var xe,Ce=W&N,Le=W&q,Ge=W&L;if(pe&&(xe=je?pe(ee,et,je,Ie):pe(ee)),xe!==void 0)return xe;if(!b(ee))return ee;var ze=m(ee);if(ze){if(xe=f(ee),!Ce)return o(ee,xe)}else{var Ne=d(ee),Fe=Ne==x||Ne==M;if(y(ee))return a(ee,Ce);if(Ne==P||Ne==O||Fe&&!je){if(xe=Le||Fe?{}:g(ee),!Ce)return Le?c(ee,i(xe,ee)):s(ee,r(xe,ee))}else{if(!te[Ne])return je?ee:{};xe=h(ee,Ne,Ce)}}Ie||(Ie=new e);var Ve=Ie.get(ee);if(Ve)return Ve;Ie.set(ee,xe),E(ee)?ee.forEach(function($e){xe.add(we($e,W,pe,$e,ee,Ie))}):v(ee)&&ee.forEach(function($e,Ke){xe.set(Ke,we($e,W,pe,Ke,ee,Ie))});var Ae=Ge?Le?u:l:Le?T:_,Ze=ze?void 0:Ae(ee);return t(Ze||ee,function($e,Ke){Ze&&(Ke=$e,$e=ee[Ke]),n(xe,Ke,we($e,W,pe,Ke,ee,Ie))}),xe}return xs=we,xs}var _s,Hp;function tT(){if(Hp)return _s;Hp=1;var e=xx(),t=4;function n(r){return e(r,t)}return _s=n,_s}var ws,Up;function qd(){if(Up)return ws;Up=1;function e(t){return function(){return t}}return ws=e,ws}var Es,Bp;function nT(){if(Bp)return Es;Bp=1;function e(t){return function(n,r,i){for(var a=-1,o=Object(n),s=i(n),c=s.length;c--;){var l=s[t?c:++a];if(r(o[l],l,o)===!1)break}return n}}return Es=e,Es}var Ss,Gp;function Od(){if(Gp)return Ss;Gp=1;var e=nT(),t=e();return Ss=t,Ss}var Cs,Vp;function Ld(){if(Vp)return Cs;Vp=1;var e=Od(),t=Sn();function n(r,i){return r&&e(r,i,t)}return Cs=n,Cs}var Ns,Kp;function rT(){if(Kp)return Ns;Kp=1;var e=cn();function t(n,r){return function(i,a){if(i==null)return i;if(!e(i))return n(i,a);for(var o=i.length,s=r?o:-1,c=Object(i);(r?s--:++s<o)&&a(c[s],s,c)!==!1;);return i}}return Ns=t,Ns}var As,Wp;function ra(){if(Wp)return As;Wp=1;var e=Ld(),t=rT(),n=t(e);return As=n,As}var Ts,Yp;function Fn(){if(Yp)return Ts;Yp=1;function e(t){return t}return Ts=e,Ts}var ks,Xp;function _x(){if(Xp)return ks;Xp=1;var e=Fn();function t(n){return typeof n=="function"?n:e}return ks=t,ks}var Rs,Zp;function wx(){if(Zp)return Rs;Zp=1;var e=Nd(),t=ra(),n=_x(),r=Xe();function i(a,o){var s=r(a)?e:t;return s(a,n(o))}return Rs=i,Rs}var Is,Qp;function Ex(){return Qp||(Qp=1,Is=wx()),Is}var Ms,Jp;function iT(){if(Jp)return Ms;Jp=1;var e=ra();function t(n,r){var i=[];return e(n,function(a,o,s){r(a,o,s)&&i.push(a)}),i}return Ms=t,Ms}var qs,eg;function aT(){if(eg)return qs;eg=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return qs=t,qs}var Os,tg;function oT(){if(tg)return Os;tg=1;function e(t){return this.__data__.has(t)}return Os=e,Os}var Ls,ng;function Sx(){if(ng)return Ls;ng=1;var e=Cd(),t=aT(),n=oT();function r(i){var a=-1,o=i==null?0:i.length;for(this.__data__=new e;++a<o;)this.add(i[a])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,Ls=r,Ls}var Ps,rg;function sT(){if(rg)return Ps;rg=1;function e(t,n){for(var r=-1,i=t==null?0:t.length;++r<i;)if(n(t[r],r,t))return!0;return!1}return Ps=e,Ps}var Ds,ig;function Cx(){if(ig)return Ds;ig=1;function e(t,n){return t.has(n)}return Ds=e,Ds}var js,ag;function Nx(){if(ag)return js;ag=1;var e=Sx(),t=sT(),n=Cx(),r=1,i=2;function a(o,s,c,l,u,d){var f=c&r,h=o.length,g=s.length;if(h!=g&&!(f&&g>h))return!1;var m=d.get(o),y=d.get(s);if(m&&y)return m==s&&y==o;var v=-1,b=!0,E=c&i?new e:void 0;for(d.set(o,s),d.set(s,o);++v<h;){var _=o[v],T=s[v];if(l)var N=f?l(T,_,v,s,o,d):l(_,T,v,o,s,d);if(N!==void 0){if(N)continue;b=!1;break}if(E){if(!t(s,function(q,L){if(!n(E,L)&&(_===q||u(_,q,c,l,d)))return E.push(L)})){b=!1;break}}else if(!(_===T||u(_,T,c,l,d))){b=!1;break}}return d.delete(o),d.delete(s),b}return js=a,js}var $s,og;function cT(){if(og)return $s;og=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(i,a){r[++n]=[a,i]}),r}return $s=e,$s}var zs,sg;function Pd(){if(sg)return zs;sg=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(i){r[++n]=i}),r}return zs=e,zs}var Fs,cg;function uT(){if(cg)return Fs;cg=1;var e=vr(),t=mx(),n=yr(),r=Nx(),i=cT(),a=Pd(),o=1,s=2,c="[object Boolean]",l="[object Date]",u="[object Error]",d="[object Map]",f="[object Number]",h="[object RegExp]",g="[object Set]",m="[object String]",y="[object Symbol]",v="[object ArrayBuffer]",b="[object DataView]",E=e?e.prototype:void 0,_=E?E.valueOf:void 0;function T(N,q,L,O,R,I,G){switch(L){case b:if(N.byteLength!=q.byteLength||N.byteOffset!=q.byteOffset)return!1;N=N.buffer,q=q.buffer;case v:return!(N.byteLength!=q.byteLength||!I(new t(N),new t(q)));case c:case l:case f:return n(+N,+q);case u:return N.name==q.name&&N.message==q.message;case h:case m:return N==q+"";case d:var H=i;case g:var x=O&o;if(H||(H=a),N.size!=q.size&&!x)return!1;var M=G.get(N);if(M)return M==q;O|=s,G.set(N,q);var k=r(H(N),H(q),O,R,I,G);return G.delete(N),k;case y:if(_)return _.call(N)==_.call(q)}return!1}return Fs=T,Fs}var Hs,ug;function lT(){if(ug)return Hs;ug=1;var e=px(),t=1,n=Object.prototype,r=n.hasOwnProperty;function i(a,o,s,c,l,u){var d=s&t,f=e(a),h=f.length,g=e(o),m=g.length;if(h!=m&&!d)return!1;for(var y=h;y--;){var v=f[y];if(!(d?v in o:r.call(o,v)))return!1}var b=u.get(a),E=u.get(o);if(b&&E)return b==o&&E==a;var _=!0;u.set(a,o),u.set(o,a);for(var T=d;++y<h;){v=f[y];var N=a[v],q=o[v];if(c)var L=d?c(q,N,v,o,a,u):c(N,q,v,a,o,u);if(!(L===void 0?N===q||l(N,q,s,c,u):L)){_=!1;break}T||(T=v=="constructor")}if(_&&!T){var O=a.constructor,R=o.constructor;O!=R&&"constructor"in a&&"constructor"in o&&!(typeof O=="function"&&O instanceof O&&typeof R=="function"&&R instanceof R)&&(_=!1)}return u.delete(a),u.delete(o),_}return Hs=i,Hs}var Us,lg;function dT(){if(lg)return Us;lg=1;var e=Xi(),t=Nx(),n=uT(),r=lT(),i=xr(),a=Xe(),o=br(),s=ti(),c=1,l="[object Arguments]",u="[object Array]",d="[object Object]",f=Object.prototype,h=f.hasOwnProperty;function g(m,y,v,b,E,_){var T=a(m),N=a(y),q=T?u:i(m),L=N?u:i(y);q=q==l?d:q,L=L==l?d:L;var O=q==d,R=L==d,I=q==L;if(I&&o(m)){if(!o(y))return!1;T=!0,O=!1}if(I&&!O)return _||(_=new e),T||s(m)?t(m,y,v,b,E,_):n(m,y,q,v,b,E,_);if(!(v&c)){var G=O&&h.call(m,"__wrapped__"),H=R&&h.call(y,"__wrapped__");if(G||H){var x=G?m.value():m,M=H?y.value():y;return _||(_=new e),E(x,M,v,b,_)}}return I?(_||(_=new e),r(m,y,v,b,E,_)):!1}return Us=g,Us}var Bs,dg;function Ax(){if(dg)return Bs;dg=1;var e=dT(),t=Vt();function n(r,i,a,o,s){return r===i?!0:r==null||i==null||!t(r)&&!t(i)?r!==r&&i!==i:e(r,i,a,o,n,s)}return Bs=n,Bs}var Gs,fg;function fT(){if(fg)return Gs;fg=1;var e=Xi(),t=Ax(),n=1,r=2;function i(a,o,s,c){var l=s.length,u=l,d=!c;if(a==null)return!u;for(a=Object(a);l--;){var f=s[l];if(d&&f[2]?f[1]!==a[f[0]]:!(f[0]in a))return!1}for(;++l<u;){f=s[l];var h=f[0],g=a[h],m=f[1];if(d&&f[2]){if(g===void 0&&!(h in a))return!1}else{var y=new e;if(c)var v=c(g,m,h,a,o,y);if(!(v===void 0?t(m,g,n|r,c,y):v))return!1}}return!0}return Gs=i,Gs}var Vs,hg;function Tx(){if(hg)return Vs;hg=1;var e=It();function t(n){return n===n&&!e(n)}return Vs=t,Vs}var Ks,pg;function hT(){if(pg)return Ks;pg=1;var e=Tx(),t=Sn();function n(r){for(var i=t(r),a=i.length;a--;){var o=i[a],s=r[o];i[a]=[o,s,e(s)]}return i}return Ks=n,Ks}var Ws,gg;function kx(){if(gg)return Ws;gg=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return Ws=e,Ws}var Ys,mg;function pT(){if(mg)return Ys;mg=1;var e=fT(),t=hT(),n=kx();function r(i){var a=t(i);return a.length==1&&a[0][2]?n(a[0][0],a[0][1]):function(o){return o===i||e(o,i,a)}}return Ys=r,Ys}var Xs,yg;function _r(){if(yg)return Xs;yg=1;var e=jn(),t=Vt(),n="[object Symbol]";function r(i){return typeof i=="symbol"||t(i)&&e(i)==n}return Xs=r,Xs}var Zs,vg;function Dd(){if(vg)return Zs;vg=1;var e=Xe(),t=_r(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function i(a,o){if(e(a))return!1;var s=typeof a;return s=="number"||s=="symbol"||s=="boolean"||a==null||t(a)?!0:r.test(a)||!n.test(a)||o!=null&&a in Object(o)}return Zs=i,Zs}var Qs,bg;function gT(){if(bg)return Qs;bg=1;var e=Cd(),t="Expected a function";function n(r,i){if(typeof r!="function"||i!=null&&typeof i!="function")throw new TypeError(t);var a=function(){var o=arguments,s=i?i.apply(this,o):o[0],c=a.cache;if(c.has(s))return c.get(s);var l=r.apply(this,o);return a.cache=c.set(s,l)||c,l};return a.cache=new(n.Cache||e),a}return n.Cache=e,Qs=n,Qs}var Js,xg;function mT(){if(xg)return Js;xg=1;var e=gT(),t=500;function n(r){var i=e(r,function(o){return a.size===t&&a.clear(),o}),a=i.cache;return i}return Js=n,Js}var ec,_g;function yT(){if(_g)return ec;_g=1;var e=mT(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(i){var a=[];return i.charCodeAt(0)===46&&a.push(""),i.replace(t,function(o,s,c,l){a.push(c?l.replace(n,"$1"):s||o)}),a});return ec=r,ec}var tc,wg;function ia(){if(wg)return tc;wg=1;function e(t,n){for(var r=-1,i=t==null?0:t.length,a=Array(i);++r<i;)a[r]=n(t[r],r,t);return a}return tc=e,tc}var nc,Eg;function vT(){if(Eg)return nc;Eg=1;var e=vr(),t=ia(),n=Xe(),r=_r(),i=e?e.prototype:void 0,a=i?i.toString:void 0;function o(s){if(typeof s=="string")return s;if(n(s))return t(s,o)+"";if(r(s))return a?a.call(s):"";var c=s+"";return c=="0"&&1/s==-1/0?"-0":c}return nc=o,nc}var rc,Sg;function Rx(){if(Sg)return rc;Sg=1;var e=vT();function t(n){return n==null?"":e(n)}return rc=t,rc}var ic,Cg;function aa(){if(Cg)return ic;Cg=1;var e=Xe(),t=Dd(),n=yT(),r=Rx();function i(a,o){return e(a)?a:t(a,o)?[a]:n(r(a))}return ic=i,ic}var ac,Ng;function ni(){if(Ng)return ac;Ng=1;var e=_r();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return ac=t,ac}var oc,Ag;function oa(){if(Ag)return oc;Ag=1;var e=aa(),t=ni();function n(r,i){i=e(i,r);for(var a=0,o=i.length;r!=null&&a<o;)r=r[t(i[a++])];return a&&a==o?r:void 0}return oc=n,oc}var sc,Tg;function bT(){if(Tg)return sc;Tg=1;var e=oa();function t(n,r,i){var a=n==null?void 0:e(n,r);return a===void 0?i:a}return sc=t,sc}var cc,kg;function xT(){if(kg)return cc;kg=1;function e(t,n){return t!=null&&n in Object(t)}return cc=e,cc}var uc,Rg;function Ix(){if(Rg)return uc;Rg=1;var e=aa(),t=ei(),n=Xe(),r=Ji(),i=Ad(),a=ni();function o(s,c,l){c=e(c,s);for(var u=-1,d=c.length,f=!1;++u<d;){var h=a(c[u]);if(!(f=s!=null&&l(s,h)))break;s=s[h]}return f||++u!=d?f:(d=s==null?0:s.length,!!d&&i(d)&&r(h,d)&&(n(s)||t(s)))}return uc=o,uc}var lc,Ig;function Mx(){if(Ig)return lc;Ig=1;var e=xT(),t=Ix();function n(r,i){return r!=null&&t(r,i,e)}return lc=n,lc}var dc,Mg;function _T(){if(Mg)return dc;Mg=1;var e=Ax(),t=bT(),n=Mx(),r=Dd(),i=Tx(),a=kx(),o=ni(),s=1,c=2;function l(u,d){return r(u)&&i(d)?a(o(u),d):function(f){var h=t(f,u);return h===void 0&&h===d?n(f,u):e(d,h,s|c)}}return dc=l,dc}var fc,qg;function qx(){if(qg)return fc;qg=1;function e(t){return function(n){return n?.[t]}}return fc=e,fc}var hc,Og;function wT(){if(Og)return hc;Og=1;var e=oa();function t(n){return function(r){return e(r,n)}}return hc=t,hc}var pc,Lg;function ET(){if(Lg)return pc;Lg=1;var e=qx(),t=wT(),n=Dd(),r=ni();function i(a){return n(a)?e(r(a)):t(a)}return pc=i,pc}var gc,Pg;function un(){if(Pg)return gc;Pg=1;var e=pT(),t=_T(),n=Fn(),r=Xe(),i=ET();function a(o){return typeof o=="function"?o:o==null?n:typeof o=="object"?r(o)?t(o[0],o[1]):e(o):i(o)}return gc=a,gc}var mc,Dg;function Ox(){if(Dg)return mc;Dg=1;var e=lx(),t=iT(),n=un(),r=Xe();function i(a,o){var s=r(a)?e:t;return s(a,n(o,3))}return mc=i,mc}var yc,jg;function ST(){if(jg)return yc;jg=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,i){return r!=null&&t.call(r,i)}return yc=n,yc}var vc,$g;function Lx(){if($g)return vc;$g=1;var e=ST(),t=Ix();function n(r,i){return r!=null&&t(r,i,e)}return vc=n,vc}var bc,zg;function CT(){if(zg)return bc;zg=1;var e=kd(),t=xr(),n=ei(),r=Xe(),i=cn(),a=br(),o=ta(),s=ti(),c="[object Map]",l="[object Set]",u=Object.prototype,d=u.hasOwnProperty;function f(h){if(h==null)return!0;if(i(h)&&(r(h)||typeof h=="string"||typeof h.splice=="function"||a(h)||s(h)||n(h)))return!h.length;var g=t(h);if(g==c||g==l)return!h.size;if(o(h))return!e(h).length;for(var m in h)if(d.call(h,m))return!1;return!0}return bc=f,bc}var xc,Fg;function Px(){if(Fg)return xc;Fg=1;function e(t){return t===void 0}return xc=e,xc}var _c,Hg;function Dx(){if(Hg)return _c;Hg=1;var e=ra(),t=cn();function n(r,i){var a=-1,o=t(r)?Array(r.length):[];return e(r,function(s,c,l){o[++a]=i(s,c,l)}),o}return _c=n,_c}var wc,Ug;function jx(){if(Ug)return wc;Ug=1;var e=ia(),t=un(),n=Dx(),r=Xe();function i(a,o){var s=r(a)?e:n;return s(a,t(o,3))}return wc=i,wc}var Ec,Bg;function NT(){if(Bg)return Ec;Bg=1;function e(t,n,r,i){var a=-1,o=t==null?0:t.length;for(i&&o&&(r=t[++a]);++a<o;)r=n(r,t[a],a,t);return r}return Ec=e,Ec}var Sc,Gg;function AT(){if(Gg)return Sc;Gg=1;function e(t,n,r,i,a){return a(t,function(o,s,c){r=i?(i=!1,o):n(r,o,s,c)}),r}return Sc=e,Sc}var Cc,Vg;function $x(){if(Vg)return Cc;Vg=1;var e=NT(),t=ra(),n=un(),r=AT(),i=Xe();function a(o,s,c){var l=i(o)?e:r,u=arguments.length<3;return l(o,n(s,4),c,u,t)}return Cc=a,Cc}var Nc,Kg;function TT(){if(Kg)return Nc;Kg=1;var e=jn(),t=Xe(),n=Vt(),r="[object String]";function i(a){return typeof a=="string"||!t(a)&&n(a)&&e(a)==r}return Nc=i,Nc}var Ac,Wg;function kT(){if(Wg)return Ac;Wg=1;var e=qx(),t=e("length");return Ac=t,Ac}var Tc,Yg;function RT(){if(Yg)return Tc;Yg=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",i=t+n+r,a="\\ufe0e\\ufe0f",o="\\u200d",s=RegExp("["+o+e+i+a+"]");function c(l){return s.test(l)}return Tc=c,Tc}var kc,Xg;function IT(){if(Xg)return kc;Xg=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",i=t+n+r,a="\\ufe0e\\ufe0f",o="["+e+"]",s="["+i+"]",c="\\ud83c[\\udffb-\\udfff]",l="(?:"+s+"|"+c+")",u="[^"+e+"]",d="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",g=l+"?",m="["+a+"]?",y="(?:"+h+"(?:"+[u,d,f].join("|")+")"+m+g+")*",v=m+g+y,b="(?:"+[u+s+"?",s,d,f,o].join("|")+")",E=RegExp(c+"(?="+c+")|"+b+v,"g");function _(T){for(var N=E.lastIndex=0;E.test(T);)++N;return N}return kc=_,kc}var Rc,Zg;function MT(){if(Zg)return Rc;Zg=1;var e=kT(),t=RT(),n=IT();function r(i){return t(i)?n(i):e(i)}return Rc=r,Rc}var Ic,Qg;function qT(){if(Qg)return Ic;Qg=1;var e=kd(),t=xr(),n=cn(),r=TT(),i=MT(),a="[object Map]",o="[object Set]";function s(c){if(c==null)return 0;if(n(c))return r(c)?i(c):c.length;var l=t(c);return l==a||l==o?c.size:e(c).length}return Ic=s,Ic}var Mc,Jg;function OT(){if(Jg)return Mc;Jg=1;var e=Nd(),t=vx(),n=Ld(),r=un(),i=na(),a=Xe(),o=br(),s=Qr(),c=It(),l=ti();function u(d,f,h){var g=a(d),m=g||o(d)||l(d);if(f=r(f,4),h==null){var y=d&&d.constructor;m?h=g?new y:[]:c(d)?h=s(y)?t(i(d)):{}:h={}}return(m?e:n)(d,function(v,b,E){return f(h,v,b,E)}),h}return Mc=u,Mc}var qc,em;function LT(){if(em)return qc;em=1;var e=vr(),t=ei(),n=Xe(),r=e?e.isConcatSpreadable:void 0;function i(a){return n(a)||t(a)||!!(r&&a&&a[r])}return qc=i,qc}var Oc,tm;function jd(){if(tm)return Oc;tm=1;var e=Id(),t=LT();function n(r,i,a,o,s){var c=-1,l=r.length;for(a||(a=t),s||(s=[]);++c<l;){var u=r[c];i>0&&a(u)?i>1?n(u,i-1,a,o,s):e(s,u):o||(s[s.length]=u)}return s}return Oc=n,Oc}var Lc,nm;function PT(){if(nm)return Lc;nm=1;function e(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}return Lc=e,Lc}var Pc,rm;function zx(){if(rm)return Pc;rm=1;var e=PT(),t=Math.max;function n(r,i,a){return i=t(i===void 0?r.length-1:i,0),function(){for(var o=arguments,s=-1,c=t(o.length-i,0),l=Array(c);++s<c;)l[s]=o[i+s];s=-1;for(var u=Array(i+1);++s<i;)u[s]=o[s];return u[i]=a(l),e(r,this,u)}}return Pc=n,Pc}var Dc,im;function DT(){if(im)return Dc;im=1;var e=qd(),t=ax(),n=Fn(),r=t?function(i,a){return t(i,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:n;return Dc=r,Dc}var jc,am;function jT(){if(am)return jc;am=1;var e=800,t=16,n=Date.now;function r(i){var a=0,o=0;return function(){var s=n(),c=t-(s-o);if(o=s,c>0){if(++a>=e)return arguments[0]}else a=0;return i.apply(void 0,arguments)}}return jc=r,jc}var $c,om;function Fx(){if(om)return $c;om=1;var e=DT(),t=jT(),n=t(e);return $c=n,$c}var zc,sm;function sa(){if(sm)return zc;sm=1;var e=Fn(),t=zx(),n=Fx();function r(i,a){return n(t(i,a,e),i+"")}return zc=r,zc}var Fc,cm;function Hx(){if(cm)return Fc;cm=1;function e(t,n,r,i){for(var a=t.length,o=r+(i?1:-1);i?o--:++o<a;)if(n(t[o],o,t))return o;return-1}return Fc=e,Fc}var Hc,um;function $T(){if(um)return Hc;um=1;function e(t){return t!==t}return Hc=e,Hc}var Uc,lm;function zT(){if(lm)return Uc;lm=1;function e(t,n,r){for(var i=r-1,a=t.length;++i<a;)if(t[i]===n)return i;return-1}return Uc=e,Uc}var Bc,dm;function FT(){if(dm)return Bc;dm=1;var e=Hx(),t=$T(),n=zT();function r(i,a,o){return a===a?n(i,a,o):e(i,t,o)}return Bc=r,Bc}var Gc,fm;function HT(){if(fm)return Gc;fm=1;var e=FT();function t(n,r){var i=n==null?0:n.length;return!!i&&e(n,r,0)>-1}return Gc=t,Gc}var Vc,hm;function UT(){if(hm)return Vc;hm=1;function e(t,n,r){for(var i=-1,a=t==null?0:t.length;++i<a;)if(r(n,t[i]))return!0;return!1}return Vc=e,Vc}var Kc,pm;function BT(){if(pm)return Kc;pm=1;function e(){}return Kc=e,Kc}var Wc,gm;function GT(){if(gm)return Wc;gm=1;var e=gx(),t=BT(),n=Pd(),r=1/0,i=e&&1/n(new e([,-0]))[1]==r?function(a){return new e(a)}:t;return Wc=i,Wc}var Yc,mm;function VT(){if(mm)return Yc;mm=1;var e=Sx(),t=HT(),n=UT(),r=Cx(),i=GT(),a=Pd(),o=200;function s(c,l,u){var d=-1,f=t,h=c.length,g=!0,m=[],y=m;if(u)g=!1,f=n;else if(h>=o){var v=l?null:i(c);if(v)return a(v);g=!1,f=r,y=new e}else y=l?[]:m;e:for(;++d<h;){var b=c[d],E=l?l(b):b;if(b=u||b!==0?b:0,g&&E===E){for(var _=y.length;_--;)if(y[_]===E)continue e;l&&y.push(E),m.push(b)}else f(y,E,u)||(y!==m&&y.push(E),m.push(b))}return m}return Yc=s,Yc}var Xc,ym;function Ux(){if(ym)return Xc;ym=1;var e=cn(),t=Vt();function n(r){return t(r)&&e(r)}return Xc=n,Xc}var Zc,vm;function KT(){if(vm)return Zc;vm=1;var e=jd(),t=sa(),n=VT(),r=Ux(),i=t(function(a){return n(e(a,1,r,!0))});return Zc=i,Zc}var Qc,bm;function WT(){if(bm)return Qc;bm=1;var e=ia();function t(n,r){return e(r,function(i){return n[i]})}return Qc=t,Qc}var Jc,xm;function Bx(){if(xm)return Jc;xm=1;var e=WT(),t=Sn();function n(r){return r==null?[]:e(r,t(r))}return Jc=n,Jc}var eu,_m;function Mt(){if(_m)return eu;_m=1;var e;if(typeof Ed=="function")try{e={clone:tT(),constant:qd(),each:Ex(),filter:Ox(),has:Lx(),isArray:Xe(),isEmpty:CT(),isFunction:Qr(),isUndefined:Px(),keys:Sn(),map:jx(),reduce:$x(),size:qT(),transform:OT(),union:KT(),values:Bx()}}catch{}return e||(e=window._),eu=e,eu}var tu,wm;function $d(){if(wm)return tu;wm=1;var e=Mt();tu=i;var t="\0",n="\0",r="";function i(u){this._isDirected=e.has(u,"directed")?u.directed:!0,this._isMultigraph=e.has(u,"multigraph")?u.multigraph:!1,this._isCompound=e.has(u,"compound")?u.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}i.prototype._nodeCount=0,i.prototype._edgeCount=0,i.prototype.isDirected=function(){return this._isDirected},i.prototype.isMultigraph=function(){return this._isMultigraph},i.prototype.isCompound=function(){return this._isCompound},i.prototype.setGraph=function(u){return this._label=u,this},i.prototype.graph=function(){return this._label},i.prototype.setDefaultNodeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultNodeLabelFn=u,this},i.prototype.nodeCount=function(){return this._nodeCount},i.prototype.nodes=function(){return e.keys(this._nodes)},i.prototype.sources=function(){var u=this;return e.filter(this.nodes(),function(d){return e.isEmpty(u._in[d])})},i.prototype.sinks=function(){var u=this;return e.filter(this.nodes(),function(d){return e.isEmpty(u._out[d])})},i.prototype.setNodes=function(u,d){var f=arguments,h=this;return e.each(u,function(g){f.length>1?h.setNode(g,d):h.setNode(g)}),this},i.prototype.setNode=function(u,d){return e.has(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=n,this._children[u]={},this._children[n][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)},i.prototype.node=function(u){return this._nodes[u]},i.prototype.hasNode=function(u){return e.has(this._nodes,u)},i.prototype.removeNode=function(u){var d=this;if(e.has(this._nodes,u)){var f=function(h){d.removeEdge(d._edgeObjs[h])};delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],e.each(this.children(u),function(h){d.setParent(h)}),delete this._children[u]),e.each(e.keys(this._in[u]),f),delete this._in[u],delete this._preds[u],e.each(e.keys(this._out[u]),f),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this},i.prototype.setParent=function(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=n;else{d+="";for(var f=d;!e.isUndefined(f);f=this.parent(f))if(f===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this},i.prototype._removeFromParentsChildList=function(u){delete this._children[this._parent[u]][u]},i.prototype.parent=function(u){if(this._isCompound){var d=this._parent[u];if(d!==n)return d}},i.prototype.children=function(u){if(e.isUndefined(u)&&(u=n),this._isCompound){var d=this._children[u];if(d)return e.keys(d)}else{if(u===n)return this.nodes();if(this.hasNode(u))return[]}},i.prototype.predecessors=function(u){var d=this._preds[u];if(d)return e.keys(d)},i.prototype.successors=function(u){var d=this._sucs[u];if(d)return e.keys(d)},i.prototype.neighbors=function(u){var d=this.predecessors(u);if(d)return e.union(d,this.successors(u))},i.prototype.isLeaf=function(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0},i.prototype.filterNodes=function(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(m,y){u(y)&&d.setNode(y,m)}),e.each(this._edgeObjs,function(m){d.hasNode(m.v)&&d.hasNode(m.w)&&d.setEdge(m,f.edge(m))});var h={};function g(m){var y=f.parent(m);return y===void 0||d.hasNode(y)?(h[m]=y,y):y in h?h[y]:g(y)}return this._isCompound&&e.each(d.nodes(),function(m){d.setParent(m,g(m))}),d},i.prototype.setDefaultEdgeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultEdgeLabelFn=u,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(u,d){var f=this,h=arguments;return e.reduce(u,function(g,m){return h.length>1?f.setEdge(g,m,d):f.setEdge(g,m),m}),this},i.prototype.setEdge=function(){var u,d,f,h,g=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(u=m.v,d=m.w,f=m.name,arguments.length===2&&(h=arguments[1],g=!0)):(u=m,d=arguments[1],f=arguments[3],arguments.length>2&&(h=arguments[2],g=!0)),u=""+u,d=""+d,e.isUndefined(f)||(f=""+f);var y=s(this._isDirected,u,d,f);if(e.has(this._edgeLabels,y))return g&&(this._edgeLabels[y]=h),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[y]=g?h:this._defaultEdgeLabelFn(u,d,f);var v=c(this._isDirected,u,d,f);return u=v.v,d=v.w,Object.freeze(v),this._edgeObjs[y]=v,a(this._preds[d],u),a(this._sucs[u],d),this._in[d][y]=v,this._out[u][y]=v,this._edgeCount++,this},i.prototype.edge=function(u,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f);return this._edgeLabels[h]},i.prototype.hasEdge=function(u,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f);return e.has(this._edgeLabels,h)},i.prototype.removeEdge=function(u,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f),g=this._edgeObjs[h];return g&&(u=g.v,d=g.w,delete this._edgeLabels[h],delete this._edgeObjs[h],o(this._preds[d],u),o(this._sucs[u],d),delete this._in[d][h],delete this._out[u][h],this._edgeCount--),this},i.prototype.inEdges=function(u,d){var f=this._in[u];if(f){var h=e.values(f);return d?e.filter(h,function(g){return g.v===d}):h}},i.prototype.outEdges=function(u,d){var f=this._out[u];if(f){var h=e.values(f);return d?e.filter(h,function(g){return g.w===d}):h}},i.prototype.nodeEdges=function(u,d){var f=this.inEdges(u,d);if(f)return f.concat(this.outEdges(u,d))};function a(u,d){u[d]?u[d]++:u[d]=1}function o(u,d){--u[d]||delete u[d]}function s(u,d,f,h){var g=""+d,m=""+f;if(!u&&g>m){var y=g;g=m,m=y}return g+r+m+r+(e.isUndefined(h)?t:h)}function c(u,d,f,h){var g=""+d,m=""+f;if(!u&&g>m){var y=g;g=m,m=y}var v={v:g,w:m};return h&&(v.name=h),v}function l(u,d){return s(u,d.v,d.w,d.name)}return tu}var nu,Em;function YT(){return Em||(Em=1,nu="2.1.8"),nu}var ru,Sm;function XT(){return Sm||(Sm=1,ru={Graph:$d(),version:YT()}),ru}var iu,Cm;function ZT(){if(Cm)return iu;Cm=1;var e=Mt(),t=$d();iu={write:n,read:a};function n(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:r(o),edges:i(o)};return e.isUndefined(o.graph())||(s.value=e.clone(o.graph())),s}function r(o){return e.map(o.nodes(),function(s){var c=o.node(s),l=o.parent(s),u={v:s};return e.isUndefined(c)||(u.value=c),e.isUndefined(l)||(u.parent=l),u})}function i(o){return e.map(o.edges(),function(s){var c=o.edge(s),l={v:s.v,w:s.w};return e.isUndefined(s.name)||(l.name=s.name),e.isUndefined(c)||(l.value=c),l})}function a(o){var s=new t(o.options).setGraph(o.value);return e.each(o.nodes,function(c){s.setNode(c.v,c.value),c.parent&&s.setParent(c.v,c.parent)}),e.each(o.edges,function(c){s.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),s}return iu}var au,Nm;function QT(){if(Nm)return au;Nm=1;var e=Mt();au=t;function t(n){var r={},i=[],a;function o(s){e.has(r,s)||(r[s]=!0,a.push(s),e.each(n.successors(s),o),e.each(n.predecessors(s),o))}return e.each(n.nodes(),function(s){a=[],o(s),a.length&&i.push(a)}),i}return au}var ou,Am;function Gx(){if(Am)return ou;Am=1;var e=Mt();ou=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var i=this._keyIndices;if(n=String(n),!e.has(i,n)){var a=this._arr,o=a.length;return i[n]=o,a.push({key:n,priority:r}),this._decrease(o),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,r){var i=this._keyIndices[n];if(r>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[i].priority+" New: "+r);this._arr[i].priority=r,this._decrease(i)},t.prototype._heapify=function(n){var r=this._arr,i=2*n,a=i+1,o=n;i<r.length&&(o=r[i].priority<r[o].priority?i:o,a<r.length&&(o=r[a].priority<r[o].priority?a:o),o!==n&&(this._swap(n,o),this._heapify(o)))},t.prototype._decrease=function(n){for(var r=this._arr,i=r[n].priority,a;n!==0&&(a=n>>1,!(r[a].priority<i));)this._swap(n,a),n=a},t.prototype._swap=function(n,r){var i=this._arr,a=this._keyIndices,o=i[n],s=i[r];i[n]=s,i[r]=o,a[s.key]=n,a[o.key]=r},ou}var su,Tm;function Vx(){if(Tm)return su;Tm=1;var e=Mt(),t=Gx();su=r;var n=e.constant(1);function r(a,o,s,c){return i(a,String(o),s||n,c||function(l){return a.outEdges(l)})}function i(a,o,s,c){var l={},u=new t,d,f,h=function(g){var m=g.v!==d?g.v:g.w,y=l[m],v=s(g),b=f.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+g+" Weight: "+v);b<y.distance&&(y.distance=b,y.predecessor=d,u.decrease(m,b))};for(a.nodes().forEach(function(g){var m=g===o?0:Number.POSITIVE_INFINITY;l[g]={distance:m},u.add(g,m)});u.size()>0&&(d=u.removeMin(),f=l[d],f.distance!==Number.POSITIVE_INFINITY);)c(d).forEach(h);return l}return su}var cu,km;function JT(){if(km)return cu;km=1;var e=Vx(),t=Mt();cu=n;function n(r,i,a){return t.transform(r.nodes(),function(o,s){o[s]=e(r,s,i,a)},{})}return cu}var uu,Rm;function Kx(){if(Rm)return uu;Rm=1;var e=Mt();uu=t;function t(n){var r=0,i=[],a={},o=[];function s(c){var l=a[c]={onStack:!0,lowlink:r,index:r++};if(i.push(c),n.successors(c).forEach(function(f){e.has(a,f)?a[f].onStack&&(l.lowlink=Math.min(l.lowlink,a[f].index)):(s(f),l.lowlink=Math.min(l.lowlink,a[f].lowlink))}),l.lowlink===l.index){var u=[],d;do d=i.pop(),a[d].onStack=!1,u.push(d);while(c!==d);o.push(u)}}return n.nodes().forEach(function(c){e.has(a,c)||s(c)}),o}return uu}var lu,Im;function ek(){if(Im)return lu;Im=1;var e=Mt(),t=Kx();lu=n;function n(r){return e.filter(t(r),function(i){return i.length>1||i.length===1&&r.hasEdge(i[0],i[0])})}return lu}var du,Mm;function tk(){if(Mm)return du;Mm=1;var e=Mt();du=n;var t=e.constant(1);function n(i,a,o){return r(i,a||t,o||function(s){return i.outEdges(s)})}function r(i,a,o){var s={},c=i.nodes();return c.forEach(function(l){s[l]={},s[l][l]={distance:0},c.forEach(function(u){l!==u&&(s[l][u]={distance:Number.POSITIVE_INFINITY})}),o(l).forEach(function(u){var d=u.v===l?u.w:u.v,f=a(u);s[l][d]={distance:f,predecessor:l}})}),c.forEach(function(l){var u=s[l];c.forEach(function(d){var f=s[d];c.forEach(function(h){var g=f[l],m=u[h],y=f[h],v=g.distance+m.distance;v<y.distance&&(y.distance=v,y.predecessor=m.predecessor)})})}),s}return du}var fu,qm;function Wx(){if(qm)return fu;qm=1;var e=Mt();fu=t,t.CycleException=n;function t(r){var i={},a={},o=[];function s(c){if(e.has(a,c))throw new n;e.has(i,c)||(a[c]=!0,i[c]=!0,e.each(r.predecessors(c),s),delete a[c],o.push(c))}if(e.each(r.sinks(),s),e.size(i)!==r.nodeCount())throw new n;return o}function n(){}return n.prototype=new Error,fu}var hu,Om;function nk(){if(Om)return hu;Om=1;var e=Wx();hu=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return hu}var pu,Lm;function Yx(){if(Lm)return pu;Lm=1;var e=Mt();pu=t;function t(r,i,a){e.isArray(i)||(i=[i]);var o=(r.isDirected()?r.successors:r.neighbors).bind(r),s=[],c={};return e.each(i,function(l){if(!r.hasNode(l))throw new Error("Graph does not have node: "+l);n(r,l,a==="post",c,o,s)}),s}function n(r,i,a,o,s,c){e.has(o,i)||(o[i]=!0,a||c.push(i),e.each(s(i),function(l){n(r,l,a,o,s,c)}),a&&c.push(i))}return pu}var gu,Pm;function rk(){if(Pm)return gu;Pm=1;var e=Yx();gu=t;function t(n,r){return e(n,r,"post")}return gu}var mu,Dm;function ik(){if(Dm)return mu;Dm=1;var e=Yx();mu=t;function t(n,r){return e(n,r,"pre")}return mu}var yu,jm;function ak(){if(jm)return yu;jm=1;var e=Mt(),t=$d(),n=Gx();yu=r;function r(i,a){var o=new t,s={},c=new n,l;function u(f){var h=f.v===l?f.w:f.v,g=c.priority(h);if(g!==void 0){var m=a(f);m<g&&(s[h]=l,c.decrease(h,m))}}if(i.nodeCount()===0)return o;e.each(i.nodes(),function(f){c.add(f,Number.POSITIVE_INFINITY),o.setNode(f)}),c.decrease(i.nodes()[0],0);for(var d=!1;c.size()>0;){if(l=c.removeMin(),e.has(s,l))o.setEdge(l,s[l]);else{if(d)throw new Error("Input graph is not connected: "+i);d=!0}i.nodeEdges(l).forEach(u)}return o}return yu}var vu,$m;function ok(){return $m||($m=1,vu={components:QT(),dijkstra:Vx(),dijkstraAll:JT(),findCycles:ek(),floydWarshall:tk(),isAcyclic:nk(),postorder:rk(),preorder:ik(),prim:ak(),tarjan:Kx(),topsort:Wx()}),vu}var bu,zm;function sk(){if(zm)return bu;zm=1;var e=XT();return bu={Graph:e.Graph,json:ZT(),alg:ok(),version:e.version},bu}var Ri;if(typeof Ed=="function")try{Ri=sk()}catch{}Ri||(Ri=window.graphlib);var zt=Ri,xu,Fm;function ck(){if(Fm)return xu;Fm=1;var e=xx(),t=1,n=4;function r(i){return e(i,t|n)}return xu=r,xu}var _u,Hm;function ca(){if(Hm)return _u;Hm=1;var e=yr(),t=cn(),n=Ji(),r=It();function i(a,o,s){if(!r(s))return!1;var c=typeof o;return(c=="number"?t(s)&&n(o,s.length):c=="string"&&o in s)?e(s[o],a):!1}return _u=i,_u}var wu,Um;function uk(){if(Um)return wu;Um=1;var e=sa(),t=yr(),n=ca(),r=zn(),i=Object.prototype,a=i.hasOwnProperty,o=e(function(s,c){s=Object(s);var l=-1,u=c.length,d=u>2?c[2]:void 0;for(d&&n(c[0],c[1],d)&&(u=1);++l<u;)for(var f=c[l],h=r(f),g=-1,m=h.length;++g<m;){var y=h[g],v=s[y];(v===void 0||t(v,i[y])&&!a.call(s,y))&&(s[y]=f[y])}return s});return wu=o,wu}var Eu,Bm;function lk(){if(Bm)return Eu;Bm=1;var e=un(),t=cn(),n=Sn();function r(i){return function(a,o,s){var c=Object(a);if(!t(a)){var l=e(o,3);a=n(a),o=function(d){return l(c[d],d,c)}}var u=i(a,o,s);return u>-1?c[l?a[u]:u]:void 0}}return Eu=r,Eu}var Su,Gm;function dk(){if(Gm)return Su;Gm=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Su=t,Su}var Cu,Vm;function fk(){if(Vm)return Cu;Vm=1;var e=dk(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Cu=n,Cu}var Nu,Km;function hk(){if(Km)return Nu;Km=1;var e=fk(),t=It(),n=_r(),r=NaN,i=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;function c(l){if(typeof l=="number")return l;if(n(l))return r;if(t(l)){var u=typeof l.valueOf=="function"?l.valueOf():l;l=t(u)?u+"":u}if(typeof l!="string")return l===0?l:+l;l=e(l);var d=a.test(l);return d||o.test(l)?s(l.slice(2),d?2:8):i.test(l)?r:+l}return Nu=c,Nu}var Au,Wm;function Xx(){if(Wm)return Au;Wm=1;var e=hk(),t=1/0,n=17976931348623157e292;function r(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var a=i<0?-1:1;return a*n}return i===i?i:0}return Au=r,Au}var Tu,Ym;function pk(){if(Ym)return Tu;Ym=1;var e=Xx();function t(n){var r=e(n),i=r%1;return r===r?i?r-i:r:0}return Tu=t,Tu}var ku,Xm;function gk(){if(Xm)return ku;Xm=1;var e=Hx(),t=un(),n=pk(),r=Math.max;function i(a,o,s){var c=a==null?0:a.length;if(!c)return-1;var l=s==null?0:n(s);return l<0&&(l=r(c+l,0)),e(a,t(o,3),l)}return ku=i,ku}var Ru,Zm;function mk(){if(Zm)return Ru;Zm=1;var e=lk(),t=gk(),n=e(t);return Ru=n,Ru}var Iu,Qm;function Zx(){if(Qm)return Iu;Qm=1;var e=jd();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return Iu=t,Iu}var Mu,Jm;function yk(){if(Jm)return Mu;Jm=1;var e=Od(),t=_x(),n=zn();function r(i,a){return i==null?i:e(i,t(a),n)}return Mu=r,Mu}var qu,ey;function vk(){if(ey)return qu;ey=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return qu=e,qu}var Ou,ty;function bk(){if(ty)return Ou;ty=1;var e=Zi(),t=Ld(),n=un();function r(i,a){var o={};return a=n(a,3),t(i,function(s,c,l){e(o,c,a(s,c,l))}),o}return Ou=r,Ou}var Lu,ny;function zd(){if(ny)return Lu;ny=1;var e=_r();function t(n,r,i){for(var a=-1,o=n.length;++a<o;){var s=n[a],c=r(s);if(c!=null&&(l===void 0?c===c&&!e(c):i(c,l)))var l=c,u=s}return u}return Lu=t,Lu}var Pu,ry;function xk(){if(ry)return Pu;ry=1;function e(t,n){return t>n}return Pu=e,Pu}var Du,iy;function _k(){if(iy)return Du;iy=1;var e=zd(),t=xk(),n=Fn();function r(i){return i&&i.length?e(i,n,t):void 0}return Du=r,Du}var ju,ay;function Qx(){if(ay)return ju;ay=1;var e=Zi(),t=yr();function n(r,i,a){(a!==void 0&&!t(r[i],a)||a===void 0&&!(i in r))&&e(r,i,a)}return ju=n,ju}var $u,oy;function wk(){if(oy)return $u;oy=1;var e=jn(),t=na(),n=Vt(),r="[object Object]",i=Function.prototype,a=Object.prototype,o=i.toString,s=a.hasOwnProperty,c=o.call(Object);function l(u){if(!n(u)||e(u)!=r)return!1;var d=t(u);if(d===null)return!0;var f=s.call(d,"constructor")&&d.constructor;return typeof f=="function"&&f instanceof f&&o.call(f)==c}return $u=l,$u}var zu,sy;function Jx(){if(sy)return zu;sy=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return zu=e,zu}var Fu,cy;function Ek(){if(cy)return Fu;cy=1;var e=Jr(),t=zn();function n(r){return e(r,t(r))}return Fu=n,Fu}var Hu,uy;function Sk(){if(uy)return Hu;uy=1;var e=Qx(),t=cx(),n=yx(),r=ux(),i=bx(),a=ei(),o=Xe(),s=Ux(),c=br(),l=Qr(),u=It(),d=wk(),f=ti(),h=Jx(),g=Ek();function m(y,v,b,E,_,T,N){var q=h(y,b),L=h(v,b),O=N.get(L);if(O){e(y,b,O);return}var R=T?T(q,L,b+"",y,v,N):void 0,I=R===void 0;if(I){var G=o(L),H=!G&&c(L),x=!G&&!H&&f(L);R=L,G||H||x?o(q)?R=q:s(q)?R=r(q):H?(I=!1,R=t(L,!0)):x?(I=!1,R=n(L,!0)):R=[]:d(L)||a(L)?(R=q,a(q)?R=g(q):(!u(q)||l(q))&&(R=i(L))):I=!1}I&&(N.set(L,R),_(R,L,E,T,N),N.delete(L)),e(y,b,R)}return Hu=m,Hu}var Uu,ly;function Ck(){if(ly)return Uu;ly=1;var e=Xi(),t=Qx(),n=Od(),r=Sk(),i=It(),a=zn(),o=Jx();function s(c,l,u,d,f){c!==l&&n(l,function(h,g){if(f||(f=new e),i(h))r(c,l,g,u,s,d,f);else{var m=d?d(o(c,g),h,g+"",c,l,f):void 0;m===void 0&&(m=h),t(c,g,m)}},a)}return Uu=s,Uu}var Bu,dy;function Nk(){if(dy)return Bu;dy=1;var e=sa(),t=ca();function n(r){return e(function(i,a){var o=-1,s=a.length,c=s>1?a[s-1]:void 0,l=s>2?a[2]:void 0;for(c=r.length>3&&typeof c=="function"?(s--,c):void 0,l&&t(a[0],a[1],l)&&(c=s<3?void 0:c,s=1),i=Object(i);++o<s;){var u=a[o];u&&r(i,u,o,c)}return i})}return Bu=n,Bu}var Gu,fy;function Ak(){if(fy)return Gu;fy=1;var e=Ck(),t=Nk(),n=t(function(r,i,a){e(r,i,a)});return Gu=n,Gu}var Vu,hy;function e0(){if(hy)return Vu;hy=1;function e(t,n){return t<n}return Vu=e,Vu}var Ku,py;function Tk(){if(py)return Ku;py=1;var e=zd(),t=e0(),n=Fn();function r(i){return i&&i.length?e(i,n,t):void 0}return Ku=r,Ku}var Wu,gy;function kk(){if(gy)return Wu;gy=1;var e=zd(),t=un(),n=e0();function r(i,a){return i&&i.length?e(i,t(a,2),n):void 0}return Wu=r,Wu}var Yu,my;function Rk(){if(my)return Yu;my=1;var e=$t(),t=function(){return e.Date.now()};return Yu=t,Yu}var Xu,yy;function Ik(){if(yy)return Xu;yy=1;var e=Qi(),t=aa(),n=Ji(),r=It(),i=ni();function a(o,s,c,l){if(!r(o))return o;s=t(s,o);for(var u=-1,d=s.length,f=d-1,h=o;h!=null&&++u<d;){var g=i(s[u]),m=c;if(g==="__proto__"||g==="constructor"||g==="prototype")return o;if(u!=f){var y=h[g];m=l?l(y,g,h):void 0,m===void 0&&(m=r(y)?y:n(s[u+1])?[]:{})}e(h,g,m),h=h[g]}return o}return Xu=a,Xu}var Zu,vy;function Mk(){if(vy)return Zu;vy=1;var e=oa(),t=Ik(),n=aa();function r(i,a,o){for(var s=-1,c=a.length,l={};++s<c;){var u=a[s],d=e(i,u);o(d,u)&&t(l,n(u,i),d)}return l}return Zu=r,Zu}var Qu,by;function qk(){if(by)return Qu;by=1;var e=Mk(),t=Mx();function n(r,i){return e(r,i,function(a,o){return t(r,o)})}return Qu=n,Qu}var Ju,xy;function Ok(){if(xy)return Ju;xy=1;var e=Zx(),t=zx(),n=Fx();function r(i){return n(t(i,void 0,e),i+"")}return Ju=r,Ju}var el,_y;function Lk(){if(_y)return el;_y=1;var e=qk(),t=Ok(),n=t(function(r,i){return r==null?{}:e(r,i)});return el=n,el}var tl,wy;function Pk(){if(wy)return tl;wy=1;var e=Math.ceil,t=Math.max;function n(r,i,a,o){for(var s=-1,c=t(e((i-r)/(a||1)),0),l=Array(c);c--;)l[o?c:++s]=r,r+=a;return l}return tl=n,tl}var nl,Ey;function Dk(){if(Ey)return nl;Ey=1;var e=Pk(),t=ca(),n=Xx();function r(i){return function(a,o,s){return s&&typeof s!="number"&&t(a,o,s)&&(o=s=void 0),a=n(a),o===void 0?(o=a,a=0):o=n(o),s=s===void 0?a<o?1:-1:n(s),e(a,o,s,i)}}return nl=r,nl}var rl,Sy;function jk(){if(Sy)return rl;Sy=1;var e=Dk(),t=e();return rl=t,rl}var il,Cy;function $k(){if(Cy)return il;Cy=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return il=e,il}var al,Ny;function zk(){if(Ny)return al;Ny=1;var e=_r();function t(n,r){if(n!==r){var i=n!==void 0,a=n===null,o=n===n,s=e(n),c=r!==void 0,l=r===null,u=r===r,d=e(r);if(!l&&!d&&!s&&n>r||s&&c&&u&&!l&&!d||a&&c&&u||!i&&u||!o)return 1;if(!a&&!s&&!d&&n<r||d&&i&&o&&!a&&!s||l&&i&&o||!c&&o||!u)return-1}return 0}return al=t,al}var ol,Ay;function Fk(){if(Ay)return ol;Ay=1;var e=zk();function t(n,r,i){for(var a=-1,o=n.criteria,s=r.criteria,c=o.length,l=i.length;++a<c;){var u=e(o[a],s[a]);if(u){if(a>=l)return u;var d=i[a];return u*(d=="desc"?-1:1)}}return n.index-r.index}return ol=t,ol}var sl,Ty;function Hk(){if(Ty)return sl;Ty=1;var e=ia(),t=oa(),n=un(),r=Dx(),i=$k(),a=ea(),o=Fk(),s=Fn(),c=Xe();function l(u,d,f){d.length?d=e(d,function(m){return c(m)?function(y){return t(y,m.length===1?m[0]:m)}:m}):d=[s];var h=-1;d=e(d,a(n));var g=r(u,function(m,y,v){var b=e(d,function(E){return E(m)});return{criteria:b,index:++h,value:m}});return i(g,function(m,y){return o(m,y,f)})}return sl=l,sl}var cl,ky;function Uk(){if(ky)return cl;ky=1;var e=jd(),t=Hk(),n=sa(),r=ca(),i=n(function(a,o){if(a==null)return[];var s=o.length;return s>1&&r(a,o[0],o[1])?o=[]:s>2&&r(o[0],o[1],o[2])&&(o=[o[0]]),t(a,e(o,1),[])});return cl=i,cl}var ul,Ry;function Bk(){if(Ry)return ul;Ry=1;var e=Rx(),t=0;function n(r){var i=++t;return e(r)+i}return ul=n,ul}var ll,Iy;function Gk(){if(Iy)return ll;Iy=1;function e(t,n,r){for(var i=-1,a=t.length,o=n.length,s={};++i<a;){var c=i<o?n[i]:void 0;r(s,t[i],c)}return s}return ll=e,ll}var dl,My;function Vk(){if(My)return dl;My=1;var e=Qi(),t=Gk();function n(r,i){return t(r||[],i||[],e)}return dl=n,dl}var Ii;if(typeof Ed=="function")try{Ii={cloneDeep:ck(),constant:qd(),defaults:uk(),each:Ex(),filter:Ox(),find:mk(),flatten:Zx(),forEach:wx(),forIn:yk(),has:Lx(),isUndefined:Px(),last:vk(),map:jx(),mapValues:bk(),max:_k(),merge:Ak(),min:Tk(),minBy:kk(),now:Rk(),pick:Lk(),range:jk(),reduce:$x(),sortBy:Uk(),uniqueId:Bk(),values:Bx(),zipObject:Vk()}}catch{}Ii||(Ii=window._);var De=Ii,Kk=ua;function ua(){var e={};e._next=e._prev=e,this._sentinel=e}ua.prototype.dequeue=function(){var e=this._sentinel,t=e._prev;if(t!==e)return t0(t),t};ua.prototype.enqueue=function(e){var t=this._sentinel;e._prev&&e._next&&t0(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t};ua.prototype.toString=function(){for(var e=[],t=this._sentinel,n=t._prev;n!==t;)e.push(JSON.stringify(n,Wk)),n=n._prev;return"["+e.join(", ")+"]"};function t0(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Wk(e,t){if(e!=="_next"&&e!=="_prev")return t}var tn=De,Yk=zt.Graph,Xk=Kk,Zk=Jk,Qk=tn.constant(1);function Jk(e,t){if(e.nodeCount()<=1)return[];var n=tR(e,t||Qk),r=eR(n.graph,n.buckets,n.zeroIdx);return tn.flatten(tn.map(r,function(i){return e.outEdges(i.v,i.w)}),!0)}function eR(e,t,n){for(var r=[],i=t[t.length-1],a=t[0],o;e.nodeCount();){for(;o=a.dequeue();)fl(e,t,n,o);for(;o=i.dequeue();)fl(e,t,n,o);if(e.nodeCount()){for(var s=t.length-2;s>0;--s)if(o=t[s].dequeue(),o){r=r.concat(fl(e,t,n,o,!0));break}}}return r}function fl(e,t,n,r,i){var a=i?[]:void 0;return tn.forEach(e.inEdges(r.v),function(o){var s=e.edge(o),c=e.node(o.v);i&&a.push({v:o.v,w:o.w}),c.out-=s,Kl(t,n,c)}),tn.forEach(e.outEdges(r.v),function(o){var s=e.edge(o),c=o.w,l=e.node(c);l.in-=s,Kl(t,n,l)}),e.removeNode(r.v),a}function tR(e,t){var n=new Yk,r=0,i=0;tn.forEach(e.nodes(),function(s){n.setNode(s,{v:s,in:0,out:0})}),tn.forEach(e.edges(),function(s){var c=n.edge(s.v,s.w)||0,l=t(s),u=c+l;n.setEdge(s.v,s.w,u),i=Math.max(i,n.node(s.v).out+=l),r=Math.max(r,n.node(s.w).in+=l)});var a=tn.range(i+r+3).map(function(){return new Xk}),o=r+1;return tn.forEach(n.nodes(),function(s){Kl(a,o,n.node(s))}),{graph:n,buckets:a,zeroIdx:o}}function Kl(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}var qn=De,nR=Zk,rR={run:iR,undo:oR};function iR(e){var t=e.graph().acyclicer==="greedy"?nR(e,n(e)):aR(e);qn.forEach(t,function(r){var i=e.edge(r);e.removeEdge(r),i.forwardName=r.name,i.reversed=!0,e.setEdge(r.w,r.v,i,qn.uniqueId("rev"))});function n(r){return function(i){return r.edge(i).weight}}}function aR(e){var t=[],n={},r={};function i(a){qn.has(r,a)||(r[a]=!0,n[a]=!0,qn.forEach(e.outEdges(a),function(o){qn.has(n,o.w)?t.push(o):i(o.w)}),delete n[a])}return qn.forEach(e.nodes(),i),t}function oR(e){qn.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}var Ee=De,n0=zt.Graph,xt={addDummyNode:r0,simplify:sR,asNonCompoundGraph:cR,successorWeights:uR,predecessorWeights:lR,intersectRect:dR,buildLayerMatrix:fR,normalizeRanks:hR,removeEmptyRanks:pR,addBorderNode:gR,maxRank:i0,partition:mR,time:yR,notime:vR};function r0(e,t,n,r){var i;do i=Ee.uniqueId(r);while(e.hasNode(i));return n.dummy=t,e.setNode(i,n),i}function sR(e){var t=new n0().setGraph(e.graph());return Ee.forEach(e.nodes(),function(n){t.setNode(n,e.node(n))}),Ee.forEach(e.edges(),function(n){var r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function cR(e){var t=new n0({multigraph:e.isMultigraph()}).setGraph(e.graph());return Ee.forEach(e.nodes(),function(n){e.children(n).length||t.setNode(n,e.node(n))}),Ee.forEach(e.edges(),function(n){t.setEdge(n,e.edge(n))}),t}function uR(e){var t=Ee.map(e.nodes(),function(n){var r={};return Ee.forEach(e.outEdges(n),function(i){r[i.w]=(r[i.w]||0)+e.edge(i).weight}),r});return Ee.zipObject(e.nodes(),t)}function lR(e){var t=Ee.map(e.nodes(),function(n){var r={};return Ee.forEach(e.inEdges(n),function(i){r[i.v]=(r[i.v]||0)+e.edge(i).weight}),r});return Ee.zipObject(e.nodes(),t)}function dR(e,t){var n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw new Error("Not possible to find intersection inside of the rectangle");var c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function fR(e){var t=Ee.map(Ee.range(i0(e)+1),function(){return[]});return Ee.forEach(e.nodes(),function(n){var r=e.node(n),i=r.rank;Ee.isUndefined(i)||(t[i][r.order]=n)}),t}function hR(e){var t=Ee.min(Ee.map(e.nodes(),function(n){return e.node(n).rank}));Ee.forEach(e.nodes(),function(n){var r=e.node(n);Ee.has(r,"rank")&&(r.rank-=t)})}function pR(e){var t=Ee.min(Ee.map(e.nodes(),function(a){return e.node(a).rank})),n=[];Ee.forEach(e.nodes(),function(a){var o=e.node(a).rank-t;n[o]||(n[o]=[]),n[o].push(a)});var r=0,i=e.graph().nodeRankFactor;Ee.forEach(n,function(a,o){Ee.isUndefined(a)&&o%i!==0?--r:r&&Ee.forEach(a,function(s){e.node(s).rank+=r})})}function gR(e,t,n,r){var i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),r0(e,"border",i,t)}function i0(e){return Ee.max(Ee.map(e.nodes(),function(t){var n=e.node(t).rank;if(!Ee.isUndefined(n))return n}))}function mR(e,t){var n={lhs:[],rhs:[]};return Ee.forEach(e,function(r){t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function yR(e,t){var n=Ee.now();try{return t()}finally{console.log(e+" time: "+(Ee.now()-n)+"ms")}}function vR(e,t){return t()}var a0=De,bR=xt,xR={run:_R,undo:ER};function _R(e){e.graph().dummyChains=[],a0.forEach(e.edges(),function(t){wR(e,t)})}function wR(e,t){var n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a!==r+1){e.removeEdge(t);var l,u,d;for(d=0,++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=bR.addDummyNode(e,"edge",u,"_d"),r===c&&(u.width=s.width,u.height=s.height,u.dummy="edge-label",u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}}function ER(e){a0.forEach(e.graph().dummyChains,function(t){var n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy==="edge-label"&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}var hi=De,la={longestPath:SR,slack:CR};function SR(e){var t={};function n(r){var i=e.node(r);if(hi.has(t,r))return i.rank;t[r]=!0;var a=hi.min(hi.map(e.outEdges(r),function(o){return n(o.w)-e.edge(o).minlen}));return(a===Number.POSITIVE_INFINITY||a===void 0||a===null)&&(a=0),i.rank=a}hi.forEach(e.sources(),n)}function CR(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var Mi=De,NR=zt.Graph,qi=la.slack,o0=AR;function AR(e){var t=new NR({directed:!1}),n=e.nodes()[0],r=e.nodeCount();t.setNode(n,{});for(var i,a;TR(t,e)<r;)i=kR(t,e),a=t.hasNode(i.v)?qi(e,i):-qi(e,i),RR(t,e,a);return t}function TR(e,t){function n(r){Mi.forEach(t.nodeEdges(r),function(i){var a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!qi(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return Mi.forEach(e.nodes(),n),e.nodeCount()}function kR(e,t){return Mi.minBy(t.edges(),function(n){if(e.hasNode(n.v)!==e.hasNode(n.w))return qi(t,n)})}function RR(e,t,n){Mi.forEach(e.nodes(),function(r){t.node(r).rank+=n})}var sn=De,IR=o0,MR=la.slack,qR=la.longestPath,OR=zt.alg.preorder,LR=zt.alg.postorder,PR=xt.simplify,DR=Hn;Hn.initLowLimValues=Hd;Hn.initCutValues=Fd;Hn.calcCutValue=s0;Hn.leaveEdge=u0;Hn.enterEdge=l0;Hn.exchangeEdges=d0;function Hn(e){e=PR(e),qR(e);var t=IR(e);Hd(t),Fd(t,e);for(var n,r;n=u0(t);)r=l0(t,e,n),d0(t,e,n,r)}function Fd(e,t){var n=LR(e,e.nodes());n=n.slice(0,n.length-1),sn.forEach(n,function(r){jR(e,t,r)})}function jR(e,t,n){var r=e.node(n),i=r.parent;e.edge(n,i).cutvalue=s0(e,t,n)}function s0(e,t,n){var r=e.node(n),i=r.parent,a=!0,o=t.edge(n,i),s=0;return o||(a=!1,o=t.edge(i,n)),s=o.weight,sn.forEach(t.nodeEdges(n),function(c){var l=c.v===n,u=l?c.w:c.v;if(u!==i){var d=l===a,f=t.edge(c).weight;if(s+=d?f:-f,zR(e,n,u)){var h=e.edge(n,u).cutvalue;s+=d?-h:h}}}),s}function Hd(e,t){arguments.length<2&&(t=e.nodes()[0]),c0(e,{},1,t)}function c0(e,t,n,r,i){var a=n,o=e.node(r);return t[r]=!0,sn.forEach(e.neighbors(r),function(s){sn.has(t,s)||(n=c0(e,t,n,s,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function u0(e){return sn.find(e.edges(),function(t){return e.edge(t).cutvalue<0})}function l0(e,t,n){var r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);var a=e.node(r),o=e.node(i),s=a,c=!1;a.lim>o.lim&&(s=o,c=!0);var l=sn.filter(t.edges(),function(u){return c===qy(e,e.node(u.v),s)&&c!==qy(e,e.node(u.w),s)});return sn.minBy(l,function(u){return MR(t,u)})}function d0(e,t,n,r){var i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Hd(e),Fd(e,t),$R(e,t)}function $R(e,t){var n=sn.find(e.nodes(),function(i){return!t.node(i).parent}),r=OR(e,n);r=r.slice(1),sn.forEach(r,function(i){var a=e.node(i).parent,o=t.edge(i,a),s=!1;o||(o=t.edge(a,i),s=!0),t.node(i).rank=t.node(a).rank+(s?o.minlen:-o.minlen)})}function zR(e,t,n){return e.hasEdge(t,n)}function qy(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var FR=la,f0=FR.longestPath,HR=o0,UR=DR,BR=GR;function GR(e){switch(e.graph().ranker){case"network-simplex":Oy(e);break;case"tight-tree":KR(e);break;case"longest-path":VR(e);break;default:Oy(e)}}var VR=f0;function KR(e){f0(e),HR(e)}function Oy(e){UR(e)}var Wl=De,WR=YR;function YR(e){var t=ZR(e);Wl.forEach(e.graph().dummyChains,function(n){for(var r=e.node(n),i=r.edgeObj,a=XR(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(l=o[c+1]).minRank<=r.rank;)c++;l=o[c]}e.setParent(n,l),n=e.successors(n)[0]}})}function XR(e,t,n,r){var i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c,l;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function ZR(e){var t={},n=0;function r(i){var a=n;Wl.forEach(e.children(i),r),t[i]={low:a,lim:n++}}return Wl.forEach(e.children(),r),t}var nn=De,Yl=xt,QR={run:JR,cleanup:n2};function JR(e){var t=Yl.addDummyNode(e,"root",{},"_root"),n=e2(e),r=nn.max(nn.values(n))-1,i=2*r+1;e.graph().nestingRoot=t,nn.forEach(e.edges(),function(o){e.edge(o).minlen*=i});var a=t2(e)+1;nn.forEach(e.children(),function(o){h0(e,t,i,a,r,n,o)}),e.graph().nodeRankFactor=i}function h0(e,t,n,r,i,a,o){var s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}var c=Yl.addBorderNode(e,"_bt"),l=Yl.addBorderNode(e,"_bb"),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,nn.forEach(s,function(d){h0(e,t,n,r,i,a,d);var f=e.node(d),h=f.borderTop?f.borderTop:d,g=f.borderBottom?f.borderBottom:d,m=f.borderTop?r:2*r,y=h!==g?1:i-a[o]+1;e.setEdge(c,h,{weight:m,minlen:y,nestingEdge:!0}),e.setEdge(g,l,{weight:m,minlen:y,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+a[o]})}function e2(e){var t={};function n(r,i){var a=e.children(r);a&&a.length&&nn.forEach(a,function(o){n(o,i+1)}),t[r]=i}return nn.forEach(e.children(),function(r){n(r,1)}),t}function t2(e){return nn.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}function n2(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,nn.forEach(e.edges(),function(n){var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}var hl=De,r2=xt,i2=a2;function a2(e){function t(n){var r=e.children(n),i=e.node(n);if(r.length&&hl.forEach(r,t),hl.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var a=i.minRank,o=i.maxRank+1;a<o;++a)Ly(e,"borderLeft","_bl",n,i,a),Ly(e,"borderRight","_br",n,i,a)}}hl.forEach(e.children(),t)}function Ly(e,t,n,r,i,a){var o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=r2.addDummyNode(e,"border",o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}var Ut=De,o2={adjust:s2,undo:c2};function s2(e){var t=e.graph().rankdir.toLowerCase();(t==="lr"||t==="rl")&&p0(e)}function c2(e){var t=e.graph().rankdir.toLowerCase();(t==="bt"||t==="rl")&&u2(e),(t==="lr"||t==="rl")&&(l2(e),p0(e))}function p0(e){Ut.forEach(e.nodes(),function(t){Py(e.node(t))}),Ut.forEach(e.edges(),function(t){Py(e.edge(t))})}function Py(e){var t=e.width;e.width=e.height,e.height=t}function u2(e){Ut.forEach(e.nodes(),function(t){pl(e.node(t))}),Ut.forEach(e.edges(),function(t){var n=e.edge(t);Ut.forEach(n.points,pl),Ut.has(n,"y")&&pl(n)})}function pl(e){e.y=-e.y}function l2(e){Ut.forEach(e.nodes(),function(t){gl(e.node(t))}),Ut.forEach(e.edges(),function(t){var n=e.edge(t);Ut.forEach(n.points,gl),Ut.has(n,"x")&&gl(n)})}function gl(e){var t=e.x;e.x=e.y,e.y=t}var Jt=De,d2=f2;function f2(e){var t={},n=Jt.filter(e.nodes(),function(s){return!e.children(s).length}),r=Jt.max(Jt.map(n,function(s){return e.node(s).rank})),i=Jt.map(Jt.range(r+1),function(){return[]});function a(s){if(!Jt.has(t,s)){t[s]=!0;var c=e.node(s);i[c.rank].push(s),Jt.forEach(e.successors(s),a)}}var o=Jt.sortBy(n,function(s){return e.node(s).rank});return Jt.forEach(o,a),i}var dn=De,h2=p2;function p2(e,t){for(var n=0,r=1;r<t.length;++r)n+=g2(e,t[r-1],t[r]);return n}function g2(e,t,n){for(var r=dn.zipObject(n,dn.map(n,function(l,u){return u})),i=dn.flatten(dn.map(t,function(l){return dn.sortBy(dn.map(e.outEdges(l),function(u){return{pos:r[u.w],weight:e.edge(u).weight}}),"pos")}),!0),a=1;a<n.length;)a<<=1;var o=2*a-1;a-=1;var s=dn.map(new Array(o),function(){return 0}),c=0;return dn.forEach(i.forEach(function(l){var u=l.pos+a;s[u]+=l.weight;for(var d=0;u>0;)u%2&&(d+=s[u+1]),u=u-1>>1,s[u]+=l.weight;c+=l.weight*d})),c}var Dy=De,m2=y2;function y2(e,t){return Dy.map(t,function(n){var r=e.inEdges(n);if(r.length){var i=Dy.reduce(r,function(a,o){var s=e.edge(o),c=e.node(o.v);return{sum:a.sum+s.weight*c.order,weight:a.weight+s.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:n}})}var St=De,v2=b2;function b2(e,t){var n={};St.forEach(e,function(i,a){var o=n[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:a};St.isUndefined(i.barycenter)||(o.barycenter=i.barycenter,o.weight=i.weight)}),St.forEach(t.edges(),function(i){var a=n[i.v],o=n[i.w];!St.isUndefined(a)&&!St.isUndefined(o)&&(o.indegree++,a.out.push(n[i.w]))});var r=St.filter(n,function(i){return!i.indegree});return x2(r)}function x2(e){var t=[];function n(a){return function(o){o.merged||(St.isUndefined(o.barycenter)||St.isUndefined(a.barycenter)||o.barycenter>=a.barycenter)&&_2(a,o)}}function r(a){return function(o){o.in.push(a),--o.indegree===0&&e.push(o)}}for(;e.length;){var i=e.pop();t.push(i),St.forEach(i.in.reverse(),n(i)),St.forEach(i.out,r(i))}return St.map(St.filter(t,function(a){return!a.merged}),function(a){return St.pick(a,["vs","i","barycenter","weight"])})}function _2(e,t){var n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}var Pr=De,w2=xt,E2=S2;function S2(e,t){var n=w2.partition(e,function(u){return Pr.has(u,"barycenter")}),r=n.lhs,i=Pr.sortBy(n.rhs,function(u){return-u.i}),a=[],o=0,s=0,c=0;r.sort(C2(!!t)),c=jy(a,i,c),Pr.forEach(r,function(u){c+=u.vs.length,a.push(u.vs),o+=u.barycenter*u.weight,s+=u.weight,c=jy(a,i,c)});var l={vs:Pr.flatten(a,!0)};return s&&(l.barycenter=o/s,l.weight=s),l}function jy(e,t,n){for(var r;t.length&&(r=Pr.last(t)).i<=n;)t.pop(),e.push(r.vs),n++;return n}function C2(e){return function(t,n){return t.barycenter<n.barycenter?-1:t.barycenter>n.barycenter?1:e?n.i-t.i:t.i-n.i}}var gn=De,N2=m2,A2=v2,T2=E2,k2=g0;function g0(e,t,n,r){var i=e.children(t),a=e.node(t),o=a?a.borderLeft:void 0,s=a?a.borderRight:void 0,c={};o&&(i=gn.filter(i,function(g){return g!==o&&g!==s}));var l=N2(e,i);gn.forEach(l,function(g){if(e.children(g.v).length){var m=g0(e,g.v,n,r);c[g.v]=m,gn.has(m,"barycenter")&&I2(g,m)}});var u=A2(l,n);R2(u,c);var d=T2(u,r);if(o&&(d.vs=gn.flatten([o,d.vs,s],!0),e.predecessors(o).length)){var f=e.node(e.predecessors(o)[0]),h=e.node(e.predecessors(s)[0]);gn.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+h.order)/(d.weight+2),d.weight+=2}return d}function R2(e,t){gn.forEach(e,function(n){n.vs=gn.flatten(n.vs.map(function(r){return t[r]?t[r].vs:r}),!0)})}function I2(e,t){gn.isUndefined(e.barycenter)?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}var Dr=De,M2=zt.Graph,q2=O2;function O2(e,t,n){var r=L2(e),i=new M2({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(a){return e.node(a)});return Dr.forEach(e.nodes(),function(a){var o=e.node(a),s=e.parent(a);(o.rank===t||o.minRank<=t&&t<=o.maxRank)&&(i.setNode(a),i.setParent(a,s||r),Dr.forEach(e[n](a),function(c){var l=c.v===a?c.w:c.v,u=i.edge(l,a),d=Dr.isUndefined(u)?0:u.weight;i.setEdge(l,a,{weight:e.edge(c).weight+d})}),Dr.has(o,"minRank")&&i.setNode(a,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]}))}),i}function L2(e){for(var t;e.hasNode(t=Dr.uniqueId("_root")););return t}var P2=De,D2=j2;function j2(e,t,n){var r={},i;P2.forEach(n,function(a){for(var o=e.parent(a),s,c;o;){if(s=e.parent(o),s?(c=r[s],r[s]=o):(c=i,i=o),c&&c!==o){t.setEdge(c,o);return}o=s}})}var bn=De,$2=d2,z2=h2,F2=k2,H2=q2,U2=D2,B2=zt.Graph,$y=xt,G2=V2;function V2(e){var t=$y.maxRank(e),n=zy(e,bn.range(1,t+1),"inEdges"),r=zy(e,bn.range(t-1,-1,-1),"outEdges"),i=$2(e);Fy(e,i);for(var a=Number.POSITIVE_INFINITY,o,s=0,c=0;c<4;++s,++c){K2(s%2?n:r,s%4>=2),i=$y.buildLayerMatrix(e);var l=z2(e,i);l<a&&(c=0,o=bn.cloneDeep(i),a=l)}Fy(e,o)}function zy(e,t,n){return bn.map(t,function(r){return H2(e,r,n)})}function K2(e,t){var n=new B2;bn.forEach(e,function(r){var i=r.graph().root,a=F2(r,i,n,t);bn.forEach(a.vs,function(o,s){r.node(o).order=s}),U2(r,n,a.vs)})}function Fy(e,t){bn.forEach(t,function(n){bn.forEach(n,function(r,i){e.node(r).order=i})})}var le=De,W2=zt.Graph,Y2=xt,X2={positionX:sI};function Z2(e,t){var n={};function r(i,a){var o=0,s=0,c=i.length,l=le.last(a);return le.forEach(a,function(u,d){var f=J2(e,u),h=f?e.node(f).order:c;(f||u===l)&&(le.forEach(a.slice(s,d+1),function(g){le.forEach(e.predecessors(g),function(m){var y=e.node(m),v=y.order;(v<o||h<v)&&!(y.dummy&&e.node(g).dummy)&&m0(n,m,g)})}),s=d+1,o=h)}),a}return le.reduce(t,r),n}function Q2(e,t){var n={};function r(a,o,s,c,l){var u;le.forEach(le.range(o,s),function(d){u=a[d],e.node(u).dummy&&le.forEach(e.predecessors(u),function(f){var h=e.node(f);h.dummy&&(h.order<c||h.order>l)&&m0(n,f,u)})})}function i(a,o){var s=-1,c,l=0;return le.forEach(o,function(u,d){if(e.node(u).dummy==="border"){var f=e.predecessors(u);f.length&&(c=e.node(f[0]).order,r(o,l,d,s,c),l=d,s=c)}r(o,l,o.length,c,a.length)}),o}return le.reduce(t,i),n}function J2(e,t){if(e.node(t).dummy)return le.find(e.predecessors(t),function(n){return e.node(n).dummy})}function m0(e,t,n){if(t>n){var r=t;t=n,n=r}var i=e[t];i||(e[t]=i={}),i[n]=!0}function eI(e,t,n){if(t>n){var r=t;t=n,n=r}return le.has(e[t],n)}function tI(e,t,n,r){var i={},a={},o={};return le.forEach(t,function(s){le.forEach(s,function(c,l){i[c]=c,a[c]=c,o[c]=l})}),le.forEach(t,function(s){var c=-1;le.forEach(s,function(l){var u=r(l);if(u.length){u=le.sortBy(u,function(m){return o[m]});for(var d=(u.length-1)/2,f=Math.floor(d),h=Math.ceil(d);f<=h;++f){var g=u[f];a[l]===l&&c<o[g]&&!eI(n,l,g)&&(a[g]=l,a[l]=i[l]=i[g],c=o[g])}}})}),{root:i,align:a}}function nI(e,t,n,r,i){var a={},o=rI(e,t,n,i),s=i?"borderLeft":"borderRight";function c(d,f){for(var h=o.nodes(),g=h.pop(),m={};g;)m[g]?d(g):(m[g]=!0,h.push(g),h=h.concat(f(g))),g=h.pop()}function l(d){a[d]=o.inEdges(d).reduce(function(f,h){return Math.max(f,a[h.v]+o.edge(h))},0)}function u(d){var f=o.outEdges(d).reduce(function(g,m){return Math.min(g,a[m.w]-o.edge(m))},Number.POSITIVE_INFINITY),h=e.node(d);f!==Number.POSITIVE_INFINITY&&h.borderType!==s&&(a[d]=Math.max(a[d],f))}return c(l,o.predecessors.bind(o)),c(u,o.successors.bind(o)),le.forEach(r,function(d){a[d]=a[n[d]]}),a}function rI(e,t,n,r){var i=new W2,a=e.graph(),o=cI(a.nodesep,a.edgesep,r);return le.forEach(t,function(s){var c;le.forEach(s,function(l){var u=n[l];if(i.setNode(u),c){var d=n[c],f=i.edge(d,u);i.setEdge(d,u,Math.max(o(e,l,c),f||0))}c=l})}),i}function iI(e,t){return le.minBy(le.values(t),function(n){var r=Number.NEGATIVE_INFINITY,i=Number.POSITIVE_INFINITY;return le.forIn(n,function(a,o){var s=uI(e,o)/2;r=Math.max(a+s,r),i=Math.min(a-s,i)}),r-i})}function aI(e,t){var n=le.values(t),r=le.min(n),i=le.max(n);le.forEach(["u","d"],function(a){le.forEach(["l","r"],function(o){var s=a+o,c=e[s],l;if(c!==t){var u=le.values(c);l=o==="l"?r-le.min(u):i-le.max(u),l&&(e[s]=le.mapValues(c,function(d){return d+l}))}})})}function oI(e,t){return le.mapValues(e.ul,function(n,r){if(t)return e[t.toLowerCase()][r];var i=le.sortBy(le.map(e,r));return(i[1]+i[2])/2})}function sI(e){var t=Y2.buildLayerMatrix(e),n=le.merge(Z2(e,t),Q2(e,t)),r={},i;le.forEach(["u","d"],function(o){i=o==="u"?t:le.values(t).reverse(),le.forEach(["l","r"],function(s){s==="r"&&(i=le.map(i,function(d){return le.values(d).reverse()}));var c=(o==="u"?e.predecessors:e.successors).bind(e),l=tI(e,i,n,c),u=nI(e,i,l.root,l.align,s==="r");s==="r"&&(u=le.mapValues(u,function(d){return-d})),r[o+s]=u})});var a=iI(e,r);return aI(r,a),oI(r,e.graph().align)}function cI(e,t,n){return function(r,i,a){var o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,le.has(o,"labelpos"))switch(o.labelpos.toLowerCase()){case"l":l=-o.width/2;break;case"r":l=o.width/2;break}if(l&&(c+=n?l:-l),l=0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,le.has(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":l=s.width/2;break;case"r":l=-s.width/2;break}return l&&(c+=n?l:-l),l=0,c}}function uI(e,t){return e.node(t).width}var jr=De,y0=xt,lI=X2.positionX,dI=fI;function fI(e){e=y0.asNonCompoundGraph(e),hI(e),jr.forEach(lI(e),function(t,n){e.node(n).x=t})}function hI(e){var t=y0.buildLayerMatrix(e),n=e.graph().ranksep,r=0;jr.forEach(t,function(i){var a=jr.max(jr.map(i,function(o){return e.node(o).height}));jr.forEach(i,function(o){e.node(o).y=r+a/2}),r+=a+n})}var ye=De,Hy=rR,Uy=xR,pI=BR,gI=xt.normalizeRanks,mI=WR,yI=xt.removeEmptyRanks,By=QR,vI=i2,Gy=o2,bI=G2,xI=dI,wn=xt,_I=zt.Graph,wI=EI;function EI(e,t){var n=t&&t.debugTiming?wn.time:wn.notime;n("layout",function(){var r=n("  buildLayoutGraph",function(){return OI(e)});n("  runLayout",function(){SI(r,n)}),n("  updateInputGraph",function(){CI(e,r)})})}function SI(e,t){t("    makeSpaceForEdgeLabels",function(){LI(e)}),t("    removeSelfEdges",function(){BI(e)}),t("    acyclic",function(){Hy.run(e)}),t("    nestingGraph.run",function(){By.run(e)}),t("    rank",function(){pI(wn.asNonCompoundGraph(e))}),t("    injectEdgeLabelProxies",function(){PI(e)}),t("    removeEmptyRanks",function(){yI(e)}),t("    nestingGraph.cleanup",function(){By.cleanup(e)}),t("    normalizeRanks",function(){gI(e)}),t("    assignRankMinMax",function(){DI(e)}),t("    removeEdgeLabelProxies",function(){jI(e)}),t("    normalize.run",function(){Uy.run(e)}),t("    parentDummyChains",function(){mI(e)}),t("    addBorderSegments",function(){vI(e)}),t("    order",function(){bI(e)}),t("    insertSelfEdges",function(){GI(e)}),t("    adjustCoordinateSystem",function(){Gy.adjust(e)}),t("    position",function(){xI(e)}),t("    positionSelfEdges",function(){VI(e)}),t("    removeBorderNodes",function(){UI(e)}),t("    normalize.undo",function(){Uy.undo(e)}),t("    fixupEdgeLabelCoords",function(){FI(e)}),t("    undoCoordinateSystem",function(){Gy.undo(e)}),t("    translateGraph",function(){$I(e)}),t("    assignNodeIntersects",function(){zI(e)}),t("    reversePoints",function(){HI(e)}),t("    acyclic.undo",function(){Hy.undo(e)})}function CI(e,t){ye.forEach(e.nodes(),function(n){var r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,t.children(n).length&&(r.width=i.width,r.height=i.height))}),ye.forEach(e.edges(),function(n){var r=e.edge(n),i=t.edge(n);r.points=i.points,ye.has(i,"x")&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var NI=["nodesep","edgesep","ranksep","marginx","marginy"],AI={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},TI=["acyclicer","ranker","rankdir","align"],kI=["width","height"],RI={width:0,height:0},II=["minlen","weight","width","height","labeloffset"],MI={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},qI=["labelpos"];function OI(e){var t=new _I({multigraph:!0,compound:!0}),n=yl(e.graph());return t.setGraph(ye.merge({},AI,ml(n,NI),ye.pick(n,TI))),ye.forEach(e.nodes(),function(r){var i=yl(e.node(r));t.setNode(r,ye.defaults(ml(i,kI),RI)),t.setParent(r,e.parent(r))}),ye.forEach(e.edges(),function(r){var i=yl(e.edge(r));t.setEdge(r,ye.merge({},MI,ml(i,II),ye.pick(i,qI)))}),t}function LI(e){var t=e.graph();t.ranksep/=2,ye.forEach(e.edges(),function(n){var r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!=="c"&&(t.rankdir==="TB"||t.rankdir==="BT"?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function PI(e){ye.forEach(e.edges(),function(t){var n=e.edge(t);if(n.width&&n.height){var r=e.node(t.v),i=e.node(t.w),a={rank:(i.rank-r.rank)/2+r.rank,e:t};wn.addDummyNode(e,"edge-proxy",a,"_ep")}})}function DI(e){var t=0;ye.forEach(e.nodes(),function(n){var r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=ye.max(t,r.maxRank))}),e.graph().maxRank=t}function jI(e){ye.forEach(e.nodes(),function(t){var n=e.node(t);n.dummy==="edge-proxy"&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function $I(e){var t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(l){var u=l.x,d=l.y,f=l.width,h=l.height;t=Math.min(t,u-f/2),n=Math.max(n,u+f/2),r=Math.min(r,d-h/2),i=Math.max(i,d+h/2)}ye.forEach(e.nodes(),function(l){c(e.node(l))}),ye.forEach(e.edges(),function(l){var u=e.edge(l);ye.has(u,"x")&&c(u)}),t-=o,r-=s,ye.forEach(e.nodes(),function(l){var u=e.node(l);u.x-=t,u.y-=r}),ye.forEach(e.edges(),function(l){var u=e.edge(l);ye.forEach(u.points,function(d){d.x-=t,d.y-=r}),ye.has(u,"x")&&(u.x-=t),ye.has(u,"y")&&(u.y-=r)}),a.width=n-t+o,a.height=i-r+s}function zI(e){ye.forEach(e.edges(),function(t){var n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(wn.intersectRect(r,a)),n.points.push(wn.intersectRect(i,o))})}function FI(e){ye.forEach(e.edges(),function(t){var n=e.edge(t);if(ye.has(n,"x"))switch((n.labelpos==="l"||n.labelpos==="r")&&(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset;break}})}function HI(e){ye.forEach(e.edges(),function(t){var n=e.edge(t);n.reversed&&n.points.reverse()})}function UI(e){ye.forEach(e.nodes(),function(t){if(e.children(t).length){var n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(ye.last(n.borderLeft)),o=e.node(ye.last(n.borderRight));n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),ye.forEach(e.nodes(),function(t){e.node(t).dummy==="border"&&e.removeNode(t)})}function BI(e){ye.forEach(e.edges(),function(t){if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function GI(e){var t=wn.buildLayerMatrix(e);ye.forEach(t,function(n){var r=0;ye.forEach(n,function(i,a){var o=e.node(i);o.order=a+r,ye.forEach(o.selfEdges,function(s){wn.addDummyNode(e,"selfedge",{width:s.label.width,height:s.label.height,rank:o.rank,order:a+ ++r,e:s.e,label:s.label},"_se")}),delete o.selfEdges})})}function VI(e){ye.forEach(e.nodes(),function(t){var n=e.node(t);if(n.dummy==="selfedge"){var r=e.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function ml(e,t){return ye.mapValues(ye.pick(e,t),Number)}function yl(e){var t={};return ye.forEach(e,function(n,r){t[r.toLowerCase()]=n}),t}var pi=De,KI=xt,WI=zt.Graph,YI={debugOrdering:XI};function XI(e){var t=KI.buildLayerMatrix(e),n=new WI({compound:!0,multigraph:!0}).setGraph({});return pi.forEach(e.nodes(),function(r){n.setNode(r,{label:r}),n.setParent(r,"layer"+e.node(r).rank)}),pi.forEach(e.edges(),function(r){n.setEdge(r.v,r.w,{},r.name)}),pi.forEach(t,function(r,i){var a="layer"+i;n.setNode(a,{rank:"same"}),pi.reduce(r,function(o,s){return n.setEdge(o,s,{style:"invis"}),s})}),n}var ZI="0.8.5",QI={graphlib:zt,layout:wI,debug:YI,util:{time:xt.time,notime:xt.notime},version:ZI};const Vy=L0(QI),JI=28,Ky=240,eM=200;function tM(){return S.useCallback((e,t,n={})=>{const r=e.filter(o=>o.data.kind==="table"),i=e.filter(o=>o.data.kind!=="table");if(r.length===0)return e;const a=n.anchorId?r.find(o=>o.id===n.anchorId):void 0;return a&&r.length>1?[...nM(a,r,t),...i]:[...v0(r,t),...i]},[])}function nM(e,t,n){const r=new Set;for(const y of n)y.source===e.id&&y.target!==e.id?r.add(y.target):y.target===e.id&&y.source!==e.id&&r.add(y.source);const i=t.filter(y=>y.id!==e.id&&r.has(y.id)).sort((y,v)=>{const b=Wy(y),E=Wy(v);return b.localeCompare(E)}),a=t.filter(y=>y.id!==e.id&&!r.has(y.id)),o=0,s=0,c=i.length,l=c===0?Ky:Math.max(Ky,eM+c*JI),u=[{...e,position:{x:o-(e.width||240)/2,y:s-(e.height||140)/2}}];for(let y=0;y<c;y+=1){const v=i[y],b=-Math.PI/2+2*Math.PI*y/c;u.push({...v,position:{x:o+l*Math.cos(b)-(v.width||240)/2,y:s+l*Math.sin(b)-(v.height||140)/2}})}if(a.length===0)return u;const d=new Set(a.map(y=>y.id)),f=n.filter(y=>d.has(y.source)||d.has(y.target)),h=v0(a,f),g=Math.min(...h.map(y=>y.position.x)),m=o+l+360-g;return[...u,...h.map(y=>({...y,position:{x:y.position.x+m,y:y.position.y-200}}))]}function v0(e,t){const n=new Vy.graphlib.Graph().setGraph({rankdir:"LR",nodesep:80,ranksep:160,marginx:40,marginy:40});n.setDefaultEdgeLabel(()=>({}));for(const i of e)n.setNode(i.id,{width:i.width||240,height:i.height||140});const r=new Set(e.map(i=>i.id));for(const i of t)r.has(i.source)&&r.has(i.target)&&n.setEdge(i.source,i.target);return Vy.layout(n),e.map(i=>{const a=n.node(i.id);return a?{...i,position:{x:a.x-(i.width||240)/2,y:a.y-(i.height||140)/2}}:i})}function Wy(e){if(e.data.kind!=="table")return e.id;const t=e.data;return`${t.schema||""}.${t.table||""}`}function rM(e,t){if(e.match(/^[a-z]+:\/\//i))return e;if(e.match(/^\/\//))return window.location.protocol+e;if(e.match(/^[a-z]+:/i))return e;const n=document.implementation.createHTMLDocument(),r=n.createElement("base"),i=n.createElement("a");return n.head.appendChild(r),n.body.appendChild(i),t&&(r.href=t),i.href=e,i.href}const iM=(()=>{let e=0;const t=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(e+=1,`u${t()}${e}`)})();function xn(e){const t=[];for(let n=0,r=e.length;n<r;n++)t.push(e[n]);return t}let Qn=null;function b0(e={}){return Qn||(e.includeStyleProperties?(Qn=e.includeStyleProperties,Qn):(Qn=xn(window.getComputedStyle(document.documentElement)),Qn))}function Oi(e,t){const r=(e.ownerDocument.defaultView||window).getComputedStyle(e).getPropertyValue(t);return r?parseFloat(r.replace("px","")):0}function aM(e){const t=Oi(e,"border-left-width"),n=Oi(e,"border-right-width");return e.clientWidth+t+n}function oM(e){const t=Oi(e,"border-top-width"),n=Oi(e,"border-bottom-width");return e.clientHeight+t+n}function x0(e,t={}){const n=t.width||aM(e),r=t.height||oM(e);return{width:n,height:r}}function sM(){let e,t;try{t=process}catch{}const n=t&&t.env?t.env.devicePixelRatio:null;return n&&(e=parseInt(n,10),Number.isNaN(e)&&(e=1)),e||window.devicePixelRatio||1}const wt=16384;function cM(e){(e.width>wt||e.height>wt)&&(e.width>wt&&e.height>wt?e.width>e.height?(e.height*=wt/e.width,e.width=wt):(e.width*=wt/e.height,e.height=wt):e.width>wt?(e.height*=wt/e.width,e.width=wt):(e.width*=wt/e.height,e.height=wt))}function Li(e){return new Promise((t,n)=>{const r=new Image;r.onload=()=>{r.decode().then(()=>{requestAnimationFrame(()=>t(r))})},r.onerror=n,r.crossOrigin="anonymous",r.decoding="async",r.src=e})}async function uM(e){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(e)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}async function lM(e,t,n){const r="http://www.w3.org/2000/svg",i=document.createElementNS(r,"svg"),a=document.createElementNS(r,"foreignObject");return i.setAttribute("width",`${t}`),i.setAttribute("height",`${n}`),i.setAttribute("viewBox",`0 0 ${t} ${n}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),i.appendChild(a),a.appendChild(e),uM(i)}const vt=(e,t)=>{if(e instanceof t)return!0;const n=Object.getPrototypeOf(e);return n===null?!1:n.constructor.name===t.name||vt(n,t)};function dM(e){const t=e.getPropertyValue("content");return`${e.cssText} content: '${t.replace(/'|"/g,"")}';`}function fM(e,t){return b0(t).map(n=>{const r=e.getPropertyValue(n),i=e.getPropertyPriority(n);return`${n}: ${r}${i?" !important":""};`}).join(" ")}function hM(e,t,n,r){const i=`.${e}:${t}`,a=n.cssText?dM(n):fM(n,r);return document.createTextNode(`${i}{${a}}`)}function Yy(e,t,n,r){const i=window.getComputedStyle(e,n),a=i.getPropertyValue("content");if(a===""||a==="none")return;const o=iM();try{t.className=`${t.className} ${o}`}catch{return}const s=document.createElement("style");s.appendChild(hM(o,n,i,r)),t.appendChild(s)}function pM(e,t,n){Yy(e,t,":before",n),Yy(e,t,":after",n)}const Xy="application/font-woff",Zy="image/jpeg",gM={woff:Xy,woff2:Xy,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Zy,jpeg:Zy,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function mM(e){const t=/\.([^./]*?)$/g.exec(e);return t?t[1]:""}function Ud(e){const t=mM(e).toLowerCase();return gM[t]||""}function yM(e){return e.split(/,/)[1]}function Xl(e){return e.search(/^(data:)/)!==-1}function vM(e,t){return`data:${t};base64,${e}`}async function _0(e,t,n){const r=await fetch(e,t);if(r.status===404)throw new Error(`Resource "${r.url}" not found`);const i=await r.blob();return new Promise((a,o)=>{const s=new FileReader;s.onerror=o,s.onloadend=()=>{try{a(n({res:r,result:s.result}))}catch(c){o(c)}},s.readAsDataURL(i)})}const vl={};function bM(e,t,n){let r=e.replace(/\?.*/,"");return n&&(r=e),/ttf|otf|eot|woff2?/i.test(r)&&(r=r.replace(/.*\//,"")),t?`[${t}]${r}`:r}async function Bd(e,t,n){const r=bM(e,t,n.includeQueryParams);if(vl[r]!=null)return vl[r];n.cacheBust&&(e+=(/\?/.test(e)?"&":"?")+new Date().getTime());let i;try{const a=await _0(e,n.fetchRequestInit,({res:o,result:s})=>(t||(t=o.headers.get("Content-Type")||""),yM(s)));i=vM(a,t)}catch(a){i=n.imagePlaceholder||"";let o=`Failed to fetch resource: ${e}`;a&&(o=typeof a=="string"?a:a.message),o&&console.warn(o)}return vl[r]=i,i}async function xM(e){const t=e.toDataURL();return t==="data:,"?e.cloneNode(!1):Li(t)}async function _M(e,t){if(e.currentSrc){const a=document.createElement("canvas"),o=a.getContext("2d");a.width=e.clientWidth,a.height=e.clientHeight,o?.drawImage(e,0,0,a.width,a.height);const s=a.toDataURL();return Li(s)}const n=e.poster,r=Ud(n),i=await Bd(n,r,t);return Li(i)}async function wM(e,t){var n;try{if(!((n=e?.contentDocument)===null||n===void 0)&&n.body)return await da(e.contentDocument.body,t,!0)}catch{}return e.cloneNode(!1)}async function EM(e,t){return vt(e,HTMLCanvasElement)?xM(e):vt(e,HTMLVideoElement)?_M(e,t):vt(e,HTMLIFrameElement)?wM(e,t):e.cloneNode(w0(e))}const SM=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SLOT",w0=e=>e.tagName!=null&&e.tagName.toUpperCase()==="SVG";async function CM(e,t,n){var r,i;if(w0(t))return t;let a=[];return SM(e)&&e.assignedNodes?a=xn(e.assignedNodes()):vt(e,HTMLIFrameElement)&&(!((r=e.contentDocument)===null||r===void 0)&&r.body)?a=xn(e.contentDocument.body.childNodes):a=xn(((i=e.shadowRoot)!==null&&i!==void 0?i:e).childNodes),a.length===0||vt(e,HTMLVideoElement)||await a.reduce((o,s)=>o.then(()=>da(s,n)).then(c=>{c&&t.appendChild(c)}),Promise.resolve()),t}function NM(e,t,n){const r=t.style;if(!r)return;const i=window.getComputedStyle(e);i.cssText?(r.cssText=i.cssText,r.transformOrigin=i.transformOrigin):b0(n).forEach(a=>{let o=i.getPropertyValue(a);a==="font-size"&&o.endsWith("px")&&(o=`${Math.floor(parseFloat(o.substring(0,o.length-2)))-.1}px`),vt(e,HTMLIFrameElement)&&a==="display"&&o==="inline"&&(o="block"),a==="d"&&t.getAttribute("d")&&(o=`path(${t.getAttribute("d")})`),r.setProperty(a,o,i.getPropertyPriority(a))})}function AM(e,t){vt(e,HTMLTextAreaElement)&&(t.innerHTML=e.value),vt(e,HTMLInputElement)&&t.setAttribute("value",e.value)}function TM(e,t){if(vt(e,HTMLSelectElement)){const n=t,r=Array.from(n.children).find(i=>e.value===i.getAttribute("value"));r&&r.setAttribute("selected","")}}function kM(e,t,n){return vt(t,Element)&&(NM(e,t,n),pM(e,t,n),AM(e,t),TM(e,t)),t}async function RM(e,t){const n=e.querySelectorAll?e.querySelectorAll("use"):[];if(n.length===0)return e;const r={};for(let a=0;a<n.length;a++){const s=n[a].getAttribute("xlink:href");if(s){const c=e.querySelector(s),l=document.querySelector(s);!c&&l&&!r[s]&&(r[s]=await da(l,t,!0))}}const i=Object.values(r);if(i.length){const a="http://www.w3.org/1999/xhtml",o=document.createElementNS(a,"svg");o.setAttribute("xmlns",a),o.style.position="absolute",o.style.width="0",o.style.height="0",o.style.overflow="hidden",o.style.display="none";const s=document.createElementNS(a,"defs");o.appendChild(s);for(let c=0;c<i.length;c++)s.appendChild(i[c]);e.appendChild(o)}return e}async function da(e,t,n){return!n&&t.filter&&!t.filter(e)?null:Promise.resolve(e).then(r=>EM(r,t)).then(r=>CM(e,r,t)).then(r=>kM(e,r,t)).then(r=>RM(r,t))}const E0=/url\((['"]?)([^'"]+?)\1\)/g,IM=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,MM=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function qM(e){const t=e.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${t})(['"]?\\))`,"g")}function OM(e){const t=[];return e.replace(E0,(n,r,i)=>(t.push(i),n)),t.filter(n=>!Xl(n))}async function LM(e,t,n,r,i){try{const a=n?rM(t,n):t,o=Ud(t);let s;return i||(s=await Bd(a,o,r)),e.replace(qM(t),`$1${s}$3`)}catch{}return e}function PM(e,{preferredFontFormat:t}){return t?e.replace(MM,n=>{for(;;){const[r,,i]=IM.exec(n)||[];if(!i)return"";if(i===t)return`src: ${r};`}}):e}function S0(e){return e.search(E0)!==-1}async function C0(e,t,n){if(!S0(e))return e;const r=PM(e,n);return OM(r).reduce((a,o)=>a.then(s=>LM(s,o,t,n)),Promise.resolve(r))}async function Jn(e,t,n){var r;const i=(r=t.style)===null||r===void 0?void 0:r.getPropertyValue(e);if(i){const a=await C0(i,null,n);return t.style.setProperty(e,a,t.style.getPropertyPriority(e)),!0}return!1}async function DM(e,t){await Jn("background",e,t)||await Jn("background-image",e,t),await Jn("mask",e,t)||await Jn("-webkit-mask",e,t)||await Jn("mask-image",e,t)||await Jn("-webkit-mask-image",e,t)}async function jM(e,t){const n=vt(e,HTMLImageElement);if(!(n&&!Xl(e.src))&&!(vt(e,SVGImageElement)&&!Xl(e.href.baseVal)))return;const r=n?e.src:e.href.baseVal,i=await Bd(r,Ud(r),t);await new Promise((a,o)=>{e.onload=a,e.onerror=t.onImageErrorHandler?(...c)=>{try{a(t.onImageErrorHandler(...c))}catch(l){o(l)}}:o;const s=e;s.decode&&(s.decode=a),s.loading==="lazy"&&(s.loading="eager"),n?(e.srcset="",e.src=i):e.href.baseVal=i})}async function $M(e,t){const r=xn(e.childNodes).map(i=>N0(i,t));await Promise.all(r).then(()=>e)}async function N0(e,t){vt(e,Element)&&(await DM(e,t),await jM(e,t),await $M(e,t))}function zM(e,t){const{style:n}=e;t.backgroundColor&&(n.backgroundColor=t.backgroundColor),t.width&&(n.width=`${t.width}px`),t.height&&(n.height=`${t.height}px`);const r=t.style;return r!=null&&Object.keys(r).forEach(i=>{n[i]=r[i]}),e}const Qy={};async function Jy(e){let t=Qy[e];if(t!=null)return t;const r=await(await fetch(e)).text();return t={url:e,cssText:r},Qy[e]=t,t}async function ev(e,t){let n=e.cssText;const r=/url\(["']?([^"')]+)["']?\)/g,a=(n.match(/url\([^)]+\)/g)||[]).map(async o=>{let s=o.replace(r,"$1");return s.startsWith("https://")||(s=new URL(s,e.url).href),_0(s,t.fetchRequestInit,({result:c})=>(n=n.replace(o,`url(${c})`),[o,c]))});return Promise.all(a).then(()=>n)}function tv(e){if(e==null)return[];const t=[],n=/(\/\*[\s\S]*?\*\/)/gi;let r=e.replace(n,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const c=i.exec(r);if(c===null)break;t.push(c[0])}r=r.replace(i,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,o="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",s=new RegExp(o,"gi");for(;;){let c=a.exec(r);if(c===null){if(c=s.exec(r),c===null)break;a.lastIndex=s.lastIndex}else s.lastIndex=a.lastIndex;t.push(c[0])}return t}async function FM(e,t){const n=[],r=[];return e.forEach(i=>{if("cssRules"in i)try{xn(i.cssRules||[]).forEach((a,o)=>{if(a.type===CSSRule.IMPORT_RULE){let s=o+1;const c=a.href,l=Jy(c).then(u=>ev(u,t)).then(u=>tv(u).forEach(d=>{try{i.insertRule(d,d.startsWith("@import")?s+=1:i.cssRules.length)}catch(f){console.error("Error inserting rule from remote css",{rule:d,error:f})}})).catch(u=>{console.error("Error loading remote css",u.toString())});r.push(l)}})}catch(a){const o=e.find(s=>s.href==null)||document.styleSheets[0];i.href!=null&&r.push(Jy(i.href).then(s=>ev(s,t)).then(s=>tv(s).forEach(c=>{o.insertRule(c,o.cssRules.length)})).catch(s=>{console.error("Error loading remote stylesheet",s)})),console.error("Error inlining remote css file",a)}}),Promise.all(r).then(()=>(e.forEach(i=>{if("cssRules"in i)try{xn(i.cssRules||[]).forEach(a=>{n.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${i.href}`,a)}}),n))}function HM(e){return e.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>S0(t.style.getPropertyValue("src")))}async function UM(e,t){if(e.ownerDocument==null)throw new Error("Provided element is not within a Document");const n=xn(e.ownerDocument.styleSheets),r=await FM(n,t);return HM(r)}function A0(e){return e.trim().replace(/["']/g,"")}function BM(e){const t=new Set;function n(r){(r.style.fontFamily||getComputedStyle(r).fontFamily).split(",").forEach(a=>{t.add(A0(a))}),Array.from(r.children).forEach(a=>{a instanceof HTMLElement&&n(a)})}return n(e),t}async function GM(e,t){const n=await UM(e,t),r=BM(e);return(await Promise.all(n.filter(a=>r.has(A0(a.style.fontFamily))).map(a=>{const o=a.parentStyleSheet?a.parentStyleSheet.href:null;return C0(a.cssText,o,t)}))).join(`
`)}async function VM(e,t){const n=t.fontEmbedCSS!=null?t.fontEmbedCSS:t.skipFonts?null:await GM(e,t);if(n){const r=document.createElement("style"),i=document.createTextNode(n);r.appendChild(i),e.firstChild?e.insertBefore(r,e.firstChild):e.appendChild(r)}}async function KM(e,t={}){const{width:n,height:r}=x0(e,t),i=await da(e,t,!0);return await VM(i,t),await N0(i,t),zM(i,t),await lM(i,n,r)}async function WM(e,t={}){const{width:n,height:r}=x0(e,t),i=await KM(e,t),a=await Li(i),o=document.createElement("canvas"),s=o.getContext("2d"),c=t.pixelRatio||sM(),l=t.canvasWidth||n,u=t.canvasHeight||r;return o.width=l*c,o.height=u*c,t.skipAutoScale||cM(o),o.style.width=`${l}`,o.style.height=`${u}`,t.backgroundColor&&(s.fillStyle=t.backgroundColor,s.fillRect(0,0,o.width,o.height)),s.drawImage(a,0,0,o.width,o.height),o}async function YM(e,t={}){return(await WM(e,t)).toDataURL()}function XM(){return S.useCallback(async(e,t="lineage.png")=>{const r=e.querySelector(".react-flow__viewport")||e,i=await YM(r,{cacheBust:!0,backgroundColor:getComputedStyle(e).backgroundColor||"#0f0f0e",pixelRatio:2}),a=document.createElement("a");a.setAttribute("download",t),a.setAttribute("href",i),a.click()},[])}function ZM(e){const t=S.useRef(null),n=S.useCallback(async(i,a)=>{t.current?.abort();const o=new AbortController;t.current=o;const s=new URLSearchParams;s.set("profile",a.profile),a.database&&s.set("database",a.database);const c=V0();try{const l=await fetch(`/api/lineage/${encodeURI(i)}/suggest/stream?${s.toString()}`,{method:"GET",headers:c?{Authorization:`Bearer ${c}`}:{},signal:o.signal});if(!l.ok||!l.body){e.onError?.(`SSE stream failed (HTTP ${l.status})`);return}const u=l.body.getReader(),d=new TextDecoder;let f="";for(;;){const{value:h,done:g}=await u.read();if(g)break;f+=d.decode(h,{stream:!0});let m=f.indexOf(`

`);for(;m>=0;){const y=f.slice(0,m).trim();if(f=f.slice(m+2),m=f.indexOf(`

`),!y)continue;const v=y.split(`
`);let b="message",E="";for(const _ of v)_.startsWith("event:")?b=_.slice(6).trim():_.startsWith("data:")&&(E+=_.slice(5).trim());try{const _=E?JSON.parse(E):{};b==="edges-batch"?e.onBatch(_):b==="done"?e.onDone?.(_):b==="error"?e.onError?.(String(_.message||"stream error")):b==="warning"&&e.onWarning?.(String(_.message||""))}catch{}}}}catch(l){if(l.name==="AbortError")return;e.onError?.(l.message)}},[e]),r=S.useCallback(()=>{t.current?.abort()},[]);return{start:n,cancel:r}}/*! @license DOMPurify 3.4.5 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.5/LICENSE */function nv(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function QM(e){if(Array.isArray(e))return e}function JM(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(u){l=!0,i=u}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function eq(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function tq(e,t){return QM(e)||JM(e,t)||nq(e,t)||eq()}function nq(e,t){if(e){if(typeof e=="string")return nv(e,t);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?nv(e,t):void 0}}const T0=Object.entries,rv=Object.setPrototypeOf,rq=Object.isFrozen,iq=Object.getPrototypeOf,aq=Object.getOwnPropertyDescriptor;let ft=Object.freeze,Rt=Object.seal,ir=Object.create,k0=typeof Reflect<"u"&&Reflect,Zl=k0.apply,Ql=k0.construct;ft||(ft=function(t){return t});Rt||(Rt=function(t){return t});Zl||(Zl=function(t,n){for(var r=arguments.length,i=new Array(r>2?r-2:0),a=2;a<r;a++)i[a-2]=arguments[a];return t.apply(n,i)});Ql||(Ql=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return new t(...r)});const er=Ye(Array.prototype.forEach),oq=Ye(Array.prototype.lastIndexOf),iv=Ye(Array.prototype.pop),tr=Ye(Array.prototype.push),sq=Ye(Array.prototype.splice),dt=Array.isArray,$r=Ye(String.prototype.toLowerCase),bl=Ye(String.prototype.toString),av=Ye(String.prototype.match),nr=Ye(String.prototype.replace),ov=Ye(String.prototype.indexOf),cq=Ye(String.prototype.trim),uq=Ye(Number.prototype.toString),lq=Ye(Boolean.prototype.toString),sv=typeof BigInt>"u"?null:Ye(BigInt.prototype.toString),cv=typeof Symbol>"u"?null:Ye(Symbol.prototype.toString),Be=Ye(Object.prototype.hasOwnProperty),Tr=Ye(Object.prototype.toString),at=Ye(RegExp.prototype.test),gi=dq(TypeError);function Ye(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Zl(e,t,r)}}function dq(e){return function(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return Ql(e,n)}}function ge(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:$r;if(rv&&rv(e,null),!dt(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i=="string"){const a=n(i);a!==i&&(rq(t)||(t[r]=a),i=a)}e[i]=!0}return e}function fq(e){for(let t=0;t<e.length;t++)Be(e,t)||(e[t]=null);return e}function mt(e){const t=ir(null);for(const r of T0(e)){var n=tq(r,2);const i=n[0],a=n[1];Be(e,i)&&(dt(a)?t[i]=fq(a):a&&typeof a=="object"&&a.constructor===Object?t[i]=mt(a):t[i]=a)}return t}function hq(e){switch(typeof e){case"string":return e;case"number":return uq(e);case"boolean":return lq(e);case"bigint":return sv?sv(e):"0";case"symbol":return cv?cv(e):"Symbol()";case"undefined":return Tr(e);case"function":case"object":{if(e===null)return Tr(e);const t=e,n=Rn(t,"toString");if(typeof n=="function"){const r=n(t);return typeof r=="string"?r:Tr(r)}return Tr(e)}default:return Tr(e)}}function Rn(e,t){for(;e!==null;){const r=aq(e,t);if(r){if(r.get)return Ye(r.get);if(typeof r.value=="function")return Ye(r.value)}e=iq(e)}function n(){return null}return n}function pq(e){try{return at(e,""),!0}catch{return!1}}const uv=ft(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),xl=ft(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),_l=ft(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),gq=ft(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),wl=ft(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),mq=ft(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),lv=ft(["#text"]),dv=ft(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),El=ft(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),fv=ft(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),mi=ft(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),yq=Rt(/{{[\w\W]*|^[\w\W]*}}/g),vq=Rt(/<%[\w\W]*|^[\w\W]*%>/g),bq=Rt(/\${[\w\W]*/g),xq=Rt(/^data-[\-\w.\u00B7-\uFFFF]+$/),_q=Rt(/^aria-[\-\w]+$/),hv=Rt(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),wq=Rt(/^(?:\w+script|data):/i),Eq=Rt(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Sq=Rt(/^html$/i),Cq=Rt(/^[a-z][.\w]*(-[.\w]+)+$/i),rr={element:1,text:3,progressingInstruction:7,comment:8,document:9},Nq=function(){return typeof window>"u"?null:window},Aq=function(t,n){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let r=null;const i="data-tt-policy-suffix";n&&n.hasAttribute(i)&&(r=n.getAttribute(i));const a="dompurify"+(r?"#"+r:"");try{return t.createPolicy(a,{createHTML(o){return o},createScriptURL(o){return o}})}catch{return console.warn("TrustedTypes policy "+a+" could not be created."),null}},pv=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function R0(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Nq();const t=ne=>R0(ne);if(t.version="3.4.5",t.removed=[],!e||!e.document||e.document.nodeType!==rr.document||!e.Element)return t.isSupported=!1,t;let n=e.document;const r=n,i=r.currentScript,a=e.DocumentFragment,o=e.HTMLTemplateElement,s=e.Node,c=e.Element,l=e.NodeFilter,u=e.NamedNodeMap,d=u===void 0?e.NamedNodeMap||e.MozNamedAttrMap:u,f=e.HTMLFormElement,h=e.DOMParser,g=e.trustedTypes,m=c.prototype,y=Rn(m,"cloneNode"),v=Rn(m,"remove"),b=Rn(m,"nextSibling"),E=Rn(m,"childNodes"),_=Rn(m,"parentNode"),T=s&&s.prototype?Rn(s.prototype,"nodeType"):null;if(typeof o=="function"){const ne=n.createElement("template");ne.content&&ne.content.ownerDocument&&(n=ne.content.ownerDocument)}let N,q="";const L=n,O=L.implementation,R=L.createNodeIterator,I=L.createDocumentFragment,G=L.getElementsByTagName,H=r.importNode;let x=pv();t.isSupported=typeof T0=="function"&&typeof _=="function"&&O&&O.createHTMLDocument!==void 0;const M=yq,k=vq,z=bq,P=xq,C=_q,j=wq,$=Eq,U=Cq;let K=hv,V=null;const se=ge({},[...uv,...xl,..._l,...wl,...lv]);let re=null;const de=ge({},[...dv,...El,...fv,...mi]);let ie=Object.seal(ir(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),he=null,ue=null;const ve=Object.seal(ir(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let qe=!0,Oe=!0,Re=!1,te=!0,we=!1,ee=!0,W=!1,pe=!1,et=!1,je=!1,Ie=!1,xe=!1,Ce=!0,Le=!1;const Ge="user-content-";let ze=!0,Ne=!1,Fe={},Ve=null;const Ae=ge({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ze=null;const $e=ge({},["audio","video","img","source","image","track"]);let Ke=null;const qt=ge({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Qe="http://www.w3.org/1998/Math/MathML",ht="http://www.w3.org/2000/svg",st="http://www.w3.org/1999/xhtml";let Nt=st,Ot=!1,Kt=null;const Un=ge({},[Qe,ht,st],bl);let _t=ge({},["mi","mo","mn","ms","mtext"]),Wt=ge({},["annotation-xml"]);const Bn=ge({},["title","style","font","a","script"]);let Yt=null;const Gn=["application/xhtml+xml","text/html"],wr="text/html";let A=null,B=null;const J=n.createElement("form"),X=function(w){return w instanceof RegExp||w instanceof Function},Z=function(){let w=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(B&&B===w)return;(!w||typeof w!="object")&&(w={}),w=mt(w),Yt=Gn.indexOf(w.PARSER_MEDIA_TYPE)===-1?wr:w.PARSER_MEDIA_TYPE,A=Yt==="application/xhtml+xml"?bl:$r,V=Be(w,"ALLOWED_TAGS")&&dt(w.ALLOWED_TAGS)?ge({},w.ALLOWED_TAGS,A):se,re=Be(w,"ALLOWED_ATTR")&&dt(w.ALLOWED_ATTR)?ge({},w.ALLOWED_ATTR,A):de,Kt=Be(w,"ALLOWED_NAMESPACES")&&dt(w.ALLOWED_NAMESPACES)?ge({},w.ALLOWED_NAMESPACES,bl):Un,Ke=Be(w,"ADD_URI_SAFE_ATTR")&&dt(w.ADD_URI_SAFE_ATTR)?ge(mt(qt),w.ADD_URI_SAFE_ATTR,A):qt,Ze=Be(w,"ADD_DATA_URI_TAGS")&&dt(w.ADD_DATA_URI_TAGS)?ge(mt($e),w.ADD_DATA_URI_TAGS,A):$e,Ve=Be(w,"FORBID_CONTENTS")&&dt(w.FORBID_CONTENTS)?ge({},w.FORBID_CONTENTS,A):Ae,he=Be(w,"FORBID_TAGS")&&dt(w.FORBID_TAGS)?ge({},w.FORBID_TAGS,A):mt({}),ue=Be(w,"FORBID_ATTR")&&dt(w.FORBID_ATTR)?ge({},w.FORBID_ATTR,A):mt({}),Fe=Be(w,"USE_PROFILES")?w.USE_PROFILES&&typeof w.USE_PROFILES=="object"?mt(w.USE_PROFILES):w.USE_PROFILES:!1,qe=w.ALLOW_ARIA_ATTR!==!1,Oe=w.ALLOW_DATA_ATTR!==!1,Re=w.ALLOW_UNKNOWN_PROTOCOLS||!1,te=w.ALLOW_SELF_CLOSE_IN_ATTR!==!1,we=w.SAFE_FOR_TEMPLATES||!1,ee=w.SAFE_FOR_XML!==!1,W=w.WHOLE_DOCUMENT||!1,je=w.RETURN_DOM||!1,Ie=w.RETURN_DOM_FRAGMENT||!1,xe=w.RETURN_TRUSTED_TYPE||!1,et=w.FORCE_BODY||!1,Ce=w.SANITIZE_DOM!==!1,Le=w.SANITIZE_NAMED_PROPS||!1,ze=w.KEEP_CONTENT!==!1,Ne=w.IN_PLACE||!1,K=pq(w.ALLOWED_URI_REGEXP)?w.ALLOWED_URI_REGEXP:hv,Nt=typeof w.NAMESPACE=="string"?w.NAMESPACE:st,_t=Be(w,"MATHML_TEXT_INTEGRATION_POINTS")&&w.MATHML_TEXT_INTEGRATION_POINTS&&typeof w.MATHML_TEXT_INTEGRATION_POINTS=="object"?mt(w.MATHML_TEXT_INTEGRATION_POINTS):ge({},["mi","mo","mn","ms","mtext"]),Wt=Be(w,"HTML_INTEGRATION_POINTS")&&w.HTML_INTEGRATION_POINTS&&typeof w.HTML_INTEGRATION_POINTS=="object"?mt(w.HTML_INTEGRATION_POINTS):ge({},["annotation-xml"]);const F=Be(w,"CUSTOM_ELEMENT_HANDLING")&&w.CUSTOM_ELEMENT_HANDLING&&typeof w.CUSTOM_ELEMENT_HANDLING=="object"?mt(w.CUSTOM_ELEMENT_HANDLING):ir(null);if(ie=ir(null),Be(F,"tagNameCheck")&&X(F.tagNameCheck)&&(ie.tagNameCheck=F.tagNameCheck),Be(F,"attributeNameCheck")&&X(F.attributeNameCheck)&&(ie.attributeNameCheck=F.attributeNameCheck),Be(F,"allowCustomizedBuiltInElements")&&typeof F.allowCustomizedBuiltInElements=="boolean"&&(ie.allowCustomizedBuiltInElements=F.allowCustomizedBuiltInElements),we&&(Oe=!1),Ie&&(je=!0),Fe&&(V=ge({},lv),re=ir(null),Fe.html===!0&&(ge(V,uv),ge(re,dv)),Fe.svg===!0&&(ge(V,xl),ge(re,El),ge(re,mi)),Fe.svgFilters===!0&&(ge(V,_l),ge(re,El),ge(re,mi)),Fe.mathMl===!0&&(ge(V,wl),ge(re,fv),ge(re,mi))),ve.tagCheck=null,ve.attributeCheck=null,Be(w,"ADD_TAGS")&&(typeof w.ADD_TAGS=="function"?ve.tagCheck=w.ADD_TAGS:dt(w.ADD_TAGS)&&(V===se&&(V=mt(V)),ge(V,w.ADD_TAGS,A))),Be(w,"ADD_ATTR")&&(typeof w.ADD_ATTR=="function"?ve.attributeCheck=w.ADD_ATTR:dt(w.ADD_ATTR)&&(re===de&&(re=mt(re)),ge(re,w.ADD_ATTR,A))),Be(w,"ADD_URI_SAFE_ATTR")&&dt(w.ADD_URI_SAFE_ATTR)&&ge(Ke,w.ADD_URI_SAFE_ATTR,A),Be(w,"FORBID_CONTENTS")&&dt(w.FORBID_CONTENTS)&&(Ve===Ae&&(Ve=mt(Ve)),ge(Ve,w.FORBID_CONTENTS,A)),Be(w,"ADD_FORBID_CONTENTS")&&dt(w.ADD_FORBID_CONTENTS)&&(Ve===Ae&&(Ve=mt(Ve)),ge(Ve,w.ADD_FORBID_CONTENTS,A)),ze&&(V["#text"]=!0),W&&ge(V,["html","head","body"]),V.table&&(ge(V,["tbody"]),delete he.tbody),w.TRUSTED_TYPES_POLICY){if(typeof w.TRUSTED_TYPES_POLICY.createHTML!="function")throw gi('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof w.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw gi('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');N=w.TRUSTED_TYPES_POLICY,q=N.createHTML("")}else N===void 0&&(N=Aq(g,i)),N!==null&&typeof q=="string"&&(q=N.createHTML(""));ft&&ft(w),B=w},ae=ge({},[...xl,..._l,...gq]),_e=ge({},[...wl,...mq]),oe=function(w){let F=_(w);(!F||!F.tagName)&&(F={namespaceURI:Nt,tagName:"template"});const Q=$r(w.tagName),me=$r(F.tagName);return Kt[w.namespaceURI]?w.namespaceURI===ht?F.namespaceURI===st?Q==="svg":F.namespaceURI===Qe?Q==="svg"&&(me==="annotation-xml"||_t[me]):!!ae[Q]:w.namespaceURI===Qe?F.namespaceURI===st?Q==="math":F.namespaceURI===ht?Q==="math"&&Wt[me]:!!_e[Q]:w.namespaceURI===st?F.namespaceURI===ht&&!Wt[me]||F.namespaceURI===Qe&&!_t[me]?!1:!_e[Q]&&(Bn[Q]||!ae[Q]):!!(Yt==="application/xhtml+xml"&&Kt[w.namespaceURI]):!1},ce=function(w){tr(t.removed,{element:w});try{_(w).removeChild(w)}catch{v(w)}},Te=function(w,F){try{tr(t.removed,{attribute:F.getAttributeNode(w),from:F})}catch{tr(t.removed,{attribute:null,from:F})}if(F.removeAttribute(w),w==="is")if(je||Ie)try{ce(F)}catch{}else try{F.setAttribute(w,"")}catch{}},fe=function(w){let F=null,Q=null;if(et)w="<remove></remove>"+w;else{const Ue=av(w,/^[\r\n\t ]+/);Q=Ue&&Ue[0]}Yt==="application/xhtml+xml"&&Nt===st&&(w='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+w+"</body></html>");const me=N?N.createHTML(w):w;if(Nt===st)try{F=new h().parseFromString(me,Yt)}catch{}if(!F||!F.documentElement){F=O.createDocument(Nt,"template",null);try{F.documentElement.innerHTML=Ot?q:me}catch{}}const He=F.body||F.documentElement;return w&&Q&&He.insertBefore(n.createTextNode(Q),He.childNodes[0]||null),Nt===st?G.call(F,W?"html":"body")[0]:W?F.documentElement:He},it=function(w){return R.call(w.ownerDocument||w,w,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},pt=function(w){w.normalize();const F=R.call(w.ownerDocument||w,w,l.SHOW_TEXT|l.SHOW_COMMENT|l.SHOW_CDATA_SECTION|l.SHOW_PROCESSING_INSTRUCTION,null);let Q=F.nextNode();for(;Q;){let me=Q.data;er([M,k,z],He=>{me=nr(me,He," ")}),Q.data=me,Q=F.nextNode()}},gt=function(w){return w instanceof f&&(typeof w.nodeName!="string"||typeof w.textContent!="string"||typeof w.removeChild!="function"||!(w.attributes instanceof d)||typeof w.removeAttribute!="function"||typeof w.setAttribute!="function"||typeof w.namespaceURI!="string"||typeof w.insertBefore!="function"||typeof w.hasChildNodes!="function")},ke=function(w){if(!T||typeof w!="object"||w===null)return!1;try{return typeof T(w)=="number"}catch{return!1}};function tt(ne,w,F){er(ne,Q=>{Q.call(t,w,F,B)})}const lt=function(w){let F=null;if(tt(x.beforeSanitizeElements,w,null),gt(w))return ce(w),!0;const Q=A(w.nodeName);if(tt(x.uponSanitizeElement,w,{tagName:Q,allowedTags:V}),ee&&w.hasChildNodes()&&!ke(w.firstElementChild)&&at(/<[/\w!]/g,w.innerHTML)&&at(/<[/\w!]/g,w.textContent)||ee&&w.namespaceURI===st&&Q==="style"&&ke(w.firstElementChild)||w.nodeType===rr.progressingInstruction||ee&&w.nodeType===rr.comment&&at(/<[/\w]/g,w.data))return ce(w),!0;if(he[Q]||!(ve.tagCheck instanceof Function&&ve.tagCheck(Q))&&!V[Q]){if(!he[Q]&&Cn(Q)&&(ie.tagNameCheck instanceof RegExp&&at(ie.tagNameCheck,Q)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(Q)))return!1;if(ze&&!Ve[Q]){const me=_(w)||w.parentNode,He=E(w)||w.childNodes;if(He&&me){const Ue=He.length;for(let ct=Ue-1;ct>=0;--ct){const At=y(He[ct],!0);me.insertBefore(At,b(w))}}}return ce(w),!0}return w instanceof c&&!oe(w)||(Q==="noscript"||Q==="noembed"||Q==="noframes")&&at(/<\/no(script|embed|frames)/i,w.innerHTML)?(ce(w),!0):(we&&w.nodeType===rr.text&&(F=w.textContent,er([M,k,z],me=>{F=nr(F,me," ")}),w.textContent!==F&&(tr(t.removed,{element:w.cloneNode()}),w.textContent=F)),tt(x.afterSanitizeElements,w,null),!1)},Ft=function(w,F,Q){if(ue[F]||Ce&&(F==="id"||F==="name")&&(Q in n||Q in J))return!1;const me=re[F]||ve.attributeCheck instanceof Function&&ve.attributeCheck(F,w);if(!(Oe&&!ue[F]&&at(P,F))){if(!(qe&&at(C,F))){if(!me||ue[F]){if(!(Cn(w)&&(ie.tagNameCheck instanceof RegExp&&at(ie.tagNameCheck,w)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(w))&&(ie.attributeNameCheck instanceof RegExp&&at(ie.attributeNameCheck,F)||ie.attributeNameCheck instanceof Function&&ie.attributeNameCheck(F,w))||F==="is"&&ie.allowCustomizedBuiltInElements&&(ie.tagNameCheck instanceof RegExp&&at(ie.tagNameCheck,Q)||ie.tagNameCheck instanceof Function&&ie.tagNameCheck(Q))))return!1}else if(!Ke[F]){if(!at(K,nr(Q,$,""))){if(!((F==="src"||F==="xlink:href"||F==="href")&&w!=="script"&&ov(Q,"data:")===0&&Ze[w])){if(!(Re&&!at(j,nr(Q,$,"")))){if(Q)return!1}}}}}}return!0},Vn=ge({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Cn=function(w){return!Vn[$r(w)]&&at(U,w)},Nn=function(w){tt(x.beforeSanitizeAttributes,w,null);const F=w.attributes;if(!F||gt(w))return;const Q={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:re,forceKeepAttr:void 0};let me=F.length;for(;me--;){const He=F[me],Ue=He.name,ct=He.namespaceURI,At=He.value,Zt=A(Ue),ha=At;let nt=Ue==="value"?ha:cq(ha);if(Q.attrName=Zt,Q.attrValue=nt,Q.keepAttr=!0,Q.forceKeepAttr=void 0,tt(x.uponSanitizeAttribute,w,Q),nt=Q.attrValue,Le&&(Zt==="id"||Zt==="name")&&ov(nt,Ge)!==0&&(Te(Ue,w),nt=Ge+nt),ee&&at(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,nt)){Te(Ue,w);continue}if(Zt==="attributename"&&av(nt,"href")){Te(Ue,w);continue}if(Q.forceKeepAttr)continue;if(!Q.keepAttr){Te(Ue,w);continue}if(!te&&at(/\/>/i,nt)){Te(Ue,w);continue}we&&er([M,k,z],Wd=>{nt=nr(nt,Wd," ")});const Kd=A(w.nodeName);if(!Ft(Kd,Zt,nt)){Te(Ue,w);continue}if(N&&typeof g=="object"&&typeof g.getAttributeType=="function"&&!ct)switch(g.getAttributeType(Kd,Zt)){case"TrustedHTML":{nt=N.createHTML(nt);break}case"TrustedScriptURL":{nt=N.createScriptURL(nt);break}}if(nt!==ha)try{ct?w.setAttributeNS(ct,Ue,nt):w.setAttribute(Ue,nt),gt(w)?ce(w):iv(t.removed)}catch{Te(Ue,w)}}tt(x.afterSanitizeAttributes,w,null)},An=function(w){let F=null;const Q=it(w);for(tt(x.beforeSanitizeShadowDOM,w,null);F=Q.nextNode();)tt(x.uponSanitizeShadowNode,F,null),lt(F),Nn(F),F.content instanceof a&&An(F.content);tt(x.afterSanitizeShadowDOM,w,null)},Xt=function(w){if(w.nodeType===rr.element&&w.shadowRoot instanceof a){const me=w.shadowRoot;Xt(me),An(me)}const F=w.childNodes;if(!F)return;const Q=[];er(F,me=>{tr(Q,me)});for(const me of Q)Xt(me)};return t.sanitize=function(ne){let w=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},F=null,Q=null,me=null,He=null;if(Ot=!ne,Ot&&(ne="<!-->"),typeof ne!="string"&&!ke(ne)&&(ne=hq(ne),typeof ne!="string"))throw gi("dirty is not a string, aborting");if(!t.isSupported)return ne;if(pe||Z(w),t.removed=[],typeof ne=="string"&&(Ne=!1),Ne){const At=ne.nodeName;if(typeof At=="string"){const Zt=A(At);if(!V[Zt]||he[Zt])throw gi("root node is forbidden and cannot be sanitized in-place")}Xt(ne)}else if(ke(ne))F=fe("<!---->"),Q=F.ownerDocument.importNode(ne,!0),Q.nodeType===rr.element&&Q.nodeName==="BODY"||Q.nodeName==="HTML"?F=Q:F.appendChild(Q),Xt(Q);else{if(!je&&!we&&!W&&ne.indexOf("<")===-1)return N&&xe?N.createHTML(ne):ne;if(F=fe(ne),!F)return je?null:xe?q:""}F&&et&&ce(F.firstChild);const Ue=it(Ne?ne:F);for(;me=Ue.nextNode();)lt(me),Nn(me),me.content instanceof a&&An(me.content);if(Ne)return we&&pt(ne),ne;if(je){if(we&&pt(F),Ie)for(He=I.call(F.ownerDocument);F.firstChild;)He.appendChild(F.firstChild);else He=F;return(re.shadowroot||re.shadowrootmode)&&(He=H.call(r,He,!0)),He}let ct=W?F.outerHTML:F.innerHTML;return W&&V["!doctype"]&&F.ownerDocument&&F.ownerDocument.doctype&&F.ownerDocument.doctype.name&&at(Sq,F.ownerDocument.doctype.name)&&(ct="<!DOCTYPE "+F.ownerDocument.doctype.name+`>
`+ct),we&&er([M,k,z],At=>{ct=nr(ct,At," ")}),N&&xe?N.createHTML(ct):ct},t.setConfig=function(){let ne=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Z(ne),pe=!0},t.clearConfig=function(){B=null,pe=!1},t.isValidAttribute=function(ne,w,F){B||Z({});const Q=A(ne),me=A(w);return Ft(Q,me,F)},t.addHook=function(ne,w){typeof w=="function"&&tr(x[ne],w)},t.removeHook=function(ne,w){if(w!==void 0){const F=oq(x[ne],w);return F===-1?void 0:sq(x[ne],F,1)[0]}return iv(x[ne])},t.removeHooks=function(ne){x[ne]=[]},t.removeAllHooks=function(){x=pv()},t}var Tq=R0();const kq=[{label:"S",px:12},{label:"M",px:15},{label:"L",px:20},{label:"XL",px:28}],Rq=["rgb(245,244,242)","#fbbf24","#34d399","#60a5fa","#f472b6","#a78bfa","#f87171","#94a3b8"];function Iq({visible:e,editorRef:t,onChange:n,onDelete:r}){const[i,a]=S.useState(!1),[o,s]=S.useState(!1);function c(h){const g=t.current;g&&(g.focus(),h(),n())}function l(){c(()=>document.execCommand("bold"))}function u(){c(()=>document.execCommand("insertUnorderedList"))}function d(h){c(()=>document.execCommand("foreColor",!1,h)),s(!1)}function f(h){c(()=>{const g=window.getSelection();if(!g||g.rangeCount===0||g.isCollapsed){t.current&&(t.current.style.fontSize=`${h}px`);return}const m=g.getRangeAt(0),y=document.createElement("span");y.style.fontSize=`${h}px`;try{y.appendChild(m.extractContents()),m.insertNode(y),g.removeAllRanges();const v=document.createRange();v.selectNodeContents(y),g.addRange(v)}catch{}}),a(!1)}return p.jsx(ex,{isVisible:e,position:Y.Top,offset:8,children:p.jsxs("div",{className:"flex items-center gap-0.5 rounded-md border border-surface-border bg-surface-raised px-1 py-0.5 shadow-lg",children:[p.jsxs("button",{type:"button",title:"Font size",onMouseDown:h=>h.preventDefault(),onClick:()=>{a(h=>!h),s(!1)},className:"inline-flex h-6 items-center gap-0.5 rounded px-1.5 text-[11px] text-fg-muted hover:bg-surface hover:text-ink",children:[p.jsx(Iv,{size:12}),p.jsx("span",{children:"Size"})]}),i&&p.jsx("div",{className:"absolute left-1 top-7 z-20 flex gap-0.5 rounded-md border border-surface-border bg-surface-raised p-1 shadow-xl",children:kq.map(h=>p.jsx("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>f(h.px),className:"rounded px-1.5 py-0.5 text-[11px] text-fg-muted hover:bg-surface hover:text-ink",style:{fontSize:`${Math.min(h.px,14)}px`},children:h.label},h.label))}),p.jsx("button",{type:"button",title:"Bold (⌘B)",onMouseDown:h=>h.preventDefault(),onClick:l,className:"inline-flex h-6 w-6 items-center justify-center rounded text-fg-muted hover:bg-surface hover:text-ink",children:p.jsx(Q0,{size:12})}),p.jsx("button",{type:"button",title:"Color",onMouseDown:h=>h.preventDefault(),onClick:()=>{s(h=>!h),a(!1)},className:"inline-flex h-6 w-6 items-center justify-center rounded text-fg-muted hover:bg-surface hover:text-ink",children:p.jsx("span",{className:"block h-3 w-3 rounded-sm border border-white/30",style:{background:"linear-gradient(135deg,#60a5fa,#f472b6,#fbbf24)"}})}),o&&p.jsx("div",{className:Pe("absolute left-12 top-7 z-20 flex gap-0.5 rounded-md border","border-surface-border bg-surface-raised p-1 shadow-xl"),children:Rq.map(h=>p.jsx("button",{type:"button",onMouseDown:g=>g.preventDefault(),onClick:()=>d(h),className:"h-4 w-4 rounded-full border border-white/30 transition hover:scale-110",style:{background:h}},h))}),p.jsx("button",{type:"button",title:"Bullet list",onMouseDown:h=>h.preventDefault(),onClick:u,className:"inline-flex h-6 w-6 items-center justify-center rounded text-fg-muted hover:bg-surface hover:text-ink",children:p.jsx(J0,{size:12})}),p.jsx("span",{className:"mx-1 h-4 w-px bg-surface-border"}),p.jsx("button",{type:"button",title:"Delete (Backspace)",onMouseDown:h=>h.preventDefault(),onClick:r,className:"inline-flex h-6 w-6 items-center justify-center rounded text-fg-muted hover:bg-critical-soft hover:text-critical",children:p.jsx(Yr,{size:12})})]})})}const Mq=["amber","rose","emerald","sky","violet","slate"],qq={ALLOWED_TAGS:["b","strong","i","em","u","br","div","span","ul","li","p"],ALLOWED_ATTR:["style"]};function gv(e){return String(Tq.sanitize(e||"",qq))}function Oq({id:e,data:t,selected:n}){const r=jt(),[i,a]=S.useState(!1),[o,s]=S.useState(t.color||"amber"),[c,l]=S.useState(t.text||""),u=Ea[o]??Ea.amber,d=t.style||"note",f=S.useRef(null),h=S.useRef(gv(t.text||""));S.useEffect(()=>{d==="text"&&f.current&&h.current&&(f.current.innerHTML=h.current)},[]);const g=S.useCallback(()=>{const b=gv(f.current?.innerHTML||"");r.setNodes(E=>E.map(_=>_.id===e?{..._,data:{..._.data,text:b}}:_))},[e,r]),m=S.useCallback(b=>{l(b),r.setNodes(E=>E.map(_=>_.id===e?{..._,data:{..._.data,text:b}}:_))},[e,r]);function y(b){s(b),a(!1),r.setNodes(E=>E.map(_=>_.id===e?{..._,data:{..._.data,color:b}}:_))}const v=S.useCallback(()=>{r.deleteElements({nodes:[{id:e}]})},[e,r]);return d==="text"?p.jsxs("div",{className:Pe("lcv-text-node group relative h-full w-full rounded-md",n?"ring-1 ring-accent-default/70 ring-offset-1 ring-offset-bg":"ring-1 ring-transparent"),style:{minWidth:100,minHeight:36},children:[p.jsx(Fl,{isVisible:n,minWidth:100,minHeight:36,lineStyle:{borderColor:"rgb(var(--accent))"}}),p.jsx(Iq,{visible:!!n,editorRef:f,onChange:g,onDelete:v}),p.jsxs("div",{className:Pe("lcv-text-topbar pointer-events-none absolute inset-x-0 top-0","flex h-4 items-center justify-between px-1","opacity-0 transition-opacity duration-150","group-hover:opacity-100",n&&"opacity-100"),children:[p.jsx("span",{className:"lcv-comment-grip pointer-events-auto inline-flex h-4 cursor-grab items-center text-fg-muted hover:text-ink",title:"Drag to move",children:p.jsx(m_,{size:10})}),p.jsx("button",{type:"button",onMouseDown:b=>b.preventDefault(),onClick:v,className:"nodrag pointer-events-auto inline-flex h-4 w-4 items-center justify-center rounded text-fg-muted hover:bg-critical-soft hover:text-critical",title:"Delete (Backspace)",children:p.jsx(Wr,{size:11})})]}),p.jsx("div",{ref:f,contentEditable:!0,suppressContentEditableWarning:!0,spellCheck:!1,onInput:g,"data-placeholder":"Text…",className:Pe("lcv-text-editor nodrag nowheel","block min-h-[28px] w-full cursor-text bg-transparent px-2 pb-1 pt-3 leading-snug text-ink outline-none","text-[15px] font-medium"),style:{whiteSpace:"pre-wrap",overflowWrap:"anywhere",wordBreak:"break-word"}})]}):p.jsxs("div",{className:Pe("relative h-full w-full overflow-hidden rounded-lg shadow-xl",n?"ring-2 ring-accent-default":""),style:{background:u.bg,border:`2px solid ${u.border}`},children:[p.jsx(Fl,{isVisible:n,minWidth:140,minHeight:100,lineStyle:{borderColor:u.border}}),p.jsxs("div",{className:"lcv-comment-grip flex h-6 items-center justify-between border-b border-white/10 bg-white/5 px-2 text-[10px] text-ink-muted",children:[p.jsx("span",{className:"cursor-grab select-none uppercase tracking-wide",children:"note"}),p.jsx("button",{type:"button","aria-label":"Change color",className:"nodrag h-3.5 w-3.5 rounded-full border border-white/30",style:{background:u.border},onClick:b=>{b.stopPropagation(),a(E=>!E)}})]}),i&&p.jsx("div",{className:"nodrag absolute right-1 top-7 z-10 flex gap-1 rounded border border-surface-border bg-surface-raised p-1 shadow-lg",onClick:b=>b.stopPropagation(),children:Mq.map(b=>{const E=Ea[b];return p.jsx("button",{type:"button",title:b,onClick:()=>y(b),className:"h-4 w-4 rounded-full border border-white/30 transition hover:scale-110",style:{background:E.border}},b)})}),p.jsx("textarea",{value:c,onChange:b=>m(b.target.value),spellCheck:!1,placeholder:"Note…",className:"nodrag nowheel absolute inset-x-0 bottom-0 top-6 w-full resize-none border-0 bg-transparent px-2 py-1.5 text-[12px] leading-snug text-ink outline-none placeholder:text-ink-dim"})]})}const Lq=S.memo(Oq),Gd=["lineage-canvas-logos"];function I0(){return Dn({queryKey:Gd,queryFn:()=>En("/api/lineage/logos"),staleTime:6e4})}function Pq(){const e=gr();return Pi({mutationFn:t=>En("/api/lineage/logos",{method:"POST",body:JSON.stringify(t)}),onSuccess:()=>{e.invalidateQueries({queryKey:Gd})}})}function Dq(){const e=gr();return Pi({mutationFn:async t=>{const n=await fetch(`/api/lineage/logos/${t}`,{method:"DELETE"});if(!n.ok){const r=await n.text();throw new Error(r||`delete failed (${n.status})`)}},onSuccess:()=>{e.invalidateQueries({queryKey:Gd})}})}function M0(){const e=I0();return S.useMemo(()=>{const t=new Map;for(const n of e.data?.logos??[]){const r=t.get(n.key);(!r||n.source==="custom"&&r.source!=="custom")&&t.set(n.key,n)}return t},[e.data])}function Vd(e){return e&&(e.data_url||e.url)||""}function jq({logoKey:e,onClick:t}){const n=M0(),r=e?n.get(e):void 0,i=Vd(r);return p.jsx("button",{type:"button",onClick:a=>{a.stopPropagation(),t()},className:"nodrag flex h-5 w-5 items-center justify-center rounded border border-transparent text-fg-muted transition hover:border-surface-border hover:bg-surface",title:r?`Logo: ${r.label}`:"Set logo badge",children:i?p.jsx("img",{src:i,alt:r?.label||e||"",className:"h-4 w-4 object-contain",draggable:!1}):p.jsx(Rv,{size:11})})}const $q=[{key:"all",label:"All"},{key:"cloud",label:"Cloud"},{key:"warehouse",label:"Warehouse"},{key:"bi",label:"BI"},{key:"tooling",label:"Tooling"},{key:"custom",label:"Custom"}],zq=200*1024,Fq=new Set(["image/svg+xml","image/png","image/jpeg","image/jpg","image/webp"]);function mv(e){return e.toLowerCase().trim().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40)}function q0({open:e,onClose:t,onPick:n,title:r,onClear:i}){const a=I0(),o=Pq(),s=Dq(),c=td(),[l,u]=S.useState("all"),[d,f]=S.useState(!1),[h,g]=S.useState(""),[m,y]=S.useState(""),[v,b]=S.useState(""),[E,_]=S.useState("");S.useEffect(()=>{e||(u("all"),f(!1),g(""),y(""),b(""),_(""))},[e]);const T=a.data?.logos??[],N=S.useMemo(()=>l==="all"?T:T.filter(R=>R.category===l),[T,l]);async function q(R){if(!Fq.has(R.type)){c.push({title:"Unsupported file type",description:`Allowed: SVG, PNG, JPG, WebP. Got ${R.type||"unknown"}.`,tone:"error"});return}if(R.size>zq){c.push({title:"File too large",description:`${Math.round(R.size/1024)} KB exceeds 200 KB limit.`,tone:"error"});return}const I=new FileReader;I.onload=()=>{_(String(I.result||"")),h||g(R.name.replace(/\.[^.]+$/,""))},I.readAsDataURL(R)}async function L(){const R=m||mv(h);if(!R||!h){c.push({title:"Need label + key",tone:"warning"});return}if(!E&&!v){c.push({title:"Upload a file or paste a URL",tone:"warning"});return}try{const I=await o.mutateAsync({key:R,label:h,category:"custom",data_url:E||void 0,url:v||void 0});c.push({title:"Custom logo added",tone:"success"}),f(!1),n(I),t()}catch(I){c.push({title:"Add failed",description:I.message,tone:"error"})}}async function O(R){if(R.source==="custom"&&window.confirm(`Delete custom logo "${R.label}"?`))try{await s.mutateAsync(R.id),c.push({title:"Deleted",tone:"success"})}catch(I){c.push({title:"Delete failed",description:I.message,tone:"error"})}}return p.jsx(ar,{open:e,onClose:t,size:"md",title:p.jsx("span",{children:r||"Pick a logo"}),description:"Choose from the default library or upload your own (SVG / PNG / JPG / WebP, max 200 KB).",children:p.jsxs("div",{className:"space-y-3 text-sm",children:[p.jsxs("div",{className:"flex flex-wrap items-center gap-1 border-b border-surface-border pb-2",children:[$q.map(R=>p.jsx("button",{type:"button",onClick:()=>u(R.key),className:"rounded px-2 py-1 text-[12px] "+(l===R.key?"bg-accent-soft text-accent-ink":"text-fg-muted hover:bg-surface"),children:R.label},R.key)),p.jsxs("button",{type:"button",onClick:()=>f(R=>!R),className:"ml-auto inline-flex items-center gap-1 rounded border border-surface-border bg-surface px-2 py-1 text-[12px] text-ink hover:bg-surface-raised",children:[p.jsx(Sl,{size:11}),"Add custom"]})]}),d&&p.jsxs("div",{className:"space-y-2 rounded-md border border-surface-border bg-surface p-2",children:[p.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[p.jsx("input",{value:h,onChange:R=>g(R.target.value),placeholder:"Label (e.g. My Co)",className:"rounded border border-surface-border bg-surface-raised px-2 py-1 text-[12px]"}),p.jsx("input",{value:m,onChange:R=>y(mv(R.target.value)),placeholder:"Key (auto from label)",className:"rounded border border-surface-border bg-surface-raised px-2 py-1 font-mono text-[12px]"})]}),p.jsx("input",{value:v,onChange:R=>b(R.target.value),placeholder:"… or paste a public URL",className:"block w-full rounded border border-surface-border bg-surface-raised px-2 py-1 text-[12px]"}),p.jsxs("label",{className:"flex items-center justify-between rounded border border-dashed border-surface-border bg-surface-raised px-2 py-2 text-[12px] text-fg-muted",children:[p.jsx("span",{children:E?"File loaded — ready to add":"Click to choose file"}),p.jsx("input",{type:"file",hidden:!0,accept:"image/svg+xml,image/png,image/jpeg,image/webp",onChange:R=>{const I=R.target.files?.[0];I&&q(I)}}),p.jsx(Sl,{size:12})]}),p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx(Et,{variant:"secondary",size:"sm",onClick:()=>f(!1),children:"Cancel"}),p.jsx(Et,{variant:"primary",size:"sm",loading:o.isPending,onClick:L,children:"Add"})]})]}),p.jsx("div",{className:"grid gap-2 overflow-y-auto",style:{maxHeight:320,gridTemplateColumns:"repeat(auto-fill, minmax(96px, 1fr))"},children:a.isLoading?p.jsx("div",{className:"col-span-full p-4 text-center text-xs text-fg-muted",children:"Loading…"}):N.length===0?p.jsx("div",{className:"col-span-full p-4 text-center text-xs text-fg-muted",children:"No logos in this category."}):N.map(R=>p.jsxs("button",{type:"button",onClick:()=>{n(R),t()},className:"group relative flex flex-col items-center gap-1 rounded-md border border-surface-border bg-surface p-2 hover:border-accent-default",title:R.label,children:[p.jsx("img",{src:Vd(R),alt:R.label,className:"h-12 w-12 object-contain",draggable:!1}),p.jsx("span",{className:"w-full truncate text-center text-[10px] text-fg-muted",children:R.label}),R.source==="custom"&&p.jsx("span",{role:"button",tabIndex:0,onClick:I=>{I.stopPropagation(),O(R)},onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),O(R))},className:"absolute right-1 top-1 rounded p-0.5 text-fg-muted opacity-0 transition group-hover:opacity-100 hover:bg-critical-soft hover:text-critical","aria-label":"Delete custom logo",children:p.jsx(Yr,{size:10})})]},R.id))}),i&&p.jsx("div",{className:"flex justify-end border-t border-surface-border pt-2",children:p.jsx(Et,{variant:"secondary",size:"sm",leadingIcon:p.jsx(Wr,{size:12}),onClick:()=>{i(),t()},children:"Remove logo"})})]})})}function fa({nodeId:e,visible:t}){const n=jt();return p.jsx(ex,{isVisible:t,position:Y.Top,offset:6,children:p.jsx("button",{type:"button",onMouseDown:r=>r.preventDefault(),onClick:r=>{r.stopPropagation(),n.deleteElements({nodes:[{id:e}]})},title:"Delete (Backspace)",className:"inline-flex h-6 w-6 items-center justify-center rounded-md border border-surface-border bg-surface-raised text-fg-muted shadow-lg transition hover:bg-critical-soft hover:text-critical",children:p.jsx(Yr,{size:12})})})}function Hq({name:e,dtype:t,isPrimary:n,isForeign:r,traced:i}){const a=nx(t),o=Bl[a];return p.jsxs("div",{className:Pe("lcv-col-row",i&&"bg-accent-soft text-accent-ink"),style:{position:"relative"},children:[p.jsx(ut,{type:"target",position:Y.Left,id:e,className:"lcv-handle",style:{background:o,left:-5}}),p.jsx("span",{className:"lcv-type-badge",style:{background:o},title:t||"unknown",children:WN(t)}),p.jsxs("span",{className:"flex-1 truncate font-mono text-[12px]",children:[e,n&&p.jsx("span",{className:"ml-1 text-[9px] uppercase tracking-wide text-amber-300",children:"pk"}),r&&p.jsx("span",{className:"ml-1 text-[9px] uppercase tracking-wide text-sky-300",children:"fk"})]}),p.jsx(ut,{type:"source",position:Y.Right,id:e,className:"lcv-handle",style:{background:o,right:-5}})]})}function yv({columns:e}){return p.jsx("div",{"aria-hidden":!0,style:{position:"absolute",left:0,right:0,top:28,height:0,overflow:"hidden",visibility:"hidden"},children:e.map(t=>p.jsxs("div",{className:"lcv-col-row",style:{position:"relative"},children:[p.jsx(ut,{type:"target",position:Y.Left,id:t.name,className:"lcv-handle",style:{left:-5}}),p.jsx(ut,{type:"source",position:Y.Right,id:t.name,className:"lcv-handle",style:{right:-5}})]},t.name))})}const Uq=8;function Bq({id:e,data:t,selected:n}){const r=jt(),i=S.useMemo(()=>t.columns||[],[t.columns]),a=t.schema?`${t.schema}.${t.table}`:t.table,o=!!t.expanded,s=g=>{r.setNodes(m=>m.map(y=>y.id===e?{...y,data:{...y.data,expanded:g}}:y))};S.useEffect(()=>{t.forceExpandTick&&!t.expanded&&s(!0)},[t.forceExpandTick]);const[c,l]=S.useState(""),[u,d]=S.useState(!1);function f(g){r.setNodes(m=>m.map(y=>y.id===e?{...y,data:{...y.data,logoKey:g}}:y))}const h=S.useMemo(()=>{const g=c.trim().toLowerCase();return g?i.filter(m=>m.name.toLowerCase().includes(g)):i},[i,c]);return p.jsxs("div",{className:Pe("rounded-lg border bg-surface-raised text-ink shadow-lg","transition-shadow duration-150",n?"border-accent-default shadow-accent-soft/40":t.isAnchor?"border-amber-400/70":"border-surface-border"),style:{minWidth:260,maxWidth:340},children:[p.jsxs("div",{className:"flex items-center gap-2 border-b border-surface-border px-3 py-2",children:[p.jsx("button",{type:"button","aria-label":o?"Collapse columns":"Expand columns",onClick:g=>{g.stopPropagation(),s(!o)},className:"nodrag flex h-4 w-4 items-center justify-center rounded text-fg-muted hover:text-ink",children:o?p.jsx(Di,{size:12}):p.jsx(Jl,{size:12})}),p.jsx(jq,{logoKey:t.logoKey,onClick:()=>d(!0)}),t.isAnchor&&p.jsx(k_,{size:12,className:"text-amber-300",fill:"currentColor"}),p.jsx("span",{className:"flex-1 truncate text-[13px] font-semibold",title:t.fqn,children:a}),i.length>0&&p.jsx("span",{className:"rounded bg-surface px-1.5 py-0.5 font-mono text-[10px] text-fg-muted",title:`${i.length} columns`,children:i.length}),t.showProfileChip&&t.profile&&p.jsx("span",{title:t.profile,className:"rounded bg-surface px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-fg-muted",children:t.profile.slice(0,10)})]}),i.length===0?p.jsxs(p.Fragment,{children:[p.jsx(ut,{type:"target",position:Y.Left,id:"__table__",className:"lcv-handle",style:{background:Bl.unknown,top:"50%"}}),p.jsx("div",{className:"px-3 py-3 text-[11px] text-fg-muted",children:"(no columns cached)"}),p.jsx(ut,{type:"source",position:Y.Right,id:"__table__",className:"lcv-handle",style:{background:Bl.unknown,top:"50%"}})]}):o?p.jsxs(p.Fragment,{children:[i.length>=Uq&&p.jsxs("div",{className:"nodrag relative border-b border-surface-border px-2 py-1",children:[p.jsx(ed,{size:11,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-fg-muted"}),p.jsx("input",{value:c,onChange:g=>l(g.target.value),placeholder:"filter columns…",className:"block w-full rounded bg-transparent pl-5 pr-1 py-0.5 text-[11.5px] outline-none placeholder:text-fg-muted"}),p.jsxs("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 font-mono text-[10px] text-fg-muted",children:[h.length,"/",i.length]})]}),p.jsxs("div",{className:"nowheel py-1",style:{maxHeight:400,overflowY:"auto"},children:[h.length===0?p.jsx("div",{className:"px-3 py-2 text-[11px] text-fg-muted",children:"No matching columns."}):h.map(g=>p.jsx(Hq,{name:g.name,dtype:g.dtype,isPrimary:g.isPrimary,isForeign:g.isForeign,traced:t.tracedColumn===g.name},g.name)),c.trim()&&p.jsx(yv,{columns:i.filter(g=>!h.some(m=>m.name===g.name))})]})]}):p.jsxs(p.Fragment,{children:[p.jsx(yv,{columns:i}),p.jsxs("button",{type:"button",onClick:g=>{g.stopPropagation(),s(!0)},className:"nodrag block w-full px-3 py-1.5 text-left text-[11px] text-fg-muted hover:bg-surface",children:["+ show ",i.length," column",i.length===1?"":"s"]})]}),p.jsx(q0,{open:u,onClose:()=>d(!1),onPick:g=>f(g.key),onClear:t.logoKey?()=>f(""):void 0,title:"Pick header logo"}),p.jsx(fa,{nodeId:e,visible:!!n})]})}const Gq=S.memo(Bq);function Vq(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/(@[A-Za-z_][A-Za-z0-9_]*)/g,"<mark>$1</mark>")}function Kq({value:e,onChange:t,columns:n,placeholder:r,rows:i=3}){const a=S.useRef(null),o=S.useRef(null),[s,c]=S.useState(!1),[l,u]=S.useState(""),[d,f]=S.useState(0),h=S.useMemo(()=>{const b=l.toLowerCase();return b?n.filter(E=>E.toLowerCase().includes(b)).slice(0,10):n.slice(0,10)},[n,l]);S.useEffect(()=>{f(0)},[s,h.length]);function g(b){o.current&&(o.current.scrollTop=b.target.scrollTop,o.current.scrollLeft=b.target.scrollLeft)}function m(b){const E=b.target.value;t(E);const _=b.target.selectionStart||0,T=E.slice(0,_),N=T.lastIndexOf("@");N>=0&&/^@[A-Za-z0-9_]*$/.test(T.slice(N))?(u(T.slice(N+1)),c(!0)):c(!1)}function y(b){const E=a.current;if(!E)return;const _=E.selectionStart||0,T=E.value.slice(0,_),N=E.value.slice(_),q=T.lastIndexOf("@");if(q<0)return;const L=T.slice(0,q)+"@"+b+N;t(L),c(!1),requestAnimationFrame(()=>{const O=q+1+b.length;E.focus(),E.setSelectionRange(O,O)})}function v(b){s&&(b.key==="ArrowDown"?(b.preventDefault(),f(E=>(E+1)%Math.max(h.length,1))):b.key==="ArrowUp"?(b.preventDefault(),f(E=>(E-1+h.length)%Math.max(h.length,1))):b.key==="Enter"?h[d]&&(b.preventDefault(),y(h[d])):b.key==="Escape"&&c(!1))}return p.jsxs("div",{className:"nodrag nowheel relative w-full",children:[p.jsx("div",{ref:o,"aria-hidden":!0,className:"lcv-mention-backdrop rounded-md border-surface-border font-mono text-[12.5px] leading-snug",dangerouslySetInnerHTML:{__html:Vq(e||"")}}),p.jsx("textarea",{ref:a,value:e,onChange:m,onKeyDown:v,onScroll:g,placeholder:r||"e.g. @status == 'completed' AND @amount > 100",rows:i,spellCheck:!1,className:"nodrag relative z-10 w-full resize-none rounded-md border border-surface-border bg-transparent px-2.5 py-2 font-mono text-[12.5px] leading-snug text-ink outline-none focus:border-accent-default",style:{caretColor:"rgb(var(--ink))"}}),s&&h.length>0&&p.jsx("ul",{className:"absolute left-2 top-full z-20 mt-1 max-h-44 w-56 overflow-y-auto rounded-md border border-surface-border bg-surface-raised text-[12px] shadow-2xl",children:h.map((b,E)=>p.jsxs("li",{className:"flex cursor-pointer items-center gap-2 px-2 py-1 "+(E===d?"bg-accent-soft text-accent-ink":""),onMouseEnter:()=>f(E),onMouseDown:_=>{_.preventDefault(),y(b)},children:[p.jsx("span",{className:"font-mono text-fg-muted",children:"@"}),p.jsx("span",{className:"font-mono",children:b})]},b))})]})}function Wq({id:e,data:t,selected:n}){const r=jt(),[i,a]=S.useState(t.expression||""),o=Gl.filter,s=t.upstreamColumns||[];function c(l){a(l),r.setNodes(u=>u.map(d=>d.id===e?{...d,data:{...d.data,expression:l}}:d))}return p.jsxs("div",{className:Pe("rounded-lg border bg-surface-raised text-ink shadow-lg",n?"border-accent-default":"border-surface-border"),style:{minWidth:260,maxWidth:340,borderLeft:`3px solid ${o}`},children:[p.jsx(ut,{type:"target",position:Y.Left,id:"in",className:"lcv-handle",style:{background:o}}),p.jsxs("div",{className:"flex items-center gap-1.5 border-b border-surface-border px-3 py-1.5",children:[p.jsx(kv,{size:11,style:{color:o}}),p.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-wide",style:{color:o},children:"where"}),p.jsx("span",{className:"ml-auto text-[10px] text-fg-muted",children:"filter"})]}),p.jsx("div",{className:"nodrag nowheel px-2 pb-2 pt-1",children:p.jsx(Kq,{value:i,onChange:c,columns:s,rows:3})}),p.jsx(ut,{type:"source",position:Y.Right,id:"out",className:"lcv-handle",style:{background:o}}),p.jsx(fa,{nodeId:e,visible:!!n})]})}const Yq=S.memo(Wq);function Xq({id:e,data:t,selected:n}){const r=jt(),i=M0(),a=t.logoKey?i.get(t.logoKey):void 0,o=Vd(a),[s,c]=S.useState(t.label||a?.label||"");function l(u){c(u),r.setNodes(d=>d.map(f=>f.id===e?{...f,data:{...f.data,label:u}}:f))}return p.jsxs("div",{className:Pe("relative flex h-full w-full flex-col items-center justify-between rounded-lg border bg-surface-raised p-2 text-ink shadow-lg",n?"border-accent-default":"border-surface-border"),children:[p.jsx(Fl,{isVisible:n,minWidth:96,minHeight:96,keepAspectRatio:!0}),p.jsx(ut,{type:"target",position:Y.Left,id:"in",className:"lcv-handle",style:{background:"rgb(var(--accent))"}}),p.jsx("div",{className:"flex flex-1 items-center justify-center overflow-hidden",children:o?p.jsx("img",{src:o,alt:a?.label||t.logoKey||"",className:"max-h-full max-w-full object-contain",draggable:!1}):p.jsx("span",{className:"font-mono text-[11px] text-fg-muted",children:"(missing logo)"})}),p.jsx("input",{value:s,onChange:u=>l(u.target.value),placeholder:a?.label||t.logoKey||"",spellCheck:!1,className:"nodrag mt-1 w-full rounded bg-transparent text-center text-[11px] text-ink outline-none placeholder:text-fg-muted"}),p.jsx(ut,{type:"source",position:Y.Right,id:"out",className:"lcv-handle",style:{background:"rgb(var(--accent))"}}),p.jsx(fa,{nodeId:e,visible:!!n})]})}const Zq=S.memo(Xq),Qq={join:Tv,aggregate:Cv,function:Av,projection:Nv},Jq={join:"join",aggregate:"group by",function:"fn",projection:"select"},eO={join:"customers.id = orders.customer_id",aggregate:"country, status",function:"round(amount, 2) AS amount_r",projection:"id, name, status"};function tO({id:e,data:t,selected:n}){const r=jt(),[i,a]=S.useState(t.expression||""),o=Gl[t.opKind]??Gl.function,s=Qq[t.opKind]??Av;function c(l){a(l),r.setNodes(u=>u.map(d=>d.id===e?{...d,data:{...d.data,expression:l}}:d))}return p.jsxs("div",{className:Pe("rounded-lg border bg-surface-raised text-ink shadow-lg",n?"border-accent-default":"border-surface-border"),style:{minWidth:240,maxWidth:340,borderLeft:`3px solid ${o}`},children:[p.jsx(ut,{type:"target",position:Y.Left,id:"in",className:"lcv-handle",style:{background:o}}),p.jsxs("div",{className:"flex items-center gap-1.5 border-b border-surface-border px-3 py-1.5",children:[p.jsx(s,{size:11,style:{color:o}}),p.jsx("span",{className:"text-[12px] font-semibold uppercase tracking-wide",style:{color:o},children:Jq[t.opKind]||t.opKind})]}),p.jsx("div",{className:"nodrag nowheel px-2 pb-2 pt-1",children:p.jsx("textarea",{value:i,onChange:l=>c(l.target.value),rows:3,spellCheck:!1,placeholder:eO[t.opKind]||"expression…",className:"block w-full resize-none rounded border border-surface-border bg-transparent px-2 py-1.5 font-mono text-[12.5px] leading-snug text-ink outline-none focus:border-accent-default"})}),p.jsx(ut,{type:"source",position:Y.Right,id:"out",className:"lcv-handle",style:{background:o}}),p.jsx(fa,{nodeId:e,visible:!!n})]})}const nO=S.memo(tO),rO={table:Gq,filter:Yq,operator:nO,comment:Lq,logo:Zq};function vv(e){return e==="filter"?"filter":"operator"}async function iO(e){return En("/api/lineage/manual",{method:"POST",body:JSON.stringify(e)})}async function aO(e){return En(`/api/lineage/by-id/${e}`)}function oO(e){const{primaryProfile:t,artifactName:n,anchorFqn:r}=e,i=[],a=[],o=[],s=[],c=[],l=new Map,u=new Set;for(const d of e.nodes)if(d.data.kind==="table")l.set(d.id,d.data),i.push({profile:d.data.profile||t,fqn:d.data.fqn,x:d.position.x,y:d.position.y,width:d.width||240,height:d.height||120,logo_key:d.data.logoKey||""});else if(d.data.kind==="operator"){const f=d.data;u.add(d.id),o.push({node_id:d.id,op_kind:f.opKind,expression:f.expression||"",x:d.position.x,y:d.position.y,width:d.width||240,height:d.height||120})}else if(d.data.kind==="comment"){const f=d.data;s.push({x:d.position.x,y:d.position.y,width:d.width||240,height:d.height||140,color:String(f.color||"amber"),text:f.text||"",style:f.style||"note"})}else d.data.kind==="logo"&&c.push({logo_key:d.data.logoKey,label:d.data.label||"",x:d.position.x,y:d.position.y,width:d.width||120,height:d.height||120});for(const d of e.edges){const f=l.get(d.source),h=l.get(d.target),g=u.has(d.source),m=u.has(d.target);if(!f&&!g||!h&&!m)continue;const y=d.data;a.push({source_fqn:f?.fqn,source_profile:f?f.profile||t:void 0,source_node_id:g?d.source:void 0,target_fqn:h?.fqn,target_profile:h?h.profile||t:void 0,target_node_id:m?d.target:void 0,source_column:d.sourceHandle||void 0,target_column:d.targetHandle||void 0,style_color:y?.styleColor??null,style_dashed:y?.styleDashed??null,cardinality:y?.cardinality??null})}return{profile:t,name:n,anchor_fqn:r,artifact_id:e.artifactId??null,nodes:i,edges:a,operators:o,comments:s,logo_nodes:c}}const sO=1;function cO(e){const t=new Set;e.nodes.forEach(o=>o.profile&&t.add(o.profile));const n=t.size>sO,r=e.nodes.map(o=>uO(o,{multiProfile:n,isAnchor:o.entity_id===e.anchor_entity_id}));for(const o of e.comments)r.push({id:`comment-${o.id}`,type:"comment",position:{x:o.x,y:o.y},width:o.width,height:o.height,data:{kind:"comment",id:`comment-${o.id}`,commentId:o.id,color:o.color||"amber",text:o.text,style:o.style==="text"?"text":"note"},dragHandle:".lcv-comment-grip"});for(const o of e.logo_nodes??[])r.push({id:`logo-${o.id}`,type:"logo",position:{x:o.x,y:o.y},width:o.width,height:o.height,data:{kind:"logo",id:`logo-${o.id}`,logoKey:o.logo_key,label:o.label||o.logo_label||"",logoNodeId:o.id}});const i=new Map;for(const o of e.nodes)i.set(o.entity_id,zr(o));const a=[];for(const o of e.edges){const s=i.get(o.from_entity_id),c=i.get(o.to_entity_id);!s||!c||a.push(O0(o,s,c))}return{primaryProfile:e.primary_profile,artifactId:e.artifact_id,artifactName:e.name,anchorEntityId:e.anchor_entity_id,nodes:r,edges:a,multiProfile:n}}function zr(e){return`n-${e.entity_id}`}function uO(e,t){if(e.kind==="operator"){const n=(e.op_kind||"").toLowerCase(),i=new Set(["filter","join","aggregate","function","projection"]).has(n)?n:"function";return{id:zr(e),type:"operator",position:{x:e.x,y:e.y},data:{kind:"operator",id:zr(e),opKind:i,expression:e.expression??"",operatorId:e.entity_id},sourcePosition:Y.Right,targetPosition:Y.Left}}return{id:zr(e),type:"table",position:{x:e.x,y:e.y},data:{kind:"table",id:zr(e),profile:e.profile,database:e.database,schema:e.schema,table:e.table,fqn:e.fqn,columns:Array.isArray(e.columns)?e.columns:[],entityId:e.entity_id,showProfileChip:t.multiProfile,isAnchor:t.isAnchor,logoKey:e.logo_key||void 0},sourcePosition:Y.Right,targetPosition:Y.Left}}function O0(e,t,n){const r=vn[e.relationship_type]??vn.unknown,i=e.relationship_type==="name_match"||e.relationship_type==="lineage_llm"&&e.score<.7,a=e.style_color??void 0,o=e.style_dashed??void 0,s=e.cardinality??void 0,c=a??r,l=o??i;return{id:`e-${e.id}`,source:t,target:n,sourceHandle:e.from_column||void 0,targetHandle:e.to_column||void 0,type:"column-edge",data:{relationshipType:e.relationship_type,source:e.source,confidence:e.score,verdict:e.verdict,edgeId:e.id,hoverLabel:lO(e),styleColor:a,styleDashed:o,cardinality:s},style:{stroke:c,strokeWidth:e.score>=.9?1.6:1.1,strokeDasharray:l?"5 4":void 0}}}function lO(e){const t=e.score>=.001?` · ${Math.round(e.score*100)}%`:"";return`${e.relationship_type}${t}`}function bv(e){const t=e.database?`${e.database}.${e.schema}.${e.table}`:`${e.schema}.${e.table}`,n=e.entityId?`n-${e.entityId}`:`n-tmp-${t}-${e.profile}`;return{id:n,type:"table",position:e.position,data:{kind:"table",id:n,profile:e.profile,database:e.database,schema:e.schema,table:e.table,fqn:t,columns:e.columns,entityId:e.entityId,showProfileChip:e.multiProfile,isAnchor:e.isAnchor},sourcePosition:Y.Right,targetPosition:Y.Left}}const dO="name-match-local",xv=.5;function _v(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"")}function fO(e,t){const n=e.filter(c=>c.data.kind==="table");if(n.length<2)return{edges:[],pairsSkippedForMissingColumns:0};const r=Math.max(1,t.maxPerPair??12),i=new Set;for(const c of t.existingEdges){const l=c.sourceHandle||"",u=c.targetHandle||"";i.add(`${c.source}|${l}|${c.target}|${u}`),i.add(`${c.target}|${u}|${c.source}|${l}`)}const a=vn.name_match,o=[];let s=0;for(let c=0;c<n.length;c+=1)for(let l=c+1;l<n.length;l+=1){const u=n[c],d=n[l],f=u.data.columns??[],h=d.data.columns??[];if(f.length===0||h.length===0){s+=1;continue}const g=new Map;for(const v of f){const b=_v(v.name);b&&g.set(b,v.name)}const m=[];for(const v of h){const b=_v(v.name),E=g.get(b);E&&m.push({aName:E,bName:v.name})}m.sort((v,b)=>v.aName.localeCompare(b.aName));const y=m.slice(0,r);for(const v of y){const b=`${u.id}|${v.aName}|${d.id}|${v.bName}`;i.has(b)||(i.add(b),i.add(`${d.id}|${v.bName}|${u.id}|${v.aName}`),o.push({id:`${dO}-${u.id}-${v.aName}-${d.id}-${v.bName}`,source:u.id,target:d.id,sourceHandle:v.aName,targetHandle:v.bName,type:"column-edge",data:{relationshipType:"name_match",source:"name_match_heuristic",confidence:xv,verdict:"",hoverLabel:`${v.aName} → ${v.bName}
Name match
Confidence ${Math.round(xv*100)}% (low)`},style:{stroke:a,strokeWidth:1.1,strokeDasharray:"5 4"}}))}}return{edges:o,pairsSkippedForMissingColumns:s}}function hO(e,t){const n=e.measured,r=e.width??n?.width??320,i=e.height??n?.height??200;return{x:e.position.x-t/2,y:e.position.y-t/2,width:r+t,height:i+t}}function pO(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function kr({existing:e,hint:t,size:n,gutter:r=32,maxRing:i=24}){const a=e.filter(l=>l.position&&l.data).map(l=>hO(l,r)),o=(l,u)=>({x:l-r/2,y:u-r/2,width:n.width+r,height:n.height+r}),s=(l,u)=>a.every(d=>!pO(o(l,u),d));if(s(t.x,t.y))return t;const c=Math.max(160,Math.min(n.width,n.height)+r);for(let l=1;l<=i;l+=1)for(let u=-l;u<=l;u+=1)for(let d=-l;d<=l;d+=1){if(Math.abs(u)!==l&&Math.abs(d)!==l)continue;const f=t.x+u*c,h=t.y+d*c;if(s(f,h))return{x:f,y:h}}return{x:t.x,y:t.y+(i+1)*c}}function wv(e,t){if(!e)return{x:200,y:200};const n=e.getBoundingClientRect();return t({x:n.left+n.width/2,y:n.top+n.height/2})}async function gO(e,t){return En("/api/lineage/sql/parse",{method:"POST",body:JSON.stringify({sql:e,dialect:t})})}async function mO(e,t){return En("/api/lineage/sql/render",{method:"POST",body:JSON.stringify({canvas:e,dialect:t})})}const yO={postgresql:"postgres",postgres:"postgres",mysql:"mysql",snowflake:"snowflake",databricks:"databricks",bigquery:"bigquery",redshift:"redshift",trino:"trino",presto:"trino",hive:"hive"};function vO(e){return e?yO[String(e).toLowerCase()]??"":""}function bO(){return p.jsx(xd,{children:p.jsx(xO,{})})}function xO(){const e=td(),t=gr(),[n,r]=P0(),i=n.get("artifact")?Number(n.get("artifact")):null,[a,o]=S.useState([]),[s,c]=S.useState([]),[l,u]=S.useState(""),[d,f]=S.useState(""),[h,g]=S.useState(i),[m,y]=S.useState(!1),[v,b]=S.useState(!1),[E,_]=S.useState(!1),[T,N]=S.useState(!1),[q,L]=S.useState(!1),[O,R]=S.useState(!1),[I,G]=S.useState(!1),[H,x]=S.useState(!1),[M,k]=S.useState(!1),[z,P]=S.useState(!1),[C,j]=S.useState(""),[$,U]=S.useState(""),[K,V]=S.useState(null),[se,re]=S.useState(""),[de,ie]=S.useState(""),he=S.useRef(null),ue=S.useRef(null),[ve,qe]=S.useState(void 0),Oe=tM(),Re=XM(),te=jt();S.useLayoutEffect(()=>{function A(){const B=ue.current;if(!B)return;const J=B.getBoundingClientRect().top,Z=Math.max(360,window.innerHeight-J-32);qe(Z)}return A(),window.addEventListener("resize",A),()=>window.removeEventListener("resize",A)},[]);const we=Dn({queryKey:["lineage-canvas",i],queryFn:()=>i?aO(i):null,enabled:!!i});S.useEffect(()=>{if(we.data){const A=cO(we.data);o(A.nodes),c(A.edges),u(A.primaryProfile),f(A.artifactName),g(A.artifactId),b(!1)}},[we.data]);const ee=n.get("seed");S.useEffect(()=>{if(!ee||i)return;const A=ee.split("|");if(A.length<4)return;const[B,J,X,Z,ae=""]=A;if(!B||!Z)return;Ie({profile:B,backend:ae,database:J,schema:X,table:Z,columns:[]});const _e=new URLSearchParams(n);_e.delete("seed"),r(_e,{replace:!0})},[ee,i]);const W=S.useCallback(A=>{o(B=>Db(A,B)),A.some(B=>B.type==="remove"||B.type==="add"||B.type==="dimensions"||B.type==="position"&&B.dragging===!1)&&b(!0)},[]),pe=S.useCallback(A=>{c(B=>fC(A,B)),A.some(B=>B.type==="remove"||B.type==="add")&&b(!0)},[]),et=S.useCallback(A=>{if(!A.source||!A.target||A.source===A.target)return;const B=`manual-${A.source}-${A.target}-${A.sourceHandle||""}-${A.targetHandle||""}`;c(J=>{if(J.some(Z=>Z.id===B))return J;const X={id:B,source:A.source,target:A.target,sourceHandle:A.sourceHandle||void 0,targetHandle:A.targetHandle||void 0,type:"column-edge",data:{relationshipType:"lineage_manual",source:"manual",confidence:1,verdict:"approved",hoverLabel:"manual"},style:{stroke:vn.lineage_manual,strokeWidth:1.6}};return mb(X,J)}),b(!0)},[]);function je(){if(!l){const A=a.find(B=>B.data.kind==="table");A&&A.data.kind==="table"&&u(A.data.profile)}}function Ie(A){const B=vO(A.backend),J=wv(he.current,X=>te.screenToFlowPosition(X));o(X=>{const Z=X.filter(fe=>fe.data.kind==="table").length,ae=X.some(fe=>fe.data.kind==="table"&&fe.data.profile&&fe.data.profile!==A.profile),_e=kr({existing:X,hint:J,size:{width:320,height:180}}),oe=bv({...A,position:_e,multiProfile:ae,isAnchor:Z===0});B&&oe.data.kind==="table"&&(oe.data.logoKey=B);const ce=X.findIndex(fe=>fe.id===oe.id);if(ce>=0){const fe=X.slice(),it=fe[ce];return it.data.kind==="table"&&oe.data.kind==="table"&&(fe[ce]={...it,data:{...it.data,columns:oe.data.columns.length?oe.data.columns:it.data.columns}}),fe}const Te=[...X,oe];return ae?Te.map(fe=>fe.data.kind==="table"?{...fe,data:{...fe.data,showProfileChip:!0}}:fe):Te}),l||u(A.profile),b(!0)}function xe(){return wv(he.current,A=>te.screenToFlowPosition(A))}function Ce(A){const B=`op-tmp-${A}-${Date.now()}`,J=xe();o(X=>{const Z=kr({existing:X,hint:J,size:{width:300,height:200}}),ae={id:B,type:vv(A),position:Z,width:300,height:200,data:{kind:"operator",id:B,opKind:A,expression:"",upstreamColumns:[]}};return[...X,ae]}),b(!0)}function Le(A){const B=`logo-tmp-${A.key}-${Date.now()}`,J=xe();o(X=>{const Z=kr({existing:X,hint:J,size:{width:120,height:120}}),ae={id:B,type:"logo",position:Z,width:120,height:120,data:{kind:"logo",id:B,logoKey:A.key,label:A.label}};return[...X,ae]}),b(!0)}function Ge(){const A=`comment-tmp-${Date.now()}`,B=xe();o(J=>{const X=kr({existing:J,hint:B,size:{width:220,height:140}}),Z={id:A,type:"comment",position:X,width:220,height:140,data:{kind:"comment",id:A,color:"amber",text:"",style:"note"},dragHandle:".lcv-comment-grip"};return[...J,Z]}),b(!0)}function ze(){const A=`text-tmp-${Date.now()}`,B=xe();o(J=>{const X=kr({existing:J,hint:B,size:{width:220,height:36}}),Z={id:A,type:"comment",position:X,width:220,height:36,data:{kind:"comment",id:A,color:"amber",text:"",style:"text"}};return[...J,Z]}),b(!0)}async function Ne(){const A=a.filter(oe=>oe.data.kind==="table");if(A.length<2)return 0;const B=[],J=[];for(const oe of A){const ce=oe.data;typeof ce.entityId=="number"&&ce.entityId>0?B.push(ce.entityId):ce.profile&&ce.fqn&&J.push({profile:ce.profile,fqn:ce.fqn})}if(B.length+J.length<2)return 0;let X;try{X=await Y0({entityIds:B,tables:J})}catch{return 0}if(X.edges.length===0)return 0;const Z=new Map,ae=new Map;for(const oe of A){const ce=oe.data;if(typeof ce.entityId=="number"&&ce.entityId>0&&Z.set(ce.entityId,oe.id),ce.fqn){ae.set(ce.fqn,oe.id);const Te=ce.fqn.split(".");if(Te.length>=3){const fe=Te.slice(-2).join(".");ae.has(fe)||ae.set(fe,oe.id)}}}let _e=0;return c(oe=>{const ce=[...oe],Te=new Set(ce.map(fe=>fe.id));for(const fe of X.edges){const it=Z.get(fe.from_entity_id),pt=Z.get(fe.to_entity_id);if(!it||!pt)continue;const gt=O0(fe,it,pt);Te.has(gt.id)||(Te.add(gt.id),ce.push(gt),_e+=1)}return ce}),_e>0&&b(!0),_e}async function Fe(){const B=te.getNodes().filter(Z=>Z.data.kind==="table").filter(Z=>{const ae=Z.data;return(ae.columns?.length??0)===0&&ae.profile&&ae.table});if(B.length===0)return 0;const J=await Promise.all(B.map(Z=>{const ae=Z.data;return Hl({profile:ae.profile,database:ae.database||"",schema:ae.schema||"",table:ae.table}).then(_e=>({id:Z.id,cols:_e})).catch(()=>({id:Z.id,cols:[]}))}));let X=0;return te.setNodes(Z=>Z.map(ae=>{const _e=J.find(oe=>oe.id===ae.id);return!_e||_e.cols.length===0||ae.data.kind!=="table"?ae:(X+=1,{...ae,data:{...ae.data,columns:_e.cols}})})),X}async function Ve(){const A=await Ne();await Fe();const B=te.getNodes(),J=te.getEdges(),X=fO(B,{existingEdges:J});let Z=0;X.edges.length>0&&te.setEdges(oe=>{const ce=[...oe],Te=new Set(ce.map(fe=>fe.id));for(const fe of X.edges)Te.has(fe.id)||(Te.add(fe.id),ce.push(fe),Z+=1);return ce});const ae=A+Z;ae>0&&b(!0);const _e=[];A&&_e.push(`${A} catalog`),Z&&_e.push(`${Z} name-match`),e.push({title:"Discover related",description:ae?`Added ${_e.join(" + ")} edge${ae===1?"":"s"}.`:"No additional edges between the tables on canvas.",tone:ae?"success":"info"})}function Ae(){const A=te.getNodes(),B=te.getEdges();let J;$&&(J=A.find(ae=>ae.data.kind==="table"&&ae.data.fqn===$)?.id);const X=Oe(A,B,{anchorId:J});te.setNodes(X),requestAnimationFrame(()=>{te.fitView({padding:.2,duration:300})})}const Ze=S.useRef(new Map),$e=S.useRef(0),Ke=ZM({onBatch:A=>{const B=[],J=new Map;Ze.current=J,o(X=>{const Z=[...X];for(const ke of Z)if(ke.data.kind==="table"){const tt=ke.data.fqn;if(!tt)continue;J.set(tt,ke.id);const lt=tt.split(".");if(lt.length>=3){const Ft=lt.slice(-2).join(".");J.has(Ft)||J.set(Ft,ke.id)}}const ae=$?Z.find(ke=>ke.data.kind==="table"&&ke.data.fqn===$):void 0,_e=ae?.data.kind==="table"?ae.data:void 0,oe=_e?.database||"",ce=_e?.profile||l,Te=_e?.logoKey||"",fe=ae?.position?.x??320,it=ae?.position?.y??200;let pt=0;const gt=ke=>{if(!ke)return"";const tt=J.get(ke);if(tt)return tt;const lt=ke.split("."),Ft=lt.length>2?lt[0]:oe,Vn=lt.length>1?lt[lt.length-2]:"",Cn=lt[lt.length-1],Nn=pt%8,An=Math.floor(pt/8),Xt=Nn*(Math.PI/4),ne=280+An*200;pt+=1;const w=`n-fqn-${ke}`,F={id:w,type:"table",position:{x:fe+ne*Math.cos(Xt),y:it+ne*Math.sin(Xt)},data:{kind:"table",id:w,profile:ce,database:Ft,schema:Vn,table:Cn,fqn:ke,columns:[],...Te?{logoKey:Te}:{}}};return Z.push(F),J.set(ke,w),B.push({id:w,database:Ft,schema:Vn,table:Cn}),w};for(const ke of A.edges)ke.from&&ke.from===ke.to||(gt(ke.from),gt(ke.to));return $e.current+=B.length,B.length>0&&b(!0),Z}),B.length&&l&&Promise.all(B.map(X=>Hl({profile:l,database:X.database,schema:X.schema,table:X.table}).then(Z=>({id:X.id,cols:Z})).catch(()=>({id:X.id,cols:[]})))).then(X=>{o(Z=>Z.map(ae=>{const _e=X.find(oe=>oe.id===ae.id);return!_e||_e.cols.length===0?ae:ae.data.kind==="table"?{...ae,data:{...ae.data,columns:_e.cols}}:ae}))}),c(X=>{const Z=[...X],ae=new Set(Z.map(oe=>oe.id)),_e=Ze.current;for(const oe of A.edges){if(oe.from&&oe.from===oe.to)continue;const ce=_e.get(oe.from)??`n-fqn-${oe.from}`,Te=_e.get(oe.to)??`n-fqn-${oe.to}`,fe=`${A.extractor}-${ce}-${Te}-${oe.from_column||""}-${oe.to_column||""}`;if(ae.has(fe))continue;ae.add(fe);const it=vn[oe.type]??vn.unknown,pt=oe.type==="name_match"||oe.type==="lineage_llm"&&oe.confidence<.7,gt=XN({fromColumn:oe.from_column,toColumn:oe.to_column,type:oe.type,confidence:oe.confidence,dashed:pt});Z.push({id:fe,source:ce,target:Te,sourceHandle:oe.from_column||void 0,targetHandle:oe.to_column||void 0,type:"column-edge",className:"lcv-edge-fadein",data:{relationshipType:oe.type,source:oe.extractor,confidence:oe.confidence,verdict:"",hoverLabel:gt},style:{stroke:it,strokeWidth:oe.confidence>=.9?1.6:1.1,strokeDasharray:pt?"5 4":void 0}})}return Z})},onWarning:A=>e.push({title:"AI warning",description:A,tone:"warning"}),onError:A=>{e.push({title:"AI stream error",description:A,tone:"error"}),y(!1)},onDone:A=>{y(!1),e.push({title:"Generation complete",description:`${A.total_edges} edge(s) streamed in.`,tone:"success"}),Ne(),$e.current>0&&window.setTimeout(()=>Ae(),80)}});function qt(){if(!l||!$){e.push({title:"Pick anchor + profile first",tone:"warning"});return}const A=a.find(X=>X.data.kind==="table"&&X.data.fqn===$),B=A?.data.kind==="table"&&A.data.database||"",J=A?.data.kind==="table"&&A.data.profile||l;y(!0),G(!1),$e.current=0,Ke.start($,{profile:J,database:B})}const Qe=Pi({mutationFn:async()=>{je();const A=l;if(!A)throw new Error("Pick at least one table first to bind the profile.");const B=a.filter(Z=>Z.data.kind==="table");if(B.length===0)throw new Error("Add at least one node.");if(!C.trim())throw new Error("Give the canvas a name.");const J=B[0].data.fqn,X=oO({primaryProfile:A,artifactName:C.trim(),anchorFqn:J,artifactId:h,nodes:a,edges:s});return iO(X)},onSuccess:A=>{e.push({title:"Canvas saved",description:`Persisted ${A.persisted_edges} edge(s).`,tone:"success"}),R(!1),g(A.artifact_id),r({artifact:String(A.artifact_id)}),t.invalidateQueries({queryKey:["lineage-artifacts"]}),b(!1),V(null)},onError:A=>{const B=A;if(B instanceof K0&&B.status===409){const J=B.data||{},X=typeof J.existing_id=="number"?J.existing_id:null,Z=typeof J.existing_name=="string"?J.existing_name:C.trim();V({existingId:X,existingName:Z});return}e.push({title:"Save failed",description:A.message,tone:"error"})}});async function ht(){if(he.current)try{await Re(he.current,`${(d||"lineage").replace(/[^A-Za-z0-9_-]+/g,"_")}.png`)}catch(A){e.push({title:"PNG export failed",description:A.message,tone:"error"})}}async function st(){try{const A=await gO(se);x(!1),re("");const B=[];let J=80;for(const Z of A.tables)B.push(bv({profile:l,database:"",schema:Z.schema,table:Z.table,columns:Z.columns.map(ae=>({name:ae,dtype:"unknown"})),position:{x:J,y:100},multiProfile:!1})),J+=280;let X=320;for(const Z of A.operators)B.push({id:Z.id,type:vv(Z.kind),position:{x:200,y:X},data:{kind:"operator",id:Z.id,opKind:Z.kind,expression:Z.expression,upstreamColumns:[]}}),X+=140;o(Z=>[...Z,...B]),e.push({title:"SQL imported",description:`${A.tables.length} table(s), ${A.operators.length} operator(s).`,tone:"success"})}catch(A){e.push({title:"SQL parse failed",description:A.message,tone:"error"})}}async function Nt(){try{const A={tables:a.filter(J=>J.data.kind==="table").map(J=>{const X=J.data;return{id:X.fqn,schema:X.schema,table:X.table,columns:(X.columns||[]).map(Z=>Z.name)}}),operators:a.filter(J=>J.data.kind==="operator").map(J=>{const X=J.data;return{id:X.id,kind:X.opKind,expression:X.expression}})},B=await mO(A);ie(B.sql),k(!0)}catch(A){e.push({title:"SQL render failed",description:A.message,tone:"error"})}}function Ot(A){a.find(J=>J.id===A)&&o(J=>J.map(X=>({...X,selected:X.id===A})))}function Kt(A,B){o(J=>J.map(X=>X.data.kind!=="table"||X.id!==A?X:{...X,data:{...X.data,tracedColumn:B}}))}S.useEffect(()=>{function A(B){const J=B.metaKey||B.ctrlKey;J&&B.key==="k"?(B.preventDefault(),N(!0)):J&&B.shiftKey&&B.key.toLowerCase()==="f"?(B.preventDefault(),L(!0)):J&&B.key==="s"&&(B.preventDefault(),C||j(d||`canvas-${Date.now()}`),R(!0))}return window.addEventListener("keydown",A),()=>window.removeEventListener("keydown",A)},[C,d]);async function Un(){if(!h){e.push({title:"Save first",description:"Sharing needs a persisted canvas."});return}const A=`${window.location.origin}/lineage?artifact=${h}`;try{await navigator.clipboard.writeText(A),e.push({title:"Link copied",description:A,tone:"success"})}catch{e.push({title:"Could not copy",description:A,tone:"warning"})}}function _t(A){if(A.target instanceof HTMLInputElement||A.target instanceof HTMLTextAreaElement||A.target instanceof HTMLElement&&A.target.isContentEditable||A.metaKey||A.ctrlKey||A.altKey)return;const B=A.key.toLowerCase();B==="d"?_(!0):B==="f"?Ce("filter"):B==="e"?Ce("function"):B==="g"?Ce("aggregate"):B==="j"?Ce("join"):B==="c"?Ge():B==="t"?ze():B==="i"?P(!0):B==="l"&&Ae()}const Wt=S.useMemo(()=>a.filter(A=>A.data.kind==="table"),[a]),Bn=v&&a.length>0;function Yt(A){r({artifact:String(A)})}function Gn(){o([]),c([]),u(""),f(""),g(null),r({}),b(!1)}function wr(){Bn&&!window.confirm("Discard the current canvas and start a new lineage?")||(Gn(),U(""),j(""))}return p.jsxs("div",{ref:ue,className:"flex flex-col gap-2",style:{height:ve},children:[p.jsx(X0,{title:"Lineage",breadcrumbs:[{label:"Lineage",to:"/lineage"}],description:"AI-generated and hand-authored data lineage across every cached profile."}),p.jsx(nA,{primaryProfile:l,onAddTable:()=>_(!0),onAddFilter:()=>Ce("filter"),onAddJoin:()=>Ce("join"),onAddAggregate:()=>Ce("aggregate"),onAddFunction:()=>Ce("function"),onAddComment:Ge,onAddText:ze,onAddLogo:()=>P(!0),onUndo:()=>e.push({title:"Undo/Redo wiring in progress"}),onRedo:()=>e.push({title:"Undo/Redo wiring in progress"}),canUndo:!1,canRedo:!1,onAutoLayout:Ae,onGenerateAI:()=>{je(),U(Wt[0]?Wt[0].data.fqn:""),G(!0)},generating:m,onSearch:()=>N(!0),onTrackAttribute:()=>L(!0),onSave:()=>{C||j(d||`canvas-${Date.now()}`),R(!0)},onExportPng:ht,onShare:Un,onImportSql:()=>x(!0),onExportSql:Nt,hasUnsavedWork:Bn,activeArtifactId:h,onOpenSavedArtifact:Yt,onActiveSavedArtifactDeleted:Gn,onDiscoverRelated:()=>void Ve(),onNewLineage:wr}),p.jsxs("div",{ref:he,className:"lcv-canvas-root relative min-h-0 flex-1 overflow-hidden rounded-xl border border-surface-border",tabIndex:0,onKeyDown:_t,children:[p.jsx(VN,{}),p.jsxs("div",{className:"pointer-events-none absolute right-3 top-3 z-10 flex items-center gap-2",children:[m&&p.jsxs("div",{className:"inline-flex items-center gap-1.5 rounded-md bg-surface-raised/90 px-2 py-1 text-[11px] text-fg-muted shadow",children:[p.jsx(W0,{size:12,className:"animate-spin"}),"streaming AI batches…"]}),p.jsx(QN,{})]}),p.jsxs(Zb,{nodes:a,edges:s,nodeTypes:rO,edgeTypes:KN,onNodesChange:W,onEdgesChange:pe,onConnect:et,fitView:!0,fitViewOptions:{padding:.2},proOptions:{hideAttribution:!0},minZoom:.1,maxZoom:4,multiSelectionKeyCode:["Meta","Control"],selectionKeyCode:"Shift",deleteKeyCode:["Backspace","Delete"],nodesDraggable:!0,nodesConnectable:!0,elementsSelectable:!0,children:[p.jsx(vN,{gap:20,size:1}),p.jsx(dN,{showInteractive:!1})]})]}),p.jsx(jN,{open:E,onClose:()=>_(!1),defaultProfile:l,onPick:Ie,onBatchAdded:A=>{A>1&&window.setTimeout(()=>Ae(),60)}}),p.jsx(q0,{open:z,onClose:()=>P(!1),onPick:Le,title:"Add a logo node"}),p.jsx(JN,{open:T,onClose:()=>N(!1),nodes:a,onSelect:Ot}),p.jsx($N,{open:q,onClose:()=>L(!1),nodes:a,onHighlight:Kt}),p.jsx(ar,{open:O,onClose:()=>{R(!1),V(null)},title:p.jsx("span",{children:"Save canvas"}),description:"Persist this canvas as a lineage artifact. The artifact id is the identifier we use to re-open it — the name is purely display.",footer:p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx(Et,{variant:"secondary",size:"md",onClick:()=>{R(!1),V(null)},children:"Cancel"}),p.jsx(Et,{variant:"primary",size:"md",loading:Qe.isPending,disabled:!C.trim()||Qe.isPending||K!==null&&K.existingName.trim()===C.trim(),onClick:()=>Qe.mutate(),children:"Save"})]}),children:p.jsxs("label",{className:"block space-y-1 text-sm",children:[p.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-muted",children:"Canvas name"}),p.jsx("input",{type:"text",value:C,onChange:A=>{j(A.target.value),K&&K.existingName.trim()!==A.target.value.trim()&&V(null)},placeholder:"my-canvas",className:Pe("block w-full rounded-md border bg-surface-raised px-3 py-2 text-sm focus:outline-none",K&&K.existingName.trim()===C.trim()?"border-critical focus:border-critical":"border-surface-border focus:border-accent-default")}),K&&K.existingName.trim()===C.trim()&&p.jsxs("div",{className:"flex items-center justify-between gap-2 pt-1 text-[11.5px] text-critical",children:[p.jsx("span",{children:"⚠ Already used by another saved lineage. Rename or open it."}),K.existingId!==null&&p.jsx("button",{type:"button",onClick:()=>{const A=K.existingId;A!==null&&(R(!1),V(null),r({artifact:String(A)}))},className:"rounded border border-critical/40 px-2 py-0.5 text-[11px] text-critical transition hover:bg-critical-soft",children:"Open existing →"})]})]})}),p.jsx(ar,{open:I,onClose:()=>G(!1),title:p.jsx("span",{children:"AI Generate lineage"}),description:"AMX walks every cached extractor (FK, view DDL, query log, codebase, prior LLM verdicts) and streams edges into the canvas as each batch completes.",footer:p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx(Et,{variant:"secondary",size:"md",onClick:()=>G(!1),children:"Cancel"}),p.jsx(Et,{variant:"primary",size:"md",onClick:qt,disabled:!$||!l,children:"Start streaming"})]}),children:p.jsx("div",{className:"space-y-3 text-sm",children:p.jsxs("label",{className:"block space-y-1",children:[p.jsx("span",{className:"text-[10px] uppercase tracking-wide text-fg-muted",children:"Anchor table"}),p.jsxs("select",{value:$,onChange:A=>U(A.target.value),className:"block w-full rounded-md border border-surface-border bg-surface-raised px-2 py-1.5 text-sm",children:[p.jsx("option",{value:"",children:"— pick anchor —"}),Wt.map(A=>{const B=A.data;return p.jsxs("option",{value:B.fqn,children:[B.fqn," (",B.profile,")"]},A.id)})]}),p.jsxs("p",{className:"text-[11px] text-fg-muted",children:["The streamed edges land relative to this anchor. Use the active primary profile"," ",p.jsx("span",{className:"font-mono",children:l||"(none)"}),"."]})]})})}),p.jsx(ar,{open:H,onClose:()=>x(!1),title:p.jsx("span",{children:"Import SQL"}),description:"Paste a SELECT and AMX will build the canvas nodes for it via sqlglot.",footer:p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx(Et,{variant:"secondary",size:"md",onClick:()=>x(!1),children:"Cancel"}),p.jsx(Et,{variant:"primary",size:"md",onClick:st,disabled:!se.trim(),children:"Parse"})]}),children:p.jsx("textarea",{rows:10,spellCheck:!1,value:se,onChange:A=>re(A.target.value),placeholder:"SELECT … FROM …",className:"block w-full rounded-md border border-surface-border bg-surface-raised px-2 py-2 font-mono text-[12.5px] outline-none focus:border-accent-default"})}),p.jsx(ar,{open:M,onClose:()=>k(!1),title:p.jsx("span",{children:"Export SQL"}),description:"The current canvas, composed back into a SELECT.",footer:p.jsxs("div",{className:"flex justify-end gap-2",children:[p.jsx(Et,{variant:"secondary",size:"md",onClick:()=>k(!1),children:"Close"}),p.jsx(Et,{variant:"primary",size:"md",onClick:async()=>{try{await navigator.clipboard.writeText(de),e.push({title:"Copied to clipboard",tone:"success"})}catch{e.push({title:"Copy failed",tone:"warning"})}},children:"Copy"})]}),children:p.jsx("pre",{className:"block max-h-80 w-full overflow-auto rounded-md border border-surface-border bg-surface px-3 py-2 font-mono text-[12px]",children:de})})]})}function qO(){return p.jsx(bO,{})}export{qO as default};
